|
@@ -1,5 +1,6 @@
|
|
|
package com.jpsoft.printing.modules.base.controller;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.printing.modules.base.entity.Account;
|
|
|
import com.jpsoft.printing.modules.base.entity.Customer;
|
|
@@ -56,6 +57,8 @@ public class WorkController {
|
|
|
MessageResult<Work> msgResult = new MessageResult<>();
|
|
|
|
|
|
Work work = new Work();
|
|
|
+ work.setTagOperator("+");
|
|
|
+ work.setTagUnit("米");
|
|
|
|
|
|
msgResult.setData(work);
|
|
|
msgResult.setResult(true);
|
|
@@ -316,7 +319,7 @@ public class WorkController {
|
|
|
|
|
|
Map<String, Object> accMap = new HashMap<>();
|
|
|
accMap.put("sort", i+1);
|
|
|
- accMap.put("length", stock.getLength());
|
|
|
+ accMap.put("length", stock.getTagLength());
|
|
|
mapList.add(accMap);
|
|
|
}
|
|
|
|
|
@@ -324,6 +327,7 @@ public class WorkController {
|
|
|
map.put("number", work.getNumber());
|
|
|
map.put("name", work.getName());
|
|
|
map.put("width", work.getWidth());
|
|
|
+ map.put("colour", work.getColour());
|
|
|
map.put("list", mapList);
|
|
|
map.put("totalCount", stockList.size());
|
|
|
map.put("totalLength", totalLength);
|
|
@@ -356,69 +360,54 @@ public class WorkController {
|
|
|
Workbook wb = WorkbookFactory.create(resource.getInputStream());
|
|
|
|
|
|
//Excel
|
|
|
- Sheet sheet = wb.getSheetAt(0);
|
|
|
- //样式
|
|
|
- CellStyle style = wb.createCellStyle();
|
|
|
- style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
- Font font = wb.createFont();
|
|
|
- font.setFontHeightInPoints((short)10);
|
|
|
- style.setFont(font);
|
|
|
+ Sheet sheetTitle = wb.getSheetAt(0);
|
|
|
//数据
|
|
|
- Row rowTitle = sheet.getRow(1);
|
|
|
+ List<Map> list = (List<Map>)map.get("list");
|
|
|
+ Row rowTitle = sheetTitle.getRow(2);
|
|
|
rowTitle.getCell(0).setCellValue("客户:" + map.get("customer").toString());
|
|
|
- rowTitle.getCell(3).setCellValue("订单号:" + map.get("number").toString());
|
|
|
- rowTitle.getCell(6).setCellValue("品名:" + map.get("name").toString());
|
|
|
- rowTitle.getCell(9).setCellValue("幅宽:" + map.get("width").toString());
|
|
|
- int rowNum = 2;
|
|
|
+ rowTitle.getCell(4).setCellValue("订单号:" + map.get("number").toString());
|
|
|
+ rowTitle.getCell(9).setCellValue("品名:" + map.get("name").toString());
|
|
|
+ rowTitle.getCell(14).setCellValue("幅宽:" + map.get("width").toString());
|
|
|
+ rowTitle.getCell(18).setCellValue("单位:米");
|
|
|
+ int rowStart = 5;
|
|
|
+ //分页
|
|
|
+ int pageNum = (int)Math.ceil(list.size() / 200);
|
|
|
+ for(int i = 0; i < pageNum; i++) {
|
|
|
+ Sheet newSheet = wb.cloneSheet(0);
|
|
|
+ newSheet.setSelected(false);
|
|
|
+ wb.setSheetName(wb.getSheetIndex(newSheet), "sheet" + (i + 2));
|
|
|
+ }
|
|
|
|
|
|
- List<Map> list = (List<Map>)map.get("list");
|
|
|
- for(int i=0; i<list.size(); i++) {
|
|
|
+ BigDecimal colLenTotal = new BigDecimal(0);
|
|
|
+ BigDecimal pageLenTotal = new BigDecimal(0);
|
|
|
+ Integer pageSize = 0;
|
|
|
+ for(int i = 0; i < list.size(); i++) {
|
|
|
Map item = list.get(i);
|
|
|
+ int columnNum = (int)Math.floor((i % 200) / 20);
|
|
|
+ int rowNum = i % 20;
|
|
|
+
|
|
|
+ Sheet sheet = wb.getSheetAt((int)Math.floor(i / 200));
|
|
|
+ sheet.getRow(rowStart + rowNum).getCell(columnNum * 2).setCellValue(item.get("sort").toString());
|
|
|
+ sheet.getRow(rowStart + rowNum).getCell(columnNum * 2 + 1).setCellValue(item.get("length").toString());
|
|
|
|
|
|
- Row row = null;
|
|
|
- int remainder = i % 6;
|
|
|
- if(remainder == 0) {
|
|
|
- row = sheet.createRow(++rowNum);
|
|
|
+ colLenTotal = colLenTotal.add(Convert.toBigDecimal(item.get("length")));
|
|
|
+ pageLenTotal = pageLenTotal.add(Convert.toBigDecimal(item.get("length")));
|
|
|
+ pageSize++;
|
|
|
+
|
|
|
+ if((Integer)item.get("sort") % 20 == 0 || i + 1 == list.size()) {
|
|
|
+ sheet.getRow(3).getCell(columnNum * 2).setCellValue(map.get("colour").toString());
|
|
|
+ sheet.getRow(25).getCell(columnNum * 2).setCellValue(colLenTotal.toString());
|
|
|
+ colLenTotal = new BigDecimal(0);
|
|
|
}
|
|
|
- else {
|
|
|
- row = sheet.getRow(rowNum);
|
|
|
+
|
|
|
+ if((Integer)item.get("sort") % 200 == 0 || i + 1 == list.size()) {
|
|
|
+ sheet.getRow(27).getCell(0).setCellValue(pageSize.toString());
|
|
|
+ sheet.getRow(27).getCell(3).setCellValue(pageLenTotal.toString());
|
|
|
+ pageLenTotal = new BigDecimal(0);
|
|
|
+ pageSize = 0;
|
|
|
}
|
|
|
- row.createCell(remainder * 2).setCellValue(item.get("sort").toString());
|
|
|
- row.getCell(remainder * 2).setCellStyle(style);
|
|
|
- row.createCell(remainder * 2 + 1).setCellValue(item.get("length").toString());
|
|
|
- row.getCell(remainder * 2 + 1).setCellStyle(style);
|
|
|
}
|
|
|
|
|
|
- rowNum++;
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 1));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 2, 3));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 4, 5));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 6, 7));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 8, 11));
|
|
|
- Row rowBottom1 = sheet.createRow(rowNum);
|
|
|
- rowBottom1.createCell(0).setCellValue("件数");
|
|
|
- rowBottom1.getCell(0).setCellStyle(style);
|
|
|
- rowBottom1.createCell(2).setCellValue("米数");
|
|
|
- rowBottom1.getCell(2).setCellStyle(style);
|
|
|
- rowBottom1.createCell(4).setCellValue("单价");
|
|
|
- rowBottom1.getCell(4).setCellStyle(style);
|
|
|
- rowBottom1.createCell(6).setCellValue("金额");
|
|
|
- rowBottom1.getCell(6).setCellStyle(style);
|
|
|
- rowBottom1.createCell(8).setCellValue("作欠款凭证");
|
|
|
- rowBottom1.getCell(8).setCellStyle(style);
|
|
|
-
|
|
|
- rowNum++;
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 1));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 2, 3));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 4, 5));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 6, 7));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 8, 11));
|
|
|
- Row rowBottom2 = sheet.createRow(rowNum);
|
|
|
- rowBottom2.createCell(0).setCellValue(map.get("totalCount").toString());
|
|
|
- rowBottom2.getCell(0).setCellStyle(style);
|
|
|
- rowBottom2.createCell(2).setCellValue(map.get("totalLength").toString());
|
|
|
- rowBottom2.getCell(2).setCellStyle(style);
|
|
|
-
|
|
|
//保存到服务器,返回文件名
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|