diff --git a/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java b/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java index d6f6ab501..c24a2f513 100644 --- a/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java +++ b/src/com/engine/salary/entity/siaccount/bo/InsuranceComparisonResultBO.java @@ -18,10 +18,7 @@ import com.engine.salary.util.page.Column; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -44,13 +41,20 @@ public class InsuranceComparisonResultBO { * 构建福利核算结果列表的表头(线下对比) * */ - public static List buildTableColumns4ComparisonResult() { + public static List buildTableColumns4ComparisonResult(Set insuranceBaseSet, Set insurancePerPaySet, Set insuranceComPaySet) { List listAll = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll(); - List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1).collect(Collectors.toList()); - List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2).collect(Collectors.toList()); - List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3).collect(Collectors.toList()); + List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List socialWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelComList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelComList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelComList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); List columns = Lists.newArrayList(); // 员工信息字段 columns.add(new Column("姓名", "userName", "userName")); @@ -80,33 +84,33 @@ public class InsuranceComparisonResultBO { } //社保个人(生育保险个人、工伤保险个人、失业保险个人、养老保险个人、医疗保险个人) - for (ICategoryPO po : socialWelfareList) { + for (ICategoryPO po : socialWelPerList) { columns.add(new Column(po.getInsuranceName() + "个人", po.getId() + "socialPer", po.getId() + "socialPer")); } columns.add(new Column("社保个人合计", "socialPerSum", "socialPerSum")); //住房公积金个人、补充住房公积金个人 - for (ICategoryPO po : fundWelfareList) { + for (ICategoryPO po : fundWelPerList) { columns.add(new Column(po.getInsuranceName() + "个人", po.getId() + "fundPer", po.getId() + "fundPer")); } columns.add(new Column("公积金个人合计", "fundPerSum", "fundPerSum")); //其他个人(比如企业年金个人) - for (ICategoryPO po : otherWelfareList) { + for (ICategoryPO po : otherWelPerList) { columns.add(new Column(po.getInsuranceName() + "个人", po.getId() + "otherPer", po.getId() + "otherPer")); } columns.add(new Column("其他福利个人合计", "otherPerSum", "otherPerSum")); columns.add(new Column("个人合计", "perSum", "perSum")); //社保单位(生育保险单位、工伤保险单位、失业保险单位、养老保险单位、医疗保险单位) - for (ICategoryPO po : socialWelfareList) { + for (ICategoryPO po : socialWelComList) { columns.add(new Column(po.getInsuranceName() + "单位", po.getId() + "socialCom", po.getId() + "socialCom")); } columns.add(new Column("社保单位合计", "socialComSum", "socialComSum")); //住房公积金单位、补充住房公积金单位 - for (ICategoryPO po : fundWelfareList) { + for (ICategoryPO po : fundWelComList) { columns.add(new Column(po.getInsuranceName() + "单位", po.getId() + "fundCom", po.getId() + "fundCom")); } columns.add(new Column("公积金单位合计", "fundComSum", "fundComSum")); //其他单位(比如企业年金单位) - for (ICategoryPO po : otherWelfareList) { + for (ICategoryPO po : otherWelComList) { columns.add(new Column(po.getInsuranceName() + "单位", po.getId() + "otherCom", po.getId() + "otherCom")); } columns.add(new Column("其他福利单位合计", "otherComSum", "otherComSum")); @@ -123,7 +127,7 @@ public class InsuranceComparisonResultBO { * 构建福利核算线下对比结果 * */ - public static List> buildComparisonTableData(List accountExportPOS, List excelAccountExportPOS) { + public static List> buildComparisonTableData(List accountExportPOS, List excelAccountExportPOS, Map schemeIdNameMap) { Map> excelResultMap = SalaryEntityUtil.group2Map(excelAccountExportPOS, ExcelAccountExportPO::getWorkcode); // Map> acctResultMap = SalaryEntityUtil.group2Map(accountExportPOS, AccountExportPO::getWorkcode); @@ -162,6 +166,11 @@ public class InsuranceComparisonResultBO { map.put("supplementFundAccount", accountExportPO.getSupplementFundAccount()); map.put("supplementFundAccount" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue()); + //福利方案名称 + map.put("socialSchemeName", schemeIdNameMap.get(accountExportPO.getSocialSchemeId())); + map.put("fundSchemeName", schemeIdNameMap.get(accountExportPO.getFundSchemeId())); + map.put("otherSchemeName", schemeIdNameMap.get(accountExportPO.getOtherSchemeId())); + //线下值 List excelResultValueList = excelResultMap.get(accountExportPO.getWorkcode()); ExcelAccountExportPO excelAccountExportPO = new ExcelAccountExportPO(); diff --git a/src/com/engine/salary/service/SIAccountService.java b/src/com/engine/salary/service/SIAccountService.java index 8a9a97497..8bf792abb 100644 --- a/src/com/engine/salary/service/SIAccountService.java +++ b/src/com/engine/salary/service/SIAccountService.java @@ -244,7 +244,7 @@ public interface SIAccountService { /** * 导出“福利核算-线下对比导入模板” */ - XSSFWorkbook exportComparisonWelfareTemplate(InsuranceAcctDetailImportTemplateParam param); + XSSFWorkbook exportComparisonWelfareTemplate(InsuranceAccountDetailParam param); /** * 将通过“福利核算-线下对比导入”模板导入的数据更新到hrsa_excel_bill_detail表中 diff --git a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java index c2e813437..2fe3ba1c6 100644 --- a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java @@ -11,11 +11,14 @@ import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.entity.siexport.param.InsuranceExportParam; import com.engine.salary.entity.siexport.po.AccountExportPO; import com.engine.salary.entity.siexport.po.ExcelAccountExportPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.enums.siaccount.EmployeeStatusEnum; import com.engine.salary.mapper.InsuranceExportMapper; 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.SISchemeService; import com.engine.salary.sys.entity.vo.OrderRuleVO; import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; @@ -26,6 +29,7 @@ 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; @@ -57,6 +61,14 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar return MapperProxyFactory.getProxy(ICategoryMapper.class); } + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + + private SISchemeService getSISchemeService(User user) { + return ServiceUtil.getService(SISchemeServiceImpl.class, user); + } + /** * 根据列表查询条件查询线下对比结果(分页) */ @@ -155,10 +167,35 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar //2-查询线下对比数据 List excelAccountExportPOS = getInsuranceExportMapper().exportExcelAccount(queryParam); encryptUtil.decryptList(excelAccountExportPOS, ExcelAccountExportPO.class); + + //整理线上核算记录相关的福利方案,并以此整理需要对比的福利项类别数据 + Set welfareSchemeIds = new HashSet<>(); + accountExportPOS.forEach(f -> { + welfareSchemeIds.add(f.getSocialSchemeId()); + welfareSchemeIds.add(f.getFundSchemeId()); + welfareSchemeIds.add(f.getOtherSchemeId()); + }); + List insuranceSchemeDetailPos = getInsuranceSchemeDetailMapper().listAll(); + List insuranceBaseIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insurancePerPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 2) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insuranceComPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + Set insuranceBaseSet = new HashSet<>(insuranceBaseIds); + Set insurancePerPaySet = new HashSet<>(insurancePerPayIds); + Set insuranceComPaySet = new HashSet<>(insuranceComPayIds); //3-构建福利核算对比结果列表表头 - List weaTableColumns = InsuranceComparisonResultBO.buildTableColumns4ComparisonResult(); + List weaTableColumns = InsuranceComparisonResultBO.buildTableColumns4ComparisonResult(insuranceBaseSet, insurancePerPaySet, insuranceComPaySet); //4-通过线上线下两份数据获得对比结果 - List> resultMapList = InsuranceComparisonResultBO.buildComparisonTableData(accountExportPOS, excelAccountExportPOS); + Map schemeIdNameMap = getSISchemeService(user).getSchemeIdNameMap(); + List> resultMapList = InsuranceComparisonResultBO.buildComparisonTableData(accountExportPOS, excelAccountExportPOS, schemeIdNameMap); // 系统值和线下值一致的人员 if (queryParam.isOnlyDiffEmployee()) { diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index f7aeec426..3ac3faca2 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -28,6 +28,9 @@ import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO; import com.engine.salary.entity.sicategory.po.ICategoryPO; +import com.engine.salary.entity.siexport.param.InsuranceExportParam; +import com.engine.salary.entity.siexport.po.AccountExportPO; +import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.UserStatusEnum; @@ -35,6 +38,7 @@ import com.engine.salary.enums.siaccount.*; import com.engine.salary.enums.sicategory.DeleteTypeEnum; import com.engine.salary.enums.sicategory.WelfareTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.InsuranceExportMapper; import com.engine.salary.mapper.siaccount.ExcelInsuranceDetailMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; @@ -43,6 +47,7 @@ import com.engine.salary.mapper.siarchives.FundSchemeMapper; import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; 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.mapper.sys.SalarySysConfMapper; import com.engine.salary.mapper.taxagent.TaxAgentMapper; @@ -183,6 +188,14 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { return MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class); } + private InsuranceExportMapper getInsuranceExportMapper() { + return MapperProxyFactory.getProxy(InsuranceExportMapper.class); + } + + private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class); + } + @Override public Map listPage(InsuranceAccountBatchParam queryParam) { Long employeeId = (long) user.getUID(); @@ -1824,12 +1837,51 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { * 导出“福利核算-线下对比导入模板” */ @Override - public XSSFWorkbook exportComparisonWelfareTemplate(InsuranceAcctDetailImportTemplateParam param) { + public XSSFWorkbook exportComparisonWelfareTemplate(InsuranceAccountDetailParam param) { + + //查询线上福利核算记录 + InsuranceExportParam insuranceExportParam = new InsuranceExportParam(); + insuranceExportParam.setBillMonth(param.getBillMonth()); + insuranceExportParam.setPaymentOrganization(param.getPaymentOrganization()); + List accountExportPOS = getInsuranceExportMapper().exportAccount(param.getPaymentStatus(), insuranceExportParam); + + //整理线上核算记录相关的福利方案,并以此整理需要对比的福利项类别数据 + Set welfareSchemeIds = new HashSet<>(); + accountExportPOS.forEach(f -> { + welfareSchemeIds.add(f.getSocialSchemeId()); + welfareSchemeIds.add(f.getFundSchemeId()); + welfareSchemeIds.add(f.getOtherSchemeId()); + }); + List insuranceSchemeDetailPos = getInsuranceSchemeDetailMapper().listAll(); + List insuranceBaseIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insurancePerPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 2) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + List insuranceComPayIds = insuranceSchemeDetailPos.stream() + .filter(f -> welfareSchemeIds.contains(f.getPrimaryId()) && f.getIsPayment() == 1 && f.getPaymentScope() == 1) + .map(InsuranceSchemeDetailPO::getInsuranceId) + .collect(Collectors.toList()); + Set insuranceBaseSet = new HashSet<>(insuranceBaseIds); + Set insurancePerPaySet = new HashSet<>(insurancePerPayIds); + Set insuranceComPaySet = new HashSet<>(insuranceComPayIds); List listAll = getICategoryMapper().listAll(); - List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1).collect(Collectors.toList()); - List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2).collect(Collectors.toList()); - List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3).collect(Collectors.toList()); + List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceBaseSet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelPerList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insurancePerPaySet.contains(e.getId())).collect(Collectors.toList()); + + List socialWelComList = listAll.stream().filter(e -> e.getWelfareType() == 1 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List fundWelComList = listAll.stream().filter(e -> e.getWelfareType() == 2 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List otherWelComList = listAll.stream().filter(e -> e.getWelfareType() == 3 && e.getIsUse() == 1 && insuranceComPaySet.contains(e.getId())).collect(Collectors.toList()); + List headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"), SalaryI18nUtil.getI18nLabel(86185, "部门"), SalaryI18nUtil.getI18nLabel(86186, "手机号"), @@ -1860,33 +1912,33 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { headerList.add(po.getInsuranceName() + "申报基数"); } //社保个人(生育保险个人、工伤保险个人、失业保险个人、养老保险个人、医疗保险个人) - for (ICategoryPO po : socialWelfareList) { + for (ICategoryPO po : socialWelPerList) { headerList.add(po.getInsuranceName() + "个人"); } headerList.add(SalaryI18nUtil.getI18nLabel(100388, "社保个人合计")); //住房公积金个人、补充住房公积金个人 - for (ICategoryPO po : fundWelfareList) { + for (ICategoryPO po : fundWelPerList) { headerList.add(po.getInsuranceName() + "个人"); } headerList.add(SalaryI18nUtil.getI18nLabel(100390, "公积金个人合计")); //其他个人(比如企业年金个人) - for (ICategoryPO po : otherWelfareList) { + for (ICategoryPO po : otherWelPerList) { headerList.add(po.getInsuranceName() + "个人"); } headerList.add(SalaryI18nUtil.getI18nLabel(100392, "其他福利个人合计")); headerList.add(SalaryI18nUtil.getI18nLabel(100393, "个人合计")); //社保单位(生育保险单位、工伤保险单位、失业保险单位、养老保险单位、医疗保险单位) - for (ICategoryPO po : socialWelfareList) { + for (ICategoryPO po : socialWelComList) { headerList.add(po.getInsuranceName() + "单位"); } headerList.add(SalaryI18nUtil.getI18nLabel(100394, "社保单位合计")); //住房公积金单位、补充住房公积金单位 - for (ICategoryPO po : fundWelfareList) { + for (ICategoryPO po : fundWelComList) { headerList.add(po.getInsuranceName() + "单位"); } headerList.add(SalaryI18nUtil.getI18nLabel(100395, "公积金单位合计")); //其他单位(比如企业年金单位) - for (ICategoryPO po : otherWelfareList) { + for (ICategoryPO po : otherWelComList) { headerList.add(po.getInsuranceName() + "单位"); } headerList.add(SalaryI18nUtil.getI18nLabel(100396, "其他福利单位合计")); diff --git a/src/com/engine/salary/web/SIAccountController.java b/src/com/engine/salary/web/SIAccountController.java index b9978755f..448922c7d 100644 --- a/src/com/engine/salary/web/SIAccountController.java +++ b/src/com/engine/salary/web/SIAccountController.java @@ -559,12 +559,21 @@ public class SIAccountController { @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response exportComparisonWelfareTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { - InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam(); + InsuranceAccountDetailParam param = new InsuranceAccountDetailParam(); -// String welfareNames = request.getParameter("welfareNames"); -// if (StringUtils.isNotBlank(welfareNames)) { -// param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList())); -// } + String billMonth = request.getParameter("billMonth"); + if (StringUtils.isNotBlank(billMonth)) { + param.setBillMonth(billMonth); + } + String paymentOrganization = request.getParameter("paymentOrganization"); + if (StringUtils.isNotBlank(paymentOrganization)) { + param.setPaymentOrganization(paymentOrganization); + } + + String paymentStatus = request.getParameter("paymentStatus"); + if (StringUtils.isNotBlank(paymentStatus)) { + param.setPaymentStatus(Integer.valueOf(paymentStatus)); + } User user = HrmUserVarify.getUser(request, response); XSSFWorkbook workbook = getService(user).exportComparisonWelfareTemplate(param);