diff --git a/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java index 75b63245c..c7f3be70b 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java @@ -71,6 +71,7 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.BeanUtils; +import org.springframework.util.StopWatch; import weaver.file.ImageFileManager; import weaver.hrm.User; @@ -1036,6 +1037,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc } private Map batchImport(SalaryAcctImportParam param, String importType) { + StopWatch stopWatch = new StopWatch("导入核算数据"); + stopWatch.start("数据准备"); Map apidatas = new HashMap(); ValidUtil.doValidator(param); Date now = new Date(); @@ -1053,27 +1056,38 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc if (salaryAcctRecordPO == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); } + stopWatch.stop(); // 薪资账套下的薪资项目副本 + stopWatch.start("薪资账套下的薪资项目副本"); List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); // 薪资项目 Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); List salaryItems = getSalaryItemService(user).listByIds(salaryItemIds); Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getName, SalaryItemPO::getId); + stopWatch.stop(); // 薪资核算确认的人员 + stopWatch.start("薪资核算确认的人员"); List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordId); Map salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, e -> e.getEmployeeId() + "-" + e.getTaxAgentId()); + stopWatch.stop(); // 租户下所有的人员 + stopWatch.start("薪资核算确认的人员"); List salaryEmployees = getSalaryEmployeeService(user).listAllForReport(); Map salaryEmployeeMap = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getUsername, DataCollectionEmployee::getEmployeeId); Map emps = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getEmployeeId); + stopWatch.stop(); // 租户下所有的个税扣缴义务人 + stopWatch.start("租户下所有的个税扣缴义务人"); List taxAgents = getTaxAgentService(user).listAll(); Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId); + stopWatch.stop(); // 薪资核算人员信息字段 + stopWatch.start("薪资核算人员信息字段"); List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); List salarySobEmpFields = SalaryEntityUtil.properties(new SalarySobItemAggregateBO().buildEmpField(salarySobEmpFieldPOS), SalarySobEmpFieldDTO::getFieldName, Collectors.toList()); List excludeFields = Arrays.asList("个税扣缴义务人", "部门", "姓名"); salarySobEmpFields = salarySobEmpFields.stream().filter(field -> !excludeFields.contains(field)).collect(Collectors.toList()); + stopWatch.stop(); // 索引(用于计算进度) int index = 0; // 失败的数量 @@ -1103,10 +1117,10 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId())); - + stopWatch.start("解析文件"); Workbook workbook = ExcelSupport.parseFile(fileInputStream, EXCEL_TYPE_XLSX); Sheet sheet = workbook.getSheetAt(0); - + stopWatch.stop(); // 错误提示信息 List excelComments = Lists.newArrayList(); @@ -1136,6 +1150,7 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc if (CollectionUtils.isEmpty(data)) { throw new RuntimeException("无数据"); } + stopWatch.start("解析数据"); for (int i = 0; i < data.size(); i++) { String row = "第" + (i + 3) + "行"; @@ -1365,10 +1380,12 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc } successCount++; } + stopWatch.stop(); // 如果sheet包含错误数据 // if (CollectionUtils.isNotEmpty(errorDatas)) { // salaryBatchService.createErrorExcelSheet(headers, errorDatas, excelSheet.getName(), excelComments, errorExcelSheets); // } + stopWatch.start("插入数据"); if (StringUtils.equals("importExcelAcctResult", importType)) { getSalaryComparisonResultService(user).deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId)); if (CollectionUtils.isNotEmpty(excelAcctResults)) { @@ -1421,6 +1438,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc getSalaryAcctEmployeeService(user).batchSave(newSalaryAcctEmployees); } } + stopWatch.stop(); + stopWatch.start("锁定数据"); SalarySysConfPO autoLock = getSalarySysConfService(user).getOneByCode(SalarySysConstant.EDIT_IMPORT_AUTO_LOCK); if (autoLock != null && StringUtils.equals(autoLock.getConfValue(), "1")) { // 导入的列都自动锁定 @@ -1430,6 +1449,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc .lockStatus(LockStatusEnum.LOCK).build(); getSalaryAcctResultService(user).updateLockStatusByParam(updateLockStatusParam); } + stopWatch.stop(); + log.info(stopWatch.prettyPrint()); apidatas.put("successCount", successCount); apidatas.put("errorCount", failCount);