|
|
@ -98,6 +98,9 @@ public class ExcelController { |
|
|
|
JSONArray headerJsonArray = JSONArray.parse(jsonObject.getString("ttsupplierrsheader")); |
|
|
|
JSONArray lineJsonArray = JSONArray.parse(jsonObject.getString("ttsupplierrsline")); |
|
|
|
List<String> fileNames = new ArrayList<>(); |
|
|
|
if(headerJsonArray == null) { |
|
|
|
return AjaxResult.error(HttpStatus.TTSUPPLIERRSHEADER_FAIL, "数据不存在ttsupplierrsheader"); |
|
|
|
} |
|
|
|
for(int i = 0; i < headerJsonArray.size(); i++) { |
|
|
|
JSONObject jsonObjectHeader = headerJsonArray.getJSONObject(i); |
|
|
|
String schmHeaderOrder = jsonObjectHeader.getString("schm_header_order"); |
|
|
@ -333,9 +336,11 @@ public class ExcelController { |
|
|
|
nextCell.setCellStyle(cellStyle7); |
|
|
|
} |
|
|
|
} |
|
|
|
// 合并单元格
|
|
|
|
CellRangeAddress cellRangeAddress3 = new CellRangeAddress(14, 14, firmArray.size() + 6, firmArray.size() + forecastArray.size() + 5); |
|
|
|
sheet.addMergedRegion(cellRangeAddress3); |
|
|
|
if (!forecastArray.isEmpty()) { |
|
|
|
// 合并单元格
|
|
|
|
CellRangeAddress cellRangeAddress3 = new CellRangeAddress(14, 14, firmArray.size() + 6, firmArray.size() + forecastArray.size() + 5); |
|
|
|
sheet.addMergedRegion(cellRangeAddress3); |
|
|
|
} |
|
|
|
inputStream.close(); |
|
|
|
FileOutputStream outputStream = new FileOutputStream(filePath + "/" + fileName); |
|
|
|
workbook.write(outputStream); |
|
|
@ -392,7 +397,7 @@ public class ExcelController { |
|
|
|
CellStyle cellStyle7 = getCellStyle(sheet, 16, 10);//Forecast数据样式
|
|
|
|
Row row14 = sheet.getRow(14); |
|
|
|
Row row15 = sheet.getRow(15); |
|
|
|
for(int i = 0; i < firmArray.size(); i++) { |
|
|
|
for (int i = 0; i < firmArray.size(); i++) { |
|
|
|
int cellIndex = 8 + i; |
|
|
|
JSONObject firm = firmArray.getJSONObject(i); |
|
|
|
//设置firm标题
|
|
|
@ -410,7 +415,7 @@ public class ExcelController { |
|
|
|
firmDateCell.setCellValue(firm.getString("schd_line_date")); |
|
|
|
firmDateCell.setCellStyle(cellStyle4); |
|
|
|
//设置每个firm订单数据
|
|
|
|
for(int count = 0; count < orderArray.size(); count++) { |
|
|
|
for (int count = 0; count < orderArray.size(); count++) { |
|
|
|
String cellValue = ""; |
|
|
|
JSONObject object = orderArray.getJSONObject(count); |
|
|
|
JSONObject order = firm.getJSONObject(object.getString("schd_line_line")); |
|
|
@ -419,13 +424,13 @@ public class ExcelController { |
|
|
|
if (nextCell == null) { |
|
|
|
nextCell = nextRow.createCell(cellIndex); |
|
|
|
} |
|
|
|
if(order != null) { |
|
|
|
if (order != null) { |
|
|
|
cellValue = order.getString("schd_line_qty"); |
|
|
|
} |
|
|
|
if(cellValue.equals("0")) { |
|
|
|
if (cellValue.equals("0")) { |
|
|
|
cellValue = ""; |
|
|
|
} |
|
|
|
if(!cellValue.isEmpty()) { |
|
|
|
if (!cellValue.isEmpty()) { |
|
|
|
nextCell.setCellValue(new BigDecimal(cellValue).intValue()); |
|
|
|
} else { |
|
|
|
nextCell.setCellValue(""); |
|
|
@ -434,7 +439,7 @@ public class ExcelController { |
|
|
|
} |
|
|
|
} |
|
|
|
//设置firm前的Pick Up Date 提货日期列
|
|
|
|
for(int count = 0; count < orderArray.size(); count++) { |
|
|
|
for (int count = 0; count < orderArray.size(); count++) { |
|
|
|
Row beforeRow = sheet.getRow(16 + count); |
|
|
|
Cell beforeCell = beforeRow.getCell(7); |
|
|
|
if (beforeCell == null) { |
|
|
@ -444,7 +449,7 @@ public class ExcelController { |
|
|
|
beforeCell.setCellStyle(cellStyle1); |
|
|
|
} |
|
|
|
//设置forecast前的Pick Up Date 提货日期列
|
|
|
|
for(int count = 0; count < orderArray.size() + 2; count++) { |
|
|
|
for (int count = 0; count < orderArray.size() + 2; count++) { |
|
|
|
int cellIndex = 8 + firmArray.size(); |
|
|
|
Row nextRow = sheet.getRow(14 + count); |
|
|
|
Cell nextCell = nextRow.getCell(cellIndex); |
|
|
@ -453,23 +458,23 @@ public class ExcelController { |
|
|
|
} |
|
|
|
nextCell.setCellValue(""); |
|
|
|
nextCell.setCellStyle(cellStyle2); |
|
|
|
if(count == 0) { |
|
|
|
if (count == 0) { |
|
|
|
nextCell.setCellValue("Pick Up Date 提货日期"); |
|
|
|
nextCell.setCellStyle(cellStyle2); |
|
|
|
} else if(count == 1) { |
|
|
|
} else if (count == 1) { |
|
|
|
nextCell.setCellValue("ETA " + jsonObjectHeader.getString("schm_header_arrive_us") + "\n到达" + jsonObjectHeader.getString("schm_header_arrive_ch") + "时间"); |
|
|
|
} else { |
|
|
|
nextCell.setCellValue(""); |
|
|
|
} |
|
|
|
} |
|
|
|
for(int i = 0; i < forecastArray.size(); i++) { |
|
|
|
for (int i = 0; i < forecastArray.size(); i++) { |
|
|
|
int cellIndex = 9 + firmArray.size() + i; |
|
|
|
//设置forecast标题
|
|
|
|
Cell forecastCell = row14.getCell(cellIndex); |
|
|
|
if (forecastCell == null) { |
|
|
|
forecastCell = row14.createCell(cellIndex); |
|
|
|
} |
|
|
|
if(i == 0) { |
|
|
|
if (i == 0) { |
|
|
|
forecastCell.setCellValue("forecast 预测"); |
|
|
|
} else { |
|
|
|
forecastCell.setCellValue(""); |
|
|
@ -484,22 +489,22 @@ public class ExcelController { |
|
|
|
forecastDateCell.setCellValue(forecast.getString("schd_line_date")); |
|
|
|
forecastDateCell.setCellStyle(cellStyle5); |
|
|
|
//设置forecast每个订单数据
|
|
|
|
for(int count = 0; count < orderArray.size(); count++) { |
|
|
|
for (int count = 0; count < orderArray.size(); count++) { |
|
|
|
String cellValue = ""; |
|
|
|
JSONObject object = orderArray.getJSONObject(count); |
|
|
|
JSONObject order = forecast.getJSONObject(object.getString("schd_line_line")); |
|
|
|
Row nextRow = sheet.getRow(16 + count); |
|
|
|
if(order != null) { |
|
|
|
if (order != null) { |
|
|
|
cellValue = order.getString("schd_line_qty"); |
|
|
|
} |
|
|
|
if(cellValue.equals("0")) { |
|
|
|
if (cellValue.equals("0")) { |
|
|
|
cellValue = ""; |
|
|
|
} |
|
|
|
Cell nextCell = nextRow.getCell(cellIndex); |
|
|
|
if (nextCell == null) { |
|
|
|
nextCell = nextRow.createCell(cellIndex); |
|
|
|
} |
|
|
|
if(!cellValue.isEmpty()) { |
|
|
|
if (!cellValue.isEmpty()) { |
|
|
|
nextCell.setCellValue(new BigDecimal(cellValue).intValue()); |
|
|
|
} else { |
|
|
|
nextCell.setCellValue(""); |
|
|
@ -507,9 +512,11 @@ public class ExcelController { |
|
|
|
nextCell.setCellStyle(cellStyle7); |
|
|
|
} |
|
|
|
} |
|
|
|
// 合并单元格
|
|
|
|
CellRangeAddress cellRangeAddress3 = new CellRangeAddress(14, 14, firmArray.size() + 9, firmArray.size() + forecastArray.size() + 8); |
|
|
|
sheet.addMergedRegion(cellRangeAddress3); |
|
|
|
if (!forecastArray.isEmpty()) { |
|
|
|
// 合并单元格
|
|
|
|
CellRangeAddress cellRangeAddress3 = new CellRangeAddress(14, 14, firmArray.size() + 9, firmArray.size() + forecastArray.size() + 8); |
|
|
|
sheet.addMergedRegion(cellRangeAddress3); |
|
|
|
} |
|
|
|
inputStream.close(); |
|
|
|
FileOutputStream outputStream = new FileOutputStream(filePath + "/" + fileName); |
|
|
|
workbook.write(outputStream); |
|
|
@ -696,6 +703,7 @@ public class ExcelController { |
|
|
|
private String fillGuowai2(String orderNo, JSONObject jsonObjectHeader, JSONArray orderArray, JSONArray firmArray, JSONArray forecastArray) throws IOException { |
|
|
|
ClassPathResource templateFile = new ClassPathResource("guowai2.xls"); |
|
|
|
String filePath = WinConfig.getUploadPath(); |
|
|
|
orderNo = orderNo.toUpperCase(); |
|
|
|
String fileName = orderNo + ".xls"; |
|
|
|
File file = new File(filePath); |
|
|
|
if (!file.exists()) { |
|
|
|