From 9bf79e1dd9f0133e8e1191f8f627ceda7d49e642 Mon Sep 17 00:00:00 2001 From: liuchen864 <23082234@qq.com> Date: Tue, 21 May 2024 09:43:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=87=BA=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/base/ExcelController.java | 98 ++++++++++-------- win-admin/src/main/resources/guowai2.xls | Bin 75264 -> 75264 bytes 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/win-admin/src/main/java/com/win/web/controller/base/ExcelController.java b/win-admin/src/main/java/com/win/web/controller/base/ExcelController.java index b4d329a..7331459 100644 --- a/win-admin/src/main/java/com/win/web/controller/base/ExcelController.java +++ b/win-admin/src/main/java/com/win/web/controller/base/ExcelController.java @@ -82,7 +82,7 @@ public class ExcelController { qadAccessQueryWrapper.eq("domain",domain); QadAccess qadAccess = qadAccessService.getOne(qadAccessQueryWrapper); if(qadAccess == null) { - return AjaxResult.error(HttpStatus.QAD_ACCESS_ERROR,"QAD_ACCESS_ERROR"); + return AjaxResult.error(HttpStatus.QAD_ACCESS_ERROR,"QAD访问控制不存在"); } JSONArray jsonArray = new JSONArray(); JSONObject ttSearchCondition = new JSONObject(); @@ -106,35 +106,46 @@ public class ExcelController { for(int i = 0; i < headerJsonArray.size(); i++) { JSONObject jsonObjectHeader = headerJsonArray.getJSONObject(i); String schmHeaderOrder = jsonObjectHeader.getString("schm_header_order"); - TreeMap mainMap = new TreeMap<>(); + TreeMap firmOrderMap = new TreeMap<>(); + TreeMap forecastOrderMap = new TreeMap<>(); TreeMap firmMap = new TreeMap<>(); TreeMap forecastMap = new TreeMap<>(); - JSONArray orderArray = new JSONArray(); + JSONArray firmOrderArray = new JSONArray(); + JSONArray forecastOrderArray = new JSONArray(); JSONArray firmArray = new JSONArray(); JSONArray forecastArray = new JSONArray(); for(int j = 0; j < lineJsonArray.size(); j++) { JSONObject jsonObjectLine = lineJsonArray.getJSONObject(j); String schdLineOrder = jsonObjectLine.getString("schd_line_order"); int schdLineLine = jsonObjectLine.getIntValue("schd_line_line"); + String schdLineFcQual = jsonObjectLine.getString("schd_line_fc_qual"); if(schmHeaderOrder.equals(schdLineOrder)) { - JSONObject main = mainMap.get(schdLineLine); - if(main == null) { - main = new JSONObject(); - main.put("schd_line_line", schdLineLine); - main.put("schd_line_part", jsonObjectLine.getString("schd_line_part")); - main.put("schd_line_um", jsonObjectLine.getString("schd_line_um")); - main.put("schd_line_part_desc", jsonObjectLine.getString("schd_line_part_desc")); - main.put("schd_line_req_qty", jsonObjectLine.getIntValue("schd_line_req_qty")); - main.put("schd_line_cum_qty", jsonObjectLine.getIntValue("schd_line_cum_qty")); - main.put("schd_line_pcr_qty", jsonObjectLine.getIntValue("schd_line_pcr_qty")); + JSONObject order; + if ("F".equals(schdLineFcQual)) { + order = firmOrderMap.get(schdLineLine); + } else { + order = forecastOrderMap.get(schdLineLine); + } + if (order == null) { + order = new JSONObject(); + order.put("schd_line_line", schdLineLine); + order.put("schd_line_part", jsonObjectLine.getString("schd_line_part")); + order.put("schd_line_um", jsonObjectLine.getString("schd_line_um")); + order.put("schd_line_part_desc", jsonObjectLine.getString("schd_line_part_desc")); + order.put("schd_line_req_qty", jsonObjectLine.getIntValue("schd_line_req_qty")); + order.put("schd_line_cum_qty", jsonObjectLine.getIntValue("schd_line_cum_qty")); + order.put("schd_line_pcr_qty", jsonObjectLine.getIntValue("schd_line_pcr_qty")); + } + if ("F".equals(schdLineFcQual)) { + firmOrderMap.put(schdLineLine, order); + } else { + forecastOrderMap.put(schdLineLine, order); } - mainMap.put(schdLineLine, main); String schdLineDate = jsonObjectLine.getString("schd_line_date"); String schdLineDateDl = jsonObjectLine.getString("schd_line_date_dl"); String schdLineDateTh = jsonObjectLine.getString("schd_line_date_th"); - if(schdLineDate != null) { - String schdLineFcQual = jsonObjectLine.getString("schd_line_fc_qual"); - if("F".equals(schdLineFcQual)) { + if (schdLineDate != null) { + if ("F".equals(schdLineFcQual)) { JSONObject firm = firmMap.get(schdLineDate); if (firm == null) { firm = new JSONObject(); @@ -142,9 +153,9 @@ public class ExcelController { firm.put("schd_line_date_dl", schdLineDateDl); firm.put("schd_line_date_th", schdLineDateTh); } - JSONObject order = new JSONObject(); - order.put("schd_line_qty", jsonObjectLine.getString("schd_line_qty")); - firm.put(String.valueOf(schdLineLine), order); + JSONObject orderJsonObject = new JSONObject(); + orderJsonObject.put("schd_line_qty", jsonObjectLine.getString("schd_line_qty")); + firm.put(String.valueOf(schdLineLine), orderJsonObject); firmMap.put(schdLineDate, firm); } else { JSONObject forecast = forecastMap.get(schdLineDate); @@ -154,23 +165,27 @@ public class ExcelController { forecast.put("schd_line_date_dl", schdLineDateDl); forecast.put("schd_line_date_th", schdLineDateTh); } - JSONObject order = new JSONObject(); - order.put("schd_line_qty", jsonObjectLine.getString("schd_line_qty")); - forecast.put(String.valueOf(schdLineLine), order); + JSONObject orderJsonObject = new JSONObject(); + orderJsonObject.put("schd_line_qty", jsonObjectLine.getString("schd_line_qty")); + forecast.put(String.valueOf(schdLineLine), orderJsonObject); forecastMap.put(schdLineDate, forecast); } } } } - for(Integer mainKey : mainMap.keySet()) { - orderArray.add(mainMap.get(mainKey)); + for(Integer firmOrderKey : firmOrderMap.keySet()) { + firmOrderArray.add(firmOrderMap.get(firmOrderKey)); + } + for(Integer forecastOrderKey : forecastOrderMap.keySet()) { + forecastOrderArray.add(forecastOrderMap.get(forecastOrderKey)); } for(String firmKey : firmMap.keySet()) { JSONObject firm = firmMap.get(firmKey); + JSONObject forecast = forecastMap.get(firmKey); boolean isAllZero = false; - for(int count = 0; count < orderArray.size(); count++) { + for(int count = 0; count < firmOrderArray.size(); count++) { String cellValue = ""; - JSONObject object = orderArray.getJSONObject(count); + JSONObject object = firmOrderArray.getJSONObject(count); JSONObject order = firm.getJSONObject(object.getString("schd_line_line")); if(order != null) { cellValue = order.getString("schd_line_qty"); @@ -186,9 +201,9 @@ public class ExcelController { for(String forecastKey : forecastMap.keySet()) { JSONObject forecast = forecastMap.get(forecastKey); boolean isAllZero = false; - for(int count = 0; count < orderArray.size(); count++) { + for(int count = 0; count < forecastOrderArray.size(); count++) { String cellValue = ""; - JSONObject object = orderArray.getJSONObject(count); + JSONObject object = forecastOrderArray.getJSONObject(count); JSONObject order = forecast.getJSONObject(object.getString("schd_line_line")); if(order != null) { cellValue = order.getString("schd_line_qty"); @@ -202,13 +217,13 @@ public class ExcelController { } } if("changchun".equals(type)) {//长春模板 - fileNames.add(fillChangchun(orderNo, jsonObjectHeader, orderArray, firmArray, forecastArray)); + fileNames.add(fillChangchun(orderNo, jsonObjectHeader, firmOrderArray, firmArray, forecastArray)); } else if("foshan".equals(type)) { - fileNames.add(fillFoshanQingdao(orderNo, jsonObjectHeader, orderArray, firmArray, forecastArray)); + fileNames.add(fillFoshanQingdao(orderNo, jsonObjectHeader, firmOrderArray, firmArray, forecastArray)); } else if("guowai1".equals(type)) { - fileNames.add(fillGuowai1(orderNo, jsonObjectHeader, orderArray, firmArray, forecastArray)); + fileNames.add(fillGuowai1(orderNo, jsonObjectHeader, firmOrderArray, firmArray, forecastArray)); } else if("guowai2".equals(type)) { - fileNames.add(fillGuowai2(orderNo, jsonObjectHeader, orderArray, firmArray, forecastArray)); + fileNames.add(fillGuowai2(orderNo, jsonObjectHeader, firmOrderArray, forecastOrderArray, firmArray, forecastArray)); } } return AjaxResult.success(fileNames); @@ -726,13 +741,14 @@ public class ExcelController { * 横财国外格式excel * @param orderNo 订单号 * @param jsonObjectHeader 头部信息 - * @param orderArray 订单数据 + * @param firmOrderArray firm订单数据 + * @param forecastOrderArray forecast订单数据 * @param firmArray firm数据 * @param forecastArray forecast数据 * @return 生成文件的路径 * @throws IOException io异常 */ - private String fillGuowai2(String orderNo, JSONObject jsonObjectHeader, JSONArray orderArray, JSONArray firmArray, JSONArray forecastArray) throws IOException { + private String fillGuowai2(String orderNo, JSONObject jsonObjectHeader, JSONArray firmOrderArray, JSONArray forecastOrderArray, JSONArray firmArray, JSONArray forecastArray) throws IOException { ClassPathResource templateFile = new ClassPathResource("guowai2.xls"); String filePath = WinConfig.getUploadPath(); orderNo = orderNo.toUpperCase(); @@ -756,9 +772,9 @@ public class ExcelController { //基础数据 excelWriter.fill(jsonObjectHeader, writeSheet2); //firmOrder数据 - excelWriter.fill(new FillWrapper("order", orderArray), fillConfig, writeSheet1); + excelWriter.fill(new FillWrapper("order", firmOrderArray), fillConfig, writeSheet1); //forecast - excelWriter.fill(new FillWrapper("order", orderArray), fillConfig, writeSheet2); + excelWriter.fill(new FillWrapper("order", forecastOrderArray), fillConfig, writeSheet2); } finally { if (excelWriter != null) { excelWriter.finish(); @@ -806,9 +822,9 @@ public class ExcelController { firmCell.setCellValue(orderNo); firmCell.setCellStyle(cellStyle2); //设置每个firm订单数据 - for(int count = 0; count < orderArray.size(); count++) { + for(int count = 0; count < firmOrderArray.size(); count++) { String cellValue = ""; - JSONObject object = orderArray.getJSONObject(count); + JSONObject object = firmOrderArray.getJSONObject(count); JSONObject order = firm.getJSONObject(object.getString("schd_line_line")); Row nextRow = sheet.getRow(19 + count); Cell nextCell = nextRow.getCell(cellIndex); @@ -870,9 +886,9 @@ public class ExcelController { forecastCell.setCellValue("forecast"); forecastCell.setCellStyle(cellStyleForecast2); //设置forecast每个订单数据 - for(int count = 0; count < orderArray.size(); count++) { + for(int count = 0; count < forecastOrderArray.size(); count++) { String cellValue = ""; - JSONObject object = orderArray.getJSONObject(count); + JSONObject object = forecastOrderArray.getJSONObject(count); JSONObject order = forecast.getJSONObject(object.getString("schd_line_line")); Row nextRow = sheetForecast.getRow(18 + count); if(order != null) { diff --git a/win-admin/src/main/resources/guowai2.xls b/win-admin/src/main/resources/guowai2.xls index 1aad2e555df984b18f4237c3bd7c821e6d593efe..fffda3035755bd2a8a71227e144120220c3b712e 100644 GIT binary patch delta 360 zcmZoT!_shuWrLcjgx!1wAmCENiAw+5Ma19+0Hana~?w)2S^$Mm>BpO z7(R4>Icy&?fHb2H0|O6`=AL}OGK0xfq$)82A`i7#tZUzxpc&=JG?h+W#P20SGteU!5dKu@I1J$8a5}DTR@NA%H;x z1Shlq@8DqpTO$Ar8Wxtxv;U_~T5L3h@fbV1M*XT=jLcgvGV1eBFHm7*+s-7w_)Uay L()OP!jO>g6GD%qy delta 414 zcmXAlUnoOy6vw~6-Mh=i?yf&c$vlv@@<46(iJ6j=zYms(l7@tr)gHWPVOo+_KY3YU zlEMq!!h^I2$-_!*NhwdXN6FJLmviU*>YRS(d_U*g?-x#q;gopV=&4qBK~aLP+2F!d zU?3Qn3PzwH&AlGKYa7$W#`r%>umkVm!bN(Ypvs&E3Rrp4Gt6sLAFJeJYMUt(*W#)) z-g2@6l+wI=6*!`L93{OOSY8KSB*4D`oRb6F1SYM(ftKbmn`QJ4aNh%}HkbHrW)*xU z-9uSRhbX%;{jv=NgTY2el6WMuD1CeZxx6-?xO8e)c_)*XOjgJc(LsB%KK}OOsFzSj zPbjnqM|;)>yxP}(Ea+4qCLLyoyh{JqQNutf_6j=Ubkfnrq@xc4_v%ZvhDAB)yg=`> z?~&|w7%+$?B0Knl9xWA!XY`#41c9GrTzqxEb&K5=jSO8MJ~82fm9bx$$M)Ul3d>cp Ln~To|R>b}QfKq4@