薪酬系统-福利档案,减员action优化

This commit is contained in:
sy 2024-01-29 11:30:04 +08:00
parent 9c9a8e2661
commit c4adecf436
3 changed files with 60 additions and 2 deletions

View File

@ -1,14 +1,18 @@
package com.engine.salary.action;
import cn.hutool.core.util.StrUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
import com.engine.salary.service.SIArchivesService;
import com.engine.salary.service.impl.SIArchivesServiceImpl;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
@ -84,6 +88,12 @@ public class StayDelToStopSIArchiveAction implements Action {
Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() );
Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString());
String payEndYearMonth = importDataMap.getOrDefault("最后缴纳月", "").toString();
if (StrUtil.isNotBlank(payEndYearMonth) && !SalaryDateUtil.checkYearMonth(payEndYearMonth)) {
requestInfo.getRequestManager().setMessage("最后缴纳月格式有误,正确格式示例为'2021-01'");
return FAILURE_AND_CONTINUE;
}
//操作人
String uid = importDataMap.getOrDefault("操作人","1").toString();
User user = new User(Integer.parseInt(uid));
@ -92,12 +102,17 @@ public class StayDelToStopSIArchiveAction implements Action {
if(insuranceArchivesBaseInfoPO == null){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!");
return FAILURE_AND_CONTINUE;
} else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())){
} else if(StrUtil.isBlank(payEndYearMonth) && !insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待减员,无法进行减员操作,请检查后重试!");
return FAILURE_AND_CONTINUE;
}
//减员
Map<String, Object> resultMap = getSIArchivesService(user).stayDelToStop(Collections.singletonList(insuranceArchivesBaseInfoPO.getId()));
Map<String, Object> resultMap = new HashMap<>();
if (StrUtil.isBlank(payEndYearMonth)) {
resultMap = getSIArchivesService(user).stayDelToStop(Collections.singletonList(insuranceArchivesBaseInfoPO.getId()));
} else {
resultMap = getSIArchivesService(user).stopWithoutLimit(Collections.singletonList(insuranceArchivesBaseInfoPO.getId()), payEndYearMonth);
}
if (resultMap.get("type").toString().equals("fail")) {
requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString());
return FAILURE_AND_CONTINUE;

View File

@ -74,6 +74,11 @@ public interface SIArchivesService {
*/
Map<String, Object> stayDelToStop(Collection<Long> ids);
/**
* 批量减员直接减员并给予最后缴纳月
*/
Map<String, Object> stopWithoutLimit(Collection<Long> ids, String yearMonth);
/**
* 全量减员
*/

View File

@ -876,6 +876,44 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
return resultMap;
}
@Override
public Map<String, Object> stopWithoutLimit(Collection<Long> ids, String yearMonth) {
if (CollectionUtils.isEmpty(ids)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
}
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listByIds(ids);
//分别新建福利档案基础信息相关的社保公积金其他福利档案列表
List<InsuranceArchivesSocialSchemePO> socialList = new ArrayList<>();
List<InsuranceArchivesFundSchemePO> fundList = new ArrayList<>();
List<InsuranceArchivesOtherSchemePO> otherList = new ArrayList<>();
//获取待处理的福利档案基础信息id列表
List<Long> baseInfoIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
//分别获取福利档案基础信息相关的社保公积金其他福利档案id列表
List<Long> socialIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
List<Long> fundIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
List<Long> otherIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList());
//进行减员操作
if (baseInfoIds.size() > 0) {
getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder()
.ids(baseInfoIds).runStatus(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()).build());
getSocialSchemeMapper().batchUpdateEndTime(socialIds, yearMonth);
getFundSchemeMapper().batchUpdateEndTime(fundIds, yearMonth);
getOtherSchemeMapper().batchUpdateEndTime(otherIds, yearMonth);
}
Map<String, Object> resultMap = new HashMap<>(2);
String resultMsg = "操作成功";
String resultType = "success";
resultMap.put("type", resultType);
resultMap.put("msg", resultMsg);
return resultMap;
}
/**
* 全量减员
*/