package com.engine.salary.service.impl; import com.alibaba.fastjson.JSON; import com.cloudstore.eccom.constant.WeaBoolAttr; import com.cloudstore.eccom.pc.table.WeaTableColumn; 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; 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.enums.sicategory.WelfareTypeEnum; import com.engine.salary.mapper.sicategory.ICategoryMapper; import com.engine.salary.service.ColumnBuildService; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import org.apache.commons.lang3.StringUtils; import java.util.*; import java.util.stream.Collectors; /** * @Author weaver_cl * @Description: * @Date 2022/4/12 * @Version V1.0 **/ public class ColumnBuildServiceImpl extends Service implements ColumnBuildService { @Override public List buildCommonColumnsWithStyle(List pos, Long employeeId, String tenantKey, boolean flag) { List list = new ArrayList<>(); Map categoryIdNameMap = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll().stream().collect(Collectors.toMap(ICategoryPO -> String.valueOf(ICategoryPO.getId()), ICategoryPO::getInsuranceName)); Map> columns = buildPaymentTitle(pos, categoryIdNameMap, employeeId, tenantKey); Map> personColumns = buildPersonalTitle(pos, categoryIdNameMap, employeeId, tenantKey); Map> comColumns = buildComTitle(pos, categoryIdNameMap, employeeId, tenantKey); WeaTableColumn weaTableNameColumn = new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 85429, "姓名"), "userName"); weaTableNameColumn.setFixed("left"); WeaTableColumn idColumn = new WeaTableColumn("150px", "id", "id"); idColumn.setIsPrimarykey(WeaBoolAttr.TRUE); idColumn.setDisplay(WeaBoolAttr.FALSE); list.add(idColumn); WeaTableColumn employeeIdColumn = new WeaTableColumn("150px", "人员信息表的主键id", "employeeId"); employeeIdColumn.setDisplay(WeaBoolAttr.FALSE); list.add(employeeIdColumn); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86185, "部门"), "department")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86186, "手机号"), "mobile")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86187, "员工状态"), "employeeStatus")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100377, "数据来源"), "sourceFrom")); if (flag) { list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100379, "补缴月份"), "supplementaryMonth")); } list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91325, "个税扣缴义务人"), "socialPayOrg")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91324, "社保账号"), "socialAccount")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), "socialSchemeName")); //组装社保基数 columns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); // list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91488, "公积金缴纳组织"), "fundPayOrg")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91486, "公积金账号"), "fundAccount")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称"), "fundSchemeName")); //组装公积金基数 columns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91487, "补充公积金账号"), "supplementFundAccount")); // list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91497, "其他福利缴纳组织"), "otherPayOrg")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"), "otherSchemeName")); columns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); personColumns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100388, "社保个人合计") + "", "socialPerSum")); personColumns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100390, "公积金个人合计") + "", "fundPerSum")); personColumns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100392, "其他福利个人合计") + "", "otherPerSum")); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100393, "个人合计") + "", "perSum")); comColumns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100394, "社保单位合计") + "", "socialComSum")); comColumns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100395, "公积金单位合计") + "", "fundComSum")); comColumns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100396, "其他福利单位合计") + "", "otherComSum")); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100397, "单位合计") + "", "comSum")); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100398, "社保合计") + "", "socialSum")); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100399, "公积金合计") + "", "fundSum")); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 100400, "其他福利合计") + "", "otherSum")); list.add(new WeaTableColumn("150px","" + SalaryI18nUtil.getI18nLabel( 93278, "合计") + "", "total")); return list; } private Map> buildPaymentTitle(List pos, Map categoryIdNameMap, Long employeeId, String tenantKey) { Set socailIds = new HashSet<>(); Set fundIds = new HashSet<>(); Set otherIds = new HashSet<>(); Map> result = new HashMap<>(); pos.stream().forEach(item -> { if (StringUtils.isNotBlank(item.getSocialPaymentBaseString())) { Map socialJson = JSON.parseObject(item.getSocialPaymentBaseString(), new HashMap().getClass()); if(socialJson!=null){ socialJson.forEach((k, v) -> { socailIds.add(k); }); } } if (StringUtils.isNotBlank(item.getFundPaymentBaseString())) { Map fundJson = JSON.parseObject(item.getFundPaymentBaseString(), new HashMap().getClass()); if(fundJson!=null){ fundJson.forEach((k, v) -> { fundIds.add(k); }); } } if (StringUtils.isNotBlank(item.getOtherPaymentBaseString())) { Map otherJson = JSON.parseObject(item.getOtherPaymentBaseString(), new HashMap().getClass()); if(otherJson!=null){ otherJson.forEach((k, v) -> { otherIds.add(k); }); } } }); Map socialColumns = new HashMap<>(); Map fundColumns = new HashMap<>(); Map otherColumns = new HashMap<>(); socailIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(100293, "申报基数"), social + "socialBase"); } }); fundIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "fundBase"); } }); otherIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "otherBase"); } }); result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns); result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns); result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns); return result; } private Map> buildPersonalTitle(List pos, Map categoryIdNameMap, Long employeeId, String tenantKey) { Set socailIds = new HashSet<>(); Set fundIds = new HashSet<>(); Set otherIds = new HashSet<>(); Map> result = new HashMap<>(); pos.stream().forEach(item -> { if (StringUtils.isNotBlank(item.getSocialPerJson())) { Map socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap().getClass()); if(socialJson!=null){ socialJson.forEach((k, v) -> { socailIds.add(k); }); } } if (StringUtils.isNotBlank(item.getFundPerJson())) { Map fundJson = JSON.parseObject(item.getFundPerJson(), new HashMap().getClass()); if(fundJson!=null){ fundJson.forEach((k, v) -> { fundIds.add(k); }); } } if (StringUtils.isNotBlank(item.getOtherPerJson())) { Map otherJson = JSON.parseObject(item.getOtherPerJson(), new HashMap().getClass()); if(otherJson!=null){ otherJson.forEach((k, v) -> { otherIds.add(k); }); } } }); Map socialColumns = new HashMap<>(); Map fundColumns = new HashMap<>(); Map otherColumns = new HashMap<>(); socailIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "socialPer"); } }); fundIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "fundPer"); } }); otherIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "otherPer"); } }); result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns); result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns); result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns); return result; } private Map> buildComTitle(List pos, Map categoryIdNameMap, Long employeeId, String tenantKey) { Set socailIds = new HashSet<>(); Set fundIds = new HashSet<>(); Set otherIds = new HashSet<>(); Map> result = new HashMap<>(); pos.stream().forEach(item -> { if (StringUtils.isNotBlank(item.getSocialComJson())) { Map socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap().getClass()); if(socialJson!=null){ socialJson.forEach((k, v) -> { socailIds.add(k); }); } } if (StringUtils.isNotBlank(item.getFundComJson())) { Map fundJson = JSON.parseObject(item.getFundComJson(), new HashMap().getClass()); if(fundJson!=null){ fundJson.forEach((k, v) -> { fundIds.add(k); }); } } if (StringUtils.isNotBlank(item.getOtherComJson())) { Map otherJson = JSON.parseObject(item.getOtherComJson(), new HashMap().getClass()); if(otherJson!=null){ otherJson.forEach((k, v) -> { otherIds.add(k); }); } } }); Map socialColumns = new HashMap<>(); Map fundColumns = new HashMap<>(); Map otherColumns = new HashMap<>(); socailIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "socialCom"); } }); fundIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "fundCom"); } }); otherIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "otherCom"); } }); result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns); result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns); result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns); return result; } @Override public List buildCommonColumns(List pos) { return null; } @Override public List buildInspectColumns(List pos) { List list = new ArrayList<>(); SIArchivesBiz siArchivesBiz = new SIArchivesBiz(); List employeeIds = pos.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList()); Map insuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds); Map categoryIdNameMap = MapperProxyFactory.getProxy(ICategoryMapper.class).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"); weaTableNameColumn.setFixed("left"); WeaTableColumn idColumn = new WeaTableColumn("150px", "id", "id"); idColumn.setIsPrimarykey(WeaBoolAttr.TRUE); idColumn.setDisplay(WeaBoolAttr.FALSE); list.add(idColumn); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86185, "部门"), "department")); list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile")); list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "employeeStatus")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100544, "缴纳情况"), "supplementaryMonth")); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), "socialSchemeName")); //组装社保基数 columns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称"), "fundSchemeName")); //组装公积金基数 columns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91496, "其他福利方案名称"), "otherSchemeName")); columns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> { list.add(new WeaTableColumn("150px",k, v)); }); return list; } private Map> buildInspectTableTitle(List pos, Map categoryIdNameMap ) { Set socailIds = new HashSet<>(); Set fundIds = new HashSet<>(); Set otherIds = new HashSet<>(); Map> result = new HashMap<>(); pos.stream().forEach(item -> { InsuranceArchivesSocialSchemePO social = item.getSocial(); if (social != null && StringUtils.isNotBlank(social.getSocialPaymentBaseString())) { Map socialJson = JSON.parseObject(social.getSocialPaymentBaseString(), new HashMap().getClass()); if(socialJson!=null){ socialJson.forEach((k, v) -> { socailIds.add(k); }); } } InsuranceArchivesFundSchemePO fund = item.getFund(); if (fund != null && StringUtils.isNotBlank(fund.getFundPaymentBaseString())) { Map fundJson = JSON.parseObject(fund.getFundPaymentBaseString(), new HashMap().getClass()); if(fundJson!=null){ fundJson.forEach((k, v) -> { fundIds.add(k); }); } } InsuranceArchivesOtherSchemePO other = item.getOther(); if (other != null && StringUtils.isNotBlank(other.getOtherPaymentBaseString())) { Map otherJson = JSON.parseObject(other.getOtherPaymentBaseString(), new HashMap().getClass()); if(otherJson!=null){ otherJson.forEach((k, v) -> { otherIds.add(k); }); } } }); Map socialColumns = new HashMap<>(); Map fundColumns = new HashMap<>(); Map otherColumns = new HashMap<>(); socailIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "socialBase"); } }); fundIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "fundBase"); } }); otherIds.stream().forEach(social -> { if (categoryIdNameMap.containsKey(social)) { otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "otherBase"); } }); result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns); result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns); result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns); return result; } }