福利台账核算接口

This commit is contained in:
Chengliang 2022-04-15 13:17:25 +08:00
parent 23388ef017
commit 6ddf60a548
16 changed files with 1083 additions and 57 deletions

View File

@ -5,10 +5,7 @@ import com.alibaba.fastjson.TypeReference;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.siaccount.param.DSTenantKeyThreadVar;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.param.*;
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailTempPO;
@ -17,20 +14,17 @@ import com.engine.salary.entity.siarchives.po.InsuranceArchivesAccountPO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import com.engine.salary.enums.siaccount.BillStatusEnum;
import com.engine.salary.enums.siaccount.InspectStatusEnum;
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.enums.siaccount.ResourceFromEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.enums.sicategory.IsPaymentEnum;
import com.engine.salary.enums.sicategory.NonPaymentEnum;
import com.engine.salary.enums.sicategory.PaymentScopeEnum;
import com.engine.salary.enums.siaccount.*;
import com.engine.salary.enums.sicategory.*;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper;
import com.engine.salary.mapper.siaccount.SIAccountDetailTempMapper;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper;
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryDateUtil;
@ -69,6 +63,7 @@ import java.util.stream.Collectors;
**/
public class SIAccountBiz {
private SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
public PageInfo<InsuranceAccountBatchPO> listPage(InsuranceAccountBatchParam queryParam, Long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
@ -704,8 +699,561 @@ public class SIAccountBiz {
}
public void saveCommonAccount(SaveCommonAccountParam param, Long employeeId) {
List<Long> collect;
SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel( 100466, "参数为空"));
SalaryAssert.notNull(param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 100467, "账单月为空"));
if (CollectionUtils.isNotEmpty(param.getExcludes())) {
collect = param.getIncludes().stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList());
} else {
collect = param.getIncludes();
}
SalaryAssert.notEmpty(collect, SalaryI18nUtil.getI18nLabel( 99920, "无核算人员"));
AccountParam accountParam = new AccountParam();
accountParam.setBillMonth(param.getBillMonth());
accountParam.setIds(collect);
accounting(accountParam, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
}
public void delete(AccountParam param, Long employeeId) {
InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth());
SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel( 84026, "参数错误"));
MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).deleteById(insuranceAccountBatchPO.getId());
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDeleteNotFile(param.getBillMonth());
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId()));
// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 100464, "删除台账"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 100464, "删除台账"));
// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
}
public void saveSupplementaryAccount(SaveSupplementaryAccountParam param, Long employeeId) {
if (StringUtils.isBlank(param.getBillMonth()) || CollectionUtils.isEmpty(param.getBillMonthList()) || CollectionUtils.isEmpty(param.getProjects())
|| CollectionUtils.isEmpty(param.getIncludes())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 84026, "参数错误"));
}
//需要补缴的月份
if (param.getBillMonthList().contains(param.getBillMonth())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 100481, "当前月走正常缴纳"));
}
//需要补缴的员工id
List<Long> employeeIds = param.getIncludes();
if (CollectionUtils.isNotEmpty(param.getExcludes())) {
employeeIds = employeeIds.stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList());
}
SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel( 99920, "无核算人员"));
List<SupplementAccountBaseParam> baseList = new ArrayList<>();
employeeIds.stream().forEach(id -> {
param.getBillMonthList().stream().forEach(month -> {
SupplementAccountBaseParam supplementAccountBaseParam = SupplementAccountBaseParam.builder()
.supplementaryMonth(month)
.employeeId(id)
.projects(param.getProjects())
.billMonth(param.getBillMonth())
.build();
baseList.add(supplementAccountBaseParam);
});
});
//核算开始
accountSupplement(baseList, employeeIds, param.getBillMonth(),employeeId);
updateBatchAccount(param.getBillMonth(), employeeId,SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
}
/**
* @param baseList 员工id-账单月份-补缴月份单挑-补缴项 集合
* @param employeeIds 需要补缴的员工id
* @return
*/
public String accountSupplement(List<SupplementAccountBaseParam> baseList, List<Long> employeeIds, String billMonth,Long employeeId) {
//(k,v) k-员工id v-员工对应的福利档案数据
Map<Long, InsuranceArchivesAccountPO> longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds,SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
//核算结果集
List<InsuranceAccountDetailPO> pos = new ArrayList<>();
baseList.forEach(baseParam -> {
InsuranceAccountDetailPO insuranceAccountDetailPO = accountSingleEmployeeBill(baseParam, longInsuranceArchivesAccountPOMap.get(baseParam.getEmployeeId()),employeeId);
pos.add(insuranceAccountDetailPO);
});
batchSaveSupplementAccount(pos, billMonth,SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
return SalaryI18nUtil.getI18nLabel(100492, "核算完成,数据保存成功");
}
public InsuranceAccountDetailPO accountSingleEmployeeBill(SupplementAccountBaseParam baseParam, InsuranceArchivesAccountPO accountPO,Long employeeId) {
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
List<Integer> projects = baseParam.getProjects();
insuranceAccountDetailPO.setBillMonth(baseParam.getBillMonth());
insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue());
insuranceAccountDetailPO.setCreator(employeeId);
insuranceAccountDetailPO.setCreateTime(new Date());
insuranceAccountDetailPO.setUpdateTime(new Date());
insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceAccountDetailPO.setId(IdGenerator.generate());
insuranceAccountDetailPO.setEmployeeId(baseParam.getEmployeeId());
insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.REPAIR.getValue());
insuranceAccountDetailPO.setSupplementaryMonth(baseParam.getSupplementaryMonth());
insuranceAccountDetailPO.setSupplementaryProjects(
String.join(",",
baseParam.getProjects() == null ? new ArrayList<>() : baseParam.getProjects().stream().map(String::valueOf).collect(Collectors.toList())));
insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue());
if (projects.contains(ProjectTypeEnum.ALL.getValue())) {
accountSocial(insuranceAccountDetailPO, accountPO);
accountFund(insuranceAccountDetailPO, accountPO);
accountOther(insuranceAccountDetailPO, accountPO);
return account(insuranceAccountDetailPO);
}
if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) {
accountSocial(insuranceAccountDetailPO, accountPO);
}
if (!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) {
List<Long> ids = new ArrayList<>();
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();
ids.add(insuranceCategoryPO.getId());
}
if (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue())) {
ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93114, "医疗保险").equals(item.getInsuranceName())).findFirst()
.get();
ids.add(insuranceCategoryPO.getId());
}
accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids);
}
if (projects.contains(ProjectTypeEnum.FUND.getValue())) {
accountFund(insuranceAccountDetailPO, accountPO);
}
if (projects.contains(ProjectTypeEnum.OTHER.getValue())) {
accountOther(insuranceAccountDetailPO, accountPO);
}
return account(insuranceAccountDetailPO);
}
public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO) {
if (accountPO.getOther() != null) {
InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther();
insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization());
insuranceAccountDetailPO.setOtherSchemeId(otherPO.getOtherSchemeId());
insuranceAccountDetailPO.setOtherPaymentBaseString(otherPO.getOtherPaymentBaseString());
if ((Objects.equals(NonPaymentEnum.YES.getValue(), otherPO.getNonPayment()) || otherPO.getNonPayment() == null) && otherPO.getOtherSchemeId() != null) {
List<InsuranceSchemeDetailPO> detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(otherPO.getOtherSchemeId());
//方案中包含的需要缴纳其他的个人福利
Map<Long, InsuranceSchemeDetailPO> otherPerson = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算其他的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
archivesPerson.forEach((id, value) -> {
if (otherPerson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
List<BigDecimal> otherPer = new ArrayList<>();
Map<String, String> otherPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = otherPerson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesPerson.get(String.valueOf(e))) ? "0" : archivesPerson.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
otherPerJsonMap.put(String.valueOf(e), result.toPlainString());
otherPer.add(result);
});
insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerJsonMap));
BigDecimal otherPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherPer) {
otherPerSum = otherPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString());
//方案中包含的需要缴纳公积金的单位福利
Map<Long, InsuranceSchemeDetailPO> otherCom = detailPOS.stream()
.filter(
item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算其他的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
archivesCom.forEach((id, value) -> {
if (otherCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
List<BigDecimal> otherComList = new ArrayList<>();
Map<String, String> otherComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = otherCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesCom.get(String.valueOf(e))) ? "0" : archivesCom.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
otherComJsonMap.put(String.valueOf(e), result.toPlainString());
otherComList.add(result);
});
insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComJsonMap));
BigDecimal otherComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherComList) {
otherComSum = otherComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountFund(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO) {
if (accountPO.getFund() != null) {
InsuranceArchivesFundSchemePO fundPO = accountPO.getFund();
insuranceAccountDetailPO.setFundPayOrg(fundPO.getPaymentOrganization());
insuranceAccountDetailPO.setFundAccount(fundPO.getFundAccount());
insuranceAccountDetailPO.setSupplementFundAccount(fundPO.getSupplementFundAccount());
insuranceAccountDetailPO.setFundSchemeId(fundPO.getFundSchemeId());
insuranceAccountDetailPO.setFundPaymentBaseString(fundPO.getFundPaymentBaseString());
if ((NonPaymentEnum.YES.getValue() == fundPO.getNonPayment() || fundPO.getNonPayment() == null) && fundPO.getFundSchemeId() != null) {
List<InsuranceSchemeDetailPO> detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(fundPO.getFundSchemeId());
//方案中包含的需要缴纳社保的个人福利
Map<Long, InsuranceSchemeDetailPO> fundperson = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算公积金的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
archivesPerson.forEach((id, value) -> {
if (fundperson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
List<BigDecimal> fundPer = new ArrayList<>();
Map<String, String> fundPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = fundperson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesPerson.get(String.valueOf(e))) ? "0" : archivesPerson.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
fundPerJsonMap.put(String.valueOf(e), result.toPlainString());
fundPer.add(result);
});
insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerJsonMap));
BigDecimal funPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundPer) {
funPerSum = funPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundPerSum(funPerSum.toPlainString());
//方案中包含的需要缴纳公积金的单位福利
Map<Long, InsuranceSchemeDetailPO> fundCom = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算公积金的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
archivesCom.forEach((id, value) -> {
if (fundCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
List<BigDecimal> fundComList = new ArrayList<>();
Map<String, String> fundComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = fundCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesCom.get(String.valueOf(e))) ? "0" : archivesCom.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
fundComJsonMap.put(String.valueOf(e), result.toPlainString());
fundComList.add(result);
});
insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComJsonMap));
BigDecimal fundComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundComList) {
fundComSum = fundComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountSocial(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO) {
if (accountPO.getSocial() != null) {
InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial();
insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization());
insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount());
insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId());
insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString());
if ((NonPaymentEnum.YES.getValue() == socialPO.getNonPayment() || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null) {
List<InsuranceSchemeDetailPO> detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(socialPO.getSocialSchemeId());
//方案中包含的需要缴纳社保的个人福利
Map<Long, InsuranceSchemeDetailPO> schemeperson = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
archivesPerson.forEach((id, value) -> {
if (schemeperson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
List<BigDecimal> socialPer = new ArrayList<>();
Map<String, String> socialPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = schemeperson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesPerson.get(String.valueOf(e))) ? "0" : archivesPerson.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
socialPerJsonMap.put(String.valueOf(e), result.toPlainString());
socialPer.add(result);
});
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap));
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
//方案中包含的需要缴纳社保的单位福利
Map<Long, InsuranceSchemeDetailPO> schemeCom = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
archivesCom.forEach((id, value) -> {
if (schemeCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
List<BigDecimal> socialCom = new ArrayList<>();
Map<String, String> sociaComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = schemeCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(StringUtils.isBlank(archivesCom.get(String.valueOf(e))) ? "0" : archivesCom.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
sociaComJsonMap.put(String.valueOf(e), result.toPlainString());
socialCom.add(result);
});
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap));
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal decimal : socialCom) {
socialComSum = socialComSum.add(decimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountEndowmentInsurance(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, List<Long> categoryIds) {
if (accountPO.getSocial() != null) {
InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial();
insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization());
insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount());
insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId());
insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString());
if ((NonPaymentEnum.YES.getValue() == socialPO.getNonPayment() || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null) {
List<InsuranceSchemeDetailPO> detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(socialPO.getSocialSchemeId());
//方案中包含的需要缴纳社保的个人福利
Map<Long, InsuranceSchemeDetailPO> schemeperson = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
categoryIds.forEach(item -> {
if (archivesPerson.containsKey(String.valueOf(item)) && schemeperson.containsKey(item)) {
needArchivesPerson.add(item);
}
});
List<BigDecimal> socialPer = new ArrayList<>();
Map<String, String> socialPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = schemeperson.get(e);
BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(archivesPerson.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
socialPerJsonMap.put(String.valueOf(e), result.toPlainString());
socialPer.add(result);
});
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap));
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
//方案中包含的需要缴纳社保的单位福利
Map<Long, InsuranceSchemeDetailPO> schemeCom = detailPOS.stream()
.filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue())
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
archivesCom.forEach((id, value) -> {
if (schemeCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
List<BigDecimal> socialCom = new ArrayList<>();
Map<String, String> sociaComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = schemeCom.get(e);
BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal(archivesCom.get(String.valueOf(e)));
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
;
sociaComJsonMap.put(String.valueOf(e), result.toPlainString());
socialCom.add(result);
});
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap));
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal decimal : socialCom) {
socialComSum = socialComSum.add(decimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
@Transactional
public void batchSaveSupplementAccount(List<InsuranceAccountDetailPO> pos, String billMonth, String tenantKey) {
if (CollectionUtils.isEmpty(pos)) {
return;
}
batchSaveAccountInspectDetail(pos, billMonth, tenantKey);
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDelSupplementAccountDetails(pos);
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchSaveAccountDetails(pos);
//删除日志
// pos.stream().forEach(item -> {
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(item.getId()));
// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId()));
// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100448, "删除核算记录"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100448, "删除核算记录"));
// insuranceSchemeContext.setNewValues(item);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
// });
//插入日志
// pos.stream().forEach(item -> {
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(item.getId()));
// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId()));
// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100494, "新建核算记录"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100494, "新建核算记录"));
// insuranceSchemeContext.setNewValues(item);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
// });
}
public void deleteCommonAccount(SaveCommonAccountParam param, Long employeeId) {
SalaryAssert.notBlank(param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 84026, "参数错误"));
SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel( 84026, "参数错误"));
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDelAccountDetails(param.getIncludes(), param.getBillMonth());
//记录日志
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.join(",", param.getIncludes().stream().map(item -> String.valueOf(item)).collect(Collectors.toList())));
// insuranceSchemeContext.setTargetName(param.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账"));
// insuranceSchemeContext.setNewValues(param);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
updateBatchAccount(param.getBillMonth(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
}
public void deleteSupplementaryAccount(List<SupplementAccountBaseParam> param, Long employeeId) {
SalaryAssert.notEmpty(param, SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
boolean valid = param.stream().anyMatch(item -> item.getEmployeeId() == null
|| StringUtils.isBlank(item.getSupplementaryMonth())
|| StringUtils.isBlank(item.getBillMonth()));
if (valid) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
}
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDelSupplementDetailsByIds(param);
// param.stream().forEach(item -> {
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(IdGenerator.generate()));
// insuranceSchemeContext.setTargetName(item.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100490, "删除补缴核算记录"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100490, "删除补缴核算记录"));
// insuranceSchemeContext.setNewValues(item);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
// });
updateBatchAccount(param.get(0).getBillMonth(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
}
public void file(String billMonth, Long employeeId) {
//归档前检查是否有核算异常
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getByInspectStatusAndBillMonth(InspectStatusEnum.IGNORE.getValue(),billMonth);
SalaryAssert.isEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel( 100500, "当前核算月存在核算异常数据"));
//开始归档数据
InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillStatus(billMonth,BillStatusEnum.NOT_ARCHIVED.getValue());
SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel( 100503, "月份账单不存在"));
SalaryAssert.isFalse(insuranceAccountBatchPO.getBillStatus() == BillStatusEnum.ARCHIVED.getValue(), SalaryI18nUtil.getI18nLabel( 100504, "月份账单已归档"));
insuranceAccountBatchPO.setBillStatus(BillStatusEnum.ARCHIVED.getValue());
MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).updateById(insuranceAccountBatchPO);
//日志记录
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId()));
// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100506, "台账归档"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100506, "台账归档"));
// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
}
}

View File

@ -24,7 +24,6 @@ import java.util.Date;
@AllArgsConstructor
@SalaryTable(pageId = "021c4a65-c401-4bcc-a720-6233996e17f1", tableType = WeaTableType.CHECKBOX,operates = {
})
@Accessors(chain = true)
public class InsuranceAccountDetailPO {
/**

View File

@ -1,6 +1,9 @@
package com.engine.salary.entity.siaccount.po;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
@ -13,7 +16,9 @@ import java.util.Date;
* @Version V1.0
**/
@Data
@Accessors(chain = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InsuranceAccountDetailTempPO {
/**

View File

@ -6,11 +6,11 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description:
* @Author: zhangheng
* @CreateDate: 2021/12/7 19:05
* @Version: v1.0
*/
* @Author weaver_cl
* @Description: TODO
* @Date 2022/3/17
* @Version V1.0
**/
@Data
@Builder
@NoArgsConstructor

View File

@ -51,4 +51,12 @@ public interface InsuranceAccountBatchMapper {
*/
void updateById(@Param("pos") InsuranceAccountBatchPO pos);
/**
*
* @param billMonth
* @param billStatus
* @return
*/
InsuranceAccountBatchPO getByBillStatus(@Param("billMonth") String billMonth,@Param("billStatus")Integer billStatus);
}

View File

@ -118,6 +118,17 @@
</select>
<select id="getByBillStatus" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_bill_batch t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
AND t.bill_status = #{billStatus}
</select>
<delete id="deleteById">
UPDATE hrsa_bill_batch
SET delete_type = 1

View File

@ -1,6 +1,7 @@
package com.engine.salary.mapper.siaccount;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.param.SupplementAccountBaseParam;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import org.apache.ibatis.annotations.Param;
@ -47,5 +48,35 @@ public interface InsuranceAccountDetailMapper {
void batchSaveAccountDetails(@Param("accounts") Collection<InsuranceAccountDetailPO> accounts);
/**
* 条件查询
* @param billMonth
* @return
*/
List<InsuranceAccountDetailPO> selectList(@Param("billMonth") String billMonth);
/**
* 根据账单月份删除
* @param billMonth
*/
void batchDeleteNotFile(@Param("billMonth") String billMonth);
/**
* 批量删除
* @param pos
*/
void batchDelSupplementAccountDetails(@Param("pos") Collection<InsuranceAccountDetailPO> pos);
/**
* 根据员工id批量删除
* @param pos
*/
void batchDelSupplementDetailsByIds(@Param("pos") Collection<SupplementAccountBaseParam> pos);
void batchUnConfirmedInspectDetails(@Param("ids") Collection<Long> ids);
}

View File

@ -133,7 +133,7 @@
</select>
<select id="selectAccountIds" resultMap="Long">
<select id="selectAccountIds" resultType="java.lang.Long">
SELECT
t.employee_id
FROM
@ -144,13 +144,45 @@
<!-- 根据主键删除记录 -->
<delete id="delete" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
<delete id="deleteById" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="batchDeleteNotFile" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
DELETE
FROM hrsa_bill_detail
WHERE delete_type = 0
AND bill_month = #{billMonth}
AND bill_status = 0
</delete>
<delete id="batchDelSupplementAccountDetails">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="pos" open="(" item="po" separator="," close=")">
#{po.id}
</foreach>
</delete>
<update id="batchUnConfirmedInspectDetails">
UPDATE
hrsa_bill_inspect
SET
inspect_status = 0
WHERE
delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 批量删除 -->
<delete id="batchDelAccountDetails">
@ -165,6 +197,17 @@
</delete>
<delete id="batchDelSupplementDetailsByIds">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
AND employee_id IN
<foreach collection="pos" open="(" item="po" separator="," close=")">
#{po.employeeId}
</foreach>
</delete>
<insert id="batchSaveAccountDetails">
INSERT INTO hrsa_bill_detail
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,

View File

@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
* @Author weaver_cl
@ -25,4 +26,18 @@ public interface InsuranceAccountInspectMapper {
*/
void batchSaveInspectDetails(@Param("pos") Collection<InsuranceAccountInspectPO> pos);
/**
*
* @param inspectStatus
* @param billMonth
* @return
*/
List<InsuranceAccountInspectPO> getByInspectStatusAndBillMonth(@Param("inspectStatus")Integer inspectStatus,@Param("billMonth")String billMonth);
List<InsuranceAccountInspectPO> getByInspectStatusAndIds(@Param("inspectStatus")Integer inspectStatus,@Param("ids")Collection<Long> ids);
}

View File

@ -32,6 +32,34 @@
, t.tenant_key
</sql>
<select id="getByInspectStatusAndBillMonth" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_bill_inspect t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
AND t.inspect_status = #{inspectStatus}
</select>
<sql id="paramSql">
<if test="ids != null and ids.size()>0">
AND t.id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</sql>
<select id="getByInspectStatusAndIds" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_bill_inspect t
WHERE t.delete_type = 0
AND t.inspect_status = #{inspectStatus}
<include refid="paramSql"/>
</select>
<!-- 批量删除 -->
<delete id="batchDelInspectDetails">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper">
<mapper namespace="com.engine.salary.mapper.siaccount.SIAccountDetailTempMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailTempPO">
<result column="id" property="id"/>
<result column="employee_id" property="employeeId"/>

View File

@ -66,4 +66,12 @@ public interface ICategoryMapper {
*/
List<ICategoryPO> listByWelfareType(@Param("welfareType") Integer welfareType,
@Param("dataType") Integer dataType);
/**
* 根据数据类型查询
* @param dataType
* @return
*/
List<ICategoryPO> listByDataType(@Param("dataType") Integer dataType);
}

View File

@ -97,6 +97,14 @@
ORDER BY id DESC
</select>
<select id="listByDataType" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_category t
WHERE data_type= #{dataType} AND delete_type = 0
</select>
<!-- 更新,更新修改字段 -->
<update id="update" parameterType="com.engine.salary.entity.sicategory.po.ICategoryPO">
UPDATE hrsa_insurance_category

View File

@ -1,9 +1,9 @@
package com.engine.salary.service;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.param.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
@ -14,18 +14,109 @@ import java.util.Map;
**/
public interface SIAccountService {
/**
* 查询台账列表
* @param insuranceAccountBatchParam
* @return
*/
Map<String,Object> listPage(InsuranceAccountBatchParam insuranceAccountBatchParam);
/**
* 获取正常缴纳列表
* @param insuranceAccountDetailParam
* @return
*/
Map<String,Object> listCommonPage(InsuranceAccountDetailParam insuranceAccountDetailParam);
/**
* 根据姓名名获取正常缴纳列表
* @param insuranceAccountDetailParam
* @return
*/
Map<String,Object> listCommonPageByName(InsuranceAccountDetailParam insuranceAccountDetailParam);
/**
* 获取补缴缴纳列表
* @param insuranceAccountDetailParam
* @return
*/
Map<String,Object> listSupplementaryPage(InsuranceAccountDetailParam insuranceAccountDetailParam);
/**
* 根据姓名获取补缴缴纳列表
* @param insuranceAccountDetailParam
* @return
*/
Map<String,Object> supplementaryByNameList(InsuranceAccountDetailParam insuranceAccountDetailParam);
/**
* 获取核算月份备注填写表单
* @param params
* @return
*/
Map<String, Object> getForm(Map<String, Object> params);
Map<String, Object> save(AccountParam param);
/**
* 保存并进入核算
* @param param
*/
void save(AccountParam param);
/**
* 正常缴纳页核算
* @param saveCommonAccountParam
*/
void commonAccount(SaveCommonAccountParam saveCommonAccountParam);
/**
* 删除月份表单
* @param accountParam
*/
void delete(AccountParam accountParam);
/**
* 添加正常缴纳人员
* @param accountParam
*/
void saveCommonAccount(SaveCommonAccountParam accountParam);
/**
* 添加补缴人员
* @param saveSupplementaryAccountParam
*/
void saveSupplementaryAccount(SaveSupplementaryAccountParam saveSupplementaryAccountParam);
/**
* 删除正常缴纳人员
* @param accountParam
*/
void deleteCommonAccount(SaveCommonAccountParam accountParam);
/**
* 删除补缴人员
* @param supplementAccountBaseParams
*/
void deleteSummplementaryAccount(List<SupplementAccountBaseParam> supplementAccountBaseParams);
/**
* 台账归档
* @param accountParam
*/
void file(AccountParam accountParam);
/**
* 重置核算异常
* @param ids
*/
void unconfirmed(Collection<Long> ids);
/**
* 获取核算异常列表页是否导出档案开关
* @param s
*/
Map<String, Boolean> buttonCheck(String s);
}

View File

@ -13,17 +13,17 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.param.Permission;
import com.engine.salary.entity.siaccount.param.*;
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
import com.engine.salary.enums.siaccount.BillStatusEnum;
import com.engine.salary.enums.siaccount.InspectStatusEnum;
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper;
import com.engine.salary.service.ColumnBuildService;
import com.engine.salary.service.RecordsBuildService;
import com.engine.salary.service.SIAccountService;
@ -251,27 +251,78 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
return apidatas;
}
/**
* 保存月份和备注信息并进入核算
*
* @param param 请求入参
* <p>
* 接口逻辑
* 1检查当前月份是否已经归档如果已经归档直接返回状态为未归档继续执行
* 2从基础人员表左连接部门和离职表以及档案表查询出来符合缴纳的人员清单
* 1离职日期在当月一号零时之后
* 2档案中配置了福利缴纳开始缴纳月开始时间包含当前月
* 3forkjoin核算并入库
* 4更新台账
*/
@Override
public Map<String, Object> save(AccountParam param) {
Map<String, Object> apidatas = new HashMap<>();
public void save(AccountParam param) {
Long employeeId = (long)user.getUID();
String lastname = user.getLastname();
String lastName = user.getLastname();
ValidUtil.doValidator(param);
siAccountBiz.save(true,param,employeeId,lastname);
return apidatas;
siAccountBiz.save(true,param,employeeId,lastName);
}
@Override
public void commonAccount(SaveCommonAccountParam param) {
Long employeeId = (long)user.getUID();
ValidUtil.doValidator(param);
siAccountBiz.saveCommonAccount(param,employeeId);
}
@Override
public void delete(AccountParam accountParam) {
Long employeeId = (long)user.getUID();
siAccountBiz.delete(accountParam,employeeId);
}
@Override
public void saveCommonAccount(SaveCommonAccountParam accountParam) {
Long employeeId = (long)user.getUID();
siAccountBiz.saveCommonAccount(accountParam,employeeId);
}
@Override
public void saveSupplementaryAccount(SaveSupplementaryAccountParam saveSupplementaryAccountParam) {
Long employeeId = (long)user.getUID();
siAccountBiz.saveSupplementaryAccount(saveSupplementaryAccountParam,employeeId);
}
@Override
public void deleteCommonAccount(SaveCommonAccountParam param) {
Long employeeId = (long)user.getUID();
siAccountBiz.deleteCommonAccount(param,employeeId);
}
@Override
public void deleteSummplementaryAccount(List<SupplementAccountBaseParam> supplementAccountBaseParams) {
Long employeeId = (long)user.getUID();
siAccountBiz.deleteSupplementaryAccount(supplementAccountBaseParams,employeeId);
}
@Override
public void file(AccountParam accountParam) {
Long employeeId = (long)user.getUID();
String billMonth = accountParam.getBillMonth();
siAccountBiz.file(billMonth,employeeId);
}
@Override
public void unconfirmed(Collection<Long> ids) {
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getByInspectStatusAndIds(InspectStatusEnum.COMFORED.getValue(),ids);
if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) {
MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchUnConfirmedInspectDetails(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getId).collect(Collectors.toList()));
}
}
@Override
public Map<String, Boolean> buttonCheck(String billMonth) {
Map<String, Boolean> result = new HashMap<>();
List<InsuranceAccountInspectPO> list = MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).getByInspectStatusAndBillMonth(InspectStatusEnum.IGNORE.getValue(),billMonth);
if (CollectionUtils.isEmpty(list)) {
result.put("displayFlag", false);
return result;
}
result.put("displayFlag", true);
return result;
}

View File

@ -2,12 +2,13 @@ package com.engine.salary.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.param.*;
import com.engine.salary.service.impl.SIAccountServiceImpl;
import com.engine.salary.util.ResponseResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.RequestParam;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import com.engine.salary.service.SIAccountService;
@ -17,6 +18,8 @@ import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
@ -28,11 +31,12 @@ import java.util.Map;
public class SIAccountController {
public SIAccountService getService(User user) {
return ServiceUtil.getService(SIAccountServiceImpl.class,user);
return ServiceUtil.getService(SIAccountServiceImpl.class, user);
}
/**
* 获取台账列表页
*
* @param request
* @param response
* @return
@ -40,13 +44,14 @@ public class SIAccountController {
@GET
@Path("/batch/list")
@Produces(MediaType.APPLICATION_JSON)
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody InsuranceAccountBatchParam insuranceAccountBatchParam) {
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceAccountBatchParam insuranceAccountBatchParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<InsuranceAccountBatchParam, Map<String, Object>>().run(getService(user)::listPage, insuranceAccountBatchParam);
}
/**
* 获取正常缴纳列表
*
* @param request
* @param response
* @param insuranceAccountDetailParam
@ -63,6 +68,7 @@ public class SIAccountController {
/**
* 根据姓名获取正常缴纳列表
*
* @param request
* @param response
* @param insuranceAccountDetailParam
@ -72,13 +78,14 @@ public class SIAccountController {
@Path("/detail/common/search")
@Produces(MediaType.APPLICATION_JSON)
public String commonByNameList(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
@RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<InsuranceAccountDetailParam, Map<String, Object>>().run(getService(user)::listCommonPageByName, insuranceAccountDetailParam);
}
/**
* 获取补缴缴纳列表
*
* @param request
* @param response
* @param insuranceAccountDetailParam
@ -88,13 +95,14 @@ public class SIAccountController {
@Path("/detail/supplementary/list")
@Produces(MediaType.APPLICATION_JSON)
public String listSupplementaryPage(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
@RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<InsuranceAccountDetailParam, Map<String, Object>>().run(getService(user)::listSupplementaryPage, insuranceAccountDetailParam);
}
/**
* 根据姓名获取补缴缴纳列表
*
* @param request
* @param response
* @param insuranceAccountDetailParam
@ -104,7 +112,7 @@ public class SIAccountController {
@Path("/detail/supplementary/search")
@Produces(MediaType.APPLICATION_JSON)
public String supplementaryByNameList(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
@RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<InsuranceAccountDetailParam, Map<String, Object>>().run(getService(user)::supplementaryByNameList, insuranceAccountDetailParam);
}
@ -112,6 +120,7 @@ public class SIAccountController {
/**
* 获取核算月份备注填写表单
*
* @param request
* @param response
* @return
@ -127,6 +136,7 @@ public class SIAccountController {
/**
* 保存并进入核算
*
* @param request
* @param response
* @param param
@ -138,15 +148,185 @@ public class SIAccountController {
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody AccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<AccountParam, Map<String, Object>>().run(getService(user)::save, param);
return new ResponseResult<AccountParam, String>().run(getService(user)::save, param);
}
/**
* 正常缴纳页核算
*
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/commonAccount")
@Produces(MediaType.APPLICATION_JSON)
public String commonAccount(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody SaveCommonAccountParam param) {
User user = HrmUserVarify.getUser(request, response);
if (CollectionUtils.isNotEmpty(param.getIncludes())) {
return new ResponseResult<SaveCommonAccountParam, String>().run(getService(user)::commonAccount, param);
} else {
AccountParam reqParam = new AccountParam();
reqParam.setBillMonth(param.getBillMonth());
return new ResponseResult<AccountParam, String>().run(getService(user)::save, reqParam);
}
}
/**
* 删除月份表单
*
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/delete")
@Produces(MediaType.APPLICATION_JSON)
public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody AccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<AccountParam, String>().run(getService(user)::delete, param);
}
// @GetMapping("commonForm")
// @ApiOperation("正常缴纳添加缴纳人员表单")
// @WeaPermission
// public WeaResult<WeaForm> queryCommonForm() {
// return siAccountWrapper.getCommonForm(UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey());
// }
@POST
@Path("/common/save")
@Produces(MediaType.APPLICATION_JSON)
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody SaveCommonAccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SaveCommonAccountParam, String>().run(getService(user)::saveCommonAccount, param);
}
// @GetMapping("querySupplementaryForm")
// @ApiOperation("补缴添加缴纳人员表单")
// @WeaPermission
// public WeaResult<WeaForm> querySupplementaryForm() {
// return siAccountWrapper.getSupplementaryForm(UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey());
// }
@POST
@Path("/supplementary/save")
@Produces(MediaType.APPLICATION_JSON)
public String saveSummplementaryAccount(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody SaveSupplementaryAccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SaveSupplementaryAccountParam, String>().run(getService(user)::saveSupplementaryAccount, param);
}
@POST
@Path("/common/delete")
@Produces(MediaType.APPLICATION_JSON)
public String deleteCommon(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody SaveCommonAccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SaveCommonAccountParam, String>().run(getService(user)::deleteCommonAccount, param);
}
@POST
@Path("/supplementary/delete")
@Produces(MediaType.APPLICATION_JSON)
public String deleteSummplementaryAccount(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody List<SupplementAccountBaseParam> param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<List<SupplementAccountBaseParam>, String>().run(getService(user)::deleteSummplementaryAccount, param);
}
@POST
@Path("/file")
@Produces(MediaType.APPLICATION_JSON)
public String file(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody AccountParam accountParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<AccountParam, String>().run(getService(user)::file, accountParam);
}
// @GET
// @Path("/changeList")
// @Produces(MediaType.APPLICATION_JSON)
// public String changeList(@Context HttpServletRequest request, @Context HttpServletResponse response,
// @RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
// User user = HrmUserVarify.getUser(request, response);
// return new ResponseResult<InsuranceAccountDetailParam, Map<String, Object>>().run(getService(user)::changeList, insuranceAccountDetailParam);
// }
// @GetMapping("overView")
// @ApiOperation("总览")
// @WeaPermission
// public WeaResult<WeaTable<InsuranceAccountViewListDTO>> overView(@RequestParam(value = "billMonth") String billMonth) {
// return siAccountWrapper.overView(billMonth, UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey());
// }
//
// @GetMapping("tabList")
// @ApiOperation("tab信息")
// @WeaPermission
// public WeaResult<InsuranceAccountTabDTO> tabList(@RequestParam(value = "billMonth") String billMonth) {
// return siAccountWrapper.tabList(billMonth, UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey());
// }
//
// @GetMapping("inspectList")
// @ApiOperation("核算失败列表")
// @WeaPermission
// public WeaResult<WeaTable> getInspectTable(@RequestParam(value = "billMonth") String billMonth) {
// return siAccountWrapper.getInspectTable(billMonth, UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey());
// }
//
// @PostMapping("inspectAccount")
// @ApiOperation("核算核算异常")
// @WeaPermission
// public WeaResult<String> accountInspect(@RequestBody InspectAccountParam param) {
// return siAccountWrapper.accountInspect(param.getIds(), param.getBillMonth(), UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey());
// }
//
// @PostMapping("ignore")
// @ApiOperation("忽略核算异常")
// @WeaPermission
// public WeaResult<String> ignore(@RequestBody Collection<Long> ids) {
// return siAccountWrapper.ignore(ids, TenantContext.getCurrentTenantKey());
// }
//
// @PostMapping("unconfirmed")
// @ApiOperation("重置核算异常")
// @WeaPermission
// public WeaResult<String> unconfirmed(@RequestBody Collection<Long> ids) {
// return siAccountWrapper.unConfirmed(ids, TenantContext.getCurrentTenantKey());
// }
@POST
@Path("/unconfirmed")
@Produces(MediaType.APPLICATION_JSON)
public String unconfirmed(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody Collection<Long> ids) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Collection<Long>, String>().run(getService(user)::unconfirmed, ids);
}
@GET
@Path("/getDisplayFlag")
@Produces(MediaType.APPLICATION_JSON)
public String buttonCheck(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("billMonth") String billMonth) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, Map<String, Boolean>>().run(getService(user)::buttonCheck, billMonth);
}
}