员工数据录入

This commit is contained in:
dengwc 2024-03-09 13:43:58 +08:00
parent 4993beffc1
commit ff51999019
11 changed files with 289 additions and 73 deletions

View File

@ -93,6 +93,12 @@
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,41 @@
package com.chint.domain.aggregates.standards;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serializable;
/**
* 人员职级关系表(StaffRank)表实体类
*
* @author dengweichao
* @since 2024-03-09 10:35:08
*/
@Data
@Table("staff_rank")
public class StaffRank {
@Id
@ExcelIgnore
private Integer id;
//SF号
@ExcelProperty(index = 1)
private String employeeNo;
//员工名称
@ExcelProperty(index = 0)
private String employeeName;
//员工职级
@ExcelProperty(index = 2)
private String employeeLevel;
//公司标识1集团2新能
@ExcelIgnore
private String tag;
}

View File

@ -0,0 +1,24 @@
package com.chint.domain.aggregates.standards;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* 新能员工数据excel导入
*
* @author dengweichao
* @since 2024-03-09 10:35:08
*/
@Data
public class XNStaffRank {
//SF号
@ExcelProperty(index = 0)
private String nameAndSF;
//员工名称
@ExcelProperty(index = 1)
private String employeeLevel;
}

View File

@ -15,6 +15,9 @@ public class RankConstant {
public static final String STANDARD_LEVEL_DQXS_CODE = "";//电器销售编号
public static final String STANDARD_LEVEL_DQXS = "DQXS_";//电器销售
public static final String SHDY_COMPANY_CODE = "A20050001";//上海正泰电源系统有限公司
//集团差标等级
public static final String STANDARD_LEVEL_ONE = "JT_STANDARD_LEVEL_ONE";//差标1
public static final String STANDARD_LEVEL_TWO = "JT_STANDARD_LEVEL_TWO";//差标2

View File

@ -0,0 +1,11 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.standards.TravelStandards;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcStaffRank extends CrudRepository<StaffRank, Integer> {
}

View File

@ -22,6 +22,7 @@ import java.lang.reflect.Type;
import java.util.HashMap;
import static com.chint.infrastructure.constant.BPMConstant.*;
import static com.chint.infrastructure.constant.RankConstant.SHDY_COMPANY_CODE;
@Service
@ -39,6 +40,10 @@ public class BPMRequest {
@Value("${bpm.ZWBPMUrl}")
private String ZWBPMUrl;
@Value("${bpm.DYBPMUrl}")
private String DYBPMUrl;
//超标申请
public BPMResponse exceedStandard(ExceedStandardDto exceedStandardDto, String sysCode) {
return switch (sysCode) {
@ -96,11 +101,18 @@ public class BPMRequest {
String entityParamValues = gson.toJson(entityObject);
//获取用户信息
User user = BaseContext.getCurrentUser();
String companyCode = user.getCompanyCode();//公司编号
String url;
if (SHDY_COMPANY_CODE.equals(companyCode)) {
url = DYBPMUrl;
} else {
url = H3BPMUrl;
}
bpmRequest.setWorkflowCode(workflowCode)
.setUserCode(String.valueOf(user.getEmployeeNo()))//sf号
.setFinishStart(true)//true会自动流转到下一审批点false:停在手工填写节点
.setEntityParamValues(entityParamValues);
BPMBaseResponse bpmBaseResponse = httpPostRequest.post(H3BPMUrl + H3BPM_EXCEED_STANDARD_URL, bpmRequest, BPMBaseResponse.class);
BPMBaseResponse bpmBaseResponse = httpPostRequest.post(url + H3BPM_EXCEED_STANDARD_URL, bpmRequest, BPMBaseResponse.class);
System.out.println("response = " + bpmBaseResponse);
return bpmBaseResponse.getD();
}

View File

@ -70,6 +70,8 @@ feishu:
bpm:
#集团H3
H3BPMUrl: https://bpmtest10.chint.com
#电源
DYBPMUrl: http://10.207.0.245:8013
#新能
XNBPMUrl: http://10.145.30.119:8090
xn-client-id: xclient

View File

@ -83,6 +83,8 @@ feishu:
bpm:
#集团H3
H3BPMUrl: https://bpmtest10.chint.com
#电源
DYBPMUrl: http://10.207.0.245:8013
#新能
XNBPMUrl: http://10.145.30.119:8090
xn-client-id: xclient

View File

@ -0,0 +1,96 @@
package com.chint;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.standards.XNStaffRank;
import com.chint.infrastructure.repository.jdbc.JdbcStaffRank;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.File;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
@SpringBootTest
public class ExcelTest {
/**
* 读取excel
*/
@Autowired
private JdbcStaffRank jdbcStaffRank;
// @Test
// 集团员工数据导入
public void simpleRead() {
// 写法1JDK8+ ,不用额外写一个DemoDataListener
// since: 3.0.0-beta1
// String fileName = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
String fileName = "D:\\用户目录\\Downloads" + File.separator + "人员.xlsx";
// 这里默认每次会读取100条数据 然后返回过来 直接调用使用数据就行
// 具体需要返回多少行可以在`PageReadListener`的构造函数设置
EasyExcel.read(fileName, StaffRank.class, new PageReadListener<StaffRank>(dataList -> {
jdbcStaffRank.saveAll(dataList);
})).sheet().doRead();
}
// @Test
// 新能员工数据导入
public void simpleRead1() {
// 写法1JDK8+ ,不用额外写一个DemoDataListener
// since: 3.0.0-beta1
// String fileName = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
String fileName = "D:\\用户目录\\Downloads" + File.separator + "新能人员职级.xlsx";
// 这里默认每次会读取100条数据 然后返回过来 直接调用使用数据就行
// 具体需要返回多少行可以在`PageReadListener`的构造函数设置
EasyExcel.read(fileName, XNStaffRank.class, new PageReadListener<XNStaffRank>(dataList -> {
ArrayList<StaffRank> staffRanks = new ArrayList<>();
for (XNStaffRank xnStaffRank : dataList) {
String nameSF = xnStaffRank.getNameAndSF();
StaffRank staffRank = getStaffRank(xnStaffRank, nameSF);
staffRanks.add(staffRank);
}
jdbcStaffRank.saveAll(staffRanks);
})).sheet().doRead();
}
private static StaffRank getStaffRank(XNStaffRank xnStaffRank, String nameSF) {
String regex = "(.*?)\\((.*?)\\)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(nameSF);
String name = null;
String number = null;
// 提取匹配到的内容
if (matcher.find()) {
name = matcher.group(1); // 提取第一个括号前的部分作为名字
number = matcher.group(2); // 提取括号中的数字
}
String employeeLevel = xnStaffRank.getEmployeeLevel();
String regex1 = "\\((.*?)\\)";
Pattern pattern1 = Pattern.compile(regex1);
Matcher matcher1 = pattern1.matcher(employeeLevel);
String contentInBracket = null;
// 提取匹配到的内容
if (matcher1.find()) {
contentInBracket = matcher1.group(1); // 提取括号内的内容
}
StaffRank staffRank = new StaffRank();
staffRank.setEmployeeNo(number);
staffRank.setEmployeeName(name);
staffRank.setEmployeeLevel(contentInBracket);
staffRank.setTag("2");
return staffRank;
}
}

View File

@ -33,10 +33,7 @@ import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.chint.infrastructure.constant.BPMConstant.*;
@ -62,6 +59,9 @@ public class LYTest {
@Value("${bpm.H3BPMUrl}")
private String H3BPMUrl;
@Value("${bpm.DYBPMUrl}")
private String DYBPMUrl;
@Value("${bpm.XNBPMUrl}")
private String XNBPMUrl;
@ -337,8 +337,11 @@ public class LYTest {
.setHouseLayout("双人床")//酒店超标提供房型
.setSeatingStandard("")//火车票超标提供席别标准
.setCabinClass("")//机票超标提供舱等
.setExcessAmount(BigDecimal.valueOf(1000))//超标金额
.setReason("酒店爆满订不到");//超标原因
.setExcessAmount(BigDecimal.valueOf(6320))//超标金额
.setReason("酒店爆满订不到")//超标原因
.setOccupant("邓委超")//入住人
.setDays(4)//入住天数
.setExcessAmountDay(BigDecimal.valueOf(1580));//超标金额(/)
String entityParamValues = gson.toJson(exceedStandardDto);
bpmRequest.setWorkflowCode("JT_FI_CLCESQ")//流程编码
.setUserCode("231116011")//sf号
@ -456,8 +459,10 @@ public class LYTest {
.setSeatingStandard("")//火车票超标提供席别标准
.setCabinClass("")//机票超标提供舱等
.setExcessAmount(BigDecimal.valueOf(1000))//超标金额
.setReason("酒店爆满订不到");//超标原因
.setReason("酒店爆满订不到")//超标原因
.setOccupant("邓委超")//入住人
.setDays(4)//入住天数
.setExcessAmountDay(BigDecimal.valueOf(420));//超标金额(/)
String entityParamValues = gson.toJson(exceedStandardDto);
Type type = new TypeToken<HashMap<String, Object>>() {
}.getType();
@ -589,7 +594,7 @@ public class LYTest {
//智维BPM
// @Test
public void testDemo4() throws Exception {
YSTokenDto tokenDto = httpPostRequest.get(ZWBPMUrl + YSBPM_TOKEN_URL + "?code=" + "210413023", YSTokenDto.class);//191107079
YSTokenDto tokenDto = httpPostRequest.get(ZWBPMUrl + YSBPM_TOKEN_URL + "?code=" + "210914011", YSTokenDto.class);//191107079
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
@ -659,7 +664,7 @@ public class LYTest {
*/
// @Test
public void testDemo5() throws Exception {
YSTokenDto tokenDto = httpPostRequest.get(ZWBPMUrl + YSBPM_TOKEN_URL + "?code=" + "210413023", YSTokenDto.class);
YSTokenDto tokenDto = httpPostRequest.get(ZWBPMUrl + YSBPM_TOKEN_URL + "?code=" + "210914011", YSTokenDto.class);
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
@ -677,7 +682,10 @@ public class LYTest {
.setSeatingStandard("")//火车票超标提供席别标准
.setCabinClass("")//机票超标提供舱等
.setExcessAmount(BigDecimal.valueOf(1000))//超标金额
.setReason("酒店爆满订不到");//超标原因
.setReason("酒店爆满订不到")//超标原因
.setOccupant("邓委超")//入住人
.setDays(4)//入住天数
.setExcessAmountDay(BigDecimal.valueOf(420));//超标金额(/)
String entityParamValues = gson.toJson(exceedStandardDto);
Type type = new TypeToken<HashMap<String, Object>>() {
@ -698,7 +706,15 @@ public class LYTest {
//智维改签
// @Test
public void testDemo6() throws Exception {
public void testDemo7() throws Exception {
YSTokenDto tokenDto = httpPostRequest.get(ZWBPMUrl + YSBPM_TOKEN_URL + "?code=" + "210914011", YSTokenDto.class);
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
String userId = tokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getZWInstance();
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
RescheduleDto rescheduleDto = new RescheduleDto();
rescheduleDto.setOrderType("机票改签")//内容选项机票改签机票退票火车票改签火车票退票
.setOrderSource("携程商旅")//携程商旅/同程商旅
@ -711,42 +727,51 @@ public class LYTest {
.setRebookSeatingStandard("")//火车票改签提供: 改签后席别
.setFee(BigDecimal.valueOf(100))//费用
.setReason("行程冲突");//原因
bpmRequest.reschedule(rescheduleDto, "hsh");
String entityParamValues = gson.toJson(rescheduleDto);
Type type = new TypeToken<HashMap<String, Object>>() {
}.getType();
HashMap<String, Object> map = gson.fromJson(entityParamValues, type);
request.setData(map);//数据
request.setDepartmentId("");//部门id默认主部门
request.setFinishStart(true);//发起流程
request.setUserId(userId);//员工号
request.setWorkflowCode("ZW_AS_CLGQSQ");//改签流程
try {
StartWorkflowResponse response = client.startWorkflow(request);
System.out.println("response = " + JSON.toJSONString(response));
} catch (ApiException e) {
throw new RuntimeException(e.getMessage());
}
// @Test
public void searchTrain(){
lySearchRequest.getTrainOrderDetail("DT240306475434045");
}
// @Test
public void searchFlight(){
lySearchRequest.getFlightOrderDetail("DF240305474952657");
}
// @Test
public void searchHotel(){
lySearchRequest.getHotelOrderDetail("HO20240304180600433930");
}
// @Test
public void searchCar(){
lySearchRequest.getCarDetailResponse("DC240306475281195");
}
@Autowired
private JdbcOrderTravelRepository travelRepository;
//@Test
public void searchCa2r(){
OrderTravel orderTravel = new OrderTravel();
orderTravel.setOrderNo("22222222222");
orderTravel.setTravelNo( "333333333");
travelRepository.save(orderTravel);
List<OrderTravel> byOrderNo = travelRepository.findByOrderNo("22222222222");
System.out.println(byOrderNo);
private JdbcOrderTravelRepository orderTravelRepository;
// @Test
void test11() {
List<OrderTravel> byOrderNo = orderTravelRepository.findByOrderNo(null);
System.out.println("byOrderNo = " + byOrderNo);
for (OrderTravel orderTravel : byOrderNo) {
System.out.println(orderTravel.getTravelNo());
}
}
// @Test
void testClient() {
CloudpivotOpenClient xnInstance = ClientFactory.getXNInstance();
CloudpivotOpenClient zwInstance = ClientFactory.getZWInstance();
System.out.println("xnInstance = " + xnInstance);
System.out.println("zwInstance = " + zwInstance);
}
// @Test
void removeDuplicates() {
StringBuilder stringBuilder = new StringBuilder();
String cityStr = stringBuilder.toString();
String[] array = cityStr.split(",");
Set<String> set = new LinkedHashSet<>(Arrays.asList(array));
String join = String.join(",", set);
System.out.println("join = " + join);
}
}

View File

@ -4,6 +4,7 @@ import cn.hutool.extra.pinyin.PinyinUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chint.application.services.login.strategy.PailaLoginStrategy;
import com.chint.domain.aggregates.location.basedata.AirportPOIInfoEntity;
import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
import com.chint.domain.aggregates.order.Leg;
@ -12,27 +13,30 @@ import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.*;
import com.chint.infrastructure.util.Digest;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.ly.LYPostRequest;
import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.dto.flydatapushback.FlyOkDTO;
import com.chint.interfaces.rest.ly.dto.flydatapushback.ParamFly;
import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.OrderInfo;
import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.*;
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushResult;
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeDto;
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeParam;
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest;
import com.chint.interfaces.rest.user.UserHttpRequest;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.IOException;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@ -75,11 +79,6 @@ class RouteApplicationTests {
@Autowired
private CountryLevelInfoRepository countryLevelInfoRepository;
@Value("${FSSC.jt-baseUrl}")
private String jtFSSCUrl;
@Value("${FSSC.xn-baseUrl}")
private String xnFSSCUrl;
private String lyConfirm = "https://api.qa.dttrip.cn/openapi/api/DomesticFlight/ConfirmFlightOrderChange";
@ -87,30 +86,25 @@ class RouteApplicationTests {
private TrainChangeRequest trainChangeRequest;
@Autowired
private LYPostRequest lyPostRequest;
@Autowired
private PostRequest postRequest;
private LYPostRequest postRequest;
@Value("${chint.loginSecretKey}")
private String LOGIN_SECRET_KEY;
void test3() {
void test3(){
FlyOkDTO freightDTO = new FlyOkDTO();
ParamFly param = new ParamFly();
param.setOrderSerialNo("T240307476035978");
StrokePushResult postData = lyPostRequest.post(lyConfirm, freightDTO, StrokePushResult.class);
StrokePushResult postData = postRequest.post(lyConfirm, freightDTO, StrokePushResult.class);
System.out.println(postData);
}
private User user = new User(1L, "230615020", 1, "卢麟哲", "1033719135@qq.com", "15857193365");
@Test
/* @Test
void fsscLogin() {
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
}
}*/
// @Test
void contextLoads() {
@ -202,8 +196,8 @@ class RouteApplicationTests {
String billcode = "CLSQ240310009999";
String companycode = "正泰集团股份有限公司";
String timespan = "1708908662738";
String s = Digest.md5(sfno + syscode + billcode + companycode + LOGIN_SECRET_KEY + timespan);
System.out.println(s);
// String s = Digest.md5(sfno + syscode + billcode + companycode + LOGIN_SECRET_KEY + timespan);
// System.out.println(s);
// log.info("info");
// log.trace("trace");
// log.trace("trace");
@ -271,7 +265,7 @@ class RouteApplicationTests {
System.out.println(Arrays.toString(ids.toArray()));
}
// @Test
// @Test
void deleteRouteByEmployeeNo() {
List<RouteOrder> byEmployeeNo = routeRepository.findByEmployeeNo("220322120");
for (RouteOrder routeOrder : byEmployeeNo) {
@ -790,8 +784,8 @@ class RouteApplicationTests {
}
// @Test
void findOutInternationlCityInfo() {
// @Test
void findOutInternationlCityInfo(){
List<Location> locationList = locationRepository.findNotChintCityByLevel("3106_1_", 3);
List<Location> saveLocations = new ArrayList<>();
List<String> noCountryCity = new ArrayList<>();