From 72e9e152d659da1693941e0c0d9c4e1095022a49 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Wed, 20 Apr 2022 19:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=8F=E5=88=A9=E5=8F=B0=E8=B4=A6=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/salary/web/SIExportController.java | 13 + src/com/engine/salary/biz/SIAccountBiz.java | 22 +- .../param/InsuranceArchivesListParam.java | 12 +- .../InsuranceAccountBatchMapper.java | 3 +- .../siaccount/InsuranceAccountBatchMapper.xml | 9 +- .../InsuranceAccountDetailMapper.java | 4 +- .../InsuranceAccountDetailMapper.xml | 68 ++++- .../siaccount/SIAccountDetailTempMapper.xml | 2 + .../sischeme/InsuranceSchemeDetailMapper.java | 2 +- .../sischeme/InsuranceSchemeDetailMapper.xml | 6 + .../salary/service/SIImportService.java | 20 ++ .../service/impl/SIAccountServiceImpl.java | 9 +- .../service/impl/SIImportServiceImpl.java | 252 ++++++++++++++++++ .../engine/salary/web/SIExportController.java | 111 +++++++- .../engine/salary/web/SIImportController.java | 77 ++++++ .../salary/wrapper/SIImportWrapper.java | 28 ++ 16 files changed, 596 insertions(+), 42 deletions(-) create mode 100644 src/com/api/salary/web/SIExportController.java create mode 100644 src/com/engine/salary/service/SIImportService.java create mode 100644 src/com/engine/salary/service/impl/SIImportServiceImpl.java create mode 100644 src/com/engine/salary/web/SIImportController.java create mode 100644 src/com/engine/salary/wrapper/SIImportWrapper.java diff --git a/src/com/api/salary/web/SIExportController.java b/src/com/api/salary/web/SIExportController.java new file mode 100644 index 000000000..048fe946a --- /dev/null +++ b/src/com/api/salary/web/SIExportController.java @@ -0,0 +1,13 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/20 + * @Version V1.0 + **/ +@Path("/bs/hrmsalary/welfare") +public class SIExportController extends com.engine.salary.web.SIExportController { +} diff --git a/src/com/engine/salary/biz/SIAccountBiz.java b/src/com/engine/salary/biz/SIAccountBiz.java index d9520b0bd..b02176a56 100644 --- a/src/com/engine/salary/biz/SIAccountBiz.java +++ b/src/com/engine/salary/biz/SIAccountBiz.java @@ -2,11 +2,9 @@ package com.engine.salary.biz; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; -import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO; -import com.engine.salary.entity.salaryarchive.po.TaxAgentPO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.param.*; import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; @@ -26,12 +24,9 @@ import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountInspectMapper; import com.engine.salary.mapper.siaccount.SIAccountDetailTempMapper; -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.SalaryAssert; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; @@ -39,25 +34,20 @@ import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.PageUtil; -import com.kingbase8.util.LOGGER; +import com.google.common.collect.Lists; import dm.jdbc.util.IdGenerator; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.SqlSession; import org.springframework.beans.BeanUtils; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.annotation.Propagation; + import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.DefaultTransactionDefinition; import weaver.conn.mybatis.MyBatisFactory; import java.math.BigDecimal; -import java.time.LocalDateTime; import java.util.*; -import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; import java.util.function.Function; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -133,7 +123,7 @@ public class SIAccountBiz { public void account(String billMonth, Long employeeId, String tenantKey) { List employeeIds = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(billMonth)); if (CollectionUtils.isEmpty(employeeIds)) { - List list = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getAllByBillMonth(billMonth); + List list = Lists.newArrayList(MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth)); if (CollectionUtils.isNotEmpty(list)) { list.stream().forEach(f -> { MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).deleteById(f.getId()); @@ -164,7 +154,7 @@ public class SIAccountBiz { } - @Transactional(propagation = Propagation.NEVER, rollbackFor = Exception.class) + //@Transactional(propagation = Propagation.NEVER, rollbackFor = Exception.class) public void doAccounting(AccountParam param, Long employeeId, String tenantKey) { try { List ids; @@ -196,7 +186,7 @@ public class SIAccountBiz { /*}*/ MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).batchDelAccountTempDetails(ids, param.getBillMonth()); } catch (Exception e) { - List list = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getAllByBillMonth(param.getBillMonth()); + List list = Lists.newArrayList(MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(param.getBillMonth())); if (CollectionUtils.isNotEmpty(list)) { list.stream().forEach(f -> { MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).deleteById(f.getId()); diff --git a/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesListParam.java b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesListParam.java index 8888365c5..423623b6c 100644 --- a/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesListParam.java +++ b/src/com/engine/salary/entity/siarchives/param/InsuranceArchivesListParam.java @@ -37,22 +37,22 @@ public class InsuranceArchivesListParam extends BaseQueryParam { private List positions; //入职时间") - private Date[] hireDate; + private String[] hireDate; //离职时间") - private Date[] dimissionDate; + private String[] dimissionDate; //入职开始时间") - private Date hiredateStart; + private String hiredateStart; //入职结束时间") - private Date hiredateEnd; + private String hiredateEnd; //离职开始时间") - private Date dimissionDateStart; + private String dimissionDateStart; //离职结束时间") - private Date dimissionDateEnd; + private String dimissionDateEnd; //社保方案id") private Long siSchemeId; diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java index 578654a26..899bffd0a 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.java @@ -36,7 +36,6 @@ public interface InsuranceAccountBatchMapper { void insert(InsuranceAccountBatchPO insuranceAccountBatchPO); - List getAllByBillMonth(@Param("billMonth") String billMonth); /** * 根据主键删除 @@ -59,4 +58,6 @@ public interface InsuranceAccountBatchMapper { */ InsuranceAccountBatchPO getByBillStatus(@Param("billMonth") String billMonth,@Param("billStatus")Integer billStatus); + + List listByTimeRange(@Param("minDate") String minDate, @Param("maxDate") String maxDate); } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml index 1282ac474..b966a0680 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountBatchMapper.xml @@ -98,17 +98,18 @@ ORDER BY t.bill_month DESC - - SELECT FROM hrsa_bill_batch t WHERE t.delete_type = 0 - AND t.bill_month = #{billMonth} + AND t.bill_month between #{minDate} and #{maxDate} + ORDER BY t.bill_month DESC - SELECT FROM diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java index c9f5dbce1..51d3587d9 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.java @@ -26,10 +26,10 @@ public interface InsuranceAccountDetailMapper { /** * 根据账单月份获取所有员工 - * @param billMonth + * @param time * @return */ - List selectAccountIds(@Param("billMonth") String billMonth); + List selectAccountIds(@Param("time") String time); /** * 根据id删除 diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml index 55342838a..eff96524a 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMapper.xml @@ -157,12 +157,68 @@ @@ -226,10 +282,12 @@ SET delete_type = 1 WHERE delete_type = 0 AND bill_month = #{billMonth} + AND employee_id IN #{employeeId} + diff --git a/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml index 5ffbf57d1..81b85a670 100644 --- a/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/SIAccountDetailTempMapper.xml @@ -280,10 +280,12 @@ hrsa_bill_detail_temp t WHERE t.delete_type = 0 AND t.bill_month = #{billMonth} + AND t.employee_id IN #{employeeId} + diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java index 61bdbbef0..1bcc9a90d 100644 --- a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.java @@ -19,7 +19,7 @@ public interface InsuranceSchemeDetailMapper { * * @return list */ - List queryListBySchemeId(Long schemeId); + List queryListBySchemeId(@Param("schemeId")Long schemeId); /** * 新增,插入所有字段 diff --git a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml index 2be432060..bd641ac60 100644 --- a/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml +++ b/src/com/engine/salary/mapper/sischeme/InsuranceSchemeDetailMapper.xml @@ -63,6 +63,12 @@ + diff --git a/src/com/engine/salary/service/SIImportService.java b/src/com/engine/salary/service/SIImportService.java new file mode 100644 index 000000000..67ca5d7da --- /dev/null +++ b/src/com/engine/salary/service/SIImportService.java @@ -0,0 +1,20 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/20 + * @Version V1.0 + **/ +public interface SIImportService { + + /** + * 导出档案导入所需要的模板,可根据开关选择是否导出现有的档案数据 + * + * @param param 是否导出带档案数据的模板 + */ + XSSFWorkbook exportTemplate(InsuranceArchivesListParam param); +} diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index b63b9ae40..178c6da3e 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -243,14 +243,14 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { //条件组 List addGroups = new ArrayList<>(); List conditionItems = new ArrayList<>(); - SearchConditionItem datePickerItem = SalaryFormItemUtil.datePickerItem(user, 2, 16, true, 1, "账单月份", "billMonth"); + SearchConditionItem datePickerItem = SalaryFormItemUtil.datePickerItem(user, 2, 16, true, 2, "账单月份", "billMonth"); String minDate = SalaryDateUtil.getYearMonth(-1, 0); String maxDate = SalaryDateUtil.getYearMonth(0, 6); + datePickerItem.setOtherParams(new HashMap<>()); datePickerItem.getOtherParams().put("minDate",minDate); datePickerItem.getOtherParams().put("maxDate",maxDate); - InsuranceAccountBatchParam queryParam = InsuranceAccountBatchParam.builder().startTime(minDate).endTime(maxDate).build(); - List billMonthList = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).list(queryParam); + List billMonthList = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).listByTimeRange(minDate,maxDate); if (CollectionUtils.isEmpty(billMonthList)) { datePickerItem.getOtherParams().put("disabledData", Collections.emptyList()); } else { @@ -261,7 +261,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { datePickerItem.getOtherParams().put("showFormat", "YYYY-MM"); conditionItems.add(datePickerItem); - SearchConditionItem textareaItem = SalaryFormItemUtil.textareaItem(user, 2, 16, true, 1, 60, "备注", "remarks"); + SearchConditionItem textareaItem = SalaryFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "备注", "remarks"); conditionItems.add(textareaItem); addGroups.add(new SearchConditionGroup("常用条件",true,conditionItems)); @@ -541,6 +541,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { SearchConditionItem billMonthList = SalaryFormItemUtil.datePickerItem(user, 2, 16, true, 2, "账单月份", "billMonth"); billMonthList.setMultiple(true); + billMonthList.setOtherParams(new HashMap<>()); billMonthList.getOtherParams().put("type", "months"); billMonthList.getOtherParams().put("format", "YYYY-MM"); billMonthList.getOtherParams().put("showFormat", "YYYY-MM"); diff --git a/src/com/engine/salary/service/impl/SIImportServiceImpl.java b/src/com/engine/salary/service/impl/SIImportServiceImpl.java new file mode 100644 index 000000000..247aec89b --- /dev/null +++ b/src/com/engine/salary/service/impl/SIImportServiceImpl.java @@ -0,0 +1,252 @@ +package com.engine.salary.service.impl; + +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.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.po.InsuranceSchemePO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.enums.sicategory.WelfareTypeEnum; +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.InsuranceSchemeMapper; +import com.engine.salary.service.SIArchivesService; +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.ExcelUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/20 + * @Version V1.0 + **/ +public class SIImportServiceImpl extends Service implements SIImportService { + + public SIArchivesService getSIArchivesService(User user) { + return ServiceUtil.getService(SIArchivesServiceImpl.class,user); + } + + @Override + public XSSFWorkbook exportTemplate(InsuranceArchivesListParam param) { + //工作簿list + List> excelSheetData = new ArrayList<>(); + + //工作簿名称 + String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案"); //表头 + List headers = buildHeader(); + 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()); + request.setStartNum(param.getStartNum()); + request.setPageSize(param.getPageSize()); + } else { + request = param; + } + request.setPageSize(null); + request.setStartNum(null); + List insuranceArchivesEmployeePOS = getSIArchivesService(user).listPageEmployeePOS(request); + if (insuranceArchivesEmployeePOS == null) { + insuranceArchivesEmployeePOS = new ArrayList<>(); + } + List> datas = buildTableData(insuranceArchivesEmployeePOS); + //表头 + excelSheetData.add(Collections.singletonList(headers.toArray(new String[0]))); + //工作簿数据 + List> rows = new LinkedList<>(); + for (int i = 1; i <= datas.size(); i++) { + List row = new ArrayList<>(); + for (int j = 0; j < 4; j++) { + Object cellValue = datas.get(i - 1).get(headers.get(j)); + row.add(cellValue); + } + rows.add(row); + } + //根据是否导出数据开关设置已存在的档案数据 + for (int i = 1; i <= datas.size(); i++) { + List row = rows.get(i - 1); + for (int j = 4; j < headers.size(); j++) { + if (param.getExportData()) { + Object cellValue = datas.get(i - 1).get(headers.get(j)); + row.add(cellValue); + } else { + row.add(""); + } + } + } + excelSheetData.addAll(rows); + return ExcelUtil.genWorkbookV2(excelSheetData, sheetName); + } + + + /** + * 构建档案excel的表头 + * + * @return + */ + public List buildHeader() { + List result = new ArrayList<>(); + result.add(SalaryI18nUtil.getI18nLabel( 85429, "姓名")); + result.add(SalaryI18nUtil.getI18nLabel( 86185, "部门")); + result.add(SalaryI18nUtil.getI18nLabel( 86186, "手机号")); + result.add(SalaryI18nUtil.getI18nLabel( 86187, "员工状态")); + result.add(SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称")); + result.add(SalaryI18nUtil.getI18nLabel( 91325, "社保缴纳组织")); + //社保福利基数 + Map socialMap = welfareNameIdMap( WelfareTypeEnum.SOCIAL_SECURITY); + socialMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"))); + result.add(SalaryI18nUtil.getI18nLabel( 91324, "社保账号")); + result.add(SalaryI18nUtil.getI18nLabel( 91319, "社保起始缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91320, "社保最后缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称")); + result.add(SalaryI18nUtil.getI18nLabel( 91488, "公积金缴纳组织")); + result.add(SalaryI18nUtil.getI18nLabel( 91486, "公积金账号")); + //公积金福利基数 + Map fundMap = welfareNameIdMap( WelfareTypeEnum.ACCUMULATION_FUND); + fundMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"))); + result.add(SalaryI18nUtil.getI18nLabel( 91487, "补充公积金账号")); + result.add(SalaryI18nUtil.getI18nLabel( 91483, "公积金起始缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91484, "公积金最后缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91496, "其他福利方案名称")); + result.add(SalaryI18nUtil.getI18nLabel( 91497, "其他福利缴纳组织")); + //其他福利基数 + Map otherMap = welfareNameIdMap( WelfareTypeEnum.OTHER); + otherMap.forEach((k, v) -> result.add(k + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"))); + result.add(SalaryI18nUtil.getI18nLabel( 91490, "其他福利起始缴纳月")); + result.add(SalaryI18nUtil.getI18nLabel( 91494, "其他福利最后缴纳月")); + return result; + } + + /** + * 获取福利类型名称-id的map + * + * @param welfareTypeEnum + * @return + */ + public Map welfareNameIdMap(WelfareTypeEnum welfareTypeEnum) { + return MapperProxyFactory.getProxy(ICategoryMapper.class).listByWelfareType(welfareTypeEnum.getValue(),null).stream().collect(Collectors.toMap(ICategoryPO::getInsuranceName, ICategoryPO::getId)); + } + + public Map welfareMap() { + return MapperProxyFactory.getProxy(ICategoryMapper.class).listAll().stream().collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName)); + } + + /** + * 获取缴纳组织id-名称集合 + * + * @return + */ + public Map paymentOrganizationIdNameMap() { + List list = MapperProxyFactory.getProxy(TaxAgentMapper.class).listAll(); + if (CollectionUtils.isEmpty(list)) { + return new HashMap<>(); + } + return list.stream().collect(Collectors.toMap(TaxAgent::getId, TaxAgent::getName)); + } + + public List> buildTableData(List insuranceArchivesEmployeePOS) { + List> records = new ArrayList<>(); + //获取id,福利名称的map,用于下面组装福利数据 + Map welfareMap = welfareMap(); + //获取缴纳组织id-name集合 + Map paymentMap = paymentOrganizationIdNameMap(); + //获取id,方案名称的map,用于下面组装福利数据 + Map schemeMap = new HashMap<>(); + List schemeList = MapperProxyFactory.getProxy(InsuranceSchemeMapper.class).listAll(); + if (CollectionUtils.isNotEmpty(schemeList)) { + schemeMap = schemeList.stream().collect(Collectors.toMap(InsuranceSchemePO::getId, InsuranceSchemePO::getSchemeName)); + } + List employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList()); + Map socialSchemePOMap = new HashMap<>(); + List socialSchemePOList = MapperProxyFactory.getProxy(SocialSchemeMapper.class).getSocialByEmployeeId(employeeIds); + if (CollectionUtils.isNotEmpty(socialSchemePOList)) { + socialSchemePOMap = socialSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity())); + } + List fundSchemePOList = MapperProxyFactory.getProxy(FundSchemeMapper.class).getFundByEmployeeId(employeeIds); + Map fundSchemePOMap = new HashMap<>(); + if (CollectionUtils.isNotEmpty(fundSchemePOList)) { + fundSchemePOMap = fundSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity())); + } + Map otherSchemePOMap = new HashMap<>(); + List otherSchemePOList = MapperProxyFactory.getProxy(OtherSchemeMapper.class).getOtherByEmployeeId(employeeIds); + if (CollectionUtils.isNotEmpty(otherSchemePOList)) { + otherSchemePOMap = otherSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesOtherSchemePO::getEmployeeId, Function.identity())); + } + for (InsuranceArchivesEmployeePO item : insuranceArchivesEmployeePOS) { + InsuranceArchivesSocialSchemePO socialItem = socialSchemePOMap.get(item.getEmployeeId()); + InsuranceArchivesFundSchemePO fundItem = fundSchemePOMap.get(item.getEmployeeId()); + InsuranceArchivesOtherSchemePO otherItem = otherSchemePOMap.get(item.getEmployeeId()); + Map map = new HashMap<>(); + map.put(SalaryI18nUtil.getI18nLabel( 85429, "姓名"), item.getUserName()); + map.put(SalaryI18nUtil.getI18nLabel( 86185, "部门"), item.getDepartmentName()); + map.put(SalaryI18nUtil.getI18nLabel( 86186, "手机号"), item.getTelephone()); + map.put(SalaryI18nUtil.getI18nLabel( 86187, "员工状态"), item.getUserStatusEnum() == null ? "" : item.getUserStatusEnum().getDescription()); + if (socialItem != null) { + map.put(SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), schemeMap.get(socialItem.getSocialSchemeId())); + map.put(SalaryI18nUtil.getI18nLabel( 91325, "社保缴纳组织"), paymentMap.get(socialItem.getPaymentOrganization())); + Map socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference>() { + }); + if (socialJson != null) { + socialJson.forEach((k, v) -> map.put(welfareMap.get(Long.valueOf(k)) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), v)); + } + map.put(SalaryI18nUtil.getI18nLabel( 91324, "社保账号"), socialItem.getSocialAccount()); + map.put(SalaryI18nUtil.getI18nLabel( 91319, "社保起始缴纳月"), socialItem.getSocialStartTime()); + map.put(SalaryI18nUtil.getI18nLabel( 91320, "社保最后缴纳月"), socialItem.getSocialEndTime()); + } + if (fundItem != null) { + map.put(SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称"), schemeMap.get(fundItem.getFundSchemeId())); + map.put(SalaryI18nUtil.getI18nLabel( 91488, "公积金缴纳组织"), paymentMap.get(fundItem.getPaymentOrganization())); + map.put(SalaryI18nUtil.getI18nLabel( 91486, "公积金账号"), fundItem.getFundAccount()); + Map fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference>() { + }); + if (fundJson != null) { + fundJson.forEach((k, v) -> map.put(welfareMap.get(Long.valueOf(k)) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), v)); + } + map.put(SalaryI18nUtil.getI18nLabel( 91487, "补充公积金账号"), fundItem.getSupplementFundAccount()); + map.put(SalaryI18nUtil.getI18nLabel( 91483, "公积金起始缴纳月"), fundItem.getFundStartTime()); + map.put(SalaryI18nUtil.getI18nLabel( 91484, "公积金最后缴纳月"), fundItem.getFundEndTime()); + + } + if (otherItem != null) { + map.put(SalaryI18nUtil.getI18nLabel( 91496, "其他福利方案名称"), schemeMap.get(otherItem.getOtherSchemeId())); + map.put(SalaryI18nUtil.getI18nLabel( 91497, "其他福利缴纳组织"), paymentMap.get(otherItem.getPaymentOrganization())); + Map otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference>() { + }); + if (otherJson != null) { + otherJson.forEach((k, v) -> map.put(welfareMap.get(Long.valueOf(k)) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), v)); + } + map.put(SalaryI18nUtil.getI18nLabel( 91490, "其他福利起始缴纳月"), otherItem.getOtherStartTime()); + map.put(SalaryI18nUtil.getI18nLabel( 91494, "其他福利最后缴纳月"), otherItem.getOtherEndTime()); + } + records.add(map); + } + return records; + } + +} diff --git a/src/com/engine/salary/web/SIExportController.java b/src/com/engine/salary/web/SIExportController.java index 4eeed12d4..8dfcf67f4 100644 --- a/src/com/engine/salary/web/SIExportController.java +++ b/src/com/engine/salary/web/SIExportController.java @@ -11,12 +11,14 @@ import com.engine.salary.service.SIAccountService; import com.engine.salary.service.impl.SIAccountServiceImpl; import com.engine.salary.wrapper.SIExportWrapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -25,8 +27,11 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; import java.net.URLEncoder; +import java.text.SimpleDateFormat; import java.time.LocalDate; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -46,11 +51,12 @@ public class SIExportController { return ServiceUtil.getService(SIExportWrapper.class,user); } - @POST + @GET @Path("/archives/export") @Produces(MediaType.APPLICATION_OCTET_STREAM) - public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response, - @RequestBody InsuranceArchivesListParam param) { + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response + ) { + InsuranceArchivesListParam param = buildParam(request); User user = HrmUserVarify.getUser(request, response); XSSFWorkbook workbook = getSIExportWrapper(user).export(param); String time = LocalDate.now().toString(); @@ -68,6 +74,8 @@ public class SIExportController { return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); } + + @POST @Path("/archives/exportInspect") @Produces(MediaType.APPLICATION_OCTET_STREAM) @@ -164,5 +172,102 @@ public class SIExportController { return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); } + private InsuranceArchivesListParam buildParam(HttpServletRequest request) { + InsuranceArchivesListParam param = new InsuranceArchivesListParam(); + String userName = request.getParameter("userName"); + if (StringUtils.isNotBlank(userName)) { + param.setUserName(userName); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setUserName(jobNum); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + String statuses = request.getParameter("statuses"); + if (StringUtils.isNotBlank(statuses)) { + param.setStatuses(Arrays.stream(statuses.split(",")).map(String::valueOf).collect(Collectors.toList())); + } + String positions = request.getParameter("positions"); + if (StringUtils.isNotBlank(positions)) { + param.setPositions(Arrays.stream(positions.split(",")).map(BigDecimal::new).collect(Collectors.toList())); + } + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + param.setHireDate(hiredate.split(",")); + } + String dimissionDate = request.getParameter("dimissionDate"); + if (StringUtils.isNotBlank(dimissionDate)) { + param.setDimissionDate(dimissionDate.split(",")); + } + String hiredateStart = request.getParameter("hiredateStart"); + if (StringUtils.isNotBlank(hiredateStart)) { + param.setHiredateStart(hiredateStart); + } + String hiredateEnd = request.getParameter("hiredateEnd"); + if (StringUtils.isNotBlank(hiredateEnd)) { + param.setHiredateEnd(hiredateEnd); + } + String dimissionDateStart = request.getParameter("dimissionDateStart"); + if (StringUtils.isNotBlank(dimissionDateStart)) { + param.setDimissionDateStart(dimissionDateStart); + } + String dimissionDateEnd = request.getParameter("dimissionDateEnd"); + if (StringUtils.isNotBlank(dimissionDateEnd)) { + param.setDimissionDateEnd(dimissionDateEnd); + } + String siSchemeId = request.getParameter("siSchemeId"); + if (StringUtils.isNotBlank(siSchemeId)) { + param.setSiSchemeId(Long.valueOf(siSchemeId)); + } + String fundSchemeId = request.getParameter("fundSchemeId"); + if (StringUtils.isNotBlank(fundSchemeId)) { + param.setFundSchemeId(Long.valueOf(fundSchemeId)); + } + String otherSchemeId = request.getParameter("otherSchemeId"); + if (StringUtils.isNotBlank(otherSchemeId)) { + param.setOtherSchemeId(Long.valueOf(otherSchemeId)); + } + String employeeIds = request.getParameter("employeeIds"); + if (StringUtils.isNotBlank(employeeIds)) { + param.setEmployeeIds(Arrays.stream(employeeIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String dataSource = request.getParameter("dataSource"); + if (StringUtils.isNotBlank(dataSource)) { + param.setDataSource(dataSource); + } + + String exportData = request.getParameter("exportData"); + if (StringUtils.isNotBlank(exportData)) { + param.setExportData(Boolean.valueOf(exportData)); + } + String inspectAll = request.getParameter("inspectAll"); + if (StringUtils.isNotBlank(inspectAll)) { + param.setInspectAll(Boolean.valueOf(inspectAll)); + } + + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + + String billMonth = request.getParameter("billMonth"); + if (StringUtils.isNotBlank(billMonth)) { + param.setBillMonth(billMonth); + } + String templateFlag = request.getParameter("templateFlag"); + if (StringUtils.isNotBlank(templateFlag)) { + param.setTemplateFlag(Boolean.valueOf(templateFlag)); + } + + return param; + } } diff --git a/src/com/engine/salary/web/SIImportController.java b/src/com/engine/salary/web/SIImportController.java new file mode 100644 index 000000000..485911f96 --- /dev/null +++ b/src/com/engine/salary/web/SIImportController.java @@ -0,0 +1,77 @@ +package com.engine.salary.web; + +import cn.hutool.core.util.BooleanUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.biz.SIAccountBiz; +import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.wrapper.SIImportWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author weaver_cl + * @Description: TODO 福利导入控制器 + * @Date 2022/4/20 + * @Version V1.0 + **/ +public class SIImportController { + + public SIImportWrapper getSIImportWrapper(User user) { + return ServiceUtil.getService(SIImportWrapper.class,user); + } + + + @POST + @Path("/exportCurrentData") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody InsuranceArchivesListParam param) { + SIAccountBiz siAccountBiz = new SIAccountBiz(); + if (param.getInspectAll() != null && param.getInspectAll()) { + List insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth()); + param.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList())); + } + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIImportWrapper(user).exportTemplate(param); + String time = LocalDate.now().toString(); + String fileName = ""; + if (BooleanUtil.isTrue(param.getTemplateFlag())) { + fileName =SalaryI18nUtil.getI18nLabel( 100571, "社保福利档案模板"); + } else { + fileName = SalaryI18nUtil.getI18nLabel( 94629, "社保福利档案"); + } + fileName = fileName + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } + + +} diff --git a/src/com/engine/salary/wrapper/SIImportWrapper.java b/src/com/engine/salary/wrapper/SIImportWrapper.java new file mode 100644 index 000000000..a1989b560 --- /dev/null +++ b/src/com/engine/salary/wrapper/SIImportWrapper.java @@ -0,0 +1,28 @@ +package com.engine.salary.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam; +import com.engine.salary.service.SIImportService; +import com.engine.salary.service.impl.SIImportServiceImpl; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/4/20 + * @Version V1.0 + **/ +public class SIImportWrapper extends Service { + + public SIImportService getSIImportService(User user) { + return ServiceUtil.getService(SIImportServiceImpl.class,user); + } + + + public XSSFWorkbook exportTemplate(InsuranceArchivesListParam param) { + return getSIImportService(user).exportTemplate(param); + } +}