From 3c5e788c490a6b41f6b41a4435173d798edee4c1 Mon Sep 17 00:00:00 2001 From: liuxy Date: Thu, 24 Nov 2022 15:53:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pda/st/service/impl/PrintServiceImpl.java | 144 ++++++++++-------- 1 file changed, 82 insertions(+), 62 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java index 2c841bef7..1323d4a52 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java @@ -17,6 +17,10 @@ import org.nl.wms.st.inbill.service.CheckOutBillService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; + /** * @author liuxy * @description 服务实现 @@ -39,69 +43,85 @@ public class PrintServiceImpl implements PrintService { @Override public JSONObject customerPrint(JSONObject whereJson) { - String box_no = whereJson.getString("box_no"); - - JSONObject box_jo = WQL.getWO("PDA_ST_01").addParam("flag","5").addParam("box_no",box_no).process().uniqueResult(0); - - if (ObjectUtil.isEmpty(box_jo)){ - throw new BadRequestException("未查询到木箱相关信息!"); - } - - //组织木箱打印信息 - //箱号 - String package_box_sn = box_jo.getString("package_box_sn"); - //订单号 - String sale_order_name = box_jo.getString("sale_order_name"); - //品名 - String product_description = box_jo.getString("product_description"); - //物料号 - String product_name = box_jo.getString("product_name"); - //规格 - String width = box_jo.getString("width"); - //批号 - String pcsn = ""; - - //入库日期 - String date_of_FG_inbound = box_jo.getString("date_of_FG_inbound"); - //毛重 - String box_weight = box_jo.getString("box_weight"); - //生产日期 - String date_of_production = box_jo.getString("date_of_production"); - //卷数 - String quanlity_in_box = box_jo.getString("quanlity_in_box"); - //保质期 - String quality_guaran_period = box_jo.getString("quality_guaran_period"); - //检验员 - String nspector = ""; - //储存条件 - String storage_conditions = ""; - - double weight = 0; - JSONArray rows = WQL.getWO("PDA_ST_01").addParam("flag","5").addParam("box_no",box_no).process().getResultJSONArray(0); - for (int i = 0; i < rows.size(); i++) { - JSONObject row= rows.getJSONObject(i); - weight += row.getDoubleValue("net_weight"); - } - - //净重 - - JSONObject print_info = new JSONObject(); - print_info.put("package_box_sn",package_box_sn); - print_info.put("sale_order_name",sale_order_name); - print_info.put("product_description",product_description); - print_info.put("product_name",product_name); - print_info.put("width",width); - print_info.put("pcsn",pcsn); - print_info.put("sum_net_weight",weight); - print_info.put("date_of_FG_inbound",date_of_FG_inbound); - print_info.put("box_weight",box_weight); - print_info.put("date_of_production",date_of_production); - print_info.put("quanlity_in_box",quanlity_in_box); - print_info.put("quality_guaran_period",quality_guaran_period); - print_info.put("nspector",nspector); - print_info.put("storage_conditions",storage_conditions); - JSONObject jo = new JSONObject(); + + try { + String box_no = whereJson.getString("box_no"); + + JSONObject box_jo = WQL.getWO("PDA_ST_01").addParam("flag", "5").addParam("box_no", box_no).process().uniqueResult(0); + + if (ObjectUtil.isEmpty(box_jo)) { + throw new BadRequestException("未查询到木箱相关信息!"); + } + + //组织木箱打印信息 + //箱号 + String package_box_sn = box_jo.getString("package_box_sn"); + //订单号 + String sale_order_name = box_jo.getString("sale_order_name"); + //品名 + String product_description = box_jo.getString("product_description"); + //物料号 + String product_name = box_jo.getString("product_name"); + //规格 + String width = box_jo.getString("width"); + //批号 + String pcsn = ""; + + //入库日期 + String date_of_FG_inbound = box_jo.getString("date_of_FG_inbound"); + //毛重 + String box_weight = box_jo.getString("box_weight"); + //生产日期 + String date_of_production = box_jo.getString("date_of_production"); + //卷数 + String quanlity_in_box = box_jo.getString("quanlity_in_box"); + //保质期 + String quality_guaran_period = box_jo.getString("quality_guaran_period"); + //检验员 + String nspector = ""; + //储存条件 + String storage_conditions = ""; + + double weight = 0; + JSONArray rows = WQL.getWO("PDA_ST_01").addParam("flag", "5").addParam("box_no", box_no).process().getResultJSONArray(0); + for (int i = 0; i < rows.size(); i++) { + JSONObject row = rows.getJSONObject(i); + weight += row.getDoubleValue("net_weight"); + } + + // 生成txt文件 + String filePath = "\\\\10.1.3.21" + "\\LMSPrinter" + "外包标签.txt"; + FileWriter fw = null; + + File file = new File(filePath); + if (!file.exists()) { + file.createNewFile(); + } + fw = new FileWriter(filePath); + BufferedWriter bw = new BufferedWriter(fw); + bw.write("package_box_sn,sale_order_name,product_description,product_name,width,pcsn,date_of_FG_inbound,box_weight,date_of_production,quanlity_in_box,quality_guaran_period,nspector,storage_conditions,weight\n"); + + bw.write(package_box_sn + "," + + sale_order_name + "," + + product_description + "," + + product_name + "," + + width + "," + + pcsn + "," + + date_of_FG_inbound + "," + + box_weight + "," + + date_of_production + "," + + quanlity_in_box + "," + + quality_guaran_period + "," + + nspector + "," + + storage_conditions + "," + + weight + ",\n" + ); + + bw.close(); + } catch (Exception e) { + jo.put("message", "打印失败!"+e.getMessage()); + } jo.put("message", "打印成功!"); return jo; }