|
@@ -1,53 +1,41 @@
|
|
|
package org.jeecg.modules.history.controller;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLDecoder;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.detail.dto.InterlockDetailQueryDTO;
|
|
|
import org.jeecg.modules.detail.mapper.InterlockDetailMapper;
|
|
|
import org.jeecg.modules.history.dto.InterlockHistoryQueryDTO;
|
|
|
import org.jeecg.modules.history.entity.InterlockDetailHistory;
|
|
|
import org.jeecg.modules.history.mapper.InterlockSummaryHistoryMapper;
|
|
|
import org.jeecg.modules.history.service.IInterlockDetailHistoryService;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-
|
|
|
import org.jeecg.modules.history.vo.InterlockDetailHistoryQueryVO;
|
|
|
import org.jeecg.modules.history.vo.InterlockHistoryDistinctZZXTVO;
|
|
|
import org.jeecg.modules.history.vo.InterlockSummaryHistoryVO;
|
|
|
-import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
-import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
-import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
-import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
|
|
- /**
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
* @Description: 联锁详细信息历史数据表
|
|
|
* @Author: jeecg-boot
|
|
|
* @Date: 2024-05-30
|
|
@@ -68,10 +56,29 @@ public class InterlockDetailHistoryController extends JeecgController<InterlockD
|
|
|
@SuppressWarnings("all")
|
|
|
private InterlockDetailMapper interlockDetailMapper;
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置响应结果
|
|
|
+ *
|
|
|
+ * @param response 响应结果对象
|
|
|
+ * @param rawFileName 文件名
|
|
|
+ * @throws UnsupportedEncodingException 不支持编码异常
|
|
|
+ */
|
|
|
+ private void setExcelResponseProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException {
|
|
|
+ //设置内容类型
|
|
|
+// response.setContentType("application/vnd.vnd.ms-excel"); //xls
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); //xlsx
|
|
|
+ //设置编码格式
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ //设置导出文件名称(避免乱码)
|
|
|
+ String fileName = URLEncoder.encode(rawFileName.concat(".xlsx"), "UTF-8");
|
|
|
+ // 设置响应头
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@GetMapping(value = "/sdexportLS")
|
|
|
@ApiOperation("..............手动导出excel")
|
|
|
- public void downloadExcel(HttpServletRequest request, HttpServletResponse response, InterlockHistoryQueryDTO dto) {
|
|
|
+ public void downloadExcel(HttpServletResponse response, InterlockHistoryQueryDTO dto) {
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
@@ -88,17 +95,26 @@ public class InterlockDetailHistoryController extends JeecgController<InterlockD
|
|
|
}
|
|
|
|
|
|
// 设置响应头使浏览器能够下载文件
|
|
|
- response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
- response.setHeader("Content-Disposition", "attachment; filename="+fileName);
|
|
|
+ try {
|
|
|
+ this.setExcelResponseProp(response, fileName);
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
// 将Excel文件写入响应输出流
|
|
|
try {
|
|
|
workbook.write(response.getOutputStream());
|
|
|
- workbook.close();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
long duration = endTime - startTime;
|
|
|
String log = "手动导出Excel程序运行时间(毫秒):" + duration;
|