From 4b0eee479879f398ad52c2d04b048e47d079c5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Wed, 4 Sep 2024 15:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E8=B7=A8=E6=89=A3?= =?UTF-8?q?=E7=BC=B4=E4=B9=89=E5=8A=A1=E4=BA=BA=E5=8F=91=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/salaryBill/bo/SalaryBillBO.java | 53 +++++---------- .../salaryBill/dto/SalaryBillSendDTO.java | 2 +- .../salary/service/SalaryBillService.java | 3 +- .../service/impl/SalaryBillServiceImpl.java | 43 ++----------- .../service/impl/SalarySendServiceImpl.java | 64 +++++++++---------- 5 files changed, 58 insertions(+), 107 deletions(-) diff --git a/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java index 1bdae5dda..f71994e72 100644 --- a/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java +++ b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java @@ -119,53 +119,34 @@ public class SalaryBillBO { /** * 构建工资单中的人员信息 * - * @param simpleEmployee */ - public static void buildEmployeeInfo(SalaryBillSendDTO salaryBillSendParam, DataCollectionEmployee simpleEmployee) { + public static void buildEmployeeInfo(SalaryBillSendDTO salaryBillSendParam, Map empInfo) { SalaryTemplateSalaryItemSetListDTO employeeInformation = salaryBillSendParam.getEmployeeInformation(); Map employeeField = salaryBillSendParam.getEmployeeField(); - if (employeeInformation == null || simpleEmployee == null) { + if (employeeInformation == null || empInfo == null) { return; } if (CollectionUtils.isNotEmpty(employeeInformation.getItems())) { //获取员工信息的字段名和中文描述的map关系 SalaryFormulaEmployeeDTO salaryFormulaEmployeeDTO = SalaryFormulaEmployeeDTO.builder() - .employeeId(simpleEmployee.getEmployeeId()) - .taxAgentName(salaryBillSendParam.getTaxAgentName()) - .departmentName(simpleEmployee.getDepartmentName()) - .companystartdate(simpleEmployee.getCompanystartdate()) - .email(StringUtils.isEmpty(simpleEmployee.getEmail()) ? "" : simpleEmployee.getEmail()) - .sex(simpleEmployee.getSex() == null ? "" : simpleEmployee.getSex()) - .mobile(StringUtils.isEmpty(simpleEmployee.getMobile()) ? "" : simpleEmployee.getMobile()).jobtitleName(simpleEmployee.getJobtitleName()) - .status(StringUtils.isEmpty(simpleEmployee.getStatus()) ? "" : simpleEmployee.getStatus()) - .telephone(StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone()) - .username(StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername()) - .workcode(simpleEmployee.getWorkcode()) - .idNo(simpleEmployee.getIdNo()) - .statusName(simpleEmployee.getStatusName()) + .employeeId((long) empInfo.getOrDefault("employeeId", 0L)) + .taxAgentName(Util.null2String(empInfo.get("taxAgentName"))) + .departmentName(Util.null2String(empInfo.get("departmentName"))) + .companystartdate(Util.null2String(empInfo.get("companystartdate"))) + .email(Util.null2String(empInfo.get("email"))) + .sex(Util.null2String(empInfo.get("sex"))) + .mobile(Util.null2String(empInfo.get("mobile"))) + .jobtitleName(Util.null2String(empInfo.get("jobtitleName"))) + .status(Util.null2String(empInfo.get("status"))) + .telephone(Util.null2String(empInfo.get("telephone"))) + .username(Util.null2String(empInfo.get("username"))) + .workcode(Util.null2String(empInfo.get("workcode"))) + .idNo(Util.null2String(empInfo.get("idNo"))) + .statusName(Util.null2String(empInfo.get("statusName"))) .build(); List items = employeeInformation.getItems(); - // 1.SalaryAcctResultBO.buildEmployeeFieldName()的取法 -// Set> entries = employeeField.entrySet(); -// for (SalaryTemplateSalaryItemListDTO e : items) { -// Optional> entry = entries.stream().filter(f -> Objects.equals(e.getName(), f.getValue())).findFirst(); -// if (entry.isPresent()) { -// String key = entry.get().getKey(); -// if (StringUtils.isNotBlank(key)) { -// String getter = "get" + key.substring(0, 1).toUpperCase() + key.substring(1); -// try { -// Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter); -// Object invoke = method.invoke(salaryFormulaEmployeeDTO); -// e.setSalaryItemValue((String) invoke); -// } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { -// log.error("no such method", e); -// } -// } -// } -// } - // 2.SalaryBillBO.buildEmployeeFieldName() for (SalaryTemplateSalaryItemListDTO e : items) { String employeeFieldName = employeeField.get(e.getName()); if (!StringUtils.isEmpty(employeeFieldName)) { @@ -262,7 +243,7 @@ public class SalaryBillBO { } Util_Message.store(messageBean); } catch (IOException e) { - log.error("消息发送失败",e); + log.error("消息发送失败", e); } } diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java index c77c0bd7a..dc9d31b73 100644 --- a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java @@ -59,7 +59,7 @@ public class SalaryBillSendDTO { private String picUrl; //扣缴义务人名称 - private String taxAgentName; +// private String taxAgentName; //工资单模板-薪资项目设置 private List salaryItemSetList; diff --git a/src/com/engine/salary/service/SalaryBillService.java b/src/com/engine/salary/service/SalaryBillService.java index 4878df87b..755d98542 100644 --- a/src/com/engine/salary/service/SalaryBillService.java +++ b/src/com/engine/salary/service/SalaryBillService.java @@ -58,11 +58,10 @@ public interface SalaryBillService { /** * 构建发放参数 * @param salarySend - * @param taxAgentName * @param salaryTemplate * @return */ - SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, String taxAgentName, SalaryTemplatePO salaryTemplate); + SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, SalaryTemplatePO salaryTemplate); /** * 工资单撤回 diff --git a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java index 060f15cb2..322581129 100644 --- a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java @@ -6,13 +6,12 @@ import com.alibaba.fastjson.JSONArray; import com.api.formmode.mybatis.util.SqlProxyHandle; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.hrmelog.entity.dto.LoggerContext; import com.engine.salary.biz.SalarySendBiz; import com.engine.salary.biz.SalarySendInfoBiz; import com.engine.salary.cache.SalaryCacheKey; import com.engine.salary.config.SalaryElogConfig; import com.engine.salary.constant.HrmSalaryPayrollConf; -import com.engine.hrmelog.entity.dto.LoggerContext; -import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.progress.ProgressDTO; import com.engine.salary.entity.salaryBill.bo.SalaryBillBO; import com.engine.salary.entity.salaryBill.bo.SalaryTemplateBO; @@ -26,7 +25,6 @@ import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.salarysob.po.SalarySobPO; -import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.OperateTypeEnum; import com.engine.salary.enums.salarybill.*; import com.engine.salary.enums.salarysend.SalarySendGrantTypeEnum; @@ -46,7 +44,6 @@ import com.weaver.util.threadPool.entity.LocalRunnable; import lombok.extern.slf4j.Slf4j; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; - import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import weaver.hrm.User; @@ -225,9 +222,8 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService } } try { - TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySob.getTaxAgentId()); // 1.构建发送参数 - SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, taxAgentPO.getName(), salaryTemplate); + SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, salaryTemplate); // 2.获取可发送的列表,此步最耗时,需要解密核算数据 List sendStatusList = Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue(), SalarySendStatusEnum.ALREADYSEND.getValue()); List> enableSendList = getEnableSendList(salarySend, ids, salaryBillSendParam, sendStatusList); @@ -255,10 +251,8 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService private void handleGrant(SalarySendPO salarySend, List ids, SalarySobPO salarySob, SalaryTemplatePO salaryTemplate) { try { - TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySob.getTaxAgentId()); - // 1.构建发送参数 - SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, taxAgentPO.getName(), salaryTemplate); + SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, salaryTemplate); // 2.获取可发送的列表,此步最耗时,需要解密核算数据 List sendStatusList = Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue()); @@ -309,12 +303,10 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService } private void genPdf(SalaryBillSendDTO salaryBillSendParam, List> enableSendList) { - // 获取人员完整信息 - Map allEmployeeMap = getEmployeeWholeInfo(enableSendList); //生成工资单pdf enableSendList.forEach(e -> { // 构建人员信息 - SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, allEmployeeMap.get(e.get("employeeId").toString())); + SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, e); SalaryBillBO.genPdf(e, salaryBillSendParam); }); @@ -333,11 +325,10 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService * 构建发送参数 * * @param salarySend - * @param taxAgentName * @param salaryTemplate * @return */ - public SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, String taxAgentName, SalaryTemplatePO salaryTemplate) { + public SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, SalaryTemplatePO salaryTemplate) { // 发送通道 Set sendChannels = SalaryBillBO.buildSendChannels(salaryTemplate); if (CollectionUtils.isEmpty(sendChannels)) { @@ -408,8 +399,6 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService .backgroundBase64(backgroundBase64) // 云桥工资单消息图 .picUrl(picUrl) - // 扣缴义务人名称 - .taxAgentName(taxAgentName) // 工资单模板-薪资项目设置 .salaryItemSetList(salaryItemSetList) // 工资单模板-员工基本信息 @@ -462,11 +451,10 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService } } -// // 是否是合并计税 -// boolean isMerge = this.getSalarySendService(user).isMergeBySalarySend(salarySend); List salaryAcctEmployeeList = this.getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId()); List acctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); list = list.stream().filter(f -> acctEmployeeIds.contains(f.getEmployeeId())).collect(Collectors.toList()); + SalaryI18nUtil.i18nList(list); List employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).collect(Collectors.toList()); @@ -666,9 +654,6 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService Set sendChannels = salaryBillSendParam.getSendChannels(); - // 获取人员完整信息 - Map allEmployeeMap = this.getEmployeeWholeInfo(enableSendList); - List sendInfoUpdateList = Lists.newArrayList(); AtomicInteger index = new AtomicInteger(0); AtomicInteger part = new AtomicInteger(0); @@ -681,7 +666,7 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService if (sendChannels.contains(MessageChannelEnum.EMAIL) || sendChannels.contains(MessageChannelEnum.SMS)) { // 构建人员信息 - SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, allEmployeeMap.get(e.get("employeeId").toString())); + SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, e); //发送邮件 if (sendChannels.contains(MessageChannelEnum.EMAIL)) { @@ -715,20 +700,6 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService return sendInfoUpdateList.stream().map(SalarySendInfoPO::getId).collect(Collectors.toList()); } - /** - * 获取人员完整信息 - * - * @param enableSendList - * @return - */ - private Map getEmployeeWholeInfo(List> enableSendList) { - - List ids = enableSendList.stream().map(e -> Long.valueOf(e.get("employeeId").toString())).collect(Collectors.toList()); - - // 获取所有人员信息 - List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(ids); - return SalaryEntityUtil.convert2Map(simpleEmployees, e -> e.getEmployeeId() + ""); - } // /** 工资单发放 end **********************************************************************/ /** diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 120cbd78a..5ee35419d 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -1036,7 +1036,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService return listMaps; } // 所有个税扣缴义务人 -// Map taxAgentMap = SalaryEntityUtil.convert2Map(getTaxAgentService(user).listAll(), TaxAgentPO::getId, TaxAgentPO::getName); + Map taxAgentMap = SalaryEntityUtil.convert2Map(getTaxAgentService(user).listAll(), TaxAgentPO::getId, TaxAgentPO::getName); // 按人员分组核算数据 // Map> relationSalaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId); Map salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, salaryAcctEmployee -> salaryAcctEmployee.getEmployeeId() + "-" + salaryAcctEmployee.getTaxAgentId()); @@ -1058,42 +1058,42 @@ public class SalarySendServiceImpl extends Service implements SalarySendService Map finalEmpSubComMap = empComMap; boolean finalIsOrigin = isOrigin; list.forEach(e -> { + + SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.getOrDefault(e.getEmployeeId() + "-" + e.getTaxAgentId(), new SalaryAcctEmployeePO()); + DataCollectionEmployee hrmDepartmentComInfo = finalEmpSubComMap.getOrDefault(e.getEmployeeId(), new DataCollectionEmployee()); Map map = new LinkedHashMap<>(); - map.put("id", e.getId() + ""); - DataCollectionEmployee hrmDepartmentComInfo = finalEmpSubComMap.get(e.getEmployeeId()); - if (hrmDepartmentComInfo != null) { - map.put("subCompanyName", hrmDepartmentComInfo.getSubcompanyName()); - } else { - map.put("subCompanyName", ""); - } - if (hrmDepartmentComInfo != null) { - map.put("department", e.getDepartment()); - } - map.put("employeeId", e.getEmployeeId() + ""); - map.put("username", e.getUsername()); + map.put("id", e.getId()); + map.put("employeeId", e.getEmployeeId()); + map.put("taxAgentName", taxAgentMap.getOrDefault(salaryAcctEmployee.getTaxAgentId(), "")); + map.put("taxAgentId", salaryAcctEmployee.getTaxAgentId()); + map.put("username", hrmDepartmentComInfo.getUsername()); + + map.put("departmentName", salaryAcctEmployee.getDepartmentName()); + map.put("departmentId", salaryAcctEmployee.getDepartmentId()); + + map.put("subcompanyName", salaryAcctEmployee.getSubcompanyName()); + map.put("subcompanyId", salaryAcctEmployee.getSubcompanyId()); + map.put("jobtitleName", salaryAcctEmployee.getJobtitleName()); + map.put("jobtitleId", salaryAcctEmployee.getJobtitleId()); + map.put("companystartdate", hrmDepartmentComInfo.getCompanystartdate()); map.put("mobile", e.getMobile()); - map.put("jobNum", e.getJobNum()); - map.put("email", e.getEmail()); + map.put("dissmissdate", hrmDepartmentComInfo.getDismissdate()); + map.put("status", salaryAcctEmployee.getStatus()); + map.put("statusName", UserStatusEnum.getDefaultLabelByValue(Integer.valueOf(salaryAcctEmployee.getStatus()))); + map.put("workcode", hrmDepartmentComInfo.getWorkcode()); + map.put("sex", "0".equals(hrmDepartmentComInfo.getSex()) ? "男" : "女"); + map.put("idNo", hrmDepartmentComInfo.getIdNo()); + map.put("email", hrmDepartmentComInfo.getEmail()); + map.put("telephone", hrmDepartmentComInfo.getTelephone()); + map.put("jobcall", hrmDepartmentComInfo.getJobcall()); + map.put("jobcallId", hrmDepartmentComInfo.getJobcallId()); + map.put("birthday", hrmDepartmentComInfo.getBirthday()); + // map.put("employeeType", SalarySendEmployeeTypeEnum.getNameByValue(e.getEmployeeType())); // 单个人的核算数据 List resultValues = Lists.newArrayList(); - // 个税扣缴义务人 -// if (incomeCategorys.size() > 1) { -// List acctEmployees = relationSalaryAcctEmployeeMap.getOrDefault(e.getEmployeeId(), Collections.emptyList()); -// for (SalaryAcctEmployeePO salaryAcctEmployee : acctEmployees) { -// if (singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) { -// resultValues.add(singleEmpAcctMap.get(salaryAcctEmployee.getId())); -// } -// } -// } else { -// SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(e.getEmployeeId() + "-" + e.getTaxAgent()); -// if (salaryAcctEmployee != null && singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) { -// resultValues.add(singleEmpAcctMap.get(salaryAcctEmployee.getId())); -// } -// } - SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(e.getEmployeeId() + "-" + e.getTaxAgentId()); - if (salaryAcctEmployee != null && singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) { + if (singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) { resultValues.addAll(singleEmpAcctMap.get(salaryAcctEmployee.getId())); } // 薪资项目 @@ -1862,7 +1862,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService if (CollectionUtils.isEmpty(salaryTemplates)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100518, "没有默认模板,无法发送")); } - SalaryBillSendDTO salaryBillSendDTO = getSalaryBillService(user).buildSendParams(salarySendPO, taxAgentPO.getName(), salaryTemplates.get(0)); + SalaryBillSendDTO salaryBillSendDTO = getSalaryBillService(user).buildSendParams(salarySendPO, salaryTemplates.get(0)); SalaryTemplatePO salaryTemplate = salaryBillSendDTO.getSalaryTemplate(); if (salaryTemplate == null) {