修复导出相关问题
parent
c6ea9844ca
commit
dceba5c4b2
|
@ -9,19 +9,21 @@ import com.zcloud.entity.Page;
|
||||||
import com.zcloud.entity.PageData;
|
import com.zcloud.entity.PageData;
|
||||||
import com.zcloud.entity.accident.AccidentRecords;
|
import com.zcloud.entity.accident.AccidentRecords;
|
||||||
import com.zcloud.service.accident.AccidentRecordsService;
|
import com.zcloud.service.accident.AccidentRecordsService;
|
||||||
|
import com.zcloud.util.ObjectExcelView;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@Controller
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/accident")
|
@RequestMapping("/accident")
|
||||||
public class AccidentRecordsController extends BaseController {
|
public class AccidentRecordsController extends BaseController {
|
||||||
|
@ -35,6 +37,7 @@ public class AccidentRecordsController extends BaseController {
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
* @return 返回结果
|
* @return 返回结果
|
||||||
*/
|
*/
|
||||||
|
@ResponseBody
|
||||||
@RequestMapping(value = "/page")
|
@RequestMapping(value = "/page")
|
||||||
public Map<String, Object> queryPage(Page page, HttpServletRequest request) {
|
public Map<String, Object> queryPage(Page page, HttpServletRequest request) {
|
||||||
page.setPd(new PageData(request));
|
page.setPd(new PageData(request));
|
||||||
|
@ -51,6 +54,7 @@ public class AccidentRecordsController extends BaseController {
|
||||||
* @param id id
|
* @param id id
|
||||||
* @return 返回结果
|
* @return 返回结果
|
||||||
*/
|
*/
|
||||||
|
@ResponseBody
|
||||||
@RequestMapping("/{id}")
|
@RequestMapping("/{id}")
|
||||||
public Map<String, Object> getById(@PathVariable("id") Long id) {
|
public Map<String, Object> getById(@PathVariable("id") Long id) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
@ -65,6 +69,7 @@ public class AccidentRecordsController extends BaseController {
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
* @return 返回结果
|
* @return 返回结果
|
||||||
*/
|
*/
|
||||||
|
@ResponseBody
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
public Map<String, Object> save(HttpServletRequest request) {
|
public Map<String, Object> save(HttpServletRequest request) {
|
||||||
AccidentRecords accidentRecords = BeanUtil.mapToBean(new PageData(request), AccidentRecords.class, true);
|
AccidentRecords accidentRecords = BeanUtil.mapToBean(new PageData(request), AccidentRecords.class, true);
|
||||||
|
@ -80,6 +85,7 @@ public class AccidentRecordsController extends BaseController {
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
* @return 返回结果
|
* @return 返回结果
|
||||||
*/
|
*/
|
||||||
|
@ResponseBody
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
public Map<String, Object> update(HttpServletRequest request) {
|
public Map<String, Object> update(HttpServletRequest request) {
|
||||||
AccidentRecords accidentRecords = BeanUtil.mapToBean(new PageData(request), AccidentRecords.class, true);
|
AccidentRecords accidentRecords = BeanUtil.mapToBean(new PageData(request), AccidentRecords.class, true);
|
||||||
|
@ -96,6 +102,7 @@ public class AccidentRecordsController extends BaseController {
|
||||||
* @param values id集合
|
* @param values id集合
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
|
@ResponseBody
|
||||||
@RequestMapping("/delete/{ids}")
|
@RequestMapping("/delete/{ids}")
|
||||||
public Map<String, Object> delete(@PathVariable("ids") String values) {
|
public Map<String, Object> delete(@PathVariable("ids") String values) {
|
||||||
if (StrUtil.isEmpty(values)) {
|
if (StrUtil.isEmpty(values)) {
|
||||||
|
@ -112,26 +119,27 @@ public class AccidentRecordsController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 导出excel
|
* 导出excel
|
||||||
*
|
*
|
||||||
* @param request 请求
|
* @param request 请求
|
||||||
* @param response 响应
|
* @return 返回结果
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/export/excel")
|
@RequestMapping("/export/excel")
|
||||||
public void exportExcel(HttpServletRequest request, HttpServletResponse response) {
|
public ModelAndView exportExcel(HttpServletRequest request) {
|
||||||
accidentRecordsService.exportExcel(new PageData(request), response);
|
Map<String, Object> dataMap = accidentRecordsService.exportExcel(new PageData(request));
|
||||||
|
return new ModelAndView(new ObjectExcelView(), dataMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 导入excel
|
// * 导入excel
|
||||||
*
|
// *
|
||||||
* @param file 文件
|
// * @param file 文件
|
||||||
*/
|
// */
|
||||||
@RequestMapping("/import/excel")
|
// @RequestMapping("/import/excel")
|
||||||
public void importExcel(@RequestParam("file") MultipartFile file) {
|
// public void importExcel(@RequestParam("file") MultipartFile file) {
|
||||||
if (file == null || file.isEmpty()) {
|
// if (file == null || file.isEmpty()) {
|
||||||
throw new RuntimeException("文件不能为空");
|
// throw new RuntimeException("文件不能为空");
|
||||||
}
|
// }
|
||||||
accidentRecordsService.importExcel(file);
|
// accidentRecordsService.importExcel(file);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入图片
|
* 导入图片
|
||||||
|
@ -139,6 +147,7 @@ public class AccidentRecordsController extends BaseController {
|
||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
|
@ResponseBody
|
||||||
@RequestMapping("/import/photos")
|
@RequestMapping("/import/photos")
|
||||||
public Map<String, Object> importPhotos(@RequestParam("file") MultipartFile file) {
|
public Map<String, Object> importPhotos(@RequestParam("file") MultipartFile file) {
|
||||||
if (file == null || file.isEmpty()) {
|
if (file == null || file.isEmpty()) {
|
||||||
|
@ -156,6 +165,7 @@ public class AccidentRecordsController extends BaseController {
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
|
@ResponseBody
|
||||||
@RequestMapping("/delete/photos")
|
@RequestMapping("/delete/photos")
|
||||||
public Map<String, Object> deletePhotos(HttpServletRequest request) {
|
public Map<String, Object> deletePhotos(HttpServletRequest request) {
|
||||||
String path = new PageData(request).getString("path");
|
String path = new PageData(request).getString("path");
|
||||||
|
|
|
@ -57,5 +57,5 @@ public interface AccidentRecordsMapper {
|
||||||
* @param pd 条件
|
* @param pd 条件
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
List<AccidentRecordsExcel> listExcel(PageData pd);
|
List<AccidentRecordsExcel> listExcel(@Param("pd") PageData pd);
|
||||||
}
|
}
|
|
@ -5,8 +5,8 @@ import com.zcloud.entity.PageData;
|
||||||
import com.zcloud.entity.accident.AccidentRecords;
|
import com.zcloud.entity.accident.AccidentRecords;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface AccidentRecordsService {
|
public interface AccidentRecordsService {
|
||||||
|
|
||||||
|
@ -51,16 +51,16 @@ public interface AccidentRecordsService {
|
||||||
* 导出Excel
|
* 导出Excel
|
||||||
*
|
*
|
||||||
* @param pd 查询条件
|
* @param pd 查询条件
|
||||||
* @param response 响应
|
* @return 组装好的数据
|
||||||
*/
|
*/
|
||||||
void exportExcel(PageData pd, HttpServletResponse response);
|
Map<String,Object> exportExcel(PageData pd);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 导入Excel
|
// * 导入Excel
|
||||||
*
|
// *
|
||||||
* @param file 文件
|
// * @param file 文件
|
||||||
*/
|
// */
|
||||||
void importExcel(MultipartFile file);
|
// void importExcel(MultipartFile file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入图片
|
* 导入图片
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package com.zcloud.service.accident.impl;
|
package com.zcloud.service.accident.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.*;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.poi.excel.ExcelReader;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.poi.excel.ExcelWriter;
|
|
||||||
import com.zcloud.entity.Page;
|
import com.zcloud.entity.Page;
|
||||||
import com.zcloud.entity.PageData;
|
import com.zcloud.entity.PageData;
|
||||||
import com.zcloud.entity.accident.AccidentRecords;
|
import com.zcloud.entity.accident.AccidentRecords;
|
||||||
|
@ -15,27 +12,18 @@ import com.zcloud.entity.accident.dto.AccidentRecordsExcel;
|
||||||
import com.zcloud.mapper.datasource.accident.AccidentRecordsMapper;
|
import com.zcloud.mapper.datasource.accident.AccidentRecordsMapper;
|
||||||
import com.zcloud.service.accident.AccidentRecordsService;
|
import com.zcloud.service.accident.AccidentRecordsService;
|
||||||
import com.zcloud.service.bus.ImgFilesService;
|
import com.zcloud.service.bus.ImgFilesService;
|
||||||
import com.zcloud.service.system.DictionariesService;
|
|
||||||
import com.zcloud.util.*;
|
import com.zcloud.util.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
|
||||||
import org.apache.ibatis.session.SqlSession;
|
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -44,15 +32,15 @@ import java.util.stream.Collectors;
|
||||||
public class AccidentRecordsServiceImpl implements AccidentRecordsService {
|
public class AccidentRecordsServiceImpl implements AccidentRecordsService {
|
||||||
|
|
||||||
private final AccidentRecordsMapper accidentRecordsMapper;
|
private final AccidentRecordsMapper accidentRecordsMapper;
|
||||||
private final SqlSessionFactory sqlSessionFactory;
|
//private final SqlSessionFactory sqlSessionFactory;
|
||||||
private final DictionariesService dictionariesService;
|
//private final DictionariesService dictionariesService;
|
||||||
private static final Map<String, String> HEADER_ALIAS_CACHE;
|
private static final List<Field> HEADER_ALIAS_CACHE;
|
||||||
private final ImgFilesService imgFilesService;
|
private final ImgFilesService imgFilesService;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
HEADER_ALIAS_CACHE = Arrays.stream(ReflectUtil.getFields(AccidentRecordsExcel.class))
|
HEADER_ALIAS_CACHE = Arrays.stream(ReflectUtil.getFields(AccidentRecordsExcel.class))
|
||||||
.filter(field -> field.isAnnotationPresent(ExcelValue.class))
|
.filter(field -> field.isAnnotationPresent(ExcelValue.class))
|
||||||
.collect(Collectors.toMap(Field::getName, field -> field.getAnnotation(ExcelValue.class).value()));
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -98,70 +86,71 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exportExcel(PageData pd, HttpServletResponse response) {
|
public Map<String, Object> exportExcel(PageData pd) {
|
||||||
// 查询数据
|
// 查询数据
|
||||||
pd.put("corpInfoId", Jurisdiction.getCORPINFO_ID());
|
pd.put("corpInfoId", Jurisdiction.getCORPINFO_ID());
|
||||||
List<AccidentRecordsExcel> list = accidentRecordsMapper.listExcel(pd);
|
List<AccidentRecordsExcel> excels = accidentRecordsMapper.listExcel(pd);
|
||||||
|
|
||||||
// 检查查询结果是否为空
|
// 检查查询结果是否为空
|
||||||
if (list == null || list.isEmpty()) {
|
if (excels == null || excels.isEmpty()) {
|
||||||
throw new RuntimeException("没有查询到数据");
|
throw new RuntimeException("没有查询到数据");
|
||||||
}
|
}
|
||||||
|
Map<String, Object> dataMap = new HashMap<String, Object>() {{
|
||||||
|
put("filename", "事故调查");
|
||||||
|
put("titles", HEADER_ALIAS_CACHE.stream().map(field -> field.getAnnotation(ExcelValue.class)
|
||||||
|
.value()).collect(Collectors.toList()));
|
||||||
|
}};
|
||||||
|
|
||||||
// 设置响应头
|
List<PageData> varList = excels.stream().map(excel -> {
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
PageData data = new PageData();
|
||||||
response.setCharacterEncoding("utf-8");
|
for (int i = 0; i < HEADER_ALIAS_CACHE.size(); i++) {
|
||||||
response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + URLUtil.encode("事故调查表", CharsetUtil.UTF_8) + ".xlsx");
|
data.put("var" + (i + 1), ReflectUtil.getFieldValue(excel, HEADER_ALIAS_CACHE.get(i)));
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
try (ExcelWriter writer = ExcelUtil.getBigWriter()) {
|
dataMap.put("varList", varList);
|
||||||
writer.setHeaderAlias(HEADER_ALIAS_CACHE)
|
return dataMap;
|
||||||
.setOnlyAlias(true)
|
|
||||||
.write(list, true)
|
|
||||||
.flush(response.getOutputStream());
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("导出excel失败", e);
|
|
||||||
throw new RuntimeException("导出excel失败");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void importExcel(MultipartFile file) {
|
// public void importExcel(MultipartFile file) {
|
||||||
// ExecutorType.BATCH: 这个执行器会批量执行所有更新语句。
|
// // ExecutorType.BATCH: 这个执行器会批量执行所有更新语句。
|
||||||
SqlSession sqlSession = null;
|
// SqlSession sqlSession = null;
|
||||||
try (ExcelReader reader = ExcelUtil.getReader(file.getInputStream())) {
|
// try (ExcelReader reader = ExcelUtil.getReader(file.getInputStream())) {
|
||||||
// 标记别名
|
// // 标记别名
|
||||||
HEADER_ALIAS_CACHE.forEach((k, v) -> reader.addHeaderAlias(v, k));
|
// HEADER_ALIAS_CACHE.forEach((k, v) -> reader.addHeaderAlias(v, k));
|
||||||
List<AccidentRecordsExcel> recordsExcels = reader.readAll(AccidentRecordsExcel.class);
|
// List<AccidentRecordsExcel> recordsExcels = reader.readAll(AccidentRecordsExcel.class);
|
||||||
if (CollUtil.isEmpty(recordsExcels)) {
|
// if (CollUtil.isEmpty(recordsExcels)) {
|
||||||
throw new RuntimeException("没有数据");
|
// throw new RuntimeException("没有数据");
|
||||||
}
|
// }
|
||||||
sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
// sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||||
AccidentRecordsMapper mapper = sqlSession.getMapper(AccidentRecordsMapper.class);
|
// AccidentRecordsMapper mapper = sqlSession.getMapper(AccidentRecordsMapper.class);
|
||||||
for (int i = 0; i < recordsExcels.size(); i++) {
|
// for (int i = 0; i < recordsExcels.size(); i++) {
|
||||||
mapper.save(new AccidentRecords(recordsExcels.get(i), dictionariesService));
|
// mapper.save(new AccidentRecords(recordsExcels.get(i), dictionariesService));
|
||||||
if ((i + 1) % 300 == 0 || i == recordsExcels.size() - 1) {
|
// if ((i + 1) % 300 == 0 || i == recordsExcels.size() - 1) {
|
||||||
sqlSession.flushStatements();
|
// sqlSession.flushStatements();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// 避免刷新数据字典不生效 每次导出重新查询字典
|
// // 避免刷新数据字典不生效 每次导出重新查询字典
|
||||||
AccidentRecords.dictMap.clear();
|
// AccidentRecords.dictMap.clear();
|
||||||
sqlSession.commit();
|
// sqlSession.commit();
|
||||||
} catch (RuntimeException e) {
|
// } catch (RuntimeException e) {
|
||||||
if (sqlSession != null) {
|
// if (sqlSession != null) {
|
||||||
sqlSession.rollback();
|
// sqlSession.rollback();
|
||||||
}
|
// }
|
||||||
log.error("导入excel失败", e);
|
// log.error("导入excel失败", e);
|
||||||
throw e;
|
// throw e;
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
if (sqlSession != null) {
|
// if (sqlSession != null) {
|
||||||
sqlSession.rollback();
|
// sqlSession.rollback();
|
||||||
}
|
// }
|
||||||
log.error("导入excel失败", e);
|
// log.error("导入excel失败", e);
|
||||||
throw new RuntimeException("导入excel失败");
|
// throw new RuntimeException("导入excel失败");
|
||||||
} finally {
|
// } finally {
|
||||||
IoUtil.close(sqlSession);
|
// IoUtil.close(sqlSession);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String importPhotos(MultipartFile file) {
|
public String importPhotos(MultipartFile file) {
|
||||||
|
|
|
@ -267,28 +267,32 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="listExcel" resultType="com.zcloud.entity.accident.dto.AccidentRecordsExcel">
|
<select id="listExcel" resultType="com.zcloud.entity.accident.dto.AccidentRecordsExcel" parameterType="pd">
|
||||||
select incident_number,
|
select incident_number as incidentNumber,
|
||||||
incident_name,
|
incident_name as incidentName,
|
||||||
(select NAME from sys_dictionaries
|
(select NAME
|
||||||
where DICTIONARIES_ID = '8d4140a900184b60836ad1a6490fd510' and BIANMA = incident_type) as 'incidentType',
|
from sys_dictionaries
|
||||||
(select NAME from sys_dictionaries
|
where PARENT_ID = '8d4140a900184b60836ad1a6490fd510'
|
||||||
where DICTIONARIES_ID = 'b61a1edc59c0430c8741c5f51aa26c3c' and BIANMA = incident_level) as 'incidentLevel',
|
and BIANMA = incident_type) as 'incidentType',
|
||||||
CORP_NAME as 'companyName',
|
(select NAME
|
||||||
incident_nature ,
|
from sys_dictionaries
|
||||||
`location`,
|
where PARENT_ID = 'b61a1edc59c0430c8741c5f51aa26c3c'
|
||||||
|
and BIANMA = incident_level) as 'incidentLevel',
|
||||||
|
CORP_NAME as 'companyName',
|
||||||
|
incident_nature as incidentNature,
|
||||||
|
`location` as location,
|
||||||
date_format(incident_date, '%Y年%m月%d日%H时%I分%s秒') as 'incidentDate',
|
date_format(incident_date, '%Y年%m月%d日%H时%I分%s秒') as 'incidentDate',
|
||||||
direct_loss,
|
direct_loss as directLoss,
|
||||||
injured,
|
injured,
|
||||||
fatalities,
|
fatalities,
|
||||||
seriously_injured,
|
seriously_injured as seriouslyInjured,
|
||||||
cause,
|
cause,
|
||||||
summary,
|
summary,
|
||||||
analysis,
|
analysis,
|
||||||
suggestions,
|
suggestions,
|
||||||
measures,
|
measures,
|
||||||
ar.creator,
|
ar.creator as creator,
|
||||||
date_format(report_date, '%Y年%m月%d日%H时%I分%s秒') as 'reportDate'
|
date_format(report_date, '%Y年%m月%d日%H时%I分%s秒') as 'reportDate'
|
||||||
from accident_records as ar
|
from accident_records as ar
|
||||||
left join bus_corp_info as bci on ar.corpinfo_id = bci.CORPINFO_ID
|
left join bus_corp_info as bci on ar.corpinfo_id = bci.CORPINFO_ID
|
||||||
<where>
|
<where>
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class AccidentRecordsServiceTest {
|
||||||
when(accidentRecordsMapper.listExcel(pd)).thenReturn(expectedList);
|
when(accidentRecordsMapper.listExcel(pd)).thenReturn(expectedList);
|
||||||
|
|
||||||
HttpServletResponse response = mock(HttpServletResponse.class);
|
HttpServletResponse response = mock(HttpServletResponse.class);
|
||||||
accidentRecordsService.exportExcel(pd, response);
|
//accidentRecordsService.exportExcel(pd, response);
|
||||||
|
|
||||||
verify(response, times(1)).setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
verify(response, times(1)).setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
verify(response, times(1)).setCharacterEncoding("utf-8");
|
verify(response, times(1)).setCharacterEncoding("utf-8");
|
||||||
|
|
Loading…
Reference in New Issue