From 2eadc713e151b506712e15b08fdfc4ab0d5c78d3 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 14 Apr 2022 11:54:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E8=B5=84=E5=8F=B0=E8=B4=A6=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=A0=B8=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/biz/SIAccountBiz.java | 660 +++++++++++++++++- src/com/engine/salary/biz/SIArchivesBiz.java | 49 +- src/com/engine/salary/biz/SISchemeBiz.java | 4 +- .../entity/siaccount/param/AccountParam.java | 3 + .../siaccount/param/DSTenantKeyThreadVar.java | 15 + .../param/InsuranceAccountBatchParam.java | 2 + .../po/InsuranceArchivesAccountPO.java | 25 + .../InsuranceAccountBatchMapper.java | 31 + .../siaccount/InsuranceAccountBatchMapper.xml | 82 +++ .../InsuranceAccountDetailMapper.java | 28 + .../InsuranceAccountDetailMapper.xml | 204 ++++++ .../InsuranceAccountInspectMapper.java | 28 + .../InsuranceAccountInspectMapper.xml | 113 +++ .../siaccount/SIAccountDetailTempMapper.java | 38 + .../siaccount/SIAccountDetailTempMapper.xml | 292 ++++++++ .../sischeme/InsuranceSchemeDetailMapper.java | 2 +- .../sischeme/InsuranceSchemeMapper.java | 1 + .../salary/service/SIAccountService.java | 3 + .../service/impl/SIAccountServiceImpl.java | 93 +-- .../engine/salary/util/SalaryEntityUtil.java | 17 + .../salary/util/SalaryFormItemUtil.java | 3 + .../salary/web/SIAccountController.java | 20 +- 22 files changed, 1661 insertions(+), 52 deletions(-) create mode 100644 src/com/engine/salary/entity/siaccount/param/DSTenantKeyThreadVar.java create mode 100644 src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml create mode 100644 src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.java create mode 100644 src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml diff --git a/src/com/engine/salary/biz/SIAccountBiz.java b/src/com/engine/salary/biz/SIAccountBiz.java index 9a6757d0d..affeb8e7f 100644 --- a/src/com/engine/salary/biz/SIAccountBiz.java +++ b/src/com/engine/salary/biz/SIAccountBiz.java @@ -1,18 +1,65 @@ package com.engine.salary.biz; +import com.alibaba.fastjson.JSON; +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.po.InsuranceAccountBatchPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailTempPO; +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +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.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.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.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.util.SalaryAssert; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.PageUtil; +import dm.jdbc.util.IdGenerator; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.SqlSession; +import org.springframework.beans.BeanUtils; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.DefaultTransactionDefinition; import weaver.conn.mybatis.MyBatisFactory; -import java.util.List; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.function.Function; +import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * @Author weaver_cl @@ -50,4 +97,615 @@ public class SIAccountBiz { sqlSession.close(); } } + + public void save(boolean flag, AccountParam param,Long employeeId,String username) { + if (flag) { + InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth()); + SalaryAssert.isNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel( 100461, "所属月份存在核算数据")); + InsuranceAccountBatchPO build = InsuranceAccountBatchPO.builder() + //.id(IdGenerator.generate()) + .accountant(username) + .billMonth(param.getBillMonth()) + .billStatus(BillStatusEnum.NOT_ARCHIVED.getValue()) + .remarks(param.getRemarks()) + .creator(employeeId) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .build(); + MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).insert(build); +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// insuranceSchemeContext.setTargetId(String.valueOf(build.getId())); +// insuranceSchemeContext.setTargetName(build.getBillMonth()); +// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue()); +// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账")); +// insuranceSchemeContext.setNewValues(build); +// siAccountLoggerTemplate.write(insuranceSchemeContext); + } + account(param.getBillMonth(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + + } + + public void account(String billMonth, Long employeeId, String tenantKey) { + List employeeIds = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(billMonth)); + if (CollectionUtils.isEmpty(employeeIds)) { + List list = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getAllByBillMonth(billMonth); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).deleteById(f.getId()); + }); + } + } + SalaryAssert.notEmpty(employeeIds, "no account data"); + AccountParam param = new AccountParam(); + param.setBillMonth(billMonth); + ExecutorService taskExecutor = Executors.newCachedThreadPool(); + taskExecutor.execute(() -> { + try { + DSTenantKeyThreadVar.tenantKey.set(tenantKey); + accounting(param, employeeId, tenantKey); + } finally { + DSTenantKeyThreadVar.tenantKey.remove(); + } + }); + } + + public void accounting(AccountParam param, Long employeeId, String tenantKey) { + //薪资核算进度暂未实现 +// SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress(tenantKey + param.getBillMonth(), employeeId, tenantKey); +// if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) { +// return; +// } + doAccounting(param, employeeId, tenantKey); + } + + + @Transactional(propagation = Propagation.NEVER, rollbackFor = Exception.class) + public void doAccounting(AccountParam param, Long employeeId, String tenantKey) { + try { + List ids; + if (CollectionUtils.isEmpty(param.getIds())) { + ids = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth())); + } else { + ids = param.getIds(); + } + if (CollectionUtils.isEmpty(ids)) { + //salaryAcctProgressService.fail(tenantKey + param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 100468, "无需要核算的人员")); + return; + } + SalaryAcctProgressDTO salaryAcctProgressDTO = new SalaryAcctProgressDTO(SalaryI18nUtil.getI18nLabel( 97515, "核算中"), 97515L, ids.size(), 0, + BigDecimal.ZERO, true, "", true); + //salaryAcctProgressService.initProgress(tenantKey + param.getBillMonth(), salaryAcctProgressDTO, employeeId, tenantKey); + /* List> partition = Lists.partition(ids, 100); + CountDownLatch countDownLatch = new CountDownLatch(partition.size()); + BlockingDeque results = new LinkedBlockingDeque<>(partition.size());*/ + commonAccount(/*countDownLatch, results, */param.getBillMonth(), ids, employeeId, tenantKey); + /* for (List batchIds : partition) { + taskExecutor.execute(() -> { + commonAccount(countDownLatch, results, param.getBillMonth(), batchIds, simpleEmployee); + }); + } + countDownLatch.await(); + boolean allSuccess = results.stream().allMatch(Boolean::booleanValue);*/ + /* if (allSuccess) {*/ + handleData(ids, param.getBillMonth(), employeeId, tenantKey); + /*}*/ + MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).batchDelAccountTempDetails(ids, param.getBillMonth()); + } catch (Exception e) { + List list = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getAllByBillMonth(param.getBillMonth()); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).deleteById(f.getId()); + }); + } + + //薪资核算进度暂未实现 + //salaryAcctProgressService.del(tenantKey + param.getBillMonth(), employeeId, tenantKey); + //logger.error("welfare account error:{}", e.getMessage(), e); + } + } + + + public void commonAccount(/*CountDownLatch countDownLatch, BlockingDeque results,*/ String billMonth, List ids, Long employeeId, String tenantKey) { + /* try {*/ + SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, tenantKey); + List list = new ArrayList<>(); + int count = 0; + for (Map.Entry entry : insuranceArchivesAccountPOS.entrySet()) { + Long k = entry.getKey(); + InsuranceArchivesAccountPO v = entry.getValue(); + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + insuranceAccountDetailPO.setBillMonth(billMonth); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setCreator(employeeId); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + //insuranceAccountDetailPO.setId(IdGenerator.generate()); + insuranceAccountDetailPO.setEmployeeId(k); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue()); + insuranceAccountDetailPO.setTenantKey(tenantKey); + //核算社保 + accountSocial(insuranceAccountDetailPO, v, tenantKey); + //核算公积金 + accountFund(insuranceAccountDetailPO, v, tenantKey); + //核算其他福利 + accountOther(insuranceAccountDetailPO, v, tenantKey); + //计算合计 + account(insuranceAccountDetailPO); + //临时表PO + InsuranceAccountDetailTempPO insuranceAccountDetailTempPO = new InsuranceAccountDetailTempPO(); + BeanUtils.copyProperties(insuranceAccountDetailPO, insuranceAccountDetailTempPO); + list.add(insuranceAccountDetailTempPO); + count++; + if (count % 50 == 0 || count >= ids.size()) { + //salaryAcctProgressService.getAndAddCalculatedQty(tenantKey + billMonth, count >= ids.size() ? count % 50 : 50); + } + } + if (CollectionUtils.isNotEmpty(list)) { + MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).batchSaveAccountTempDetails(list); + } + + /* } catch (Exception e) { + logger.error("福利核算失败:{}", e.getMessage(), e); + results.add(false); + } finally { + countDownLatch.countDown(); + }*/ + } + + + private void handleData(List ids, String billMonth, Long employeeId, String tenantKey) { + //事务后续处理 + //TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition()); + try { + List list = MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).getListByEmployeeIdsAndBillMonth(ids,billMonth); + MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchDelAccountDetails(ids, billMonth); + List collect = list.stream().map(item -> { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + BeanUtils.copyProperties(item, insuranceAccountDetailPO); + return insuranceAccountDetailPO; + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + batchSaveAccountInspectDetail(collect, billMonth, tenantKey); + MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).batchSaveAccountDetails(collect); + updateBatchAccount(billMonth, employeeId, tenantKey); + } + //transactionManager.commit(status); + } catch (Exception e) { + //transactionManager.rollback(status); + throw e; + } + } + + public InsuranceAccountDetailPO account(InsuranceAccountDetailPO insuranceAccountDetailPO) { + //个人合计 + BigDecimal socialPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum()); + BigDecimal fundPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum()); + BigDecimal otherPerson = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum()); + BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson); + insuranceAccountDetailPO.setPerSum(perSum.toPlainString()); + //单位合计 + BigDecimal socialCom = + StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum()); + BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum()); + BigDecimal otherCom = + StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum()); + BigDecimal comSum = socialCom.add(fundCom).add(otherCom); + insuranceAccountDetailPO.setComSum(comSum.toPlainString()); + //社保合计 + insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString()); + //公积金合计 + insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString()); + //其他福利合计 + insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString()); + //合计 + insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString()); + return insuranceAccountDetailPO; + } + + public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String tenantKey) { + 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, String tenantKey) { + 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, String tenantKey) { + 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 void batchSaveAccountInspectDetail(List list, String billMonth, String tenantKey) { + List insuranceAccountInspectAllPOS = accountInspect(list, true); + batchDelInspectDetail(insuranceAccountInspectAllPOS); + List insuranceAccountInspectPOS = accountInspect(list, false); + if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) { + batchSaveInspectDetail(insuranceAccountInspectPOS); + } + } + + public List accountInspect(List list, boolean isAll) { + List insuranceAccountInspectPOS = new ArrayList<>(); + for (InsuranceAccountDetailPO e : list) { + if (isAll || detailCheck(e.getSocialPerJson()) || detailCheck(e.getSocialComJson()) + || detailCheck(e.getFundPerJson()) || detailCheck(e.getFundComJson()) + || detailCheck(e.getOtherPerJson()) || detailCheck(e.getOtherComJson())) { + InsuranceAccountInspectPO insuranceAccountInspectPO = InsuranceAccountInspectPO.builder().build(); + insuranceAccountInspectPO.setId(IdGenerator.generate()); + insuranceAccountInspectPO.setSupplementaryProjects(e.getSupplementaryProjects()); + insuranceAccountInspectPO.setInspectStatus(InspectStatusEnum.IGNORE.getValue()); + insuranceAccountInspectPO.setBillMonth(e.getBillMonth()); + insuranceAccountInspectPO.setCreator(e.getCreator()); + insuranceAccountInspectPO.setCreateTime(new Date()); + insuranceAccountInspectPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountInspectPO.setEmployeeId(e.getEmployeeId()); + insuranceAccountInspectPO.setPaymentStatus(e.getPaymentStatus()); + insuranceAccountInspectPO.setSupplementaryMonth(e.getSupplementaryMonth()); + insuranceAccountInspectPO.setTenantKey(e.getTenantKey()); + insuranceAccountInspectPO.setUpdateTime(new Date()); + insuranceAccountInspectPOS.add(insuranceAccountInspectPO); + } + } + return insuranceAccountInspectPOS; + } + + + public boolean detailCheck(String baseString) { + if (StringUtils.isEmpty(baseString)) { + return false; + } + Map baseStringMap = JSON.parseObject(baseString, new TypeReference>() { + }); + if (baseStringMap == null || baseStringMap.size() == 0) { + return false; + } + return baseStringMap.values().stream().anyMatch(item -> StringUtils.isEmpty(item) || Pattern.matches("^([0].?[0]*)$", item)); + + } + + public void batchDelInspectDetail(List list) { + MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).batchDelInspectDetails(list); + //上报删除日志 +// list.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(100445, "删除核算异常记录")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100445, "删除核算异常记录")); +// insuranceSchemeContext.setNewValues(item); +// siAccountLoggerTemplate.write(insuranceSchemeContext); +// }); + } + + public void batchSaveInspectDetail(List list) { + MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class).batchSaveInspectDetails(list); + //上报新增日志 +// list.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(100447, "新建核算异常记录")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100447, "新建核算异常记录")); +// insuranceSchemeContext.setNewValues(item); +// siAccountLoggerTemplate.write(insuranceSchemeContext); +// }); + } + + + /** + * 跟新台账接口 + * + * @param billMonth 账单月份 + * @param tenantKey 租户key + */ + public void updateBatchAccount(String billMonth, Long employeeId, String tenantKey) { + + List insuranceAccountDetailPOS = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectList(billMonth); + Map> map = insuranceAccountDetailPOS.stream().filter(item -> item.getEmployeeId() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId)); + int socialAccountPerson = 0; + int funcAccountPerson = 0; + int otherAccountPerson = 0; + BigDecimal socialSum = new BigDecimal("0"); + BigDecimal fundSum = new BigDecimal("0"); + BigDecimal otherSum = new BigDecimal("0"); + for (Map.Entry> entry : map.entrySet()) { + List v = entry.getValue(); + BigDecimal socialTemp = new BigDecimal("0"); + BigDecimal fundTemp = new BigDecimal("0"); + BigDecimal otherTemp = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : v) { + BigDecimal socialPerson = StringUtils.isBlank(item.getSocialSum()) ? new BigDecimal("0") : new BigDecimal(item.getSocialSum()); + BigDecimal fundPerson = StringUtils.isBlank(item.getFundSum()) ? new BigDecimal("0") : new BigDecimal(item.getFundSum()); + BigDecimal otherPerson = StringUtils.isBlank(item.getOtherSum()) ? new BigDecimal("0") : new BigDecimal(item.getOtherSum()); + socialTemp = socialTemp.add(socialPerson); + fundTemp = fundTemp.add(fundPerson); + otherTemp = otherTemp.add(otherPerson); + } + if (!"0".equals(socialTemp.toPlainString())) { + socialSum = socialSum.add(socialTemp); + socialAccountPerson += 1; + } + if (!"0".equals(fundTemp.toPlainString())) { + fundSum = fundSum.add(fundTemp); + funcAccountPerson += 1; + } + if (!"0".equals(otherTemp.toPlainString())) { + otherSum = otherSum.add(otherTemp); + otherAccountPerson += 1; + } + } + InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth); + DataCollectionEmployee simpleEmployee = MapperProxyFactory.getProxy(EmployMapper.class).getEmployeeById(employeeId); + insuranceAccountBatchPO.setAccountant(simpleEmployee.getUsername()); + insuranceAccountBatchPO.setUpdateTime(new Date()); + insuranceAccountBatchPO.setSocialPay(socialSum.toPlainString()); + insuranceAccountBatchPO.setSocialNum(socialAccountPerson); + insuranceAccountBatchPO.setFundNum(funcAccountPerson); + insuranceAccountBatchPO.setFundPay(fundSum.toPlainString()); + insuranceAccountBatchPO.setOtherNum(otherAccountPerson); + insuranceAccountBatchPO.setOtherPay(otherSum.toPlainString()); + 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, 100491, "更新台账")); +// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100491, "更新台账")); +// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO); +// siAccountLoggerTemplate.write(insuranceSchemeContext); + + } + + + + + + } diff --git a/src/com/engine/salary/biz/SIArchivesBiz.java b/src/com/engine/salary/biz/SIArchivesBiz.java index bcb0392f5..33a2a0fcf 100644 --- a/src/com/engine/salary/biz/SIArchivesBiz.java +++ b/src/com/engine/salary/biz/SIArchivesBiz.java @@ -3,7 +3,6 @@ package com.engine.salary.biz; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; -import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; @@ -21,10 +20,7 @@ import com.engine.salary.entity.siarchives.dto.InsuranceArchivesFundSchemeDTO; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesOtherSchemeDTO; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesSocialSchemeDTO; import com.engine.salary.entity.siarchives.param.*; -import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; -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.siarchives.po.*; import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; @@ -43,8 +39,10 @@ import com.engine.salary.util.SalaryAssert; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryFormItemUtil; +import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.PageUtil; +import org.apache.commons.collections.CollectionUtils; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; import weaver.general.Util; @@ -994,8 +992,43 @@ public class SIArchivesBiz { addGroups.add(new SearchConditionGroup("常用条件",true,conditionItems)); apidatas.put("condition",addGroups); return apidatas; - - - } + + /** + * 组装员工的社保,公积金,其他福利数据 + * + * @param ids 员工id集合 + * @param tenantKey 租户key + * @return map + */ + public Map buildBatchAccount(List ids, String tenantKey) { + if (CollectionUtils.isEmpty(ids)) { + return new HashMap<>(); + } + Map result = new HashMap<>(); + Map socialMap = new HashMap<>(); + Map funMap = new HashMap<>(); + Map otherMap = new HashMap<>(); + List socialPOS = MapperProxyFactory.getProxy(SocialSchemeMapper.class).getSocialByEmployeeId(ids); + if (CollectionUtils.isNotEmpty(socialPOS)) { + socialMap = socialPOS.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); + } + List fundPOS = MapperProxyFactory.getProxy(FundSchemeMapper.class).getFundByEmployeeId(ids); + if (CollectionUtils.isNotEmpty(fundPOS)) { + funMap = fundPOS.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); + } + List otherPOS = MapperProxyFactory.getProxy(OtherSchemeMapper.class).getOtherByEmployeeId(ids); + if (CollectionUtils.isNotEmpty(otherPOS)) { + otherMap = otherPOS.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); + } + for (Long id : ids) { + InsuranceArchivesAccountPO po = new InsuranceArchivesAccountPO(); + po.setSocial(socialMap.get(id)); + po.setFund(funMap.get(id)); + po.setOther(otherMap.get(id)); + result.put(id, po); + } + return result; + } + } diff --git a/src/com/engine/salary/biz/SISchemeBiz.java b/src/com/engine/salary/biz/SISchemeBiz.java index 042e0da33..deca269e4 100644 --- a/src/com/engine/salary/biz/SISchemeBiz.java +++ b/src/com/engine/salary/biz/SISchemeBiz.java @@ -221,7 +221,7 @@ public class SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); - return insuranceSchemeDetailMapper.listByPrimaryId(primaryId); + return insuranceSchemeDetailMapper.queryListBySchemeId(primaryId); } finally { sqlSession.close(); @@ -344,7 +344,7 @@ public class .build(); insuranceSchemeMapper.insert(batchPO); - List detailList = insuranceSchemeDetailMapper.listByPrimaryId(batchPO.getId()); + List detailList = insuranceSchemeDetailMapper.queryListBySchemeId(batchPO.getId()); if (CollectionUtils.isNotEmpty(detailList)) { List detailPOS = detailList.stream().map(item -> InsuranceSchemeDetailPO.builder() //.id(IdGenerator.generate()) diff --git a/src/com/engine/salary/entity/siaccount/param/AccountParam.java b/src/com/engine/salary/entity/siaccount/param/AccountParam.java index 63706cfc6..9bf107ba2 100644 --- a/src/com/engine/salary/entity/siaccount/param/AccountParam.java +++ b/src/com/engine/salary/entity/siaccount/param/AccountParam.java @@ -1,6 +1,7 @@ package com.engine.salary.entity.siaccount.param; +import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -21,10 +22,12 @@ public class AccountParam { //账单月份") //@NotNull + @DataCheck(require = true,message = "账单月份不能为空") private String billMonth; //备注") //@Length(max = 60) + @DataCheck(max = 60,message = "备注长度不能超过60个字符") private String remarks; //核算人员id集合") diff --git a/src/com/engine/salary/entity/siaccount/param/DSTenantKeyThreadVar.java b/src/com/engine/salary/entity/siaccount/param/DSTenantKeyThreadVar.java new file mode 100644 index 000000000..09880dd7c --- /dev/null +++ b/src/com/engine/salary/entity/siaccount/param/DSTenantKeyThreadVar.java @@ -0,0 +1,15 @@ +package com.engine.salary.entity.siaccount.param; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/13 + * @Version V1.0 + **/ +public class DSTenantKeyThreadVar { + public static ThreadLocal tenantKey = new ThreadLocal(); + public static ThreadLocal notDesensitization = new ThreadLocal(); + + public DSTenantKeyThreadVar() { + } +} diff --git a/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java index 2f40b75cf..4fc596729 100644 --- a/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java +++ b/src/com/engine/salary/entity/siaccount/param/InsuranceAccountBatchParam.java @@ -2,6 +2,7 @@ package com.engine.salary.entity.siaccount.param; import com.engine.salary.common.BaseQueryParam; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @@ -14,6 +15,7 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor +@Builder public class InsuranceAccountBatchParam extends BaseQueryParam { //开始时间 diff --git a/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java new file mode 100644 index 000000000..f16de0271 --- /dev/null +++ b/src/com/engine/salary/entity/siarchives/po/InsuranceArchivesAccountPO.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.siarchives.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description: + * @Author: zhangheng + * @CreateDate: 2021/12/7 19:05 + * @Version: v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InsuranceArchivesAccountPO { + + private InsuranceArchivesSocialSchemePO social; + + private InsuranceArchivesFundSchemePO fund; + + private InsuranceArchivesOtherSchemePO other; +} diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java index f5be52e78..e0bf720a8 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java @@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam; import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -20,4 +21,34 @@ public interface InsuranceAccountBatchMapper { * @return */ List list(@Param("param")InsuranceAccountBatchParam queryParam); + + /** + * 根据账单月份查询单条记录 + * @param billMonth + * @return + */ + InsuranceAccountBatchPO getByBillMonth(@Param("billMonth") String billMonth); + + /** + * 插入 + * @param insuranceAccountBatchPO + */ + void insert(InsuranceAccountBatchPO insuranceAccountBatchPO); + + + List getAllByBillMonth(@Param("billMonth") String billMonth); + + /** + * 根据主键删除 + * @param id + */ + void deleteById(@Param("id") Long id); + + + /** + * 更新 + * @param pos + */ + void updateById(@Param("pos") InsuranceAccountBatchPO pos); + } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml index a20aeca6e..1c7dd297e 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml @@ -40,6 +40,46 @@ , t.tenant_key + + INSERT INTO hrsa_bill_batch + + bill_month, + bill_status, + social_num, + fund_num, + other_num, + social_pay, + fund_pay, + other_pay, + accountant, + remarks, + creator, + delete_type, + create_time, + update_time, + tenant_key, + + + #{billMonth}, + #{billStatus}, + #{socialNum}, + #{fundNum}, + #{otherNum}, + #{socialPay}, + #{fundPay}, + #{otherPay}, + #{accountant}, + #{remarks}, + #{creator}, + #{deleteType}, + #{createTime}, + #{updateTime}, + #{tenantKey}, + + + AND @@ -59,6 +99,48 @@ + + + + + + + UPDATE hrsa_bill_batch + SET delete_type = 1 + WHERE delete_type = 0 + AND id = #{id} + + + + + UPDATE hrsa_bill_batch + + accountant=#{accountant}, + update_time=#{updateTime}, + social_pay=#{socialPay}, + social_num=#{socialNum}, + fund_num=#{fundNum}, + fund_pay=#{fundPay}, + other_num=#{otherNum}, + other_pay=#{otherPay}, + + WHERE id = #{id} AND delete_type = 0 + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java index 205c8624c..dbaaf190b 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java @@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -20,4 +21,31 @@ public interface InsuranceAccountDetailMapper { * @return */ List list(@Param("param")InsuranceAccountDetailParam queryParam); + + /** + * 根据账单月份获取所有员工 + * @param billMonth + * @return + */ + List selectAccountIds(@Param("billMonth") String billMonth); + + /** + * 根据id删除 + * @param id + */ + void deleteById(@Param("id")Long id); + + /** + * 批量删除 + */ + void batchDelAccountDetails(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth); + + /** + * 批量保存 + * @param accounts + */ + void batchSaveAccountDetails(@Param("accounts") Collection accounts); + + + List selectList(@Param("billMonth") String billMonth); } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml index e32be656a..0110ca112 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml @@ -123,6 +123,210 @@ ORDER BY t.update_time DESC + + + + + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE id = #{id} + AND delete_type = 0 + + + + + + UPDATE hrsa_bill_detail + SET delete_type = 1 + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND employee_id IN + + #{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, + fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json, + fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.fundPayOrg}, + #{item.fundAccount} + #{item.supplementFundAccount} + #{item.otherPayOrg} + #{item.socialSchemeId} + #{item.socialPaymentBaseString} + #{item.fundSchemeId} + #{item.fundPaymentBaseString} + #{item.otherSchemeId} + #{item.otherPaymentBaseString} + #{item.socialPerJson} + #{item.socialPerSum} + #{item.fundPerJson} + #{item.fundPerSum} + #{item.otherPerJson} + #{item.otherPerSum} + #{item.perSum} + #{item.socialComJson} + #{item.socialComSum} + #{item.fundComJson} + #{item.fundComSum} + #{item.otherComJson} + #{item.otherComSum} + #{item.comSum} + #{item.socialSum} + #{item.fundSum} + #{item.otherSum} + #{item.total} + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + ) + + + + 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, + fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json, + fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key) + + + select + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.fundPayOrg}, + #{item.fundAccount} + #{item.supplementFundAccount} + #{item.otherPayOrg} + #{item.socialSchemeId} + #{item.socialPaymentBaseString} + #{item.fundSchemeId} + #{item.fundPaymentBaseString} + #{item.otherSchemeId} + #{item.otherPaymentBaseString} + #{item.socialPerJson} + #{item.socialPerSum} + #{item.fundPerJson} + #{item.fundPerSum} + #{item.otherPerJson} + #{item.otherPerSum} + #{item.perSum} + #{item.socialComJson} + #{item.socialComSum} + #{item.fundComJson} + #{item.fundComSum} + #{item.otherComJson} + #{item.otherComSum} + #{item.comSum} + #{item.socialSum} + #{item.fundSum} + #{item.otherSum} + #{item.total} + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + from dual + + + + 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, + fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json, + fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.fundPayOrg}, + #{item.fundAccount} + #{item.supplementFundAccount} + #{item.otherPayOrg} + #{item.socialSchemeId} + #{item.socialPaymentBaseString} + #{item.fundSchemeId} + #{item.fundPaymentBaseString} + #{item.otherSchemeId} + #{item.otherPaymentBaseString} + #{item.socialPerJson} + #{item.socialPerSum} + #{item.fundPerJson} + #{item.fundPerSum} + #{item.otherPerJson} + #{item.otherPerSum} + #{item.perSum} + #{item.socialComJson} + #{item.socialComSum} + #{item.fundComJson} + #{item.fundComSum} + #{item.otherComJson} + #{item.otherComSum} + #{item.comSum} + #{item.socialSum} + #{item.fundSum} + #{item.otherSum} + #{item.total} + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + ) + + diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java new file mode 100644 index 000000000..c358e4617 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.java @@ -0,0 +1,28 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/14 + * @Version V1.0 + **/ +public interface InsuranceAccountInspectMapper { + + /** + * 批量删除 + * @param pos + */ + void batchDelInspectDetails(@Param("pos") Collection pos); + + /** + * 批量保存 + * @param pos + */ + void batchSaveInspectDetails(@Param("pos") Collection pos); + +} diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml new file mode 100644 index 000000000..5e7499a00 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountInspectMapper.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.bill_month + , t.payment_status + , t.inspect_status + , t.supplementary_month + , t.supplementary_projects + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + + + + + + UPDATE hrsa_bill_inspect + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{po.id} + + + + + + INSERT INTO hrsa_bill_inspect + (employee_id,bill_month,payment_status,inspect_status,supplementary_month, + supplementary_projects,creator,delete_type,create_time,update_time.tenant_key) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.paymentStatus}, + #{item.inspectStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_bill_inspect + (employee_id,bill_month,payment_status,inspect_status,supplementary_month, + supplementary_projects,creator,delete_type,create_time,update_time.tenant_key) + + + select + #{item.employeeId}, + #{item.billMonth}, + #{item.paymentStatus}, + #{item.inspectStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + from dual + + + + INSERT INTO hrsa_bill_inspect + (employee_id,bill_month,payment_status,inspect_status,supplementary_month, + supplementary_projects,creator,delete_type,create_time,update_time.tenant_key) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.paymentStatus}, + #{item.inspectStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + ) + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.java b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.java new file mode 100644 index 000000000..0312219e8 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.java @@ -0,0 +1,38 @@ +package com.engine.salary.mapper.siaccount; + +import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailTempPO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/13 + * @Version V1.0 + **/ +public interface SIAccountDetailTempMapper { + + /** + * 批量删除 + * @param employeeIds + * @param billMonth + */ + void batchDelAccountTempDetails(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth); + + /** + * 批量保存 + * @param accounts + */ + void batchSaveAccountTempDetails(@Param("accounts") Collection accounts); + + + /** + * 获取 + * @param employeeIds + * @param billMonth + * @return + */ + List getListByEmployeeIdsAndBillMonth(@Param("employeeIds") Collection employeeIds, @Param("billMonth") String billMonth); +} diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml new file mode 100644 index 000000000..02862dca8 --- /dev/null +++ b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml @@ -0,0 +1,292 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t.id + , t.employee_id + , t.bill_month + , t.bill_status + , t.payment_status + , t.supplementary_month + , t.supplementary_projects + , t.resource_from + , t.social_pay_org + , t.social_account + , t.fund_pay_org + , t.fund_account + , t.supplement_fund_account + , t.other_pay_org + , t.social_scheme_id + , t.social_payment_base_string + , t.fund_scheme_id + , t.fund_payment_base_string + , t.other_scheme_id + , t.other_payment_base_string + , t.social_per_json + , t.social_per_sum + , t.fund_per_json + , t.fund_per_sum + , t.other_per_json + , t.other_per_sum + , t.per_sum + , t.social_com_json + , t.social_com_sum + , t.fund_com_json + , t.fund_com_sum + , t.other_com_json + , t.other_com_sum + , t.com_sum + , t.social_sum + , t.fund_sum + , t.other_sum + , t.total + , t.creator + , t.delete_type + , t.create_time + , t.update_time + , t.tenant_key + + + + + + + + UPDATE hrsa_bill_detail_temp + SET delete_type = 1 + WHERE delete_type = 0 + AND bill_month = #{billMonth} + AND employee_id IN + + #{employeeId} + + + + + + INSERT INTO hrsa_bill_detail_temp + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org, + fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json, + fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.fundPayOrg}, + #{item.fundAccount} + #{item.supplementFundAccount} + #{item.otherPayOrg} + #{item.socialSchemeId} + #{item.socialPaymentBaseString} + #{item.fundSchemeId} + #{item.fundPaymentBaseString} + #{item.otherSchemeId} + #{item.otherPaymentBaseString} + #{item.socialPerJson} + #{item.socialPerSum} + #{item.fundPerJson} + #{item.fundPerSum} + #{item.otherPerJson} + #{item.otherPerSum} + #{item.perSum} + #{item.socialComJson} + #{item.socialComSum} + #{item.fundComJson} + #{item.fundComSum} + #{item.otherComJson} + #{item.otherComSum} + #{item.comSum} + #{item.socialSum} + #{item.fundSum} + #{item.otherSum} + #{item.total} + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + ) + + + + INSERT INTO hrsa_bill_detail_temp + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org, + fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json, + fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key) + + + select + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.fundPayOrg}, + #{item.fundAccount} + #{item.supplementFundAccount} + #{item.otherPayOrg} + #{item.socialSchemeId} + #{item.socialPaymentBaseString} + #{item.fundSchemeId} + #{item.fundPaymentBaseString} + #{item.otherSchemeId} + #{item.otherPaymentBaseString} + #{item.socialPerJson} + #{item.socialPerSum} + #{item.fundPerJson} + #{item.fundPerSum} + #{item.otherPerJson} + #{item.otherPerSum} + #{item.perSum} + #{item.socialComJson} + #{item.socialComSum} + #{item.fundComJson} + #{item.fundComSum} + #{item.otherComJson} + #{item.otherComSum} + #{item.comSum} + #{item.socialSum} + #{item.fundSum} + #{item.otherSum} + #{item.total} + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + from dual + + + + INSERT INTO hrsa_bill_detail_temp + (employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org, + fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json, + social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json, + fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key) + VALUES + + ( + #{item.employeeId}, + #{item.billMonth}, + #{item.billStatus}, + #{item.paymentStatus}, + #{item.supplementaryMonth}, + #{item.supplementaryProjects}, + #{item.resourceFrom}, + #{item.socialPayOrg}, + #{item.socialAccount}, + #{item.fundPayOrg}, + #{item.fundAccount} + #{item.supplementFundAccount} + #{item.otherPayOrg} + #{item.socialSchemeId} + #{item.socialPaymentBaseString} + #{item.fundSchemeId} + #{item.fundPaymentBaseString} + #{item.otherSchemeId} + #{item.otherPaymentBaseString} + #{item.socialPerJson} + #{item.socialPerSum} + #{item.fundPerJson} + #{item.fundPerSum} + #{item.otherPerJson} + #{item.otherPerSum} + #{item.perSum} + #{item.socialComJson} + #{item.socialComSum} + #{item.fundComJson} + #{item.fundComSum} + #{item.otherComJson} + #{item.otherComSum} + #{item.comSum} + #{item.socialSum} + #{item.fundSum} + #{item.otherSum} + #{item.total} + #{item.creator} + #{item.deleteType} + #{item.createTime} + #{item.updateTime} + #{item.tenantKey} + ) + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java index 0c7d85184..61bdbbef0 100644 --- a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java @@ -19,7 +19,7 @@ public interface InsuranceSchemeDetailMapper { * * @return list */ - List listByPrimaryId(Long primaryId); + List queryListBySchemeId(Long schemeId); /** * 新增,插入所有字段 diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java index 3bee638f3..ff49885dc 100644 --- a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeMapper.java @@ -42,6 +42,7 @@ public interface InsuranceSchemeMapper { */ List listByName(String schemeName); + /** * 查询所有 * @return diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java index a968773fb..4c6a086ed 100644 --- a/src/com/engine/salary/service/SIAccountService.java +++ b/src/com/engine/salary/service/SIAccountService.java @@ -1,5 +1,6 @@ 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; @@ -12,6 +13,7 @@ import java.util.Map; * @Version V1.0 **/ public interface SIAccountService { + Map listPage(InsuranceAccountBatchParam insuranceAccountBatchParam); Map listCommonPage(InsuranceAccountDetailParam insuranceAccountDetailParam); @@ -24,5 +26,6 @@ public interface SIAccountService { Map getForm(Map params); + Map save(AccountParam param); } diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index b4f3e9a18..a2aa2c007 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -2,10 +2,7 @@ package com.engine.salary.service.impl; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; -import com.api.browser.util.ConditionFactory; import com.cloudstore.eccom.pc.table.WeaTableColumn; -import com.cloudstore.eccom.pc.table.WeaTableOperate; -import com.cloudstore.eccom.pc.table.WeaTableOperates; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; @@ -16,6 +13,7 @@ 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; @@ -24,6 +22,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.enums.siaccount.BillStatusEnum; 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.service.ColumnBuildService; import com.engine.salary.service.RecordsBuildService; @@ -33,8 +32,10 @@ import java.util.*; import java.util.stream.Collectors; import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryFormItemUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.valid.ValidUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import weaver.hrm.User; @@ -216,47 +217,61 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public Map getForm(Map params) { - ConditionFactory conditionFactory = new ConditionFactory(user); + Map apidatas = new HashMap<>(); //条件组 List addGroups = new ArrayList<>(); List conditionItems = new ArrayList<>(); + SearchConditionItem datePickerItem = SalaryFormItemUtil.datePickerItem(user, 2, 16, true, 1, "账单月份", "billMonth"); + String minDate = SalaryDateUtil.getYearMonth(-1, 0); + String maxDate = SalaryDateUtil.getYearMonth(0, 6); + datePickerItem.getOtherParams().put("minDate",minDate); + datePickerItem.getOtherParams().put("maxDate",maxDate); + InsuranceAccountBatchParam queryParam = InsuranceAccountBatchParam.builder().startTime(minDate).endTime(maxDate).build(); -// -// WeaForm weaForm = new WeaForm(); -// WeaFormItem weaFormItem = new WeaFormItem(WeaFormItemType.DATEPICKER); -// weaFormItem.setRequired(true); -// String minDate = SalaryDateUtil.getYearMonth(-1, 0); -// String maxDate = SalaryDateUtil.getYearMonth(0, 6); -// weaFormItem.getOtherParams().put("minDate", minDate); -// weaFormItem.getOtherParams().put("maxDate", maxDate); -// List billMonthList = siAccountService.listByTimeRange(minDate, maxDate, tenantKey); -// if (CollectionUtils.isEmpty(billMonthList)) { -// weaFormItem.getOtherParams().put("disabledData", Collections.emptyList()); -// } else { -// weaFormItem.getOtherParams().put("disabledData", billMonthList.stream().map(InsuranceAccountBatchPO::getBillMonth).collect(Collectors.toList())); -// } -// weaFormItem.getOtherParams().put("type", "month"); -// weaFormItem.getOtherParams().put("format", "YYYY-MM"); -// weaFormItem.getOtherParams().put("showFormat", "YYYY-MM"); -// weaForm.getItems().put("billMonth", weaFormItem); -// -// -// -// -// WeaFormItem remarksItem = new WeaFormItem(WeaFormItemType.TEXTAREA); -// remarksItem.setMaxLength("60"); -// weaForm.getItems().put("remarks", remarksItem); -// List one = new ArrayList<>(); -// one.add(new WeaFormLayout("billMonth", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 92146, "账单月份"), new String[]{"billMonth"})); -// List two = new ArrayList<>(); -// two.add(new WeaFormLayout("remarks", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 84961, "备注"), new String[]{"remarks"})); -// weaForm.getLayout().add(one); -// weaForm.getLayout().add(two); -// Map data = new HashMap<>(); -// data.put("billMonth", SalaryDateUtil.getYearMonth(0, 0)); -// weaForm.setData(data); - return null; + List billMonthList = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).list(queryParam); + if (CollectionUtils.isEmpty(billMonthList)) { + datePickerItem.getOtherParams().put("disabledData", Collections.emptyList()); + } else { + datePickerItem.getOtherParams().put("disabledData", billMonthList.stream().map(InsuranceAccountBatchPO::getBillMonth).collect(Collectors.toList())); + } + datePickerItem.getOtherParams().put("type", "month"); + datePickerItem.getOtherParams().put("format", "YYYY-MM"); + datePickerItem.getOtherParams().put("showFormat", "YYYY-MM"); + conditionItems.add(datePickerItem); + + SearchConditionItem textareaItem = SalaryFormItemUtil.textareaItem(user, 2, 16, true, 1, 60, "备注", "remarks"); + conditionItems.add(textareaItem); + addGroups.add(new SearchConditionGroup("常用条件",true,conditionItems)); + + apidatas.put("billMonth", SalaryDateUtil.getYearMonth(0, 0)); + + apidatas.put("condition",addGroups); + + return apidatas; + } + + /** + * 保存月份和备注信息并进入核算 + * + * @param param 请求入参 + *

+ * 接口逻辑: + * 1、检查当前月份是否已经归档,如果已经归档直接返回,状态为未归档继续执行 + * 2、从基础人员表左连接部门和离职表以及档案表,查询出来符合缴纳的人员清单 + * (1)离职日期在当月一号零时之后 + * (2)档案中配置了福利缴纳开始缴纳月,开始时间包含当前月 + * 3、forkjoin核算并入库 + * 4、更新台账 + */ + @Override + public Map save(AccountParam param) { + Map apidatas = new HashMap<>(); + Long employeeId = (long)user.getUID(); + String lastname = user.getLastname(); + ValidUtil.doValidator(param); + siAccountBiz.save(true,param,employeeId,lastname); + return apidatas; } diff --git a/src/com/engine/salary/util/SalaryEntityUtil.java b/src/com/engine/salary/util/SalaryEntityUtil.java index fdd7581c7..f02cfadbb 100644 --- a/src/com/engine/salary/util/SalaryEntityUtil.java +++ b/src/com/engine/salary/util/SalaryEntityUtil.java @@ -7,6 +7,7 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.Collection; import java.util.List; @@ -172,4 +173,20 @@ public class SalaryEntityUtil { return BigDecimal.ZERO; } } + + + + public static BigDecimal carryRule(Integer newScale, Integer rententionRule, BigDecimal value) { + if (BigDecimal.ROUND_UNNECESSARY == rententionRule) { + String tempValue = value.toPlainString().concat("000"); + int i = tempValue.indexOf("."); + String s = String.valueOf(tempValue.charAt(i + newScale + 1)); + if ("0".equals(s)) { + return value.setScale(newScale, RoundingMode.DOWN); + } else { + return value.setScale(newScale, RoundingMode.UP); + } + } + return value.setScale(newScale, rententionRule); + } } diff --git a/src/com/engine/salary/util/SalaryFormItemUtil.java b/src/com/engine/salary/util/SalaryFormItemUtil.java index 6a124c7f9..aab1687f1 100644 --- a/src/com/engine/salary/util/SalaryFormItemUtil.java +++ b/src/com/engine/salary/util/SalaryFormItemUtil.java @@ -166,6 +166,7 @@ public class SalaryFormItemUtil { return textarea; } + /** * 日期 * @param user @@ -192,4 +193,6 @@ public class SalaryFormItemUtil { + + } diff --git a/src/com/engine/salary/web/SIAccountController.java b/src/com/engine/salary/web/SIAccountController.java index 4e3f8a026..6ae03e1b6 100644 --- a/src/com/engine/salary/web/SIAccountController.java +++ b/src/com/engine/salary/web/SIAccountController.java @@ -2,14 +2,15 @@ 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.service.SIAccountService; import com.engine.salary.service.impl.SIAccountServiceImpl; import com.engine.salary.util.ResponseResult; import io.swagger.v3.oas.annotations.parameters.RequestBody; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; +import com.engine.salary.service.SIAccountService; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -124,6 +125,23 @@ public class SIAccountController { } + /** + * 保存并进入核算 + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + 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); + } + +