保存核算人员时增加快照数据

This commit is contained in:
钱涛 2024-12-09 13:21:25 +08:00
parent 7d346aa4b0
commit 4100ba1331
4 changed files with 97 additions and 17 deletions

View File

@ -103,16 +103,16 @@ public class SalaryAcctEmployeeBO {
.employeeId(emp.getEmployeeId())
.employeeType(emp.isExtEmp() ? 1 : 0)
.taxAgentId(taxAgentId)
// .departmentId(emp.getDepartmentId())
// .departmentName(emp.getDepartmentName())
// .jobcall(emp.getJobcall())
// .jobcallId(emp.getJobcallId())
// .jobtitleId(emp.getJobtitleId())
// .jobtitleName(emp.getJobtitleName())
// .subcompanyId(emp.getSubcompanyid())
// .subcompanyName(emp.getSubcompanyName())
// .status(emp.getStatus())
// .accountType(emp.getAccountType())
.departmentId(emp.getDepartmentId())
.departmentName(emp.getDepartmentName())
.jobcall(emp.getJobcall())
.jobcallId(emp.getJobcallId())
.jobtitleId(emp.getJobtitleId())
.jobtitleName(emp.getJobtitleName())
.subcompanyId(emp.getSubcompanyid())
.subcompanyName(emp.getSubcompanyName())
.status(emp.getStatus())
.accountType(emp.getAccountType())
.creator(employeeId)
.createTime(now)
.updateTime(now)

View File

@ -27,6 +27,7 @@ import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper;
import com.engine.salary.mapper.sys.SalarySysConfMapper;
import com.engine.salary.report.entity.param.SalaryStatisticsReportDataQueryParam;
import com.engine.salary.service.*;
import com.engine.salary.sys.constant.SalarySysConstant;
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
@ -431,9 +432,8 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "个税扣缴义务人下无该人员档案信息或薪资缴纳日期不在薪资周期内"));
}
//替换快照数据
shotEmpData(salaryAcctEmployeePOS, salarySobCycleDTO.getSalaryCycleFromDate());
batchSave(salaryAcctEmployeePOS);
//保存核算人员
saveAcctEmployeePOS(salaryAcctEmployeePOS, salarySobCycleDTO);
// 记录日志
@ -449,6 +449,19 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
SalaryElogConfig.salaryAcctRecordLoggerTemplate.write(loggerContext);
}
private void saveAcctEmployeePOS(List<SalaryAcctEmployeePO> salaryAcctEmployeePOS, SalarySobCycleDTO sobCycle) {
boolean shotEmpBtn = "1".equals(getSalarySysConfService(user).getValueByCode(SalarySysConstant.SHOT_EMP_BTN));
//替换快照数据
if (shotEmpBtn) {
String valueByCode = getSalarySysConfService(user).getValueByCode(SalarySysConstant.SHOT_EMP_TIME_TYPE);
shotEmpData(salaryAcctEmployeePOS, sobCycle.getSalaryCycleFromDate());
}
//保存
batchSave(salaryAcctEmployeePOS);
}
private void shotEmpData(List<SalaryAcctEmployeePO> salaryAcctEmployeePOS, Date shotTime) {
List<Long> employees = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
List<DataCollectionEmployee> snapshot = getSalaryEmployeeService(user).snapshot(employees, shotTime);
@ -467,6 +480,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
salaryAcctEmployeePO.setAccountType(shotEmp.getAccountType());
});
}
@Override
public void batchSave(Collection<SalaryAcctEmployeePO> salaryAcctEmployeePOS) {
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
@ -580,8 +594,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
// 保存薪资核算人员
if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) {
shotEmpData(salaryAcctEmployeePOS, salarySobCycleDTO.getSalaryCycleFromDate());
batchSave(salaryAcctEmployeePOS);
saveAcctEmployeePOS(salaryAcctEmployeePOS, salarySobCycleDTO);
}
}
@ -627,8 +640,8 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
List<Long> delIds = oldEmps.stream().filter(po -> !newEmpMap.containsKey(po.getTaxAgentId() + "_" + po.getEmployeeId())).map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
deleteByIds(delIds);
shotEmpData(addEmps, salarySobCycleDTO.getSalaryCycleFromDate());
batchSave(addEmps);
saveAcctEmployeePOS(addEmps, salarySobCycleDTO);
}

View File

@ -204,4 +204,14 @@ public class SalarySysConstant {
* 审批流程发起后允许修改核算数据
*/
public static final String APPROVAL_CAN_EDIT_RESULT_STATUS = "APPROVAL_CAN_EDIT_RESULT_STATUS";
/**
* 是否采用组织快照,0关闭 1开启
*/
public static final String SHOT_EMP_BTN = "SHOT_EMP_BTN";
/**
* 快照时间点
*/
public static final String SHOT_EMP_TIME_TYPE = "SHOT_EMP_TIME_TYPE";
}

View File

@ -0,0 +1,57 @@
package com.engine.salary.sys.enums;
import com.engine.salary.enums.BaseEnum;
import org.apache.commons.lang3.StringUtils;
/**
* 快照时间点类型
* <p>Copyright: Copyright (c) 2024</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public enum ShotTimeTypeEnum implements BaseEnum<String> {
salaryFirstDate("salaryFirstDate", "薪资所属月第一天", 1),
salaryLastDate("salaryLastDate", "薪资所属月最后一天", 1),
salaryCycleFromDate("salaryCycleFromDate", "薪资周期起始日期", 1),
salaryCycleEndDate("salaryCycleEndDate", "薪资周期结束日期", 1);
private String value;
private String defaultLabel;
private int labelId;
ShotTimeTypeEnum(String value, String defaultLabel, int labelId) {
this.value = value;
this.defaultLabel = defaultLabel;
this.labelId = labelId;
}
@Override
public String getValue() {
return value;
}
@Override
public String getDefaultLabel() {
return defaultLabel;
}
@Override
public Integer getLabelId() {
return labelId;
}
public static ShotTimeTypeEnum parseByValue(String value) {
for (ShotTimeTypeEnum e : ShotTimeTypeEnum.values()) {
if (StringUtils.equals(e.getValue(), value)) {
return e;
}
}
return salaryCycleFromDate;
}
}