129 lines
5.7 KiB
Java
129 lines
5.7 KiB
Java
|
|
package com.engine.salary.service.impl;
|
||
|
|
|
||
|
|
import com.alibaba.fastjson.JSON;
|
||
|
|
import com.engine.core.impl.Service;
|
||
|
|
import com.engine.salary.encrypt.EncryptUtil;
|
||
|
|
import com.engine.salary.entity.siaccount.param.SaveSupplementaryAccountParam;
|
||
|
|
import com.engine.salary.entity.siaccount.param.SupplementAccountBaseParam;
|
||
|
|
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
|
||
|
|
import com.engine.salary.entity.siarchives.po.InsuranceArchivesAccountPO;
|
||
|
|
import com.engine.salary.entity.sicategory.po.ICategoryPO;
|
||
|
|
import com.engine.salary.enums.siaccount.ProjectTypeEnum;
|
||
|
|
import com.engine.salary.enums.sicategory.DataTypeEnum;
|
||
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
||
|
|
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
|
||
|
|
import com.engine.salary.mapper.sicategory.ICategoryMapper;
|
||
|
|
import com.engine.salary.service.SIRepairService;
|
||
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
||
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
||
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
||
|
|
import com.google.common.collect.Maps;
|
||
|
|
|
||
|
|
import java.util.*;
|
||
|
|
import java.util.stream.Collectors;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @Author: sy
|
||
|
|
* @Description: 福利台账-补缴实现类
|
||
|
|
* @Date: 2022/12/27
|
||
|
|
**/
|
||
|
|
public class SIRepairServiceImpl extends Service implements SIRepairService {
|
||
|
|
|
||
|
|
private EncryptUtil encryptUtil = new EncryptUtil();
|
||
|
|
|
||
|
|
private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() {
|
||
|
|
return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取指定月份的福利缴纳基数作为补缴基数
|
||
|
|
* @param param
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public List<Map<String, String>> getSupplementPaymentForm(SupplementAccountBaseParam param) {
|
||
|
|
|
||
|
|
Long paymentOrganization = param.getPaymentOrganization();
|
||
|
|
String billMonth = param.getBillMonth();
|
||
|
|
List<Integer> projects = param.getProjects();
|
||
|
|
Long employeeId = param.getEmployeeId();
|
||
|
|
|
||
|
|
List<InsuranceAccountDetailPO> detailPOList = getInsuranceAccountDetailMapper().queryNormalList(billMonth, paymentOrganization, employeeId);
|
||
|
|
|
||
|
|
if (detailPOList.size() > 1) {
|
||
|
|
throw new SalaryRunTimeException("该人员本次核算出现多组数据,请删除数据库中多余核算项");
|
||
|
|
} else if (detailPOList.size() == 0) {
|
||
|
|
throw new SalaryRunTimeException("数据不存在");
|
||
|
|
} else {
|
||
|
|
InsuranceAccountDetailPO targetDetailPO = detailPOList.get(0);
|
||
|
|
encryptUtil.decrypt(targetDetailPO, InsuranceAccountDetailPO.class);
|
||
|
|
|
||
|
|
String socialBaseString = targetDetailPO.getSocialPaymentBaseString();
|
||
|
|
String fundBaseString = targetDetailPO.getFundPaymentBaseString();
|
||
|
|
String otherBaseString = targetDetailPO.getOtherPaymentBaseString();
|
||
|
|
|
||
|
|
Map<String, String> socialBaseMap = JSON.parseObject(socialBaseString, HashMap.class);
|
||
|
|
Map<String, String> fundBaseMap = JSON.parseObject(fundBaseString, HashMap.class);
|
||
|
|
Map<String, String> otherBaseMap = JSON.parseObject(otherBaseString, HashMap.class);
|
||
|
|
|
||
|
|
Map<String, String> targetBaseMap = new HashMap<>();
|
||
|
|
|
||
|
|
List<ICategoryPO> allCategoryList = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll();
|
||
|
|
Map<Long, String> categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName);
|
||
|
|
|
||
|
|
if (projects.contains(ProjectTypeEnum.ALL.getValue())) {
|
||
|
|
targetBaseMap.putAll(socialBaseMap);
|
||
|
|
targetBaseMap.putAll(fundBaseMap);
|
||
|
|
targetBaseMap.putAll(otherBaseMap);
|
||
|
|
}
|
||
|
|
if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) {
|
||
|
|
targetBaseMap.putAll(socialBaseMap);
|
||
|
|
}
|
||
|
|
if (!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) {
|
||
|
|
|
||
|
|
List<ICategoryPO> list = MapperProxyFactory.getProxy(ICategoryMapper.class).listByDataType(DataTypeEnum.SYSTEM.getValue());
|
||
|
|
|
||
|
|
if (projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) {
|
||
|
|
ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93113, "养老保险").equals(item.getInsuranceName())).findFirst()
|
||
|
|
.get();
|
||
|
|
targetBaseMap.put(insuranceCategoryPO.getId().toString(), socialBaseMap.get(insuranceCategoryPO.getId()));
|
||
|
|
}
|
||
|
|
if (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue())) {
|
||
|
|
ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93114, "医疗保险").equals(item.getInsuranceName())).findFirst()
|
||
|
|
.get();
|
||
|
|
targetBaseMap.put(insuranceCategoryPO.getId().toString(), socialBaseMap.get(insuranceCategoryPO.getId()));
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
if (projects.contains(ProjectTypeEnum.FUND.getValue())) {
|
||
|
|
targetBaseMap.putAll(fundBaseMap);
|
||
|
|
|
||
|
|
}
|
||
|
|
if (projects.contains(ProjectTypeEnum.OTHER.getValue())) {
|
||
|
|
|
||
|
|
targetBaseMap.putAll(otherBaseMap);
|
||
|
|
}
|
||
|
|
|
||
|
|
List<Map<String, String>> resulit = new ArrayList();
|
||
|
|
if (targetBaseMap.size() > 0) {
|
||
|
|
for (Map.Entry<String, String> entry : targetBaseMap.entrySet()) {
|
||
|
|
|
||
|
|
Map<String, String> map = new HashMap<>();
|
||
|
|
map.put("insuranceId", entry.getKey());
|
||
|
|
map.put("insuranceName", categoryNameMap.get(Long.valueOf(entry.getKey())));
|
||
|
|
map.put("insuranceBase", entry.getValue());
|
||
|
|
|
||
|
|
resulit.add(map);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return resulit;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|