change - 同步员工工资系数

maser
yinq 1 year ago
parent 57d00149f1
commit d901e9e1b8

@ -40,5 +40,20 @@ public class ERPPortController extends BaseController {
return AjaxResult.success(portService.getERPOrderData(paramDto));
}
/**
*
*
* @param paramMap
* @return
*/
@PostMapping("/getERPEmployeeWageData")
public AjaxResult getERPEmployeeWageData(@RequestBody Map paramMap) {
ERPParamDto paramDto = new ERPParamDto();
paramDto.setAppCode(String.valueOf(paramMap.get("AppCode")));
paramDto.setController(String.valueOf(paramMap.get("Controller")));
paramDto.setActionName(String.valueOf(paramMap.get("ActionName")));
return AjaxResult.success(portService.getERPEmployeeWageData(paramDto));
}
}

@ -25,11 +25,11 @@ public class UpperLowerGlueItem1 {
MaterialNo = materialNo;
}
public com.os.mes.api.domain.Material getMaterial() {
public Material getMaterial() {
return Material;
}
public void setMaterial(com.os.mes.api.domain.Material material) {
public void setMaterial(Material material) {
Material = material;
}

@ -2,6 +2,7 @@ package com.os.mes.api.service;
import com.os.mes.api.domain.ERPParamDto;
import com.os.mes.base.domain.BaseStaffInfo;
import com.os.mes.prod.domain.ProdOrderDetail;
import java.util.List;
@ -22,4 +23,12 @@ public interface IERPPortService {
*/
List<ProdOrderDetail> getERPOrderData(ERPParamDto paramDto);
/**
*
* @param paramDto
* @return
*/
List<BaseStaffInfo> getERPEmployeeWageData(ERPParamDto paramDto);
}

@ -9,6 +9,8 @@ import com.os.mes.api.domain.ResponseData;
import com.os.mes.api.service.IERPPortService;
import com.os.mes.api.utils.ApiUtils;
import com.os.mes.api.utils.ERPConstants;
import com.os.mes.base.domain.BaseStaffInfo;
import com.os.mes.base.service.IBaseStaffInfoService;
import com.os.mes.prod.domain.ProdOrderDetail;
import com.os.mes.prod.service.IProdOrderInfoService;
import com.os.mes.prod.service.impl.ProdOrderInfoServiceImpl;
@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -34,6 +37,9 @@ public class ERPPortServiceImpl implements IERPPortService {
@Autowired
private IProdOrderInfoService orderInfoService;
@Autowired
private IBaseStaffInfoService staffInfoService;
/**
* ERP
*
@ -70,4 +76,39 @@ public class ERPPortServiceImpl implements IERPPortService {
}
/**
*
* @param paramDto
* @return
*/
@Override
public List<BaseStaffInfo> getERPEmployeeWageData(ERPParamDto paramDto) {
List<BaseStaffInfo> resultList = new ArrayList<>();
String requestParam = null;
String result = null;
try {
// 创建ObjectMapper实例 对象转JSON字符串
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
requestParam = objectMapper.writeValueAsString(paramDto);
result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam);
// 处理接口返回消息
ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串转换为 Java 对象
HashMap hashMap = resultMapper.readValue(result, HashMap.class);
HashMap returnData = (HashMap)hashMap.get("ReturnData");
List<HashMap<String, String>> dataList = (List<HashMap<String, String>>)returnData.get("data");
for (HashMap<String, String> data : dataList) {
BaseStaffInfo baseStaffInfo = staffInfoService.insertStaffByERP(data);
resultList.add(baseStaffInfo);
}
logger.warn("获取员工工资系数成功:" + requestParam + "|" + result);
} catch (JsonProcessingException e) {
logger.warn("获取员工工资系数异常:" + requestParam + "|" + result + "|" + e);
}
return resultList;
}
}

@ -32,7 +32,7 @@ public class ERPConstants {
public static final String orderActionName = "GetReleaseOrders";
//获取【政策与条款】-最新工资系数
//最新工资系数
public static final String salaryAppCode = "A1c661aa059ad4d4f8230b187a85385c5";
public static final String salaryController = "SalaryCoefficientApiController";
public static final String salaryActionName = "GetSalaryCoefficient";

@ -1,5 +1,6 @@
package com.os.mes.base.service;
import java.util.HashMap;
import java.util.List;
import com.os.mes.base.domain.BaseStaffInfo;
@ -58,4 +59,12 @@ public interface IBaseStaffInfoService {
* @return
*/
public int deleteBaseStaffInfoByObjId(Long objId);
/**
* ERP
* @param data
* @return
*/
public BaseStaffInfo insertStaffByERP(HashMap<String, String> data);
}

@ -1,5 +1,7 @@
package com.os.mes.base.service.impl;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import com.os.common.utils.DateUtils;
@ -94,4 +96,36 @@ public class BaseStaffInfoServiceImpl implements IBaseStaffInfoService {
baseStaffInfo.setDelFlag("2");
return baseStaffInfoMapper.updateBaseStaffInfo(baseStaffInfo);
}
/**
*
*
* @param data
* @return
*/
@Override
public BaseStaffInfo insertStaffByERP(HashMap<String, String> data) {
String jobNumber = String.valueOf(data.get("JobNumber"));
String SalaryCoefficient = String.valueOf(data.get("SalaryCoefficient"));
BaseStaffInfo staffInfo = new BaseStaffInfo();
staffInfo.setStaffId(jobNumber);
List<BaseStaffInfo> staffInfoList = baseStaffInfoMapper.selectBaseStaffInfoList(staffInfo);
if (staffInfoList.size() > 0) {
staffInfo = staffInfoList.get(0);
staffInfo.setWageCoefficient(new BigDecimal(SalaryCoefficient));
staffInfo.setUpdateTime(DateUtils.getNowDate());
baseStaffInfoMapper.updateBaseStaffInfo(staffInfo);
} else {
staffInfo.setStaffName(jobNumber);
staffInfo.setStaffType("2");
staffInfo.setSex("2");
staffInfo.setTeamCode(" ");
staffInfo.setWageCoefficient(new BigDecimal(SalaryCoefficient));
staffInfo.setCreateTime(DateUtils.getNowDate());
baseStaffInfoMapper.insertBaseStaffInfo(staffInfo);
}
return staffInfo;
}
}

@ -35,6 +35,12 @@
<artifactId>haiwei-common</artifactId>
</dependency>
<!-- MES模块-->
<dependency>
<groupId>com.haiwei</groupId>
<artifactId>haiwei-mes</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,68 @@
package com.os.quartz.task;
import com.os.mes.api.domain.ERPParamDto;
import com.os.mes.api.service.IERPPortService;
import com.os.mes.api.utils.ERPConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* @Author YinQ
* @create 2023-10-08 9:11
*/
@Component("ERPTask")
public class ERPTask {
@Autowired
private IERPPortService portService;
public void ERPOrderTask(Long startDays, Long endDays) {
String startDate = convertDaysToDateString(startDays, 0);
String endDate = convertDaysToDateString(endDays, 1);
ERPParamDto paramDto = new ERPParamDto();
paramDto.setAppCode(ERPConstants.orderAppCode);
paramDto.setController(ERPConstants.orderController);
paramDto.setActionName(ERPConstants.orderActionName);
paramDto.setOrderStartTime(startDate);
paramDto.setOrderEndTime(endDate);
portService.getERPOrderData(paramDto);
}
public void ERPEmployeeWageTask() {
ERPParamDto paramDto = new ERPParamDto();
paramDto.setAppCode(ERPConstants.employeeAppCode);
paramDto.setController(ERPConstants.employeeController);
paramDto.setActionName(ERPConstants.employeeActionName);
portService.getERPEmployeeWageData(paramDto);
}
/**
* daystype
* type: 0-1-
*
* @param days
* @return
*/
public static String convertDaysToDateString(Long days, Integer type) {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
LocalDate targetDate = null;
// 减去相应的天数
if (type.equals(0)) {
targetDate = currentDate.minusDays(days);
} else {
targetDate = currentDate.plusDays(days);
}
// 创建DateTimeFormatter对象指定日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd 00:00:00");
// 格式化日期为字符串并返回
return targetDate.format(formatter);
}
}
Loading…
Cancel
Save