From b1d3d2c445d276208d6b02b78eeb384115c6e5db Mon Sep 17 00:00:00 2001 From: sy Date: Tue, 30 Jan 2024 14:31:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E5=A4=8D=E5=88=B6action?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/CopyToPaySIArchiveAction.java | 149 ++++++++++++++++++ .../mapper/siarchives/OtherSchemeMapper.java | 7 + .../mapper/siarchives/OtherSchemeMapper.xml | 9 ++ .../salary/service/SIArchivesService.java | 9 ++ .../service/impl/SIArchivesServiceImpl.java | 124 +++++++++++++++ 5 files changed, 298 insertions(+) create mode 100644 src/com/engine/salary/action/CopyToPaySIArchiveAction.java diff --git a/src/com/engine/salary/action/CopyToPaySIArchiveAction.java b/src/com/engine/salary/action/CopyToPaySIArchiveAction.java new file mode 100644 index 000000000..6ff38ee6d --- /dev/null +++ b/src/com/engine/salary/action/CopyToPaySIArchiveAction.java @@ -0,0 +1,149 @@ +package com.engine.salary.action; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 拷贝福利档案并置为在缴 + * @Date: 2024/1/29 + **/ +@Slf4j +public class CopyToPaySIArchiveAction implements Action { + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private String tableName; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new CopyToPaySIArchiveAction.SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, CopyToPaySIArchiveAction.SalaryField::getSalaryName, CopyToPaySIArchiveAction.SalaryField::getValue)); + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("1"); + //增员 + String toCopyTaxAgentName = importData.get(0).get("待复制个税扣缴义务人").toString(); + String toUpdateTaxAgentName = importData.get(0).get("待更新个税扣缴义务人").toString(); + String payStartYearMonth = importData.get(0).getOrDefault("起始缴纳月", "").toString(); + if (StrUtil.isNotBlank(payStartYearMonth) && !SalaryDateUtil.checkYearMonth(payStartYearMonth)) { + requestInfo.getRequestManager().setMessage("起始缴纳月格式有误,正确格式示例为'2021-01'"); + return FAILURE_AND_CONTINUE; + } + + List toCopyTaxAgentPOS = getTaxAgentMapper().listByName(toCopyTaxAgentName); + List toUpdateTaxAgentPOS = getTaxAgentMapper().listByName(toUpdateTaxAgentName); + if(CollectionUtils.isEmpty(toCopyTaxAgentPOS)){ + requestInfo.getRequestManager().setMessage("待复制个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + if(CollectionUtils.isEmpty(toUpdateTaxAgentPOS)){ + requestInfo.getRequestManager().setMessage("待更新个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long toCopyTaxAgentId = toCopyTaxAgentPOS.get(0).getId(); + Long toUpdateTaxAgentId = toUpdateTaxAgentPOS.get(0).getId(); + Long employeeId = Long.valueOf(list.stream().filter(f -> f.salaryName.equals("员工id")).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("-1")); + User user = new User(Integer.parseInt(uid)); + //拷贝福利档案并置为在缴 + Map resultMap = getSIArchivesService(user).copyToPay(toCopyTaxAgentId, toUpdateTaxAgentId, employeeId, payStartYearMonth); + if (!"success".equals(resultMap.get("type").toString())) { + requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString()); + return FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + log.error("福利档案复制并置为在缴异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java index f468b0d45..6ad9fbe78 100644 --- a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java +++ b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java @@ -36,6 +36,13 @@ public interface OtherSchemeMapper { */ List getOtherById(@Param("ids")List ids); + /** + * 根据id获取单条 + * @param id + * @return + */ + InsuranceArchivesOtherSchemePO getOneById(@Param("id")Long id); + /** * 批量删除 * @param singletonList diff --git a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml index 2d67257b4..12adf7fb4 100644 --- a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml +++ b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml @@ -80,6 +80,15 @@ + + + UPDATE hrsa_other_archives diff --git a/src/com/engine/salary/service/SIArchivesService.java b/src/com/engine/salary/service/SIArchivesService.java index 0bdc90cd9..7f2f31866 100644 --- a/src/com/engine/salary/service/SIArchivesService.java +++ b/src/com/engine/salary/service/SIArchivesService.java @@ -94,6 +94,15 @@ public interface SIArchivesService { */ Map stayAddToPay(Collection ids); + /** + * 拷贝福利档案到新的个税扣缴义务人并置为在缴 + * @param toCopyTaxAgentId 被拷贝的福利档案所属个税扣缴义务人id + * @param toUpdateTaxAgentId 被更新的福利档案所属个税扣缴义务人id + * @param employeeId 福利档案所属人员id + * @return + */ + Map copyToPay(Long toCopyTaxAgentId, Long toUpdateTaxAgentId, Long employeeId, String payStartYearMonth); + /** * 待减员页面的删除待办 */ diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 6e1f5e94a..8871548f4 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -6,6 +6,7 @@ import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd; +import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBaseInfoBO; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO; import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; @@ -71,6 +72,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + private EncryptUtil encryptUtil = new EncryptUtil(); + private TaxAgentService getTaxAgentService(User user) { return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } @@ -1217,4 +1220,125 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return listPage; } + /** + * 拷贝福利档案到新的个税扣缴义务人并置为在缴 + */ + @Override + public Map copyToPay(Long toCopyTaxAgentId, Long toUpdateTaxAgentId, Long employeeId, String payStartYearMonth) { + if (toCopyTaxAgentId == null || toUpdateTaxAgentId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人不能为空")); + } + if (employeeId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "人员id不能为空")); + } + //获取待拷贝的福利档案明细 + InsuranceArchivesBaseInfoPO toCopyBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(toCopyTaxAgentId, employeeId); + if(toCopyBaseInfoPO == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "待复制个税扣缴义务人下该员工不存在福利档案,请检查后重试!")); + } + InsuranceArchivesSocialSchemePO toCopySocialInfo = getSocialSchemeMapper().getOneById(toCopyBaseInfoPO.getSocialArchivesId()); + InsuranceArchivesFundSchemePO toCopyFundInfo = getFundSchemeMapper().getOneById(toCopyBaseInfoPO.getFundArchivesId()); + InsuranceArchivesOtherSchemePO toCopyOtherInfo = getOtherSchemeMapper().getOneById(toCopyBaseInfoPO.getOtherArchivesId()); + //获取待更新的福利档案 + InsuranceArchivesBaseInfoPO toUpdateBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(toUpdateTaxAgentId, employeeId); + if(toUpdateBaseInfoPO == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "待更新个税扣缴义务人下该员工不存在福利档案,请检查后重试!")); + } + InsuranceArchivesSocialSchemePO toUpdateSocialInfo = getSocialSchemeMapper().getOneById(toUpdateBaseInfoPO.getSocialArchivesId()); + InsuranceArchivesFundSchemePO toUpdateFundInfo = getFundSchemeMapper().getOneById(toUpdateBaseInfoPO.getFundArchivesId()); + InsuranceArchivesOtherSchemePO toUpdateOtherInfo = getOtherSchemeMapper().getOneById(toUpdateBaseInfoPO.getOtherArchivesId()); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(toCopySocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.decrypt(toUpdateSocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.decrypt(toCopyFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.decrypt(toUpdateFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.decrypt(toCopyOtherInfo, InsuranceArchivesOtherSchemePO.class); + encryptUtil.decrypt(toUpdateOtherInfo, InsuranceArchivesOtherSchemePO.class); + + InsuranceArchivesBaseHistoryDTO socialAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopySocialInfo.getSocialSchemeId()) + .adjustAfterBaseJson(toCopySocialInfo.getSocialPaymentBaseString()) + .adjustAfterComBaseJson(toCopySocialInfo.getSocialPaymentComBaseString()) + .welfareType(toUpdateSocialInfo.getWelfareType()) + .employeeId(toUpdateSocialInfo.getEmployeeId()) + .paymentOrganization(toUpdateSocialInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateSocialInfo.getSocialSchemeId()) + .adjustBeforeBaseJson(toUpdateSocialInfo.getSocialPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateSocialInfo.getSocialPaymentComBaseString()) + .build(); + InsuranceArchivesBaseHistoryDTO fundAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopyFundInfo.getFundSchemeId()) + .adjustAfterBaseJson(toCopyFundInfo.getFundPaymentBaseString()) + .adjustAfterComBaseJson(toCopyFundInfo.getFundPaymentComBaseString()) + .welfareType(toUpdateFundInfo.getWelfareType()) + .employeeId(toUpdateFundInfo.getEmployeeId()) + .paymentOrganization(toUpdateFundInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateFundInfo.getFundSchemeId()) + .adjustBeforeBaseJson(toUpdateFundInfo.getFundPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateFundInfo.getFundPaymentComBaseString()) + .build(); + InsuranceArchivesBaseHistoryDTO otherAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopyOtherInfo.getOtherSchemeId()) + .adjustAfterBaseJson(toCopyOtherInfo.getOtherPaymentBaseString()) + .adjustAfterComBaseJson(toCopyOtherInfo.getOtherPaymentComBaseString()) + .welfareType(toUpdateOtherInfo.getWelfareType()) + .employeeId(toUpdateOtherInfo.getEmployeeId()) + .paymentOrganization(toUpdateOtherInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateOtherInfo.getOtherSchemeId()) + .adjustBeforeBaseJson(toUpdateOtherInfo.getOtherPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateOtherInfo.getOtherPaymentComBaseString()) + .build(); + List adjustHistoryList = new ArrayList<>(); + adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(socialAdjustInfo, (long) user.getUID())); + adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(fundAdjustInfo, (long) user.getUID())); + adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(otherAdjustInfo, (long) user.getUID())); + //更新字段 + toUpdateBaseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + + toUpdateSocialInfo.setSocialAccount(toCopySocialInfo.getSocialAccount()); + toUpdateSocialInfo.setSocialSchemeId(toCopySocialInfo.getSocialSchemeId()); + toUpdateSocialInfo.setSocialPaymentBaseString(toCopySocialInfo.getSocialPaymentBaseString()); + toUpdateSocialInfo.setSocialPaymentComBaseString(toCopySocialInfo.getSocialPaymentComBaseString()); + toUpdateSocialInfo.setNonPayment(toCopySocialInfo.getNonPayment()); + toUpdateSocialInfo.setUnderTake(toCopySocialInfo.getUnderTake()); + toUpdateSocialInfo.setSocialStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopySocialInfo.getSocialStartTime()); + toUpdateSocialInfo.setUpdateTime(new Date()); + + toUpdateFundInfo.setFundAccount(toCopyFundInfo.getFundAccount()); + toUpdateFundInfo.setSupplementFundAccount(toCopyFundInfo.getSupplementFundAccount()); + toUpdateFundInfo.setFundSchemeId(toCopyFundInfo.getFundSchemeId()); + toUpdateFundInfo.setFundPaymentBaseString(toCopyFundInfo.getFundPaymentBaseString()); + toUpdateFundInfo.setFundPaymentComBaseString(toCopyFundInfo.getFundPaymentComBaseString()); + toUpdateFundInfo.setNonPayment(toCopyFundInfo.getNonPayment()); + toUpdateFundInfo.setUnderTake(toCopyFundInfo.getUnderTake()); + toUpdateFundInfo.setFundStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopyFundInfo.getFundStartTime()); + toUpdateFundInfo.setUpdateTime(new Date()); + + toUpdateOtherInfo.setOtherSchemeId(toCopyOtherInfo.getOtherSchemeId()); + toUpdateOtherInfo.setOtherPaymentBaseString(toCopyOtherInfo.getOtherPaymentBaseString()); + toUpdateOtherInfo.setOtherPaymentComBaseString(toCopyOtherInfo.getOtherPaymentComBaseString()); + toUpdateOtherInfo.setNonPayment(toCopyOtherInfo.getNonPayment()); + toUpdateOtherInfo.setUnderTake(toCopyOtherInfo.getUnderTake()); + toUpdateOtherInfo.setOtherStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopyOtherInfo.getOtherStartTime()); + toUpdateOtherInfo.setUpdateTime(new Date()); + //档案入库 + encryptUtil.encrypt(toUpdateSocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.encrypt(toUpdateFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.encrypt(toUpdateOtherInfo, InsuranceArchivesOtherSchemePO.class); + + getInsuranceBaseInfoMapper().updateById(toUpdateBaseInfoPO); + getSocialSchemeMapper().updateById(toUpdateSocialInfo); + getFundSchemeMapper().updateById(toUpdateFundInfo); + getOtherSchemeMapper().updateById(toUpdateOtherInfo); + //基数调整记录入库 + siArchivesBiz.batchInsertAdjustHistory(adjustHistoryList, (long) user.getUID()); + + Map resultMap = new HashMap<>(2); + String resultMsg = "操作成功"; + String resultType = "success"; + + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } }