From 40462d9fec23cd0cf493b919902e939d42570be3 Mon Sep 17 00:00:00 2001 From: sy Date: Thu, 3 Nov 2022 11:14:59 +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=A8=A1=E5=9D=97bug=E4=BF=AE=E5=A4=8Dv1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/biz/SIArchivesBiz.java | 59 ++++++++++++++----- .../service/impl/SIArchivesServiceImpl.java | 52 ++++++++++++---- 2 files changed, 85 insertions(+), 26 deletions(-) diff --git a/src/com/engine/salary/biz/SIArchivesBiz.java b/src/com/engine/salary/biz/SIArchivesBiz.java index 0b3b52ca9..fc0f92edb 100644 --- a/src/com/engine/salary/biz/SIArchivesBiz.java +++ b/src/com/engine/salary/biz/SIArchivesBiz.java @@ -55,6 +55,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.apache.ibatis.session.SqlSession; +import org.springframework.util.StopWatch; import weaver.conn.mybatis.MyBatisFactory; import weaver.general.Util; import weaver.hrm.User; @@ -911,7 +912,7 @@ public class SIArchivesBiz { public Map listPageEmployeePOS(InsuranceArchivesListParam param, long operateId) { //是否分权 Boolean needAuth = param.getNeedAuth(); - + StopWatch sw = new StopWatch(); SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); Map datas = new HashMap<>(16); try { @@ -924,11 +925,15 @@ public class SIArchivesBiz { if (needAuth) { Collection taxAgentEmployeeIds = param.getTaxAgentEmployeeIds(); Collection taxAgentIds = param.getTaxAgentIds(); + sw.start("获取福利档案列表数据"); page = socialSchemeMapper.queryEmployeeList(param); + sw.stop(); + page = page.stream().filter(f -> // taxAgentEmployeeIds.contains(f.getEmployeeId())|| taxAgentIds.contains(f.getPaymentOrganization()) ).collect(Collectors.toList()); + // 填充总数和当页数据 // 分页参数 pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), InsuranceArchivesEmployeePO.class); @@ -937,17 +942,23 @@ public class SIArchivesBiz { } else { SalaryPageUtil.start(param.getCurrent(), param.getPageSize()); // List page = socialSchemeMapper.listPageEmployeePOS(param); + sw.start("获取档案列表数据"); page = socialSchemeMapper.queryEmployeeList(param); + sw.stop(); + pageInfo = new PageInfo<>(page, InsuranceArchivesEmployeePO.class); } List> records = null; + sw.start("buildTableData方法处理福利档案列表数据"); if (param.getExportData() != null && param.getExportData()) { records = buildTableData(page, true); } else { records = buildTableData(page, false); } + sw.stop(); + sw.start("buildWeaTableColumns方法处理福利档案列表数据"); List columns = buildWeaTableColumns(page, operateId); - + sw.stop(); WeaTable table = new WeaTable(); table.setColumns(columns); //设置check是否可用 @@ -967,6 +978,8 @@ public class SIArchivesBiz { datas.put("datas", records); datas.put("columns", columns); datas.put("dataKey", result.getResultMap()); + + log.info("各操作计时 {}", sw.prettyPrint()); return datas; } finally { @@ -1422,9 +1435,14 @@ public class SIArchivesBiz { * 判断是否需要生成历史福利档案基本信息 */ public void createOldInsuranceBaseInfo(Long creator) { + + StopWatch sw = new StopWatch(); + log.info("判断是否需要生成历史数据"); List nowBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoList(); if (nowBaseInfoList.size() == 0) { + log.info("福利档案基础信息表为空,开始生成历史数据:"); //处理公积金、其他福利档案中个税扣缴义务人为空的情况 + sw.start("处理公积金、其他福利档案中个税扣缴义务人为空的情况"); List socialList = getSocialSchemeMapper().listAll(); List fundList = getFundSchemeMapper().listAll(); List otherList = getOtherSchemeMapper().listAll(); @@ -1434,28 +1452,36 @@ public class SIArchivesBiz { for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) { List toDealFundList = fundList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList()); if (toDealFundList.size() > 0) { - for (InsuranceArchivesFundSchemePO toDealFundPO : toDealFundList) { - toDealFundPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); - updateFundList.add(toDealFundPO); - } + InsuranceArchivesFundSchemePO toDealFundPO = toDealFundList.get(0); + toDealFundPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); + updateFundList.add(toDealFundPO); } List toDealOtherList = otherList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList()); if (toDealOtherList.size() > 0) { - for (InsuranceArchivesOtherSchemePO toDealOtherPO : toDealOtherList) { - toDealOtherPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); - updateOtherList.add(toDealOtherPO); - } + InsuranceArchivesOtherSchemePO toDealOtherPO = toDealOtherList.get(0); + toDealOtherPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); + updateOtherList.add(toDealOtherPO); + } - //更新公积金和其他福利档案 - updateFundList.forEach(getFundSchemeMapper()::updateById); - updateOtherList.forEach(getOtherSchemeMapper()::updateById); + } + log.info("重置个税扣缴义务人id的公积金档案数:{}", updateFundList.size()); + log.info("重置个税扣缴义务人id的其他福利档案数:{}", updateOtherList.size()); + //更新公积金和其他福利档案 + updateFundList.forEach(getFundSchemeMapper()::updateById); + updateOtherList.forEach(getOtherSchemeMapper()::updateById); + sw.stop(); - - // + sw.start("处理待入库的历史福利档案基础信息并入库"); List addBaseInfoList = new ArrayList<>(); + List oldBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(null); + log.info("获取待生成的历史福利档案基础信息条数:{}", oldBaseInfoList.size()); + //去重 + oldBaseInfoList = oldBaseInfoList.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + log.info("去重后的待生成历史福利档案基础信息条数:{}", oldBaseInfoList.size()); if (oldBaseInfoList.size() > 0) { //设置基本信息表字段 for (InsuranceArchivesBaseInfoPO po : oldBaseInfoList) { @@ -1473,8 +1499,9 @@ public class SIArchivesBiz { List> partition = Lists.partition(addBaseInfoList, 50); partition.forEach(getInsuranceBaseInfoMapper()::batchSave); } + sw.stop(); } - + log.info("各操作计时 {}", sw.prettyPrint()); } diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index d7a0fdd8f..939fea49c 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -35,10 +35,13 @@ import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelUtil; import com.google.common.collect.Lists; +import com.icbc.api.internal.apache.http.impl.cookie.S; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StopWatch; import weaver.general.Util; import weaver.hrm.User; @@ -52,6 +55,7 @@ import java.util.stream.Collectors; * @Date 2022/3/11 * @Version V1.0 **/ +@Slf4j public class SIArchivesServiceImpl extends Service implements SIArchivesService { private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); @@ -134,13 +138,22 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService @Override public Map listPage(InsuranceArchivesListParam param) { long currentEmployeeId = user.getUID(); - + log.info("获取福利档案列表逻辑开始: {}", param); + StopWatch sw = new StopWatch(); + sw.start("福利档案-历史数据处理"); // 1.历史数据处理 siArchivesBiz.createOldInsuranceBaseInfo(currentEmployeeId); + sw.stop(); + + sw.start("福利档案-待减员自动处理"); // 2.待减员自动处理 handleStayDelData(currentEmployeeId); + sw.stop(); + + sw.start("福利档案-增量数据处理"); // 3.增量数据处理 handleChangeData(currentEmployeeId); + sw.stop(); //排序配置 OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); @@ -160,6 +173,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); apidatas = siArchivesBiz.listPage(param, (long) user.getUID()); + log.info("各操作计时 {}", sw.prettyPrint()); return apidatas; } @@ -169,16 +183,17 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ @Transactional(rollbackFor = Exception.class) private void handleStayDelData(long currentEmployeeId) { - + log.info("福利档案中待减员数据自动处理逻辑开始:"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); String today = simpleDateFormat.format(new Date()); //part1,员工维护了社保/公积金/其他福利最后缴纳日,且任一类信息大于今天的,自动将待减员状态置为正在缴纳状态 List rePayList = getInsuranceBaseInfoMapper().getRePayList(today); updateInsuranceBaseInfoRunStatus(rePayList, EmployeeStatusEnum.PAYING.getValue()); + log.info("自动将待减员状态置为正在缴纳状态的档案数量 {}:", rePayList.size()); //part2,员工维护了社保/公积金/其他福利最后缴纳日,且三类信息都小于今天的,自动置为待减员状态 List reStayDelList = getInsuranceBaseInfoMapper().getReStayDelList(today); updateInsuranceBaseInfoRunStatus(reStayDelList, EmployeeStatusEnum.STAY_DEL.getValue()); - + log.info("自动置为待减员状态的档案数量 {}:", reStayDelList.size()); //part3,非在职员工且处于正常缴纳的福利档案置为待减员状态 //定义非在职的人事状态 List personnelStatuses = new ArrayList() {{ @@ -195,7 +210,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService List noNormalList = getInsuranceBaseInfoMapper().getAbnormalList(insuranceArchivesListParam); updateInsuranceBaseInfoRunStatus(noNormalList, EmployeeStatusEnum.STAY_DEL.getValue()); - + log.info("自动处理非在职员工的档案数量 {}:", noNormalList.size()); } } @@ -205,28 +220,35 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ @Transactional(rollbackFor = Exception.class) private void handleChangeData(long currentEmployeeId) { - + log.info("福利档案中增量数据处理逻辑开始:"); // 所有增量人员列表 List taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE); + log.info("待处理的福利档案增量数据数量 {}:", taxAgentEmpChangeList.size()); if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) { return; } // 当前可以管辖的人员 Collection taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId); + log.info("当前可以管辖的个税扣缴义务人数量 {}:", taxAgentList.size()); taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> taxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList()); if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) { return; } + log.info("根据当前可以管辖的个税扣缴义务人筛选出的可处理增量数据数量 {}:", taxAgentEmpChangeList.size()); // 所有福利档案基础信息数据 List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); - + log.info("当前数据库中所有福利档案基础信息数据数量 {}:", baseInfoPOList.size()); + StopWatch sw = new StopWatch(); + sw.start("将增量数据进一步处理为新增、更新两类数据"); InsuranceArchivesBaseInfoBO.ChangeData changeData = InsuranceArchivesBaseInfoBO.buildChangeData(taxAgentEmpChangeList, baseInfoPOList, currentEmployeeId); + sw.stop(); // 批量修改福利档案 if (CollectionUtils.isNotEmpty(changeData.getBaseInfoUpdateTodoList())) { + log.info("增量数据中待更新的数据数量 {}:", changeData.getBaseInfoUpdateTodoList().size()); //对于即将调整为“待减员”的数据,更新社保、公积金、其他福利档案的停止缴纳时间 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); String today = simpleDateFormat.format(new Date()); - + sw.start("生成增量数据中即将置为“待减员”的数据"); List toStayDelList = changeData.getBaseInfoUpdateTodoList().stream() .filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) .collect(Collectors.toList()); @@ -243,6 +265,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService }); } + sw.stop(); + + sw.start("生成增量数据中即将置为“逻辑删除”的数据"); //对于逻辑删除的数据,同样逻辑删除相关的社保、公积金、其他福利档案 List delList = changeData.getBaseInfoUpdateTodoList().stream() .filter(f -> f.getDeleteType().equals(DeleteTypeEnum.DELETED.getValue())) @@ -263,23 +288,30 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService .build()); } } - + sw.stop(); //修改福利档案基础信息 + sw.start("增量数据中待更新数据入库"); List> partitionUpdateBase = Lists.partition(changeData.getBaseInfoUpdateTodoList(), 100); partitionUpdateBase.forEach(part-> getInsuranceBaseInfoMapper().batchUpdate(part)); - + sw.stop(); + log.info("增量数据中待更新的数据处理完成!"); } + + sw.start("处理增量数据中待新增的数据"); // 批量新增福利档案 if (CollectionUtils.isNotEmpty(changeData.getBaseInfoAddTodoList())) { + log.info("增量数据中待新增的数据数量 {}:", changeData.getBaseInfoAddTodoList().size()); //新增社保、公积金、其他福利档案、福利档案基础信息 addNewInsuranceBaseInfo(changeData.getBaseInfoAddTodoList(), currentEmployeeId); + log.info("增量数据中待新增的数据处理完成!"); } + sw.stop(); // 删除增量数据 if (CollectionUtils.isNotEmpty(changeData.getChangeIds())) { getTaxAgentEmpChangeService(user).deleleByIds(changeData.getChangeIds()); } - + log.info("各操作计时 {}", sw.prettyPrint()); } //新增社保、公积金、其他福利档案、福利档案基础信息 private List addNewInsuranceBaseInfo(List baseInfoPOList, Long currentEmployeeId) {