package com.engine.salary.biz; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.demo.DemoPo; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBO; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseDTO; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesFundSchemeDTO; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesOtherSchemeDTO; import com.engine.salary.entity.siarchives.dto.InsuranceArchivesSocialSchemeDTO; import com.engine.salary.entity.siarchives.param.*; import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; import com.engine.salary.entity.taxrate.TaxAgent; import com.engine.salary.enums.sicategory.*; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.TaxAgentMapper; 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.mapper.sicategory.ICategoryMapper; import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper; import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper; import com.engine.salary.util.*; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.PageUtil; import org.apache.ibatis.session.SqlSession; import weaver.conn.mybatis.MyBatisFactory; import weaver.general.Util; import weaver.hrm.User; import java.time.LocalDateTime; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; /** * @Author weaver_cl * @Description: TODO * @Date 2022/3/12 * @Version V1.0 **/ public class SIArchivesBiz { /** * * @param welfareType * @param employeeId * @param operateId * @param user * @return */ public Map getBaseForm(WelfareTypeEnum welfareType, Long employeeId, Long operateId, User user) { Map data = new HashMap<>(16); SalaryAssert.notNull(employeeId, "员工id不可为空"); EmployBiz employBiz = new EmployBiz(); List employeeByIds = employBiz.getEmployeeByIdsAll(Collections.singletonList(employeeId)); SalaryAssert.notEmpty(employeeByIds,"员工信息不存在"); DataCollectionEmployee item = employeeByIds.get(0); if (welfareType == null) { //基础信息表单 InsuranceArchivesBaseDTO insuranceArchivesBaseDTO = InsuranceArchivesBaseDTO.builder().department(item.getDepartmentName()) .hiredate(SalaryDateUtil.getFormatLocalDate(item.getCompanystartdate())) .position(item.getJobtitleName()) .username(item.getUsername()) .telephone(item.getMobile()) .dimissionDate(SalaryDateUtil.getFormatLocalDate(item.getDissmissdate())) .build(); // if (item.getStatus() == UserStatus.unavailable) { // InsuranceArchivesListParam insuranceArchivesListParam = new InsuranceArchivesListParam(); // insuranceArchivesListParam.setEmployeeIds(Collections.singletonList(employeeId)); // List insuranceArchivesEmployeePOS = siArchivesSocialMapper.queryEmployeeList(insuranceArchivesListParam, tenantKey); // if (CollectionUtils.isNotEmpty(insuranceArchivesEmployeePOS)) { // insuranceArchivesBaseDTO.setDimissionDate(SalaryDateUtil.getFormatLocalDate(insuranceArchivesEmployeePOS.get(0).getDimissionDate())); // } // } //WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(InsuranceArchivesBaseDTO.class, insuranceArchivesBaseDTO); // weaForm.getGroups().add(new WeaFormGroup("g1", "员工信息")); // weaForm.getLayout().forEach(items -> items.forEach(e -> e.setGroupId("g1"))); data.put("data",insuranceArchivesBaseDTO); return data; } SISchemeBiz siSchemeBiz = new SISchemeBiz(); List list = siSchemeBiz.listAll(); List selectItems = new ArrayList<>(); List addGroups = new ArrayList<>(); List paymentOptions = paymentOrganizationOptions(); List underTakeOptions = Arrays.stream(UndertakerEnum.values()).map(e -> new SearchConditionOption(e.name(), e.getDefaultLabel())).collect(Collectors.toList()); //返回数据 switch (welfareType) { case SOCIAL_SECURITY: InsuranceArchivesSocialSchemeDTO insuranceArchivesSocialSchemeDTO = buildSocialForm(employeeId, operateId ); 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, "社保方案名称"); SearchConditionItem organizationName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "社保缴纳组织"); SearchConditionItem underTakeName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "社保个人实际承担方"); selectItems.add(socialName); selectItems.add(organizationName); selectItems.add(underTakeName); addGroups.add(new SearchConditionGroup("社保基础信息",true,selectItems)); data.put("data",insuranceArchivesSocialSchemeDTO); data.put("items",addGroups); break; case ACCUMULATION_FUND: InsuranceArchivesFundSchemeDTO insuranceArchivesFundSchemeDTO = buildFundForm(employeeId, operateId); 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, "公积金方案名称"); SearchConditionItem organizationFundName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "公积金缴纳组织"); SearchConditionItem underTakeFundName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "公积金个人实际承担方"); selectItems.add(fundName); selectItems.add(organizationFundName); selectItems.add(underTakeFundName); addGroups.add(new SearchConditionGroup("公积金基础信息",true,selectItems)); data.put("data",insuranceArchivesFundSchemeDTO); data.put("items",addGroups); break; case OTHER: InsuranceArchivesOtherSchemeDTO insuranceArchivesOtherSchemeDTO = buildOtherForm(employeeId, operateId); 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, "其它福利名称"); SearchConditionItem organizationOtherName = SalaryFormItemUtil.selectItem(user, paymentOptions, 2, 12, 6, false, "其它福利缴纳组织"); SearchConditionItem underTakeOtherName = SalaryFormItemUtil.selectItem(user, underTakeOptions, 2, 12, 6, false, "其它福利个人实际承担方"); selectItems.add(otherName); selectItems.add(organizationOtherName); selectItems.add(underTakeOtherName); addGroups.add(new SearchConditionGroup("其它福利基础信息",true,selectItems)); data.put("data",insuranceArchivesOtherSchemeDTO); data.put("items",addGroups); break; default: } return data; } /** * 获取详细表单 * @param user * @param welfareType * @param employeeId * @param operateId * @param schemeId * @return */ public Map getPaymentForm(User user, WelfareTypeEnum welfareType, Long employeeId, long operateId, Long schemeId) { Map data = new HashMap<>(16); switch (welfareType) { case SOCIAL_SECURITY: data = buildSocialPaymentForm(user,employeeId, schemeId, operateId,welfareType.getValue()); break; case ACCUMULATION_FUND: data = buildFundPaymentForm(user,employeeId, schemeId, operateId,welfareType.getValue()); break; case OTHER: data = buildOtherPaymentForm(user,employeeId, schemeId, operateId,welfareType.getValue()); break; default: } return data; } /** * 其他payForm * @param employeeId * @param schemeId * @param operateId * @return */ public Map buildOtherPaymentForm(User user,Long employeeId, Long schemeId, long operateId,Integer welfareType) { Map dataMap = new HashMap<>(); InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, operateId); if (data != null) { dataMap.put("data",JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference>() { })); } List addGroups = new ArrayList<>(); List inputItems = buildPaymentBase(user,schemeId,welfareType); addGroups.add(new SearchConditionGroup("其它福利缴纳基数",true,inputItems)); dataMap.put("items",addGroups); return dataMap; } /** * 公积金payForm * @param employeeId * @param schemeId * @param operateId * @return */ public Map buildFundPaymentForm(User user,Long employeeId, Long schemeId, long operateId,Integer welfareType) { Map dataMap = new HashMap<>(); InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, operateId); if (data != null) { dataMap.put("data",JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference>() { })); } List addGroups = new ArrayList<>(); List inputItems = buildPaymentBase(user,schemeId,welfareType); addGroups.add(new SearchConditionGroup("公积金缴纳基数",true,inputItems)); dataMap.put("items",addGroups); return dataMap; } /** * 社保payForm * @param employeeId * @param schemeId * @param operateId * @return */ public Map buildSocialPaymentForm(User user,Long employeeId, Long schemeId, long operateId,Integer welfareType) { Map dataMap = new HashMap<>(); InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, operateId); if (data != null) { dataMap.put("data",JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference>() { })); } List addGroups = new ArrayList<>(); List inputItems = buildPaymentBase(user,schemeId,welfareType); addGroups.add(new SearchConditionGroup("社保缴纳基数",true,inputItems)); dataMap.put("items",addGroups); return dataMap; } /** * 构造payment(items) * @param schemeId * @return */ public List buildPaymentBase(User user,Long schemeId,Integer welfareType) { List inputItems = new ArrayList<>(); if(schemeId == null) { return new ArrayList<>(); } List list = queryListByPrimaryIdIsPayment(schemeId,welfareType).stream().collect(Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceSchemeDetailPO::getInsuranceId))), ArrayList::new) ); SICategoryBiz siCategoryBiz = new SICategoryBiz(); list.forEach(insuranceSchemeDetail-> { ICategoryPO iCategoryPO = siCategoryBiz.getByID(insuranceSchemeDetail.getInsuranceId()); if (iCategoryPO != null) { inputItems.add(SalaryFormItemUtil.inputNumberItem(user,"precision:2",String.valueOf(insuranceSchemeDetail.getInsuranceId()),2,12,2,iCategoryPO.getInsuranceName())); } }); return inputItems; } /** * 获取方案明细 * @param schemeId * @return */ public List queryListByPrimaryIdIsPayment(Long schemeId,Integer welfareType) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try{ InsuranceSchemeDetailMapper insuranceSchemeDetailMapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class); return insuranceSchemeDetailMapper.queryListByPrimaryIdIsPayment(schemeId, IsPaymentEnum.YES.getValue(),welfareType); }finally { sqlSession.close(); } } /** * 社保缴纳组织 * @return */ public List paymentOrganizationOptions() { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class); List list = taxAgentMapper.listAll(); if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); } return list .stream() .map(item -> new SearchConditionOption(String.valueOf(item.getId()), item.getName())).collect(Collectors.toList()); }finally { sqlSession.close(); } } /** * 其它基础表单 * @param employeeId * @param operateId * @return */ public InsuranceArchivesOtherSchemeDTO buildOtherForm(Long employeeId, Long operateId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(employeeId)).get(0); InsuranceArchivesOtherSchemeDTO data = InsuranceArchivesBO.convertOtherPOtoDTO(insuranceArchivesOtherSchemePO, employeeId); if (insuranceArchivesOtherSchemePO == null) { data.setEmployeeId(employeeId); data.setUnderTake(UndertakerEnum.SCOPE_COMPANY); } return data; }finally { sqlSession.close(); } } /** * 公积金基础表单 * @param employeeId * @param operateId * @return */ public InsuranceArchivesFundSchemeDTO buildFundForm(Long employeeId, Long operateId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(employeeId)).get(0); InsuranceArchivesFundSchemeDTO data = InsuranceArchivesBO.convertFundPOtoDTO(insuranceArchivesFundSchemePO, employeeId); if (insuranceArchivesFundSchemePO == null) { data.setEmployeeId(employeeId); data.setUnderTake(UndertakerEnum.SCOPE_COMPANY); } return data; }finally { sqlSession.close(); } } /** * 社保基础表单 * @param employeeId * @param operateId * @return */ public InsuranceArchivesSocialSchemeDTO buildSocialForm(Long employeeId, Long operateId) { InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = getSocialByEmployeeId(employeeId); InsuranceArchivesSocialSchemeDTO data = InsuranceArchivesBO.convertSocialPOtoDTO(insuranceArchivesSocialSchemePO, employeeId); if (insuranceArchivesSocialSchemePO == null) { data.setEmployeeId(employeeId); data.setUnderTake(UndertakerEnum.SCOPE_COMPANY); } return data; } /** * 获取社保档案表 * @param employeeId * @return */ public InsuranceArchivesSocialSchemePO getSocialByEmployeeId(Long employeeId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); return socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(employeeId)).get(0); }finally { sqlSession.close(); } } /** * 新增 * @param param * @param employeeId */ public void insert(InsuranceArchivesSaveParam param, long employeeId) { SalaryAssert.notNull(param.getWelfareType(), "福利类型为空"); switch (param.getWelfareType()) { case SOCIAL_SECURITY: socialSave(param, employeeId); break; case ACCUMULATION_FUND: fundSave(param, employeeId); break; case OTHER: otherSave(param, employeeId); break; default: throw new SalaryRunTimeException("福利类型不存在"); } } /** * * @param paramReq * @param employeeId */ public void otherSave(InsuranceArchivesSaveParam paramReq, long employeeId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); InsuranceArchivesOtherSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesOtherSaveParam.class); SalaryAssert.notNull( "员工id为空", param, param.getEmployeeId()); otherSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = InsuranceArchivesOtherSchemePO.builder() .otherSchemeId(param.getOtherName()) .otherStartTime(param.getOtherStartTime()) .underTake(param.getUnderTake().getValue()) .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) .welfareType(paramReq.getWelfareType().getValue()) .otherEndTime(param.getOtherEndTime()) .employeeId(param.getEmployeeId()) .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) .updateTime(new Date()) .createTime(new Date()) //.id(IdGenerator.generate()) .nonPayment(param.getNonPayment()) .creator(employeeId) .paymentOrganization(param.getPaymentOrganization()) .otherPaymentBaseString(paramReq.getPaymentForm()) .build(); otherSchemeMapper.batchSave(Collections.singletonList(insuranceArchivesOtherSchemePO)); sqlSession.commit(); }finally { sqlSession.close(); } } /** * * @param paramReq * @param employeeId */ public void fundSave(InsuranceArchivesSaveParam paramReq, long employeeId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); InsuranceArchivesFundSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesFundSaveParam.class); SalaryAssert.notNull("员工id为空", param, param.getEmployeeId()); fundSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = InsuranceArchivesFundSchemePO.builder() .fundSchemeId(param.getFundName()) .fundAccount(param.getFundAccount()) .fundEndTime(param.getFundEndTime()) .fundStartTime(param.getFundStartTime()) .fundPaymentBaseString(paramReq.getPaymentForm()) .supplementFundAccount(param.getSupplementFundAccount()) //.id(IdGenerator.generate()) .createTime(new Date()) .creator(employeeId) .nonPayment(param.getNonPayment()) .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) .underTake(param.getUnderTake().getValue()) .paymentOrganization(param.getPaymentOrganization()) .updateTime(new Date()) .welfareType(paramReq.getWelfareType().getValue()) .employeeId(param.getEmployeeId()) .build(); fundSchemeMapper.batchSave(Collections.singletonList(insuranceArchivesFundSchemePO)); sqlSession.commit(); }finally { sqlSession.close(); } } /** * * @param paramReq * @param employeeId */ public void socialSave(InsuranceArchivesSaveParam paramReq, long employeeId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); try { SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); InsuranceArchivesSocialSaveParam param = JSONObject.parseObject(paramReq.getBaseForm(), InsuranceArchivesSocialSaveParam.class); SalaryAssert.notNull("员工id为空", param, param.getEmployeeId()); //删除社保数据 socialSchemeMapper.batchDeleteByEmployeeIds(Collections.singletonList(param.getEmployeeId())); InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = InsuranceArchivesSocialSchemePO.builder() //.id(IdGenerator.generate()) .welfareType(paramReq.getWelfareType().getValue()) .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) .socialPaymentBaseString(paramReq.getPaymentForm()) .socialSchemeId(param.getSocialName()) .createTime(new Date()) .socialEndTime(param.getSocialEndTime()) .socialStartTime(param.getSocialStartTime()) .creator(employeeId) .nonPayment(param.getNonPayment()) .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) .employeeId(param.getEmployeeId()) .updateTime(new Date()) .underTake(param.getUnderTake().getValue()) .socialAccount(param.getSchemeAccount()) .paymentOrganization(param.getPaymentOrganization()) .build(); socialSchemeMapper.batchSave(Collections.singletonList(insuranceArchivesSocialSchemePO)); sqlSession.commit(); }finally { sqlSession.close(); } } /** * 档案列表 *

* 这里是一个含有比较多动态字段的列表,用的是手动拼装的方式 * @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]); } long current = param.getCurrent() == null ? 1L : param.getCurrent(); long pageSize = param.getPageSize() == null ? 10 : param.getPageSize(); long startNum = (current - 1) * pageSize; param.setStartNum(startNum); param.setPageSize(pageSize); if (Objects.equals("fromQuickSearch", param.getDataSource())) { request.setStatuses(param.getStatuses()); request.setKeyword(param.getUserName()); request.setStartNum(param.getStartNum()); request.setPageSize(param.getPageSize()); request.setCurrent(current); } else { request = param; } apidatas = listPageEmployeePOS(request, operateId); return apidatas; } /** * 获取员工的基本信息 *

* 此处主要是一个公共接口,有多处引用。我们薪资系统只保存员工id(employeeId), * 但是页面上需要展示员工的更多信息(姓名,部门,状态。。。), * 所以这里主要是用于接收联表数据的一个接口 * * @param param 高级搜索条件,用于过滤数据 * @param operateId 操作员id * @return list */ public Map listPageEmployeePOS(InsuranceArchivesListParam param, long operateId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); Map datas = new HashMap<>(16); try { SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); PageUtil.start(param.getCurrent().intValue(), param.getPageSize().intValue()); List page = socialSchemeMapper.listPageEmployeePOS(param); PageInfo pageInfo = new PageInfo<>(page, InsuranceArchivesEmployeePO.class); List> records = buildTableData(param, page); datas.put("pageInfo", pageInfo); datas.put("datas",records); datas.put("columns",buildWeaTableColumns(page, operateId)); return datas; }finally { sqlSession.close(); } } /** * * @param * @param operateId * @return */ private List buildWeaTableColumns(List insuranceArchivesEmployeePOS, long operateId) { Map> titleMap = buildColumnTitle(insuranceArchivesEmployeePOS, operateId); List list = new ArrayList<>(); WeaTableColumn nameColumn = new WeaTableColumn( "100px","姓名", "employeeName" ); nameColumn.setFixed("left"); list.add(nameColumn); list.add(new WeaTableColumn("150px","部门", "departmentName")); list.add(new WeaTableColumn("150px","手机号", "mobile")); list.add(new WeaTableColumn("150px","员工状态", "status")); list.add(new WeaTableColumn("150px","社保方案名称", "socialName")); titleMap.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> list.add(new WeaTableColumn(v, k, "150px"))); list.add(new WeaTableColumn("150px","社保账号", "socialAccount")); list.add(new WeaTableColumn("150px","社保起始缴纳月", "socialStartTime")); list.add(new WeaTableColumn("150px","社保最后缴纳月", "socialEndTime")); list.add(new WeaTableColumn("150px","公积金方案名称", "fundName")); list.add(new WeaTableColumn("150px","公积金账号", "fundAccount")); titleMap.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> list.add(new WeaTableColumn(v, k, "150px"))); list.add(new WeaTableColumn("150px","补充公积金账号", "supplementFundAccount" )); list.add(new WeaTableColumn("150px","公积金起始缴纳月", "fundStartTime")); list.add(new WeaTableColumn("150px","公积金最后缴纳月", "fundEndTime")); list.add(new WeaTableColumn("150px","其他福利方案名称", "otherName")); titleMap.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> list.add(new WeaTableColumn(v, k, "150px"))); list.add(new WeaTableColumn("150px","其他福利起始缴纳月", "otherStartTime")); list.add(new WeaTableColumn("150px","其他福利最后缴纳月", "otherEndTime")); return list; } /** * * @param insuranceArchivesEmployeePOS * @param operateId * @return */ public Map> buildColumnTitle(List insuranceArchivesEmployeePOS, long operateId) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); Map> result = new HashMap<>(); 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<>(); insuranceArchivesEmployeePOS.forEach(item -> { InsuranceArchivesSocialSchemePO socialItem = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(item.getEmployeeId())).get(0); InsuranceArchivesFundSchemePO fundItem = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(item.getEmployeeId())).get(0); InsuranceArchivesOtherSchemePO otherItem = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(item.getEmployeeId())).get(0); if (socialItem != null) { Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { }); if (socialJson != null) { socialJson.forEach((k, v) -> socialSet.add(k)); } } if (fundItem != null) { Map fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference>() { }); if (fundJson != null) { fundJson.forEach((k, v) -> fundSet.add(k)); } } if (otherItem != null) { Map otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference>() { }); if (otherJson != null) { otherJson.forEach((k, v) -> otherSet.add(k)); } } }); Map socialMap = 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); socialSet.forEach(item -> { if (socialCollect.containsKey(Long.valueOf(item))) { socialMap.put(item, socialCollect.get(Long.valueOf(item)).getInsuranceName() + "申报基数"); } }); Map fundMap = 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); fundSet.forEach(item -> { if (fundCollect.containsKey(Long.valueOf(item))) { fundMap.put(item, fundCollect.get(Long.valueOf(item)).getInsuranceName() + "申报基数"); } }); Map otherMap = 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); otherSet.forEach(item -> { if (otherCollect.containsKey(Long.valueOf(item))) { otherMap.put(item, otherCollect.get(Long.valueOf(item)).getInsuranceName() + "申报基数"); } }); result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialMap); result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundMap); result.put(WelfareTypeEnum.OTHER.getValue(), otherMap); return result; }finally { sqlSession.close(); } } /** * * @param param * @param insuranceArchivesEmployeePOS * @return */ private List> buildTableData(InsuranceArchivesListParam param, List insuranceArchivesEmployeePOS) { SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); List> records = new ArrayList<>(); try { SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class); FundSchemeMapper fundSchemeMapper = sqlSession.getMapper(FundSchemeMapper.class); OtherSchemeMapper otherSchemeMapper = sqlSession.getMapper(OtherSchemeMapper.class); InsuranceSchemeMapper insuranceSchemeMapper = sqlSession.getMapper(InsuranceSchemeMapper.class); List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); Map socialSchemePOMap = socialSchemeMapper.getSocialByEmployeeId(employeeIds) .stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); Map fundSchemePOMap = fundSchemeMapper.getFundByEmployeeId(employeeIds) .stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); Map otherSchemePOMap = otherSchemeMapper.getOtherByEmployeeId(employeeIds) .stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); insuranceArchivesEmployeePOS.forEach(item -> { InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getEmployeeId()); InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getEmployeeId()); InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getEmployeeId()); Map map = new HashMap<>(); map.put("employeeName", item.getUserName()); map.put("employeeId", item.getEmployeeId()); map.put("departmentName", item.getDepartmentName()); map.put("departmentId", item.getDepartmentId()); map.put("jobNum", item.getJobNum()); map.put("mobile", item.getTelephone()); map.put("status", item.getUserStatus() == null ? "" : item.getUserStatus().getDescription()); if (socialItem != null) { map.put("socialName", insuranceSchemeMapper.querySchemeName(socialItem.getSocialSchemeId())); Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { }); if (socialJson != null) { SalaryEntityUtil.thousandthConvert(socialJson, map); } 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 (fundJson != null) { SalaryEntityUtil.thousandthConvert(fundJson, map); } 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 (otherJson != null) { SalaryEntityUtil.thousandthConvert(otherJson, map); } map.put("otherStartTime", otherItem.getOtherStartTime()); map.put("otherEndTime", otherItem.getOtherEndTime()); } records.add(map); }); return records; }finally { sqlSession.close(); } } }