From 29e5c27ffb15d6072c37cea9eff14f5fed8b5255 Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 17 Jan 2024 16:07:27 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E5=8F=B0=E8=B4=A6=EF=BC=8C=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=A0=B8=E7=AE=97=E5=B9=B6=E5=BD=92=E6=A1=A3=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=B1=BB=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/siaccount/param/AccountParam.java | 3 + .../salary/service/SIAccountService.java | 7 + .../service/impl/SIAccountServiceImpl.java | 1139 ++++++++++++++++- .../salary/timer/AutoSiAccountAndFileJob.java | 107 ++ 4 files changed, 1223 insertions(+), 33 deletions(-) create mode 100644 src/com/engine/salary/timer/AutoSiAccountAndFileJob.java diff --git a/src/com/engine/salary/entity/siaccount/param/AccountParam.java b/src/com/engine/salary/entity/siaccount/param/AccountParam.java index ceff087e9..34e11c6e5 100644 --- a/src/com/engine/salary/entity/siaccount/param/AccountParam.java +++ b/src/com/engine/salary/entity/siaccount/param/AccountParam.java @@ -42,4 +42,7 @@ public class AccountParam { @DataCheck(require = true,message = "个税扣缴义务人不能为空") private Long paymentOrganization; + // 是否核算后归档 + private boolean fileFlag = false; + } diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java index 99c157855..60d06ed86 100644 --- a/src/com/engine/salary/service/SIAccountService.java +++ b/src/com/engine/salary/service/SIAccountService.java @@ -84,6 +84,13 @@ public interface SIAccountService { */ String save(AccountParam param); + /** + * 新建核算并归档 + * @param param + * @return + */ + String saveAndFile(AccountParam param); + /** * 正常缴纳页核算 * @param saveCommonAccountParam diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index cbed96243..6bb0fd1f2 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -1,6 +1,7 @@ package com.engine.salary.service.impl; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; @@ -10,24 +11,20 @@ import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.*; +import com.engine.salary.cache.SalaryCacheKey; import com.engine.salary.component.SalaryWeaTable; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.progress.ProgressDTO; import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO; import com.engine.salary.entity.siaccount.param.*; -import com.engine.salary.entity.siaccount.po.ExcelInsuranceDetailPO; -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.entity.siarchives.po.InsuranceArchivesBaseInfoPO; -import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; -import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; -import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; +import com.engine.salary.entity.siaccount.po.*; +import com.engine.salary.entity.siarchives.po.*; import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.entity.siexport.param.InsuranceExportParam; import com.engine.salary.entity.siexport.po.AccountExportPO; @@ -40,12 +37,10 @@ import com.engine.salary.enums.siaccount.*; import com.engine.salary.enums.sicategory.*; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.InsuranceExportMapper; -import com.engine.salary.mapper.siaccount.ExcelInsuranceDetailMapper; -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.*; import com.engine.salary.mapper.siarchives.FundSchemeMapper; import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; +import com.engine.salary.mapper.siarchives.OtherSchemeMapper; import com.engine.salary.mapper.siarchives.SocialSchemeMapper; import com.engine.salary.mapper.sicategory.ICategoryMapper; import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; @@ -53,14 +48,13 @@ import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.mapper.taxagent.TaxAgentMapper; import com.engine.salary.service.*; +import com.engine.salary.sys.constant.SalarySysConstant; import com.engine.salary.sys.entity.po.SalarySysConfPO; import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.SalaryAcctEmployeeRuleEnum; import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; -import com.engine.salary.util.SalaryDateUtil; -import com.engine.salary.util.SalaryEntityUtil; -import com.engine.salary.util.SalaryFormItemUtil; -import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.*; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelParseHelper; import com.engine.salary.util.excel.ExcelSupport; @@ -73,13 +67,16 @@ import com.engine.salary.util.valid.ValidUtil; import com.engine.salary.wrapper.SalaryFormulaWrapper; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.mzlion.core.utils.BeanUtils; import dm.jdbc.util.IdGenerator; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; import weaver.file.ImageFileManager; import weaver.general.Util; import weaver.hrm.User; @@ -89,6 +86,7 @@ import java.math.BigDecimal; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -102,6 +100,7 @@ import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; * @Date 2022/4/11 * @Version V1.0 **/ +@Slf4j public class SIAccountServiceImpl extends Service implements SIAccountService { // private SIAccountBiz siAccountBiz = new SIAccountBiz(); @@ -180,6 +179,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return MapperProxyFactory.getProxy(FundSchemeMapper.class); } + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + private TaxAgentBiz taxAgentBiz = new TaxAgentBiz(); private ICategoryMapper getICategoryMapper() { @@ -210,6 +213,18 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return (SIBalanceService) ServiceUtil.getService(SIBalanceServiceImpl.class, user); } + private ProgressService getSalaryAcctProgressService(User user) { + return ServiceUtil.getService(ProgressServiceImpl.class, user); + } + + private SIAccountDetailTempMapper getSIAccountDetailTempMapper() { + return MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class); + } + + private InsuranceCompensationMapper getInsuranceCompensationMapper() { + return MapperProxyFactory.getProxy(InsuranceCompensationMapper.class); + } + @Override public Map listPage(InsuranceAccountBatchParam queryParam) { Long employeeId = (long) user.getUID(); @@ -563,20 +578,22 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public String save(AccountParam param) { - ValidUtil.doValidator(param); - - Long employeeId = (long) user.getUID(); - String lastName = user.getLastname(); - return getSiAccountBiz(user).save(param.isFlag(), param, employeeId, lastName); +// ValidUtil.doValidator(param); +// +// Long employeeId = (long) user.getUID(); +// String lastName = user.getLastname(); +// return getSiAccountBiz(user).save(param.isFlag(), param, employeeId, lastName); + return saveAndFile(param); } @Override public void commonAccount(SaveCommonAccountParam param) { - ValidUtil.doValidator(param); - - Long employeeId = (long) user.getUID(); - String currentUserName = user.getLastname(); - getSiAccountBiz(user).saveCommonAccount(param, employeeId, currentUserName); +// ValidUtil.doValidator(param); +// +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).saveCommonAccount(param, employeeId, currentUserName); + siSaveCommonAccount(param); } @Override @@ -587,9 +604,31 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public void saveCommonAccount(SaveCommonAccountParam accountParam) { - Long employeeId = (long) user.getUID(); - String currentUserName = user.getLastname(); - getSiAccountBiz(user).saveCommonAccount(accountParam, employeeId, currentUserName); +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).saveCommonAccount(accountParam, employeeId, currentUserName); + siSaveCommonAccount(accountParam); + } + + /** + * 福利台账正常缴纳页-核算 + */ + public void siSaveCommonAccount(SaveCommonAccountParam param) { + ValidUtil.doValidator(param); + + 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); + siAccounting(accountParam); } @Override @@ -618,9 +657,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public void file(AccountParam accountParam) { - Long employeeId = (long) user.getUID(); - String billMonth = accountParam.getBillMonth(); - getSiAccountBiz(user).file(billMonth, employeeId, accountParam.getPaymentOrganization()); +// Long employeeId = (long) user.getUID(); +// String billMonth = accountParam.getBillMonth(); +// getSiAccountBiz(user).file(billMonth, employeeId, accountParam.getPaymentOrganization()); + siFile(accountParam.getBillMonth(), accountParam.getPaymentOrganization()); } @Override @@ -4279,4 +4319,1037 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); return insuranceAccountDetailPO; } + + /** + * 新建核算并归档 + * @param param + * @return + */ + @Override + public String saveAndFile(AccountParam param) { + ValidUtil.doValidator(param); + if (param.isFlag()) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + insuranceAccountBatchPO = encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.isNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(0, "所属月份存在核算数据")); + + InsuranceAccountBatchPO build = InsuranceAccountBatchPO.builder() + .paymentOrganization(param.getPaymentOrganization()) + .accountant(user.getLastname()) + .billMonth(param.getBillMonth()) + .billStatus(BillStatusEnum.NOT_ARCHIVED.getValue()) + .remarks(param.getRemarks()) + .creator((long) user.getUID()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .createTime(new Date()) + .updateTime(new Date()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .paymentOrganization(param.getPaymentOrganization()) + .socialPay("0") + .fundPay("0") + .otherPay("0") + .build(); + encryptUtil.encrypt(build, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().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); + } + try { + List employeeIds = getInsuranceAccountDetailMapper().selectEmpByPaymentOrg(param.getPaymentOrganization()); + if (CollectionUtils.isEmpty(employeeIds)) { + List list = Lists.newArrayList(getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); + encryptUtil.decryptList(list, InsuranceAccountDetailPO.class); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountDetailMapper().deleteById(f.getId()); + }); + } + } + SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(0, "没有需要核算的人员")); +// AccountParam selectParam = new AccountParam(); +// selectParam.setBillMonth(param.getBillMonth()); +// selectParam.setPaymentOrganization(param.getPaymentOrganization()); + ExecutorService taskExecutor = Executors.newCachedThreadPool(); + taskExecutor.execute(() -> { + siAccounting(param); + if (param.isFileFlag()) { + siFile(param.getBillMonth(), param.getPaymentOrganization()); + } + }); + } catch (Exception e) { + // 回滚 + List list = Lists.newArrayList(getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); + list = encryptUtil.decryptList(list, InsuranceAccountBatchPO.class); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountBatchMapper().deleteById(f.getId()); + }); + } + throw new SalaryRunTimeException(e.getMessage()); + } + return String.valueOf(user.getUID()); + } + + + public void siAccounting(AccountParam param) { + //福利核算进度 + ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth()); + if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.isStatus() && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) { + return; + } + + log.info("开始核算,当前操作人为:{}", user.getLastname()); + log.info("核算时间:{}, 核算月份:{}, 个税扣缴义务人:{}, 是否首次核算:{}", new Date(), param.getBillMonth(), param.getPaymentOrganization(), param.isFlag()); + try { + List ids; + List validIds = new ArrayList<>(); + if (CollectionUtils.isEmpty(param.getIds())) { + List empIds = getInsuranceAccountDetailMapper().selectEmpByPaymentOrg(param.getPaymentOrganization()); + // 获取薪资核算人员规则 + SalarySysConfPO salaryAcctEmployeeRule = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ACCT_EMPLOYEE_RULE); + List status = new ArrayList<>(); + if(Objects.isNull(salaryAcctEmployeeRule) || StringUtils.equals(salaryAcctEmployeeRule.getConfValue(), SalaryAcctEmployeeRuleEnum.BYPAYENDTIME.getValue()) ){ + // 包含停缴 + status = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(),EmployeeStatusEnum.STAY_DEL.getValue(), + EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()); + }else{ + status = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(),EmployeeStatusEnum.STAY_DEL.getValue()); + } + List finalStatus = status; + //过滤出需要核算的人员,即福利档案基础信息表中runStatus为正在缴纳和待减员的人员 + List baseInfoPOList = getInsuranceBaseInfoMapper().listAll(); + List canAccountIds = baseInfoPOList.stream() + .filter(f->f.getPaymentOrganization().equals(param.getPaymentOrganization()) + && (finalStatus.contains(f.getRunStatus()) )) + .map(InsuranceArchivesBaseInfoPO::getEmployeeId) + .collect(Collectors.toList()); + + //20231122逻辑优化,过滤出不在起始缴纳月和最后缴纳月区间的人员 + List empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth()); + empIds = empIds.stream().filter(f->canAccountIds.contains(f) && empIdsInPayMonthRange.contains(f)).collect(Collectors.toList()); + + List socials = siArchivesBiz.getSocialByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + socials = socials.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp1 = socials.stream() + .filter(s -> !(StringUtils.isBlank(s.getSocialEndTime()) && StringUtils.isBlank(s.getSocialStartTime())) && + (StringUtils.isBlank(s.getSocialEndTime()) || (SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01")))) ) + .map(InsuranceArchivesSocialSchemePO::getEmployeeId) + .collect(Collectors.toList()); + + List funds = siArchivesBiz.getFundByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + funds = funds.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp2 = funds.stream() + .filter(s -> !(StringUtils.isBlank(s.getFundStartTime()) && StringUtils.isBlank(s.getFundEndTime())) && + (StringUtils.isBlank(s.getFundEndTime()) || (SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01"))))) + .map(InsuranceArchivesFundSchemePO::getEmployeeId) + .collect(Collectors.toList()); + + List others = siArchivesBiz.getOtherByEmployeeIds(empIds); + //过滤出目标个税扣缴义务人相关信息 + others = others.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); + List emp3 = others.stream() + .filter(s -> !(StringUtils.isBlank(s.getOtherStartTime()) && StringUtils.isBlank(s.getOtherEndTime())) && + (StringUtils.isBlank(s.getOtherEndTime()) || (SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01"))))) + .map(InsuranceArchivesOtherSchemePO::getEmployeeId) + .collect(Collectors.toList()); + validIds.addAll(emp1); + validIds.addAll(emp2); + validIds.addAll(emp3); + + List finalValidIds = validIds.stream().distinct().collect(Collectors.toList()); + ids = empIds.stream().filter(finalValidIds::contains).collect(Collectors.toList()); + } else { + ids = param.getIds(); + } + + // 初始化进度 + ProgressDTO initProgress = new ProgressDTO() + .setTitle(SalaryI18nUtil.getI18nLabel(0, "核算中")) + .setTitleLabelId(97515L) + .setTotalQuantity(ids.size()) + .setCalculatedQuantity(NumberUtils.INTEGER_ZERO) + .setProgress(BigDecimal.ZERO) + .setStatus(true) + .setMessage(StringUtils.EMPTY); + getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), initProgress); + + if (CollectionUtils.isEmpty(ids)) { + getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), true); + return; + } + + log.info("开始生成福利核算数据,待处理人员数量:{}", ids.size()); + siCommonAccount(param.getBillMonth(), ids, param.getPaymentOrganization()); + log.info("福利核算数据生成完毕,开始数据处理"); + + handleData(ids, param); + log.info("福利核算数据处理完毕!"); + + List> partition = Lists.partition((List) ids, 100); + partition.forEach(part -> { + getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, param.getBillMonth(), param.getPaymentOrganization()); + }); + log.info("更新福利核算进度······"); + getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), true); + log.info("福利核算进度完成!"); + } catch (Exception e) { + log.error("account run fail", e); + getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), SalaryI18nUtil.getI18nLabel(0, "福利核算出错") + ": " + e.getMessage()); + + List list = Lists.newArrayList(getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization())); + if (CollectionUtils.isNotEmpty(list)) { + list.stream().forEach(f -> { + getInsuranceAccountBatchMapper().deleteById(f.getId()); + }); + } + + } + + } + + public void siCommonAccount(String billMonth, List ids, Long paymentOrganization) { + SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, paymentOrganization); + 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((long) user.getUID()); + insuranceAccountDetailPO.setCreateTime(new Date()); + insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + insuranceAccountDetailPO.setEmployeeId(k); + insuranceAccountDetailPO.setUpdateTime(new Date()); + insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); + insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue()); + insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization); + + //核算社保 + accountSocial(insuranceAccountDetailPO, v, billMonth); + //核算公积金 + accountFund(insuranceAccountDetailPO, v, billMonth); + //核算其他福利 + accountOther(insuranceAccountDetailPO, v, billMonth); + //计算合计 + account(insuranceAccountDetailPO); + //临时表PO + InsuranceAccountDetailTempPO insuranceAccountDetailTempPO = new InsuranceAccountDetailTempPO(); + BeanUtils.copyProperties(insuranceAccountDetailPO, insuranceAccountDetailTempPO); + list.add(insuranceAccountDetailTempPO); + count++; + + if (count % 50 == 0 || count >= ids.size()) { + if (count >= ids.size()) { + getSalaryAcctProgressService(user).updateProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth, BigDecimal.valueOf(0.99), false); + log.info("更新福利核算进度,当前进度为:{}", getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth)); + } else { + getSalaryAcctProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.ACCT_PROGRESS + billMonth, count >= ids.size() ? count % 50 : 50); + log.info("更新福利核算进度,当前进度为:{}", getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth)); + } + + } + + } + //临时表入库前先对(可能存在的)历史数据进行删除 + List> partition = Lists.partition((List) ids, 100); + partition.forEach(part -> { + getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, billMonth, paymentOrganization); + }); + //临时表数据入库 + if (CollectionUtils.isNotEmpty(list)) { + encryptUtil.encryptList(list, InsuranceAccountDetailTempPO.class); + List> lists = splitList(list, 40); + lists.forEach(subList -> { + getSIAccountDetailTempMapper().batchSaveAccountTempDetails(subList); + }); + } + + } + + public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + if (accountPO.getOther() != null) { + InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther(); + insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization()); + insuranceAccountDetailPO.setOtherSchemeId(otherPO.getOtherSchemeId()); + insuranceAccountDetailPO.setOtherPaymentBaseString(otherPO.getOtherPaymentBaseString()); + insuranceAccountDetailPO.setOtherPaymentComBaseString(otherPO.getOtherPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), otherPO.getOtherStartTime(), otherPO.getOtherEndTime()); + if ((Objects.equals(NonPaymentEnum.YES.getValue(), otherPO.getNonPayment()) || otherPO.getNonPayment() == null) && otherPO.getOtherSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(otherPO.getOtherSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳其他的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map otherPerson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + //需要核算其他的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (otherPerson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(otherPerson.size() > 0) { + otherPerson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(otherPerson, billMonth, otherPO.getOtherStartTime()); + + 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((ObjectUtils.isEmpty(archivesPerson) || 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 = new BigDecimal("0"); + if (po.getPaymentCycle() != null && po.getPaymentCycle() == 1) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + 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()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(otherPO.getOtherPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap().getClass()); + } + //需要核算其他的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (otherCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(otherCom.size() > 0) { + otherCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(otherCom, billMonth, otherPO.getOtherStartTime()); + + List otherComList = new ArrayList<>(); + Map otherComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + 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((ObjectUtils.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.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 = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + 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 billMonth) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + 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()); + insuranceAccountDetailPO.setFundPaymentComBaseString(fundPO.getFundPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), fundPO.getFundStartTime(), fundPO.getFundEndTime()); + if ((NonPaymentEnum.YES.getValue().equals(fundPO.getNonPayment()) || fundPO.getNonPayment() == null) && fundPO.getFundSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(fundPO.getFundSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map fundperson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + //需要核算公积金的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (fundperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(fundperson.size() > 0) { + fundperson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(fundperson, billMonth, fundPO.getFundStartTime()); + + 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((ObjectUtils.isEmpty(archivesPerson) || 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 = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + 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 -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(fundPO.getFundPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap().getClass()); + } + //需要核算公积金的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (fundCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(fundCom.size() > 0) { + fundCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(fundCom, billMonth, fundPO.getFundStartTime()); + + List fundComList = new ArrayList<>(); + Map fundComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + 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((ObjectUtils.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.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 = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + 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 billMonth) { + boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + if (accountPO.getSocial() != null) { + InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial(); + insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization()); + insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount()); + insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setSocialPaymentComBaseString(socialPO.getSocialPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), socialPO.getSocialStartTime(), socialPO.getSocialEndTime()); + if ((NonPaymentEnum.YES.getValue().equals(socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map schemeperson = detailPOS.stream() + .filter(item -> + Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && + Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))) + ) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + archivesPerson.forEach((id, value) -> { + if (schemeperson.containsKey(Long.valueOf(id))) { + needArchivesPerson.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(schemeperson.size() > 0) { + schemeperson.forEach((id, object) -> { + if (!needArchivesPerson.contains(id)) { + needArchivesPerson.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime()); + + List socialPer = new ArrayList<>(); + Map socialPerJsonMap = new HashMap<>(); + needArchivesPerson.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((ObjectUtils.isEmpty(archivesPerson) || 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 = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + 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 -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = new HashMap<>(); + if (welBaseDiffSign) { + archivesCom = JSON.parseObject(socialPO.getSocialPaymentComBaseString(), new HashMap().getClass()); + } else { + archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + } + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + archivesCom.forEach((id, value) -> { + if (schemeCom.containsKey(Long.valueOf(id))) { + needArchivesCom.add(Long.valueOf(id)); + } + }); + } + //避免福利档案的方案未设置基数,导致核算时遗漏这些福利项的核算,遍历下方案相关福利项,并将遗漏的福利项id添加 + if(schemeCom.size() > 0) { + schemeCom.forEach((id, object) -> { + if (!needArchivesCom.contains(id)) { + needArchivesCom.add(id); + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime()); + + List socialCom = new ArrayList<>(); + Map sociaComJsonMap = new HashMap<>(); + HashMap finalArchivesCom = archivesCom; + 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((ObjectUtils.isEmpty(finalArchivesCom) || StringUtils.isBlank(finalArchivesCom.get(String.valueOf(e)))) ? "0" : finalArchivesCom.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 = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + 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; + } + + /** + * 对于核算月和福利起始缴纳月处于同年时,要避免根据周期缴纳福利费用时,可能出现的多余费用缴纳情况 + * @param schemeDetail 福利方案明细 + * @param billMonth 核算月 + * @param startMonth 福利起始缴纳月 + * @return + */ + public Map checkCycleSettingWithStartMonth(Map schemeDetail, String billMonth, String startMonth) { + String billYear = billMonth.substring(0,4); + if (StringUtils.isNotBlank(startMonth) && billYear.equals(startMonth.substring(0,4))) { + int startMonthIndex = Integer.parseInt(startMonth.split("-")[1]) - 1; + schemeDetail.forEach((k, v) -> { + if (v.getPaymentCycle() != null && v.getPaymentCycle().equals(1) && startMonthIndex != 0) { + StringBuilder newCycleSetting = new StringBuilder(v.getCycleSetting()); + newCycleSetting.setCharAt(startMonthIndex - 1, '1'); + v.setCycleSetting(newCycleSetting.toString()); + } + }); + + } + return schemeDetail; + } + + private List> splitList(List list, int groupSize) { + int length = list.size(); + // 计算可以分成多少组 + int num = (length + groupSize - 1) / groupSize; + List> newList = new ArrayList<>(num); + for (int i = 0; i < num; i++) { + // 开始位置 + int fromIndex = i * groupSize; + // 结束位置 + int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; + newList.add(list.subList(fromIndex, toIndex)); + } + return newList; + } + + /** + * 根据个税扣缴义务人和账单月,获取三类福利档案中符合缴纳开始结束月区间的人员id + * @param paymentOrganization + * @param billMonth + * @return + */ + public List listCanPayEmpIds(Long paymentOrganization, String billMonth) { + List listCanPayEmpIds = new ArrayList<>(); + //社保档案中可进行缴纳的人员 + List socialCanPayEmpIds = getSocialSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth); + //公积金档案中可进行缴纳的人员 + List fundCanPayEmpIds = getFundSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth); + //其他福利档案中可进行缴纳的人员 + List otherCanPayEmpIds = getOtherSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth); + if (socialCanPayEmpIds != null && socialCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(socialCanPayEmpIds); + } + if (fundCanPayEmpIds != null && fundCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(fundCanPayEmpIds); + } + if (otherCanPayEmpIds != null && otherCanPayEmpIds.size() > 0) { + listCanPayEmpIds.addAll(otherCanPayEmpIds); + } + //去重 + listCanPayEmpIds = listCanPayEmpIds.stream().distinct().collect(Collectors.toList()); + return listCanPayEmpIds; + } + + private void handleData(List ids, AccountParam param) { + String billMonth = param.getBillMonth(); + try { + List list = new ArrayList<>(); + List> partitionDetailTempInfo = Lists.partition((List) ids, 100); + partitionDetailTempInfo.forEach(part -> list.addAll( + getSIAccountDetailTempMapper().getListByEmployeeIdsAndBillMonth(part, billMonth, param.getPaymentOrganization()))); + + encryptUtil.decryptList(list, InsuranceAccountDetailTempPO.class); + Integer paymentStatus = 0; + log.info("核算明细临时表 hrsa_bill_detail_temp待处理数量:{}", list.size()); + List> partitionIds = Lists.partition((List) ids, 100); + log.info("bill_detail入库前删除数据数量:{}", ids.size()); + for (List part : partitionIds) { + getInsuranceAccountDetailMapper().batchDelAccountDetails(part, billMonth, param.getPaymentOrganization(), paymentStatus); + + //删除账单月份+个税扣缴义务人+人员id下的调差数据 + getInsuranceCompensationMapper().deleteByBillMonthPayOrgEmpIds(InsuranceCompensationPO.builder() + .billMonth(billMonth) + .paymentOrganization(param.getPaymentOrganization()) + .employeeIds(part) + .build()); + } + + //生成bill_detail入库数据 + List collect = list.stream().map(item -> { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + BeanUtils.copyProperties(item, insuranceAccountDetailPO); + return insuranceAccountDetailPO; + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + log.info("bill_detail入库数据数量:{}", collect.size()); + batchSaveAccountInspectDetail(collect); + encryptUtil.encryptList(collect, InsuranceAccountDetailPO.class); + List> lists = splitDetailList(collect, 20); + lists.forEach(subList -> { + getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList); + }); + updateBatchAccount(param); + } + } catch (Exception e) { + log.error("福利核算数据处理失败", e); + getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), SalaryI18nUtil.getI18nLabel(0, "福利核算出错") + ": " + e.getMessage()); + throw e; + } + } + + public void batchSaveAccountInspectDetail(List list) { + List insuranceAccountInspectAllPOS = accountInspect(list, true); + batchDelInspectDetail(insuranceAccountInspectAllPOS); + List insuranceAccountInspectPOS = accountInspect(list, false); + if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) { + batchSaveInspectDetail(insuranceAccountInspectPOS); + } + } + public void batchDelInspectDetail(List list) { + List> lists = Lists.partition(list, 100); + lists.forEach(getInsuranceAccountInspectMapper()::batchDelInspectDetails); + + } + + public void batchSaveInspectDetail(List list) { + List> lists = Lists.partition(list, 100); + lists.forEach(getInsuranceAccountInspectMapper()::batchSaveInspectDetails); + } + + 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.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)); + + } + + private List> splitDetailList(List list, int groupSize) { + int length = list.size(); + // 计算可以分成多少组 + int num = (length + groupSize - 1) / groupSize; + List> newList = new ArrayList<>(num); + for (int i = 0; i < num; i++) { + // 开始位置 + int fromIndex = i * groupSize; + // 结束位置 + int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length; + newList.add(list.subList(fromIndex, toIndex)); + } + return newList; + } + + /** + * 更新台账接口 + */ + public void updateBatchAccount(AccountParam param) { + String billMonth = param.getBillMonth(); + + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(billMonth, param.getPaymentOrganization()); + 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"); + encryptUtil.decryptList(v, InsuranceAccountDetailPO.class); + boolean socialPersonFlag = false; + boolean fundPersonFlag = false; + boolean otherPersonFlag = false; + for (InsuranceAccountDetailPO item : v) { + // 判断社保是否为0 + socialPersonFlag = (StringUtils.isBlank(item.getSocialSum()) || SalaryEntityUtil.StringEqZERO(item.getSocialSum())); + BigDecimal socialPerson = socialPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getSocialSum()); + fundPersonFlag = (StringUtils.isBlank(item.getFundSum()) || SalaryEntityUtil.StringEqZERO(item.getFundSum())); + BigDecimal fundPerson = fundPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getFundSum()); + otherPersonFlag = (StringUtils.isBlank(item.getOtherSum()) || SalaryEntityUtil.StringEqZERO(item.getOtherSum())); + BigDecimal otherPerson = otherPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getOtherSum()); + socialTemp = socialTemp.add(socialPerson); + fundTemp = fundTemp.add(fundPerson); + otherTemp = otherTemp.add(otherPerson); + if (!socialPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + socialAccountPerson += 1; + } + if (!fundPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + funcAccountPerson += 1; + } + if (!otherPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) { + otherAccountPerson += 1; + } + } + + if (!"0".equals(socialTemp.toPlainString())) { + socialSum = socialSum.add(socialTemp); + } + if (!"0".equals(fundTemp.toPlainString())) { + fundSum = fundSum.add(fundTemp); + } + if (!"0".equals(otherTemp.toPlainString())) { + otherSum = otherSum.add(otherTemp); + } + } + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, param.getPaymentOrganization()); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + + insuranceAccountBatchPO.setAccountant(user.getLastname()); + 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()); + encryptUtil.encrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().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); + + } + + public void siFile(String billMonth, Long paymentOrganization) { + + //开始归档数据 + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillStatus(billMonth, BillStatusEnum.NOT_ARCHIVED.getValue(), paymentOrganization); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(0, "月份账单不存在")); + SalaryAssert.isFalse(Objects.equals(insuranceAccountBatchPO.getBillStatus(), BillStatusEnum.ARCHIVED.getValue()), SalaryI18nUtil.getI18nLabel(0, "月份账单已归档")); + insuranceAccountBatchPO.setBillStatus(BillStatusEnum.ARCHIVED.getValue()); + encryptUtil.encrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + getInsuranceAccountBatchMapper().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/timer/AutoSiAccountAndFileJob.java b/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java new file mode 100644 index 000000000..7d1b8f757 --- /dev/null +++ b/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java @@ -0,0 +1,107 @@ +package com.engine.salary.timer; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.common.SalaryContext; +import com.engine.salary.entity.siaccount.param.AccountParam; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.formlua.util.RegularUtil; +import com.engine.salary.service.SIAccountService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SIAccountServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 福利台账核算并归档任务 + * @Date: 2024/1/15 + **/ +@Slf4j +public class AutoSiAccountAndFileJob extends BaseCronJob { + + private String diffToCurrentMonth; + + public String getDiffToCurrentMonth() { + return diffToCurrentMonth; + } + + public void setDiffToCurrentMonth(String diffToCurrentMonth) { + this.diffToCurrentMonth = diffToCurrentMonth; + } + + private String taxAgentNames; + + public String getTaxAgentNames() { + return taxAgentNames; + } + + public void setTaxAgentNames(String taxAgentNames) { + this.taxAgentNames = taxAgentNames; + } + + private String fileFlag; + + public String getFileFlag() { + return fileFlag; + } + + public void setFileFlag(String fileFlag) { + this.fileFlag = fileFlag; + } + + private TaxAgentService getTaxAgentService(User user) { + SalaryContext.get().setValue("user",user); + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + public SIAccountService getSIAccountService(User user) { + SalaryContext.get().setValue("user",user); + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + @Override + public void execute() { + if (StrUtil.isNotBlank(diffToCurrentMonth) && RegularUtil.isInteger(diffToCurrentMonth)) { + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + user.setLastname("sysadmin"); + + Calendar accountTime= Calendar.getInstance(); +// prevMonth.setTimeInMillis(System.currentTimeMillis()); + accountTime.set(Calendar.MONTH, accountTime.get(Calendar.MONTH) + Integer.parseInt(diffToCurrentMonth)); + SimpleDateFormat s=new SimpleDateFormat("yyyy-MM"); + + String accountMonth = s.format(accountTime.getTime()); + boolean isFile = false; + if (StrUtil.isNotBlank(fileFlag) && "true".equals(fileFlag)) { + isFile = true; + } + //核算并归档 + List taxAgentList = getTaxAgentService(user).listAll(); + //判断是否过滤个税扣缴义务人 + if (StrUtil.isNotBlank(taxAgentNames)) { + List taxAgentNameList = Arrays.stream(taxAgentNames.split(",")).map(String::new).collect(Collectors.toList()); + taxAgentList = taxAgentList.stream().filter(f -> taxAgentNameList.contains(f.getName())).collect(Collectors.toList()); + } + for (TaxAgentPO po : taxAgentList) { + try { + getSIAccountService(user).saveAndFile(AccountParam.builder().paymentOrganization(po.getId()).billMonth(accountMonth).flag(true).fileFlag(isFile).build()); + } catch (Exception e) { + log.info("个税扣缴义务人-" + po.getName() + ",新建账单月份" + accountMonth + "的福利核算(并归档)过程失败,原因:" + e.getMessage()); + } + } + + } + + } +} From f236b8e655da64dacb98662097419a93f861b846 Mon Sep 17 00:00:00 2001 From: sy Date: Fri, 19 Jan 2024 11:35:11 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E5=8F=B0=E8=B4=A6=EF=BC=8C=E6=A0=B8=E7=AE=97?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=96=B9=E6=B3=95=E6=A2=B3=E7=90=86=E5=92=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/SIAccountService.java | 2 + .../service/impl/SIAccountServiceImpl.java | 935 +++++++++++++++++- .../service/impl/SIExportServiceImpl.java | 6 +- .../salary/timer/AutoSiAccountAndFileJob.java | 1 - .../engine/salary/web/SIExportController.java | 13 +- 5 files changed, 918 insertions(+), 39 deletions(-) diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java index 60d06ed86..6a496845b 100644 --- a/src/com/engine/salary/service/SIAccountService.java +++ b/src/com/engine/salary/service/SIAccountService.java @@ -314,5 +314,7 @@ public interface SIAccountService { boolean checkBalance(InsuranceAccountDetailPO po); boolean checkBalancePayInsurance(InsuranceAccountDetailPO po); + + List buildRecords(List list, Map paymentMap); } diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index 6bb0fd1f2..43168124a 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -18,10 +18,7 @@ import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.progress.ProgressDTO; import com.engine.salary.entity.siaccount.bo.InsuranceAccountBO; -import com.engine.salary.entity.siaccount.dto.InsuranceAccountBatchListDTO; -import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; -import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; -import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO; +import com.engine.salary.entity.siaccount.dto.*; import com.engine.salary.entity.siaccount.param.*; import com.engine.salary.entity.siaccount.po.*; import com.engine.salary.entity.siarchives.po.*; @@ -67,6 +64,7 @@ import com.engine.salary.util.valid.ValidUtil; import com.engine.salary.wrapper.SalaryFormulaWrapper; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.wbi.util.StringUtil; import dm.jdbc.util.IdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -83,6 +81,7 @@ import weaver.hrm.User; import java.io.InputStream; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -103,7 +102,6 @@ import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; @Slf4j public class SIAccountServiceImpl extends Service implements SIAccountService { -// private SIAccountBiz siAccountBiz = new SIAccountBiz(); private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); @@ -113,9 +111,9 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return ServiceUtil.getService(RecordsBuildServiceImpl.class, user); } - public SIAccountBiz getSiAccountBiz(User user) { - return ServiceUtil.getService(SIAccountBiz.class, user); - } +// public SIAccountBiz getSiAccountBiz(User user) { +// return ServiceUtil.getService(SIAccountBiz.class, user); +// } public ColumnBuildService getColumnBuildService(User user) { return ServiceUtil.getService(ColumnBuildServiceImpl.class, user); @@ -225,6 +223,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return MapperProxyFactory.getProxy(InsuranceCompensationMapper.class); } + private SIAccountUtilMapper getSIAccountUtilMapper() { + return MapperProxyFactory.getProxy(SIAccountUtilMapper.class); + } + @Override public Map listPage(InsuranceAccountBatchParam queryParam) { Long employeeId = (long) user.getUID(); @@ -244,7 +246,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { } //福利台账列表 - PageInfo pageInfo = getSiAccountBiz(user).listPage(queryParam); +// PageInfo pageInfo = getSiAccountBiz(user).listPage(queryParam); + PageInfo pageInfo = siBatchListPage(queryParam); Collection insuranceAccountBatchPOS = pageInfo.getList(); List insuranceAccountBatchListDTOS = InsuranceAccountBO.buildAccountBatchDTOList(insuranceAccountBatchPOS); @@ -313,7 +316,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { Map datas = new HashMap<>(); //正常缴纳列表 - PageInfo pageInfo = getSiAccountBiz(user).listCommonPage(queryParam); +// PageInfo pageInfo = getSiAccountBiz(user).listCommonPage(queryParam); + PageInfo pageInfo = siBatchListCommonPage(queryParam); List insuranceAccountDetailPOS = pageInfo.getList(); //数据组装 @@ -599,7 +603,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public void delete(AccountParam accountParam) { Long employeeId = (long) user.getUID(); - getSiAccountBiz(user).delete(accountParam, employeeId); +// getSiAccountBiz(user).delete(accountParam, employeeId); + siDelete(accountParam); } @Override @@ -635,24 +640,27 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { public void saveSupplementaryAccount(SaveSupplementaryAccountParam saveSupplementaryAccountParam) { ValidUtil.doValidator(saveSupplementaryAccountParam); - Long employeeId = (long) user.getUID(); - String currentUserName = user.getLastname(); - getSiAccountBiz(user).saveSupplementaryAccount(saveSupplementaryAccountParam, employeeId, currentUserName); +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).saveSupplementaryAccount(saveSupplementaryAccountParam, employeeId, currentUserName); + siSaveSupplementaryAccount(saveSupplementaryAccountParam); } @Override public void deleteCommonAccount(SaveCommonAccountParam param) { ValidUtil.doValidator(param); - Long employeeId = (long) user.getUID(); - String currentUserName = user.getLastname(); - getSiAccountBiz(user).deleteCommonAccount(param, employeeId, currentUserName); +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).deleteCommonAccount(param, employeeId, currentUserName); + siDeleteCommonAccount(param); } @Override public void deleteSummplementaryAccount(List supplementAccountBaseParams) { - Long employeeId = (long) user.getUID(); - String currentUserName = user.getLastname(); - getSiAccountBiz(user).deleteSupplementaryAccount(supplementAccountBaseParams, employeeId, currentUserName); +// Long employeeId = (long) user.getUID(); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).deleteSupplementaryAccount(supplementAccountBaseParams, employeeId, currentUserName); + siDeleteSupplementaryAccount(supplementAccountBaseParams); } @Override @@ -799,10 +807,11 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public void accountInspect(InspectAccountParam param) { - Long employeeId = (long) user.getUID(); +// Long employeeId = (long) user.getUID(); ValidUtil.doValidator(param); - String currentUserName = user.getLastname(); - getSiAccountBiz(user).accountInspect(param.getIds(), param.getBillMonth(), employeeId, currentUserName, param.getPaymentOrganization()); +// String currentUserName = user.getLastname(); +// getSiAccountBiz(user).accountInspect(param.getIds(), param.getBillMonth(), employeeId, currentUserName, param.getPaymentOrganization()); + accountInspect(param.getIds(), param.getBillMonth(), param.getPaymentOrganization()); } @Override @@ -926,7 +935,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public PageInfo overView(InsuranceAccountDetailParam queryParam) { - PageInfo pageInfos = getSiAccountBiz(user).overView(queryParam); +// PageInfo pageInfos = getSiAccountBiz(user).overView(queryParam); + PageInfo pageInfos = siOverView(queryParam); return pageInfos; } @@ -1521,13 +1531,15 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { @Override public void socialSecurityBenefitsRecalculate(InsuranceAccountBatchPO param) { //fixme 重新核算的校验逻辑 1、先取台账对应扣缴义务人下的所有账套 2、取账套下所有核算记录 3、判断核算记录有没有使用对应月份的福利台账 - int num = getSiAccountBiz(user).checkIfBusinessaccounting(param); +// int num = getSiAccountBiz(user).checkIfBusinessaccounting(param); + int num = checkIfBusinessAccounting(param); //表示已经被核算过不能重新核算 if (num > 0) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "已被薪酬核算给核算过,无法重新核算!")); } param.setBillStatus(0); - getSiAccountBiz(user).updateById(param); +// getSiAccountBiz(user).updateById(param); + updateById(param); } /** @@ -1804,7 +1816,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { encryptUtil.encryptList(updateInsuranceAccountDetailList, InsuranceAccountDetailPO.class); //更新 for(InsuranceAccountDetailPO po : updateInsuranceAccountDetailList) { - getSiAccountBiz(user).updateByEmployeeIdAndBillMonth(po); +// getSiAccountBiz(user).updateByEmployeeIdAndBillMonth(po); + updateByEmployeeIdAndBillMonth(po); } //刷新hrsa_bill_batch中数据统计信息 @@ -3667,7 +3680,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { encryptUtil.encryptList(updateInsuranceAccountDetailList, InsuranceAccountDetailPO.class); //更新 for(InsuranceAccountDetailPO po : updateInsuranceAccountDetailList) { - getSiAccountBiz(user).updateByEmployeeIdAndBillMonth(po); +// getSiAccountBiz(user).updateByEmployeeIdAndBillMonth(po); + updateByEmployeeIdAndBillMonth(po); } } if (createInsuranceAccountDetailList.size() > 0) { @@ -3705,7 +3719,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { // 正常缴纳列表 queryParam.setPageSize(10000000); - PageInfo pageInfo = getSiAccountBiz(user).listCommonPage(queryParam); +// PageInfo pageInfo = getSiAccountBiz(user).listCommonPage(queryParam); + PageInfo pageInfo = siBatchListCommonPage(queryParam); List insuranceAccountDetailPOS = pageInfo.getList(); // 数据组装 List> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId); @@ -4319,6 +4334,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); return insuranceAccountDetailPO; } + /*****以下代码为SIAccountBiz中逻辑迁移,旨在减少Biz类的使用*****/ /** * 新建核算并归档 @@ -5352,4 +5368,865 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { // insuranceSchemeContext.setNewValues(insuranceAccountBatchPO); // siAccountLoggerTemplate.write(insuranceSchemeContext); } + + + public PageInfo siBatchListPage(InsuranceAccountBatchParam queryParam) { + List list = getInsuranceAccountBatchMapper().list(queryParam); + PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, InsuranceAccountBatchPO.class); + encryptUtil.decryptList(page.getList(), InsuranceAccountBatchPO.class); + return page; + } + + public PageInfo siBatchListCommonPage(InsuranceAccountDetailParam queryParam) { + queryParam.setPaymentStatus(PaymentStatusEnum.COMMON.getValue()); + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + //系统人员福利台账明细 + List list = getInsuranceAccountDetailMapper().list(queryParam); + //非系统各人员台账明细 + List extList = getInsuranceAccountDetailMapper().extList(queryParam); + list.addAll(extList); + PageInfo pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), + list, InsuranceAccountDetailPO.class); + encryptUtil.decryptList(pageInfo.getList(), InsuranceAccountDetailPO.class); + return pageInfo; + } + + public void siDelete(AccountParam param) { + InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()); + encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class); + SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(0, "参数错误")); +// if (insuranceAccountBatchPO.getBillStatus().equals(BillStatusEnum.ARCHIVED.getValue())) { +// int num = checkIfBusinessAccounting(insuranceAccountBatchPO); +// //表示已经被核算过不能重新核算 +// if (num > 0) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "已被薪酬核算给核算过,无法删除!")); +// } +// } + +// if(param.getPaymentOrganization()==null){ +// throw new SalaryRunTimeException("个税扣缴义务人为空"); +// } + getInsuranceAccountBatchMapper().deleteById(insuranceAccountBatchPO.getId()); + getInsuranceAccountDetailMapper().batchDeleteNotFile(param.getBillMonth(), param.getPaymentOrganization()); + + //删除账单月份+个税扣缴义务人下的调差数据 + getInsuranceCompensationMapper().deleteByBillMonthAndPayOrg(param.getBillMonth(), param.getPaymentOrganization()); +// 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 siSaveSupplementaryAccount(SaveSupplementaryAccountParam param) { + if (StringUtils.isBlank(param.getBillMonth()) || CollectionUtils.isEmpty(param.getBillMonthList()) || CollectionUtils.isEmpty(param.getProjects()) + || CollectionUtils.isEmpty(param.getIncludes())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "参数错误")); + } + //需要补缴的月份 + if (param.getBillMonthList().contains(param.getBillMonth())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "当前月走正常缴纳")); + } + //需要补缴的员工id + List employeeIds = param.getIncludes(); + if (CollectionUtils.isNotEmpty(param.getExcludes())) { + employeeIds = employeeIds.stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList()); + } + //校验补缴人员是否存在福利档案基础信息,并且runStatus处于正在缴纳或者待减员 + List insuranceBaseInfoList = getInsuranceBaseInfoMapper().getSocialByPaymentOrganization(param.getPaymentOrganization()); + List finalEmployeeIds = employeeIds; + List filterList = insuranceBaseInfoList.stream().filter(e -> { + for (Long uId : finalEmployeeIds) { + if (e.getEmployeeId().equals(uId) && (e.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()) || e.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()))) { + return true; + } + } + return false; + }).collect(Collectors.toList()); + if (filterList.size() != employeeIds.size()) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "补缴人员中存在未设置福利档案人员或相关人员不在福利在缴人员中,不可新建补缴信息!")); + } + //20231122逻辑优化,过滤出不在起始缴纳月和最后缴纳月区间的人员 + List empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth()); + employeeIds = employeeIds.stream().filter(f -> empIdsInPayMonthRange.contains(f)).collect(Collectors.toList()); + + SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(0, "无核算人员")); + List baseList = new ArrayList<>(); + employeeIds.stream().forEach(id -> { + param.getBillMonthList().stream().forEach(month -> { + SupplementAccountBaseParam supplementAccountBaseParam = SupplementAccountBaseParam.builder() + .supplementaryMonth(month) + .employeeId(id) + .paymentOrganization(param.getPaymentOrganization()) + .projects(param.getProjects()) + .billMonth(param.getBillMonth()) + .supplementType(param.getSupplementType()) + .build(); + if ("2".equals(param.getSupplementType())) { + supplementAccountBaseParam.setSocialPaymentBaseString(param.getSocialPaymentBaseString()); + supplementAccountBaseParam.setFundPaymentBaseString(param.getFundPaymentBaseString()); + supplementAccountBaseParam.setOtherPaymentBaseString(param.getOtherPaymentBaseString()); + } else if("3".equals(param.getSupplementType())) { + supplementAccountBaseParam.setSocialPaymentPerString(param.getSocialPaymentPerString()); + supplementAccountBaseParam.setSocialPaymentComString(param.getSocialPaymentComString()); + supplementAccountBaseParam.setFundPaymentPerString(param.getFundPaymentPerString()); + supplementAccountBaseParam.setFundPaymentComString(param.getFundPaymentComString()); + supplementAccountBaseParam.setOtherPaymentPerString(param.getOtherPaymentPerString()); + supplementAccountBaseParam.setOtherPaymentComString(param.getOtherPaymentComString()); + } + baseList.add(supplementAccountBaseParam); + }); + }); + //核算开始 + accountSupplement(baseList, employeeIds, param.getPaymentOrganization()); + + updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build()); + } + + /** + * @param baseList 员工id-账单月份-补缴月份(单挑)-补缴项 集合 + * @param employeeIds 需要补缴的员工id + * @return + */ + public String accountSupplement(List baseList, List employeeIds, Long paymentOrganization) { + //(k,v) k-员工id v-员工对应的福利档案数据 + Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); + //核算结果集 + List pos = new ArrayList<>(); + baseList.forEach(baseParam -> { + //判断人员id+账单月份+补缴月份在表中的唯一性 + List supplementList = getInsuranceAccountDetailMapper().querySupplementList(baseParam.getBillMonth(), baseParam.getPaymentOrganization(), baseParam.getEmployeeId(), baseParam.getSupplementaryMonth()); + if (supplementList.size() > 0) { + throw new SalaryRunTimeException("当前人员和账单月份已存在该补缴月份的数据!无法再次创建!"); + } + InsuranceAccountDetailPO insuranceAccountDetailPO = accountSingleEmployeeBill(baseParam, longInsuranceArchivesAccountPOMap.get(baseParam.getEmployeeId())); + pos.add(insuranceAccountDetailPO); + }); + batchSaveSupplementAccount(pos); + return SalaryI18nUtil.getI18nLabel(0, "核算完成,数据保存成功"); + } + + public InsuranceAccountDetailPO accountSingleEmployeeBill(SupplementAccountBaseParam baseParam, InsuranceArchivesAccountPO accountPO) { + InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO(); + List projects = baseParam.getProjects(); + insuranceAccountDetailPO.setBillMonth(baseParam.getBillMonth()); + insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue()); + insuranceAccountDetailPO.setCreator((long) user.getUID()); + 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.setPaymentOrganization(baseParam.getPaymentOrganization()); + 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()); + //缴纳组织=个税扣缴义务人 + insuranceAccountDetailPO.setSocialPayOrg(baseParam.getPaymentOrganization()); + if (projects.contains(ProjectTypeEnum.ALL.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + if (accountPO.getFund() != null) { + accountPO.getFund().setFundPaymentBaseString(baseParam.getFundPaymentBaseString()); + } + if (accountPO.getOther() != null) { + accountPO.getOther().setOtherPaymentBaseString(baseParam.getOtherPaymentBaseString()); + } + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupSocialByData(insuranceAccountDetailPO, baseParam); + accountSupFundByData(insuranceAccountDetailPO, baseParam); + accountSupOtherByData(insuranceAccountDetailPO, baseParam); + } else { + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + return account(insuranceAccountDetailPO); + } + if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupSocialByData(insuranceAccountDetailPO, baseParam); + } else { + accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + } + if (!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) { + List ids = new ArrayList<>(); + List list = getICategoryMapper().listByDataType(DataTypeEnum.SYSTEM.getValue()); + + if (projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) { + ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(0, "养老保险").equals(item.getInsuranceName())).findFirst() + .get(); + ids.add(insuranceCategoryPO.getId()); + } + if (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue())) { + ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(0, "医疗保险").equals(item.getInsuranceName())).findFirst() + .get(); + ids.add(insuranceCategoryPO.getId()); + } + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getSocial() != null) { + accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString()); + } + accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupEndowmentInsuranceByData(insuranceAccountDetailPO, baseParam, ids); + } else { + accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids, baseParam.getSupplementaryMonth()); + } + + } + if (projects.contains(ProjectTypeEnum.FUND.getValue())) { + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getFund() != null) { + accountPO.getFund().setFundPaymentBaseString(baseParam.getFundPaymentBaseString()); + } + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupFundByData(insuranceAccountDetailPO, baseParam); + } else { + accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + } + if (projects.contains(ProjectTypeEnum.OTHER.getValue())) { + + if ("2".equals(baseParam.getSupplementType())) { + if (accountPO.getOther() != null) { + accountPO.getOther().setOtherPaymentBaseString(baseParam.getOtherPaymentBaseString()); + } + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } else if ("3".equals(baseParam.getSupplementType())) { + accountSupOtherByData(insuranceAccountDetailPO, baseParam); + } else { + accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth()); + } + + } + + return account(insuranceAccountDetailPO); + } + + public void accountSupFundByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //公积金个人 + if (StringUtils.isNotBlank(baseParam.getFundPaymentPerString())) { + List fundPer = new ArrayList<>(); + HashMap fundPerson = JSON.parseObject(baseParam.getFundPaymentPerString(), new HashMap().getClass()); + fundPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundPer.add(result); + }); + insuranceAccountDetailPO.setFundPerJson(baseParam.getFundPaymentPerString()); + BigDecimal fundPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundPer) { + fundPerSum = fundPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundPerSum(fundPerSum.toPlainString()); + } + //公积金单位 + if (StringUtils.isNotBlank(baseParam.getFundPaymentComString())) { + List fundCom = new ArrayList<>(); + HashMap fundComMap = JSON.parseObject(baseParam.getFundPaymentComString(), new HashMap().getClass()); + fundComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + fundCom.add(result); + }); + insuranceAccountDetailPO.setFundComJson(baseParam.getFundPaymentComString()); + BigDecimal fundComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : fundCom) { + fundComSum = fundComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString()); + } + } + + public void accountSupOtherByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //其他福利个人 + if (StringUtils.isNotBlank(baseParam.getOtherPaymentPerString())) { + List otherPer = new ArrayList<>(); + HashMap otherPerMap = JSON.parseObject(baseParam.getOtherPaymentPerString(), new HashMap().getClass()); + otherPerMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherPer.add(result); + }); + insuranceAccountDetailPO.setOtherPerJson(baseParam.getOtherPaymentPerString()); + BigDecimal otherPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherPer) { + otherPerSum = otherPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString()); + } + //其他福利单位 + if (StringUtils.isNotBlank(baseParam.getOtherPaymentComString())) { + List otherCom = new ArrayList<>(); + HashMap otherComMap = JSON.parseObject(baseParam.getOtherPaymentComString(), new HashMap().getClass()); + otherComMap.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + otherCom.add(result); + }); + insuranceAccountDetailPO.setOtherComJson(baseParam.getOtherPaymentComString()); + BigDecimal otherComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : otherCom) { + otherComSum = otherComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString()); + } + } + + public void accountSupSocialByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) { + //社保个人 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentPerString())) { + List socialPer = new ArrayList<>(); + HashMap archivesPerson = JSON.parseObject(baseParam.getSocialPaymentPerString(), new HashMap().getClass()); + archivesPerson.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialPer.add(result); + }); + insuranceAccountDetailPO.setSocialPerJson(baseParam.getSocialPaymentPerString()); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + } + //社保单位 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentComString())) { + List socialCom = new ArrayList<>(); + HashMap archivesCom = JSON.parseObject(baseParam.getSocialPaymentComString(), new HashMap().getClass()); + archivesCom.forEach((k, v) -> { + BigDecimal result = new BigDecimal(v); + socialCom.add(result); + }); + insuranceAccountDetailPO.setSocialComJson(baseParam.getSocialPaymentComString()); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialCom) { + socialComSum = socialComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + + public InsuranceAccountDetailPO accountEndowmentInsurance(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, List categoryIds, String billMonth) { + if (accountPO.getSocial() != null) { + InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial(); + insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization()); + insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount()); + insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId()); + insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString()); + insuranceAccountDetailPO.setSocialPaymentComBaseString(socialPO.getSocialPaymentComBaseString()); + //判断是否在起始缴纳月和最后缴纳月之间 + Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, socialPO.getSocialStartTime(), socialPO.getSocialEndTime()); + + if ((Objects.equals(NonPaymentEnum.YES.getValue(), socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) { + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId()); + encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class); + //方案中包含的需要缴纳社保的个人福利 + int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1; + Map schemeperson = detailPOS.stream() + .filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) + && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) + && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 个人 + List needArchivesPerson = new ArrayList<>(); + if (archivesPerson != null) { + categoryIds.forEach(item -> { + if (archivesPerson.containsKey(String.valueOf(item)) && schemeperson.containsKey(item)) { + if (StringUtils.isNotBlank(archivesPerson.get(String.valueOf(item)))) { + needArchivesPerson.add(item); + } + } + }); + } + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime()); + + List socialPer = new ArrayList<>(); + Map socialPerJsonMap = new HashMap<>(); + needArchivesPerson.forEach(e -> { + InsuranceSchemeDetailPO po = schemeperson.get(e); + BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesPerson) || 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 = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + 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 -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && + (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))) + .collect( + Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity())); + //档案中包含的基数信息 + HashMap archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap().getClass()); + //需要核算社保的福利id 单位 + List needArchivesCom = new ArrayList<>(); + if (archivesCom != null) { + categoryIds.forEach(item -> { + if (archivesCom.containsKey(String.valueOf(item)) && schemeCom.containsKey(item)) { + if (StringUtils.isNotBlank(archivesCom.get(String.valueOf(item)))) { + needArchivesCom.add(item); + } + } + }); + //判断核算周期、核算月、福利起始缴纳月的关系 + checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime()); + } + List socialCom = new ArrayList<>(); + Map sociaComJsonMap = new HashMap<>(); + needArchivesCom.forEach(e -> { + InsuranceSchemeDetailPO po = schemeCom.get(e); + BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100")); + BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesCom) || 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 = new BigDecimal("0"); + if (Objects.equals(po.getPaymentCycle(), 1)) { + int monthValue = 1; + for (int i = monthIndex - 1; i >= 0; i--) { + String cycleValue = po.getCycleSetting().charAt(i) + ""; + if (Integer.parseInt(cycleValue) == 1) { + break; + } + monthValue++; + } + if (po.getAccountType() == 1) { + paymentNum = paymentNum.multiply(new BigDecimal(monthValue)); + fixedCost = fixedCost.multiply(new BigDecimal(monthValue)); + result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)); + } else { + for (int i = 0; i < monthValue; i++) { + result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost))); + } + } + } else { + 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 accountSupEndowmentInsuranceByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam, List ids) { + //社保个人 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentPerString())) { + List socialPer = new ArrayList<>(); + HashMap archivesPerson = JSON.parseObject(baseParam.getSocialPaymentPerString(), new HashMap().getClass()); + HashMap socialPerson = new HashMap<>(); + archivesPerson.forEach((k, v) -> { + if (ids.contains(Long.valueOf(k))) { + socialPerson.put(k, v); + BigDecimal result = new BigDecimal(v); + socialPer.add(result); + } + + }); + insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerson)); + BigDecimal socialPerSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialPer) { + socialPerSum = socialPerSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString()); + } + //社保单位 + if (StringUtils.isNotBlank(baseParam.getSocialPaymentComString())) { + List socialCom = new ArrayList<>(); + HashMap archivesCom = JSON.parseObject(baseParam.getSocialPaymentComString(), new HashMap().getClass()); + HashMap socialComMap = new HashMap<>(); + archivesCom.forEach((k, v) -> { + if (ids.contains(Long.valueOf(k))) { + socialComMap.put(k, v); + BigDecimal result = new BigDecimal(v); + socialCom.add(result); + } + }); + insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap)); + BigDecimal socialComSum = new BigDecimal("0"); + for (BigDecimal bigDecimal : socialCom) { + socialComSum = socialComSum.add(bigDecimal); + } + insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString()); + } + } + + public void batchSaveSupplementAccount(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + batchSaveAccountInspectDetail(pos); + getInsuranceAccountDetailMapper().batchDelSupplementAccountDetails(pos); + encryptUtil.encryptList(pos, InsuranceAccountDetailPO.class); + List> lists = splitDetailList(pos, 20); + lists.forEach(subList -> { + getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList); + }); + //删除日志 +// 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 siDeleteCommonAccount(SaveCommonAccountParam param) { + ValidUtil.doValidator(param); + SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel(0, "参数错误")); + //根据id批量删除 + if (param.getIds().size() > 0) { + getInsuranceAccountDetailMapper().batchDelAccountDetailsByIds(param.getIds()); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "请勾选需要删除的数据项!")); + } + //记录日志 +// 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(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build()); + } + + public void siDeleteSupplementaryAccount(List param) { + SalaryAssert.notEmpty(param, SalaryI18nUtil.getI18nLabel(0, "参数错误")); + boolean valid = param.stream().anyMatch(item -> item.getEmployeeId() == null + || StringUtils.isBlank(item.getSupplementaryMonth()) + || StringUtils.isBlank(item.getBillMonth())); + if (valid) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "参数错误")); + } + getInsuranceAccountDetailMapper().batchDelSupplementDetailsByIds(param); +// param.stream().forEach(item -> { +// LoggerContext insuranceSchemeContext = new LoggerContext(); +// 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(AccountParam.builder().billMonth(param.get(0).getBillMonth()).paymentOrganization(param.get(0).getPaymentOrganization()).build()); + } + + public void accountInspect(Collection ids, String billMonth, Long paymentOrganization) { + List insuranceAccountInspectPOS = allInspects(ids, billMonth); + SalaryAssert.notEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel(0, "无核算数据")); + List commonInspects = insuranceAccountInspectPOS.stream() + .filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.COMMON.getValue())) + .collect(Collectors.toList()); + List supplementInspects = insuranceAccountInspectPOS.stream() + .filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.REPAIR.getValue())) + .collect(Collectors.toList()); + //核算正常缴纳 + if (CollectionUtils.isNotEmpty(commonInspects)) { + SaveCommonAccountParam param = new SaveCommonAccountParam(); + param.setBillMonth(billMonth); + param.setIncludes(commonInspects.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList())); + siSaveCommonAccount(param); + } + //核算补缴 + if (CollectionUtils.isNotEmpty(supplementInspects)) { + List baseList = new ArrayList<>(); + supplementInspects.forEach(e -> { + SupplementAccountBaseParam base = new SupplementAccountBaseParam(); + base.setBillMonth(billMonth); + base.setProjects( + e.getSupplementaryProjects() == null ? null : Arrays.stream(e.getSupplementaryProjects().split(",")).map(Integer::valueOf).collect(Collectors.toList())); + base.setEmployeeId(e.getEmployeeId()); + base.setSupplementaryMonth(e.getSupplementaryMonth()); + baseList.add(base); + }); + accountSupplement(baseList, baseList.stream().map(SupplementAccountBaseParam::getEmployeeId).collect(Collectors.toList()), paymentOrganization); + } + } + + public PageInfo siOverView(InsuranceAccountDetailParam queryParam) { + + List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(queryParam.getBillMonth(), StringUtil.isBlank(queryParam.getPaymentOrganization()) ? null : Long.valueOf(queryParam.getPaymentOrganization())); + encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class); + //获取扣缴义务人信息 + List paymentList = getTaxAgentMapper().listAll(); + SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(0, "该租户无扣缴义务人")); + Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity())); + List insuranceAccountViewListDTOS = buildRecords(insuranceAccountDetailPOS, paymentMap); + + PageInfo insuranceAccountViewListDTOPage = new PageInfo<>(insuranceAccountViewListDTOS, InsuranceAccountViewListDTO.class); + insuranceAccountViewListDTOPage.setTotal(insuranceAccountViewListDTOS.size()); + return insuranceAccountViewListDTOPage; + } + + @Override + public List buildRecords(List list, Map paymentMap) { + Map result = new HashMap<>(); + //根据组织分组,对社保进行统计 + Map> socialCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + socialCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountSocialView(insuranceAccountViewListDTO, v); + }); + //根据组织分组,对公积金进行统计 + Map> fundCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + fundCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountFundView(insuranceAccountViewListDTO, v); + }); + //根据组织分组,对其他福利进行统计 + Map> otherCollect = list.stream().filter(item -> item.getSocialPayOrg() != null) + .collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg)); + otherCollect.forEach((k, v) -> { + if (result.get(k) == null) { + InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO(); + temp.setPayOrg(paymentMap.get(k).getName()); + result.put(k, temp); + } + InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k); + accountOtherView(insuranceAccountViewListDTO, v); + }); + //对各组织进行金额合计 + List viewDTOS = new ArrayList<>(); + result.forEach((k, v) -> { + BigDecimal socialPaySum = StringUtils.isBlank(v.getSocialPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getSocialPaySum()); + BigDecimal fundPaySum = StringUtils.isBlank(v.getFundPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getFundPaySum()); + BigDecimal otherPaySum = StringUtils.isBlank(v.getOtherPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getOtherPaySum()); + v.setIndex(k); + BigDecimal sum = socialPaySum.add(fundPaySum).add(otherPaySum); + v.setSum(sum.toPlainString()); + viewDTOS.add(v); + }); + //合计 + InsuranceAccountViewListDTO insuranceAccountViewListDTO = new InsuranceAccountViewListDTO(); + int socialNum = 0; + int fundNum = 0; + int otherNum = 0; + BigDecimal socialSum = new BigDecimal("0"); + BigDecimal fundSum = new BigDecimal("0"); + BigDecimal otherSum = new BigDecimal("0"); + BigDecimal sum = new BigDecimal("0"); + for (InsuranceAccountViewListDTO item : viewDTOS) { + if (item.getSocialNum() != null) { + socialNum += item.getSocialNum(); + } + if (item.getFundNum() != null) { + fundNum += item.getFundNum(); + } + if (item.getOtherNum() != null) { + otherNum += item.getOtherNum(); + } + if (StringUtils.isNotBlank(item.getSocialPaySum())) { + socialSum = socialSum.add(new BigDecimal(item.getSocialPaySum())); + } + if (StringUtils.isNotBlank(item.getFundPaySum())) { + fundSum = fundSum.add(new BigDecimal(item.getFundPaySum())); + } + if (StringUtils.isNotBlank(item.getOtherPaySum())) { + otherSum = otherSum.add(new BigDecimal(item.getOtherPaySum())); + } + if (StringUtils.isNotBlank(item.getSum())) { + sum = sum.add(new BigDecimal(item.getSum())); + } + } + insuranceAccountViewListDTO.setSum(sum.toPlainString()); + insuranceAccountViewListDTO.setSocialPaySum(socialSum.toPlainString()); + insuranceAccountViewListDTO.setPayOrg(SalaryI18nUtil.getI18nLabel(0, "合计")); + insuranceAccountViewListDTO.setFundPaySum(fundSum.toPlainString()); + insuranceAccountViewListDTO.setOtherPaySum(otherSum.toPlainString()); + insuranceAccountViewListDTO.setSocialNum(socialNum); + insuranceAccountViewListDTO.setFundNum(fundNum); + insuranceAccountViewListDTO.setOtherNum(otherNum); + viewDTOS.add(insuranceAccountViewListDTO); + viewDTOS.forEach(e -> { + e.setSocialPaySum(StringUtils.isBlank(e.getSocialPaySum()) ? "0" : e.getSocialPaySum()); + e.setSocialNum(e.getSocialNum() == null ? 0 : e.getSocialNum()); + e.setFundNum(e.getFundNum() == null ? 0 : e.getFundNum()); + e.setFundPaySum(StringUtils.isBlank(e.getFundPaySum()) ? "0" : e.getFundPaySum()); + e.setOtherPaySum(StringUtils.isBlank(e.getOtherPaySum()) ? "0" : e.getOtherPaySum()); + e.setOtherNum(e.getOtherNum() == null ? 0 : e.getOtherNum()); + e.setSum(SalaryEntityUtil.thousandthConvert(e.getSum())); + e.setSocialPaySum(SalaryEntityUtil.thousandthConvert(e.getSocialPaySum())); + e.setOtherPaySum(SalaryEntityUtil.thousandthConvert(e.getOtherPaySum())); + e.setFundPaySum(SalaryEntityUtil.thousandthConvert(e.getFundPaySum())); + }); + return viewDTOS; + } + + public void accountOtherView(InsuranceAccountViewListDTO dto, List pos) { + int otherNum = 0; + BigDecimal otherPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getOtherSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getOtherSum()) != 0.0) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + otherNum += 1; + } + otherPaySum = otherPaySum.add(new BigDecimal(item.getOtherSum())); + } + } + dto.setOtherNum(otherNum); + dto.setOtherPaySum(otherPaySum.toPlainString()); + } + + public void accountFundView(InsuranceAccountViewListDTO dto, List pos) { + int fundNum = 0; + BigDecimal fundPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getFundSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getFundSum()) != 0.0) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + fundNum += 1; + } + fundPaySum = fundPaySum.add(new BigDecimal(item.getFundSum())); + } + } + dto.setFundNum(fundNum); + dto.setFundPaySum(fundPaySum.toPlainString()); + } + + public void accountSocialView(InsuranceAccountViewListDTO dto, List pos) { + int socialNum = 0; + BigDecimal socialPaySum = new BigDecimal("0"); + for (InsuranceAccountDetailPO item : pos) { + if (StringUtils.isNotBlank(item.getSocialSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getSocialSum()) != 0.0 ) { + if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) { + socialNum += 1; + } + socialPaySum = socialPaySum.add(new BigDecimal(item.getSocialSum())); + } + } + dto.setSocialNum(socialNum); + dto.setSocialPaySum(socialPaySum.toPlainString()); + } + + /** + * 查询台账id是否已经薪资核算核算过 + * + * @param param + * @return + */ + public int checkIfBusinessAccounting(InsuranceAccountBatchPO param) { + List list = getSIAccountUtilMapper().checkIfBusinessaccounting(param.getId()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + return (int) list.stream().filter( f -> { + String billMonthBySob = sdf.format(convertSalaryMonthToBillMonth(f.getSalaryMonth(), f.getSocialSecurityCycleType())); + return f.getBillmonth().equals(billMonthBySob.substring(0, 7)); + }).count(); + } + + public Date convertSalaryMonthToBillMonth(Date salaryMonth, Integer socialSecurityCycleType) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(salaryMonth); + calendar.add(Calendar.MONTH, socialSecurityCycleType - 3); + return calendar.getTime(); + } + + /** + * 更新薪资台账 + * + * @param param + * @return + */ + public void updateById(InsuranceAccountBatchPO param) { + getInsuranceAccountBatchMapper().updateById(param); + } + + /** + * 更新福利台账 + */ + public void updateByEmployeeIdAndBillMonth(InsuranceAccountDetailPO insuranceAccountDetailPO) { + getInsuranceAccountDetailMapper().updateByEmployeeIdAndBillMonth(insuranceAccountDetailPO); + } + + /*****以上代码为SIAccountBiz中方法逻辑迁移,旨在减少Biz类的使用*****/ + } diff --git a/src/com/engine/salary/service/impl/SIExportServiceImpl.java b/src/com/engine/salary/service/impl/SIExportServiceImpl.java index ac3ec8488..93c929e46 100644 --- a/src/com/engine/salary/service/impl/SIExportServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIExportServiceImpl.java @@ -5,7 +5,6 @@ import com.alibaba.fastjson.TypeReference; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.salary.biz.SIAccountBiz; import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; @@ -68,7 +67,7 @@ public class SIExportServiceImpl extends Service implements SIExportService { private EncryptUtil encryptUtil = new EncryptUtil(); - private SIAccountBiz siAccountBiz = new SIAccountBiz(); +// private SIAccountBiz siAccountBiz = new SIAccountBiz(); private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); @@ -117,7 +116,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { List paymentList =getTaxAgentMapper().listAll(); SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(100341, "该租户无扣缴义务人")); Map paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity())); - List insuranceAccountViewListDTOS = siAccountBiz.buildRecords(insuranceAccountDetailPOS, paymentMap); +// List insuranceAccountViewListDTOS = siAccountBiz.buildRecords(insuranceAccountDetailPOS, paymentMap); + List insuranceAccountViewListDTOS = getSIAccountService(user).buildRecords(insuranceAccountDetailPOS, paymentMap); List> excelSheetData = new ArrayList<>(); // 1.工作簿名称 diff --git a/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java b/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java index 7d1b8f757..646024f3d 100644 --- a/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java +++ b/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java @@ -77,7 +77,6 @@ public class AutoSiAccountAndFileJob extends BaseCronJob { user.setLastname("sysadmin"); Calendar accountTime= Calendar.getInstance(); -// prevMonth.setTimeInMillis(System.currentTimeMillis()); accountTime.set(Calendar.MONTH, accountTime.get(Calendar.MONTH) + Integer.parseInt(diffToCurrentMonth)); SimpleDateFormat s=new SimpleDateFormat("yyyy-MM"); diff --git a/src/com/engine/salary/web/SIExportController.java b/src/com/engine/salary/web/SIExportController.java index a37cd05c8..f3636c8dd 100644 --- a/src/com/engine/salary/web/SIExportController.java +++ b/src/com/engine/salary/web/SIExportController.java @@ -2,7 +2,6 @@ package com.engine.salary.web; import cn.hutool.core.util.BooleanUtil; import com.engine.common.util.ServiceUtil; -import com.engine.salary.biz.SIAccountBiz; import com.engine.salary.entity.siaccount.param.InspectAccountParam; import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; @@ -85,8 +84,9 @@ public class SIExportController { @QueryParam("ids")List ids,@QueryParam("billMonth") String billMonth) { InspectAccountParam param = InspectAccountParam.builder().ids(ids).billMonth(billMonth).build(); User user = HrmUserVarify.getUser(request, response); - SIAccountBiz siAccountBiz = new SIAccountBiz(); - List insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth()); +// SIAccountBiz siAccountBiz = new SIAccountBiz(); +// List insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth()); + List insuranceAccountInspectPOS = getService(user).allInspects(param.getIds(), param.getBillMonth()); InsuranceArchivesListParam req = new InsuranceArchivesListParam(); req.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList())); XSSFWorkbook workbook = getSIExportWrapper(user).export(req); @@ -236,12 +236,13 @@ public class SIExportController { @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response exportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { InsuranceArchivesListParam param = buildParam(request); - SIAccountBiz siAccountBiz = new SIAccountBiz(); + User user = HrmUserVarify.getUser(request, response); +// SIAccountBiz siAccountBiz = new SIAccountBiz(); if (param.getInspectAll() != null && param.getInspectAll()) { - List insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth()); +// List insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth()); + List insuranceAccountInspectPOS = getService(user).allInspects(param.getIds(), param.getBillMonth()); param.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList())); } - User user = HrmUserVarify.getUser(request, response); XSSFWorkbook workbook = getSIImportWrapper(user).exportTemplate(param); String time = LocalDate.now().toString(); String fileName = ""; From 94d72cd93c646a5ea80b211cb34ec95a5f7b1e96 Mon Sep 17 00:00:00 2001 From: sy Date: Tue, 23 Jan 2024 10:52:53 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E6=A8=A1=E6=9D=BF=EF=BC=8C=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=8A=9F=E8=83=BD=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/SalaryTemplateCopyParam.java | 2 + .../impl/SalaryTemplateServiceImpl.java | 56 ++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateCopyParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateCopyParam.java index bf0e24f1e..53fb50eaf 100644 --- a/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateCopyParam.java +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateCopyParam.java @@ -23,6 +23,8 @@ public class SalaryTemplateCopyParam { // 模板名称") private String name; + private Long salarySobId; + public static void checkParam(SalaryTemplateCopyParam copyParam) { if (copyParam.getId() == null) { throw new SalaryRunTimeException("id必选"); diff --git a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java index 591261abb..cf325731f 100644 --- a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java @@ -2,6 +2,7 @@ package com.engine.salary.service.impl; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.SalarySobBiz; @@ -16,15 +17,17 @@ import com.engine.salary.entity.salaryBill.param.SalaryTemplateQueryParam; import com.engine.salary.entity.salaryBill.param.SalaryTemplateSaveParam; import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO; import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemGroupDTO; -import com.engine.salary.entity.salarysob.po.SalarySobItemHidePO; -import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.salarysob.po.*; import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper; import com.engine.salary.service.*; import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; import com.mzlion.core.utils.BeanUtils; @@ -68,6 +71,14 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate return ServiceUtil.getService(SalaryBillItemNameServiceImpl.class, user); } + private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) { + return (SalarySobEmpFieldService) ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user); + } + + private SalarySobEmpFieldMapper getSalarySobEmpFieldMapper() { + return MapperProxyFactory.getProxy(SalarySobEmpFieldMapper.class); + } + @Override public SalaryTemplatePO getById(Long id) { return mapper.getById(id); @@ -272,6 +283,47 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate salaryTemplateNew.setId(null); salaryTemplateNew.setName(copyParam.getName()); salaryTemplateNew.setUseType(SalaryTemplateWhetherEnum.FALSE.getValue()); + + //20240122逻辑变更,拷贝工资单模板时,可变更薪资账套 + if (copyParam.getSalarySobId() != null && !copyParam.getSalarySobId().equals(salaryTemplate.getSalarySobId())) { + // 查询薪资账套的员工信息字段 + List salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(copyParam.getSalarySobId()); + List empFieldCodeList = salarySobEmpFieldPOS.stream().map(SalarySobEmpFieldPO::getFieldCode).collect(Collectors.toList()); + Map empFieldCodeWithIdMap = SalaryEntityUtil.convert2Map(salarySobEmpFieldPOS, SalarySobEmpFieldPO::getFieldCode, SalarySobEmpFieldPO::getId); + // 查询薪资账套的薪资项目副本 + List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobIdWithHideItem(copyParam.getSalarySobId()); + List salaryItemIdList = salarySobItemPOS.stream().map(SalarySobItemPO::getSalaryItemId).collect(Collectors.toList()); + //拷贝数据中的薪资项目 + List salaryItemSettingList = JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + for (SalaryTemplateSalaryItemSetListDTO salaryItemSetting : salaryItemSettingList) { + if ("111111111111111111".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null) { + List newItems = new ArrayList<>(); + for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { + SalarySobEmpFieldPO empFieldPO = getSalarySobEmpFieldMapper().getById(Long.valueOf(templateItem.getSalaryItemId())); + if (empFieldCodeList.contains(empFieldPO.getFieldCode()) && empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()) != null) { + templateItem.setId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString()); + templateItem.setSalaryItemId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString()); + newItems.add(templateItem); + } + } + salaryItemSetting.setItems(newItems); + } else { + List newItems = new ArrayList<>(); + for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { + SalarySobEmpFieldPO empFieldPO = getSalarySobEmpFieldMapper().getById(Long.valueOf(templateItem.getSalaryItemId())); + if (empFieldCodeList.contains(empFieldPO.getFieldCode()) && empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()) != null) { + templateItem.setId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString()); + templateItem.setSalaryItemId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString()); + newItems.add(templateItem); + } + } + salaryItemSetting.setItems(newItems); + } + } + List replenishSalaryItemSettingList = JSONArray.parseArray(salaryTemplate.getReplenishSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + + } + mapper.insert(salaryTemplateNew); // 复制工资单自定义名称信息 From 2d24fbfa231e1ed88f52de05ceb40f7c73f9d7b9 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Tue, 23 Jan 2024 11:34:36 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E5=9B=9E=E7=AE=97=E5=B7=A5=E8=B5=84?= =?UTF-8?q?=E5=8D=95=E5=8F=91=E6=94=BE=E5=90=8E=E4=B8=8D=E8=83=BD=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E5=9B=9E=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/entity/salaryacct/bo/SalaryAcctRecordBO.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java index 53eb473b6..e0fad94bd 100644 --- a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java @@ -73,7 +73,9 @@ public class SalaryAcctRecordBO { } else if (SalaryAcctRecordStatusEnum.ARCHIVED == salaryAcctRecordStatusEnum && ( salarySendMap.get(salaryAcctRecordPO.getId()) ==Boolean.TRUE ) ){ btnList.add(new WeaTableOperate("查看", null, "3")); btnList.add(new WeaTableOperate("重新核算", null, "4")); - btnList.add(new WeaTableOperate("回算", null, "5")); + if(salaryAcctRecordPO.getBackCalcStatus() == null || salaryAcctRecordPO.getBackCalcStatus() == NumberUtils.INTEGER_ZERO) { + btnList.add(new WeaTableOperate("回算", null, "5")); + } } else { btnList.add(new WeaTableOperate("查看", null, "3")); btnList.add(new WeaTableOperate("重新核算", null, "4")); From 2a67ca9238c65bb721f5c4abfcb1645c90994d92 Mon Sep 17 00:00:00 2001 From: sy Date: Tue, 23 Jan 2024 13:55:49 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E6=A8=A1=E6=9D=BF=EF=BC=8C=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=8A=9F=E8=83=BD=E6=94=B9=E9=80=A02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalaryTemplateServiceImpl.java | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java index cf325731f..c778138ad 100644 --- a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.salary.service.impl; +import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -294,7 +295,8 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobIdWithHideItem(copyParam.getSalarySobId()); List salaryItemIdList = salarySobItemPOS.stream().map(SalarySobItemPO::getSalaryItemId).collect(Collectors.toList()); //拷贝数据中的薪资项目 - List salaryItemSettingList = JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + List salaryItemSettingList = StrUtil.isNotBlank(salaryTemplate.getSalaryItemSetting()) + ? JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class) : new ArrayList<>(); for (SalaryTemplateSalaryItemSetListDTO salaryItemSetting : salaryItemSettingList) { if ("111111111111111111".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null) { List newItems = new ArrayList<>(); @@ -307,7 +309,20 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate } } salaryItemSetting.setItems(newItems); - } else { + } else if (salaryItemSetting.getItems() != null){ + List newItems = new ArrayList<>(); + for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { + if (salaryItemIdList.contains(Long.valueOf(templateItem.getSalaryItemId()))) { + newItems.add(templateItem); + } + } + salaryItemSetting.setItems(newItems); + } + } + List replenishSalaryItemSettingList = StrUtil.isNotBlank(salaryTemplate.getReplenishSalaryItemSetting()) + ? JSONArray.parseArray(salaryTemplate.getReplenishSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class): new ArrayList<>(); + for (SalaryTemplateSalaryItemSetListDTO salaryItemSetting : replenishSalaryItemSettingList) { + if ("111111111111111111".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null) { List newItems = new ArrayList<>(); for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { SalarySobEmpFieldPO empFieldPO = getSalarySobEmpFieldMapper().getById(Long.valueOf(templateItem.getSalaryItemId())); @@ -318,10 +333,19 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate } } salaryItemSetting.setItems(newItems); + } else if (!"333333333333333333".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null){ + List newItems = new ArrayList<>(); + for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) { + if (salaryItemIdList.contains(Long.valueOf(templateItem.getSalaryItemId()))) { + newItems.add(templateItem); + } + } + salaryItemSetting.setItems(newItems); } } - List replenishSalaryItemSettingList = JSONArray.parseArray(salaryTemplate.getReplenishSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); - + salaryTemplateNew.setSalaryItemSetting(salaryItemSettingList.size() > 0 ? JSONUtil.toJsonStr(salaryItemSettingList) : ""); + salaryTemplateNew.setReplenishSalaryItemSetting(replenishSalaryItemSettingList.size() > 0 ? JSONUtil.toJsonStr(replenishSalaryItemSettingList) : ""); + salaryTemplateNew.setSalarySobId(copyParam.getSalarySobId()); } mapper.insert(salaryTemplateNew); From 60e792d4813f69bac11a4b523584b5d8e7c8078a Mon Sep 17 00:00:00 2001 From: sy Date: Tue, 23 Jan 2024 14:46:29 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E5=8F=B0=E8=B4=A6=EF=BC=8C=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=A0=B8=E7=AE=97=E5=B9=B6=E5=BD=92=E6=A1=A3=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/timer/AutoSiAccountAndFileJob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java b/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java index 646024f3d..47dd04994 100644 --- a/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java +++ b/src/com/engine/salary/timer/AutoSiAccountAndFileJob.java @@ -70,7 +70,7 @@ public class AutoSiAccountAndFileJob extends BaseCronJob { @Override public void execute() { - if (StrUtil.isNotBlank(diffToCurrentMonth) && RegularUtil.isInteger(diffToCurrentMonth)) { + if (StrUtil.isNotBlank(diffToCurrentMonth) && (RegularUtil.isInteger(diffToCurrentMonth) || "0".equals(diffToCurrentMonth))) { User user = new User(); user.setUid(1); user.setLoginid("sysadmin"); From 71f90882d32d006f84b5524c264495514d84f207 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Tue, 23 Jan 2024 16:45:09 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=E5=8C=BA=E5=88=86pc=E5=92=8C=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/salaryBill/bo/SalaryTemplateBO.java | 1 + .../salaryBill/dto/SalaryBillAckFeedbackDTO.java | 6 ++++++ .../salaryBill/dto/SalaryTemplateBaseSetDTO.java | 6 ++++++ .../param/SalaryTemplateSaveParam.java | 5 +++++ .../entity/salaryBill/po/SalaryTemplatePO.java | 7 +++++++ .../mapper/salarybill/SalaryTemplateMapper.xml | 16 ++++++++++++++++ .../impl/SalaryBillBaseSetServiceImpl.java | 7 ++++++- .../service/impl/SalarySendServiceImpl.java | 5 +++++ .../service/impl/SalaryTemplateServiceImpl.java | 1 + .../salary/sys/constant/SalarySysConstant.java | 5 +++++ .../salary/wrapper/SalaryTemplateWrapper.java | 1 + 11 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/com/engine/salary/entity/salaryBill/bo/SalaryTemplateBO.java b/src/com/engine/salary/entity/salaryBill/bo/SalaryTemplateBO.java index cd7af96ba..32fd9f0d6 100644 --- a/src/com/engine/salary/entity/salaryBill/bo/SalaryTemplateBO.java +++ b/src/com/engine/salary/entity/salaryBill/bo/SalaryTemplateBO.java @@ -80,6 +80,7 @@ public class SalaryTemplateBO { .ackFeedbackStatus(saveParam.getAckFeedbackStatus()?1:0) .autoAckDays(saveParam.getAutoAckDays()) .feedbackUrl(saveParam.getFeedbackUrl()) + .mobileFeedbackUrl(saveParam.getMobileFeedbackUrl()) .createTime(new Date()) .updateTime(new Date()) .creator(employeeId) diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java index 340e97387..767d6ccac 100644 --- a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java @@ -27,6 +27,12 @@ public class SalaryBillAckFeedbackDTO { */ private String feedBackUrl; + + /** + * 移动端反馈地址 + */ + private String mobileFeedBackUrl; + /** * 超时自动确认天数 */ diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseSetDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseSetDTO.java index 3f76a30a8..47f4eb854 100644 --- a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseSetDTO.java +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateBaseSetDTO.java @@ -92,4 +92,10 @@ public class SalaryTemplateBaseSetDTO { * */ private String feedbackUrl; + + /** + * 移动端反馈流程地址 + * + */ + private String mobileFeedbackUrl; } diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateSaveParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateSaveParam.java index 7f13c13c6..df1996e6d 100644 --- a/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateSaveParam.java +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryTemplateSaveParam.java @@ -110,6 +110,11 @@ public class SalaryTemplateSaveParam { */ private String feedbackUrl; + /** + * 移动端反馈流程地址 + */ + private String mobileFeedbackUrl; + List salaryBillItemNameSetting; public static void checkParam(SalaryTemplateSaveParam saveParam) { diff --git a/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java b/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java index a428a68ed..5ffcbaf24 100644 --- a/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java +++ b/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java @@ -192,6 +192,13 @@ public class SalaryTemplatePO { private String feedbackUrl; + /** + * 移动端反馈流程地址 + * + */ + private String mobileFeedbackUrl; + + private Collection salarySobIds; } diff --git a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml index 17e371c33..07898826c 100644 --- a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml +++ b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml @@ -92,6 +92,7 @@ ack_feedback_status, auto_ack_days, feedback_url, + mobile_feedback_url, create_time, update_time, creator, @@ -534,6 +535,9 @@ feedback_url=#{feedbackUrl}, + + mobile_feedback_url=#{mobileFeedbackUrl}, + create_time=#{createTime}, @@ -636,6 +640,9 @@ feedback_url, + + mobile_feedback_url, + create_time, @@ -734,6 +741,9 @@ #{feedbackUrl}, + + #{mobileFeedbackUrl}, + #{createTime}, @@ -842,6 +852,9 @@ feedback_url, + + mobile_feedback_url, + create_time, @@ -940,6 +953,9 @@ #{feedbackUrl}, + + #{mobileFeedbackUrl}, + #{createTime}, diff --git a/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java index e5f6d51d3..5cafea060 100644 --- a/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java @@ -100,6 +100,7 @@ public class SalaryBillBaseSetServiceImpl extends Service implements SalaryBillB if (StringUtils.equals(ackFeedbackSetting.getAckStatus(), "1")) { // 2.保存反馈地址 getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getFeedBackUrl(), SALARY_FEEDBACK_URL, "工资单反馈地址", "billSend"); + getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getMobileFeedBackUrl(), SALARY_FEEDBACK_URL_MOBILE, "移动端工资单反馈地址", "billSend"); // 3.保存自动确认时间 getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getAutoAckDays().toString(), SALARY_AUTO_ACK_DAYS, "工资单反馈自动确认", "billSend"); } @@ -126,7 +127,7 @@ public class SalaryBillBaseSetServiceImpl extends Service implements SalaryBillB @Override public SalaryBillAckFeedbackDTO getDefaultAckFeedbackSetting() { // 获取反馈开启状态、自动确认时长、反馈地址 - List codes = Arrays.asList(SalarySysConstant.SALARY_SEND_FEEDBACK, SalarySysConstant.SALARY_AUTO_ACK_DAYS, SalarySysConstant.SALARY_FEEDBACK_URL); + List codes = Arrays.asList(SalarySysConstant.SALARY_SEND_FEEDBACK, SalarySysConstant.SALARY_AUTO_ACK_DAYS, SalarySysConstant.SALARY_FEEDBACK_URL, SALARY_FEEDBACK_URL_MOBILE); List sysConfList = getSalarySysConfService(user).getListByCodes(codes); Map sysConfMap = SalaryEntityUtil.convert2Map(sysConfList, SalarySysConfPO::getConfKey, SalarySysConfPO::getConfValue); @@ -137,6 +138,7 @@ public class SalaryBillBaseSetServiceImpl extends Service implements SalaryBillB defaultAckFeedBackDTO.setAckStatus("0"); defaultAckFeedBackDTO.setAutoAckDays(0); defaultAckFeedBackDTO.setFeedBackUrl("/"); + defaultAckFeedBackDTO.setMobileFeedBackUrl("/"); return defaultAckFeedBackDTO; } defaultAckFeedBackDTO.setAckStatus(ackStatus); @@ -146,6 +148,9 @@ public class SalaryBillBaseSetServiceImpl extends Service implements SalaryBillB // 反馈地址 String feedbackUrl = sysConfMap.getOrDefault(SalarySysConstant.SALARY_FEEDBACK_URL, ""); defaultAckFeedBackDTO.setFeedBackUrl(feedbackUrl); + + String mobileFeedbackUrl = sysConfMap.getOrDefault(SALARY_FEEDBACK_URL_MOBILE, ""); + defaultAckFeedBackDTO.setMobileFeedBackUrl(mobileFeedbackUrl); return defaultAckFeedBackDTO; } diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 20cb9f176..2a5f9b688 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -524,6 +524,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService } SalaryTemplatePO salaryTemplate = buildSalaryTemplateContent(salaryTemplateContent); + if (StringUtils.isNotBlank(salaryTemplate.getFeedbackUrl()) && StringUtils.isBlank(salaryTemplate.getMobileFeedbackUrl())) { + // 如果设置了pc反馈地址,没有设置移动端反馈地址,则移动端反馈地址默认等于pc反馈地址 + salaryTemplate.setMobileFeedbackUrl(salaryTemplate.getFeedbackUrl()); + } // 判断是否是补发 boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySendInfo.getSalaryAcctType()); @@ -826,6 +830,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService .ackFeedbackStatus(Integer.valueOf(map.getOrDefault("ackFeedbackStatus", "0").toString())) .autoAckDays(Integer.valueOf(map.getOrDefault("autoAckDays", "0").toString())) .feedbackUrl(map.getOrDefault("feedbackUrl", "").toString()) + .feedbackUrl(map.getOrDefault("mobileFeedbackUrl", "").toString()) .name(map.getOrDefault("name", "").toString()) .salarySobId(Long.valueOf(map.getOrDefault("salarySobId", "0").toString())) .useType(Integer.valueOf(map.getOrDefault("useType", "0").toString())) diff --git a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java index 591261abb..df24535aa 100644 --- a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java @@ -217,6 +217,7 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate salaryTemplateNew.setAckFeedbackStatus(saveParam.getAckFeedbackStatus() ? 1 : 0); salaryTemplateNew.setAutoAckDays(saveParam.getAutoAckDays()); salaryTemplateNew.setFeedbackUrl(saveParam.getFeedbackUrl()); + salaryTemplateNew.setMobileFeedbackUrl(saveParam.getMobileFeedbackUrl()); // todo 薪资项目设置检查校验 salaryTemplateNew.setSalaryItemSetting(saveParam.getSalaryItemSetting() != null ? JSONUtil.toJsonStr(saveParam.getSalaryItemSetting()) : ""); salaryTemplateNew.setReplenishSalaryItemSetting(saveParam.getReplenishSalaryItemSetting() != null ? JSONUtil.toJsonStr(saveParam.getReplenishSalaryItemSetting()) : ""); diff --git a/src/com/engine/salary/sys/constant/SalarySysConstant.java b/src/com/engine/salary/sys/constant/SalarySysConstant.java index afe54d3c0..081702d22 100644 --- a/src/com/engine/salary/sys/constant/SalarySysConstant.java +++ b/src/com/engine/salary/sys/constant/SalarySysConstant.java @@ -96,6 +96,11 @@ public class SalarySysConstant { */ public static final String SALARY_FEEDBACK_URL = "SALARY_FEEDBACK_URL"; + /** + * 工资单反馈地址-移动端 + */ + public static final String SALARY_FEEDBACK_URL_MOBILE = "SALARY_FEEDBACK_URL_MOBILE"; + /** * 工资单查询限制 */ diff --git a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java index 6149b500e..22aac4134 100644 --- a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java @@ -199,6 +199,7 @@ public class SalaryTemplateWrapper extends Service { salaryTemplateBaseSetDTO.setAckFeedbackStatus(StringUtils.equals(defaultAckFeedback.getAckStatus(), "1")); salaryTemplateBaseSetDTO.setAutoAckDays(defaultAckFeedback.getAutoAckDays()); salaryTemplateBaseSetDTO.setFeedbackUrl(defaultAckFeedback.getFeedBackUrl()); + salaryTemplateBaseSetDTO.setMobileFeedbackUrl(defaultAckFeedback.getMobileFeedBackUrl()); } Map salaryTemplateBase = new HashMap<>(); salaryTemplateBase.put("data", salaryTemplateBaseSetDTO); From 4da07b9e8071a3229819860fa5ebe9aa4552b57b Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 24 Jan 2024 14:35:55 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=E3=80=81=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?=EF=BC=8C=E5=9F=BA=E6=95=B0=E8=B0=83=E6=95=B4=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2=E5=A2=9E=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E6=9D=83=EF=BC=8C=E5=8F=B0=E8=B4=A6=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81=E4=B8=AA=E7=A8=8E=E6=89=A3=E7=BC=B4?= =?UTF-8?q?=E4=B9=89=E5=8A=A1=E4=BA=BA=E5=A4=9A=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salaryBill/dto/SalaryTemplateListDTO.java | 3 +++ .../mapper/salarybill/SalaryTemplateMapper.xml | 9 ++++++--- .../salary/service/impl/SIAccountServiceImpl.java | 4 +++- .../salary/service/impl/SIArchivesServiceImpl.java | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java index 60182ae3f..887f36905 100644 --- a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java @@ -54,4 +54,7 @@ public class SalaryTemplateListDTO { @SalaryTableColumn(text = "备注", width = "20%", column = "description") @TableTitle(title = "备注", dataIndex = "description", key = "description") private String description; + + // 薪资账套id + private Long salarySobId; } diff --git a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml index 17e371c33..9912f302d 100644 --- a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml +++ b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml @@ -366,7 +366,8 @@ t.replenish_name as replenishName, s.name as salarysob, t.use_type as useType, - t.description + t.description, + t.salary_sob_id from hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id where t.delete_type = 0 @@ -398,7 +399,8 @@ t.replenish_name as replenishName, s.name as salarysob, t.use_type as useType, - t.description + t.description, + t.salary_sob_id from hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id where t.delete_type = 0 @@ -430,7 +432,8 @@ t.replenish_name as replenishName, s.name as salarysob, t.use_type as useType, - t.description + t.description, + t.salary_sob_id from hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id where t.delete_type = 0 diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index 43168124a..8b8da3b77 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -232,6 +232,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { Long employeeId = (long) user.getUID(); Map datas = new HashMap<>(); + List paymentOrganizationIds = queryParam.getTaxAgents(); // 分权逻辑 Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); if (needAuth) { @@ -240,7 +241,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { if (CollectionUtils.isEmpty(taxAgents)) { //防止普通用户查询 queryParam.setTaxAgents(Collections.singletonList(-1L)); - } else { + } else if (paymentOrganizationIds != null && paymentOrganizationIds.size() > 0){ + taxAgents.retainAll(paymentOrganizationIds); queryParam.setTaxAgents(taxAgents); } } diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 8738c66f9..071dde24e 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -1159,6 +1159,20 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService public PageInfo historyListByEmployeeIdAndOperator(SIArchiveBaseHistoryListParam param) { List adjustHistoryDTOS = siArchivesBiz.getBaseHistoryByEmployeeIdAndOperator(param.getOperator(), param.getEmployeeId()); + + // 分权逻辑 + Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); + if (needAuth) { + Collection taxAgentPOS = getTaxAgentService(user).listAllTaxAgents((long) user.getUID()); + List taxAgents = taxAgentPOS.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(taxAgents)) { + //防止普通用户查询 + adjustHistoryDTOS = new ArrayList<>(); + } else { + adjustHistoryDTOS = adjustHistoryDTOS.stream().filter(f -> taxAgents.contains(f.getPaymentOrganization())).collect(Collectors.toList()); + } + } + adjustHistoryDTOS.forEach(f -> { if (StringUtils.isNotBlank(f.getPaymentScope())) { if(f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_PERSON.getValue().toString())) { From e92e134d2136d22b8200cc038b8c1c0705c2e479 Mon Sep 17 00:00:00 2001 From: sy Date: Thu, 25 Jan 2024 11:41:35 +0800 Subject: [PATCH 09/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E6=A8=A1=E6=9D=BF=EF=BC=8C=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=8A=9F=E8=83=BD=E6=94=B9=E9=80=A0=EF=BC=8C=E8=A1=A5?= =?UTF-8?q?=E5=8F=91=E5=B7=A5=E8=B5=84=E5=8D=95=E6=A8=A1=E6=9D=BF=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/salary/service/impl/SalaryTemplateServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java index c778138ad..cd7b1bc8e 100644 --- a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java @@ -28,6 +28,7 @@ import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper; import com.engine.salary.service.*; 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.SalaryPageUtil; @@ -283,6 +284,7 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate BeanUtils.copyProperties(salaryTemplate, salaryTemplateNew); salaryTemplateNew.setId(null); salaryTemplateNew.setName(copyParam.getName()); + salaryTemplateNew.setReplenishName(copyParam.getName() + "-" + SalaryI18nUtil.getI18nLabel(0, "补发工资单")); salaryTemplateNew.setUseType(SalaryTemplateWhetherEnum.FALSE.getValue()); //20240122逻辑变更,拷贝工资单模板时,可变更薪资账套 From 78f96c5008d4f6ef6e53d1432740aae2a693374a Mon Sep 17 00:00:00 2001 From: sy Date: Thu, 25 Jan 2024 13:37:35 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=EF=BC=8C=E6=8B=89=E5=8F=9620240101=E5=88=86=E6=94=AF=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=86=85=E5=AE=B9=EF=BC=8C=E5=B9=B6=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/service/impl/SIAccountServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index 0095dcbf2..857196426 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -67,7 +67,6 @@ import com.google.common.collect.Maps; import com.mzlion.core.utils.BeanUtils; import com.engine.salary.util.db.IdGenerator; import com.wbi.util.StringUtil; -import dm.jdbc.util.IdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.math.NumberUtils; @@ -76,7 +75,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.springframework.beans.BeanUtils; import weaver.file.ImageFileManager; import weaver.general.Util; import weaver.hrm.User; From f215b45afaab663c07377a2f5267c1539f22de02 Mon Sep 17 00:00:00 2001 From: sy Date: Fri, 26 Jan 2024 10:04:53 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E6=A8=A1=E6=9D=BF=EF=BC=8C=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=8A=9F=E8=83=BD=E6=94=B9=E9=80=A0=EF=BC=8C=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=B8=A6=E9=80=89=E6=8B=A9=E8=96=AA=E8=B5=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E9=80=BB=E8=BE=91=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/SalaryBillSalaryItemQueryParam.java | 2 ++ .../entity/salarysob/po/SalarySobItemGroupPO.java | 2 +- .../salary/wrapper/SalaryTemplateWrapper.java | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryItemQueryParam.java b/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryItemQueryParam.java index 26c819771..fa5540965 100644 --- a/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryItemQueryParam.java +++ b/src/com/engine/salary/entity/salaryBill/param/SalaryBillSalaryItemQueryParam.java @@ -16,6 +16,8 @@ public class SalaryBillSalaryItemQueryParam extends BaseQueryParam { private Long groupId; + private String groupName; + private Boolean isReplenish; private List existSalaryItemIds; diff --git a/src/com/engine/salary/entity/salarysob/po/SalarySobItemGroupPO.java b/src/com/engine/salary/entity/salarysob/po/SalarySobItemGroupPO.java index 4a6b5502a..64ef8a52f 100644 --- a/src/com/engine/salary/entity/salarysob/po/SalarySobItemGroupPO.java +++ b/src/com/engine/salary/entity/salarysob/po/SalarySobItemGroupPO.java @@ -34,7 +34,7 @@ public class SalarySobItemGroupPO { private Long salarySobId; /** - * 薪资账套的名称 + * 薪资账套中薪资项目分组的名称 */ private String name; diff --git a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java index 6149b500e..a1d54e5da 100644 --- a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java @@ -9,16 +9,19 @@ import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO; import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO; import com.engine.salary.entity.salarysob.po.SalarySobPO; import com.engine.salary.enums.salarybill.SalaryTemplateReplenishRuleEnum; import com.engine.salary.enums.salarybill.SalaryTemplateVarEnum; import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salarysob.SalarySobItemGroupMapper; import com.engine.salary.service.*; import com.engine.salary.service.impl.*; import com.engine.salary.util.JsonUtil; 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.mzlion.core.utils.BeanUtils; import org.apache.commons.collections4.CollectionUtils; @@ -71,6 +74,10 @@ public class SalaryTemplateWrapper extends Service { return ServiceUtil.getService(SalaryBillItemNameServiceImpl.class, user); } + private SalarySobItemGroupMapper getSalarySobItemGroupMapper() { + return MapperProxyFactory.getProxy(SalarySobItemGroupMapper.class); + } + /** * 工资单模板列表 * @@ -479,7 +486,13 @@ public class SalaryTemplateWrapper extends Service { Boolean isReplenish = Optional.ofNullable(param.getIsReplenish()).orElse(false); List salaryItemSet = getSalaryTemplateService(user).getSalaryItemSetContainHide(param.getSalarySobId(), param.getSalaryTemplateId(), isReplenish); Long groupId = param.getGroupId(); - return salaryItemSet.stream().filter(s -> Objects.equals(s.getGroupId(), groupId + "")).map(SalaryTemplateSalaryItemSetListDTO::getItems).findFirst().orElse(Collections.emptyList()).stream().filter(item -> !Optional.ofNullable(param.getExistSalaryItemIds()).orElse(Collections.emptyList()).contains(item.getId())).collect(Collectors.toList()); + //工资单模板copy可能导致groupId不匹配 + List salarySobItemGroupPOS = getSalarySobItemGroupMapper().listSome(SalarySobItemGroupPO.builder().salarySobId(param.getSalarySobId()).name(param.getGroupName()).build()); + if (salarySobItemGroupPOS != null && salarySobItemGroupPOS.size() > 0) { + groupId = salarySobItemGroupPOS.get(0).getId(); + } + Long finalGroupId = groupId; + return salaryItemSet.stream().filter(s -> Objects.equals(s.getGroupId(), finalGroupId + "")).map(SalaryTemplateSalaryItemSetListDTO::getItems).findFirst().orElse(Collections.emptyList()).stream().filter(item -> !Optional.ofNullable(param.getExistSalaryItemIds()).orElse(Collections.emptyList()).contains(item.getId())).collect(Collectors.toList()); } /** From c4adecf436dc5cd1b2dbc93f2d3879b55e51a8d9 Mon Sep 17 00:00:00 2001 From: sy Date: Mon, 29 Jan 2024 11:30:04 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E5=87=8F=E5=91=98?= =?UTF-8?q?action=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/StayDelToStopSIArchiveAction.java | 19 +++++++++- .../salary/service/SIArchivesService.java | 5 +++ .../service/impl/SIArchivesServiceImpl.java | 38 +++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/com/engine/salary/action/StayDelToStopSIArchiveAction.java b/src/com/engine/salary/action/StayDelToStopSIArchiveAction.java index c7aa0a8bf..1c75d42c0 100644 --- a/src/com/engine/salary/action/StayDelToStopSIArchiveAction.java +++ b/src/com/engine/salary/action/StayDelToStopSIArchiveAction.java @@ -1,14 +1,18 @@ package com.engine.salary.action; +import cn.hutool.core.util.StrUtil; import com.engine.common.util.ServiceUtil; import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.siaccount.EmployeeStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; import com.engine.salary.mapper.taxagent.TaxAgentMapper; import com.engine.salary.service.SIArchivesService; import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -84,6 +88,12 @@ public class StayDelToStopSIArchiveAction implements Action { Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() ); Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString()); + String payEndYearMonth = importDataMap.getOrDefault("最后缴纳月", "").toString(); + if (StrUtil.isNotBlank(payEndYearMonth) && !SalaryDateUtil.checkYearMonth(payEndYearMonth)) { + requestInfo.getRequestManager().setMessage("最后缴纳月格式有误,正确格式示例为'2021-01'"); + return FAILURE_AND_CONTINUE; + } + //操作人 String uid = importDataMap.getOrDefault("操作人","1").toString(); User user = new User(Integer.parseInt(uid)); @@ -92,12 +102,17 @@ public class StayDelToStopSIArchiveAction implements Action { if(insuranceArchivesBaseInfoPO == null){ requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在福利档案,请检查后重试!"); return FAILURE_AND_CONTINUE; - } else if(!insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())){ + } else if(StrUtil.isBlank(payEndYearMonth) && !insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())){ requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工的福利档案状态不是待减员,无法进行减员操作,请检查后重试!"); return FAILURE_AND_CONTINUE; } //减员 - Map resultMap = getSIArchivesService(user).stayDelToStop(Collections.singletonList(insuranceArchivesBaseInfoPO.getId())); + Map resultMap = new HashMap<>(); + if (StrUtil.isBlank(payEndYearMonth)) { + resultMap = getSIArchivesService(user).stayDelToStop(Collections.singletonList(insuranceArchivesBaseInfoPO.getId())); + } else { + resultMap = getSIArchivesService(user).stopWithoutLimit(Collections.singletonList(insuranceArchivesBaseInfoPO.getId()), payEndYearMonth); + } if (resultMap.get("type").toString().equals("fail")) { requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString()); return FAILURE_AND_CONTINUE; diff --git a/src/com/engine/salary/service/SIArchivesService.java b/src/com/engine/salary/service/SIArchivesService.java index 3e98c15d3..0bdc90cd9 100644 --- a/src/com/engine/salary/service/SIArchivesService.java +++ b/src/com/engine/salary/service/SIArchivesService.java @@ -74,6 +74,11 @@ public interface SIArchivesService { */ Map stayDelToStop(Collection ids); + /** + * 批量减员,直接减员,并给予最后缴纳月 + */ + Map stopWithoutLimit(Collection ids, String yearMonth); + /** * 全量减员 */ diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 8738c66f9..6e1f5e94a 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -876,6 +876,44 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return resultMap; } + @Override + public Map stopWithoutLimit(Collection ids, String yearMonth) { + + if (CollectionUtils.isEmpty(ids)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); + } + List baseInfoPOList = getInsuranceBaseInfoMapper().listByIds(ids); + + //分别新建福利档案基础信息相关的社保、公积金、其他福利档案列表 + List socialList = new ArrayList<>(); + List fundList = new ArrayList<>(); + List otherList = new ArrayList<>(); + //获取待处理的福利档案基础信息id列表 + List baseInfoIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + //分别获取福利档案基础信息相关的社保、公积金、其他福利档案id列表 + List socialIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList()); + List fundIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList()); + List otherIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList()); + //进行减员操作 + if (baseInfoIds.size() > 0) { + getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder() + .ids(baseInfoIds).runStatus(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()).build()); + + getSocialSchemeMapper().batchUpdateEndTime(socialIds, yearMonth); + getFundSchemeMapper().batchUpdateEndTime(fundIds, yearMonth); + getOtherSchemeMapper().batchUpdateEndTime(otherIds, yearMonth); + } + + + Map resultMap = new HashMap<>(2); + String resultMsg = "操作成功"; + String resultType = "success"; + + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } + /** * 全量减员 */ From 65f972846faca8d235811c2f0b5cb80ef38928e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 30 Jan 2024 10:26:44 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=E5=A4=84=E7=90=86id=E8=B6=85=E8=BF=87210?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/SalaryAcctEmployeeQueryParam.java | 2 +- .../impl/SalaryAcctEmployeeServiceImpl.java | 27 +++++++++++++++++-- .../impl/SalaryAcctResultServiceImpl.java | 6 ++--- .../SalaryComparisonResultServiceImpl.java | 2 +- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeQueryParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeQueryParam.java index cfe97aae9..81266c2d3 100644 --- a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeQueryParam.java +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctEmployeeQueryParam.java @@ -57,7 +57,7 @@ public class SalaryAcctEmployeeQueryParam extends BaseQueryParam { private LocalDateRange dismissDate; //薪资核算人员列表主键id") - private Collection ids; + private List ids; private String workcode; } diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java index a0da13747..2991cf398 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.salary.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import com.api.formmode.mybatis.util.SqlProxyHandle; import com.engine.common.util.ServiceUtil; @@ -288,7 +289,7 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct List salaryAcctEmployeePOS = listByParam(queryParam); Set keySet = SalaryEntityUtil.properties(salaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()); List resultList = Lists.newArrayList(); - if(CollectionUtils.isNotEmpty(keySet)){ + if (CollectionUtils.isNotEmpty(keySet)) { lastMonthSalaryAcctEmployeePOMap.forEach((k, v) -> { if (!keySet.contains(k)) { resultList.add(v); @@ -336,7 +337,18 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct // 查询合并计税的薪资核算人员 Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); // 分页参数 - List salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam); + List salaryAcctEmployeePOS = new ArrayList<>(); + if (CollUtil.isNotEmpty(queryParam.getIds())) { + List list = new ArrayList<>(); + List> partition = Lists.partition(queryParam.getIds(), 500); + partition.forEach(ids -> { + queryParam.setIds(ids); + list.addAll(getSalaryAcctEmployeeMapper().list4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam)); + }); + salaryAcctEmployeePOS = list; + } else { + salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam); + } return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryAcctEmployeePOS, SalaryAcctEmployeePO.class); } @@ -353,6 +365,17 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct } // 查询合并计税的薪资核算人员 Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); + + List list = new ArrayList<>(); + if (CollUtil.isNotEmpty(queryParam.getIds())) { + List> partition = Lists.partition(queryParam.getIds(), 500); + partition.forEach(ids -> { + queryParam.setIds(ids); + list.addAll(getSalaryAcctEmployeeMapper().list4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam)); + }); + return list; + } + return getSalaryAcctEmployeeMapper().list4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam); } diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java index 6fcd32486..6cf502c44 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java @@ -355,7 +355,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe //其他条件 List otherConditions = queryParam.getOtherConditions(); - if(CollectionUtils.isNotEmpty(otherConditions)){ + if (CollectionUtils.isNotEmpty(otherConditions)) { List items = SalaryEntityUtil.properties(otherConditions, SalaryAcctResultQueryParam.OtherCondition::getItemId, Collectors.toList()); List list = listBySalaryAcctRecordIdsAndSalaryItemIds(Collections.singletonList(queryParam.getSalaryAcctRecordId()), items); for (int i = 0; i < otherConditions.size(); i++) { @@ -470,7 +470,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId); } else { // 如果查询条件中没有包含"合并计税",那么就需要查询出存在合并计税的人,标记给前端 - SalaryAcctEmployeeQueryParam accEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryAcctRecordId(queryParam.getSalaryAcctRecordId()).ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId)).build(); + SalaryAcctEmployeeQueryParam accEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryAcctRecordId(queryParam.getSalaryAcctRecordId()).ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList())).build(); List salaryAcctEmployeePOS4ConsolidatedTax = getSalaryAcctEmployeeService(user).listByParam4ConsolidatedTax(accEmployeeQueryParam); salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId); } @@ -1191,7 +1191,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe batchSave(needInsertList); // 报表入库前先删除 - getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(param.getIdList(), Collections.singletonList(param.getSalaryItemId()) ); + getSalaryAcctReportService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(param.getIdList(), Collections.singletonList(param.getSalaryItemId())); getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS); } diff --git a/src/com/engine/salary/service/impl/SalaryComparisonResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryComparisonResultServiceImpl.java index 25e926aaf..3f3c3fd71 100644 --- a/src/com/engine/salary/service/impl/SalaryComparisonResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryComparisonResultServiceImpl.java @@ -215,7 +215,7 @@ public class SalaryComparisonResultServiceImpl extends Service implements Salary } else { SalaryAcctEmployeeQueryParam accEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder() .salaryAcctRecordId(queryParam.getSalaryAcctRecordId()) - .ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId)) + .ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId, Collectors.toList())) .build(); List salaryAcctEmployeePOS4ConsolidatedTax = getSalaryAcctEmployeeService(user).listByParam4ConsolidatedTax(accEmployeeQueryParam); salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId); From e5a0a8517988b89649d868dd53a1e08b0a081dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 30 Jan 2024 11:18:54 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=96=AA?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0=EF=BC=8C=E6=99=8B=E5=8D=87=E3=80=81=E9=99=8D?= =?UTF-8?q?=E8=81=8C=E3=80=81=E8=B0=83=E5=B2=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SalaryArchiveItemAdjustReasonEnum.java | 3 + .../impl/SalaryArchiveExcelServiceImpl.java | 2 +- src/com/engine/salary/util/EnumUtil.java | 357 ++++++++++++++++++ 3 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 src/com/engine/salary/util/EnumUtil.java diff --git a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveItemAdjustReasonEnum.java b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveItemAdjustReasonEnum.java index 373999a91..fb3f761cc 100644 --- a/src/com/engine/salary/enums/salaryarchive/SalaryArchiveItemAdjustReasonEnum.java +++ b/src/com/engine/salary/enums/salaryarchive/SalaryArchiveItemAdjustReasonEnum.java @@ -19,6 +19,9 @@ public enum SalaryArchiveItemAdjustReasonEnum implements BaseEnum { ONBOARD("ONBOARD", "入职", 85901), PROBATION_REVIEW("PROBATION_REVIEW", "转正", 85984), SALARY_ADJUSTMENT("SALARY_ADJUSTMENT", "调薪", 85985), + PROMOTION("SALARY_ADJUSTMENT", "晋升", 85985), + DEMOTION("SALARY_ADJUSTMENT", "降职", 85985), + JOB_TRANSFER("SALARY_ADJUSTMENT", "调岗", 85985), POSITION_OR_SALARY_ADJUSTMENT("POSITION_OR_SALARY_ADJUSTMENT", "调岗调薪", 85986), DIMISSION("DIMISSION", "离职", 85902), OTHER("OTHER", "其他", 84500), diff --git a/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java index 87137b0e8..001f5ee36 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java @@ -404,7 +404,7 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch excelComments.add(new ExcelComment(7, 0, 9, 2, SalaryI18nUtil.getI18nLabel(100458, "格式样例为'2022-01-01'、'2022/1/1'"))); excelComments.add(new ExcelComment(8, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'"))); } else if (isSalaryItemAdjust) { - excelComments.add(new ExcelComment(6, 0, 8, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,可填写如:入职,转正,调薪,调岗调薪,离职,其他,初始化"))); + excelComments.add(new ExcelComment(6, 0, 8, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,可填写如:入职,转正,调薪,晋升,降职,调岗,调岗调薪,离职,其他,初始化"))); excelComments.add(new ExcelComment(7, 0, 9, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'"))); } } else if (isSuspendList) { diff --git a/src/com/engine/salary/util/EnumUtil.java b/src/com/engine/salary/util/EnumUtil.java new file mode 100644 index 000000000..aad5269e0 --- /dev/null +++ b/src/com/engine/salary/util/EnumUtil.java @@ -0,0 +1,357 @@ +package com.engine.salary.util; + + +import lombok.extern.slf4j.Slf4j; +import sun.reflect.ConstructorAccessor; +import sun.reflect.FieldAccessor; +import sun.reflect.MethodAccessor; +import sun.reflect.ReflectionFactory; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@Slf4j +public class EnumUtil { + + /** + * 扩展枚举(把新枚举的值加入旧枚举里,从旧枚举里删除不要的枚举值) + * @param oldEnumClass 旧枚举类 + * @param newEnumClass 需要扩展的枚举类 + * @param removeOldEnums 需要删除的旧枚举值 + * @param + * @param + * @throws Exception + */ + public static void extendEnum(Class oldEnumClass,Class newEnumClass,O... removeOldEnums) throws Exception { + boolean needToRemoveOldEnum = removeOldEnums!=null&&removeOldEnums.length>0; + if(needToRemoveOldEnum){ + removeEnum(oldEnumClass,removeOldEnums); + } + List newEnums = values(newEnumClass); + Field[] fields = getFields(newEnumClass); + for (Object newEnumObject : newEnums) { + Enum newEnum = Enum.class.cast(newEnumObject); + + List fieldTypeList = new ArrayList<>(); + //枚举名称的类型:String.class + fieldTypeList.add(String.class); + for (Field field : fields) { + fieldTypeList.add(field.getType()); + } + List fieldValueList = new ArrayList<>(); + //枚举名称 + fieldValueList.add(newEnum.name()); + for (Field field : fields) { + Object value = field.get(newEnum); + fieldValueList.add(value); + } + + Class[] fieldTypes = fieldTypeList.toArray(new Class[]{}); + String[] fieldValues = fieldValueList.toArray(new String[]{}); + addEnum(oldEnumClass,fieldTypes,fieldValues); + } + } + + /** + * 新增枚举值 + * @param enumClass 枚举类型 + * @param fieldTypes 字段的类型,第一个是枚举名类型String + * @param fieldValues 字段的值,第一个是枚举名称 + * @throws Exception + */ + public static > T addEnum(Class enumClass, Class[] fieldTypes, Object[] fieldValues) throws Exception { + if(fieldTypes==null||fieldTypes.length==0){ + throw new RuntimeException("参数fieldTypes为空"); + } + if(fieldValues==null||fieldValues.length==0){ + throw new RuntimeException("参数fieldValues为空"); + } + if(fieldTypes[0]!=String.class){ + throw new RuntimeException("参数fieldTypes[0]不是String.class"); + } + if(!(fieldValues[0] instanceof String)){ + throw new RuntimeException("参数fieldValues[0]不是字符串"); + } + if(fieldTypes.length!=fieldValues.length){ + throw new RuntimeException("参数fieldTypes和参数fieldValues的长度不一致"); + } + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + String enumName = fieldValues[0].toString(); + synchronized (enumClass){ + //判断name是否已经添加过了 + if(hasEnumName(enumClass,enumName)){ + log.info("枚举类{}中已存在该枚举名:{}",enumClass.getSimpleName(),enumName); + return getEnum(enumClass,enumName); + } + //name,ordinal,其他自定义字段 + List allFieldClass = new ArrayList<>(fieldTypes.length + 1); + allFieldClass.add(String.class); + allFieldClass.add(int.class); + for (int i = 1; i < fieldTypes.length; i++) { + allFieldClass.add(fieldTypes[i]); + } + Class[] classes = allFieldClass.toArray(new Class[]{}); + Constructor constructor = enumClass.getDeclaredConstructor(classes); + ConstructorAccessor constructorAccessor = reflectionFactory.newConstructorAccessor(constructor); + List allFields = new ArrayList<>(fieldValues.length + 1); + allFields.add(enumName); + int maxOrdinal = getMaxOrdinal(enumClass); + allFields.add(maxOrdinal+1); + for (int i = 1; i < fieldValues.length; i++) { + allFields.add(fieldValues[i]); + } + //调用枚举的构造方法,创建新的枚举值 + T newEnum = (T) constructorAccessor.newInstance(allFields.toArray()); + log.info("新增枚举:{}" , newEnum); + Field valuesField = enumClass.getDeclaredField("$VALUES"); + valuesField.setAccessible(true); + + //解除values属性的final限制 + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + int modifiers = modifiersField.getInt(valuesField); + modifiers &= ~Modifier.FINAL; + modifiersField.setInt(valuesField, modifiers); + + //将新增的枚举值加入values属性里 + FieldAccessor fieldAccessor = reflectionFactory.newFieldAccessor(valuesField, false); + T[] ts = (T[]) fieldAccessor.get(enumClass); + List list = new ArrayList<>(Arrays.asList(ts)); + list.add(newEnum); + fieldAccessor.set(enumClass, list.toArray(ts)); + + //将Class对象的enumConstants和enumConstantDirectory清空(Enum.valueOf()方法会给它们赋值) + /** + * Enum.valueOf()逻辑: + * 1.取enumConstantDirectory + * 1.1如果有值则直接返回 + * 1.2如果没值,则取enumConstants,并拷贝到enumConstantDirectory,下次可直接返回 + * 1.2.1如果enumConstants有值,则返回 + * 1.2.2如果enumConstants没值,则取枚举的values属性,并拷贝到enumConstants,下次可直接返回 + * 2.enumConstantDirectory.get(name)返回 + */ + Field enumConstantDirectoryField = enumClass.getClass().getDeclaredField("enumConstantDirectory"); + enumConstantDirectoryField.setAccessible(true); + FieldAccessor enumConstantDirectoryFieldAccessor = reflectionFactory.newFieldAccessor(enumConstantDirectoryField, false); + enumConstantDirectoryFieldAccessor.set(enumClass,null); + Field enumConstantsField = enumClass.getClass().getDeclaredField("enumConstants"); + enumConstantsField.setAccessible(true); + FieldAccessor enumConstantsFieldAccessor = reflectionFactory.newFieldAccessor(enumConstantsField, false); + enumConstantsFieldAccessor.set(enumClass,null); + return newEnum; + } + } + + /** + * 获取枚举类当前最大序号 + * @param enumClass 枚举类型 + * @param + * @return + * @throws Exception + */ + public static > int getMaxOrdinal(Class enumClass) throws Exception { + List values = values(enumClass); + if(values==null||values.size()==0){ + return 0; + } + int maxOrdinal = 0; + for (T value : values) { + if(maxOrdinal + */ + public static > void removeEnum(Class enumClass, Enum... removeOldEnums) throws Exception { + if(removeOldEnums==null||removeOldEnums.length==0){ + log.warn("removeOldEnums为空"); + return; + } + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + synchronized (enumClass){ + Field valuesField = enumClass.getDeclaredField("$VALUES"); + valuesField.setAccessible(true); + + //解除values属性的final限制 + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + int modifiers = modifiersField.getInt(valuesField); + modifiers &= ~Modifier.FINAL; + modifiersField.setInt(valuesField, modifiers); + + FieldAccessor fieldAccessor = reflectionFactory.newFieldAccessor(valuesField, false); + T[] oldEnumArray = (T[]) fieldAccessor.get(enumClass); + List enumList = new ArrayList<>(Arrays.asList(oldEnumArray)); + for (Enum removeOldEnum : removeOldEnums) { + //将指定的枚举值从values属性里删除 + enumList.remove(removeOldEnum); + log.info("删除枚举值:{}",removeOldEnum); + } + //把List转成数组 + T[] newEnumArray = (T[]) Arrays.copyOf(enumList.toArray(), enumList.size(), oldEnumArray.getClass()); + fieldAccessor.set(enumClass, newEnumArray); + } + } + /** + * 修改枚举属性 + * @param enumClass 枚举类型 + * @param enumName 枚举名称 + * @param attributeName 属性名 + * @param attributeValue 属性值 + * @param + * @throws Exception + */ + public static > void setAttribute(Class enumClass,String enumName,String attributeName,Object attributeValue) throws Exception { + List values = values(enumClass); + T target = null; + for (T t:values){ + if(t.name().equals(enumName)){ + target = t; + break; + } + } + if(target==null){ + throw new RuntimeException("该枚举类没有枚举名:"+enumName); + } + Field declaredField = target.getClass().getDeclaredField(attributeName); + declaredField.setAccessible(true); + declaredField.set(target,attributeValue); + } + + /** + * 修改枚举属性 + * @param targetEnum 枚举值 + * @param attributeName 属性名 + * @param attributeValue 属性值 + * @param + * @throws Exception + */ + public static > void setAttribute(T targetEnum,String attributeName,Object attributeValue) throws Exception { + Field declaredField = targetEnum.getClass().getDeclaredField(attributeName); + declaredField.setAccessible(true); + declaredField.set(targetEnum,attributeValue); + } + + /** + * 判断枚举类是否包含了指定枚举名 + * @param clazz + * @param enumName + * @param + * @return + */ + public static > boolean hasEnumName(Class clazz, String enumName) throws Exception { +// 不要用valueOf方法,因为它会初始化enumConstantDirectory使得后续调用valueOf方法后拿不到后面加入的枚举值 +// try{ +// T t = Enum.valueOf(clazz, enumName); +// if(t!=null){ +// return true; +// } +// }catch (Exception e){ +// e.printStackTrace(); +// System.err.println(e.getMessage()); +// } + List values = values(clazz); + for (T t:values){ + if(t.name().equals(enumName)){ + return true; + } + } + return false; + } + + /** + * 根据枚举类型和枚举名获取枚举值 + * @param clazz 枚举类型 + * @param enumName 枚举名称 + * @param + * @return + * @throws Exception + */ + public static > T getEnum(Class clazz, String enumName) throws Exception { + List values = values(clazz); + for (T t:values){ + if(t.name().equals(enumName)){ + return t; + } + } + return null; + } + + /** + * 获取枚举类的所有枚举值 + * @param clazz 枚举类型 + * @param + * @return + * @throws Exception + */ + public static > List values(Class clazz) throws Exception { + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + Field valuesField = clazz.getDeclaredField("$VALUES"); + valuesField.setAccessible(true); + FieldAccessor fieldAccessor = reflectionFactory.newFieldAccessor(valuesField, false); + T[] ts = (T[]) fieldAccessor.get(clazz); + List list = new ArrayList<>(Arrays.asList(ts)); + return list; + } + + /** + * 获取枚举类的所有枚举值 + * @param clazz 枚举类型 + * @param + * @return + * @throws Exception + */ + public static > List values2(Class clazz) throws Exception { + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + Method valuesMethod = clazz.getDeclaredMethod("values"); + valuesMethod.setAccessible(true); + MethodAccessor methodAccessor = reflectionFactory.newMethodAccessor(valuesMethod); + T[] ts = (T[]) methodAccessor.invoke(clazz, null); + List list = new ArrayList<>(Arrays.asList(ts)); + return list; + } + + /** + * 获取枚举的字段(排除数组类型、枚举类型) + * @param enumClass + * @return + */ + public static Field[] getFields(Class enumClass){ + List result = new ArrayList<>(); + Field[] declaredFields = enumClass.getDeclaredFields(); + for (Field field : declaredFields) { + Class type = field.getType(); + //排除数组类型(values)、枚举类型(枚举值) + if(type!=enumClass && !type.isArray()){ + field.setAccessible(true); + result.add(field); + } + } + return result.toArray(new Field[]{}); + } + + /** + * 打印枚举值 + * @param enumClass 枚举类型 + * @throws Exception + */ + public static void printEnum(Class enumClass) throws Exception { + System.out.println("+++++++++++++++++++++++"); + List values = values(enumClass); + values.stream().forEach(System.out::println); + System.out.println("+++++++++++++++++++++++"); + } + +} From 12f66512df934de30844e5b47af87b0133c50d65 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Tue, 30 Jan 2024 13:50:05 +0800 Subject: [PATCH 15/18] =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=E5=8C=BA=E5=88=86pc=E5=92=8C=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java | 2 +- .../salary/mapper/salarybill/SalaryTemplateMapper.xml | 1 + .../service/impl/SalaryBillBaseSetServiceImpl.java | 6 +++--- .../salary/service/impl/SalarySendServiceImpl.java | 2 +- src/com/engine/salary/wrapper/SalaryTemplateWrapper.java | 9 ++++++++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java index 767d6ccac..fc9a7abf4 100644 --- a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillAckFeedbackDTO.java @@ -31,7 +31,7 @@ public class SalaryBillAckFeedbackDTO { /** * 移动端反馈地址 */ - private String mobileFeedBackUrl; + private String mobileFeedbackUrl; /** * 超时自动确认天数 diff --git a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml index 07898826c..538ae335e 100644 --- a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml +++ b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml @@ -59,6 +59,7 @@ , t.ack_feedback_status , t.auto_ack_days , t.feedback_url + , t.mobile_feedback_url , t.create_time , t.update_time , t.creator diff --git a/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java index 5cafea060..9400d83cc 100644 --- a/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryBillBaseSetServiceImpl.java @@ -100,7 +100,7 @@ public class SalaryBillBaseSetServiceImpl extends Service implements SalaryBillB if (StringUtils.equals(ackFeedbackSetting.getAckStatus(), "1")) { // 2.保存反馈地址 getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getFeedBackUrl(), SALARY_FEEDBACK_URL, "工资单反馈地址", "billSend"); - getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getMobileFeedBackUrl(), SALARY_FEEDBACK_URL_MOBILE, "移动端工资单反馈地址", "billSend"); + getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getMobileFeedbackUrl(), SALARY_FEEDBACK_URL_MOBILE, "移动端工资单反馈地址", "billSend"); // 3.保存自动确认时间 getSalarySysConfService(user).saveSettingByType(ackFeedbackSetting.getAutoAckDays().toString(), SALARY_AUTO_ACK_DAYS, "工资单反馈自动确认", "billSend"); } @@ -138,7 +138,7 @@ public class SalaryBillBaseSetServiceImpl extends Service implements SalaryBillB defaultAckFeedBackDTO.setAckStatus("0"); defaultAckFeedBackDTO.setAutoAckDays(0); defaultAckFeedBackDTO.setFeedBackUrl("/"); - defaultAckFeedBackDTO.setMobileFeedBackUrl("/"); + defaultAckFeedBackDTO.setMobileFeedbackUrl("/"); return defaultAckFeedBackDTO; } defaultAckFeedBackDTO.setAckStatus(ackStatus); @@ -150,7 +150,7 @@ public class SalaryBillBaseSetServiceImpl extends Service implements SalaryBillB defaultAckFeedBackDTO.setFeedBackUrl(feedbackUrl); String mobileFeedbackUrl = sysConfMap.getOrDefault(SALARY_FEEDBACK_URL_MOBILE, ""); - defaultAckFeedBackDTO.setMobileFeedBackUrl(mobileFeedbackUrl); + defaultAckFeedBackDTO.setMobileFeedbackUrl(mobileFeedbackUrl); return defaultAckFeedBackDTO; } diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 2a5f9b688..f79d2b74b 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -830,7 +830,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService .ackFeedbackStatus(Integer.valueOf(map.getOrDefault("ackFeedbackStatus", "0").toString())) .autoAckDays(Integer.valueOf(map.getOrDefault("autoAckDays", "0").toString())) .feedbackUrl(map.getOrDefault("feedbackUrl", "").toString()) - .feedbackUrl(map.getOrDefault("mobileFeedbackUrl", "").toString()) + .mobileFeedbackUrl(map.getOrDefault("mobileFeedbackUrl", "").toString()) .name(map.getOrDefault("name", "").toString()) .salarySobId(Long.valueOf(map.getOrDefault("salarySobId", "0").toString())) .useType(Integer.valueOf(map.getOrDefault("useType", "0").toString())) diff --git a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java index 22aac4134..25a0d96ef 100644 --- a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java @@ -176,6 +176,7 @@ public class SalaryTemplateWrapper extends Service { } + // 查询所有启用的薪资账套 List salarySobs = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); List> salarySobOptions = salarySobs.stream().map(salarySobPO -> { @@ -199,8 +200,14 @@ public class SalaryTemplateWrapper extends Service { salaryTemplateBaseSetDTO.setAckFeedbackStatus(StringUtils.equals(defaultAckFeedback.getAckStatus(), "1")); salaryTemplateBaseSetDTO.setAutoAckDays(defaultAckFeedback.getAutoAckDays()); salaryTemplateBaseSetDTO.setFeedbackUrl(defaultAckFeedback.getFeedBackUrl()); - salaryTemplateBaseSetDTO.setMobileFeedbackUrl(defaultAckFeedback.getMobileFeedBackUrl()); + salaryTemplateBaseSetDTO.setMobileFeedbackUrl(defaultAckFeedback.getMobileFeedbackUrl()); } + + // 如果设置了pc端反馈流程地址,移动端没有设置,则移动端与pc端一致 + if (StringUtils.isNotBlank(salaryTemplateBaseSetDTO.getFeedbackUrl()) && StringUtils.isBlank(salaryTemplateBaseSetDTO.getMobileFeedbackUrl())) { + salaryTemplateBaseSetDTO.setMobileFeedbackUrl(salaryTemplateBaseSetDTO.getFeedbackUrl()); + } + Map salaryTemplateBase = new HashMap<>(); salaryTemplateBase.put("data", salaryTemplateBaseSetDTO); salaryTemplateBase.put("salarySobOptions", salarySobOptions); From b1d3d2c445d276208d6b02b78eeb384115c6e5db Mon Sep 17 00:00:00 2001 From: sy Date: Tue, 30 Jan 2024 14:31:21 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E5=A4=8D=E5=88=B6?= =?UTF-8?q?action=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/CopyToPaySIArchiveAction.java | 149 ++++++++++++++++++ .../mapper/siarchives/OtherSchemeMapper.java | 7 + .../mapper/siarchives/OtherSchemeMapper.xml | 9 ++ .../salary/service/SIArchivesService.java | 9 ++ .../service/impl/SIArchivesServiceImpl.java | 124 +++++++++++++++ 5 files changed, 298 insertions(+) create mode 100644 src/com/engine/salary/action/CopyToPaySIArchiveAction.java diff --git a/src/com/engine/salary/action/CopyToPaySIArchiveAction.java b/src/com/engine/salary/action/CopyToPaySIArchiveAction.java new file mode 100644 index 000000000..6ff38ee6d --- /dev/null +++ b/src/com/engine/salary/action/CopyToPaySIArchiveAction.java @@ -0,0 +1,149 @@ +package com.engine.salary.action; + +import cn.hutool.core.util.StrUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; +import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: sy + * @Description: 拷贝福利档案并置为在缴 + * @Date: 2024/1/29 + **/ +@Slf4j +public class CopyToPaySIArchiveAction implements Action { + + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + private String tableName; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + @Override + public String execute(RequestInfo requestInfo) { + try { + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + Map fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName, + property -> Util.null2String(property.getValue()))); + + RecordSet rs = new RecordSet(); + + String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?"; + rs.executeQuery(queryImageId, requestInfo.getWorkflowid()); + + List list = new ArrayList<>(); + while (rs.next()) { + String processField = rs.getString("processfield"); + String salaryName = rs.getString("salaryname"); + String value = fieldMap.get(processField); + list.add(new CopyToPaySIArchiveAction.SalaryField(processField, salaryName, value)); + } + List> importData = new ArrayList<>(); + importData.add(SalaryEntityUtil.convert2Map(list, CopyToPaySIArchiveAction.SalaryField::getSalaryName, CopyToPaySIArchiveAction.SalaryField::getValue)); + //操作人 + String uid = list.stream().filter(f -> f.salaryName.equals("操作人")).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("1"); + //增员 + String toCopyTaxAgentName = importData.get(0).get("待复制个税扣缴义务人").toString(); + String toUpdateTaxAgentName = importData.get(0).get("待更新个税扣缴义务人").toString(); + String payStartYearMonth = importData.get(0).getOrDefault("起始缴纳月", "").toString(); + if (StrUtil.isNotBlank(payStartYearMonth) && !SalaryDateUtil.checkYearMonth(payStartYearMonth)) { + requestInfo.getRequestManager().setMessage("起始缴纳月格式有误,正确格式示例为'2021-01'"); + return FAILURE_AND_CONTINUE; + } + + List toCopyTaxAgentPOS = getTaxAgentMapper().listByName(toCopyTaxAgentName); + List toUpdateTaxAgentPOS = getTaxAgentMapper().listByName(toUpdateTaxAgentName); + if(CollectionUtils.isEmpty(toCopyTaxAgentPOS)){ + requestInfo.getRequestManager().setMessage("待复制个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + if(CollectionUtils.isEmpty(toUpdateTaxAgentPOS)){ + requestInfo.getRequestManager().setMessage("待更新个税扣缴义务人不存在!"); + return FAILURE_AND_CONTINUE; + } + Long toCopyTaxAgentId = toCopyTaxAgentPOS.get(0).getId(); + Long toUpdateTaxAgentId = toUpdateTaxAgentPOS.get(0).getId(); + Long employeeId = Long.valueOf(list.stream().filter(f -> f.salaryName.equals("员工id")).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("-1")); + User user = new User(Integer.parseInt(uid)); + //拷贝福利档案并置为在缴 + Map resultMap = getSIArchivesService(user).copyToPay(toCopyTaxAgentId, toUpdateTaxAgentId, employeeId, payStartYearMonth); + if (!"success".equals(resultMap.get("type").toString())) { + requestInfo.getRequestManager().setMessage(resultMap.get("msg").toString()); + return FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + log.error("福利档案复制并置为在缴异常", e); + requestInfo.getRequestManager().setMessage(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } + + class SalaryField { + + private String processField; + + private String salaryName; + + private String value; + + public String getProcessField() { + return processField; + } + + public void setProcessField(String processField) { + this.processField = processField; + } + + public String getSalaryName() { + return salaryName; + } + + public void setSalaryName(String salaryName) { + this.salaryName = salaryName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SalaryField(String processField, String salaryName, String value) { + this.processField = processField; + this.salaryName = salaryName; + this.value = value; + } + } +} diff --git a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java index f468b0d45..6ad9fbe78 100644 --- a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java +++ b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.java @@ -36,6 +36,13 @@ public interface OtherSchemeMapper { */ List getOtherById(@Param("ids")List ids); + /** + * 根据id获取单条 + * @param id + * @return + */ + InsuranceArchivesOtherSchemePO getOneById(@Param("id")Long id); + /** * 批量删除 * @param singletonList diff --git a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml index 2d67257b4..12adf7fb4 100644 --- a/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml +++ b/src/com/engine/salary/mapper/siarchives/OtherSchemeMapper.xml @@ -80,6 +80,15 @@ + + + UPDATE hrsa_other_archives diff --git a/src/com/engine/salary/service/SIArchivesService.java b/src/com/engine/salary/service/SIArchivesService.java index 0bdc90cd9..7f2f31866 100644 --- a/src/com/engine/salary/service/SIArchivesService.java +++ b/src/com/engine/salary/service/SIArchivesService.java @@ -94,6 +94,15 @@ public interface SIArchivesService { */ Map stayAddToPay(Collection ids); + /** + * 拷贝福利档案到新的个税扣缴义务人并置为在缴 + * @param toCopyTaxAgentId 被拷贝的福利档案所属个税扣缴义务人id + * @param toUpdateTaxAgentId 被更新的福利档案所属个税扣缴义务人id + * @param employeeId 福利档案所属人员id + * @return + */ + Map copyToPay(Long toCopyTaxAgentId, Long toUpdateTaxAgentId, Long employeeId, String payStartYearMonth); + /** * 待减员页面的删除待办 */ diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 6e1f5e94a..8871548f4 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -6,6 +6,7 @@ import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd; +import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBaseInfoBO; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO; import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; @@ -71,6 +72,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + private EncryptUtil encryptUtil = new EncryptUtil(); + private TaxAgentService getTaxAgentService(User user) { return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } @@ -1217,4 +1220,125 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return listPage; } + /** + * 拷贝福利档案到新的个税扣缴义务人并置为在缴 + */ + @Override + public Map copyToPay(Long toCopyTaxAgentId, Long toUpdateTaxAgentId, Long employeeId, String payStartYearMonth) { + if (toCopyTaxAgentId == null || toUpdateTaxAgentId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人不能为空")); + } + if (employeeId == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "人员id不能为空")); + } + //获取待拷贝的福利档案明细 + InsuranceArchivesBaseInfoPO toCopyBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(toCopyTaxAgentId, employeeId); + if(toCopyBaseInfoPO == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "待复制个税扣缴义务人下该员工不存在福利档案,请检查后重试!")); + } + InsuranceArchivesSocialSchemePO toCopySocialInfo = getSocialSchemeMapper().getOneById(toCopyBaseInfoPO.getSocialArchivesId()); + InsuranceArchivesFundSchemePO toCopyFundInfo = getFundSchemeMapper().getOneById(toCopyBaseInfoPO.getFundArchivesId()); + InsuranceArchivesOtherSchemePO toCopyOtherInfo = getOtherSchemeMapper().getOneById(toCopyBaseInfoPO.getOtherArchivesId()); + //获取待更新的福利档案 + InsuranceArchivesBaseInfoPO toUpdateBaseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(toUpdateTaxAgentId, employeeId); + if(toUpdateBaseInfoPO == null){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "待更新个税扣缴义务人下该员工不存在福利档案,请检查后重试!")); + } + InsuranceArchivesSocialSchemePO toUpdateSocialInfo = getSocialSchemeMapper().getOneById(toUpdateBaseInfoPO.getSocialArchivesId()); + InsuranceArchivesFundSchemePO toUpdateFundInfo = getFundSchemeMapper().getOneById(toUpdateBaseInfoPO.getFundArchivesId()); + InsuranceArchivesOtherSchemePO toUpdateOtherInfo = getOtherSchemeMapper().getOneById(toUpdateBaseInfoPO.getOtherArchivesId()); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(toCopySocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.decrypt(toUpdateSocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.decrypt(toCopyFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.decrypt(toUpdateFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.decrypt(toCopyOtherInfo, InsuranceArchivesOtherSchemePO.class); + encryptUtil.decrypt(toUpdateOtherInfo, InsuranceArchivesOtherSchemePO.class); + + InsuranceArchivesBaseHistoryDTO socialAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopySocialInfo.getSocialSchemeId()) + .adjustAfterBaseJson(toCopySocialInfo.getSocialPaymentBaseString()) + .adjustAfterComBaseJson(toCopySocialInfo.getSocialPaymentComBaseString()) + .welfareType(toUpdateSocialInfo.getWelfareType()) + .employeeId(toUpdateSocialInfo.getEmployeeId()) + .paymentOrganization(toUpdateSocialInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateSocialInfo.getSocialSchemeId()) + .adjustBeforeBaseJson(toUpdateSocialInfo.getSocialPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateSocialInfo.getSocialPaymentComBaseString()) + .build(); + InsuranceArchivesBaseHistoryDTO fundAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopyFundInfo.getFundSchemeId()) + .adjustAfterBaseJson(toCopyFundInfo.getFundPaymentBaseString()) + .adjustAfterComBaseJson(toCopyFundInfo.getFundPaymentComBaseString()) + .welfareType(toUpdateFundInfo.getWelfareType()) + .employeeId(toUpdateFundInfo.getEmployeeId()) + .paymentOrganization(toUpdateFundInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateFundInfo.getFundSchemeId()) + .adjustBeforeBaseJson(toUpdateFundInfo.getFundPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateFundInfo.getFundPaymentComBaseString()) + .build(); + InsuranceArchivesBaseHistoryDTO otherAdjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(toCopyOtherInfo.getOtherSchemeId()) + .adjustAfterBaseJson(toCopyOtherInfo.getOtherPaymentBaseString()) + .adjustAfterComBaseJson(toCopyOtherInfo.getOtherPaymentComBaseString()) + .welfareType(toUpdateOtherInfo.getWelfareType()) + .employeeId(toUpdateOtherInfo.getEmployeeId()) + .paymentOrganization(toUpdateOtherInfo.getPaymentOrganization()) + .adjustBeforeSchemeId(toUpdateOtherInfo.getOtherSchemeId()) + .adjustBeforeBaseJson(toUpdateOtherInfo.getOtherPaymentBaseString()) + .adjustBeforeComBaseJson(toUpdateOtherInfo.getOtherPaymentComBaseString()) + .build(); + List adjustHistoryList = new ArrayList<>(); + adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(socialAdjustInfo, (long) user.getUID())); + adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(fundAdjustInfo, (long) user.getUID())); + adjustHistoryList.addAll(siArchivesBiz.createAdjustInfo(otherAdjustInfo, (long) user.getUID())); + //更新字段 + toUpdateBaseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + + toUpdateSocialInfo.setSocialAccount(toCopySocialInfo.getSocialAccount()); + toUpdateSocialInfo.setSocialSchemeId(toCopySocialInfo.getSocialSchemeId()); + toUpdateSocialInfo.setSocialPaymentBaseString(toCopySocialInfo.getSocialPaymentBaseString()); + toUpdateSocialInfo.setSocialPaymentComBaseString(toCopySocialInfo.getSocialPaymentComBaseString()); + toUpdateSocialInfo.setNonPayment(toCopySocialInfo.getNonPayment()); + toUpdateSocialInfo.setUnderTake(toCopySocialInfo.getUnderTake()); + toUpdateSocialInfo.setSocialStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopySocialInfo.getSocialStartTime()); + toUpdateSocialInfo.setUpdateTime(new Date()); + + toUpdateFundInfo.setFundAccount(toCopyFundInfo.getFundAccount()); + toUpdateFundInfo.setSupplementFundAccount(toCopyFundInfo.getSupplementFundAccount()); + toUpdateFundInfo.setFundSchemeId(toCopyFundInfo.getFundSchemeId()); + toUpdateFundInfo.setFundPaymentBaseString(toCopyFundInfo.getFundPaymentBaseString()); + toUpdateFundInfo.setFundPaymentComBaseString(toCopyFundInfo.getFundPaymentComBaseString()); + toUpdateFundInfo.setNonPayment(toCopyFundInfo.getNonPayment()); + toUpdateFundInfo.setUnderTake(toCopyFundInfo.getUnderTake()); + toUpdateFundInfo.setFundStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopyFundInfo.getFundStartTime()); + toUpdateFundInfo.setUpdateTime(new Date()); + + toUpdateOtherInfo.setOtherSchemeId(toCopyOtherInfo.getOtherSchemeId()); + toUpdateOtherInfo.setOtherPaymentBaseString(toCopyOtherInfo.getOtherPaymentBaseString()); + toUpdateOtherInfo.setOtherPaymentComBaseString(toCopyOtherInfo.getOtherPaymentComBaseString()); + toUpdateOtherInfo.setNonPayment(toCopyOtherInfo.getNonPayment()); + toUpdateOtherInfo.setUnderTake(toCopyOtherInfo.getUnderTake()); + toUpdateOtherInfo.setOtherStartTime(StringUtils.isNotBlank(payStartYearMonth) ? payStartYearMonth : toCopyOtherInfo.getOtherStartTime()); + toUpdateOtherInfo.setUpdateTime(new Date()); + //档案入库 + encryptUtil.encrypt(toUpdateSocialInfo, InsuranceArchivesSocialSchemePO.class); + encryptUtil.encrypt(toUpdateFundInfo, InsuranceArchivesFundSchemePO.class); + encryptUtil.encrypt(toUpdateOtherInfo, InsuranceArchivesOtherSchemePO.class); + + getInsuranceBaseInfoMapper().updateById(toUpdateBaseInfoPO); + getSocialSchemeMapper().updateById(toUpdateSocialInfo); + getFundSchemeMapper().updateById(toUpdateFundInfo); + getOtherSchemeMapper().updateById(toUpdateOtherInfo); + //基数调整记录入库 + siArchivesBiz.batchInsertAdjustHistory(adjustHistoryList, (long) user.getUID()); + + Map resultMap = new HashMap<>(2); + String resultMsg = "操作成功"; + String resultType = "success"; + + resultMap.put("type", resultType); + resultMap.put("msg", resultMsg); + return resultMap; + } } From 3281b138faeb3bb4ea74e23cf42754f3d08317c5 Mon Sep 17 00:00:00 2001 From: sy Date: Tue, 30 Jan 2024 15:58:42 +0800 Subject: [PATCH 17/18] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E5=A4=8D=E5=88=B6?= =?UTF-8?q?action=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/action/CopyToPaySIArchiveAction.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/engine/salary/action/CopyToPaySIArchiveAction.java b/src/com/engine/salary/action/CopyToPaySIArchiveAction.java index 6ff38ee6d..2fcfb6596 100644 --- a/src/com/engine/salary/action/CopyToPaySIArchiveAction.java +++ b/src/com/engine/salary/action/CopyToPaySIArchiveAction.java @@ -91,8 +91,9 @@ public class CopyToPaySIArchiveAction implements Action { } Long toCopyTaxAgentId = toCopyTaxAgentPOS.get(0).getId(); Long toUpdateTaxAgentId = toUpdateTaxAgentPOS.get(0).getId(); - Long employeeId = Long.valueOf(list.stream().filter(f -> f.salaryName.equals("员工id")).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("-1")); + Long employeeId = Long.valueOf(list.stream().filter(f -> "员工id".equals(f.salaryName)).findFirst().map(CopyToPaySIArchiveAction.SalaryField::getValue).orElse("-1")); User user = new User(Integer.parseInt(uid)); + user.setLanguage(7); //拷贝福利档案并置为在缴 Map resultMap = getSIArchivesService(user).copyToPay(toCopyTaxAgentId, toUpdateTaxAgentId, employeeId, payStartYearMonth); if (!"success".equals(resultMap.get("type").toString())) { From acbffb205baa0477a3b9bf7ff28669d9cf20be2f Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Tue, 30 Jan 2024 16:00:50 +0800 Subject: [PATCH 18/18] sql --- resource/sqlupgrade/DM/sql202401300303.sql | 3 +++ resource/sqlupgrade/GS/sql202401300303.sql | 3 +++ resource/sqlupgrade/JC/sql202401300303.sql | 3 +++ resource/sqlupgrade/Mysql/sql202401300303.sql | 1 + resource/sqlupgrade/Oracle/sql202401300303.sql | 2 ++ resource/sqlupgrade/PG/sql202401300303.sql | 1 + resource/sqlupgrade/SQLServer/sql202401300303.sql | 2 ++ resource/sqlupgrade/ST/sql202401300303.sql | 3 +++ 8 files changed, 18 insertions(+) create mode 100644 resource/sqlupgrade/DM/sql202401300303.sql create mode 100644 resource/sqlupgrade/GS/sql202401300303.sql create mode 100644 resource/sqlupgrade/JC/sql202401300303.sql create mode 100644 resource/sqlupgrade/Mysql/sql202401300303.sql create mode 100644 resource/sqlupgrade/Oracle/sql202401300303.sql create mode 100644 resource/sqlupgrade/PG/sql202401300303.sql create mode 100644 resource/sqlupgrade/SQLServer/sql202401300303.sql create mode 100644 resource/sqlupgrade/ST/sql202401300303.sql diff --git a/resource/sqlupgrade/DM/sql202401300303.sql b/resource/sqlupgrade/DM/sql202401300303.sql new file mode 100644 index 000000000..edf082294 --- /dev/null +++ b/resource/sqlupgrade/DM/sql202401300303.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_template add mobile_feedback_url varchar(500); +/ + diff --git a/resource/sqlupgrade/GS/sql202401300303.sql b/resource/sqlupgrade/GS/sql202401300303.sql new file mode 100644 index 000000000..edf082294 --- /dev/null +++ b/resource/sqlupgrade/GS/sql202401300303.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_template add mobile_feedback_url varchar(500); +/ + diff --git a/resource/sqlupgrade/JC/sql202401300303.sql b/resource/sqlupgrade/JC/sql202401300303.sql new file mode 100644 index 000000000..edf082294 --- /dev/null +++ b/resource/sqlupgrade/JC/sql202401300303.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_template add mobile_feedback_url varchar(500); +/ + diff --git a/resource/sqlupgrade/Mysql/sql202401300303.sql b/resource/sqlupgrade/Mysql/sql202401300303.sql new file mode 100644 index 000000000..847c44d97 --- /dev/null +++ b/resource/sqlupgrade/Mysql/sql202401300303.sql @@ -0,0 +1 @@ +alter table hrsa_salary_template add mobile_feedback_url varchar(500); \ No newline at end of file diff --git a/resource/sqlupgrade/Oracle/sql202401300303.sql b/resource/sqlupgrade/Oracle/sql202401300303.sql new file mode 100644 index 000000000..6211d28fa --- /dev/null +++ b/resource/sqlupgrade/Oracle/sql202401300303.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_template add mobile_feedback_url varchar(500) +/ \ No newline at end of file diff --git a/resource/sqlupgrade/PG/sql202401300303.sql b/resource/sqlupgrade/PG/sql202401300303.sql new file mode 100644 index 000000000..847c44d97 --- /dev/null +++ b/resource/sqlupgrade/PG/sql202401300303.sql @@ -0,0 +1 @@ +alter table hrsa_salary_template add mobile_feedback_url varchar(500); \ No newline at end of file diff --git a/resource/sqlupgrade/SQLServer/sql202401300303.sql b/resource/sqlupgrade/SQLServer/sql202401300303.sql new file mode 100644 index 000000000..96f40257b --- /dev/null +++ b/resource/sqlupgrade/SQLServer/sql202401300303.sql @@ -0,0 +1,2 @@ +alter table hrsa_salary_template add mobile_feedback_url varchar(500) +GO \ No newline at end of file diff --git a/resource/sqlupgrade/ST/sql202401300303.sql b/resource/sqlupgrade/ST/sql202401300303.sql new file mode 100644 index 000000000..edf082294 --- /dev/null +++ b/resource/sqlupgrade/ST/sql202401300303.sql @@ -0,0 +1,3 @@ +alter table hrsa_salary_template add mobile_feedback_url varchar(500); +/ +