Commit a9fe2bab authored by fangxinjiang's avatar fangxinjiang

优化-fxj

parent 7380f8b2
...@@ -170,6 +170,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -170,6 +170,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
long count = noPageCountDiy(searchVo); long count = noPageCountDiy(searchVo);
ServletOutputStream out = null; ServletOutputStream out = null;
HashMap<String,String> userMap = new HashMap<>(); HashMap<String,String> userMap = new HashMap<>();
ExcelWriter excelWriter = null;
try { try {
R<AllUserNaVo> userListR = upmsDaprUtils.getAllUserName(); R<AllUserNaVo> userListR = upmsDaprUtils.getAllUserName();
if (Common.isNotNull(userListR)) { if (Common.isNotNull(userListR)) {
...@@ -190,7 +191,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -190,7 +191,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
Map<String,String> redisLabelMap = (Map<String, String>) RedisUtil.redis.opsForValue().get(CacheConstants.REDIS_DICT_LABLE); Map<String,String> redisLabelMap = (Map<String, String>) RedisUtil.redis.opsForValue().get(CacheConstants.REDIS_DICT_LABLE);
redisLabelMap.putAll(userMap); redisLabelMap.putAll(userMap);
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, TDispatchInfoExportVo.class) excelWriter = EasyExcel.write(out, TDispatchInfoExportVo.class)
.registerConverter(new DictConverter(nameAndDicTypeMap,redisLabelMap)) .registerConverter(new DictConverter(nameAndDicTypeMap,redisLabelMap))
.includeColumnFieldNames(searchVo.getExportFields()).build(); .includeColumnFieldNames(searchVo.getExportFields()).build();
int index = 0; int index = 0;
...@@ -219,7 +220,6 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -219,7 +220,6 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
list.clear(); list.clear();
} }
out.flush(); out.flush();
excelWriter.finish();
} catch (Exception e) { } catch (Exception e) {
log.error("执行异常", e); log.error("执行异常", e);
} finally { } finally {
...@@ -227,6 +227,9 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -227,6 +227,9 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
if (null != out) { if (null != out) {
out.close(); out.close();
} }
if (null != excelWriter){
excelWriter.finish();
}
} catch (IOException e) { } catch (IOException e) {
log.error("执行异常", e); log.error("执行异常", e);
} }
......
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