薪酬系统-福利档案,复制action开发
This commit is contained in:
parent
c4adecf436
commit
b1d3d2c445
|
|
@ -0,0 +1,149 @@
|
|||
package com.engine.salary.action;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
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.db.MapperProxyFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: sy
|
||||
* @Description: 拷贝福利档案并置为在缴
|
||||
* @Date: 2024/1/29
|
||||
**/
|
||||
@Slf4j
|
||||
public class CopyToPaySIArchiveAction implements Action {
|
||||
|
||||
private TaxAgentMapper getTaxAgentMapper() {
|
||||
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
|
||||
}
|
||||
|
||||
private SIArchivesService getSIArchivesService(User user) {
|
||||
return ServiceUtil.getService(SIArchivesServiceImpl.class,user);
|
||||
}
|
||||
|
||||
private String tableName;
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
try {
|
||||
Property[] properties = requestInfo.getMainTableInfo().getProperty();
|
||||
Map<String, String> fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName,
|
||||
property -> Util.null2String(property.getValue())));
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?";
|
||||
rs.executeQuery(queryImageId, requestInfo.getWorkflowid());
|
||||
|
||||
List<CopyToPaySIArchiveAction.SalaryField> list = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
String processField = rs.getString("processfield");
|
||||
String salaryName = rs.getString("salaryname");
|
||||
String value = fieldMap.get(processField);
|
||||
list.add(new CopyToPaySIArchiveAction.SalaryField(processField, salaryName, value));
|
||||
}
|
||||
List<Map<String, Object>> importData = new ArrayList<>();
|
||||
importData.add(SalaryEntityUtil.convert2Map(list, CopyToPaySIArchiveAction.SalaryField::getSalaryName, CopyToPaySIArchiveAction.SalaryField::getValue));
|
||||
//操作人
|
||||
String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("1");
|
||||
//增员
|
||||
String toCopyTaxAgentName = importData.get(0).get("待复制个税扣缴义务人").toString();
|
||||
String toUpdateTaxAgentName = importData.get(0).get("待更新个税扣缴义务人").toString();
|
||||
String payStartYearMonth = importData.get(0).getOrDefault("起始缴纳月", "").toString();
|
||||
if (StrUtil.isNotBlank(payStartYearMonth) && !SalaryDateUtil.checkYearMonth(payStartYearMonth)) {
|
||||
requestInfo.getRequestManager().setMessage("起始缴纳月格式有误,正确格式示例为'2021-01'");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
List<TaxAgentPO> toCopyTaxAgentPOS = getTaxAgentMapper().listByName(toCopyTaxAgentName);
|
||||
List<TaxAgentPO> toUpdateTaxAgentPOS = getTaxAgentMapper().listByName(toUpdateTaxAgentName);
|
||||
if(CollectionUtils.isEmpty(toCopyTaxAgentPOS)){
|
||||
requestInfo.getRequestManager().setMessage("待复制个税扣缴义务人不存在!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
if(CollectionUtils.isEmpty(toUpdateTaxAgentPOS)){
|
||||
requestInfo.getRequestManager().setMessage("待更新个税扣缴义务人不存在!");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
Long toCopyTaxAgentId = toCopyTaxAgentPOS.get(0).getId();
|
||||
Long toUpdateTaxAgentId = toUpdateTaxAgentPOS.get(0).getId();
|
||||
Long employeeId = Long.valueOf(list.stream().filter(f -> f.salaryName.equals("员工id")).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("-1"));
|
||||
User user = new User(Integer.parseInt(uid));
|
||||
//拷贝福利档案并置为在缴
|
||||
Map<String, Object> resultMap = getSIArchivesService(user).copyToPay(toCopyTaxAgentId, toUpdateTaxAgentId, employeeId, payStartYearMonth);
|
||||
if (!"success".equals(resultMap.get("type").toString())) {
|
||||
requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString());
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("福利档案复制并置为在缴异常", e);
|
||||
requestInfo.getRequestManager().setMessage(e.getMessage());
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
class SalaryField {
|
||||
|
||||
private String processField;
|
||||
|
||||
private String salaryName;
|
||||
|
||||
private String value;
|
||||
|
||||
public String getProcessField() {
|
||||
return processField;
|
||||
}
|
||||
|
||||
public void setProcessField(String processField) {
|
||||
this.processField = processField;
|
||||
}
|
||||
|
||||
public String getSalaryName() {
|
||||
return salaryName;
|
||||
}
|
||||
|
||||
public void setSalaryName(String salaryName) {
|
||||
this.salaryName = salaryName;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public SalaryField(String processField, String salaryName, String value) {
|
||||
this.processField = processField;
|
||||
this.salaryName = salaryName;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,13 @@ public interface OtherSchemeMapper {
|
|||
*/
|
||||
List<InsuranceArchivesOtherSchemePO> getOtherById(@Param("ids")List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据id获取单条
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
InsuranceArchivesOtherSchemePO getOneById(@Param("id")Long id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param singletonList
|
||||
|
|
|
|||
|
|
@ -80,6 +80,15 @@
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据id获取单条记录 -->
|
||||
<select id="getOneById" resultMap="BaseResultMap" >
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_other_archives t
|
||||
WHERE delete_type = 0
|
||||
AND id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 批量删除 -->
|
||||
<delete id="batchDeleteByEmployeeIds">
|
||||
UPDATE hrsa_other_archives
|
||||
|
|
|
|||
|
|
@ -94,6 +94,15 @@ public interface SIArchivesService {
|
|||
*/
|
||||
Map<String, Object> stayAddToPay(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 拷贝福利档案到新的个税扣缴义务人并置为在缴
|
||||
* @param toCopyTaxAgentId 被拷贝的福利档案所属个税扣缴义务人id
|
||||
* @param toUpdateTaxAgentId 被更新的福利档案所属个税扣缴义务人id
|
||||
* @param employeeId 福利档案所属人员id
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> copyToPay(Long toCopyTaxAgentId, Long toUpdateTaxAgentId, Long employeeId, String payStartYearMonth);
|
||||
|
||||
/**
|
||||
* 待减员页面的删除待办
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.engine.common.util.ServiceUtil;
|
|||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.biz.SIArchivesBiz;
|
||||
import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd;
|
||||
import com.engine.salary.encrypt.EncryptUtil;
|
||||
import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBaseInfoBO;
|
||||
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO;
|
||||
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
|
||||
|
|
@ -71,6 +72,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
|
||||
private SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
|
||||
|
||||
private EncryptUtil encryptUtil = new EncryptUtil();
|
||||
|
||||
private TaxAgentService getTaxAgentService(User user) {
|
||||
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
||||
}
|
||||
|
|
@ -1217,4 +1220,125 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
return listPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝福利档案到新的个税扣缴义务人并置为在缴
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> copyToPay(Long toCopyTaxAgentId, Long toUpdateTaxAgentId, Long employeeId, String payStartYearMonth) {
|
||||
if (toCopyTaxAgentId == null || toUpdateTaxAgentId == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人不能为空"));
|
||||
}
|
||||
if (employeeId == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "人员id不能为空"));
|
||||
}
|
||||
//获取待拷贝的福利档案明细
|
||||
InsuranceArchivesBaseInfoPO toCopyBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(toCopyTaxAgentId, employeeId);
|
||||
if(toCopyBaseInfoPO == null){
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "待复制个税扣缴义务人下该员工不存在福利档案,请检查后重试!"));
|
||||
}
|
||||
InsuranceArchivesSocialSchemePO toCopySocialInfo = getSocialSchemeMapper().getOneById(toCopyBaseInfoPO.getSocialArchivesId());
|
||||
InsuranceArchivesFundSchemePO toCopyFundInfo = getFundSchemeMapper().getOneById(toCopyBaseInfoPO.getFundArchivesId());
|
||||
InsuranceArchivesOtherSchemePO toCopyOtherInfo = getOtherSchemeMapper().getOneById(toCopyBaseInfoPO.getOtherArchivesId());
|
||||
//获取待更新的福利档案
|
||||
InsuranceArchivesBaseInfoPO toUpdateBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(toUpdateTaxAgentId, employeeId);
|
||||
if(toUpdateBaseInfoPO == null){
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "待更新个税扣缴义务人下该员工不存在福利档案,请检查后重试!"));
|
||||
}
|
||||
InsuranceArchivesSocialSchemePO toUpdateSocialInfo = getSocialSchemeMapper().getOneById(toUpdateBaseInfoPO.getSocialArchivesId());
|
||||
InsuranceArchivesFundSchemePO toUpdateFundInfo = getFundSchemeMapper().getOneById(toUpdateBaseInfoPO.getFundArchivesId());
|
||||
InsuranceArchivesOtherSchemePO toUpdateOtherInfo = getOtherSchemeMapper().getOneById(toUpdateBaseInfoPO.getOtherArchivesId());
|
||||
//设置福利档案基数调整记录数据
|
||||
encryptUtil.decrypt(toCopySocialInfo, InsuranceArchivesSocialSchemePO.class);
|
||||
encryptUtil.decrypt(toUpdateSocialInfo, InsuranceArchivesSocialSchemePO.class);
|
||||
encryptUtil.decrypt(toCopyFundInfo, InsuranceArchivesFundSchemePO.class);
|
||||
encryptUtil.decrypt(toUpdateFundInfo, InsuranceArchivesFundSchemePO.class);
|
||||
encryptUtil.decrypt(toCopyOtherInfo, InsuranceArchivesOtherSchemePO.class);
|
||||
encryptUtil.decrypt(toUpdateOtherInfo, InsuranceArchivesOtherSchemePO.class);
|
||||
|
||||
InsuranceArchivesBaseHistoryDTO socialAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder()
|
||||
.adjustAfterSchemeId(toCopySocialInfo.getSocialSchemeId())
|
||||
.adjustAfterBaseJson(toCopySocialInfo.getSocialPaymentBaseString())
|
||||
.adjustAfterComBaseJson(toCopySocialInfo.getSocialPaymentComBaseString())
|
||||
.welfareType(toUpdateSocialInfo.getWelfareType())
|
||||
.employeeId(toUpdateSocialInfo.getEmployeeId())
|
||||
.paymentOrganization(toUpdateSocialInfo.getPaymentOrganization())
|
||||
.adjustBeforeSchemeId(toUpdateSocialInfo.getSocialSchemeId())
|
||||
.adjustBeforeBaseJson(toUpdateSocialInfo.getSocialPaymentBaseString())
|
||||
.adjustBeforeComBaseJson(toUpdateSocialInfo.getSocialPaymentComBaseString())
|
||||
.build();
|
||||
InsuranceArchivesBaseHistoryDTO fundAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder()
|
||||
.adjustAfterSchemeId(toCopyFundInfo.getFundSchemeId())
|
||||
.adjustAfterBaseJson(toCopyFundInfo.getFundPaymentBaseString())
|
||||
.adjustAfterComBaseJson(toCopyFundInfo.getFundPaymentComBaseString())
|
||||
.welfareType(toUpdateFundInfo.getWelfareType())
|
||||
.employeeId(toUpdateFundInfo.getEmployeeId())
|
||||
.paymentOrganization(toUpdateFundInfo.getPaymentOrganization())
|
||||
.adjustBeforeSchemeId(toUpdateFundInfo.getFundSchemeId())
|
||||
.adjustBeforeBaseJson(toUpdateFundInfo.getFundPaymentBaseString())
|
||||
.adjustBeforeComBaseJson(toUpdateFundInfo.getFundPaymentComBaseString())
|
||||
.build();
|
||||
InsuranceArchivesBaseHistoryDTO otherAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder()
|
||||
.adjustAfterSchemeId(toCopyOtherInfo.getOtherSchemeId())
|
||||
.adjustAfterBaseJson(toCopyOtherInfo.getOtherPaymentBaseString())
|
||||
.adjustAfterComBaseJson(toCopyOtherInfo.getOtherPaymentComBaseString())
|
||||
.welfareType(toUpdateOtherInfo.getWelfareType())
|
||||
.employeeId(toUpdateOtherInfo.getEmployeeId())
|
||||
.paymentOrganization(toUpdateOtherInfo.getPaymentOrganization())
|
||||
.adjustBeforeSchemeId(toUpdateOtherInfo.getOtherSchemeId())
|
||||
.adjustBeforeBaseJson(toUpdateOtherInfo.getOtherPaymentBaseString())
|
||||
.adjustBeforeComBaseJson(toUpdateOtherInfo.getOtherPaymentComBaseString())
|
||||
.build();
|
||||
List<InsuranceArchivesBaseHistoryPO> adjustHistoryList = new ArrayList<>();
|
||||
adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(socialAdjustInfo, (long) user.getUID()));
|
||||
adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(fundAdjustInfo, (long) user.getUID()));
|
||||
adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(otherAdjustInfo, (long) user.getUID()));
|
||||
//更新字段
|
||||
toUpdateBaseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue());
|
||||
|
||||
toUpdateSocialInfo.setSocialAccount(toCopySocialInfo.getSocialAccount());
|
||||
toUpdateSocialInfo.setSocialSchemeId(toCopySocialInfo.getSocialSchemeId());
|
||||
toUpdateSocialInfo.setSocialPaymentBaseString(toCopySocialInfo.getSocialPaymentBaseString());
|
||||
toUpdateSocialInfo.setSocialPaymentComBaseString(toCopySocialInfo.getSocialPaymentComBaseString());
|
||||
toUpdateSocialInfo.setNonPayment(toCopySocialInfo.getNonPayment());
|
||||
toUpdateSocialInfo.setUnderTake(toCopySocialInfo.getUnderTake());
|
||||
toUpdateSocialInfo.setSocialStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopySocialInfo.getSocialStartTime());
|
||||
toUpdateSocialInfo.setUpdateTime(new Date());
|
||||
|
||||
toUpdateFundInfo.setFundAccount(toCopyFundInfo.getFundAccount());
|
||||
toUpdateFundInfo.setSupplementFundAccount(toCopyFundInfo.getSupplementFundAccount());
|
||||
toUpdateFundInfo.setFundSchemeId(toCopyFundInfo.getFundSchemeId());
|
||||
toUpdateFundInfo.setFundPaymentBaseString(toCopyFundInfo.getFundPaymentBaseString());
|
||||
toUpdateFundInfo.setFundPaymentComBaseString(toCopyFundInfo.getFundPaymentComBaseString());
|
||||
toUpdateFundInfo.setNonPayment(toCopyFundInfo.getNonPayment());
|
||||
toUpdateFundInfo.setUnderTake(toCopyFundInfo.getUnderTake());
|
||||
toUpdateFundInfo.setFundStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopyFundInfo.getFundStartTime());
|
||||
toUpdateFundInfo.setUpdateTime(new Date());
|
||||
|
||||
toUpdateOtherInfo.setOtherSchemeId(toCopyOtherInfo.getOtherSchemeId());
|
||||
toUpdateOtherInfo.setOtherPaymentBaseString(toCopyOtherInfo.getOtherPaymentBaseString());
|
||||
toUpdateOtherInfo.setOtherPaymentComBaseString(toCopyOtherInfo.getOtherPaymentComBaseString());
|
||||
toUpdateOtherInfo.setNonPayment(toCopyOtherInfo.getNonPayment());
|
||||
toUpdateOtherInfo.setUnderTake(toCopyOtherInfo.getUnderTake());
|
||||
toUpdateOtherInfo.setOtherStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopyOtherInfo.getOtherStartTime());
|
||||
toUpdateOtherInfo.setUpdateTime(new Date());
|
||||
//档案入库
|
||||
encryptUtil.encrypt(toUpdateSocialInfo, InsuranceArchivesSocialSchemePO.class);
|
||||
encryptUtil.encrypt(toUpdateFundInfo, InsuranceArchivesFundSchemePO.class);
|
||||
encryptUtil.encrypt(toUpdateOtherInfo, InsuranceArchivesOtherSchemePO.class);
|
||||
|
||||
getInsuranceBaseInfoMapper().updateById(toUpdateBaseInfoPO);
|
||||
getSocialSchemeMapper().updateById(toUpdateSocialInfo);
|
||||
getFundSchemeMapper().updateById(toUpdateFundInfo);
|
||||
getOtherSchemeMapper().updateById(toUpdateOtherInfo);
|
||||
//基数调整记录入库
|
||||
siArchivesBiz.batchInsertAdjustHistory(adjustHistoryList, (long) user.getUID());
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>(2);
|
||||
String resultMsg = "操作成功";
|
||||
String resultType = "success";
|
||||
|
||||
resultMap.put("type", resultType);
|
||||
resultMap.put("msg", resultMsg);
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue