福利台账相关

This commit is contained in:
Chengliang 2022-04-20 19:12:01 +08:00
parent 24a20e14d0
commit 72e9e152d6
16 changed files with 596 additions and 42 deletions

View File

@ -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 {
}

View File

@ -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<Long> employeeIds = MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).selectAccountIds(SalaryDateUtil.getMonthBegin(billMonth));
if (CollectionUtils.isEmpty(employeeIds)) {
List<InsuranceAccountBatchPO> list = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getAllByBillMonth(billMonth);
List<InsuranceAccountBatchPO> 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<Long> ids;
@ -196,7 +186,7 @@ public class SIAccountBiz {
/*}*/
MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).batchDelAccountTempDetails(ids, param.getBillMonth());
} catch (Exception e) {
List<InsuranceAccountBatchPO> list = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getAllByBillMonth(param.getBillMonth());
List<InsuranceAccountBatchPO> 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());

View File

@ -37,22 +37,22 @@ public class InsuranceArchivesListParam extends BaseQueryParam {
private List<BigDecimal> 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;

View File

@ -36,7 +36,6 @@ public interface InsuranceAccountBatchMapper {
void insert(InsuranceAccountBatchPO insuranceAccountBatchPO);
List<InsuranceAccountBatchPO> getAllByBillMonth(@Param("billMonth") String billMonth);
/**
* 根据主键删除
@ -59,4 +58,6 @@ public interface InsuranceAccountBatchMapper {
*/
InsuranceAccountBatchPO getByBillStatus(@Param("billMonth") String billMonth,@Param("billStatus")Integer billStatus);
List<InsuranceAccountBatchPO> listByTimeRange(@Param("minDate") String minDate, @Param("maxDate") String maxDate);
}

View File

@ -98,17 +98,18 @@
ORDER BY t.bill_month DESC
</select>
<select id="getByBillMonth" resultMap="BaseResultMap">
<select id="listByTimeRange" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
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>
<select id="getAllByBillMonth" resultMap="BaseResultMap">
<select id="getByBillMonth" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM

View File

@ -26,10 +26,10 @@ public interface InsuranceAccountDetailMapper {
/**
* 根据账单月份获取所有员工
* @param billMonth
* @param time
* @return
*/
List<Long> selectAccountIds(@Param("billMonth") String billMonth);
List<Long> selectAccountIds(@Param("time") String time);
/**
* 根据id删除

View File

@ -157,12 +157,68 @@
<select id="selectAccountIds" resultType="java.lang.Long">
SELECT
t.employee_id
SELECT DISTINCT a.ID
FROM (
SELECT t.ID,
social.social_start_time,
social.social_end_time,
fund.fund_start_time,
fund.fund_end_time,
other.other_start_time,
other.other_end_time
FROM (
SELECT e.ID
FROM hrmresource e
LEFT JOIN (SELECT
t.*
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
(
SELECT
log.resource_n,
log.dismissdate
FROM
bill_hrmdismiss log ORDER BY
log.dismissdate DESC
) t
GROUP BY
t.resource_n) l
ON e.ID = l.resource_n
WHERE(
e.status != '5'
OR l.dismissdate IS NULL
OR l.dismissdate = ''
OR l.dismissdate
> #{time}
)
) AS t
LEFT JOIN hrsa_social_archives social ON t.ID = social.employee_id
LEFT JOIN hrsa_fund_archives fund ON t.ID = fund.employee_id
LEFT JOIN hrsa_other_archives other ON t.ID = other.employee_id
WHERE (
fund.fund_start_time IS NOT NULL AND fund.fund_start_time != ''
AND(
fund.fund_end_time IS NULL
OR fund.fund_end_time = ''
OR fund.fund_end_time > #{time}
)
)
OR (
social.social_start_time IS NOT NULL AND social.social_start_time != ''
AND(
social.social_end_time IS NULL
OR social.social_end_time = ''
OR social.social_end_time > #{time}
)
)
OR (
other.other_start_time IS NOT NULL AND other.other_start_time != ''
AND(
other.other_end_time IS NULL
OR other.other_end_time = ''
OR other.other_end_time > #{time}
)
)
) a
</select>
@ -226,10 +282,12 @@
SET delete_type = 1
WHERE delete_type = 0
AND bill_month = #{billMonth}
<if test="employeeIds != null and employeeIds.size()>0">
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
</delete>

View File

@ -280,10 +280,12 @@
hrsa_bill_detail_temp t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
<if test="employeeIds != null and employeeIds.size()>0">
AND t.employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
</select>

View File

@ -19,7 +19,7 @@ public interface InsuranceSchemeDetailMapper {
*
* @return list
*/
List<InsuranceSchemeDetailPO> queryListBySchemeId(Long schemeId);
List<InsuranceSchemeDetailPO> queryListBySchemeId(@Param("schemeId")Long schemeId);
/**
* 新增插入所有字段

View File

@ -63,6 +63,12 @@
</sql>
<select id="queryListBySchemeId" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_scheme_detail t
WHERE t.primary_id = #{schemeId} AND delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->

View File

@ -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);
}

View File

@ -243,14 +243,14 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
//条件组
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> 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<InsuranceAccountBatchPO> billMonthList = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).list(queryParam);
List<InsuranceAccountBatchPO> 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");

View File

@ -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<List<Object>> excelSheetData = new ArrayList<>();
//工作簿名称
String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案"); //表头
List<String> 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<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS = getSIArchivesService(user).listPageEmployeePOS(request);
if (insuranceArchivesEmployeePOS == null) {
insuranceArchivesEmployeePOS = new ArrayList<>();
}
List<Map<String, Object>> datas = buildTableData(insuranceArchivesEmployeePOS);
//表头
excelSheetData.add(Collections.singletonList(headers.toArray(new String[0])));
//工作簿数据
List<List<Object>> rows = new LinkedList<>();
for (int i = 1; i <= datas.size(); i++) {
List<Object> 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<Object> 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<String> buildHeader() {
List<String> 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<String, Long> 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<String, Long> 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<String, Long> 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<String, Long> welfareNameIdMap(WelfareTypeEnum welfareTypeEnum) {
return MapperProxyFactory.getProxy(ICategoryMapper.class).listByWelfareType(welfareTypeEnum.getValue(),null).stream().collect(Collectors.toMap(ICategoryPO::getInsuranceName, ICategoryPO::getId));
}
public Map<Long, String> welfareMap() {
return MapperProxyFactory.getProxy(ICategoryMapper.class).listAll().stream().collect(Collectors.toMap(ICategoryPO::getId, ICategoryPO::getInsuranceName));
}
/**
* 获取缴纳组织id-名称集合
*
* @return
*/
public Map<Long, String> paymentOrganizationIdNameMap() {
List<TaxAgent> 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<Map<String, Object>> buildTableData(List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS) {
List<Map<String, Object>> records = new ArrayList<>();
//获取id,福利名称的map用于下面组装福利数据
Map<Long, String> welfareMap = welfareMap();
//获取缴纳组织id-name集合
Map<Long, String> paymentMap = paymentOrganizationIdNameMap();
//获取id,方案名称的map用于下面组装福利数据
Map<Long, String> schemeMap = new HashMap<>();
List<InsuranceSchemePO> schemeList = MapperProxyFactory.getProxy(InsuranceSchemeMapper.class).listAll();
if (CollectionUtils.isNotEmpty(schemeList)) {
schemeMap = schemeList.stream().collect(Collectors.toMap(InsuranceSchemePO::getId, InsuranceSchemePO::getSchemeName));
}
List<Long> employeeIds = insuranceArchivesEmployeePOS.stream().map(InsuranceArchivesEmployeePO::getEmployeeId).collect(Collectors.toList());
Map<Long, InsuranceArchivesSocialSchemePO> socialSchemePOMap = new HashMap<>();
List<InsuranceArchivesSocialSchemePO> socialSchemePOList = MapperProxyFactory.getProxy(SocialSchemeMapper.class).getSocialByEmployeeId(employeeIds);
if (CollectionUtils.isNotEmpty(socialSchemePOList)) {
socialSchemePOMap = socialSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesSocialSchemePO::getEmployeeId, Function.identity()));
}
List<InsuranceArchivesFundSchemePO> fundSchemePOList = MapperProxyFactory.getProxy(FundSchemeMapper.class).getFundByEmployeeId(employeeIds);
Map<Long, InsuranceArchivesFundSchemePO> fundSchemePOMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(fundSchemePOList)) {
fundSchemePOMap = fundSchemePOList.stream().collect(Collectors.toMap(InsuranceArchivesFundSchemePO::getEmployeeId, Function.identity()));
}
Map<Long, InsuranceArchivesOtherSchemePO> otherSchemePOMap = new HashMap<>();
List<InsuranceArchivesOtherSchemePO> 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<String, Object> 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<String, Object> socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
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<String, Object> fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
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<String, Object> otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
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;
}
}

View File

@ -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;
}
}

View File

@ -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<InsuranceAccountInspectPO> 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();
}
}

View File

@ -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);
}
}