Commit 56f43907 authored by huyuchen's avatar huyuchen

导出优化

parent 490e40c5
......@@ -68,6 +68,7 @@ import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 员工合同
......@@ -1136,17 +1137,22 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
}
try {
ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class);
for (EmployeeContractExportVO vo : list) {
util.convertEntity(vo, null, null, null);
}
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding(CommonConstants.UTF8);
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 获取所有字典type
Map<String,String> nameAndDicTypeMap = util.getConverterDicType();
// 获取所有字典对应的值
Map<String,String> redisLabelMap = (Map<String, String>) RedisUtil.redis.opsForValue().get(CacheConstants.REDIS_DICT_LABLE);
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcelFactory.write(out, EmployeeContractExportVO.class).includeColumnFiledNames(contractInfo.getExportFields())
.sheet("员工合同").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeContractExportVO.class)
.registerConverter(new DictConverter(nameAndDicTypeMap,redisLabelMap))
.includeColumnFieldNames(contractInfo.getExportFields()).build();
WriteSheet writeSheet = EasyExcel.writerSheet("员工合同").build();
excelWriter.write(list, writeSheet);
out.flush();
excelWriter.finish();
} catch (Exception e) {
log.error("员工合同导出异常:", e);
} finally {
......@@ -1176,17 +1182,22 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
}
try {
ExcelUtil<EmployeeContractExportVO> util = new ExcelUtil<>(EmployeeContractExportVO.class);
for (EmployeeContractExportVO vo : list) {
util.convertEntity(vo, null, null, null);
}
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding(CommonConstants.UTF8);
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 获取所有字典type
Map<String,String> nameAndDicTypeMap = util.getConverterDicType();
// 获取所有字典对应的值
Map<String,String> redisLabelMap = (Map<String, String>) RedisUtil.redis.opsForValue().get(CacheConstants.REDIS_DICT_LABLE);
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcelFactory.write(out, EmployeeContractExportVO.class).includeColumnFiledNames(contractInfo.getExportFields())
.sheet("员工合同【合并历史】").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, EmployeeContractExportVO.class)
.registerConverter(new DictConverter(nameAndDicTypeMap,redisLabelMap))
.includeColumnFieldNames(contractInfo.getExportFields()).build();
WriteSheet writeSheet = EasyExcel.writerSheet("员工合同【合并历史】").build();
excelWriter.write(list, writeSheet);
out.flush();
excelWriter.finish();
} catch (Exception e) {
log.error(EmployeeConstants.CONCART_ALL_EXPORT_EXCEPTION, e);
} finally {
......
......@@ -448,8 +448,44 @@
<!--导出-->
<select id="getTEmployeeContractExport" resultMap="tEmployeeContrctInfoExportMap">
SELECT
<include refid="Base_Export_Column_List"/>,a.type
a.APPLY_NO,
a.EMP_NO,
a.EMP_NAME,
a.EMP_IDCARD,
a.CONTRACT_START,
a.CONTRACT_END,
a1.AREA_NAME as "FILE_PROVINCE",
a2.AREA_NAME as "FILE_CITY",
a3.AREA_NAME as "FILE_TOWN",
a.SUBJECT_DEPART,
a.DEPT_NO,
a.EMP_NATRUE,
a.CONTRACT_NAME,
a.CONTRACT_SUB_NAME,
a.SITUATION,
a.CONTRACT_TYPE,
a.CONTRACT_PARTY,
a.SUBJECT_UNIT,
CASE WHEN a.AUDIT_STATUS=0 THEN "待提交"
WHEN a.AUDIT_STATUS =1 THEN "待审核"
WHEN a.AUDIT_STATUS =2 THEN "审核通过"
WHEN a.AUDIT_STATUS =3 THEN "审核不通过"
ELSE a.AUDIT_STATUS END as "AUDIT_STATUS",
if(a.IN_USE = 0,'可用','不可用') IN_USE,
if(a.IS_FILE = 0,'有附件','无附件') FILES,
if(a.IS_FILE = 0,'已归档','未归档') IS_FILE,
a.CREATE_NAME,
CASE WHEN a.type=0 THEN "派增-社保派单"
WHEN a.type =1 THEN "派增-无社保新签"
WHEN a.type =2 THEN "派增-续签"
WHEN a.type =3 THEN "派减-作废"
WHEN a.type =4 THEN "派减-终止"
ELSE a.type END as "type",
a.CREATE_TIME
FROM t_employee_contract_info a
LEFT JOIN sys_area a1 on a1.id=a.FILE_PROVINCE
LEFT JOIN sys_area a2 on a2.id=a.FILE_CITY
LEFT JOIN sys_area a3 on a3.id=a.FILE_TOWN
<where>
a.DELETE_FLAG = 0
<include refid="tEmployeeContractInfo_where"/>
......@@ -464,12 +500,48 @@
<!--导出历史合并-->
<select id="getTEmployeeContractExportHistory" resultMap="tEmployeeContrctInfoExportMap">
SELECT
<include refid="Base_Export_Column_List"/>
,count(1) CREATE_NUM,
a.APPLY_NO,
a.EMP_NO,
a.EMP_NAME,
a.EMP_IDCARD,
a.CONTRACT_START,
a.CONTRACT_END,
a1.AREA_NAME as "FILE_PROVINCE",
a2.AREA_NAME as "FILE_CITY",
a3.AREA_NAME as "FILE_TOWN",
a.SUBJECT_DEPART,
a.DEPT_NO,
a.EMP_NATRUE,
a.CONTRACT_NAME,
a.CONTRACT_SUB_NAME,
a.SITUATION,
a.CONTRACT_TYPE,
a.CONTRACT_PARTY,
a.SUBJECT_UNIT,
CASE WHEN a.AUDIT_STATUS=0 THEN "待提交"
WHEN a.AUDIT_STATUS =1 THEN "待审核"
WHEN a.AUDIT_STATUS =2 THEN "审核通过"
WHEN a.AUDIT_STATUS =3 THEN "审核不通过"
ELSE a.AUDIT_STATUS END as "AUDIT_STATUS",
if(a.IN_USE = 0,'可用','不可用') IN_USE,
if(a.IS_FILE = 0,'有附件','无附件') FILES,
if(a.IS_FILE = 0,'已归档','未归档') IS_FILE,
a.CREATE_NAME,
CASE WHEN a.type=0 THEN "派增-社保派单"
WHEN a.type =1 THEN "派增-无社保新签"
WHEN a.type =2 THEN "派增-续签"
WHEN a.type =3 THEN "派减-作废"
WHEN a.type =4 THEN "派减-终止"
ELSE a.type END as "type",
a.CREATE_TIME,
count(1) CREATE_NUM,
min(a.CONTRACT_START) START_DATE,
max(a.CONTRACT_END) END_DATE,
GROUP_CONCAT(concat(a.CONTRACT_START,'~',ifnull(a.CONTRACT_END,'')) ORDER BY a.CONTRACT_START asc) HISTORY
FROM t_employee_contract_info a
LEFT JOIN sys_area a1 on a1.id=a.FILE_PROVINCE
LEFT JOIN sys_area a2 on a2.id=a.FILE_CITY
LEFT JOIN sys_area a3 on a3.id=a.FILE_TOWN
<where>
a.DELETE_FLAG = 0 and a.AUDIT_TIME_LAST is not null and a.SITUATION != '作废' and a.SITUATION != '终止'
<include refid="tEmployeeContractInfo_where"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment