diff --git a/os-mes/src/main/java/com/os/mes/api/controller/ERPPortController.java b/os-mes/src/main/java/com/os/mes/api/controller/ERPPortController.java index 6d595f8..c610d0c 100644 --- a/os-mes/src/main/java/com/os/mes/api/controller/ERPPortController.java +++ b/os-mes/src/main/java/com/os/mes/api/controller/ERPPortController.java @@ -4,7 +4,7 @@ import com.os.common.core.controller.BaseController; import com.os.common.core.domain.AjaxResult; import com.os.mes.api.domain.ERPParamDto; import com.os.mes.api.service.IERPPortService; -import com.os.mes.base.service.IBaseCustomDataService; +import com.os.mes.record.domain.RecordStaffSalary; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -70,5 +70,15 @@ public class ERPPortController extends BaseController { return AjaxResult.success(portService.getERPLatestSalaryData(paramDto)); } + /** + * 新增【薪资明细】 + * @param recordStaffSalary + * @return + */ + @PostMapping("/addSalaryBreakdown") + public AjaxResult addSalaryBreakdown(@RequestBody RecordStaffSalary recordStaffSalary) { + return AjaxResult.success(portService.addSalaryBreakdown(recordStaffSalary)); + } + } diff --git a/os-mes/src/main/java/com/os/mes/api/domain/ERPStaffSalary.java b/os-mes/src/main/java/com/os/mes/api/domain/ERPStaffSalary.java new file mode 100644 index 0000000..9ffdb82 --- /dev/null +++ b/os-mes/src/main/java/com/os/mes/api/domain/ERPStaffSalary.java @@ -0,0 +1,204 @@ +package com.os.mes.api.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.os.common.annotation.Excel; +import com.os.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * erp员工工资 + * + * @author Yinq + * @date 2024-07-02 + */ +public class ERPStaffSalary +{ + private static final long serialVersionUID = 1L; + + /** + * 应用代码 + */ + @JsonProperty(value = "AppCode") + private String AppCode; + + /** + * 控制器 + */ + @JsonProperty(value = "Controller") + private String Controller; + + /** + * 动作名称 + */ + @JsonProperty(value = "ActionName") + private String ActionName; + + /** 身份证 */ + @JsonProperty(value = "IDCard") + private String idCard; + + /** 班组编号 */ + @JsonProperty(value = "GroupID") + private String groupId; + + /** 事件日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @JsonProperty(value = "EventDate") + private Date eventDate; + + /** 薪资类别 */ + @JsonProperty(value = "SalaryCategory") + private String salaryCategory; + + /** 收入大类 */ + @JsonProperty(value = "RevenueClass") + private String revenueClass; + + /** 收入金额 */ + @JsonProperty(value = "RevenueAmount") + private BigDecimal revenueAmount; + + /** 收入理由 */ + @JsonProperty(value = "RevenueReason") + private String revenueReason; + + /** 扣罚大类 */ + @JsonProperty(value = "FineClass") + private String fineClass; + + /** 扣罚金额 */ + @JsonProperty(value = "FineAmount") + private BigDecimal fineAmount; + + /** 扣罚理由 */ + @JsonProperty(value = "fineReason") + private String fineReason; + + public String getAppCode() { + return AppCode; + } + + public void setAppCode(String appCode) { + AppCode = appCode; + } + + public String getController() { + return Controller; + } + + public void setController(String controller) { + Controller = controller; + } + + public String getActionName() { + return ActionName; + } + + public void setActionName(String actionName) { + ActionName = actionName; + } + + public String getIdCard() { + return idCard; + } + + public void setIdCard(String idCard) { + this.idCard = idCard; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public Date getEventDate() { + return eventDate; + } + + public void setEventDate(Date eventDate) { + this.eventDate = eventDate; + } + + public String getSalaryCategory() { + return salaryCategory; + } + + public void setSalaryCategory(String salaryCategory) { + this.salaryCategory = salaryCategory; + } + + public String getRevenueClass() { + return revenueClass; + } + + public void setRevenueClass(String revenueClass) { + this.revenueClass = revenueClass; + } + + public BigDecimal getRevenueAmount() { + return revenueAmount; + } + + public void setRevenueAmount(BigDecimal revenueAmount) { + this.revenueAmount = revenueAmount; + } + + public String getRevenueReason() { + return revenueReason; + } + + public void setRevenueReason(String revenueReason) { + this.revenueReason = revenueReason; + } + + public String getFineClass() { + return fineClass; + } + + public void setFineClass(String fineClass) { + this.fineClass = fineClass; + } + + public BigDecimal getFineAmount() { + return fineAmount; + } + + public void setFineAmount(BigDecimal fineAmount) { + this.fineAmount = fineAmount; + } + + public String getFineReason() { + return fineReason; + } + + public void setFineReason(String fineReason) { + this.fineReason = fineReason; + } + + @Override + public String toString() { + return "ERPStaffSalary{" + + "AppCode='" + AppCode + '\'' + + ", Controller='" + Controller + '\'' + + ", ActionName='" + ActionName + '\'' + + ", idCard='" + idCard + '\'' + + ", groupId='" + groupId + '\'' + + ", eventDate=" + eventDate + + ", salaryCategory='" + salaryCategory + '\'' + + ", revenueClass='" + revenueClass + '\'' + + ", revenueAmount=" + revenueAmount + + ", revenueReason='" + revenueReason + '\'' + + ", fineClass='" + fineClass + '\'' + + ", fineAmount=" + fineAmount + + ", fineReason='" + fineReason + '\'' + + '}'; + } +} diff --git a/os-mes/src/main/java/com/os/mes/api/service/IERPPortService.java b/os-mes/src/main/java/com/os/mes/api/service/IERPPortService.java index 861319f..f38e131 100644 --- a/os-mes/src/main/java/com/os/mes/api/service/IERPPortService.java +++ b/os-mes/src/main/java/com/os/mes/api/service/IERPPortService.java @@ -5,7 +5,9 @@ import com.os.mes.api.domain.ERPParamDto; import com.os.mes.api.domain.LatestSalary; import com.os.mes.base.domain.BaseStaffInfo; import com.os.mes.prod.domain.ProdOrderDetail; +import com.os.mes.record.domain.RecordStaffSalary; +import java.util.HashMap; import java.util.List; /** @@ -38,4 +40,11 @@ public interface IERPPortService { */ LatestSalary getERPLatestSalaryData(ERPParamDto paramDto); + /** + * 新增【薪资明细】 + * @param recordStaffSalary + * @return + */ + String addSalaryBreakdown(RecordStaffSalary recordStaffSalary); + } diff --git a/os-mes/src/main/java/com/os/mes/api/service/impl/ERPPortServiceImpl.java b/os-mes/src/main/java/com/os/mes/api/service/impl/ERPPortServiceImpl.java index 9906846..4a64bd9 100644 --- a/os-mes/src/main/java/com/os/mes/api/service/impl/ERPPortServiceImpl.java +++ b/os-mes/src/main/java/com/os/mes/api/service/impl/ERPPortServiceImpl.java @@ -4,10 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.os.common.utils.StringUtils; -import com.os.mes.api.domain.ERPParamDto; -import com.os.mes.api.domain.LatestSalary; -import com.os.mes.api.domain.RecordData; -import com.os.mes.api.domain.ResponseData; +import com.os.mes.api.domain.*; import com.os.mes.api.service.IERPPortService; import com.os.mes.api.utils.ApiUtils; import com.os.mes.api.utils.ERPConstants; @@ -16,12 +13,16 @@ 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; +import com.os.mes.record.domain.RecordStaffSalary; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; @@ -151,5 +152,58 @@ public class ERPPortServiceImpl implements IERPPortService { return latestSalary; } + /** + * 新增【薪资明细】 + * @param recordStaffSalary + * @return + */ + @Override + public String addSalaryBreakdown(RecordStaffSalary recordStaffSalary) { + String objectId = null;//ERP返回数据的ObjectId + String requestParam = null; + String result = null; + ERPStaffSalary erpStaffSalary = new ERPStaffSalary(); + erpStaffSalary.setAppCode(ERPConstants.addSalaryAppCode); + erpStaffSalary.setController(ERPConstants.addSalaryController); + erpStaffSalary.setActionName(ERPConstants.addSalaryActionName); + erpStaffSalary.setIdCard(recordStaffSalary.getIdCard()); + erpStaffSalary.setGroupId(recordStaffSalary.getGroupId()); + erpStaffSalary.setEventDate(recordStaffSalary.getEventDate()); + erpStaffSalary.setSalaryCategory(recordStaffSalary.getSalaryCategory()); + erpStaffSalary.setRevenueClass(recordStaffSalary.getRevenueClass()); + erpStaffSalary.setRevenueAmount(recordStaffSalary.getRevenueAmount()); + erpStaffSalary.setRevenueReason(recordStaffSalary.getRevenueReason()); + try { + // 创建ObjectMapper实例 对象转JSON字符串 + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); + requestParam = objectMapper.writeValueAsString(erpStaffSalary); +// result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam); + result = "{\n" + + "\t\"Successful\": true,\n" + + "\t\"ErrorMessage\": null,\n" + + "\t\"Logined\": false,\n" + + "\t\"ReturnData\": {\n" + + "\t\t\"data\": {\n" + + "\t\t\t\"ObjectId\": \"25ff81b4-fb0b-4f1c-b9b1-6a2afab1cd0f\"\n" + + "\t\t},\n" + + "\t\t\"result\": \"success\",\n" + + "\t\t\"message\": \"创建成功!\"\n" + + "\t},\n" + + "\t\"DataType\": 0\n" + + "}"; + // 处理接口返回消息 + ObjectMapper resultMapper = new ObjectMapper(); + // 将 JSON 字符串转换为 Java 对象 + HashMap hashMap = resultMapper.readValue(result, HashMap.class); + HashMap returnData = (HashMap)hashMap.get("ReturnData"); + HashMap data = (HashMap)returnData.get("data"); + objectId = String.valueOf(data.get("ObjectId")); + } catch (Exception e) { + logger.warn("新增【薪资明细】异常:" + requestParam + "|" + result + "|" + e); + } + return objectId; + } + } diff --git a/os-mes/src/main/java/com/os/mes/api/utils/ERPConstants.java b/os-mes/src/main/java/com/os/mes/api/utils/ERPConstants.java index 8812eb6..d6fa3de 100644 --- a/os-mes/src/main/java/com/os/mes/api/utils/ERPConstants.java +++ b/os-mes/src/main/java/com/os/mes/api/utils/ERPConstants.java @@ -42,5 +42,9 @@ public class ERPConstants { public static final String employeeController = "EmployeeApiController"; public static final String employeeActionName = "GetEmployeeInfos"; + //新增【薪资明细】 + public static final String addSalaryAppCode = "Ad824e2774bf54eaa9493af5985b2f37b"; + public static final String addSalaryController = "SalaryDetailApiController"; + public static final String addSalaryActionName = "CreateSalaryDetail"; } diff --git a/os-mes/src/main/java/com/os/mes/record/controller/RecordStaffSalaryController.java b/os-mes/src/main/java/com/os/mes/record/controller/RecordStaffSalaryController.java index 33cd8ab..93e7904 100644 --- a/os-mes/src/main/java/com/os/mes/record/controller/RecordStaffSalaryController.java +++ b/os-mes/src/main/java/com/os/mes/record/controller/RecordStaffSalaryController.java @@ -110,4 +110,15 @@ public class RecordStaffSalaryController extends BaseController { return success(list); } + /** + * 维护员工工资记录 + * 上传ERP + * @param recordStaffSalaryList + * @return + */ + @PostMapping("/uploadERPStaffSalary") + public AjaxResult uploadERPStaffSalary(@RequestBody List recordStaffSalaryList) { + return toAjax(recordStaffSalaryService.uploadERPStaffSalary(recordStaffSalaryList)); + } + } diff --git a/os-mes/src/main/java/com/os/mes/record/domain/RecordStaffSalary.java b/os-mes/src/main/java/com/os/mes/record/domain/RecordStaffSalary.java index 6f9609b..4d84172 100644 --- a/os-mes/src/main/java/com/os/mes/record/domain/RecordStaffSalary.java +++ b/os-mes/src/main/java/com/os/mes/record/domain/RecordStaffSalary.java @@ -98,6 +98,17 @@ public class RecordStaffSalary extends BaseEntity @Excel(name = "结束日期", width = 30, dateFormat = "yyyy-MM-dd") private Date endDate; + /** ERP数据的ObjectId */ + private String objectId; + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + public Date getBeginDate() { return beginDate; } diff --git a/os-mes/src/main/java/com/os/mes/record/service/IRecordStaffSalaryService.java b/os-mes/src/main/java/com/os/mes/record/service/IRecordStaffSalaryService.java index 6617ce2..aca9cc7 100644 --- a/os-mes/src/main/java/com/os/mes/record/service/IRecordStaffSalaryService.java +++ b/os-mes/src/main/java/com/os/mes/record/service/IRecordStaffSalaryService.java @@ -65,4 +65,12 @@ public interface IRecordStaffSalaryService { * @return */ List selectTeamEmployeesWages(RecordStaffSalary recordStaffSalary); + + /** + * 维护员工工资记录 + * 上传ERP + * @param recordStaffSalaryList + * @return + */ + public int uploadERPStaffSalary(List recordStaffSalaryList); } diff --git a/os-mes/src/main/java/com/os/mes/record/service/impl/RecordStaffSalaryServiceImpl.java b/os-mes/src/main/java/com/os/mes/record/service/impl/RecordStaffSalaryServiceImpl.java index 8333b53..6aca499 100644 --- a/os-mes/src/main/java/com/os/mes/record/service/impl/RecordStaffSalaryServiceImpl.java +++ b/os-mes/src/main/java/com/os/mes/record/service/impl/RecordStaffSalaryServiceImpl.java @@ -2,13 +2,11 @@ package com.os.mes.record.service.impl; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Stream; import com.os.common.utils.DateUtils; +import com.os.common.utils.Threads; import com.os.common.utils.uuid.PlanCodeUtils; import com.os.mes.api.domain.ERPParamDto; import com.os.mes.api.domain.LatestSalary; @@ -131,10 +129,19 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService { LatestSalary salaryData = portService.getERPLatestSalaryData(new ERPParamDto()); ProdOrderInfo orderInfo = new ProdOrderInfo(); - orderInfo.setParams(recordStaffSalary.getParams()); + Map params = recordStaffSalary.getParams(); + Date beginOrderDate = null; + Date endOrderDate = null; + if (params.containsKey("beginOrderDate")){ + beginOrderDate = DateUtils.parseDate(String.valueOf(params.get("beginOrderDate"))); + } + if (params.containsKey("endOrderDate")){ + endOrderDate = DateUtils.parseDate(String.valueOf(params.get("endOrderDate"))); + } + orderInfo.setParams(params); List orderInfoList = prodOrderInfoMapper.selectProdOrderInfoList(orderInfo); - Long objId = 1L; + long objId = 1L; String taskCode = PlanCodeUtils.getTaskCode(); //按照班组 分工资; for (BaseTeamMembers team : membersList) { @@ -186,6 +193,8 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService { staffSalary.setStaffName(staffInfo.getStaffName()); staffSalary.setCardId(staffInfo.getCardId()); staffSalary.setTeamName(team.getTeamName()); + staffSalary.setBeginDate(beginOrderDate); + staffSalary.setEndDate(endOrderDate); result.add(staffSalary); } @@ -193,4 +202,24 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService { return result; } + /** + * 维护员工工资记录 + * 上传ERP + * @param recordStaffSalaryList + * @return + */ + @Override + public int uploadERPStaffSalary(List recordStaffSalaryList) { + Thread thread = new Thread(() -> { + for (RecordStaffSalary staffSalary : recordStaffSalaryList) { + String objectId = portService.addSalaryBreakdown(staffSalary); + staffSalary.setObjectId(objectId); + recordStaffSalaryMapper.insertRecordStaffSalary(staffSalary); + } + }); + thread.start(); //启动新线程 + + return 1; + } + } diff --git a/os-mes/src/main/resources/mapper/mes/record/RecordStaffSalaryMapper.xml b/os-mes/src/main/resources/mapper/mes/record/RecordStaffSalaryMapper.xml index f3dc41e..ef31f59 100644 --- a/os-mes/src/main/resources/mapper/mes/record/RecordStaffSalaryMapper.xml +++ b/os-mes/src/main/resources/mapper/mes/record/RecordStaffSalaryMapper.xml @@ -21,6 +21,8 @@ + + @@ -38,6 +40,7 @@ create_time, task_code, salary_coefficient, + object_id, begin_date, end_date from record_staff_salary @@ -60,8 +63,7 @@ and fine_reason = #{fineReason} and task_code = #{taskCode} and salary_coefficient = #{salaryCoefficient} - and begin_date = #{beginDate} - and end_date = #{endDate} + and object_id = #{objectId} @@ -88,6 +90,7 @@ salary_coefficient, begin_date, end_date, + object_id, #{idCard}, @@ -105,6 +108,7 @@ #{salaryCoefficient}, #{beginDate}, #{endDate}, + #{objectId}, @@ -126,6 +130,7 @@ salary_coefficient = #{salaryCoefficient}, begin_date = #{beginDate}, end_date = #{endDate}, + object_id = #{objectId}, where obj_id = #{objId}