Merge branch 'release/2.16.1.2410.01' into feature/次账号

This commit is contained in:
钱涛 2024-10-17 14:28:08 +08:00
commit 4ec883cd9c
4 changed files with 87 additions and 79 deletions

View File

@ -1,5 +1,5 @@
log=false
defaultCloseNonStandard149=true
AESEncryptScrect=990EB004A1C862721C1513AE90038C9E
version=2.15.2.2409.01
version=2.16.1.2410.01
openFormulaForcedEditing=false

View File

@ -695,7 +695,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
if (isRealOrg) {
employeeList = employeeList.stream().filter(emp -> subCompanyIds.contains(emp.getSubcompanyid())).collect(Collectors.toList());
} else {
list.stream().filter(emp -> subCompanyIds.contains(emp.getSubcompanyId())).collect(Collectors.toList());
list = list.stream().filter(emp -> subCompanyIds.contains(emp.getSubcompanyId())).collect(Collectors.toList());
}
}

View File

@ -58,11 +58,9 @@ import com.engine.salary.wrapper.SalarySobItemWrapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.wbi.util.Util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
@ -70,7 +68,7 @@ import org.apache.poi.ss.usermodel.Sheet;
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 +1034,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
}
private Map<String, Object> batchImport(SalaryAcctImportParam param, String importType) {
StopWatch stopWatch = new StopWatch("导入核算数据");
stopWatch.start("数据准备");
Map<String, Object> apidatas = new HashMap<String, Object>();
ValidUtil.doValidator(param);
Date now = new Date();
@ -1053,27 +1053,38 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
if (salaryAcctRecordPO == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
stopWatch.stop();
// 薪资账套下的薪资项目副本
stopWatch.start("薪资账套下的薪资项目副本");
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
// 薪资项目
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
List<SalaryItemPO> salaryItems = getSalaryItemService(user).listByIds(salaryItemIds);
Map<String, Long> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getName, SalaryItemPO::getId);
stopWatch.stop();
// 薪资核算确认的人员
stopWatch.start("薪资核算确认的人员");
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordId);
Map<String, SalaryAcctEmployeePO> salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, e -> e.getEmployeeId() + "-" + e.getTaxAgentId());
stopWatch.stop();
// 租户下所有的人员
stopWatch.start("薪资核算确认的人员");
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listAllForReport();
Map<String, Long> salaryEmployeeMap = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getUsername, DataCollectionEmployee::getEmployeeId);
Map<Long, DataCollectionEmployee> emps = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getEmployeeId);
stopWatch.stop();
// 租户下所有的个税扣缴义务人
stopWatch.start("租户下所有的个税扣缴义务人");
List<TaxAgentPO> taxAgents = getTaxAgentService(user).listAll();
Map<String, Long> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getName, TaxAgentPO::getId);
stopWatch.stop();
// 薪资核算人员信息字段
stopWatch.start("薪资核算人员信息字段");
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
List<String> salarySobEmpFields = SalaryEntityUtil.properties(new SalarySobItemAggregateBO().buildEmpField(salarySobEmpFieldPOS), SalarySobEmpFieldDTO::getFieldName, Collectors.toList());
List<String> excludeFields = Arrays.asList("个税扣缴义务人", "部门", "姓名");
salarySobEmpFields = salarySobEmpFields.stream().filter(field -> !excludeFields.contains(field)).collect(Collectors.toList());
stopWatch.stop();
// 索引(用于计算进度)
int index = 0;
// 失败的数量
@ -1103,10 +1114,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<Map> excelComments = Lists.newArrayList();
@ -1136,6 +1147,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) + "";
@ -1257,19 +1269,19 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
salaryAcctResultsOfOneEmp.add(salaryAcctResult);
SalaryAcctResultReportPO reportPO = SalaryAcctResultReportPO.builder()
.id(IdGenerator.generate())
.salaryAcctRecordId(salaryAcctRecordPO.getId())
.salarySobId(salaryAcctRecordPO.getSalarySobId())
.salaryItemId(salaryItemId)
.resultValue(dataValue)
.creator(currentEmployeeId)
.createTime(now)
.updateTime(now)
.deleteType(0)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
salaryAcctResultReportOfOneEmp.add(reportPO);
// SalaryAcctResultReportPO reportPO = SalaryAcctResultReportPO.builder()
// .id(IdGenerator.generate())
// .salaryAcctRecordId(salaryAcctRecordPO.getId())
// .salarySobId(salaryAcctRecordPO.getSalarySobId())
// .salaryItemId(salaryItemId)
// .resultValue(dataValue)
// .creator(currentEmployeeId)
// .createTime(now)
// .updateTime(now)
// .deleteType(0)
// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
// .build();
// salaryAcctResultReportOfOneEmp.add(reportPO);
}
}
}
@ -1346,29 +1358,31 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
salaryAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId);
}
for (SalaryAcctResultReportPO po : salaryAcctResultReportOfOneEmp) {
po.setEmployeeId(Util.null2String(employeeId));
po.setTaxAgentId(taxAgentId);
po.setSalaryAcctEmpId(Util.null2String(salaryAcctEmpId));
DataCollectionEmployee emp = emps.get(employeeId);
po.setSubcompanyId(emp.getSubcompanyid());
po.setDepartmentId(emp.getDepartmentId());
po.setCostcenterId(emp.getCostcenterId());
po.setJobtitleId(emp.getJobtitleId());
po.setLocationId(emp.getLocationId());
}
// for (SalaryAcctResultReportPO po : salaryAcctResultReportOfOneEmp) {
// po.setEmployeeId(Util.null2String(employeeId));
// po.setTaxAgentId(taxAgentId);
// po.setSalaryAcctEmpId(Util.null2String(salaryAcctEmpId));
//
// DataCollectionEmployee emp = emps.get(employeeId);
// po.setSubcompanyId(emp.getSubcompanyid());
// po.setDepartmentId(emp.getDepartmentId());
// po.setCostcenterId(emp.getCostcenterId());
// po.setJobtitleId(emp.getJobtitleId());
// po.setLocationId(emp.getLocationId());
//
// }
salaryAcctEmpIds.add(salaryAcctEmpId);
salaryAcctResults.addAll(salaryAcctResultsOfOneEmp);
salaryAcctReports.addAll(salaryAcctResultReportOfOneEmp);
// salaryAcctReports.addAll(salaryAcctResultReportOfOneEmp);
}
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)) {
@ -1392,16 +1406,9 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
if (CollectionUtils.isNotEmpty(salaryAcctResults)) {
// 处理导入薪资项的回算值
handleOriginResultValue(deleteResults, salaryAcctResults);
// 备份一份加密前的值
List<SalaryAcctResultPO> list4log = new ArrayList<>();
salaryAcctResults.stream().forEach(source -> {
SalaryAcctResultPO target = new SalaryAcctResultPO();
BeanUtils.copyProperties(source, target);
list4log.add(target);
});
getSalaryAcctResultService(user).batchSave(salaryAcctResults);
// 记录操作日志 TODO 这里的数据没有idid是自增的重新查数据太多效率太低
// 记录操作日志
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth());
LoggerContext loggerContext = new LoggerContext<>();
@ -1411,16 +1418,17 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
loggerContext.setOperateType(OperateTypeEnum.EXCEL_IMPORT.getValue());
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "导入薪资核算数据"));
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "导入薪资核算数据 ") + targetName);
loggerContext.setOldValueList(list4log);
SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext);
//报表
getSalaryAcctReportService(user).batchSave(salaryAcctReports);
// //报表
// getSalaryAcctReportService(user).batchSave(salaryAcctReports);
}
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployees)) {
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 +1438,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);

View File

@ -17,7 +17,6 @@ import com.engine.salary.entity.hrm.JobCallInfo;
import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.hrm.SubCompanyInfo;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.entity.report.bo.SalaryAcctResultReportBO;
import com.engine.salary.entity.report.po.SalaryAcctResultReportPO;
import com.engine.salary.entity.salaryacct.bo.*;
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
@ -52,7 +51,6 @@ import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.IdGenerator;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
@ -682,12 +680,12 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
List<List<SalaryAcctResultPO>> partition = Lists.partition(salaryAcctResultPOS, 100);
partition.forEach(getSalaryAcctResultMapper()::batchInsert);
}
//报表 todo
getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(Collections.singletonList(saveParam.getSalaryAcctEmpId()), saveItemIds);
List<SalaryAcctResultReportPO> salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2PO(saveParam, salaryAcctEmployeePO, (long) user.getUID(), emps);
if (CollectionUtils.isNotEmpty(salaryAcctResultReportPOS)) {
getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
}
//报表
// getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(Collections.singletonList(saveParam.getSalaryAcctEmpId()), saveItemIds);
// List<SalaryAcctResultReportPO> salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2PO(saveParam, salaryAcctEmployeePO, (long) user.getUID(), emps);
// if (CollectionUtils.isNotEmpty(salaryAcctResultReportPOS)) {
// getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
// }
// 存储薪资核算结果数据来源日志
@ -1189,30 +1187,30 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
}
// 报表
SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder()
.id(IdGenerator.generate())
.salarySobId(salaryAcctRecordPO.getSalarySobId())
.salaryItemId(param.getSalaryItemId())
.salaryAcctRecordId(param.getSalaryAcctRecordId())
.salaryAcctEmpId(salaryAcctEmployeePO.getId().toString())
.employeeId(salaryAcctEmployeePO.getEmployeeId().toString())
.taxAgentId(salaryAcctEmployeePO.getTaxAgentId())
.resultValue(param.getValue())
.creator(Long.valueOf(user.getUID()))
.createTime(now)
.updateTime(now)
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
DataCollectionEmployee dataCollectionEmployee = emps.get(salaryAcctEmployeePO.getEmployeeId());
if (dataCollectionEmployee != null) {
po.setDepartmentId(dataCollectionEmployee.getDepartmentId());
po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid());
po.setCostcenterId(dataCollectionEmployee.getCostcenterId());
po.setJobtitleId(dataCollectionEmployee.getJobtitleId());
po.setLocationId(dataCollectionEmployee.getLocationId());
}
salaryAcctResultReportPOS.add(po);
// SalaryAcctResultReportPO po = SalaryAcctResultReportPO.builder()
// .id(IdGenerator.generate())
// .salarySobId(salaryAcctRecordPO.getSalarySobId())
// .salaryItemId(param.getSalaryItemId())
// .salaryAcctRecordId(param.getSalaryAcctRecordId())
// .salaryAcctEmpId(salaryAcctEmployeePO.getId().toString())
// .employeeId(salaryAcctEmployeePO.getEmployeeId().toString())
// .taxAgentId(salaryAcctEmployeePO.getTaxAgentId())
// .resultValue(param.getValue())
// .creator(Long.valueOf(user.getUID()))
// .createTime(now)
// .updateTime(now)
// .deleteType(NumberUtils.INTEGER_ZERO)
// .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
// .build();
// DataCollectionEmployee dataCollectionEmployee = emps.get(salaryAcctEmployeePO.getEmployeeId());
// if (dataCollectionEmployee != null) {
// po.setDepartmentId(dataCollectionEmployee.getDepartmentId());
// po.setSubcompanyId(dataCollectionEmployee.getSubcompanyid());
// po.setCostcenterId(dataCollectionEmployee.getCostcenterId());
// po.setJobtitleId(dataCollectionEmployee.getJobtitleId());
// po.setLocationId(dataCollectionEmployee.getLocationId());
// }
// salaryAcctResultReportPOS.add(po);
});
// 入库
@ -1225,8 +1223,8 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
batchSave(needInsertList);
// 报表入库前先删除
getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(param.getIdList(), Collections.singletonList(param.getSalaryItemId()));
getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
// getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(param.getIdList(), Collections.singletonList(param.getSalaryItemId()));
// getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
}
}