代码更新

This commit is contained in:
2022-11-24 16:51:02 +08:00
parent c1caf24ad7
commit f180bf27bb
2 changed files with 62 additions and 44 deletions

View File

@@ -373,6 +373,13 @@
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
</dependency>
<!--访问共享文件-->
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
</dependency>
</dependencies>
<distributionManagement>

View File

@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import jcifs.smb.SmbFile;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
@@ -45,58 +46,65 @@ public class PrintServiceImpl implements PrintService {
public JSONObject customerPrint(JSONObject whereJson) {
JSONObject jo = new JSONObject();
String box_no = whereJson.getString("box_no");
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);
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("未查询到木箱相关信息!");
}
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 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 = "";
//入库日期
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");
}
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;
// 生成txt文件
String filePath = "smb://10.1.3.21" + "/LMSPrinter" + "外包标签.txt";
FileWriter fw = null;
try {
File file = new File(filePath);
/* File file = new File(filePath);
if (!file.exists()) {
// 判断此文件是否存在 不存在则创建 存在则覆盖
file.createNewFile();
}*/
SmbFile file = new SmbFile(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");
@@ -119,15 +127,18 @@ public class PrintServiceImpl implements PrintService {
bw.close();
} catch (Exception e) {
jo.put("message", "打印失败!"+e.getMessage());
jo.put("message", "打印失败!" + e.getMessage());
return jo;
} finally {
try {
fw.close();
} catch (Exception e) {
jo.put("message", "打印失败!"+e.getMessage());
jo.put("message", "打印失败!" + e.getMessage());
}
}
jo.put("message", "打印成功!");
return jo;
}
}