From 6ddf60a548564b5bfd5bb5d84216538976a465d0 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Fri, 15 Apr 2022 13:17:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=8F=E5=88=A9=E5=8F=B0=E8=B4=A6=E6=A0=B8?= =?UTF-8?q?=E7=AE=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/biz/SIAccountBiz.java | 572 +++++++++++++++++- .../po/InsuranceAccountDetailPO.java | 1 - .../po/InsuranceAccountDetailTempPO.java | 7 +- .../po/InsuranceArchivesAccountPO.java | 10 +- .../InsuranceAccountBatchMapper.java | 8 + .../siaccount/InsuranceAccountBatchMapper.xml | 11 + .../InsuranceAccountDetailMapper.java | 31 + .../InsuranceAccountDetailMapper.xml | 47 +- .../InsuranceAccountInspectMapper.java | 15 + .../InsuranceAccountInspectMapper.xml | 28 + .../siaccount/SIAccountDetailTempMapper.xml | 2 +- .../mapper/sicategory/ICategoryMapper.java | 8 + .../mapper/sicategory/ICategoryMapper.xml | 8 + .../salary/service/SIAccountService.java | 99 ++- .../service/impl/SIAccountServiceImpl.java | 95 ++- .../salary/web/SIAccountController.java | 198 +++++- 16 files changed, 1083 insertions(+), 57 deletions(-) diff --git a/src/com/engine/salary/biz/SIAccountBiz.java b/src/com/engine/salary/biz/SIAccountBiz.java index affeb8e7f..fe1dd4ff3 100644 --- a/src/com/engine/salary/biz/SIAccountBiz.java +++ b/src/com/engine/salary/biz/SIAccountBiz.java @@ -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 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 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 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 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 baseList, List employeeIds, String billMonth,Long employeeId) { + //(k,v) k-员工id v-员工对应的福利档案数据 + Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds,SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + //核算结果集 + List 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 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 ids = new ArrayList<>(); + List 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 detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(otherPO.getOtherSchemeId()); + //方案中包含的需要缴纳其他的个人福利 + Map 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 archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + //需要核算其他的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + archivesPerson.forEach((id, value) -> { + if (otherPerson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + List otherPer = new ArrayList<>(); + Map 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 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 archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + //需要核算其他的福利id 单位 + List needArchivesCom = new ArrayList<>(); + archivesCom.forEach((id, value) -> { + if (otherCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + List otherComList = new ArrayList<>(); + Map 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 detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(fundPO.getFundSchemeId()); + //方案中包含的需要缴纳社保的个人福利 + Map fundperson = detailPOS.stream() + .filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue()) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + //需要核算公积金的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + archivesPerson.forEach((id, value) -> { + if (fundperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + List fundPer = new ArrayList<>(); + Map 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 fundCom = detailPOS.stream() + .filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue()) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + //需要核算公积金的福利id 单位 + List needArchivesCom = new ArrayList<>(); + archivesCom.forEach((id, value) -> { + if (fundCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + List fundComList = new ArrayList<>(); + Map 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 detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(socialPO.getSocialSchemeId()); + //方案中包含的需要缴纳社保的个人福利 + Map schemeperson = detailPOS.stream() + .filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue()) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + archivesPerson.forEach((id, value) -> { + if (schemeperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + List socialPer = new ArrayList<>(); + Map 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 schemeCom = detailPOS.stream() + .filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue()) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + archivesCom.forEach((id, value) -> { + if (schemeCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + List socialCom = new ArrayList<>(); + Map 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 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 detailPOS = MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class).queryListBySchemeId(socialPO.getSocialSchemeId()); + //方案中包含的需要缴纳社保的个人福利 + Map schemeperson = detailPOS.stream() + .filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_PERSON.getValue()) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + categoryIds.forEach(item -> { + if (archivesPerson.containsKey(String.valueOf(item)) && schemeperson.containsKey(item)) { + needArchivesPerson.add(item); + } + }); + List socialPer = new ArrayList<>(); + Map 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 schemeCom = detailPOS.stream() + .filter(item -> IsPaymentEnum.YES.getValue() == item.getIsPayment() && item.getPaymentScope() == PaymentScopeEnum.SCOPE_COMPANY.getValue()) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + archivesCom.forEach((id, value) -> { + if (schemeCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + List socialCom = new ArrayList<>(); + Map 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 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 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 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); + + } } diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java index 4ec79144d..4f8f53ac3 100644 --- a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailPO.java @@ -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 { /** diff --git a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java index e2c012311..37d376c61 100644 --- a/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java +++ b/src/com/engine/salary/entity/siaccount/po/InsuranceAccountDetailTempPO.java @@ -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 { /** diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java index f16de0271..23f3313cf 100644 --- a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java @@ -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 diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java index e0bf720a8..578654a26 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java @@ -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); + } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml index 1c7dd297e..abcd25660 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml @@ -118,6 +118,17 @@ + + + UPDATE hrsa_bill_batch SET delete_type = 1 diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java index dbaaf190b..ef221d2c3 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java @@ -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 accounts); + /** + * 条件查询 + * @param billMonth + * @return + */ List selectList(@Param("billMonth") String billMonth); + + + /** + * 根据账单月份删除 + * @param billMonth + */ + void batchDeleteNotFile(@Param("billMonth") String billMonth); + + + /** + * 批量删除 + * @param pos + */ + void batchDelSupplementAccountDetails(@Param("pos") Collection pos); + + + /** + * 根据员工id批量删除 + * @param pos + */ + void batchDelSupplementDetailsByIds(@Param("pos") Collection pos); + + + void batchUnConfirmedInspectDetails(@Param("ids") Collection ids); + } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml index 0110ca112..2254555d7 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml @@ -133,7 +133,7 @@ - SELECT t.employee_id FROM @@ -144,13 +144,45 @@ - + UPDATE hrsa_bill_detail SET delete_type = 1 WHERE id = #{id} AND delete_type = 0 + + DELETE + FROM hrsa_bill_detail + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND bill_status = 0 + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{po.id} + + + + + UPDATE + hrsa_bill_inspect + SET + inspect_status = 0 + WHERE + delete_type = 0 + AND id IN + + #{id} + + + @@ -165,6 +197,17 @@ + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND employee_id IN + + #{po.employeeId} + + + + 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, diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java index c358e4617..59b93a602 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java @@ -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 pos); + + /** + * + * @param inspectStatus + * @param billMonth + * @return + */ + List getByInspectStatusAndBillMonth(@Param("inspectStatus")Integer inspectStatus,@Param("billMonth")String billMonth); + + + List getByInspectStatusAndIds(@Param("inspectStatus")Integer inspectStatus,@Param("ids")Collection ids); + + + } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml index 5e7499a00..8f2f94327 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml @@ -32,6 +32,34 @@ , t.tenant_key + + + + + AND t.id IN + + #{id} + + + + + diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml index 02862dca8..5ffbf57d1 100644 --- a/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml @@ -1,6 +1,6 @@ - + diff --git a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java index d19afd3fa..ad8caba72 100644 --- a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java +++ b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.java @@ -66,4 +66,12 @@ public interface ICategoryMapper { */ List listByWelfareType(@Param("welfareType") Integer welfareType, @Param("dataType") Integer dataType); + + /** + * 根据数据类型查询 + * @param dataType + * @return + */ + List listByDataType(@Param("dataType") Integer dataType); + } diff --git a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml index ac1551c1c..d68b0c03b 100644 --- a/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml +++ b/src/com/engine/salary/mapper/sicategory/ICategoryMapper.xml @@ -97,6 +97,14 @@ ORDER BY id DESC + + + UPDATE hrsa_insurance_category diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java index 4c6a086ed..d78f826ee 100644 --- a/src/com/engine/salary/service/SIAccountService.java +++ b/src/com/engine/salary/service/SIAccountService.java @@ -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 listPage(InsuranceAccountBatchParam insuranceAccountBatchParam); + /** + * 获取正常缴纳列表 + * @param insuranceAccountDetailParam + * @return + */ Map listCommonPage(InsuranceAccountDetailParam insuranceAccountDetailParam); + /** + * 根据姓名名获取正常缴纳列表 + * @param insuranceAccountDetailParam + * @return + */ Map listCommonPageByName(InsuranceAccountDetailParam insuranceAccountDetailParam); + /** + * 获取补缴缴纳列表 + * @param insuranceAccountDetailParam + * @return + */ Map listSupplementaryPage(InsuranceAccountDetailParam insuranceAccountDetailParam); + /** + * 根据姓名获取补缴缴纳列表 + * @param insuranceAccountDetailParam + * @return + */ Map supplementaryByNameList(InsuranceAccountDetailParam insuranceAccountDetailParam); + /** + * 获取核算月份备注填写表单 + * @param params + * @return + */ Map getForm(Map params); - Map 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 supplementAccountBaseParams); + + /** + * 台账归档 + * @param accountParam + */ + void file(AccountParam accountParam); + + /** + * 重置核算异常 + * @param ids + */ + void unconfirmed(Collection ids); + + + /** + * 获取核算异常列表页是否导出档案开关 + * @param s + */ + Map buttonCheck(String s); + + } diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index a2aa2c007..295e439a4 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -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 请求入参 - *

- * 接口逻辑: - * 1、检查当前月份是否已经归档,如果已经归档直接返回,状态为未归档继续执行 - * 2、从基础人员表左连接部门和离职表以及档案表,查询出来符合缴纳的人员清单 - * (1)离职日期在当月一号零时之后 - * (2)档案中配置了福利缴纳开始缴纳月,开始时间包含当前月 - * 3、forkjoin核算并入库 - * 4、更新台账 - */ @Override - public Map save(AccountParam param) { - Map 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 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 ids) { + List 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 buttonCheck(String billMonth) { + Map result = new HashMap<>(); + List 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; } diff --git a/src/com/engine/salary/web/SIAccountController.java b/src/com/engine/salary/web/SIAccountController.java index 6ae03e1b6..36d8313c6 100644 --- a/src/com/engine/salary/web/SIAccountController.java +++ b/src/com/engine/salary/web/SIAccountController.java @@ -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>().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>().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>().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>().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>().run(getService(user)::save, param); + return new ResponseResult().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().run(getService(user)::commonAccount, param); + } else { + AccountParam reqParam = new AccountParam(); + reqParam.setBillMonth(param.getBillMonth()); + return new ResponseResult().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().run(getService(user)::delete, param); + } +// @GetMapping("commonForm") +// @ApiOperation("正常缴纳添加缴纳人员表单") +// @WeaPermission +// public WeaResult 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().run(getService(user)::saveCommonAccount, param); + } +// @GetMapping("querySupplementaryForm") +// @ApiOperation("补缴添加缴纳人员表单") +// @WeaPermission +// public WeaResult 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().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().run(getService(user)::deleteCommonAccount, param); + } + + + @POST + @Path("/supplementary/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSummplementaryAccount(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody List param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, 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().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>().run(getService(user)::changeList, insuranceAccountDetailParam); +// } + + +// @GetMapping("overView") +// @ApiOperation("总览") +// @WeaPermission +// public WeaResult> overView(@RequestParam(value = "billMonth") String billMonth) { +// return siAccountWrapper.overView(billMonth, UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey()); +// } +// +// @GetMapping("tabList") +// @ApiOperation("tab信息") +// @WeaPermission +// public WeaResult tabList(@RequestParam(value = "billMonth") String billMonth) { +// return siAccountWrapper.tabList(billMonth, UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey()); +// } +// +// @GetMapping("inspectList") +// @ApiOperation("核算失败列表") +// @WeaPermission +// public WeaResult getInspectTable(@RequestParam(value = "billMonth") String billMonth) { +// return siAccountWrapper.getInspectTable(billMonth, UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey()); +// } +// +// @PostMapping("inspectAccount") +// @ApiOperation("核算核算异常") +// @WeaPermission +// public WeaResult accountInspect(@RequestBody InspectAccountParam param) { +// return siAccountWrapper.accountInspect(param.getIds(), param.getBillMonth(), UserContext.getCurrentUser().getEmployeeId(), TenantContext.getCurrentTenantKey()); +// } +// +// @PostMapping("ignore") +// @ApiOperation("忽略核算异常") +// @WeaPermission +// public WeaResult ignore(@RequestBody Collection ids) { +// return siAccountWrapper.ignore(ids, TenantContext.getCurrentTenantKey()); +// } +// +// @PostMapping("unconfirmed") +// @ApiOperation("重置核算异常") +// @WeaPermission +// public WeaResult unconfirmed(@RequestBody Collection 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 ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, 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>().run(getService(user)::buttonCheck, billMonth); + } }