|
@@ -212,7 +212,7 @@ public class ApiController extends BaseController {
|
|
|
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("送经量明细导出" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("送经量明细导出" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
|
|
|
response.setContentType("application/octet-stream");
|
|
|
wb.write(outputStream);
|
|
|
outputStream.flush();
|
|
@@ -229,21 +229,35 @@ public class ApiController extends BaseController {
|
|
|
Object d = CacheUtils.get(Constants.IOT_TOKEN, Constants.INDEX_FORMULA_DETAIL);
|
|
|
if (d != null) {
|
|
|
List<FormulaDetail> list = (List<FormulaDetail>) d;
|
|
|
- List<FormulaDetail> yarnDList = list.stream().sorted(Comparator.comparing(FormulaDetail::getFormula_data_6)).collect(Collectors.toList());
|
|
|
- Map<String, List<FormulaDetail>> dMap = yarnDList.stream().collect(Collectors.groupingBy(FormulaDetail::getYarnD));
|
|
|
- List<FormulaDetail> yarnFList = list.stream().sorted(Comparator.comparing(FormulaDetail::getFormula_data_9)).collect(Collectors.toList());
|
|
|
- Map<String, List<FormulaDetail>> fMap = yarnFList.stream().collect(Collectors.groupingBy(FormulaDetail::getYarnF));
|
|
|
+ list.sort(Comparator.comparing(FormulaDetail::getFormula_data_4).thenComparing(FormulaDetail::getFormula_data_5).thenComparing(FormulaDetail::getFormula_data_6)
|
|
|
+ .thenComparing(FormulaDetail::getFormula_data_7).thenComparing(FormulaDetail::getFormula_data_8).thenComparing(FormulaDetail::getFormula_data_9)
|
|
|
+ .thenComparing(FormulaDetail::getFormula_data_15));
|
|
|
+ Map<String, List<FormulaDetail>> map = list.stream().collect(Collectors.groupingBy(FormulaDetail::getYarnD, LinkedHashMap::new, Collectors.toList()));
|
|
|
+
|
|
|
try (FileInputStream inputStream = new FileInputStream(yarnExcelTemplate); Workbook wb = new XSSFWorkbook(inputStream); OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
|
|
|
Sheet sheet = wb.getSheetAt(0);
|
|
|
AtomicInteger rowNum = new AtomicInteger(2);
|
|
|
CellStyle p2 = wb.createCellStyle();
|
|
|
p2.setDataFormat(wb.createDataFormat().getFormat("0.00"));
|
|
|
- //规格D
|
|
|
- combo(sheet, rowNum, p2, dMap, true);
|
|
|
- //规格F
|
|
|
- Sheet sheetF = wb.getSheetAt(1);
|
|
|
- rowNum = new AtomicInteger(2);
|
|
|
- combo(sheetF, rowNum, p2, fMap, false);
|
|
|
+ for (String s : map.keySet()) {
|
|
|
+ int sr = rowNum.get();
|
|
|
+ List<FormulaDetail> fList = map.get(s);
|
|
|
+ for (FormulaDetail detail : fList) {
|
|
|
+ Row row = sheet.createRow(rowNum.get());
|
|
|
+ Cell[] cells = new Cell[39];
|
|
|
+ for (int i = 0; i < cells.length; i++) {
|
|
|
+ cells[i] = row.createCell(i);
|
|
|
+ }
|
|
|
+ detail.setYarnCells(cells, p2);
|
|
|
+ rowNum.getAndIncrement();
|
|
|
+ }
|
|
|
+ if (fList.size() > 1) {
|
|
|
+ int er = sr + fList.size() - 1;
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(sr, er, 0, 0));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(sr, er, 1, 1));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(sr, er, 2, 2));
|
|
|
+ }
|
|
|
+ }
|
|
|
// 清空response
|
|
|
response.reset();
|
|
|
// 设置response的Header
|
|
@@ -251,7 +265,7 @@ public class ApiController extends BaseController {
|
|
|
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("纱线规格导出" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("纱线规格导出" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
|
|
|
response.setContentType("application/octet-stream");
|
|
|
wb.write(outputStream);
|
|
|
outputStream.flush();
|
|
@@ -262,29 +276,7 @@ public class ApiController extends BaseController {
|
|
|
}
|
|
|
|
|
|
private void combo(Sheet sheet, AtomicInteger rowNum, CellStyle p2, Map<String, List<FormulaDetail>> map, boolean flag) {
|
|
|
- for (String s : map.keySet()) {
|
|
|
- int sr = rowNum.get();
|
|
|
- List<FormulaDetail> list = map.get(s);
|
|
|
- for (FormulaDetail detail : list) {
|
|
|
- Row row = sheet.createRow(rowNum.get());
|
|
|
- Cell[] cells = new Cell[39];
|
|
|
- for (int i = 0; i < cells.length; i++) {
|
|
|
- cells[i] = row.createCell(i);
|
|
|
- }
|
|
|
- if (flag) {
|
|
|
- detail.setYarnDCells(cells, p2);
|
|
|
- } else {
|
|
|
- detail.setYarnFCells(cells, p2);
|
|
|
- }
|
|
|
- rowNum.getAndIncrement();
|
|
|
- }
|
|
|
- if (list.size() > 1) {
|
|
|
- int er = sr + list.size() - 1;
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(sr, er, 0, 0));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(sr, er, 1, 1));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(sr, er, 2, 2));
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -368,7 +360,7 @@ public class ApiController extends BaseController {
|
|
|
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("平方米克重明细导出" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("平方米克重明细导出" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
|
|
|
response.setContentType("application/octet-stream");
|
|
|
wb.write(outputStream);
|
|
|
outputStream.flush();
|
|
@@ -434,7 +426,7 @@ public class ApiController extends BaseController {
|
|
|
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("毛高" + height + "设备明细导出" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("毛高" + height + "设备明细导出" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
|
|
|
response.setContentType("application/octet-stream");
|
|
|
wb.write(outputStream);
|
|
|
outputStream.flush();
|
|
@@ -485,7 +477,7 @@ public class ApiController extends BaseController {
|
|
|
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("最近7天产量统计" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("最近7天产量统计" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
|
|
|
response.setContentType("application/octet-stream");
|
|
|
wb.write(outputStream);
|
|
|
outputStream.flush();
|
|
@@ -581,7 +573,7 @@ public class ApiController extends BaseController {
|
|
|
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("停机分析" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("停机分析" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
|
|
|
response.setContentType("application/octet-stream");
|
|
|
wb.write(outputStream);
|
|
|
outputStream.flush();
|
|
@@ -689,7 +681,7 @@ public class ApiController extends BaseController {
|
|
|
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(stopStr[type - 1] + "分析" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(stopStr[type - 1] + "分析" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
|
|
|
response.setContentType("application/octet-stream");
|
|
|
wb.write(outputStream);
|
|
|
outputStream.flush();
|
|
@@ -756,7 +748,7 @@ public class ApiController extends BaseController {
|
|
|
//Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存
|
|
|
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
|
|
|
// filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("告警统计" + System.currentTimeMillis() + ".xlsx", "UTF-8"));
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("告警统计" + DateUtils.dateTimeNow() + ".xlsx", "UTF-8"));
|
|
|
response.setContentType("application/octet-stream");
|
|
|
wb.write(outputStream);
|
|
|
outputStream.flush();
|