diff --git a/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java b/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java index 561a395a4..5d4eea819 100644 --- a/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java +++ b/src/com/engine/salary/cmd/siarchives/SIArchivesTipsCmd.java @@ -3,9 +3,13 @@ package com.engine.salary.cmd.siarchives; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; -import com.engine.salary.biz.SIArchivesBiz; +import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.util.SalaryAssert; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; import weaver.hrm.User; +import java.util.List; import java.util.Map; /** @@ -28,8 +32,16 @@ public class SIArchivesTipsCmd extends AbstractCommonCommand @Override public Map execute(CommandContext commandContext) { - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); - siArchivesBiz.tips(); + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List employeeIds = socialSchemeMapper.tips(); + SalaryAssert.isEmpty(employeeIds, "当前有离职人员档案存在福利缴纳起始月,未维护福利最后缴纳月,请尽快处理"); + + } finally { + sqlSession.close(); + } return null; } } diff --git a/src/com/engine/salary/service/SIArchivesService.java b/src/com/engine/salary/service/SIArchivesService.java index 7f2f31866..4f98cc742 100644 --- a/src/com/engine/salary/service/SIArchivesService.java +++ b/src/com/engine/salary/service/SIArchivesService.java @@ -1,11 +1,11 @@ package com.engine.salary.service; +import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO; import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; import com.engine.salary.entity.siarchives.param.InsuranceArchivesSaveParam; import com.engine.salary.entity.siarchives.param.SIArchiveBaseHistoryListParam; -import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; -import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; +import com.engine.salary.entity.siarchives.po.*; import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -124,4 +124,32 @@ public interface SIArchivesService { PageInfo getAdjustHistoryList(SIArchiveBaseHistoryListParam param); PageInfo historyListByEmployeeIdAndOperator(SIArchiveBaseHistoryListParam param); + + List> buildTableData(List insuranceArchivesEmployeePOS); + + List buildWeaTableColumns(List insuranceArchivesEmployeePOS); + + boolean isDiffWelBase(); + + List payInsuranceIds(Long socialSchemeId, Integer paymentScope); + + List payInsuranceIds(Long socialSchemeId); + + List getSocialByEmployeeIds(List employeeIds); + List getFundByEmployeeIds(List employeeIds); + List getOtherByEmployeeIds(List employeeIds); + + Map buildBatchAccount(List ids, Long paymentOrganization); + + Boolean checkWelBaseLimit(Long primaryId, String paymentBaseString, Integer paymentScope); + + String checkAndBuildWelBaseWithLimit(Long primaryId, String paymentBaseString, Integer paymentScope); + + List dealSocialBaseAdjustInfoList(List adjustList, Long creator); + List dealFundBaseAdjustInfoList(List adjustList, Long creator); + List dealOtherBaseAdjustInfoList(List adjustList, Long creator); + + void batchInsertAdjustHistory(List adjustHistoryList); + + List listEndDateIsNull(List employeeIds); } diff --git a/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java b/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java index 5312f1c51..a03f1e529 100644 --- a/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java +++ b/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java @@ -4,8 +4,8 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.cloudstore.eccom.constant.WeaBoolAttr; import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesAccountPO; @@ -17,9 +17,11 @@ import com.engine.salary.enums.siaccount.PaymentStatusEnum; import com.engine.salary.enums.sicategory.WelfareTypeEnum; import com.engine.salary.mapper.sicategory.ICategoryMapper; import com.engine.salary.service.ColumnBuildService; +import com.engine.salary.service.SIArchivesService; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; import java.util.*; import java.util.stream.Collectors; @@ -32,11 +34,16 @@ import java.util.stream.Collectors; **/ public class ColumnBuildServiceImpl extends Service implements ColumnBuildService { - private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); private ICategoryMapper getICategoryMapper() { return MapperProxyFactory.getProxy(ICategoryMapper.class); } + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + @Override public List buildCommonColumnsWithStyle(List pos, Long employeeId, String tenantKey, Integer paymentStatus) { List list = new ArrayList<>(); @@ -125,7 +132,8 @@ public class ColumnBuildServiceImpl extends Service implements ColumnBuildServic } private Map> buildPaymentTitle(List pos, Map categoryIdNameMap, Long employeeId, String tenantKey) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); Set socailIds = new HashSet<>(); Set fundIds = new HashSet<>(); Set otherIds = new HashSet<>(); @@ -440,9 +448,10 @@ public class ColumnBuildServiceImpl extends Service implements ColumnBuildServic @Override public List buildInspectColumns(List pos, Long paymentOrganization) { List list = new ArrayList<>(); - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + List employeeIds = pos.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList()); - Map insuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); +// Map insuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); + Map insuranceArchivesAccountPOMap = getSIArchivesService(user).buildBatchAccount(employeeIds, paymentOrganization); Map categoryIdNameMap = getICategoryMapper().listAll().stream().collect(Collectors.toMap(ICategoryPO -> String.valueOf(ICategoryPO.getId()), ICategoryPO::getInsuranceName)); Map> columns = buildInspectTableTitle(new ArrayList<>(insuranceArchivesAccountPOMap.values()), categoryIdNameMap); WeaTableColumn weaTableNameColumn = new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 85429, "姓名"), "userName"); diff --git a/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java b/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java index a18ca32e0..2976579d4 100644 --- a/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java +++ b/src/com/engine/salary/service/impl/RecordsBuildServiceImpl.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO; import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; @@ -21,6 +20,7 @@ import com.engine.salary.mapper.datacollection.EmployMapper; import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; import com.engine.salary.mapper.taxagent.TaxAgentMapper; import com.engine.salary.service.RecordsBuildService; +import com.engine.salary.service.SIArchivesService; import com.engine.salary.service.SalaryEmployeeService; import com.engine.salary.util.SalaryAssert; import com.engine.salary.util.SalaryDateUtil; @@ -62,11 +62,16 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); } - private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } @Override public List> buildCommonRecords(List list, Long employeeId) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); List> result = new ArrayList<>(); if (CollectionUtils.isEmpty(list)) { return result; @@ -114,7 +119,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ if (welBaseDiffSign) { if (socialJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); socialJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "socialPerBase", v); @@ -125,7 +131,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ }); if (socialComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); socialComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "socialComBase", v); @@ -135,7 +142,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ } else { if (socialJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId()); socialJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "socialBase", v); @@ -158,7 +166,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ if (welBaseDiffSign) { if (fundJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); fundJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "fundPerBase", v); @@ -169,7 +178,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ }); if (fundComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); fundComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "fundComBase", v); @@ -179,7 +189,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ } else { if (fundJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId()); fundJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "fundBase", v); @@ -200,7 +211,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ if (welBaseDiffSign) { if (otherJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); otherJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "otherPerBase", v); @@ -211,7 +223,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ }); if (otherComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); otherComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "otherComBase", v); @@ -221,7 +234,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ } else { if (otherJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId()); otherJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "otherBase", v); @@ -311,7 +325,7 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ @Override public List> buildInspectRecords(List list, Long paymentOrganization) { List> result = new ArrayList<>(); - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); + if (CollectionUtils.isEmpty(list)) { return result; } @@ -325,7 +339,8 @@ public class RecordsBuildServiceImpl extends Service implements RecordsBuildServ return result; } Map collect = employeeByIds.stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, Function.identity())); - Map insuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); +// Map insuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); + Map insuranceArchivesAccountPOMap = getSIArchivesService(user).buildBatchAccount(employeeIds, paymentOrganization); list.forEach(item -> { Map record = new HashMap<>(); DataCollectionEmployee simpleEmployee = collect.get(item.getEmployeeId()) == null ? new DataCollectionEmployee() : collect.get(item.getEmployeeId()); diff --git a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java index 389e4ef2b..05512c23c 100644 --- a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java @@ -2,7 +2,6 @@ package com.engine.salary.service.impl; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.siaccount.bo.InsuranceComparisonResultBO; import com.engine.salary.entity.siaccount.dto.InsuranceComparisonResultListDTO; @@ -19,19 +18,18 @@ import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; import com.engine.salary.mapper.sicategory.ICategoryMapper; import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; import com.engine.salary.service.SIAComparisonResultService; +import com.engine.salary.service.SIArchivesService; import com.engine.salary.service.SISchemeService; import com.engine.salary.sys.entity.vo.OrderRuleVO; import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.db.MapperProxyFactory; -import com.engine.salary.util.excel.ExcelUtil; import com.engine.salary.util.excel.ExcelUtilPlus; import com.engine.salary.util.page.Column; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; import com.engine.salary.util.valid.ValidUtil; import com.google.common.collect.Lists; -import com.wbi.util.Util; import org.apache.commons.lang3.BooleanUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.User; @@ -47,7 +45,7 @@ import java.util.stream.Collectors; public class SIAComparisonResultServiceImpl extends Service implements SIAComparisonResultService { private EncryptUtil encryptUtil = new EncryptUtil(); - private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); private InsuranceExportMapper getInsuranceExportMapper() { return MapperProxyFactory.getProxy(InsuranceExportMapper.class); @@ -73,6 +71,10 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar return ServiceUtil.getService(SISchemeServiceImpl.class, user); } + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + /** * 根据列表查询条件查询线下对比结果(分页) */ @@ -144,7 +146,8 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar */ private InsuranceComparisonResultListDTO listByParam(boolean needPage, InsuranceComparisonResultQueryParam queryParam) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); //排序配置 OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); @@ -232,7 +235,8 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar } private Set welfareInfo() { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); Set info = new HashSet<>(); List listAll = getICategoryMapper().listAll(); diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index 857196426..08b7fc624 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -103,7 +103,7 @@ import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX; public class SIAccountServiceImpl extends Service implements SIAccountService { - private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); private EncryptUtil encryptUtil = new EncryptUtil(); @@ -227,6 +227,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return MapperProxyFactory.getProxy(SIAccountUtilMapper.class); } + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + @Override public Map listPage(InsuranceAccountBatchParam queryParam) { Long employeeId = (long) user.getUID(); @@ -761,13 +765,15 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), insuranceArchivesEmployeePOS, InsuranceArchivesEmployeePO.class); - List> records = siArchivesBiz.buildTableData(insuranceArchivesEmployeePOS); +// List> records = siArchivesBiz.buildTableData(insuranceArchivesEmployeePOS); + List> records = getSIArchivesService(user).buildTableData(insuranceArchivesEmployeePOS); PageInfo> pageInfos = new PageInfo<>(records); pageInfos.setTotal(pageInfo.getTotal()); pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageSize(param.getPageSize()); - List weaTableColumns = siArchivesBiz.buildWeaTableColumns(insuranceArchivesEmployeePOS, employeeId); +// List weaTableColumns = siArchivesBiz.buildWeaTableColumns(insuranceArchivesEmployeePOS, employeeId); + List weaTableColumns = getSIArchivesService(user).buildWeaTableColumns(insuranceArchivesEmployeePOS); WeaTable table = new WeaTable(); table.setPageUID(UUID.randomUUID().toString()); @@ -2349,7 +2355,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { } public Map> createWelColumnMap(InsuranceAccountDetailParam param) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); //查询线上福利核算记录 InsuranceExportParam insuranceExportParam = new InsuranceExportParam(); insuranceExportParam.setBillMonth(param.getBillMonth()); @@ -2496,7 +2503,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { } public Map welColumnNameCodeMap(InsuranceAccountDetailParam param) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); //查询线上福利核算记录 InsuranceExportParam insuranceExportParam = new InsuranceExportParam(); insuranceExportParam.setBillMonth(param.getBillMonth()); @@ -2821,7 +2829,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { * @param baseMap excel导入的对比数据 */ private ExcelInsuranceDetailPO handleExcelInsuranceDetail(String billMonth, Long employeeId, Long paymentOrganization, Map baseMap, Map welColumnNameCodeMap) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); ExcelInsuranceDetailPO excelInsuranceDetailPO = new ExcelInsuranceDetailPO(); excelInsuranceDetailPO.setId(IdGenerator.generate()); @@ -4452,7 +4461,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { 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); +// List socials = siArchivesBiz.getSocialByEmployeeIds(empIds); + List socials = getSIArchivesService(user).getSocialByEmployeeIds(empIds); //过滤出目标个税扣缴义务人相关信息 socials = socials.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); List emp1 = socials.stream() @@ -4461,7 +4471,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { .map(InsuranceArchivesSocialSchemePO::getEmployeeId) .collect(Collectors.toList()); - List funds = siArchivesBiz.getFundByEmployeeIds(empIds); +// List funds = siArchivesBiz.getFundByEmployeeIds(empIds); + List funds = getSIArchivesService(user).getFundByEmployeeIds(empIds); //过滤出目标个税扣缴义务人相关信息 funds = funds.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); List emp2 = funds.stream() @@ -4470,7 +4481,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { .map(InsuranceArchivesFundSchemePO::getEmployeeId) .collect(Collectors.toList()); - List others = siArchivesBiz.getOtherByEmployeeIds(empIds); +// List others = siArchivesBiz.getOtherByEmployeeIds(empIds); + List others = getSIArchivesService(user).getOtherByEmployeeIds(empIds); //过滤出目标个税扣缴义务人相关信息 others = others.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList()); List emp3 = others.stream() @@ -4534,8 +4546,9 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { } public void siCommonAccount(String billMonth, List ids, Long paymentOrganization) { - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); - Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, paymentOrganization); + +// Map insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, paymentOrganization); + Map insuranceArchivesAccountPOS = getSIArchivesService(user).buildBatchAccount(ids, paymentOrganization); List list = new ArrayList<>(); int count = 0; for (Map.Entry entry : insuranceArchivesAccountPOS.entrySet()) { @@ -4597,7 +4610,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { } public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); if (accountPO.getOther() != null) { InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther(); insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization()); @@ -4759,7 +4773,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { public InsuranceAccountDetailPO accountFund(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); if (accountPO.getFund() != null) { InsuranceArchivesFundSchemePO fundPO = accountPO.getFund(); insuranceAccountDetailPO.setFundPayOrg(fundPO.getPaymentOrganization()); @@ -4922,7 +4937,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { public InsuranceAccountDetailPO accountSocial(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); if (accountPO.getSocial() != null) { InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial(); insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization()); @@ -5498,7 +5514,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { */ public String accountSupplement(List baseList, List employeeIds, Long paymentOrganization) { //(k,v) k-员工id v-员工对应的福利档案数据 - Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); +// Map longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization); + Map longInsuranceArchivesAccountPOMap = getSIArchivesService(user).buildBatchAccount(employeeIds, paymentOrganization); //核算结果集 List pos = new ArrayList<>(); baseList.forEach(baseParam -> { diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 641118a29..29859d236 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -1,63 +1,94 @@ package com.engine.salary.service.impl; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; import com.cloudstore.dev.api.util.Util_DataCache; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom; import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.salary.biz.SIArchivesBiz; +import com.engine.salary.biz.SICategoryBiz; +import com.engine.salary.biz.SISchemeBiz; import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd; +import com.engine.salary.common.SalaryContext; +import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.encrypt.EncryptUtil; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBO; import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBaseInfoBO; -import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO; -import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; -import com.engine.salary.entity.siarchives.param.InsuranceArchivesSaveParam; -import com.engine.salary.entity.siarchives.param.SIArchiveBaseHistoryListParam; +import com.engine.salary.entity.siarchives.dto.*; +import com.engine.salary.entity.siarchives.param.*; import com.engine.salary.entity.siarchives.po.*; +import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum; import com.engine.salary.enums.siaccount.EmployeeStatusEnum; -import com.engine.salary.enums.sicategory.DeleteTypeEnum; -import com.engine.salary.enums.sicategory.NonPaymentEnum; -import com.engine.salary.enums.sicategory.PaymentScopeEnum; -import com.engine.salary.enums.sicategory.WelfareTypeEnum; +import com.engine.salary.enums.sicategory.*; import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; import com.engine.salary.exception.SalaryRunTimeException; -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.siarchives.*; +import com.engine.salary.mapper.sicategory.ICategoryMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; +import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; +import com.engine.salary.mapper.taxagent.TaxAgentMapper; import com.engine.salary.service.SIArchivesService; +import com.engine.salary.service.SalaryEmployeeService; import com.engine.salary.service.TaxAgentEmpChangeService; import com.engine.salary.service.TaxAgentService; 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.OpenEnum; import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; -import com.engine.salary.util.SalaryEntityUtil; -import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.*; +import com.engine.salary.util.db.IdGenerator; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.wrapper.TaxAgentWrapper; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.SqlSession; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.BeanUtils; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StopWatch; +import weaver.conn.mybatis.MyBatisFactory; import weaver.general.BaseBean; import weaver.general.Util; import weaver.hrm.User; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; +import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_AUTO_ADJUST; +import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_DIFF_BY_PER_AND_COM; + /** * @Author weaver_cl * @Description: @@ -70,7 +101,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log")); - private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); private EncryptUtil encryptUtil = new EncryptUtil(); @@ -102,6 +133,22 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService return MapperProxyFactory.getProxy(OtherSchemeMapper.class); } + private TaxAgentMapper getTaxAgentMapper() { + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private TaxAgentWrapper getTaxAgentWrapper(User user) { + return ServiceUtil.getService(TaxAgentWrapper.class, user); + } + @Override public Map getTips(Map params) { return commandExecutor.execute(new SIArchivesTipsCmd(params, user)); @@ -114,20 +161,20 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService Collection taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId); Map apidatas = new HashMap<>(16); - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); - siArchivesBiz.setNeedAuth(needAuth); - siArchivesBiz.setTaxAgentPOS(taxAgentPOS); +// SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +//// siArchivesBiz.setNeedAuth(needAuth); +//// siArchivesBiz.setTaxAgentPOS(taxAgentPOS); WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum) params.get("welfareTypeEnum"); Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId"))); Long paymentOrganization = welfareTypeEnum != null ? Long.valueOf(Util.null2String(params.get("paymentOrganization"))) : null; - apidatas = siArchivesBiz.getBaseForm(welfareTypeEnum, employeeId, (long) user.getUID(), user, paymentOrganization); +// apidatas = siArchivesBiz.getBaseForm(welfareTypeEnum, employeeId, (long) user.getUID(), user, paymentOrganization); + apidatas = getBaseForm(welfareTypeEnum, employeeId, paymentOrganization, taxAgentPOS); return apidatas; } @Override public Map getPaymentForm(Map params) { Map apidatas = new HashMap<>(16); - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum) params.get("welfareTypeEnum"); Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId"))); String schemeIdStr = Util.null2String(params.get("schemeId")); @@ -136,16 +183,31 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService if (StringUtils.isNotBlank(schemeIdStr)) { schemeId = Long.valueOf(schemeIdStr); } - - apidatas = siArchivesBiz.getPaymentForm(user, welfareTypeEnum, employeeId, (long) user.getUID(), schemeId, paymentOrganization); +// apidatas = siArchivesBiz.getPaymentForm(user, welfareTypeEnum, employeeId, (long) user.getUID(), schemeId, paymentOrganization); + apidatas = getPaymentForm(user, welfareTypeEnum, employeeId, schemeId, paymentOrganization); return apidatas; } @Override public String insert(InsuranceArchivesSaveParam param) { - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); - siArchivesBiz.insert(param, user); + SalaryAssert.notNull(param.getWelfareType(), "福利类型为空"); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + boolean welBaseDiffSign = welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + switch (param.getWelfareType()) { + case SOCIAL_SECURITY: + socialSave(param, user, welBaseDiffSign); + break; + case ACCUMULATION_FUND: + fundSave(param, user, welBaseDiffSign); + break; + case OTHER: + otherSave(param, user, welBaseDiffSign); + break; + default: + throw new SalaryRunTimeException("福利类型不存在"); + } return null; } @@ -187,8 +249,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService } Map apidatas = new HashMap<>(16); - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); - apidatas = siArchivesBiz.listPage(param, (long) user.getUID()); +// apidatas = siArchivesBiz.listPage(param, (long) user.getUID()); + apidatas = listPage(param, (long) user.getUID()); log.info("各操作计时 {}", sw.prettyPrint()); return apidatas; @@ -200,8 +262,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ private void handleHistoryData(long currentEmployeeId) { //如果触发历史数据处理,则进行一次全量增员 - if (siArchivesBiz.createOldInsuranceBaseInfo(currentEmployeeId)) { - + if (createOldInsuranceBaseInfo(currentEmployeeId)) { //批量增员 List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) @@ -576,8 +637,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService @Override public Map getSearchCondition(Map param) { Map apidatas = new HashMap<>(16); - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); - apidatas = siArchivesBiz.getSearchCondition(user); +// apidatas = siArchivesBiz.getSearchCondition(user); + apidatas = getSearchCondition(); return apidatas; } @@ -607,8 +668,10 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService if (insuranceArchivesEmployeePOS == null) { insuranceArchivesEmployeePOS = new ArrayList<>(); } - List> records = siArchivesBiz.buildTableData(insuranceArchivesEmployeePOS); - List columns = siArchivesBiz.buildWeaTableColumns(insuranceArchivesEmployeePOS, user.getUID()); +// List> records = siArchivesBiz.buildTableData(insuranceArchivesEmployeePOS); + List> records = buildTableData(insuranceArchivesEmployeePOS); +// List columns = siArchivesBiz.buildWeaTableColumns(insuranceArchivesEmployeePOS, user.getUID()); + List columns = buildWeaTableColumns(insuranceArchivesEmployeePOS); //工作簿list List> excelSheetData = new ArrayList<>(); @@ -1185,7 +1248,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService if (param.getWelfareTypeEnum() == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "参数错误")); } - List adjustHistoryDTOS = siArchivesBiz.getAdjustHistoryList(param.getPaymentOrganization(), param.getEmployeeId()); +// List adjustHistoryDTOS = siArchivesBiz.getAdjustHistoryList(param.getPaymentOrganization(), param.getEmployeeId()); + List adjustHistoryDTOS = getAdjustHistoryList(param.getPaymentOrganization(), param.getEmployeeId()); List targetHistory = adjustHistoryDTOS.stream() .filter(f -> f.getWelfareType().equals(param.getWelfareTypeEnum().getValue())).collect(Collectors.toList()); @@ -1199,7 +1263,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService @Override public PageInfo historyListByEmployeeIdAndOperator(SIArchiveBaseHistoryListParam param) { - List adjustHistoryDTOS = siArchivesBiz.getBaseHistoryByEmployeeIdAndOperator(param.getOperator(), param.getEmployeeId()); +// List adjustHistoryDTOS = siArchivesBiz.getBaseHistoryByEmployeeIdAndOperator(param.getOperator(), param.getEmployeeId()); + List adjustHistoryDTOS = getBaseHistoryByEmployeeIdAndOperator(param.getOperator(), param.getEmployeeId()); // 分权逻辑 Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); @@ -1303,9 +1368,9 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService .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())); + adjustHistoryList.addAll(createAdjustInfo(socialAdjustInfo, (long) user.getUID())); + adjustHistoryList.addAll(createAdjustInfo(fundAdjustInfo, (long) user.getUID())); + adjustHistoryList.addAll(createAdjustInfo(otherAdjustInfo, (long) user.getUID())); //更新字段 toUpdateBaseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); @@ -1345,7 +1410,8 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService getFundSchemeMapper().updateById(toUpdateFundInfo); getOtherSchemeMapper().updateById(toUpdateOtherInfo); //基数调整记录入库 - siArchivesBiz.batchInsertAdjustHistory(adjustHistoryList, (long) user.getUID()); +// siArchivesBiz.batchInsertAdjustHistory(adjustHistoryList, (long) user.getUID()); + batchInsertAdjustHistory(adjustHistoryList); Map resultMap = new HashMap<>(2); String resultMsg = "操作成功"; @@ -1355,4 +1421,2429 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService resultMap.put("msg", resultMsg); return resultMap; } + + /*****以下代码为SIArchivesBiz中逻辑迁移,旨在减少Biz类的使用*****/ + /** + * 判断是否需要生成历史福利档案基本信息 + */ + public Boolean createOldInsuranceBaseInfo(Long creator) { + + + log.info("判断是否需要生成历史数据"); + List nowBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoList(); + if (nowBaseInfoList.size() == 0) { + StopWatch sw = new StopWatch(); + log.info("福利档案基础信息表为空,开始生成历史数据:"); + //处理公积金、其他福利档案中个税扣缴义务人为空的情况 + sw.start("处理公积金、其他福利档案中个税扣缴义务人为空的情况"); + List socialList = getSocialSchemeMapper().listAll(); + List fundList = getFundSchemeMapper().listAll(); + List otherList = getOtherSchemeMapper().listAll(); + + List updateFundList = new ArrayList<>(); + List updateOtherList = new ArrayList<>(); + for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) { + List toDealFundList = fundList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList()); + if (toDealFundList.size() > 0) { + InsuranceArchivesFundSchemePO toDealFundPO = toDealFundList.get(0); + toDealFundPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); + updateFundList.add(toDealFundPO); + } + + List toDealOtherList = otherList.stream().filter(f -> f.getEmployeeId().equals(socialSchemePO.getEmployeeId()) && f.getPaymentOrganization() == null).collect(Collectors.toList()); + if (toDealOtherList.size() > 0) { + InsuranceArchivesOtherSchemePO toDealOtherPO = toDealOtherList.get(0); + toDealOtherPO.setPaymentOrganization(socialSchemePO.getPaymentOrganization()); + updateOtherList.add(toDealOtherPO); + + } + + } + log.info("重置个税扣缴义务人id的公积金档案数:{}", updateFundList.size()); + log.info("重置个税扣缴义务人id的其他福利档案数:{}", updateOtherList.size()); + //更新公积金和其他福利档案 + updateFundList.forEach(getFundSchemeMapper()::updateById); + updateOtherList.forEach(getOtherSchemeMapper()::updateById); + sw.stop(); + + sw.start("处理待入库的历史福利档案基础信息并入库"); + List addBaseInfoList = new ArrayList<>(); + + List oldBaseInfoList = getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(null); + log.info("获取待生成的历史福利档案基础信息条数:{}", oldBaseInfoList.size()); + //去重 + oldBaseInfoList = oldBaseInfoList.stream() + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); + log.info("去重后的待生成历史福利档案基础信息条数:{}", oldBaseInfoList.size()); + if (oldBaseInfoList.size() > 0) { + //设置基本信息表字段 + for (InsuranceArchivesBaseInfoPO po : oldBaseInfoList) { + po.setId(IdGenerator.generate()); + po.setCreateTime(new Date()); + po.setDeleteType(0); + po.setCreator(creator); + po.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue()); + po.setUpdateTime(new Date()); + po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + + addBaseInfoList.add(po); + } + //将历史基本信息入库 + List> partition = Lists.partition(addBaseInfoList, 50); + partition.forEach(getInsuranceBaseInfoMapper()::batchSave); + + sw.stop(); + log.info("各操作计时 {}", sw.prettyPrint()); + return true; + }else { + return false; + } + + + } else { + return false; + } + + } + @Override + public List> buildTableData(List insuranceArchivesEmployeePOS) { + return buildTableData(insuranceArchivesEmployeePOS, false); + } + + /** + * @param insuranceArchivesEmployeePOS + * @return + */ + public List> buildTableData(List insuranceArchivesEmployeePOS, boolean export) { + + boolean welBaseDiffSign = isDiffWelBase(); + + List taxAgentPOS = getTaxAgentMapper().listAll(); + Map longTaxAgentPOMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId); + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + List> records = new ArrayList<>(); + try { + InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); + + Map socialSchemePOMap = encryptUtil.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesSocialSchemePO.class) + .stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getId, Function.identity())); + + Map fundSchemePOMap = encryptUtil.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesFundSchemePO.class) + .stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getId, Function.identity())); + List otherByEmployeeList = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS); + encryptUtil.decryptList(otherByEmployeeList, InsuranceArchivesOtherSchemePO.class); + Map otherSchemePOMap = otherByEmployeeList + .stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getId, Function.identity())); + insuranceArchivesEmployeePOS.forEach(item -> { + InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getSocialId()); + InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getFundId()); + InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getOtherId()); + Map map = new HashMap<>(); + map.put("employeeName", item.getUserName()); + map.put("paymentOrganizationName", longTaxAgentPOMap.get(item.getPaymentOrganization()) != null ? longTaxAgentPOMap.get(item.getPaymentOrganization()).getName() : ""); + map.put("employeeId", item.getEmployeeId()); + map.put("departmentName", item.getDepartmentName()); + map.put("subcompanyName", item.getSubcompanyName()); + map.put("departmentId", item.getDepartmentId()); + map.put("jobNum", item.getJobNum()); + map.put("companystartdate", item.getCompanystartdate()); + map.put("dismissdate", item.getDimissionDate()); + map.put("mobile", item.getTelephone()); + map.put("siSchemeId", item.getSiSchemeId()); + map.put("fundSchemeId", item.getFundSchemeId()); + map.put("otherSchemeId", item.getOtherSchemeId()); + map.put("status", item.getUserStatus() != null ? UserStatusEnum.getDefaultLabelByValue(item.getUserStatus()) : ""); + map.put("baseInfo", item.getBaseInfoId()); + map.put("paymentOrganization", item.getPaymentOrganization()); + if (socialItem != null) { + map.put("socialName", insuranceSchemeMapper.querySchemeName(socialItem.getSocialSchemeId())); + Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map socialComJson = JSON.parseObject(socialItem.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + socialComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (socialJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(socialItem.getSocialSchemeId()); + socialJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("socialAccount", socialItem.getSocialAccount()); + map.put("socialStartTime", socialItem.getSocialStartTime()); + map.put("socialEndTime", socialItem.getSocialEndTime()); + } + if (fundItem != null) { + map.put("fundName", insuranceSchemeMapper.querySchemeName(fundItem.getFundSchemeId())); + map.put("fundAccount", fundItem.getFundAccount()); + Map fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map fundComJson = JSON.parseObject(fundItem.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + fundComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (fundJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(fundItem.getFundSchemeId()); + fundJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("supplementFundAccount", fundItem.getSupplementFundAccount()); + map.put("fundStartTime", fundItem.getFundStartTime()); + map.put("fundEndTime", fundItem.getFundEndTime()); + + } + if (otherItem != null) { + map.put("otherName", insuranceSchemeMapper.querySchemeName(otherItem.getOtherSchemeId())); + Map otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (welBaseDiffSign) { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "per", v); + } + }); + } + Map otherComJson = JSON.parseObject(otherItem.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + otherComJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k + "com", v); + } + }); + } + } else { + if (otherJson != null) { + //查询该福利方案下开启缴纳的福利项 + List insuranceIdList = payInsuranceIds(otherItem.getOtherSchemeId()); + otherJson.forEach((k, v) -> { + if (insuranceIdList.contains(Long.valueOf(k))) { + map.put(k, v); + } + }); + } + } + + map.put("otherStartTime", otherItem.getOtherStartTime()); + map.put("otherEndTime", otherItem.getOtherEndTime()); + } + records.add(map); + }); + return records; + + } finally { + sqlSession.close(); + } + } + + @Override + public boolean isDiffWelBase() { + User user = (User) SalaryContext.get().getValue("user"); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + + return welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + } + + /** + * 根据人员id和个税扣缴人id获取记录 + */ + public List getSocialByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List socialList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(po); + if (socialList.size() > 0) { + allList.add(socialList.get(0)); + } + } + return allList; + } finally { + sqlSession.close(); + } + } + + public List getFundByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List fundList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(po); + if (fundList.size() > 0) { + allList.add(fundList.get(0)); + } + } + return allList; + } finally { + sqlSession.close(); + } + } + + public List getOtherByEmployeeIdAndPayOrg(List insuranceArchivesEmployeePOS) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + List allList = new ArrayList<>(); + for (InsuranceArchivesEmployeePO po : insuranceArchivesEmployeePOS) { + List otherList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(po); + if (otherList.size() > 0) { + allList.add(otherList.get(0)); + } + } + return allList; + } finally { + sqlSession.close(); + } + } + + @Override + public List payInsuranceIds(Long socialSchemeId, Integer paymentScope) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue()) && f.getPaymentScope().equals(paymentScope)) + .map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + } + return insuranceIdList; + } + + @Override + public List payInsuranceIds(Long socialSchemeId) { + //查询该福利方案下开启缴纳的福利项 + List detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialSchemeId); + List insuranceIdList = new ArrayList<>(); + if (detailPOS != null && detailPOS.size() > 0) { + //开启缴纳的 + insuranceIdList = detailPOS.stream().filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue())).map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + } + return insuranceIdList; + } + + @Override + public List buildWeaTableColumns(List insuranceArchivesEmployeePOS) { + + Map> titleMap = buildColumnTitle(insuranceArchivesEmployeePOS); + List list = new ArrayList<>(); + WeaTableColumn nameColumn = new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel(0, "姓名"), "employeeName"); + nameColumn.setFixed("left"); + list.add(nameColumn); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人"), "paymentOrganizationName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "分部"), "subcompanyName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "部门"), "departmentName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "手机号"), "mobile")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "员工状态"), "status")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "工号"), "jobNum")); + + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "入职日期"), "companystartdate")); +// list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "合同到期日期"), "dismissdate")); + + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "社保方案名称"), "socialName")); + titleMap.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "社保账号"), "socialAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "社保起始缴纳月"), "socialStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "社保最后缴纳月"), "socialEndTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "公积金方案名称"), "fundName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "公积金账号"), "fundAccount")); + titleMap.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "补充公积金账号"), "supplementFundAccount")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "公积金起始缴纳月"), "fundStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "公积金最后缴纳月"), "fundEndTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "其他福利方案名称"), "otherName")); + titleMap.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "其他福利起始缴纳月"), "otherStartTime")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(0, "其他福利最后缴纳月"), "otherEndTime")); + return list; + } + + public Map> buildColumnTitle(List insuranceArchivesEmployeePOS) { + + boolean welBaseDiffSign = isDiffWelBase(); + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + Map> result = new HashMap<>(); + + insuranceArchivesEmployeePOS = insuranceArchivesEmployeePOS.stream() + .filter(f -> f.getEmployeeId() != null) + .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesEmployeePO::getEmployeeId))), ArrayList::new)); + try { + + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + ICategoryMapper iCategoryMapper = sqlSession.getMapper(ICategoryMapper.class); + + Set socialSet = new HashSet<>(); + Set fundSet = new HashSet<>(); + Set otherSet = new HashSet<>(); + + Set socialComSet = new HashSet<>(); + Set fundComSet = new HashSet<>(); + Set otherComSet = new HashSet<>(); + + insuranceArchivesEmployeePOS.forEach(item -> { + List socialList = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(socialList, InsuranceArchivesSocialSchemePO.class); + List fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(fundList, InsuranceArchivesFundSchemePO.class); + List otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(item.getEmployeeId())); + encryptUtil.decryptList(otherList, InsuranceArchivesOtherSchemePO.class); + if (socialList.size() > 0) { + for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) { + + Map socialJson = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (socialJson != null) { + socialJson.forEach((k, v) -> socialSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map socialComJson = JSON.parseObject(socialSchemePO.getSocialPaymentComBaseString(), new TypeReference>() { + }); + if (socialComJson != null) { + socialComJson.forEach((k, v) -> socialComSet.add(k)); + } + } + } + + } + if (fundList.size() > 0) { + for (InsuranceArchivesFundSchemePO fundSchemePO : fundList) { + Map fundJson = JSON.parseObject(fundSchemePO.getFundPaymentBaseString(), new TypeReference>() { + }); + if (fundJson != null) { + fundJson.forEach((k, v) -> fundSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map fundComJson = JSON.parseObject(fundSchemePO.getFundPaymentComBaseString(), new TypeReference>() { + }); + if (fundComJson != null) { + fundComJson.forEach((k, v) -> fundComSet.add(k)); + } + } + } + + } + if (otherList.size() > 0) { + for (InsuranceArchivesOtherSchemePO otherSchemePO : otherList) { + Map otherJson = JSON.parseObject(otherSchemePO.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (otherJson != null) { + otherJson.forEach((k, v) -> otherSet.add(k)); + } + //如果需要区分个人和公司福利基数 + if (welBaseDiffSign) { + Map otherComJson = JSON.parseObject(otherSchemePO.getOtherPaymentComBaseString(), new TypeReference>() { + }); + if (otherComJson != null) { + otherComJson.forEach((k, v) -> otherComSet.add(k)); + } + } + } + + } + }); + Map socialMap = new HashMap<>(); + Map socialComMap = new HashMap<>(); + Map socialCollect = new HashMap<>(); + Map customSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), null) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + + Map sysSocial = iCategoryMapper.listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), DataTypeEnum.SYSTEM.getValue()) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + + socialCollect.putAll(customSocial); + socialCollect.putAll(sysSocial); + + if (welBaseDiffSign) { + socialSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialMap.put(item + "per", socialCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + socialComSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialComMap.put(item + "com", socialCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + socialSet.forEach(item -> { + if (socialCollect.containsKey(Long.valueOf(item))) { + socialMap.put(item, socialCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + Map fundMap = new HashMap<>(); + Map fundComMap = new HashMap<>(); + Map fundCollect = new HashMap<>(); + Map customFund = iCategoryMapper.listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysFund = iCategoryMapper.listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + fundCollect.putAll(customFund); + fundCollect.putAll(sysFund); + if (welBaseDiffSign) { + fundSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundMap.put(item + "per", fundCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + fundComSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundComMap.put(item + "com", fundCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + fundSet.forEach(item -> { + if (fundCollect.containsKey(Long.valueOf(item))) { + fundMap.put(item, fundCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + Map otherMap = new HashMap<>(); + Map otherComMap = new HashMap<>(); + Map otherCollect = new HashMap<>(); + Map customOther = iCategoryMapper.listByWelfareType(WelfareTypeEnum.OTHER.getValue(), null).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysOther = iCategoryMapper.listByWelfareType(WelfareTypeEnum.OTHER.getValue(), DataTypeEnum.SYSTEM.getValue()).stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + otherCollect.putAll(customOther); + otherCollect.putAll(sysOther); + + if (welBaseDiffSign) { + otherSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherMap.put(item + "per", otherCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"个人")); + } + }); + otherComSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherComMap.put(item + "com", otherCollect.get(Long.valueOf(item)).getInsuranceName() + + SalaryI18nUtil.getI18nLabel(0, "申报基数") + + SalaryI18nUtil.getI18nLabel(0,"单位")); + } + }); + } else { + otherSet.forEach(item -> { + if (otherCollect.containsKey(Long.valueOf(item))) { + otherMap.put(item, otherCollect.get(Long.valueOf(item)).getInsuranceName() + SalaryI18nUtil.getI18nLabel(0, "申报基数")); + } + }); + } + // map根据key排序 + LinkedHashMap socialMapWithAscKey = socialMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundMapWithAscKey = fundMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherMapWithAscKey = otherMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + if (welBaseDiffSign) { + LinkedHashMap socialComMapWithAscKey = socialComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap fundComMapWithAscKey = fundComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + LinkedHashMap otherComMapWithAscKey = otherComMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, + LinkedHashMap::new)); + socialMapWithAscKey.putAll(socialComMapWithAscKey); + fundMapWithAscKey.putAll(fundComMapWithAscKey); + otherMapWithAscKey.putAll(otherComMapWithAscKey); + } + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialMapWithAscKey); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundMapWithAscKey); + result.put(WelfareTypeEnum.OTHER.getValue(), otherMapWithAscKey); + return result; + } finally { + sqlSession.close(); + } + + + } + + /** + * 获取福利档案基数调整记录 + * + */ + public List getAdjustHistoryList(Long paymentOrganization, Long employeeId) { + + if (paymentOrganization == null && employeeId == null) { + return null; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceBaseAdjustHistoryMapper mapper = sqlSession.getMapper(InsuranceBaseAdjustHistoryMapper.class); + List list = mapper.listByEmployeeIdAndPayOrg(paymentOrganization, employeeId); + return list; + } finally { + sqlSession.close(); + } + } + + /** + * 获取福利档案基数调整记录 + * + */ + public List getBaseHistoryByEmployeeIdAndOperator(Long operator, Long employeeId) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceBaseAdjustHistoryMapper mapper = sqlSession.getMapper(InsuranceBaseAdjustHistoryMapper.class); + List empList = mapper.listByEmployeeIdAndOperator(operator, employeeId); + List extEmpList = mapper.listByExtEmpIdAndOperator(operator, employeeId); + if (extEmpList != null) { + empList.addAll(extEmpList); + empList = empList.stream().filter(f -> org.apache.commons.lang.StringUtils.isNotBlank(f.getEmployeeName())) + .sorted(Comparator.comparing(InsuranceArchivesBaseHistoryDTO::getOperateTime).reversed()).collect(Collectors.toList()); + } + return empList; + } finally { + sqlSession.close(); + } + } + + //生成基数调整记录(基数单元未变化则忽略) + public List createAdjustInfo(InsuranceArchivesBaseHistoryDTO adjustInfo, Long creator) { + Date now = new Date(); + boolean welBaseDiffSign = isDiffWelBase(); + + List toCreateAdjustHistoryList = new ArrayList<>(); + //旧档案不存在基数信息,则直接遍历新的基数数据,生成调整记录;旧档案存在基数信息,则合并新旧基数数据,遍历合并后的技术数据中的key,生成调整记录。 + if(org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustAfterBaseJson()) && org.apache.commons.lang.StringUtils.isBlank(adjustInfo.getAdjustBeforeBaseJson())) { + Map adjustAfterBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterBaseJson(), new TypeReference>() { + }); + for (String key : adjustAfterBaseMap.keySet()) { + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustAfterBaseValue((String) adjustAfterBaseMap.get(key)); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(welBaseDiffSign ? PaymentScopeEnum.SCOPE_PERSON.getValue().toString() : PaymentScopeEnum.SCOPE_PERSON.getValue().toString() + "," + PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + toCreateAdjustHistoryList.add(adjustItem); + } + } else if (org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustAfterBaseJson()) && org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustBeforeBaseJson())) { + Map adjustAfterBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterBaseJson(), new TypeReference>() { + }); + Map adjustBeforeBaseMap = JSON.parseObject(adjustInfo.getAdjustBeforeBaseJson(), new TypeReference>() { + }); + Map reDealMap = new HashMap<>(); + if (adjustAfterBaseMap != null) { + reDealMap.putAll(adjustAfterBaseMap); + } + if (adjustBeforeBaseMap != null) { + reDealMap.putAll(adjustBeforeBaseMap); + } + if (reDealMap.size() >0) { + for (String key : reDealMap.keySet()) { + String beforeValue = (String) adjustBeforeBaseMap.get(key); + String afterValue = (String) adjustAfterBaseMap.get(key); + if (SalaryEntityUtil.empty2Zero(beforeValue).compareTo(SalaryEntityUtil.empty2Zero(afterValue)) == 0) { + continue; + } + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustBeforeBaseValue(beforeValue); + adjustItem.setAdjustAfterBaseValue(afterValue); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(welBaseDiffSign ? PaymentScopeEnum.SCOPE_PERSON.getValue().toString() : PaymentScopeEnum.SCOPE_PERSON.getValue().toString() + "," + PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + + toCreateAdjustHistoryList.add(adjustItem); + } + } + + } + //如果系统应用设置拆分了个人和公司福利基数,则对adjustBeforeComBaseJson,adjustAfterComBaseJson也进行处理 + if (welBaseDiffSign) { + //旧档案不存在基数信息,则直接遍历新的基数数据,生成调整记录;旧档案存在基数信息,则合并新旧基数数据,遍历合并后的技术数据中的key,生成调整记录。 + if(org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustAfterComBaseJson()) && org.apache.commons.lang.StringUtils.isBlank(adjustInfo.getAdjustBeforeComBaseJson())) { + Map adjustAfterComBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterComBaseJson(), new TypeReference>() { + }); + for (String key : adjustAfterComBaseMap.keySet()) { + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustAfterBaseValue((String) adjustAfterComBaseMap.get(key)); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope(PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + toCreateAdjustHistoryList.add(adjustItem); + } + } else if (org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustAfterComBaseJson()) && org.apache.commons.lang.StringUtils.isNotBlank(adjustInfo.getAdjustBeforeComBaseJson())) { + Map adjustAfterComBaseMap = JSON.parseObject(adjustInfo.getAdjustAfterComBaseJson(), new TypeReference>() { + }); + Map adjustBeforeComBaseMap = JSON.parseObject(adjustInfo.getAdjustBeforeComBaseJson(), new TypeReference>() { + }); + Map reDealMap = new HashMap<>(); + if (adjustAfterComBaseMap != null) { + reDealMap.putAll(adjustAfterComBaseMap); + } + if (adjustBeforeComBaseMap != null) { + reDealMap.putAll(adjustBeforeComBaseMap); + } + if (reDealMap.size() >0) { + for (String key : reDealMap.keySet()) { + String beforeValue = (String) adjustBeforeComBaseMap.get(key); + String afterValue = (String) adjustAfterComBaseMap.get(key); + if (SalaryEntityUtil.empty2Zero(beforeValue).compareTo(SalaryEntityUtil.empty2Zero(afterValue)) == 0) { + continue; + } + InsuranceArchivesBaseHistoryPO adjustItem = new InsuranceArchivesBaseHistoryPO(); + BeanUtils.copyProperties(adjustInfo, adjustItem); + adjustItem.setAdjustWelfareItemId(Long.valueOf(key)); + adjustItem.setAdjustBeforeBaseValue(beforeValue); + adjustItem.setAdjustAfterBaseValue(afterValue); + adjustItem.setOperateTime(now); + adjustItem.setOperator(creator); + adjustItem.setCreator(creator); + adjustItem.setCreateTime(now); + adjustItem.setUpdateTime(now); + adjustItem.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()); + adjustItem.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); + adjustItem.setId(IdGenerator.generate()); + adjustItem.setPaymentScope( PaymentScopeEnum.SCOPE_COMPANY.getValue().toString()); + + toCreateAdjustHistoryList.add(adjustItem); + } + } + + } + } + return toCreateAdjustHistoryList; + } + + /** + * 新增福利档案基数调整记录 + * + */ + @Override + public void batchInsertAdjustHistory(List adjustHistoryList) { + + if (org.apache.commons.collections.CollectionUtils.isEmpty(adjustHistoryList)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceBaseAdjustHistoryMapper mapper = sqlSession.getMapper(InsuranceBaseAdjustHistoryMapper.class); + List> partition = Lists.partition(adjustHistoryList, 100); + partition.forEach(mapper::batchSave); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + public Map getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long paymentOrganization, Collection taxAgentPOS) { + Map data = new HashMap<>(16); + SalaryAssert.notNull(employeeId, SalaryI18nUtil.getI18nLabel(0, "员工id不可为空")); + List employeeByIds = getSalaryEmployeeService(user).getEmployeeByIdsAll(Collections.singletonList(employeeId)); + SalaryAssert.notEmpty(employeeByIds, SalaryI18nUtil.getI18nLabel(0, "员工信息不存在")); + DataCollectionEmployee item = employeeByIds.get(0); + + + if (welfareType == null) { + //基础信息表单 + InsuranceArchivesBaseDTO insuranceArchivesBaseDTO = InsuranceArchivesBaseDTO.builder().department(item.getDepartmentName()) + .hiredate(item.getCompanystartdate()) + .position(item.getJobtitleName()) + .username(item.getUsername()) + .telephone(item.getMobile()) + .dimissionDate(item.getDismissdate()) + .build(); + + data.put("data", insuranceArchivesBaseDTO); + return data; + } + + SISchemeBiz siSchemeBiz = new SISchemeBiz(); + List list = siSchemeBiz.listAll(); + // 过滤可见性范围 + list = filterList(list, taxAgentPOS); + List selectItems = new ArrayList<>(); + List addGroups = new ArrayList<>(); + List paymentOptions = paymentOrganizationOptions(taxAgentPOS); + List underTakeOptions = Arrays.stream(UndertakerEnum.values()) + .map(e -> new SearchConditionOption(e.getValue().toString(), e.getDefaultLabel())).collect(Collectors.toList()); + + + //返回数据 + switch (welfareType) { + case SOCIAL_SECURITY: + InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(employeeId, paymentOrganization); + List socialList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())).collect(Collectors.toList()); + List socialOptions = new ArrayList<>(); + socialList.forEach(social -> { + socialOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem socialName = SalaryFormItemUtil.selectItem(user, socialOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "社保方案名称"), "socialSchemeId"); + SearchConditionItem organizationName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "社保缴纳组织"), "paymentOrganization"); + SearchConditionItem underTakeName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "社保个人实际承担方"), "underTake"); + + selectItems.add(socialName); + selectItems.add(organizationName); + selectItems.add(underTakeName); + + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "社保基础信息"), true, selectItems)); + data.put("data", insuranceArchivesSocialSchemeDTO); + data.put("items", addGroups); + break; + case ACCUMULATION_FUND: + InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(employeeId, paymentOrganization); + List fundList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())).collect(Collectors.toList()); + List fundOptions = new ArrayList<>(); + fundList.forEach(social -> { + fundOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem fundName = SalaryFormItemUtil.selectItem(user, fundOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "公积金方案名称"), "fundSchemeId"); + SearchConditionItem organizationFundName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "公积金缴纳组织"), "paymentOrganization"); + SearchConditionItem underTakeFundName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "公积金个人实际承担方"), "underTake"); + + selectItems.add(fundName); + selectItems.add(organizationFundName); + selectItems.add(underTakeFundName); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "公积金基础信息"), true, selectItems)); + data.put("data", insuranceArchivesFundSchemeDTO); + data.put("items", addGroups); + break; + case OTHER: + InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(employeeId, paymentOrganization); + List otherList = list.stream().filter(e -> Objects.equals(e.getWelfareType(), WelfareTypeEnum.OTHER.getValue())).collect(Collectors.toList()); + List otherOptions = new ArrayList<>(); + otherList.forEach(social -> { + otherOptions.add(new SearchConditionOption(Util.null2String(social.getId()), social.getSchemeName())); + }); + SearchConditionItem otherName = SalaryFormItemUtil.selectItem(user, otherOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "其他福利名称"), "otherSchemeId"); + SearchConditionItem organizationOtherName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "其他福利缴纳组织"), "paymentOrganization"); + SearchConditionItem underTakeOtherName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, SalaryI18nUtil.getI18nLabel(0, "其他福利个人实际承担方"), "underTake"); + + selectItems.add(otherName); + selectItems.add(organizationOtherName); + selectItems.add(underTakeOtherName); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "其他福利基础信息"), true, selectItems)); + data.put("data", insuranceArchivesOtherSchemeDTO); + data.put("items", addGroups); + break; + default: + } + return data; + } + + /*** + * @description 过滤没有权限访问的 + * @return List + * @author Harryxzy + * @date 2022/9/19 18:32 + */ + List filterList(List list, Collection taxAgentPOS){ + List ids = taxAgentPOS.stream().map(i -> String.valueOf(i.getId())).collect(Collectors.toList()); + List result = list.stream().filter(item -> { + boolean flag = true; + if (item.getSharedType()!= null && item.getSharedType().equals("1")) { + flag = false; + String taxAgentIds = item.getTaxAgentIds(); + if(org.apache.commons.lang.StringUtils.isNotBlank(taxAgentIds)){ + String splitFlag = ","; + String[] split = taxAgentIds.split(splitFlag); + for (int i = 0; i < split.length; i++) { + if (ids.contains(split[i])) { + flag = true; + } + } + } + } + return flag; + }).collect(Collectors.toList()); + return result; + } + + /** + * 社保缴纳组织 + * + * @return + */ + public List paymentOrganizationOptions(Collection taxAgentPOS) { + Collection list = taxAgentPOS; + if (org.apache.commons.collections.CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + return list + .stream() + .map(item -> new SearchConditionOption(String.valueOf(item.getId()), item.getName())).collect(Collectors.toList()); + } + + /** + * 其它基础表单 + * + * @param employeeId + * @return + */ + public InsuranceArchivesOtherSchemeDTO buildOtherForm(Long employeeId, Long paymentOrganization) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + List otherList = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(otherList, InsuranceArchivesOtherSchemePO.class); + InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = otherList.size() != 0 ? otherList.get(0) : null; + InsuranceArchivesOtherSchemeDTO data = InsuranceArchivesBO.convertOtherPOtoDTO(insuranceArchivesOtherSchemePO, employeeId); + if (insuranceArchivesOtherSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } finally { + sqlSession.close(); + } + + } + + /** + * 公积金基础表单 + * + * @param employeeId + * @return + */ + public InsuranceArchivesFundSchemeDTO buildFundForm(Long employeeId, Long paymentOrganization) { + + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + List fundList = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(fundList, InsuranceArchivesFundSchemePO.class); + InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = fundList.size() != 0 ? fundList.get(0) : null; + InsuranceArchivesFundSchemeDTO data = InsuranceArchivesBO.convertFundPOtoDTO(insuranceArchivesFundSchemePO, employeeId); + if (insuranceArchivesFundSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } finally { + sqlSession.close(); + } + + } + + /** + * 社保基础表单 + * + * @param employeeId + * @return + */ + public InsuranceArchivesSocialSchemeDTO buildSocialForm(Long employeeId, Long paymentOrganization) { + InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = getSocialByEmployeeId(employeeId, paymentOrganization); + InsuranceArchivesSocialSchemeDTO data = InsuranceArchivesBO.convertSocialPOtoDTO(insuranceArchivesSocialSchemePO, employeeId); + if (insuranceArchivesSocialSchemePO == null) { + data.setEmployeeId(employeeId); + data.setUnderTake(UndertakerEnum.SCOPE_PERSON.getValue().toString()); + } + return data; + } + + /** + * 获取社保档案表 + * + * @param employeeId + * @return + */ + public InsuranceArchivesSocialSchemePO getSocialByEmployeeId(Long employeeId, Long paymentOrganization) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List socialList = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + encryptUtil.decryptList(socialList, InsuranceArchivesSocialSchemePO.class); + return socialList.size() != 0 ? socialList.get(0) : null; + } finally { + sqlSession.close(); + } + } + + /** + * 获取详细表单 + * + * @param user + * @param welfareType + * @param employeeId + * @param schemeId + * @return + */ + public Map getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, Long schemeId, Long paymentOrganization) { + Map data = new HashMap<>(16); + //判断是否要区分个人和单位福利基数 + SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM); + boolean welBaseDiffSign = welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue()); + //判断是否要自动调整基数 + SalarySysConfPO welBaseAutoAdjust = getSalarySysConfService(user).getOneByCode(WEL_BASE_AUTO_ADJUST); + boolean welBaseAutoAdjustSign = welBaseAutoAdjust != null && welBaseAutoAdjust.getConfValue().equals(OpenEnum.OPEN.getValue()); + + switch (welfareType) { + case SOCIAL_SECURITY: + data = buildSocialPaymentForm(user, employeeId, schemeId,welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + case ACCUMULATION_FUND: + data = buildFundPaymentForm(user, employeeId, schemeId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + case OTHER: + data = buildOtherPaymentForm(user, employeeId, schemeId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign); + break; + default: + } + return data; + } + + /** + * 其他payForm + * + * @param employeeId + * @param schemeId + * @return + */ + public Map buildOtherPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + Map dataMap = new HashMap<>(); + InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getOtherPaymentBaseString()) + ? JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getOtherPaymentComBaseString()) + ? JSONObject.parseObject(data.getOtherPaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "其他福利缴纳基数"), true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "其他福利缴纳基数"), true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + } + + /** + * 公积金payForm + * + * @param employeeId + * @param schemeId + * @return + */ + public Map buildFundPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + + Map dataMap = new HashMap<>(); + InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getFundPaymentBaseString()) + ? JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getFundPaymentComBaseString()) + ? JSONObject.parseObject(data.getFundPaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "公积金缴纳基数"), true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "公积金缴纳基数"), true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + } + + /** + * 社保payForm + * + * @param employeeId + * @param schemeId + * @return + */ + public Map buildSocialPaymentForm(User user, Long employeeId, Long schemeId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) { + Map dataMap = new HashMap<>(); + InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, paymentOrganization); + Map insuranceValueMap = new HashMap<>(); + Map insuranceComValueMap = new HashMap<>(); + if (data != null) { + insuranceValueMap = StrUtil.isNotBlank(data.getSchemePaymentBaseString()) + ? JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference>() {}) : new HashMap<>(); + if (welBaseDiffSign) { + insuranceComValueMap = StrUtil.isNotBlank(data.getSchemePaymentComBaseString()) + ? JSONObject.parseObject(data.getSchemePaymentComBaseString(), new TypeReference>() {}) : new HashMap<>(); + } + } + + List addGroups = new ArrayList<>(); + List inputItems = buildPaymentBase(user, schemeId, welfareType, welBaseDiffSign); + //如果查询结果中存在 方案中缺失福利险种的值,设置初始值 + for (SearchConditionItem item : inputItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("data", insuranceValueMap); + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "社保缴纳基数"), true, inputItems)); + dataMap.put("items", addGroups); + if (welBaseDiffSign) { + List addComGroups = new ArrayList<>(); + List inputComItems = buildPaymentComBase(user, schemeId, welfareType); + addComGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0, "社保缴纳基数"), true, inputComItems)); + dataMap.put("comItems", addComGroups); + + for (SearchConditionItem item : inputComItems) { + String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null; + if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) { + String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0"; + insuranceComValueMap.put(insuranceId, basicValue); + } + } + dataMap.put("comData", insuranceComValueMap); + } + return dataMap; + + } + + /** + * 构造payment(items) + * + * @param schemeId + * @return + */ + public List buildPaymentBase(User user, Long schemeId, Integer welfareType, boolean welBaseDiffSign) { + List inputItems = new ArrayList<>(); + if (schemeId == null) { + return new ArrayList<>(); + } + List list = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_PERSON.getValue())).collect(Collectors.toList()); + if (!welBaseDiffSign) { + List perInsuranceIdList = list.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); + List moreComList = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_COMPANY.getValue()) && !perInsuranceIdList.contains(f.getInsuranceId())).collect(Collectors.toList()); + if (moreComList.size() > 0) { + list.addAll(moreComList); + } + } + + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + list.forEach(insuranceSchemeDetail -> { + ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId()); + if (iCategoryPO != null) { +// inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()))); + inputItems.add(SalaryFormItemUtil.inputNumberItemWithMaxAndMin(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()) + , insuranceSchemeDetail.getUpperLimit(), insuranceSchemeDetail.getLowerLimit())); + } + }); + return inputItems; + } + + public List buildPaymentComBase(User user, Long schemeId, Integer welfareType) { + List inputItems = new ArrayList<>(); + if (schemeId == null) { + return new ArrayList<>(); + } + List list = queryListByPrimaryIdIsPayment(schemeId, welfareType).stream() + .filter(f -> f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_COMPANY.getValue())).collect(Collectors.toList()); + SICategoryBiz siCategoryBiz = new SICategoryBiz(); + list.forEach(insuranceSchemeDetail -> { + ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId()); + if (iCategoryPO != null) { +// inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()))); + inputItems.add(SalaryFormItemUtil.inputNumberItemWithMaxAndMin(user, "precision:2", 2, 12, 2, iCategoryPO.getInsuranceName(), String.valueOf(insuranceSchemeDetail.getInsuranceId()) + , insuranceSchemeDetail.getUpperLimit(), insuranceSchemeDetail.getLowerLimit())); + } + }); + return inputItems; + } + + /** + * 获取方案明细 + * + * @param schemeId + * @return + */ + public List queryListByPrimaryIdIsPayment(Long schemeId, Integer welfareType) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); + List insuranceSchemeDetailPOS = insuranceSchemeDetailMapper.queryListByPrimaryIdIsPayment(schemeId, IsPaymentEnum.YES.getValue(), welfareType); + encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); + return insuranceSchemeDetailPOS; + } finally { + sqlSession.close(); + } + } + + public void otherSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + + InsuranceArchivesOtherSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesOtherSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0, "员工id为空"), param, param.getEmployeeId()); + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) && !SalaryDateUtil.checkYearMonth(param.getOtherEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + + List otherIds = new ArrayList(); + otherIds.add(param.getId()); + List oldOtherInfoList = otherSchemeMapper.getOtherById(otherIds); + + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getOtherSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + if (oldOtherInfoList.size() == 1) { + InsuranceArchivesOtherSchemePO oldOtherInfo = oldOtherInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldOtherInfo, InsuranceArchivesOtherSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldOtherInfo.getOtherPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldOtherInfo.getOtherSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldOtherInfo.getOtherPaymentComBaseString()); + //新数据 + InsuranceArchivesOtherSchemePO updateOtherInfo = + InsuranceArchivesOtherSchemePO.builder() + .id(oldOtherInfo.getId()) + .otherSchemeId(param.getOtherSchemeId()) + .otherStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) + .underTake(param.getUnderTake()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .welfareType(paramReq.getWelfareType().getValue()) + .otherEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) + .employeeId(param.getEmployeeId()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .updateTime(new Date()) + .nonPayment(param.getNonPayment()) + .creator(employeeId) + .paymentOrganization(param.getPaymentOrganization()) + .otherPaymentBaseString(paramReq.getPaymentForm()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateOtherInfo.getOtherSchemeId(),updateOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + } + encryptUtil.encrypt(updateOtherInfo, InsuranceArchivesOtherSchemePO.class); + otherSchemeMapper.updateById(updateOtherInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setOtherArchivesId(updateOtherInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + sqlSession.commit(); + } else { + otherSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesOtherSchemePO insertOtherInfo = InsuranceArchivesOtherSchemePO.builder() + .otherSchemeId(param.getOtherSchemeId()) + .otherStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherStartTime()) ? param.getOtherStartTime() : null) + .underTake(param.getUnderTake()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .welfareType(paramReq.getWelfareType().getValue()) + .otherEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getOtherEndTime()) ? param.getOtherEndTime() : null) + .employeeId(param.getEmployeeId()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(new Date()) + .updateTime(new Date()) + .nonPayment(param.getNonPayment()) + .creator(employeeId) + .paymentOrganization(param.getPaymentOrganization()) + .otherPaymentBaseString(paramReq.getPaymentForm()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertOtherInfo.setOtherPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertOtherInfo.getOtherSchemeId(),insertOtherInfo.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + } + encryptUtil.encrypt(insertOtherInfo, InsuranceArchivesOtherSchemePO.class); + otherSchemeMapper.insert(insertOtherInfo); + sqlSession.commit(); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List otherInfos = otherSchemeMapper.getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setOtherArchivesId(otherInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + } + + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); + + } finally { + sqlSession.close(); + } + } + + /** + * @param paramReq + * @param + */ + public void fundSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + InsuranceArchivesFundSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesFundSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0,"员工id为空"), param, param.getEmployeeId()); + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) && !SalaryDateUtil.checkYearMonth(param.getFundStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) && !SalaryDateUtil.checkYearMonth(param.getFundEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + + List fundIds = new ArrayList(); + fundIds.add(param.getId()); + List oldFundInfoList = fundSchemeMapper.getFundById(fundIds); + + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getFundSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + if (oldFundInfoList.size() == 1) { + InsuranceArchivesFundSchemePO oldFundInfo = oldFundInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldFundInfo, InsuranceArchivesFundSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldFundInfo.getFundPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldFundInfo.getFundSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldFundInfo.getFundPaymentComBaseString()); + //新数据 + InsuranceArchivesFundSchemePO updateFundInfo = InsuranceArchivesFundSchemePO.builder() + .id(oldFundInfo.getId()) + .fundSchemeId(param.getFundSchemeId()) + .fundAccount(param.getFundAccount()) + .fundEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) + .fundStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) + .fundPaymentBaseString(paramReq.getPaymentForm()) + .supplementFundAccount(param.getSupplementFundAccount()) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .underTake(param.getUnderTake()) + .paymentOrganization(param.getPaymentOrganization()) + .updateTime(new Date()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateFundInfo.getFundSchemeId(),updateFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + } + encryptUtil.encrypt(updateFundInfo, InsuranceArchivesFundSchemePO.class); + fundSchemeMapper.updateById(updateFundInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setFundArchivesId(updateFundInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + sqlSession.commit(); + } else { + fundSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesFundSchemePO insertFundInfo = InsuranceArchivesFundSchemePO.builder() + .fundSchemeId(param.getFundSchemeId()) + .fundAccount(param.getFundAccount()) + .fundEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundEndTime()) ? param.getFundEndTime() : null) + .fundStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getFundStartTime()) ? param.getFundStartTime() : null) + .fundPaymentBaseString(paramReq.getPaymentForm()) + .supplementFundAccount(param.getSupplementFundAccount()) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .underTake(param.getUnderTake()) + .paymentOrganization(param.getPaymentOrganization()) + .createTime(new Date()) + .updateTime(new Date()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .build(); + //校验福利基数是否符合上下限要求, + if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertFundInfo.setFundPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertFundInfo.getFundSchemeId(),insertFundInfo.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + } + encryptUtil.encrypt(insertFundInfo, InsuranceArchivesFundSchemePO.class); + fundSchemeMapper.insert(insertFundInfo); + sqlSession.commit(); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List fundInfos = fundSchemeMapper.getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setFundArchivesId(fundInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + + } + + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); + + } finally { + sqlSession.close(); + } + + } + + /** + * @param paramReq + * @param + */ + public void socialSave(InsuranceArchivesSaveParam paramReq, User user, boolean welBaseDiffSign) { + long employeeId = user.getUID(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + + InsuranceArchivesSocialSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesSocialSaveParam.class); + SalaryAssert.notNull(SalaryI18nUtil.getI18nLabel(0,"员工id为空"), param, param.getEmployeeId()); + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialStartTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "社保起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) && !SalaryDateUtil.checkYearMonth(param.getSocialEndTime())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "社保最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd")); + } + +// //删除社保数据 +// socialSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); + + //查询已有数据 + List socialIds = new ArrayList(); + socialIds.add(param.getId()); + List oldSocialInfoList = socialSchemeMapper.getSocialById(socialIds); + + //设置福利档案基数调整记录数据 + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(param.getSocialSchemeId()) + .adjustAfterBaseJson(paramReq.getPaymentForm()) + .adjustAfterComBaseJson(paramReq.getPaymentComForm()) + .welfareType(paramReq.getWelfareType().getValue()) + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + + //组装新数据 + if (oldSocialInfoList.size() == 1) { + //老数据 + InsuranceArchivesSocialSchemePO oldSocialInfo = oldSocialInfoList.get(0); + //设置福利档案基数调整记录数据 + encryptUtil.decrypt(oldSocialInfo, InsuranceArchivesSocialSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldSocialInfo.getSocialPaymentBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldSocialInfo.getSocialSchemeId()); + adjustInfo.setAdjustBeforeComBaseJson(oldSocialInfo.getSocialPaymentComBaseString()); + //新数据 + InsuranceArchivesSocialSchemePO updateSocialInfo = + InsuranceArchivesSocialSchemePO.builder() + .id(oldSocialInfo.getId()) + .welfareType(paramReq.getWelfareType().getValue()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .socialPaymentBaseString(paramReq.getPaymentForm()) + .socialSchemeId(param.getSocialSchemeId()) + .socialEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) + .socialStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(param.getEmployeeId()) + .updateTime(new Date()) + .underTake(param.getUnderTake()) + .socialAccount(param.getSchemeAccount()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + updateSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(updateSocialInfo.getSocialSchemeId(),updateSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + } + encryptUtil.encrypt(updateSocialInfo, InsuranceArchivesSocialSchemePO.class); + socialSchemeMapper.updateById(updateSocialInfo); + //更新base_info表状态 + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null && baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + //对于非系统人员,编辑后状态切换为正在缴纳 + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + baseInfoPO.setSocialArchivesId(updateSocialInfo.getId()); + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + sqlSession.commit(); + } else { + socialSchemeMapper.deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + //新建社保档案,并关联主表 + InsuranceArchivesSocialSchemePO insertSocialInfo = + InsuranceArchivesSocialSchemePO.builder() + .welfareType(paramReq.getWelfareType().getValue()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .socialPaymentBaseString(paramReq.getPaymentForm()) + .socialSchemeId(param.getSocialSchemeId()) + .socialEndTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialEndTime()) ? param.getSocialEndTime() : null) + .socialStartTime(org.apache.commons.lang.StringUtils.isNotBlank(param.getSocialStartTime()) ? param.getSocialStartTime() : null) + .creator(employeeId) + .nonPayment(param.getNonPayment()) + .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .employeeId(param.getEmployeeId()) + .createTime(new Date()) + .updateTime(new Date()) + .underTake(param.getUnderTake()) + .socialAccount(param.getSchemeAccount()) + .paymentOrganization(param.getPaymentOrganization()) + .build(); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + //需要拆分个人和公司福利基数时 + if (welBaseDiffSign) { + insertSocialInfo.setSocialPaymentComBaseString(paramReq.getPaymentComForm()); + //校验福利基数是否符合上下限要求 + if (!checkWelBaseLimit(insertSocialInfo.getSocialSchemeId(),insertSocialInfo.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保福利明细中的基数更新内容不符合相关基数上下限要求,请检查后重试!")); + } + } + encryptUtil.encrypt(insertSocialInfo, InsuranceArchivesSocialSchemePO.class); + socialSchemeMapper.insert(insertSocialInfo); + sqlSession.commit(); + + InsuranceArchivesBaseInfoPO baseInfoPO = getInsuranceBaseInfoMapper().getOneByEmployeeIdAndPayOrg(param.getPaymentOrganization(), param.getEmployeeId()); + if(baseInfoPO != null) { + List socialInfos = socialSchemeMapper.getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .employeeId(param.getEmployeeId()) + .paymentOrganization(param.getPaymentOrganization()) + .build()); + baseInfoPO.setSocialArchivesId(socialInfos.get(0).getId()); + //对于非系统人员,编辑后状态切换为正在缴纳 + if (baseInfoPO.getEmployeeType() != null && baseInfoPO.getEmployeeType().equals(DataCollectionEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) { + baseInfoPO.setRunStatus(EmployeeStatusEnum.PAYING.getValue()); + } + getInsuranceBaseInfoMapper().updateById(baseInfoPO); + } else { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "档案不存在!")); + } + + } + + //生成福利档案基数调整记录数据 + List adjustHistoryList = createAdjustInfo(adjustInfo, employeeId); + //福利档案基数调整记录数据入库 + batchInsertAdjustHistory(adjustHistoryList); + } finally { + sqlSession.close(); + } + } + + /** + * 校验福利基数是否符合上下限要求 + * @param primaryId + * @param paymentBaseString + * @return + */ + @Override + public Boolean checkWelBaseLimit(Long primaryId, String paymentBaseString, Integer paymentScope) { + + if (primaryId ==null || paymentBaseString == null) { + return true; + } + Map paymentBaseJson = JSON.parseObject(paymentBaseString, new HashMap().getClass()); + if (paymentBaseJson == null) { + return true; + } + + for (Map.Entry entry : paymentBaseJson.entrySet()) { + + //判断福利值是否为空/数字 + if (entry.getValue() == null || entry.getValue().length() == 0) { + continue; + } else if (!isNumeric(entry.getValue())) { + log.info("福利值非数字!"); + return false; + } + + //根据福利方案id、险种id、缴纳对象、缴费状态查询明细 + List insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().getByPI(primaryId, Long.valueOf(entry.getKey())); + log.info("福利方案id: {},, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + if (insuranceSchemeDetailPOList.size() == 0) { + log.info("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: {}, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + return false; + } + List isPaymentList = insuranceSchemeDetailPOList.stream() + .filter(f -> f.getIsPayment().equals(IsPaymentEnum.YES.getValue()) && f.getPaymentScope().equals(paymentScope)).collect(Collectors.toList()); + if (isPaymentList.size() > 0) { + InsuranceSchemeDetailPO insuranceSchemeDetailPO = isPaymentList.get(0); + + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit(); + String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit(); + if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) { + //数值低于对应福利明细下限 + log.info("社保基数 {} 数值 {} 低于对应福利明细下限 {}!", entry.getKey(), entry.getValue(), lowerLimit); + return false; + } + if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) { + //数值高于对应福利明细上限 + log.info("社保基数 {} 数值 {} 高于对应福利明细上限 {} !", entry.getKey(), entry.getValue(), upperLimit); + return false; + } + } else { + log.info("福利明细项属于未缴费状态,不对上下限进行约束"); + } + + + } + return true; + } + + + /** + * 校验福利基数是否符合上下限要求,并返回符合要求的数据 + * @param primaryId + * @param paymentBaseString + * @return + */ + @Override + public String checkAndBuildWelBaseWithLimit(Long primaryId, String paymentBaseString, Integer paymentScope) { + + if (primaryId ==null || paymentBaseString == null) { + return paymentBaseString; + } + Map paymentBaseJson = JSON.parseObject(paymentBaseString, HashMap.class); + Map newPaymentBaseJson = JSON.parseObject(paymentBaseString, HashMap.class); + if (paymentBaseJson == null) { + return null; + } + + for (Map.Entry entry : paymentBaseJson.entrySet()) { + + //判断福利值是否为空/数字 + if (entry.getValue() == null || entry.getValue().length() == 0) { + continue; + } else if (!isNumeric(entry.getValue())) { + log.info("福利值非数字!"); + newPaymentBaseJson.remove(entry.getKey()); + continue; + } + //根据福利方案id、险种id + List insuranceSchemeDetailPOList = getInsuranceSchemeDetailMapper().getByPI(primaryId, Long.valueOf(entry.getKey())); + log.info("福利方案id: {},, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + if (insuranceSchemeDetailPOList.size() == 0) { + log.info("根据福利方案id、险种id、缴纳对象查询明细为null!福利方案id: {}, 福利明细项id:{}", primaryId, Long.valueOf(entry.getKey())); + newPaymentBaseJson.remove(entry.getKey()); + continue; + } + List checkList = insuranceSchemeDetailPOList.stream() + .filter(f -> f.getPaymentScope().equals(paymentScope)).collect(Collectors.toList()); + if (checkList.size() > 0) { + InsuranceSchemeDetailPO insuranceSchemeDetailPO = checkList.get(0); + encryptUtil.decrypt(insuranceSchemeDetailPO, InsuranceSchemeDetailPO.class); + String lowerLimit = "0.000".equals(insuranceSchemeDetailPO.getLowerLimit()) ? null : insuranceSchemeDetailPO.getLowerLimit(); + String upperLimit = "0.000".equals(insuranceSchemeDetailPO.getUpperLimit()) ? null : insuranceSchemeDetailPO.getUpperLimit(); + if (lowerLimit != null && lowerLimit.length() > 0 && Double.parseDouble(entry.getValue()) < Double.parseDouble(lowerLimit)) { + //数值低于对应福利明细下限 + log.info("社保基数 {} 数值 {} 低于对应福利明细下限 {}!", entry.getKey(), entry.getValue(), lowerLimit); + newPaymentBaseJson.put(entry.getKey(), lowerLimit); + } + if (upperLimit != null && upperLimit.length() > 0 && Double.parseDouble(entry.getValue()) > Double.parseDouble(upperLimit)) { + //数值高于对应福利明细上限 + log.info("社保基数 {} 数值 {} 高于对应福利明细上限 {} !", entry.getKey(), entry.getValue(), upperLimit); + newPaymentBaseJson.put(entry.getKey(), upperLimit); + } + } + } + return JSON.toJSONString(newPaymentBaseJson); + } + + /** + * 判断字符串是否为整数或者小数或者负数 + */ + public static boolean isNumeric(String str){ + + Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$"); + Matcher isNum = pattern.matcher(str); + if (!isNum.matches()) { + return false; + } + return true; + + } + + /** + * 档案列表 + *

+ * 这里是一个含有比较多动态字段的列表,用的是手动拼装的方式 + * + * @param param 高级搜索条件 + * @param operateId 操作员id + * @return table + */ + public Map listPage(InsuranceArchivesListParam param, long operateId) { + Map apidatas = new HashMap<>(16); + InsuranceArchivesListParam request = InsuranceArchivesListParam.builder().build(); + if (param.getHireDate() != null && param.getHireDate().length == 2) { + param.setHiredateStart(param.getHireDate()[0]); + param.setHiredateEnd(param.getHireDate()[1]); + } + if (param.getDimissionDate() != null && param.getDimissionDate().length == 2) { + param.setDimissionDateStart(param.getDimissionDate()[0]); + param.setDimissionDateEnd(param.getDimissionDate()[1]); + } + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getDepartmentIdsStr())) { + request.setDepartmentIds(Arrays.stream(param.getDepartmentIdsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getSubcompanyIdsStr())) { + request.setSubcompanyIds(Arrays.stream(param.getSubcompanyIdsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getPositionsStr())) { + request.setPositions(Arrays.stream(param.getPositionsStr().split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + + if (org.apache.commons.lang.StringUtils.isNotBlank(param.getStatusesStr())) { + request.setStatuses(Arrays.stream(param.getStatusesStr().split(",")).map(String::new).collect(Collectors.toList())); + } + + request.setNeedAuth(param.getNeedAuth()); + request.setTaxAgentEmployeeIds(param.getTaxAgentEmployeeIds()); + request.setTaxAgentIds(param.getTaxAgentIds()); + + Integer current = param.getCurrent() == null ? 1 : param.getCurrent(); + Integer pageSize = param.getPageSize() == null ? 10 : param.getPageSize(); + long startNum = (current - 1) * pageSize; + param.setStartNum(startNum); + param.setPageSize(pageSize); +// request.setStatuses(param.getStatuses()); + request.setKeyword(param.getUserName()); + + request.setSiSchemeId(param.getSiSchemeId()); + request.setFundSchemeId(param.getFundSchemeId()); + request.setOtherSchemeId(param.getOtherSchemeId()); + + request.setPageSize(param.getPageSize()); + request.setCurrent(param.getCurrent()); + + request.setJobNum(param.getJobNum()); + + request.setOrderRule(param.getOrderRule()); + + request.setRunStatuses(param.getRunStatuses()); + + request.setTaxAgentId(param.getTaxAgentId()); + + request.setExtWelArchiveList(param.isExtWelArchiveList()); + + apidatas = listPageEmployeePOS(request, operateId); + + return apidatas; + } + + /** + * 获取员工的基本信息 + *

+ * 此处主要是一个公共接口,有多处引用。我们薪资系统只保存员工id(employeeId), + * 但是页面上需要展示员工的更多信息(姓名,部门,状态。。。), + * 所以这里主要是用于接收联表数据的一个接口 + * + * @param param 高级搜索条件,用于过滤数据 + * @param operateId 操作员id + * @return list + */ + public Map listPageEmployeePOS(InsuranceArchivesListParam param, long operateId) { + //是否分权 + Boolean needAuth = param.getNeedAuth(); + StopWatch sw = new StopWatch(); + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + Map datas = new HashMap<>(16); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List page = new ArrayList<>(); + PageInfo pageInfo = new PageInfo<>(InsuranceArchivesEmployeePO.class); + //获取福利档案列表数据 + if (needAuth) { + Collection taxAgentEmployeeIds = param.getTaxAgentEmployeeIds(); + Collection taxAgentIds = param.getTaxAgentIds(); + log.info("从数据库获取档案列表数据开始"); + sw.start("获取福利档案列表数据"); + if (param.isExtWelArchiveList()) { + page = socialSchemeMapper.queryExtEmployeeList(param); + } else { + page = socialSchemeMapper.queryEmployeeList(param); + } + sw.stop(); + log.info("从数据库获取档案列表数据完成!"); + page = page.stream().filter(f -> +// taxAgentEmployeeIds.contains(f.getEmployeeId())|| + taxAgentIds.contains(f.getPaymentOrganization()) + ).collect(Collectors.toList()); + // 填充总数和当页数据 + // 分页参数 + pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), InsuranceArchivesEmployeePO.class); + pageInfo.setTotal(page.size()); + pageInfo.setList(SalaryPageUtil.subList(pageInfo.getPageNum(), pageInfo.getPageSize(), page)); + } else { + log.info("从数据库获取档案列表数据开始"); + sw.start("获取档案列表数据"); + if (param.isExtWelArchiveList()) { + page = socialSchemeMapper.queryExtEmployeeList(param); + } else { + page = socialSchemeMapper.queryEmployeeList(param); + } + sw.stop(); + log.info("从数据库获取档案列表数据完成!"); + pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), + page, InsuranceArchivesEmployeePO.class); + } + List> records = null; + log.info("buildTableData方法处理福利档案列表数据开始"); + sw.start("buildTableData方法处理福利档案列表数据"); + if (param.getExportData() != null && param.getExportData()) { + records = buildTableData(pageInfo.getList(), true); + } else { + records = buildTableData(pageInfo.getList(), false); + } + sw.stop(); + log.info("buildTableData方法处理福利档案列表数据完成!"); + + log.info("buildWeaTableColumns方法处理福利档案列表数据开始"); + sw.start("buildWeaTableColumns方法处理福利档案列表数据"); + List columns = buildWeaTableColumns(pageInfo.getList()); + sw.stop(); + log.info("buildWeaTableColumns方法处理福利档案列表数据完成!"); + WeaTable table = new WeaTable(); + table.setColumns(columns); + //设置check是否可用 + List checkboxpopedomList = new ArrayList<>(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + checkboxpopedom.setPopedompara("column:system_type"); + checkboxpopedom.setShowmethod("com.engine.salary.transmethod.TaxRateTransMethod.getCheckBoxPopedom"); + checkboxpopedomList.add(checkboxpopedom); + table.setCheckboxList(checkboxpopedomList); + table.setCheckboxpopedom(null); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + datas.put("pageInfo", pageInfo); + datas.put("datas", records); + datas.put("columns", columns); + datas.put("dataKey", result.getResultMap()); + + log.info("各操作计时 {}", sw.prettyPrint()); + return datas; + + } finally { + sqlSession.close(); + } + } + + /** + * 高级搜索 + * + * @return + */ + public Map getSearchCondition() { + + List userStatusOptions = Arrays.stream(UserStatusEnum.values()).map(e -> new SearchConditionOption(String.valueOf(e.getValue()), e.getDefaultLabel())).collect(Collectors.toList()); + List list = new SISchemeBiz().listAll(); + + List schemeOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.SOCIAL_SECURITY.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + List fundOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.ACCUMULATION_FUND.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + List otherOption = list.stream().filter(item -> Objects.equals(item.getWelfareType(), WelfareTypeEnum.OTHER.getValue())) + .collect(Collectors.toList()) + .stream().map(item -> new SearchConditionOption(item.getId().toString(), item.getSchemeName())).collect(Collectors.toList()); + + List> taxAgentList = getTaxAgentWrapper(user).selectListAsAdmin(); + List taxAgentOption = taxAgentList.stream().map(item -> new SearchConditionOption(item.get("id").toString(), item.get("content").toString())).collect(Collectors.toList()); + + + Map apidatas = new HashMap(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList(); + + List conditionItems = new ArrayList(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel(SalaryI18nUtil.getI18nLabel(0,"姓名")); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + + //文本输入框 + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + jobNum.setFieldcol(16); //条件输入框所占宽度,默认值18 + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + jobNum.setLabel(SalaryI18nUtil.getI18nLabel(0,"工号")); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(jobNum); + + + SearchConditionItem departmentIds = conditionFactory.createCondition(ConditionType.BROWSER, 502329, "departmentIdsStr", "57"); + departmentIds.setColSpan(2); + departmentIds.setFieldcol(16); + departmentIds.setLabelcol(8); + departmentIds.setLabel(SalaryI18nUtil.getI18nLabel(0,"部门")); + conditionItems.add(departmentIds); + + + SearchConditionItem statuses = conditionFactory.createCondition(ConditionType.SELECT, 502327, "statusesStr"); + statuses.setInputType("select"); + statuses.setMultiple(true); + statuses.setOptions(userStatusOptions); + statuses.setColSpan(2); + statuses.setFieldcol(16); + statuses.setLabelcol(8); + statuses.setIsQuickSearch(true); + statuses.setLabel(SalaryI18nUtil.getI18nLabel(0,"状态")); + conditionItems.add(statuses); + + + SearchConditionItem positions = conditionFactory.createCondition(ConditionType.BROWSER, 502327, "positionsStr", "278"); + positions.setInputType("browser"); + positions.setColSpan(2); + positions.setFieldcol(16); + positions.setLabelcol(8); + positions.setIsQuickSearch(true); + positions.setLabel(SalaryI18nUtil.getI18nLabel(0,"岗位")); + conditionItems.add(positions); + + SearchConditionItem subcompanyIds = conditionFactory.createCondition(ConditionType.BROWSER, 502327, "subcompanyIdsStr", "194"); + subcompanyIds.setInputType("browser"); + subcompanyIds.setColSpan(2); + subcompanyIds.setFieldcol(16); + subcompanyIds.setLabelcol(8); + subcompanyIds.setIsQuickSearch(true); + subcompanyIds.setLabel(SalaryI18nUtil.getI18nLabel(0,"分部")); + conditionItems.add(subcompanyIds); + +// SearchConditionItem hireDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{"hireDate", "hireDate"}); +// hireDate.setInputType("timepicker"); +// hireDate.setColSpan(2); +// hireDate.setFieldcol(16); +// hireDate.setViewAttr(8); +// hireDate.setFormat("yyyy-MM-dd"); +// hireDate.setLabel(SalaryI18nUtil.getI18nLabel(0,"入职日期")); +// conditionItems.add(hireDate); +// +// +// SearchConditionItem dimissionDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{"dimissionDate", "dimissionDate"}); +// dimissionDate.setInputType("timepicker"); +// dimissionDate.setColSpan(2); +// dimissionDate.setFieldcol(16); +// dimissionDate.setViewAttr(8); +// dimissionDate.setFormat("yyyy-MM-dd"); +// dimissionDate.setLabel(SalaryI18nUtil.getI18nLabel(0,"离职日期")); +// conditionItems.add(dimissionDate); + + + SearchConditionItem siSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "siSchemeId"); + siSchemeId.setInputType("select"); + siSchemeId.setOptions(schemeOption); + siSchemeId.setColSpan(2); + siSchemeId.setFieldcol(16); + siSchemeId.setLabelcol(8); + siSchemeId.setIsQuickSearch(true); + siSchemeId.setLabel(SalaryI18nUtil.getI18nLabel(0,"社保方案")); + conditionItems.add(siSchemeId); + + + SearchConditionItem fundSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "fundSchemeId"); + fundSchemeId.setInputType("select"); + fundSchemeId.setOptions(fundOption); + fundSchemeId.setColSpan(2); + fundSchemeId.setFieldcol(16); + fundSchemeId.setLabelcol(8); + fundSchemeId.setIsQuickSearch(true); + fundSchemeId.setLabel(SalaryI18nUtil.getI18nLabel(0,"公积金方案")); + conditionItems.add(fundSchemeId); + + SearchConditionItem otherSchemeId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "otherSchemeId"); + otherSchemeId.setInputType("select"); + otherSchemeId.setOptions(otherOption); + otherSchemeId.setColSpan(2); + otherSchemeId.setFieldcol(16); + otherSchemeId.setLabelcol(8); + otherSchemeId.setIsQuickSearch(true); + otherSchemeId.setLabel(SalaryI18nUtil.getI18nLabel(0,"其他福利方案")); + conditionItems.add(otherSchemeId); + + SearchConditionItem taxAgentId = conditionFactory.createCondition(ConditionType.SELECT, 502327, "taxAgentId"); + taxAgentId.setInputType("select"); + taxAgentId.setOptions(taxAgentOption); + taxAgentId.setColSpan(2); + taxAgentId.setFieldcol(16); + taxAgentId.setLabelcol(8); + taxAgentId.setIsQuickSearch(true); + taxAgentId.setLabel(SalaryI18nUtil.getI18nLabel(0,"个税扣缴义务人")); + conditionItems.add(taxAgentId); + + addGroups.add(new SearchConditionGroup(SalaryI18nUtil.getI18nLabel(0,"常用条件"), true, conditionItems)); + apidatas.put("condition", addGroups); + return apidatas; + } + + @Override + public List getSocialByEmployeeIds(List employeeIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List socialList = socialSchemeMapper.getSocialByEmployeeId(longs); + allList.addAll(socialList); + } + return allList; + } finally { + sqlSession.close(); + } + } + + @Override + public List getFundByEmployeeIds(List employeeIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List fundList = fundSchemeMapper.getFundByEmployeeId(longs); + allList.addAll(fundList); + } + return allList; + } finally { + sqlSession.close(); + } + } + + @Override + public List getOtherByEmployeeIds(List employeeIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); + List> partition = Lists.partition(employeeIds, 1000); + List allList = new ArrayList<>(); + for (List longs : partition) { + List otherList = otherSchemeMapper.getOtherByEmployeeId(longs); + allList.addAll(otherList); + } + return allList; + } finally { + sqlSession.close(); + } + } + + /** + * 组装员工的社保,公积金,其他福利数据 + * + * @param ids 员工id集合 + * @return map + */ + @Override + public Map buildBatchAccount(List ids, Long paymentOrganization) { + if (org.apache.commons.collections.CollectionUtils.isEmpty(ids)) { + return new HashMap<>(); + } + //设置获取社保/公积金/其他福利档案方法的入参 + List insuranceArchivesEmployeePOS = new ArrayList<>(); + for (Long employeeId : ids) { + insuranceArchivesEmployeePOS.add(InsuranceArchivesEmployeePO.builder() + .employeeId(employeeId) + .paymentOrganization(paymentOrganization) + .build()); + } + + Map result = new HashMap<>(); + Map socialMap = new HashMap<>(); + Map funMap = new HashMap<>(); + Map otherMap = new HashMap<>(); + List socialPOS = encryptUtil.decryptList(this.getSocialByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesSocialSchemePO.class); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(socialPOS)) { + socialMap = socialPOS.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); + } + List fundPOS = encryptUtil.decryptList(this.getFundByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS), InsuranceArchivesFundSchemePO.class); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(fundPOS)) { + funMap = fundPOS.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); + } + List otherPOS = this.getOtherByEmployeeIdAndPayOrg(insuranceArchivesEmployeePOS); + encryptUtil.decryptList(otherPOS, InsuranceArchivesOtherSchemePO.class); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(otherPOS)) { + otherMap = otherPOS.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); + } + for (Long id : ids) { + InsuranceArchivesAccountPO po = new InsuranceArchivesAccountPO(); + po.setSocial(socialMap.get(id)); + po.setFund(funMap.get(id)); + po.setOther(otherMap.get(id)); + result.put(id, po); + } + return result; + } + + @Override + public List dealSocialBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesSocialSchemePO po : adjustList) { + List oldBaseInfoList = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getSocialSchemeId()) + .adjustAfterBaseJson(po.getSocialPaymentBaseString()) + .adjustAfterComBaseJson(po.getSocialPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesSocialSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesSocialSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getSocialPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getSocialPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getSocialSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"社保档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + + } + + @Override + public List dealFundBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesFundSchemePO po : adjustList) { + List oldBaseInfoList = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getFundSchemeId()) + .adjustAfterBaseJson(po.getFundPaymentBaseString()) + .adjustAfterComBaseJson(po.getFundPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesFundSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesFundSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getFundPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getFundPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getFundSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"公积金档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + } + + @Override + public List dealOtherBaseAdjustInfoList(List adjustList, Long creator) { + List adjustHistoryList = new ArrayList<>(); + if (adjustList.size() > 0) { + //遍历待更新的福利档案数据,对每组档案生成基数调整记录(基数单元未变化则忽略) + for (InsuranceArchivesOtherSchemePO po : adjustList) { + List oldBaseInfoList = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO.builder() + .paymentOrganization(po.getPaymentOrganization()).employeeId(po.getEmployeeId()).build()); + + InsuranceArchivesBaseHistoryDTO adjustInfo = InsuranceArchivesBaseHistoryDTO.builder() + .adjustAfterSchemeId(po.getOtherSchemeId()) + .adjustAfterBaseJson(po.getOtherPaymentBaseString()) + .adjustAfterComBaseJson(po.getOtherPaymentComBaseString()) + .welfareType(po.getWelfareType()) + .employeeId(po.getEmployeeId()) + .paymentOrganization(po.getPaymentOrganization()) + .build(); + if (oldBaseInfoList.size() == 1) { + //新增调整记录,变更 + InsuranceArchivesOtherSchemePO oldBaseInfo = oldBaseInfoList.get(0); + encryptUtil.decrypt(oldBaseInfo, InsuranceArchivesOtherSchemePO.class); + adjustInfo.setAdjustBeforeBaseJson(oldBaseInfo.getOtherPaymentBaseString()); + adjustInfo.setAdjustBeforeComBaseJson(oldBaseInfo.getOtherPaymentComBaseString()); + adjustInfo.setAdjustBeforeSchemeId(oldBaseInfo.getOtherSchemeId()); + } else if (oldBaseInfoList.size() > 1) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"其他福利档案存在冗余数据!")); + } + adjustHistoryList.addAll(createAdjustInfo(adjustInfo, creator)); + } + } + return adjustHistoryList; + } + + /** + * 获取没有设置社保、公积金最后缴纳月的档案 + * @param employeeIds + * @return + */ + @Override + public List listEndDateIsNull(List employeeIds) { + if (org.apache.commons.collections.CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return getInsuranceBaseInfoMapper().listEndDateIsNull(employeeIds); + } + /*****以上代码为SIArchivesBiz中方法逻辑迁移,旨在减少Biz类的使用*****/ } diff --git a/src/com/engine/salary/service/impl/SIExportServiceImpl.java b/src/com/engine/salary/service/impl/SIExportServiceImpl.java index 93c929e46..f3432aa33 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.SIArchivesBiz; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.param.InsuranceAccountDetailParam; @@ -25,10 +24,7 @@ import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; import com.engine.salary.mapper.sicategory.ICategoryMapper; import com.engine.salary.mapper.taxagent.TaxAgentMapper; -import com.engine.salary.service.SIAccountService; -import com.engine.salary.service.SIExportService; -import com.engine.salary.service.SISchemeService; -import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.*; import com.engine.salary.sys.entity.po.SalarySysConfPO; import com.engine.salary.sys.entity.vo.OrderRuleVO; import com.engine.salary.sys.enums.OpenEnum; @@ -69,7 +65,7 @@ public class SIExportServiceImpl extends Service implements SIExportService { // private SIAccountBiz siAccountBiz = new SIAccountBiz(); - private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); private SISchemeService getSISchemeService(User user) { return ServiceUtil.getService(SISchemeServiceImpl.class, user); @@ -107,6 +103,10 @@ public class SIExportServiceImpl extends Service implements SIExportService { return ServiceUtil.getService(SIAccountServiceImpl.class, user); } + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class, user); + } + @Override public XSSFWorkbook exportOverView(InsuranceExportParam queryParam) { List insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(queryParam.getBillMonth(), StringUtils.isBlank(queryParam.getPaymentOrganization()) ? null : Long.valueOf(queryParam.getPaymentOrganization())); @@ -253,7 +253,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { @Override public List> buildCommonRecords(List list) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); List> result = new ArrayList<>(); List paymentList = getTaxAgentMapper().listAll(); @@ -287,7 +288,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { if (welBaseDiffSign) { if (socialJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); socialJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "socialPerBase", v); @@ -298,7 +300,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { }); if (socialComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); socialComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "socialComBase", v); @@ -308,7 +311,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { } else { if (socialJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getSocialSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getSocialSchemeId()); socialJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "socialBase", v); @@ -332,7 +336,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { if (welBaseDiffSign) { if (fundJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); fundJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "fundPerBase", v); @@ -343,7 +348,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { }); if (fundComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); fundComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "fundComBase", v); @@ -353,7 +359,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { } else { if (fundJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getFundSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getFundSchemeId()); fundJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "fundBase", v); @@ -375,7 +382,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { if (welBaseDiffSign) { if (otherJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); otherJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "otherPerBase", v); @@ -386,7 +394,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { }); if (otherComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); otherComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "otherComBase", v); @@ -396,7 +405,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { } else { if (otherJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(item.getOtherSchemeId()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(item.getOtherSchemeId()); otherJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { record.put(k + "otherBase", v); @@ -731,7 +741,8 @@ public class SIExportServiceImpl extends Service implements SIExportService { } private Map> buildPaymentTitle(List pos, Map categoryIdNameMap) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); Set socailIds = new HashSet<>(); Set fundIds = new HashSet<>(); Set otherIds = new HashSet<>(); diff --git a/src/com/engine/salary/service/impl/SIImportServiceImpl.java b/src/com/engine/salary/service/impl/SIImportServiceImpl.java index c8b41704c..64623943d 100644 --- a/src/com/engine/salary/service/impl/SIImportServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIImportServiceImpl.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.SIArchivesBiz; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; @@ -26,7 +25,6 @@ import com.engine.salary.service.SIImportService; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelComment; -import com.engine.salary.util.excel.ExcelUtil; import com.engine.salary.util.excel.ExcelUtilPlus; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; @@ -51,7 +49,7 @@ import java.util.stream.Collectors; public class SIImportServiceImpl extends Service implements SIImportService { private EncryptUtil encryptUtil = new EncryptUtil(); - private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); public SIArchivesService getSIArchivesService(User user) { return ServiceUtil.getService(SIArchivesServiceImpl.class,user); @@ -195,7 +193,8 @@ public class SIImportServiceImpl extends Service implements SIImportService { * @return */ public List buildHeader() { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); List result = new ArrayList<>(); result.add(SalaryI18nUtil.getI18nLabel( 85429, "姓名")); result.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人")); @@ -294,19 +293,22 @@ public class SIImportServiceImpl extends Service implements SIImportService { } List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); Map socialSchemePOMap = new HashMap<>(); - List socialSchemePOList = siArchivesBiz.getSocialByEmployeeIds(employeeIds); +// List socialSchemePOList = siArchivesBiz.getSocialByEmployeeIds(employeeIds); + List socialSchemePOList = getSIArchivesService(user).getSocialByEmployeeIds(employeeIds); encryptUtil.decryptList(socialSchemePOList, InsuranceArchivesSocialSchemePO.class); if (CollectionUtils.isNotEmpty(socialSchemePOList)) { socialSchemePOMap = socialSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); } - List fundSchemePOList = siArchivesBiz.getFundByEmployeeIds(employeeIds); +// List fundSchemePOList = siArchivesBiz.getFundByEmployeeIds(employeeIds); + List fundSchemePOList = getSIArchivesService(user).getFundByEmployeeIds(employeeIds); encryptUtil.encryptList(fundSchemePOList, InsuranceArchivesFundSchemePO.class); Map fundSchemePOMap = new HashMap<>(); if (CollectionUtils.isNotEmpty(fundSchemePOList)) { fundSchemePOMap = fundSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); } Map otherSchemePOMap = new HashMap<>(); - List otherSchemePOList = siArchivesBiz.getOtherByEmployeeIds(employeeIds); +// List otherSchemePOList = siArchivesBiz.getOtherByEmployeeIds(employeeIds); + List otherSchemePOList = getSIArchivesService(user).getOtherByEmployeeIds(employeeIds); encryptUtil.decryptList(otherSchemePOList, InsuranceArchivesOtherSchemePO.class); if (CollectionUtils.isNotEmpty(otherSchemePOList)) { otherSchemePOMap = otherSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java index 19a670559..3ab971917 100644 --- a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -6,11 +6,9 @@ import com.api.formmode.mybatis.util.SqlProxyHandle; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.biz.SISchemeBiz; import com.engine.salary.cmd.sischeme.*; import com.engine.salary.constant.SalaryDefaultTenantConstant; -import com.engine.salary.encrypt.AESEncryptUtil; import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; @@ -51,7 +49,6 @@ 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; -import com.engine.salary.util.excel.ExcelUtil; import com.engine.salary.util.excel.ExcelUtilPlus; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; @@ -129,7 +126,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { return ServiceUtil.getService(SIImportServiceImpl.class, user); } - private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); +// private SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); private SISchemeBiz siSchemeBiz = new SISchemeBiz(); private SalaryEmployeeService getSalaryEmployeeService(User user) { @@ -152,6 +149,10 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user); } + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + @Override public Map getForm(Map params) { return commandExecutor.execute(new SISchemeGetFormCmd(params, user)); @@ -264,7 +265,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { @Override public List> buildTableData(List insuranceArchivesEmployeePOS) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); List> records = new ArrayList<>(); List taxAgentPOS = getTaxAgentMapper().listAll(); Map longTaxAgentPOMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId); @@ -282,9 +284,9 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { end = employeeIds.size(); } List ids = employeeIds.subList(i, end); - socialList.addAll(encryptUtil.decryptList(siArchivesBiz.getSocialByEmployeeIds(ids), InsuranceArchivesSocialSchemePO.class)); - fundList.addAll(encryptUtil.decryptList(siArchivesBiz.getFundByEmployeeIds(ids), InsuranceArchivesFundSchemePO.class)); - otherList.addAll(encryptUtil.decryptList(siArchivesBiz.getOtherByEmployeeIds(ids), InsuranceArchivesOtherSchemePO.class)); + socialList.addAll(encryptUtil.decryptList(getSIArchivesService(user).getSocialByEmployeeIds(ids), InsuranceArchivesSocialSchemePO.class)); + fundList.addAll(encryptUtil.decryptList(getSIArchivesService(user).getFundByEmployeeIds(ids), InsuranceArchivesFundSchemePO.class)); + otherList.addAll(encryptUtil.decryptList(getSIArchivesService(user).getOtherByEmployeeIds(ids), InsuranceArchivesOtherSchemePO.class)); } Map socialSchemePOMap = SalaryEntityUtil.convert2Map(socialList, k -> k.getPaymentOrganization() + "-" + k.getEmployeeId()); Map fundSchemePOMap = SalaryEntityUtil.convert2Map(fundList, k -> k.getPaymentOrganization() + "-" + k.getEmployeeId()); @@ -311,7 +313,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { if (welBaseDiffSign) { if (socialJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(socialItem.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(socialItem.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(socialItem.getSocialSchemeId(), PaymentScopeEnum.SCOPE_PERSON.getValue()); socialJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { map.put(k + "per", v); @@ -322,7 +325,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { }); if (socialComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(socialItem.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(socialItem.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(socialItem.getSocialSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); socialComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { map.put(k + "com", v); @@ -352,7 +356,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { if (welBaseDiffSign) { if (fundJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); fundJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { map.put(k + "per", v); @@ -363,7 +368,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { }); if (fundComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(fundItem.getFundSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); fundComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { map.put(k + "com", v); @@ -393,7 +399,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { if (welBaseDiffSign) { if (otherJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_PERSON.getValue()); otherJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { map.put(k + "per", v); @@ -404,7 +411,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { }); if (otherComJson != null) { //查询该福利方案下开启缴纳的福利项 - List insuranceIdList = siArchivesBiz.payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); +// List insuranceIdList = siArchivesBiz.payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); + List insuranceIdList = getSIArchivesService(user).payInsuranceIds(otherItem.getOtherSchemeId(),PaymentScopeEnum.SCOPE_COMPANY.getValue()); otherComJson.forEach((k, v) -> { if (insuranceIdList.contains(Long.valueOf(k))) { map.put(k + "com", v); @@ -587,7 +595,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { public Map> buildColumnTitle(List insuranceArchivesEmployeePOS, Long employeeId) { - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); Map> result = new HashMap<>(); Set socialSet = new HashSet<>(); @@ -599,7 +608,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { Set otherComSet = new HashSet<>(); insuranceArchivesEmployeePOS.forEach(item -> { - List socialByEmployeeId = siArchivesBiz.getSocialByEmployeeIds(new ArrayList() {{ + List socialByEmployeeId = getSIArchivesService(user).getSocialByEmployeeIds(new ArrayList() {{ add(item.getEmployeeId()); }}); encryptUtil.decryptList(socialByEmployeeId, InsuranceArchivesSocialSchemePO.class); @@ -609,7 +618,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { } InsuranceArchivesFundSchemePO fundItem = null; - List fundByEmployeeId = siArchivesBiz.getFundByEmployeeIds(new ArrayList() {{ + List fundByEmployeeId = getSIArchivesService(user).getFundByEmployeeIds(new ArrayList() {{ add(item.getEmployeeId()); }}); encryptUtil.decryptList(fundByEmployeeId, InsuranceArchivesFundSchemePO.class); @@ -619,7 +628,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { } InsuranceArchivesOtherSchemePO otherItem = null; - List otherByEmployeeId = siArchivesBiz.getOtherByEmployeeIds(new ArrayList() {{ + List otherByEmployeeId = getSIArchivesService(user).getOtherByEmployeeIds(new ArrayList() {{ add(item.getEmployeeId()); }}); encryptUtil.decryptList(otherByEmployeeId, InsuranceArchivesOtherSchemePO.class); @@ -809,6 +818,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { /** * 导入的数据插入到数据库中 */ + @Override public Map batchImportEbatch(SIArchiveImportParam param) { ValidUtil.doValidator(param); param.setProcess(false); @@ -1229,7 +1239,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { insuranceArchivesOtherSchemePO = buildOtherPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); } /**************校验申报基数**************/ - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); if (welBaseDiffSign) { for (Map.Entry entry : welfareMap.entrySet()) { String keyPerName = entry.getValue() + SalaryI18nUtil.getI18nLabel(0, "申报基数") + SalaryI18nUtil.getI18nLabel(0, "个人"); @@ -1276,19 +1287,19 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { insuranceArchivesAccountPO.setOther(insuranceArchivesOtherSchemePO); insuranceArchivesAccountPO.setBaseInfo(insuranceArchivesBaseInfoPO); //校验福利基数是否符合上下限要求, - Boolean socialCheckBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + Boolean socialCheckBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); - Boolean fundCheckBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + Boolean fundCheckBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); - Boolean otherCheckBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + Boolean otherCheckBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); Boolean socialCheckComBase = true; Boolean fundCheckComBase = true; Boolean otherCheckComBase = true; if (welBaseDiffSign) { - socialCheckComBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); - fundCheckComBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); - otherCheckComBase = siArchivesBiz.checkWelBaseLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + socialCheckComBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + fundCheckComBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + otherCheckComBase = getSIArchivesService(user).checkWelBaseLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); } if (socialCheckBase && fundCheckBase && otherCheckBase && socialCheckComBase && fundCheckComBase && otherCheckComBase) { insuranceArchivesAccountPOS.add(insuranceArchivesAccountPO); @@ -1313,18 +1324,18 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { } else if (!isError) { //校验福利基数是否符合上下限要求,不符合上下限的基数调整为上限 /下限 - String newSocialPaymentBaseString = siArchivesBiz.checkAndBuildWelBaseWithLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); - String newFundPaymentBaseString = siArchivesBiz.checkAndBuildWelBaseWithLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); - String newOtherPaymentBaseString = siArchivesBiz.checkAndBuildWelBaseWithLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + String newSocialPaymentBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + String newFundPaymentBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); + String newOtherPaymentBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentBaseString(), PaymentScopeEnum.SCOPE_PERSON.getValue()); insuranceArchivesSocialSchemePO.setSocialPaymentBaseString(newSocialPaymentBaseString); insuranceArchivesFundSchemePO.setFundPaymentBaseString(newFundPaymentBaseString); insuranceArchivesOtherSchemePO.setOtherPaymentBaseString(newOtherPaymentBaseString); if (welBaseDiffSign) { - String newSocialPaymentComBaseString = siArchivesBiz.checkAndBuildWelBaseWithLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); - String newFundPaymentComBaseString = siArchivesBiz.checkAndBuildWelBaseWithLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); - String newOtherPaymentComBaseString = siArchivesBiz.checkAndBuildWelBaseWithLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + String newSocialPaymentComBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesSocialSchemePO.getSocialSchemeId(), insuranceArchivesSocialSchemePO.getSocialPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + String newFundPaymentComBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesFundSchemePO.getFundSchemeId(), insuranceArchivesFundSchemePO.getFundPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); + String newOtherPaymentComBaseString = getSIArchivesService(user).checkAndBuildWelBaseWithLimit(insuranceArchivesOtherSchemePO.getOtherSchemeId(), insuranceArchivesOtherSchemePO.getOtherPaymentComBaseString(), PaymentScopeEnum.SCOPE_COMPANY.getValue()); insuranceArchivesSocialSchemePO.setSocialPaymentComBaseString(newSocialPaymentComBaseString); insuranceArchivesFundSchemePO.setFundPaymentComBaseString(newFundPaymentComBaseString); @@ -1413,7 +1424,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(insuranceArchivesSocialSchemePO.getSocialSchemeId()); encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); if (CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS)) { List insuranceIds = insuranceSchemeDetailPOS.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); HashMap socialPaymentBase = new HashMap<>(); @@ -1525,7 +1537,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(insuranceArchivesFundSchemePO.getFundSchemeId()); encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); if (CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS)) { List insuranceIds = insuranceSchemeDetailPOS.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); HashMap fundPaymentBase = new HashMap<>(); @@ -1627,7 +1640,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { insuranceArchivesOtherSchemePO.setEmployeeId(employeeId); List insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(insuranceArchivesOtherSchemePO.getOtherSchemeId()); encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class); - boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); +// boolean welBaseDiffSign = siArchivesBiz.isDiffWelBase(); + boolean welBaseDiffSign = getSIArchivesService(user).isDiffWelBase(); if (CollectionUtils.isNotEmpty(insuranceSchemeDetailPOS)) { List insuranceIds = insuranceSchemeDetailPOS.stream().map(InsuranceSchemeDetailPO::getInsuranceId).collect(Collectors.toList()); HashMap otherPaymentBase = new HashMap<>(); @@ -1705,7 +1719,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); //生成福利档案基数调整历史记录 - List adjustSocialHistoryPOList = siArchivesBiz.dealSocialBaseAdjustInfoList(socialSchemePOS, (long) user.getUID()); +// List adjustSocialHistoryPOList = siArchivesBiz.dealSocialBaseAdjustInfoList(socialSchemePOS, (long) user.getUID()); + List adjustSocialHistoryPOList = getSIArchivesService(user).dealSocialBaseAdjustInfoList(socialSchemePOS, (long) user.getUID()); //根据人员id和个税扣缴义务人id删除对应旧档案 socialSchemePOS.forEach(getSocialSchemeMapper()::deleteByEmployeeIdAndPayOrg); @@ -1716,7 +1731,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { partition.forEach(getSocialSchemeMapper()::batchSave); //新建福利档案基数调整历史记录 - siArchivesBiz.batchInsertAdjustHistory(adjustSocialHistoryPOList, user.getUID()); +// siArchivesBiz.batchInsertAdjustHistory(adjustSocialHistoryPOList, user.getUID()); + getSIArchivesService(user).batchInsertAdjustHistory(adjustSocialHistoryPOList); } //导入公积金档案 List fundSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getFund).collect(Collectors.toList()); @@ -1727,7 +1743,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); //生成福利档案基数调整历史记录 - List adjustFundHistoryPOList = siArchivesBiz.dealFundBaseAdjustInfoList(fundSchemePOS, (long) user.getUID()); +// List adjustFundHistoryPOList = siArchivesBiz.dealFundBaseAdjustInfoList(fundSchemePOS, (long) user.getUID()); + List adjustFundHistoryPOList = getSIArchivesService(user).dealFundBaseAdjustInfoList(fundSchemePOS, (long) user.getUID()); //根据人员id和个税扣缴义务人id删除对应档案 fundSchemePOS.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg); //新建新档案 @@ -1735,7 +1752,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { List> partition = Lists.partition(insuranceArchivesFundSchemePOS, 100); partition.forEach(getFundSchemeMapper()::batchSave); //新建福利档案基数调整历史记录 - siArchivesBiz.batchInsertAdjustHistory(adjustFundHistoryPOList, user.getUID()); +// siArchivesBiz.batchInsertAdjustHistory(adjustFundHistoryPOList, user.getUID()); + getSIArchivesService(user).batchInsertAdjustHistory(adjustFundHistoryPOList); } //导入其他福利档案 List otherSchemePOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getOther).collect(Collectors.toList()); @@ -1746,7 +1764,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getPaymentOrganization() + "-" + f.getEmployeeId()))), ArrayList::new)); //生成福利档案基数调整历史记录 - List adjustOtherHistoryPOList = siArchivesBiz.dealOtherBaseAdjustInfoList(otherSchemePOS, (long) user.getUID()); +// List adjustOtherHistoryPOList = siArchivesBiz.dealOtherBaseAdjustInfoList(otherSchemePOS, (long) user.getUID()); + List adjustOtherHistoryPOList = getSIArchivesService(user).dealOtherBaseAdjustInfoList(otherSchemePOS, (long) user.getUID()); //根据人员id和个税扣缴义务人id删除对应档案 otherSchemePOS.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg); @@ -1755,7 +1774,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { List> partition = Lists.partition(insuranceArchivesOtherSchemePOS, 100); partition.forEach(getOtherSchemeMapper()::batchSave); //新建福利档案基数调整历史记录 - siArchivesBiz.batchInsertAdjustHistory(adjustOtherHistoryPOList, user.getUID()); +// siArchivesBiz.batchInsertAdjustHistory(adjustOtherHistoryPOList, user.getUID()); + getSIArchivesService(user).batchInsertAdjustHistory(adjustOtherHistoryPOList); } //导入福利档案基础信息 List baseInfoPOS = insuranceArchivesAccountPOS.stream().filter(Objects::nonNull).map(InsuranceArchivesAccountPO::getBaseInfo).collect(Collectors.toList()); @@ -1801,6 +1821,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { * * @param param 是否导出带档案数据的模板 */ + @Override public XSSFWorkbook exportTemplate(InsuranceArchivesListParam param) { return getSIImportService().exportTemplate(param); diff --git a/src/com/engine/salary/timer/AutoSyncResignationEmpArchiveJob.java b/src/com/engine/salary/timer/AutoSyncResignationEmpArchiveJob.java index b62f8ce6d..0505d7670 100644 --- a/src/com/engine/salary/timer/AutoSyncResignationEmpArchiveJob.java +++ b/src/com/engine/salary/timer/AutoSyncResignationEmpArchiveJob.java @@ -1,15 +1,16 @@ package com.engine.salary.timer; import com.engine.common.util.ServiceUtil; -import com.engine.salary.biz.SIArchivesBiz; import com.engine.salary.biz.SalaryArchiveBiz; import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; import com.engine.salary.mapper.siarchives.FundSchemeMapper; import com.engine.salary.mapper.siarchives.OtherSchemeMapper; import com.engine.salary.mapper.siarchives.SocialSchemeMapper; +import com.engine.salary.service.SIArchivesService; import com.engine.salary.service.SalaryArchiveService; import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.impl.SIArchivesServiceImpl; import com.engine.salary.service.impl.SalaryArchiveServiceImpl; import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; import com.engine.salary.util.SalaryDateUtil; @@ -54,6 +55,10 @@ public class AutoSyncResignationEmpArchiveJob extends BaseCronJob { private String preMonth; + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + @Override public void execute() { User user = new User(); @@ -85,8 +90,8 @@ public class AutoSyncResignationEmpArchiveJob extends BaseCronJob { } // 获取离职人员中没有设置最后缴纳月的社保福利档案 - SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); - List needSyncList = siArchivesBiz.listEndDateIsNull(new ArrayList<>(resignationMap.keySet())); +// List needSyncList = siArchivesBiz.listEndDateIsNull(new ArrayList<>(resignationMap.keySet())); + List needSyncList = getSIArchivesService(user).listEndDateIsNull(new ArrayList<>(resignationMap.keySet())); // 设置社保、公积金最后缴纳月 for(InsuranceArchivesBaseInfoPO po : needSyncList){ String dismissDate = resignationMap.get(po.getEmployeeId());