From 6a79b22c1720aeacdbddd8a2d7e8f2b0ba0fe9c5 Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 7 Feb 2024 17:39:26 +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=A2=9E=E5=8A=A0=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../po/InsuranceArchivesBaseInfoPO.java | 15 + .../po/InsuranceArchivesFundSchemePO.java | 20 + .../po/InsuranceArchivesOtherSchemePO.java | 18 + .../po/InsuranceArchivesSocialSchemePO.java | 19 + .../service/impl/SIArchivesServiceImpl.java | 981 +++++++++++------- .../service/impl/SICategoryServiceImpl.java | 112 +- .../service/impl/SISchemeServiceImpl.java | 272 +++-- 7 files changed, 934 insertions(+), 503 deletions(-) diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseInfoPO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseInfoPO.java index f05cc309d..1ed65489f 100644 --- a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseInfoPO.java +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesBaseInfoPO.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.siarchives.po; +import com.engine.salary.elog.annotation.ElogTransform; import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; import lombok.AllArgsConstructor; import lombok.Builder; @@ -19,65 +20,78 @@ import java.util.Date; @NoArgsConstructor @AllArgsConstructor //hrsa_insurance_base_info +@ElogTransform(name = "福利档案主表") public class InsuranceArchivesBaseInfoPO { /** * 主键id */ + @ElogTransform(name = "主键id") private Long id; /** * 员工id */ + @ElogTransform(name = "员工id") private Long employeeId; /** * 个税扣缴义务人id */ + @ElogTransform(name = "个税扣缴义务人id") private Long paymentOrganization; /** * 社保档案id */ + @ElogTransform(name = "社保档案id") private Long socialArchivesId; /** * 公积金档案id */ + @ElogTransform(name = "公积金档案id") private Long fundArchivesId; /** * 其他福利档案id */ + @ElogTransform(name = "其他福利档案id") private Long otherArchivesId; /** * 租户key */ + @ElogTransform(name = "租户key") private String tenantKey; /** * 创建人id */ + @ElogTransform(name = "创建人id") private Long creator; /** * 是否删除 */ + @ElogTransform(name = "是否删除") private Integer deleteType; /** * 创建时间 */ + @ElogTransform(name = "创建时间") private Date createTime; /** * 更新时间 */ + @ElogTransform(name = "更新时间") private Date updateTime; /** * 福利执行状态 */ + @ElogTransform(name = "福利执行状态") private String runStatus; /** @@ -85,6 +99,7 @@ public class InsuranceArchivesBaseInfoPO { * * @see DataCollectionEmployeeTypeEnum */ + @ElogTransform(name = "人员类型") private Integer employeeType; //---------条件------- diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesFundSchemePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesFundSchemePO.java index fc171c94b..15e37cfb0 100644 --- a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesFundSchemePO.java +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesFundSchemePO.java @@ -1,6 +1,7 @@ package com.engine.salary.entity.siarchives.po; import com.engine.salary.annotation.Encrypt; +import com.engine.salary.elog.annotation.ElogTransform; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -19,35 +20,42 @@ import java.util.Date; @NoArgsConstructor @AllArgsConstructor //hrsa_fund_archives +@ElogTransform(name = "福利档案明细表-公积金信息") public class InsuranceArchivesFundSchemePO { /** * 主键id */ + @ElogTransform(name = "主键id") private Long id; /** * 员工id */ + @ElogTransform(name = "员工id") private Long employeeId; /** * 福利类型 */ + @ElogTransform(name = "福利类型") private Integer welfareType; /** * 暂不缴纳 */ + @ElogTransform(name = "是否暂不缴纳") private Integer nonPayment; /** * 公积金起始缴纳月 */ + @ElogTransform(name = "公积金起始缴纳月") private String fundStartTime; /** * 公积金最后缴纳月 */ + @ElogTransform(name = "公积金最后缴纳月") private String fundEndTime; /** @@ -59,63 +67,75 @@ public class InsuranceArchivesFundSchemePO { /** * 公积金方案id */ + @ElogTransform(name = "公积金方案id") private Long fundSchemeId; /** * 公积金账号 */ + @ElogTransform(name = "公积金账号") private String fundAccount; /** * 补充公积金账号 */ + @ElogTransform(name = "补充公积金账号") private String supplementFundAccount; /** * 公积金缴纳组织 */ + @ElogTransform(name = "公积金缴纳组织") private Long paymentOrganization; /** * 公积金个人实际承担方 */ + @ElogTransform(name = "公积金个人实际承担方") private Integer underTake; /** * 公积金缴纳基数 */ @Encrypt + @ElogTransform(name = "公积金缴纳基数") private String fundPaymentBaseString; /** * 公积金缴纳基数——单位 */ @Encrypt + @ElogTransform(name = "公积金缴纳基数——单位") private String fundPaymentComBaseString; /** * 租户key */ + @ElogTransform(name = "租户key") private String tenantKey; /** * 创建人id */ + @ElogTransform(name = "创建人id") private Long creator; /** * 是否删除 */ + @ElogTransform(name = "是否删除") private Integer deleteType; /** * 创建时间 */ + @ElogTransform(name = "创建时间") private Date createTime; /** * 更新时间 */ + @ElogTransform(name = "更新时间") private Date updateTime; } diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesOtherSchemePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesOtherSchemePO.java index 9ad9d9668..71836e143 100644 --- a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesOtherSchemePO.java +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesOtherSchemePO.java @@ -1,6 +1,7 @@ package com.engine.salary.entity.siarchives.po; import com.engine.salary.annotation.Encrypt; +import com.engine.salary.elog.annotation.ElogTransform; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -19,35 +20,42 @@ import java.util.Date; @NoArgsConstructor @AllArgsConstructor //hrsa_other_archives +@ElogTransform(name = "福利档案明细表-其他福利信息") public class InsuranceArchivesOtherSchemePO { /** * 主键id */ + @ElogTransform(name = "主键id") private Long id; /** * 员工id */ + @ElogTransform(name = "员工id") private Long employeeId; /** * 暂不缴纳 */ + @ElogTransform(name = "是否暂不缴纳") private Integer nonPayment; /** * 福利类型 */ + @ElogTransform(name = "福利类型") private Integer welfareType; /** * 其他福利起始缴纳月 */ + @ElogTransform(name = "其他福利起始缴纳月") private String otherStartTime; /** * 其他福利最后缴纳月 */ + @ElogTransform(name = "其他福利最后缴纳月") private String otherEndTime; /** @@ -59,52 +67,62 @@ public class InsuranceArchivesOtherSchemePO { /** * 其他福利方案id */ + @ElogTransform(name = "其他福利方案id") private Long otherSchemeId; /** * 其他福利缴纳组织 */ + @ElogTransform(name = "其他福利缴纳组织") private Long paymentOrganization; /** * 其他福利个人实际承担方 */ + @ElogTransform(name = "其他福利个人实际承担方") private Integer underTake; /** * 其他福利缴纳基数 */ @Encrypt + @ElogTransform(name = "其他福利缴纳基数") private String otherPaymentBaseString; /** * 其他福利缴纳基数——单位 */ @Encrypt + @ElogTransform(name = "其他福利缴纳基数——单位") private String otherPaymentComBaseString; /** * 租户key */ + @ElogTransform(name = "租户key") private String tenantKey; /** * 创建人id */ + @ElogTransform(name = "创建人id") private Long creator; /** * 是否删除 */ + @ElogTransform(name = "是否删除") private Integer deleteType; /** * 创建时间 */ + @ElogTransform(name = "创建时间") private Date createTime; /** * 更新时间 */ + @ElogTransform(name = "更新时间") private Date updateTime; } diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesSocialSchemePO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesSocialSchemePO.java index 645e5215b..5e5c3cf9e 100644 --- a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesSocialSchemePO.java +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesSocialSchemePO.java @@ -1,6 +1,7 @@ package com.engine.salary.entity.siarchives.po; import com.engine.salary.annotation.Encrypt; +import com.engine.salary.elog.annotation.ElogTransform; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -19,36 +20,43 @@ import java.util.Date; @NoArgsConstructor @AllArgsConstructor //hrsa_social_archives +@ElogTransform(name = "福利档案明细表-社保信息") public class InsuranceArchivesSocialSchemePO { /** * 主键id */ + @ElogTransform(name = "主键id") private Long id; /** * 员工id */ + @ElogTransform(name = "员工id") private Long employeeId; /** * 暂不缴纳 */ + @ElogTransform(name = "是否暂不缴纳") private Integer nonPayment; /** * 福利类型 */ + @ElogTransform(name = "福利类型") private Integer welfareType; /** * 社保起始缴纳月 */ + @ElogTransform(name = "社保起始缴纳月") private String socialStartTime; /** * 社保最后缴纳月 */ + @ElogTransform(name = "社保最后缴纳月") private String socialEndTime; /** @@ -60,57 +68,68 @@ public class InsuranceArchivesSocialSchemePO { /** * 社保方案id */ + @ElogTransform(name = "社保方案id") private Long socialSchemeId; /** * 社保账号 */ + @ElogTransform(name = "社保账号") private String socialAccount; /** * 社保缴纳组织 */ + @ElogTransform(name = "社保缴纳组织") private Long paymentOrganization; /** * 社保个人实际承担方 */ + @ElogTransform(name = "社保个人实际承担方") private Integer underTake; /** * 社保缴纳基数 */ @Encrypt + @ElogTransform(name = "社保缴纳基数") private String socialPaymentBaseString; /** * 社保缴纳基数——单位 */ @Encrypt + @ElogTransform(name = "社保缴纳基数——单位") private String socialPaymentComBaseString; /** * 租户key */ + @ElogTransform(name = "租户key") private String tenantKey; /** * 创建人id */ + @ElogTransform(name = "创建人id") private Long creator; /** * 是否删除 */ + @ElogTransform(name = "是否删除") private Integer deleteType; /** * 创建时间 */ + @ElogTransform(name = "创建时间") private Date createTime; /** * 更新时间 */ + @ElogTransform(name = "更新时间") private Date updateTime; } diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 798eed713..5f317d94b 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -18,7 +18,9 @@ import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd; import com.engine.salary.common.SalaryContext; +import com.engine.salary.config.SalaryElogConfig; import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.elog.entity.dto.LoggerContext; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBO; @@ -33,6 +35,7 @@ import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.OperateTypeEnum; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum; @@ -40,6 +43,7 @@ import com.engine.salary.enums.siaccount.EmployeeStatusEnum; import com.engine.salary.enums.sicategory.*; import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.EmployMapper; import com.engine.salary.mapper.siarchives.*; import com.engine.salary.mapper.sicategory.ICategoryMapper; import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; @@ -152,6 +156,10 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return ServiceUtil.getService(SISchemeServiceImpl.class,user); } + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } + @Override public Map getTips(Map params) { return commandExecutor.execute(new SIArchivesTipsCmd(params, user)); @@ -172,6 +180,18 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService Long paymentOrganization = welfareTypeEnum != null ? Long.valueOf(Util.null2String(params.get("paymentOrganization"))) : null; // apidatas = siArchivesBiz.getBaseForm(welfareTypeEnum, employeeId, (long) user.getUID(), user, paymentOrganization); apidatas = getBaseForm(welfareTypeEnum, employeeId, paymentOrganization, taxAgentPOS); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); +// loggerContext.setTargetId(String.valueOf(form.getId())); +// loggerContext.setTargetName(form.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看福利档案基础信息")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看福利档案基础信息") + + ": " + "人员id" + "-" + employeeId + "," + "个税扣缴义务人id" + "-" +paymentOrganization + "," + + (welfareTypeEnum == null ? SalaryI18nUtil.getI18nLabel(0, "员工基本信息") + : SalaryI18nUtil.getI18nLabel(welfareTypeEnum.getLabelId(), welfareTypeEnum.getDefaultLabel()))); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); return apidatas; } @@ -188,6 +208,17 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService } // apidatas = siArchivesBiz.getPaymentForm(user, welfareTypeEnum, employeeId, (long) user.getUID(), schemeId, paymentOrganization); apidatas = getPaymentForm(user, welfareTypeEnum, employeeId, schemeId, paymentOrganization); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); +// loggerContext.setTargetId(String.valueOf(form.getId())); +// loggerContext.setTargetName(form.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看福利档案缴纳基数")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看缴纳基数明细") + + ": " + "人员id" + "-" + employeeId + "," + "个税扣缴义务人id" + "-" +paymentOrganization + "," + + SalaryI18nUtil.getI18nLabel(welfareTypeEnum.getLabelId(), welfareTypeEnum.getDefaultLabel())); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); return apidatas; } @@ -477,7 +508,13 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService List socialArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); List fundArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); List otherArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); - + //获取子表数据,方便记录操作日志 + List socialArchives = getSocialSchemeMapper().getSocialById(socialArchiveDelIds); + List fundArchives = getFundSchemeMapper().getFundById(fundArchiveDelIds); + List otherArchives = getOtherSchemeMapper().getOtherById(otherArchiveDelIds); + Map socialArchiveMap = SalaryEntityUtil.convert2Map(socialArchives, InsuranceArchivesSocialSchemePO::getId); + Map fundArchiveMap = SalaryEntityUtil.convert2Map(fundArchives, InsuranceArchivesFundSchemePO::getId); + Map otherArchiveMap = SalaryEntityUtil.convert2Map(otherArchives, InsuranceArchivesOtherSchemePO::getId); // 删除社保档案主表及3张明细表数据 if(CollectionUtils.isNotEmpty(archiveDelIds)){ getInsuranceBaseInfoMapper().deleteByIds(archiveDelIds); @@ -491,6 +528,65 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService if(CollectionUtils.isNotEmpty(otherArchiveDelIds)){ getOtherSchemeMapper().deleteByIds(otherArchiveDelIds); } + //记录操作日志 + List targetPOList = insuranceArchivesList.stream().filter(f -> archiveDelIds.contains(f.getId())).collect(Collectors.toList()); + if (targetPOList.size() > 0) { + targetPOList.forEach(targetPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + targetPO.setDeleteType(DeleteTypeEnum.DELETED.getValue()); + //记录主表操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利档案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利档案") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //记录明细表操作日志 + InsuranceArchivesSocialSchemePO socialTargetDetail = socialArchiveMap.get(targetPO.getSocialArchivesId()); + if (socialTargetDetail != null) { + socialTargetDetail.setDeleteType(DeleteTypeEnum.DELETED.getValue()); + LoggerContext detailLoggerContext = new LoggerContext<>(); + detailLoggerContext.setUser(user); + detailLoggerContext.setTargetId(String.valueOf(targetPO.getId())); + detailLoggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-社保明细")); + detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-社保明细") + ":" + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setNewValues(socialTargetDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(detailLoggerContext); + } + InsuranceArchivesFundSchemePO fundTargetDetail = fundArchiveMap.get(targetPO.getFundArchivesId()); + if (fundTargetDetail != null) { + fundTargetDetail.setDeleteType(DeleteTypeEnum.DELETED.getValue()); + LoggerContext detailLoggerContext = new LoggerContext<>(); + detailLoggerContext.setUser(user); + detailLoggerContext.setTargetId(String.valueOf(targetPO.getId())); + detailLoggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-公积金明细")); + detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-公积金明细") + ":" + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setNewValues(fundTargetDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(detailLoggerContext); + } + InsuranceArchivesOtherSchemePO otherTargetDetail = otherArchiveMap.get(targetPO.getOtherArchivesId()); + if (otherTargetDetail != null) { + otherTargetDetail.setDeleteType(DeleteTypeEnum.DELETED.getValue()); + LoggerContext detailLoggerContext = new LoggerContext<>(); + detailLoggerContext.setUser(user); + detailLoggerContext.setTargetId(String.valueOf(targetPO.getId())); + detailLoggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-其他福利明细")); + detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利档案-其他福利明细") + ":" + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + detailLoggerContext.setNewValues(otherTargetDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(detailLoggerContext); + } + }); + } } //新增社保、公积金、其他福利档案、福利档案基础信息 @@ -781,12 +877,28 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService } /** - * 批量变更档案列表的runStatus + * 批量变更档案列表的runStatus,目前仅在待增员tab中删除待办使用,后边其他方调用时需修改操作日志记录 */ @Override public void updateRunStatus(InsuranceArchivesBaseInfoPO po) { - getInsuranceBaseInfoMapper().updateRunStatusByIds(po); + //记录操作日志 + List targetPOList = getInsuranceBaseInfoMapper().listByIds(po.getIds()); + if (targetPOList != null && targetPOList.size() > 0) { + targetPOList.forEach(targetPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "待增员档案-删除待办")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "待增员档案-删除待办") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); +// loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + }); + } } @Override @@ -828,7 +940,23 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService if (stayDelPO.getIds().size() > 0) { getInsuranceBaseInfoMapper().updateRunStatusByIds(stayDelPO); } - + //记录操作日志 + Map oldBaseInfoMap = SalaryEntityUtil.convert2Map(pos, e -> e.getPaymentOrganization() + "-" + e.getEmployeeId()); + List newPos = getInsuranceBaseInfoMapper().listByIds(ids); + newPos.forEach(targetPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "停缴档案-取消停缴")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "停缴档案-取消停缴") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldBaseInfoMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId())); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + }); } /** @@ -908,6 +1036,24 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService if (toStopBaseInfoIdList.size() > 0) { getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder() .ids(toStopBaseInfoIdList).runStatus(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()).build()); + + //记录操作日志 + toStopBaseInfoIdList.forEach(f -> { + InsuranceArchivesBaseInfoPO targetPO = getInsuranceBaseInfoMapper().getById(f); + if (targetPO != null) { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案减员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "停缴一名在缴员工") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + }); } Map resultMap = new HashMap<>(2); @@ -1127,6 +1273,23 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService .ids(part).runStatus(EmployeeStatusEnum.PAYING.getValue()).build()); }); + //记录操作日志 + toPayBaseInfoIdList.forEach(f -> { + InsuranceArchivesBaseInfoPO targetPO = getInsuranceBaseInfoMapper().getById(f); + if (targetPO != null) { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案增员")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "增加一名在缴员工") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + }); } Map resultMap = new HashMap<>(2); @@ -1239,7 +1402,19 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService .runStatus(EmployeeStatusEnum.PAYING.getValue()) .build()); }); - + nowList.forEach(targetPO -> { + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "待减员档案-删除待办")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "待减员档案-删除待办") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); +// loggerContext.setNewValues(targetPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + }); } } @@ -2725,145 +2900,157 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService public void otherSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { long employeeId = user.getUID(); - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + InsuranceArchivesOtherSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesOtherSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0, "员工id为空"), param, param.getEmployeeId()); - InsuranceArchivesOtherSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesOtherSaveParam.class); - SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0, "员工id为空"), param, param.getEmployeeId()); + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + //创建操作日志记录对象 + InsuranceArchivesBaseInfoPO targetPO = new InsuranceArchivesBaseInfoPO(); + InsuranceArchivesOtherSchemePO targetDetailPO = new InsuranceArchivesOtherSchemePO(); - if (org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherStartTime())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherEndTime())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); - } - - List otherIds = new ArrayList(); - otherIds.add(param.getId()); - List oldOtherInfoList = otherSchemeMapper.getOtherById(otherIds); + List otherIds = new ArrayList(); + otherIds.add(param.getId()); + List oldOtherInfoList = getOtherSchemeMapper().getOtherById(otherIds); + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getOtherSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + if (oldOtherInfoList.size() == 1) { + InsuranceArchivesOtherSchemePO oldOtherInfo = oldOtherInfoList.get(0); //设置福利档案基数调整记录数据 - InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() - .adjustAfterSchemeId(param.getOtherSchemeId()) - .adjustAfterBaseJson(paramReq.getPaymentForm()) - .adjustAfterComBaseJson(paramReq.getPaymentComForm()) - .welfareType(paramReq.getWelfareType().getValue()) - .employeeId(param.getEmployeeId()) - .paymentOrganization(param.getPaymentOrganization()) - .build(); - - if (oldOtherInfoList.size() == 1) { - InsuranceArchivesOtherSchemePO oldOtherInfo = oldOtherInfoList.get(0); - //设置福利档案基数调整记录数据 - encryptUtil.decrypt(oldOtherInfo, InsuranceArchivesOtherSchemePO.class); - adjustInfo.setAdjustBeforeBaseJson(oldOtherInfo.getOtherPaymentBaseString()); - adjustInfo.setAdjustBeforeSchemeId(oldOtherInfo.getOtherSchemeId()); - adjustInfo.setAdjustBeforeComBaseJson(oldOtherInfo.getOtherPaymentComBaseString()); - //新数据 - InsuranceArchivesOtherSchemePO updateOtherInfo = - InsuranceArchivesOtherSchemePO.builder() - .id(oldOtherInfo.getId()) - .otherSchemeId(param.getOtherSchemeId()) - .otherStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) - .underTake(param.getUnderTake()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .welfareType(paramReq.getWelfareType().getValue()) - .otherEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) - .employeeId(param.getEmployeeId()) - .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) - .updateTime(new Date()) - .nonPayment(param.getNonPayment()) - .creator(employeeId) - .paymentOrganization(param.getPaymentOrganization()) - .otherPaymentBaseString(paramReq.getPaymentForm()) - .build(); - //校验福利基数是否符合上下限要求, - if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + encryptUtil.decrypt(oldOtherInfo, InsuranceArchivesOtherSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldOtherInfo.getOtherPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldOtherInfo.getOtherSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldOtherInfo.getOtherPaymentComBaseString()); + //新数据 + InsuranceArchivesOtherSchemePO updateOtherInfo = + InsuranceArchivesOtherSchemePO.builder() + .id(oldOtherInfo.getId()) + .otherSchemeId(param.getOtherSchemeId()) + .otherStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) + .underTake(param.getUnderTake()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .welfareType(paramReq.getWelfareType().getValue()) + .otherEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) + .employeeId(param.getEmployeeId()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .updateTime(new Date()) + .nonPayment(param.getNonPayment()) + .creator(employeeId) + .paymentOrganization(param.getPaymentOrganization()) + .otherPaymentBaseString(paramReq.getPaymentForm()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); } - //需要拆分个人和公司福利基数时 - if (welBaseDiffSign) { - updateOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); - //校验福利基数是否符合上下限要求 - if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); - } + } + encryptUtil.encrypt(updateOtherInfo, InsuranceArchivesOtherSchemePO.class); + getOtherSchemeMapper().updateById(updateOtherInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setOtherArchivesId(updateOtherInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(updateOtherInfo, InsuranceArchivesOtherSchemePO.class); + targetDetailPO = updateOtherInfo; + } else { + getOtherSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesOtherSchemePO insertOtherInfo = InsuranceArchivesOtherSchemePO.builder() + .otherSchemeId(param.getOtherSchemeId()) + .otherStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) + .underTake(param.getUnderTake()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .welfareType(paramReq.getWelfareType().getValue()) + .otherEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) + .employeeId(param.getEmployeeId()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(new Date()) + .updateTime(new Date()) + .nonPayment(param.getNonPayment()) + .creator(employeeId) + .paymentOrganization(param.getPaymentOrganization()) + .otherPaymentBaseString(paramReq.getPaymentForm()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); } - encryptUtil.encrypt(updateOtherInfo, InsuranceArchivesOtherSchemePO.class); - otherSchemeMapper.updateById(updateOtherInfo); - //更新base_info表状态 - InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); - if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { - //对于非系统人员,编辑后状态切换为正在缴纳 - baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); - } - baseInfoPO.setOtherArchivesId(updateOtherInfo.getId()); - getInsuranceBaseInfoMapper().updateById(baseInfoPO); - sqlSession.commit(); - } else { - otherSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder() + } + encryptUtil.encrypt(insertOtherInfo, InsuranceArchivesOtherSchemePO.class); + getOtherSchemeMapper().insert(insertOtherInfo); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List otherInfos = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() .employeeId(param.getEmployeeId()) .paymentOrganization(param.getPaymentOrganization()) .build()); - //新建社保档案,并关联主表 - InsuranceArchivesOtherSchemePO insertOtherInfo = InsuranceArchivesOtherSchemePO.builder() - .otherSchemeId(param.getOtherSchemeId()) - .otherStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) - .underTake(param.getUnderTake()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .welfareType(paramReq.getWelfareType().getValue()) - .otherEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) - .employeeId(param.getEmployeeId()) - .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) - .createTime(new Date()) - .updateTime(new Date()) - .nonPayment(param.getNonPayment()) - .creator(employeeId) - .paymentOrganization(param.getPaymentOrganization()) - .otherPaymentBaseString(paramReq.getPaymentForm()) - .build(); - //校验福利基数是否符合上下限要求, - if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + baseInfoPO.setOtherArchivesId(otherInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); } - //需要拆分个人和公司福利基数时 - if (welBaseDiffSign) { - insertOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); - //校验福利基数是否符合上下限要求 - if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); - } - } - encryptUtil.encrypt(insertOtherInfo, InsuranceArchivesOtherSchemePO.class); - otherSchemeMapper.insert(insertOtherInfo); - sqlSession.commit(); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); - InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); - if(baseInfoPO != null) { - List otherInfos = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() - .employeeId(param.getEmployeeId()) - .paymentOrganization(param.getPaymentOrganization()) - .build()); - baseInfoPO.setOtherArchivesId(otherInfos.get(0).getId()); - //对于非系统人员,编辑后状态切换为正在缴纳 - if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { - baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); - } - getInsuranceBaseInfoMapper().updateById(baseInfoPO); - } else { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); - } + targetPO = baseInfoPO; + encryptUtil.decrypt(insertOtherInfo, InsuranceArchivesOtherSchemePO.class); + targetDetailPO = insertOtherInfo; + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); } - - //生成福利档案基数调整记录数据 - List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); - //福利档案基数调整记录数据入库 - batchInsertAdjustHistory(adjustHistoryList); - - } finally { - sqlSession.close(); } + //记录操作日志 + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-其他福利明细保存")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-其他福利明细保存") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetDetailPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); + } /** @@ -2872,149 +3059,159 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ public void fundSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { long employeeId = user.getUID(); - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); - InsuranceArchivesFundSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesFundSaveParam.class); - SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0,"员工id为空"), param, param.getEmployeeId()); + InsuranceArchivesFundSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesFundSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0,"员工id为空"), param, param.getEmployeeId()); - if (org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) && !SalaryDateUtil.checkYearMonth(param.getFundStartTime())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) && !SalaryDateUtil.checkYearMonth(param.getFundEndTime())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); - } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) && !SalaryDateUtil.checkYearMonth(param.getFundStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) && !SalaryDateUtil.checkYearMonth(param.getFundEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + //创建操作日志记录对象 + InsuranceArchivesBaseInfoPO targetPO = new InsuranceArchivesBaseInfoPO(); + InsuranceArchivesFundSchemePO targetDetailPO = new InsuranceArchivesFundSchemePO(); - List fundIds = new ArrayList(); - fundIds.add(param.getId()); - List oldFundInfoList = fundSchemeMapper.getFundById(fundIds); + List fundIds = new ArrayList(); + fundIds.add(param.getId()); + List oldFundInfoList = getFundSchemeMapper().getFundById(fundIds); + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getFundSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + if (oldFundInfoList.size() == 1) { + InsuranceArchivesFundSchemePO oldFundInfo = oldFundInfoList.get(0); //设置福利档案基数调整记录数据 - InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() - .adjustAfterSchemeId(param.getFundSchemeId()) - .adjustAfterBaseJson(paramReq.getPaymentForm()) - .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + encryptUtil.decrypt(oldFundInfo, InsuranceArchivesFundSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldFundInfo.getFundPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldFundInfo.getFundSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldFundInfo.getFundPaymentComBaseString()); + //新数据 + InsuranceArchivesFundSchemePO updateFundInfo = InsuranceArchivesFundSchemePO.builder() + .id(oldFundInfo.getId()) + .fundSchemeId(param.getFundSchemeId()) + .fundAccount(param.getFundAccount()) + .fundEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) + .fundStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) + .fundPaymentBaseString(paramReq.getPaymentForm()) + .supplementFundAccount(param.getSupplementFundAccount()) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .underTake(param.getUnderTake()) + .paymentOrganization(param.getPaymentOrganization()) + .updateTime(new Date()) .welfareType(paramReq.getWelfareType().getValue()) .employeeId(param.getEmployeeId()) - .paymentOrganization(param.getPaymentOrganization()) .build(); - - if (oldFundInfoList.size() == 1) { - InsuranceArchivesFundSchemePO oldFundInfo = oldFundInfoList.get(0); - //设置福利档案基数调整记录数据 - encryptUtil.decrypt(oldFundInfo, InsuranceArchivesFundSchemePO.class); - adjustInfo.setAdjustBeforeBaseJson(oldFundInfo.getFundPaymentBaseString()); - adjustInfo.setAdjustBeforeSchemeId(oldFundInfo.getFundSchemeId()); - adjustInfo.setAdjustBeforeComBaseJson(oldFundInfo.getFundPaymentComBaseString()); - //新数据 - InsuranceArchivesFundSchemePO updateFundInfo = InsuranceArchivesFundSchemePO.builder() - .id(oldFundInfo.getId()) - .fundSchemeId(param.getFundSchemeId()) - .fundAccount(param.getFundAccount()) - .fundEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) - .fundStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) - .fundPaymentBaseString(paramReq.getPaymentForm()) - .supplementFundAccount(param.getSupplementFundAccount()) - .creator(employeeId) - .nonPayment(param.getNonPayment()) - .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .underTake(param.getUnderTake()) - .paymentOrganization(param.getPaymentOrganization()) - .updateTime(new Date()) - .welfareType(paramReq.getWelfareType().getValue()) - .employeeId(param.getEmployeeId()) - .build(); - //校验福利基数是否符合上下限要求, - if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); } - //需要拆分个人和公司福利基数时 - if (welBaseDiffSign) { - updateFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); - //校验福利基数是否符合上下限要求 - if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); - } + } + encryptUtil.encrypt(updateFundInfo, InsuranceArchivesFundSchemePO.class); + getFundSchemeMapper().updateById(updateFundInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setFundArchivesId(updateFundInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(updateFundInfo, InsuranceArchivesFundSchemePO.class); + targetDetailPO = updateFundInfo; + } else { + getFundSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesFundSchemePO insertFundInfo = InsuranceArchivesFundSchemePO.builder() + .fundSchemeId(param.getFundSchemeId()) + .fundAccount(param.getFundAccount()) + .fundEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) + .fundStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) + .fundPaymentBaseString(paramReq.getPaymentForm()) + .supplementFundAccount(param.getSupplementFundAccount()) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .underTake(param.getUnderTake()) + .paymentOrganization(param.getPaymentOrganization()) + .createTime(new Date()) + .updateTime(new Date()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); } - encryptUtil.encrypt(updateFundInfo, InsuranceArchivesFundSchemePO.class); - fundSchemeMapper.updateById(updateFundInfo); - //更新base_info表状态 - InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); - if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { - //对于非系统人员,编辑后状态切换为正在缴纳 - baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); - } - baseInfoPO.setFundArchivesId(updateFundInfo.getId()); - getInsuranceBaseInfoMapper().updateById(baseInfoPO); - sqlSession.commit(); - } else { - fundSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder() + } + encryptUtil.encrypt(insertFundInfo, InsuranceArchivesFundSchemePO.class); + getFundSchemeMapper().insert(insertFundInfo); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List fundInfos = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() .employeeId(param.getEmployeeId()) .paymentOrganization(param.getPaymentOrganization()) .build()); - //新建社保档案,并关联主表 - InsuranceArchivesFundSchemePO insertFundInfo = InsuranceArchivesFundSchemePO.builder() - .fundSchemeId(param.getFundSchemeId()) - .fundAccount(param.getFundAccount()) - .fundEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) - .fundStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) - .fundPaymentBaseString(paramReq.getPaymentForm()) - .supplementFundAccount(param.getSupplementFundAccount()) - .creator(employeeId) - .nonPayment(param.getNonPayment()) - .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .underTake(param.getUnderTake()) - .paymentOrganization(param.getPaymentOrganization()) - .createTime(new Date()) - .updateTime(new Date()) - .welfareType(paramReq.getWelfareType().getValue()) - .employeeId(param.getEmployeeId()) - .build(); - //校验福利基数是否符合上下限要求, - if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); - } - //需要拆分个人和公司福利基数时 - if (welBaseDiffSign) { - insertFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); - //校验福利基数是否符合上下限要求 - if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); - } - } - encryptUtil.encrypt(insertFundInfo, InsuranceArchivesFundSchemePO.class); - fundSchemeMapper.insert(insertFundInfo); - sqlSession.commit(); - - InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); - if(baseInfoPO != null) { - List fundInfos = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() - .employeeId(param.getEmployeeId()) - .paymentOrganization(param.getPaymentOrganization()) - .build()); - baseInfoPO.setFundArchivesId(fundInfos.get(0).getId()); - //对于非系统人员,编辑后状态切换为正在缴纳 - if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { - baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); - } - getInsuranceBaseInfoMapper().updateById(baseInfoPO); - } else { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + baseInfoPO.setFundArchivesId(fundInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + targetPO = baseInfoPO; + encryptUtil.decrypt(insertFundInfo, InsuranceArchivesFundSchemePO.class); + targetDetailPO = insertFundInfo; + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); } - - //生成福利档案基数调整记录数据 - List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); - //福利档案基数调整记录数据入库 - batchInsertAdjustHistory(adjustHistoryList); - - } finally { - sqlSession.close(); } - + //记录操作日志 + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-公积金明细保存")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-公积金明细保存") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetDetailPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); } /** @@ -3023,154 +3220,164 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ public void socialSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { long employeeId = user.getUID(); - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + InsuranceArchivesSocialSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesSocialSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0,"员工id为空"), param, param.getEmployeeId()); - InsuranceArchivesSocialSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesSocialSaveParam.class); - SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0,"员工id为空"), param, param.getEmployeeId()); - - if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialStartTime())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "社保起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialEndTime())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "社保最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); - } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "社保起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "社保最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } // //删除社保数据 // socialSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); - //查询已有数据 - List socialIds = new ArrayList(); - socialIds.add(param.getId()); - List oldSocialInfoList = socialSchemeMapper.getSocialById(socialIds); - + //创建操作日志记录对象 + InsuranceArchivesBaseInfoPO targetPO = new InsuranceArchivesBaseInfoPO(); + InsuranceArchivesSocialSchemePO targetDetailPO = new InsuranceArchivesSocialSchemePO(); + //查询已有数据 + List socialIds = new ArrayList(); + socialIds.add(param.getId()); + List oldSocialInfoList = getSocialSchemeMapper().getSocialById(socialIds); + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getSocialSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //组装新数据 + if (oldSocialInfoList.size() == 1) { + //老数据 + InsuranceArchivesSocialSchemePO oldSocialInfo = oldSocialInfoList.get(0); //设置福利档案基数调整记录数据 - InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() - .adjustAfterSchemeId(param.getSocialSchemeId()) - .adjustAfterBaseJson(paramReq.getPaymentForm()) - .adjustAfterComBaseJson(paramReq.getPaymentComForm()) - .welfareType(paramReq.getWelfareType().getValue()) - .employeeId(param.getEmployeeId()) - .paymentOrganization(param.getPaymentOrganization()) - .build(); - - //组装新数据 - if (oldSocialInfoList.size() == 1) { - //老数据 - InsuranceArchivesSocialSchemePO oldSocialInfo = oldSocialInfoList.get(0); - //设置福利档案基数调整记录数据 - encryptUtil.decrypt(oldSocialInfo, InsuranceArchivesSocialSchemePO.class); - adjustInfo.setAdjustBeforeBaseJson(oldSocialInfo.getSocialPaymentBaseString()); - adjustInfo.setAdjustBeforeSchemeId(oldSocialInfo.getSocialSchemeId()); - adjustInfo.setAdjustBeforeComBaseJson(oldSocialInfo.getSocialPaymentComBaseString()); - //新数据 - InsuranceArchivesSocialSchemePO updateSocialInfo = - InsuranceArchivesSocialSchemePO.builder() - .id(oldSocialInfo.getId()) - .welfareType(paramReq.getWelfareType().getValue()) - .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) - .socialPaymentBaseString(paramReq.getPaymentForm()) - .socialSchemeId(param.getSocialSchemeId()) - .socialEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) - .socialStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) - .creator(employeeId) - .nonPayment(param.getNonPayment()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .employeeId(param.getEmployeeId()) - .updateTime(new Date()) - .underTake(param.getUnderTake()) - .socialAccount(param.getSchemeAccount()) - .paymentOrganization(param.getPaymentOrganization()) - .build(); + encryptUtil.decrypt(oldSocialInfo, InsuranceArchivesSocialSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldSocialInfo.getSocialPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldSocialInfo.getSocialSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldSocialInfo.getSocialPaymentComBaseString()); + //新数据 + InsuranceArchivesSocialSchemePO updateSocialInfo = + InsuranceArchivesSocialSchemePO.builder() + .id(oldSocialInfo.getId()) + .welfareType(paramReq.getWelfareType().getValue()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .socialPaymentBaseString(paramReq.getPaymentForm()) + .socialSchemeId(param.getSocialSchemeId()) + .socialEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) + .socialStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(param.getEmployeeId()) + .updateTime(new Date()) + .underTake(param.getUnderTake()) + .socialAccount(param.getSchemeAccount()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); //校验福利基数是否符合上下限要求 - if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); } - //需要拆分个人和公司福利基数时 - if (welBaseDiffSign) { - updateSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); - //校验福利基数是否符合上下限要求 - if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); - } + } + encryptUtil.encrypt(updateSocialInfo, InsuranceArchivesSocialSchemePO.class); + getSocialSchemeMapper().updateById(updateSocialInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setSocialArchivesId(updateSocialInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + + targetPO = baseInfoPO; + encryptUtil.decrypt(updateSocialInfo, InsuranceArchivesSocialSchemePO.class); + targetDetailPO = updateSocialInfo; + } else { + getSocialSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesSocialSchemePO insertSocialInfo = + InsuranceArchivesSocialSchemePO.builder() + .welfareType(paramReq.getWelfareType().getValue()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .socialPaymentBaseString(paramReq.getPaymentForm()) + .socialSchemeId(param.getSocialSchemeId()) + .socialEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) + .socialStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(param.getEmployeeId()) + .createTime(new Date()) + .updateTime(new Date()) + .underTake(param.getUnderTake()) + .socialAccount(param.getSchemeAccount()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); } - encryptUtil.encrypt(updateSocialInfo, InsuranceArchivesSocialSchemePO.class); - socialSchemeMapper.updateById(updateSocialInfo); - //更新base_info表状态 - InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); - if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { - //对于非系统人员,编辑后状态切换为正在缴纳 - baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); - } - baseInfoPO.setSocialArchivesId(updateSocialInfo.getId()); - getInsuranceBaseInfoMapper().updateById(baseInfoPO); - sqlSession.commit(); - } else { - socialSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() + } + encryptUtil.encrypt(insertSocialInfo, InsuranceArchivesSocialSchemePO.class); + getSocialSchemeMapper().insert(insertSocialInfo); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List socialInfos = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() .employeeId(param.getEmployeeId()) .paymentOrganization(param.getPaymentOrganization()) .build()); - //新建社保档案,并关联主表 - InsuranceArchivesSocialSchemePO insertSocialInfo = - InsuranceArchivesSocialSchemePO.builder() - .welfareType(paramReq.getWelfareType().getValue()) - .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) - .socialPaymentBaseString(paramReq.getPaymentForm()) - .socialSchemeId(param.getSocialSchemeId()) - .socialEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) - .socialStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) - .creator(employeeId) - .nonPayment(param.getNonPayment()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .employeeId(param.getEmployeeId()) - .createTime(new Date()) - .updateTime(new Date()) - .underTake(param.getUnderTake()) - .socialAccount(param.getSchemeAccount()) - .paymentOrganization(param.getPaymentOrganization()) - .build(); - //校验福利基数是否符合上下限要求 - if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); - } - //需要拆分个人和公司福利基数时 - if (welBaseDiffSign) { - insertSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); - //校验福利基数是否符合上下限要求 - if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); - } - } - encryptUtil.encrypt(insertSocialInfo, InsuranceArchivesSocialSchemePO.class); - socialSchemeMapper.insert(insertSocialInfo); - sqlSession.commit(); - - InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); - if(baseInfoPO != null) { - List socialInfos = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() - .employeeId(param.getEmployeeId()) - .paymentOrganization(param.getPaymentOrganization()) - .build()); - baseInfoPO.setSocialArchivesId(socialInfos.get(0).getId()); - //对于非系统人员,编辑后状态切换为正在缴纳 - if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { - baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); - } - getInsuranceBaseInfoMapper().updateById(baseInfoPO); - } else { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + baseInfoPO.setSocialArchivesId(socialInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + targetPO = baseInfoPO; + encryptUtil.decrypt(insertSocialInfo, InsuranceArchivesSocialSchemePO.class); + targetDetailPO = insertSocialInfo; + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); } - - //生成福利档案基数调整记录数据 - List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); - //福利档案基数调整记录数据入库 - batchInsertAdjustHistory(adjustHistoryList); - } finally { - sqlSession.close(); } + //记录操作日志 + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-社保明细保存")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-社保明细保存") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setNewValues(targetDetailPO); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); } /** diff --git a/src/com/engine/salary/service/impl/SICategoryServiceImpl.java b/src/com/engine/salary/service/impl/SICategoryServiceImpl.java index 11b7cf378..453ff9729 100644 --- a/src/com/engine/salary/service/impl/SICategoryServiceImpl.java +++ b/src/com/engine/salary/service/impl/SICategoryServiceImpl.java @@ -6,6 +6,8 @@ import com.api.browser.util.ConditionFactory; import com.api.browser.util.ConditionType; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.salary.config.SalaryElogConfig; +import com.engine.salary.elog.entity.dto.LoggerContext; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.entity.sicategory.bo.ICategoryBO; @@ -15,6 +17,7 @@ import com.engine.salary.entity.sicategory.dto.ICategoryListDTO; import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.enums.OperateTypeEnum; import com.engine.salary.enums.sicategory.DataTypeEnum; import com.engine.salary.enums.sicategory.IsPaymentEnum; import com.engine.salary.enums.sicategory.PaymentScopeEnum; @@ -119,6 +122,15 @@ public class SICategoryServiceImpl extends Service implements SICategoryService items.put("paymentScope",checkbox); apidatas.put("item",items); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(form.getId())); + loggerContext.setTargetName(form.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看自定义福利明细")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看自定义福利明细") + ": " + form.getInsuranceName()); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); return apidatas; } @@ -250,6 +262,16 @@ public class SICategoryServiceImpl extends Service implements SICategoryService .updateTime(new Date()) .build(); getICategoryMapper().updateNameAndPayScopeById(iCategoryPO); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(iCategoryPO.getId())); + loggerContext.setTargetName(iCategoryPO.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "更新自定义福利信息")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "更新自定义福利信息")); + loggerContext.setNewValues(iCategoryPO); + SalaryElogConfig.siCategoryLoggerTemplate.write(loggerContext); return null; } @@ -297,6 +319,16 @@ public class SICategoryServiceImpl extends Service implements SICategoryService //删除自定义福利项 categoryPO.setUpdateTime(new Date()); getICategoryMapper().deleteCustomCategoryById(categoryPO); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(categoryPO.getId())); + loggerContext.setTargetName(categoryPO.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建自定义福利项")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建自定义福利项")); +// loggerContext.setNewValues(categoryPO); + SalaryElogConfig.siCategoryLoggerTemplate.write(loggerContext); return null; } @@ -381,22 +413,23 @@ public class SICategoryServiceImpl extends Service implements SICategoryService * @param employeeId DataTypeEnum.SYSTEM.getValue() */ public void save(ICategoryFormDTO iCategoryFormDTO, long employeeId) { - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); - iCategoryFormDTO.setInsuranceName(StringUtils.trim(iCategoryFormDTO.getInsuranceName())); - List iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName()); - if (CollectionUtils.isNotEmpty(iCategoryPOS)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"福利名称不允许重复")); - } - ICategoryPO iCategoryPO = ICategoryBO.convertToInsuranceCategoryPO(iCategoryFormDTO, employeeId); - iCategoryMapper.insert(iCategoryPO); - - sqlSession.commit(); - - } finally { - sqlSession.close(); + iCategoryFormDTO.setInsuranceName(StringUtils.trim(iCategoryFormDTO.getInsuranceName())); + List iCategoryPOS = listByName(iCategoryFormDTO.getInsuranceName()); + if (CollectionUtils.isNotEmpty(iCategoryPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"福利名称不允许重复")); } + ICategoryPO iCategoryPO = ICategoryBO.convertToInsuranceCategoryPO(iCategoryFormDTO, employeeId); + getICategoryMapper().insert(iCategoryPO); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(iCategoryPO.getId())); + loggerContext.setTargetName(iCategoryPO.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建自定义福利项")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建自定义福利项")); + loggerContext.setNewValues(iCategoryPO); + SalaryElogConfig.siCategoryLoggerTemplate.write(loggerContext); } /** @@ -436,31 +469,34 @@ public class SICategoryServiceImpl extends Service implements SICategoryService * @param isUse */ public void updateStatusById(Long id, Integer isUse) { - SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); - try { - if(id == null) { - throw new SalaryRunTimeException("id is required"); - } - if (isUse == null) { - throw new SalaryRunTimeException("isUse is required"); - } -// List insuranceSchemeDetailPOS = new SISchemeBiz().queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue()); - List insuranceSchemeDetailPOS = getSISchemeService(user).queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue()); - if(CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS) && isUse == 0) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"该福利开启缴费,不可删除(或停用)")); - } - ICategoryPO iCategoryPO = getICategoryPOByID(id); - if (Objects.isNull(iCategoryPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"数据记录不存在")); - } - iCategoryPO.setIsUse(isUse); - ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); - iCategoryMapper.updateById(iCategoryPO); - sqlSession.commit(); - }finally { - sqlSession.close(); + if(id == null) { + throw new SalaryRunTimeException("id is required"); } + if (isUse == null) { + throw new SalaryRunTimeException("isUse is required"); + } +// List insuranceSchemeDetailPOS = new SISchemeBiz().queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue()); + List insuranceSchemeDetailPOS = getSISchemeService(user).queryListByInsuranceIdIsPayment(id, IsPaymentEnum.YES.getValue()); + if(CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS) && isUse == 0) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"该福利开启缴费,不可删除(或停用)")); + } + ICategoryPO iCategoryPO = getICategoryPOByID(id); + if (Objects.isNull(iCategoryPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"数据记录不存在")); + } + iCategoryPO.setIsUse(isUse); + getICategoryMapper().updateById(iCategoryPO); + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(iCategoryPO.getId())); + loggerContext.setTargetName(iCategoryPO.getInsuranceName()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "更新自定义福利状态")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "更新自定义福利状态")); + loggerContext.setNewValues(iCategoryPO); + SalaryElogConfig.siCategoryLoggerTemplate.write(loggerContext); } /*****以上代码为SICategoryBiz中方法逻辑迁移,旨在减少Biz类的使用*****/ diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java index 22e584b4f..3c7db3426 100644 --- a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -14,6 +14,7 @@ import com.engine.salary.elog.entity.dto.LoggerContext; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO; import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; import com.engine.salary.entity.siarchives.param.SIArchiveImportParam; import com.engine.salary.entity.siarchives.po.*; @@ -40,6 +41,7 @@ import com.engine.salary.enums.salarysob.TargetTypeEnum; import com.engine.salary.enums.siaccount.EmployeeStatusEnum; import com.engine.salary.enums.sicategory.*; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.EmployMapper; import com.engine.salary.mapper.siaccount.SIAccountUtilMapper; import com.engine.salary.mapper.siarchives.FundSchemeMapper; import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; @@ -173,6 +175,9 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { return SqlProxyHandle.getProxy(SIAccountUtilMapper.class); } + private EmployMapper getEmployMapper() { + return MapperProxyFactory.getProxy(EmployMapper.class); + } @Override public Map getForm(Map params) { // return commandExecutor.execute(new SISchemeGetFormCmd(params, user)); @@ -186,6 +191,16 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { // InsuranceSchemeFormVO form = siSchemeBiz.getForm(id, welfareTypeEnum); InsuranceSchemeFormVO form = getForm(id, welfareTypeEnum); apidatas.put("form",form); + //记录操作日志 + InsuranceSchemeDTO schemeBatch = form.getSchemeBatch(); + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(schemeBatch.getId())); + loggerContext.setTargetName(schemeBatch.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.READ.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "查看福利方案明细")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "查看福利方案明细") + ": " + schemeBatch.getSchemeName()); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); return apidatas; } @@ -623,6 +638,13 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { } rows.add(row); } + //记录操作日志 + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setOperateType(OperateTypeEnum.EXPORT.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案导出")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案导出")); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); //获取excel return ExcelUtilPlus.genWorkbookV2(rows, sheetName); } @@ -1821,10 +1843,17 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { } public void handleImportData(List insuranceArchivesAccountPOS, SIArchiveImportParam param) { + List baseInfoPOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getBaseInfo).collect(Collectors.toList()); + //去除员工id+个税扣缴义务人下重复的数据 + baseInfoPOS = baseInfoPOS.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + //老数据map + Map oldSocialArchiveMap = getSocialArchiveMap(baseInfoPOS); + Map oldFundArchiveMap = getFundArchiveMap(baseInfoPOS); + Map oldOtherArchiveMap = getOtherArchiveMap(baseInfoPOS); //导入社保档案 List socialSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getSocial).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(socialSchemePOS)) { - //去除员工id+个税扣缴义务人下重复的数据 socialSchemePOS = socialSchemePOS.stream() .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); @@ -1848,7 +1877,6 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { //导入公积金档案 List fundSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getFund).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(fundSchemePOS)) { - //去除员工id+个税扣缴义务人下重复的数据 fundSchemePOS = fundSchemePOS.stream() .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); @@ -1869,7 +1897,6 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { //导入其他福利档案 List otherSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getOther).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(otherSchemePOS)) { - //去除员工id+个税扣缴义务人下重复的数据 otherSchemePOS = otherSchemePOS.stream() .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); @@ -1889,12 +1916,12 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { getSIArchivesService(user).batchInsertAdjustHistory(adjustOtherHistoryPOList); } //导入福利档案基础信息 - List baseInfoPOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getBaseInfo).collect(Collectors.toList()); +// List baseInfoPOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getBaseInfo).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(baseInfoPOS)) { // baseInfoPOS = baseInfoPOS.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesBaseInfoPO::getEmployeeId))), ArrayList::new)); - //去除员工id+个税扣缴义务人下重复的数据 - baseInfoPOS = baseInfoPOS.stream() - .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); +// //去除员工id+个税扣缴义务人下重复的数据 +// baseInfoPOS = baseInfoPOS.stream() +// .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); //根据人员id和个税扣缴义务人id删除对应档案 baseInfoPOS.forEach(getInsuranceBaseInfoMapper()::deleteByEmployeeIdAndPayOrg); //分批批量删除 @@ -1919,6 +1946,54 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { //分批批量入库 List> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100); partition.forEach(getInsuranceBaseInfoMapper()::batchSave); + //记录操作日志 + //获取新数据map和老数据map + Map newSocialArchiveMap = getSocialArchiveMap(baseInfoPOS); + Map newFundArchiveMap = getFundArchiveMap(baseInfoPOS); + Map newOtherArchiveMap = getOtherArchiveMap(baseInfoPOS); + newInsuranceArchivesBaseInfoList.forEach(targetPO -> { + InsuranceArchivesSocialSchemePO targetSocialDetail = newSocialArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId()); + InsuranceArchivesFundSchemePO targetFundDetail = newFundArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId()); + InsuranceArchivesOtherSchemePO targetOtherDetail = newOtherArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId()); + DataCollectionEmployee empInfo = getEmployMapper().getEmployeeById(targetPO.getEmployeeId()); + TaxAgentPO taxAgentInfo = getTaxAgentMapper().getById(targetPO.getPaymentOrganization()); + if (targetSocialDetail != null) { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-社保明细导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-社保明细导入") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldSocialArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId())); + loggerContext.setNewValues(targetSocialDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + if (targetFundDetail != null) { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-公积金明细导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-公积金明细导入") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldFundArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId())); + loggerContext.setNewValues(targetFundDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + if (targetOtherDetail != null) { + LoggerContext loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利档案-其他福利明细导入")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利档案-其他福利明细导入") + ": " + taxAgentInfo.getName() + "-" + empInfo.getUsername()); + loggerContext.setOldValues(oldOtherArchiveMap.get(targetPO.getPaymentOrganization() + "-" + targetPO.getEmployeeId())); + loggerContext.setNewValues(targetOtherDetail); + SalaryElogConfig.siArchivesLoggerTemplate.write(loggerContext); + } + }); } //新增人员范围(会自动生成人员档案) if (CollectionUtils.isNotEmpty(param.getTaxAgentRanges())) { @@ -1926,6 +2001,61 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { } } + private Map getSocialArchiveMap(List baseInfoPOS) { + Map map = new HashMap<>(); + if (baseInfoPOS.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesBaseInfoPO po : baseInfoPOS) { + List archiveList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + if (archiveList.size() == 1) { + //新增调整记录,变更 + encryptUtil.decryptList(archiveList, InsuranceArchivesSocialSchemePO.class); + map.put(po.getPaymentOrganization() + "-" + po.getEmployeeId(), archiveList.get(0)); + } else if (archiveList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保档案存在冗余数据!")); + } + } + } + return map; + } + private Map getFundArchiveMap(List baseInfoPOS) { + Map map = new HashMap<>(); + if (baseInfoPOS.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesBaseInfoPO po : baseInfoPOS) { + List archiveList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + if (archiveList.size() == 1) { + //新增调整记录,变更 + encryptUtil.decryptList(archiveList, InsuranceArchivesFundSchemePO.class); + map.put(po.getPaymentOrganization() + "-" + po.getEmployeeId(), archiveList.get(0)); + } else if (archiveList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金档案存在冗余数据!")); + } + } + } + return map; + } + private Map getOtherArchiveMap(List baseInfoPOS) { + Map map = new HashMap<>(); + if (baseInfoPOS.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesBaseInfoPO po : baseInfoPOS) { + List archiveList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + if (archiveList.size() == 1) { + //新增调整记录,变更 + encryptUtil.decryptList(archiveList, InsuranceArchivesOtherSchemePO.class); + map.put(po.getPaymentOrganization() + "-" + po.getEmployeeId(), archiveList.get(0)); + } else if (archiveList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保档案存在冗余数据!")); + } + } + } + return map; + } + /** * 导出档案导入所需要的模板,可根据开关选择是否导出现有的档案数据 @@ -2335,8 +2465,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { loggerContext.setTargetId(String.valueOf(targetPO.getId())); loggerContext.setTargetName(targetPO.getSchemeName()); loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); - loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建福利方案")); - loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建福利方案") + ": " + targetPO.getSchemeName()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增福利方案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案基础信息") + ": " + targetPO.getSchemeName()); loggerContext.setNewValues(targetPO); SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); } @@ -2345,26 +2475,19 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { //加密入库 encryptUtil.encryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); insuranceSchemeDetailPOS.forEach(getInsuranceSchemeDetailMapper()::insert); - //记录操作日志 + //记录明细表操作日志 if (insuranceSchemeDetailPOS.size() > 0) { encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); - List allCategoryList = getICategoryMapper().listAll(); - Map categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName); - InsuranceSchemePO finalTargetPO = targetPO; - insuranceSchemeDetailPOS.forEach(schemeDetailPO -> { - LoggerContext loggerContext = new LoggerContext<>(); - loggerContext.setUser(user); - loggerContext.setTargetId(String.valueOf(finalTargetPO.getId())); - loggerContext.setTargetName(categoryNameMap.get(schemeDetailPO.getInsuranceId())); - loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); - loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建福利方案明细")); - loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建福利方案明细") + ": " - + categoryNameMap.get(schemeDetailPO.getInsuranceId()) - + "-" + SalaryEnumUtil.enumMatchByValue(schemeDetailPO.getPaymentScope(), PaymentScopeEnum.values(), PaymentScopeEnum.class)); - loggerContext.setNewValues(schemeDetailPO); - SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); - }); + LoggerContext> loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(targetPO.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增福利方案明细表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案明细")); + insuranceSchemeDetailPOS.forEach(loggerContext::setNewValues); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); } } @@ -2397,32 +2520,37 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"方案可见性为私有时,未设置可见范围")); } } - //记录操作日志 - LoggerContext loggerContext = new LoggerContext<>(); + //记录主表操作日志 + LoggerContext loggerContext = new LoggerContext<>(); loggerContext.setUser(user); loggerContext.setTargetId(insuranceSchemePO.getId().toString()); loggerContext.setTargetName(insuranceSchemePO.getSchemeName()); loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); - loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "福利方案保存")); - loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案保存") + ": " + insuranceSchemePO.getSchemeName()); - loggerContext.setOldValues(insuranceSchemePO); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "修改福利方案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案基础信息") + ": " + insuranceSchemePO.getSchemeName()); +// loggerContext.setOldValues(insuranceSchemePO); //更新福利方案主表 InsuranceSchemePO insuranceSchemePO1 = InsuranceSchemeBO.buildInsuranceSchemePO(insuranceSchemePO, updateParam.getInsuranceScheme()); getInsuranceSchemeMapper().update(insuranceSchemePO1); - //记录操作日志 + //记录主表操作日志 loggerContext.setNewValues(insuranceSchemePO1); SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext); - List oldInsuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(updateParam.getInsuranceScheme().getId()); - encryptUtil.decryptList(oldInsuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); - //更新福利方案明细表 先删后插 getInsuranceSchemeDetailMapper().batchDeleteByPrimaryIds(Collections.singleton(updateParam.getInsuranceScheme().getId())); //更新明细表 List insuranceSchemeDetailPOS = InsuranceSchemeBO.convertToInsuranceSchemeDetailPoList(updateParam.getInsuranceSchemeDetailList(), employeeId, insuranceSchemePO.getId()); encryptUtil.encryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); insuranceSchemeDetailPOS.forEach(getInsuranceSchemeDetailMapper()::insert); - //记录操作日志, todo - + //记录明细表操作日志 + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + LoggerContext> insuranceSchemeDetailContext = new LoggerContext<>(); + insuranceSchemeDetailContext.setTargetId(String.valueOf(insuranceSchemePO.getId())); + insuranceSchemeDetailContext.setTargetName(insuranceSchemePO.getSchemeName()); + insuranceSchemeDetailContext.setOperateType(OperateTypeEnum.UPDATE.getValue()); + insuranceSchemeDetailContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "修改福利方案明细表")); + insuranceSchemeDetailContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案明细")); + insuranceSchemeDetailPOS.forEach(insuranceSchemeDetailContext::setNewValues); + SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(insuranceSchemeDetailContext); } @@ -2451,38 +2579,33 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { getInsuranceSchemeDetailMapper().deleteByIds(schemeIds); //记录操作日志 + Map> targetDetailMap = targetDetailPoList.stream() + .collect(Collectors.groupingBy(InsuranceSchemeDetailPO::getPrimaryId)); if (targetPoList.size() > 0) { targetPoList.forEach(targetPO -> { + //记录主表操作日志 LoggerContext loggerContext = new LoggerContext<>(); loggerContext.setUser(user); loggerContext.setTargetId(String.valueOf(targetPO.getId())); loggerContext.setTargetName(targetPO.getSchemeName()); loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); - loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利方案")); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利方案主表")); loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利方案") + ": " + targetPO.getSchemeName()); loggerContext.setNewValues(targetPO); SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); - }); - } - if (targetDetailPoList.size() > 0) { - List allCategoryList = getICategoryMapper().listAll(); - Map categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName); - Map> targetDetailMap = targetDetailPoList.stream() - .collect(Collectors.groupingBy(InsuranceSchemeDetailPO::getPrimaryId)); - targetDetailMap.forEach((k, v) -> { - v.forEach(schemeDetailPO -> { - LoggerContext loggerContext = new LoggerContext<>(); - loggerContext.setUser(user); - loggerContext.setTargetId(String.valueOf(k)); - loggerContext.setTargetName(categoryNameMap.get(schemeDetailPO.getInsuranceId())); - loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); - loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利方案明细")); - loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除福利方案明细") + ": " - + categoryNameMap.get(schemeDetailPO.getInsuranceId()) - + "-" + SalaryEnumUtil.enumMatchByValue(schemeDetailPO.getPaymentScope(), PaymentScopeEnum.values(), PaymentScopeEnum.class)); - loggerContext.setNewValues(schemeDetailPO); - SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); - }); + //记录明细表操作日志 + List targetDetails = targetDetailMap.get(targetPO.getId()); + if (targetDetails != null && targetDetails.size() > 0) { + LoggerContext> detailLoggerContext = new LoggerContext<>(); + detailLoggerContext.setUser(user); + detailLoggerContext.setTargetId(String.valueOf(targetPO.getId())); + detailLoggerContext.setTargetName(targetPO.getSchemeName()); + detailLoggerContext.setOperateType(OperateTypeEnum.DELETE.getValue()); + detailLoggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除福利方案明细")); + detailLoggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案明细")); + targetDetails.forEach(detailLoggerContext::setNewValues); + SalaryElogConfig.siSchemeLoggerTemplate.write(detailLoggerContext); + } }); } @@ -2537,8 +2660,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { loggerContext.setTargetId(String.valueOf(targetPO.getId())); loggerContext.setTargetName(targetPO.getSchemeName()); loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); - loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "复制福利方案")); - loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "复制(新建)福利方案") + ": " + targetPO.getSchemeName()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "复制新增福利方案主表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案基础信息") + ": " + targetPO.getSchemeName()); loggerContext.setNewValues(targetPO); SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); } @@ -2569,26 +2692,19 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { //加密入库 encryptUtil.encryptList(detailPOS, InsuranceSchemeDetailPO.class); detailPOS.forEach(getInsuranceSchemeDetailMapper()::insert); - //记录操作日志 + //记录明细表操作日志 if (detailPOS.size() > 0) { encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); - List allCategoryList = getICategoryMapper().listAll(); - Map categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName); - InsuranceSchemePO finalTargetPO = targetPO; - detailPOS.forEach(schemeDetailPO -> { - LoggerContext loggerContext = new LoggerContext<>(); - loggerContext.setUser(user); - loggerContext.setTargetId(String.valueOf(finalTargetPO.getId())); - loggerContext.setTargetName(categoryNameMap.get(schemeDetailPO.getInsuranceId())); - loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); - loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "复制福利方案明细")); - loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "复制(新建)福利方案明细") + ": " - + categoryNameMap.get(schemeDetailPO.getInsuranceId()) - + "-" + SalaryEnumUtil.enumMatchByValue(schemeDetailPO.getPaymentScope(), PaymentScopeEnum.values(), PaymentScopeEnum.class)); - loggerContext.setNewValues(schemeDetailPO); - SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); - }); + LoggerContext> loggerContext = new LoggerContext<>(); + loggerContext.setUser(user); + loggerContext.setTargetId(String.valueOf(targetPO.getId())); + loggerContext.setTargetName(targetPO.getSchemeName()); + loggerContext.setOperateType(OperateTypeEnum.ADD.getValue()); + loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "复制新增福利方案明细表")); + loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "福利方案明细")); + detailPOS.forEach(loggerContext::setNewValues); + SalaryElogConfig.siSchemeLoggerTemplate.write(loggerContext); } }