刷新核算人员功能

This commit is contained in:
钱涛 2024-09-29 10:37:38 +08:00
parent 4db0fdc699
commit 93d2980ad8
3 changed files with 51 additions and 35 deletions

View File

@ -5,9 +5,9 @@ import cn.hutool.core.date.DateUtil;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
@ -444,6 +444,11 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
@Override
public void deleteByIds(Collection<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
// 删除薪资核算人员
getSalaryAcctEmployeeMapper().deleteByIds(ids);
// 删除薪资核算人员对应的薪资核算结果
@ -547,36 +552,47 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
@Override
public void refresh(Long salaryAcctRecordId) {
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = listBySalaryAcctRecordId(salaryAcctRecordId);
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
return;
}
List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 根据薪资账套查询人员
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
if (CollectionUtils.isEmpty(salaryEmployees)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "未查询到账套下关联人员"));
}
// 根据薪资账套查询薪资周期
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
//查询账套对应的扣缴义务人
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
//过滤掉不属于当前账套扣缴义务人的人员
Long taxAgentId = salarySobPO.getTaxAgentId();
// 查询薪资核算记录所用的帐套的薪资周期
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
// 查询薪资档案获取人员的个税扣缴义务人
List<Long> employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList());
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId);
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
// 转换成薪资核算人员po
List<SalaryAcctEmployeePO> newSalaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(employees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
newSalaryAcctEmployeePOS = newSalaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList());
// 删除以前的薪资核算人员
getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
// 插入新的薪资核算人员
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) {
batchSave(newSalaryAcctEmployeePOS);
}
List<SalaryAcctEmployeePO> newEmps = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
//过滤掉不属于当前账套扣缴义务人的人员
newEmps = newEmps.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList());
Map<String, SalaryAcctEmployeePO> newEmpMap = SalaryEntityUtil.convert2Map(newEmps, e -> e.getTaxAgentId() + "_" + e.getEmployeeId());
// 查询薪资核算人员
List<SalaryAcctEmployeePO> oldEmps = listBySalaryAcctRecordId(salaryAcctRecordId);
Map<String, SalaryAcctEmployeePO> oldEmpMap = SalaryEntityUtil.convert2Map(oldEmps, e -> e.getTaxAgentId() + "_" + e.getEmployeeId());
//新增
List<SalaryAcctEmployeePO> addEmps = newEmps.stream().filter(po -> !oldEmpMap.containsKey(po.getTaxAgentId() + "_" + po.getEmployeeId())).collect(Collectors.toList());
//删除
List<Long> delIds = oldEmps.stream().filter(po -> !newEmpMap.containsKey(po.getTaxAgentId() + "_" + po.getEmployeeId())).map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
deleteByIds(delIds);
batchSave(addEmps);
}
@ -712,20 +728,20 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
// }
// list = list.stream().filter(po -> employeeIdsByGradeFilter.contains(po.getEmployeeId())).collect(Collectors.toList());
// }
// 岗位过滤
// 岗位过滤
List<Long> position = param.getPosition();
if (CollectionUtils.isNotEmpty(position)) {
// Set<Long> employeeIdsByPostionFilter = new HashSet<>();
// simpleEmployeeList.forEach(simpleEmployee -> {
// if (simpleEmployee.getPosition() != null && param.getPosition().contains(simpleEmployee.getPosition().getId())) {
// employeeIdsByPostionFilter.add(simpleEmployee.getEmployeeId());
// }
// });
// if (CollectionUtils.isEmpty(employeeIdsByPostionFilter)) {
// return Lists.newArrayList();
// }
// Set<Long> employeeIdsByPostionFilter = new HashSet<>();
// simpleEmployeeList.forEach(simpleEmployee -> {
// if (simpleEmployee.getPosition() != null && param.getPosition().contains(simpleEmployee.getPosition().getId())) {
// employeeIdsByPostionFilter.add(simpleEmployee.getEmployeeId());
// }
// });
// if (CollectionUtils.isEmpty(employeeIdsByPostionFilter)) {
// return Lists.newArrayList();
// }
employeeList = employeeList.stream().filter(emp -> position.contains(emp.getJobtitleId())).collect(Collectors.toList());
}
}
// 人事状态过滤
if (CollectionUtils.isNotEmpty(param.getStatus())) {
Set<Long> employeeIdsByStatus = new HashSet<>();

View File

@ -247,13 +247,13 @@ public class SalaryAcctController {
return new ResponseResult<Long, String>(user).run(getSalaryAcctEmployeeWrapper(user)::checkTaxAgent, param.getSalaryAcctRecordId());
}
//刷新薪资核算人员的个税扣缴义务人
//刷新薪资核算人员
@POST
@Path("/acctemployee/refreshTaxAgent")
@Path("/acctemployee/refresh")
@Produces(MediaType.APPLICATION_JSON)
public String refreshTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctEmpRefreshTaxAgentParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, String>(user).run(getSalaryAcctEmployeeWrapper(user)::refreshTaxAgent, param.getSalaryAcctRecordId());
return new ResponseResult<Long, String>(user).run(getSalaryAcctEmployeeWrapper(user)::refresh, param.getSalaryAcctRecordId());
}
//从环比上月减少添加薪资核算人员

View File

@ -184,11 +184,11 @@ public class SalaryAcctEmployeeWrapper extends Service {
}
/**
* 刷新个税扣缴义务人
* 刷新核算人员
*
* @param salaryAcctRecordId 薪资核算记录的id
*/
public void refreshTaxAgent(Long salaryAcctRecordId) {
public void refresh(Long salaryAcctRecordId) {
getSalaryAcctEmployeeService(user).refresh(salaryAcctRecordId);
}