From 10f76c102c3c69e5401caf245cb19c2aed7decd3 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Fri, 6 May 2022 16:58:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=8F=E5=88=A9=E6=A1=A3=E6=A1=88=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/SISchemeService.java | 20 ++ .../service/impl/SISchemeServiceImpl.java | 331 +++++++++++++++++- .../engine/salary/web/SISchemeController.java | 45 ++- 3 files changed, 388 insertions(+), 8 deletions(-) diff --git a/src/com/engine/salary/service/SISchemeService.java b/src/com/engine/salary/service/SISchemeService.java index 0476e5fc0..a9127c7cc 100644 --- a/src/com/engine/salary/service/SISchemeService.java +++ b/src/com/engine/salary/service/SISchemeService.java @@ -1,9 +1,13 @@ package com.engine.salary.service; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO; import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO; import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.util.List; import java.util.Map; @@ -42,4 +46,20 @@ public interface SISchemeService { * @return */ PageInfo list(InsuranceSchemeParam param); + + List listPageEmployeePOS(InsuranceArchivesListParam param); + + List> buildTableData(List insuranceArchivesEmployeePOS); + + XSSFWorkbook export(InsuranceArchivesListParam param); + + /** + * 获取方案名称 + * + * @param schemeId 方案主键id + * @return string + */ + String querySchemeName(Long schemeId); + + List buildWeaTableColumns(List insuranceArchivesEmployeePOS, Long employeeId); } diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java index 2fedb57de..1d74b79dc 100644 --- a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -1,30 +1,43 @@ package com.engine.salary.service.impl; +import com.alibaba.fastjson.JSON; +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.SISchemeBiz; import com.engine.salary.cmd.sischeme.*; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +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.dto.InsuranceSchemeListDTO; import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO; import com.engine.salary.entity.sischeme.po.InsuranceSchemePO; -import com.engine.salary.enums.sicategory.DeleteTypeEnum; -import com.engine.salary.enums.sicategory.IsPaymentEnum; -import com.engine.salary.enums.sicategory.PaymentTypeEnum; +import com.engine.salary.enums.sicategory.*; +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.service.SISchemeService; -import com.engine.salary.util.SalaryAssert; -import com.engine.salary.util.SalaryEnumUtil; -import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.*; 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.PageUtil; +import com.kingbase8.util.LOGGER; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import java.time.LocalDateTime; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -34,6 +47,29 @@ import java.util.stream.Collectors; * @Version V1.0 **/ public class SISchemeServiceImpl extends Service implements SISchemeService { + private SocialSchemeMapper getSocialSchemeMapper() { + return MapperProxyFactory.getProxy(SocialSchemeMapper.class); + } + + private FundSchemeMapper getFundSchemeMapper() { + return MapperProxyFactory.getProxy(FundSchemeMapper.class); + } + + private OtherSchemeMapper getOtherSchemeMapper() { + return MapperProxyFactory.getProxy(OtherSchemeMapper.class); + } + + private InsuranceSchemeMapper getInsuranceSchemeMapper() { + return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class); + } + + private ICategoryMapper getICategoryMapper() { + return MapperProxyFactory.getProxy(ICategoryMapper.class); + } + + private SISchemeService getSiSchemeService() { + return ServiceUtil.getService(SISchemeServiceImpl.class, user); + } @Override public Map getForm(Map params) { @@ -100,6 +136,140 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { return pageInfo; } + @Override + public List listPageEmployeePOS(InsuranceArchivesListParam param) { + return getSocialSchemeMapper().queryEmployeeList(param); + } + + @Override + public List> buildTableData(List insuranceArchivesEmployeePOS) { + List> records = new ArrayList<>(); + List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(employeeIds)) { + return records; + } + + Map socialSchemePOMap = + getSocialSchemeMapper().getSocialByEmployeeId(employeeIds) + .stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); + Map fundSchemePOMap = + getFundSchemeMapper().getFundByEmployeeId(employeeIds) + .stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); + Map otherSchemePOMap = + getOtherSchemeMapper().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.getUserStatusEnum() == null ? "" : item.getUserStatusEnum().getDescription()); + if (socialItem != null) { + map.put("socialName", getSiSchemeService().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", getSiSchemeService().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", getSiSchemeService().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; + } + + @Override + public XSSFWorkbook export(InsuranceArchivesListParam param) { + 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 (Objects.equals("fromQuickSearch", param.getDataSource())) { + request.setStatuses(param.getStatuses()); + request.setKeyword(param.getUserName()); + } else { + request = param; + } + request.setPageSize(null); + request.setStartNum(null); + List insuranceArchivesEmployeePOS = listPageEmployeePOS(request); + if (insuranceArchivesEmployeePOS == null) { + insuranceArchivesEmployeePOS = new ArrayList<>(); + } + List> records = buildTableData(insuranceArchivesEmployeePOS); + List columns = buildWeaTableColumns(insuranceArchivesEmployeePOS, (long) user.getUID()); + + //工作簿list + + + //工作簿数据 + List> rows = new LinkedList<>(); + List collect = columns.stream().map(WeaTableColumn::getText).collect(Collectors.toList()); + rows.add(collect); + for (Map recordData : records) { + List row = new LinkedList<>(); + for (WeaTableColumn column : columns) { + try { + Object o = recordData.get(column.getColumn()); + row.add(o.toString()); + } catch(Exception e) { + row.add(""); + } + } + rows.add(row); + } +// return salaryBatchService.simpleExportExcel(ExportExcelInfo.builder() +// .bizId(exportMap.get("biz")) +// .flag(true) +// .userId(employeeId) +// .eteamsId(eteamsId) +// .tenantKey(tenantKey) +// .operator(operator) +// .module(exportMap.get("module")) +// .fileName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 94629, "社保福利档案") + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())) +// .handlerName("insuranceArchivesExportHandler") +// .dataType(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 99915, "档案")) +// .function(exportMap.get("function")).build(), sheetList); + //获取excel + return ExcelUtil.genWorkbook(rows,"福利档案"); + } + public PaymentTypeEnum buildPaymentTypeEnum(Integer value) { return SalaryEnumUtil.enumMatchByValue(value, PaymentTypeEnum.values(), PaymentTypeEnum.class); @@ -131,4 +301,153 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { ICategoryPO insuranceCategoryPO = MapperProxyFactory.getProxy(ICategoryMapper.class).getById(id); return insuranceCategoryPO == null ? "" : Objects.isNull(insuranceCategoryPO.getInsuranceName()) ? "" : insuranceCategoryPO.getInsuranceName(); } + + + @Override + public String querySchemeName(Long schemeId) { + if (schemeId == null) { + return ""; + } + InsuranceSchemePO insuranceSchemePO = + getInsuranceSchemeMapper().getById(schemeId); + if (insuranceSchemePO == null) { + return ""; + } else { + return insuranceSchemePO.getSchemeName(); + } + } + + + @Override + public List buildWeaTableColumns(List insuranceArchivesEmployeePOS, Long employeeId) { + Map> titleMap = buildColumnTitle(insuranceArchivesEmployeePOS, employeeId); + List list = new ArrayList<>(); + WeaTableColumn nameColumn = new WeaTableColumn("100px", SalaryI18nUtil.getI18nLabel( 85429, "姓名"), "employeeName"); + nameColumn.setFixed("left"); + list.add(nameColumn); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName")); + list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel( 86186, "手机号"), "mobile")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "status")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), "socialName")); + titleMap.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91324, "社保账号"), "socialAccount")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91319, "社保起始缴纳月"), "socialStartTime")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91320, "社保最后缴纳月"), "socialEndTime")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"), "fundName")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91486, "公积金账号"), "fundAccount")); + titleMap.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91487, "补充公积金账号"), "supplementFundAccount")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91483, "公积金起始缴纳月"), "fundStartTime")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91484, "公积金最后缴纳月"), "fundEndTime")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"), "otherName")); + titleMap.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> list.add(new WeaTableColumn("150px", v, k))); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91490, "其他福利起始缴纳月"), "otherStartTime")); + list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91494, "其他福利最后缴纳月"), "otherEndTime")); + return list; + } + + public Map> buildColumnTitle(List insuranceArchivesEmployeePOS, Long employeeId) { + Map> result = new HashMap<>(); + Set socialSet = new HashSet<>(); + Set fundSet = new HashSet<>(); + Set otherSet = new HashSet<>(); + insuranceArchivesEmployeePOS.forEach(item -> { + List socialByEmployeeId = getSocialSchemeMapper().getSocialByEmployeeId(new ArrayList() {{ + add(item.getEmployeeId()); + }}); + InsuranceArchivesSocialSchemePO socialItem = null; + if(socialByEmployeeId.size() > 0) { + socialItem = socialByEmployeeId.get(0); + } + InsuranceArchivesFundSchemePO fundItem = null; + + List fundByEmployeeId = getFundSchemeMapper().getFundByEmployeeId(new ArrayList() {{ + add(item.getEmployeeId()); + }}); + if(fundByEmployeeId.size() > 0) { + fundItem = fundByEmployeeId.get(0); + } + InsuranceArchivesOtherSchemePO otherItem = null; + + List otherByEmployeeId = getOtherSchemeMapper().getOtherByEmployeeId(new ArrayList() {{ + add(item.getEmployeeId()); + }}); + if(otherByEmployeeId.size() > 0) { + otherItem = otherByEmployeeId.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 = + getICategoryMapper().listByWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), null) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + + Map sysSocial = + getICategoryMapper().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() + SalaryI18nUtil.getI18nLabel( 100293, "申报基数")); + } + }); + Map fundMap = new HashMap<>(); + Map fundCollect = new HashMap<>(); + Map customFund = + getICategoryMapper().listByWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), null) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysFund = + getICategoryMapper().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() + SalaryI18nUtil.getI18nLabel( 100293, "申报基数")); + } + }); + Map otherMap = new HashMap<>(); + Map otherCollect = new HashMap<>(); + Map customOther = + getICategoryMapper().listByWelfareType(WelfareTypeEnum.OTHER.getValue(), null) + .stream().collect(Collectors.toMap(ICategoryPO::getId, Function.identity())); + Map sysOther = + getICategoryMapper().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() + SalaryI18nUtil.getI18nLabel( 100293, "申报基数")); + } + }); + + result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialMap); + result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundMap); + result.put(WelfareTypeEnum.OTHER.getValue(), otherMap); + return result; + } } diff --git a/src/com/engine/salary/web/SISchemeController.java b/src/com/engine/salary/web/SISchemeController.java index 3eb346db0..b278dc7f1 100644 --- a/src/com/engine/salary/web/SISchemeController.java +++ b/src/com/engine/salary/web/SISchemeController.java @@ -2,6 +2,7 @@ package com.engine.salary.web; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO; import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam; import com.engine.salary.entity.sischeme.param.InsuranceSchemeReqParam; @@ -11,7 +12,12 @@ import com.engine.salary.service.impl.SISchemeServiceImpl; import com.engine.salary.util.ResponseResult; import com.engine.salary.util.page.PageInfo; import com.engine.salary.wrapper.SISchemeWrapper; +import com.wbi.util.Util; +import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.axis2.wsdl.codegen.writer.CBuildScriptWriter; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -20,8 +26,12 @@ import javax.servlet.http.HttpServletResponse; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; -import java.util.Collection; -import java.util.Map; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.*; +import java.util.stream.Collectors; /** * @Author weaver_cl @@ -157,6 +167,37 @@ public class SISchemeController { } + /** + * 导出档案 + * @return + */ + @GET + @Path("/template/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + InsuranceArchivesListParam param = new InsuranceArchivesListParam(); + String ids = request.getParameter("ids"); + if(StringUtils.isNotBlank(ids)){ + param.setIds( Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getService(user).export(param); + String fileName = null; + try { + fileName = URLEncoder.encode("福利档案.xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } + }