代码更新
This commit is contained in:
@@ -17,6 +17,7 @@ import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.pda.mps.service.impl.BakingServiceImpl;
|
||||
import org.nl.wms.pda.st.service.PrintService;
|
||||
import org.nl.wms.pda.st.service.impl.PrintServiceImpl;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.nl.wms.sch.tasks.CutConveyorTask;
|
||||
import org.nl.wms.sch.tasks.EmptyVehicleTask;
|
||||
@@ -409,6 +410,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
public JSONObject deviceApply(JSONObject whereJson) {
|
||||
log.info("deviceApply请求参数:---------------------------------------------"+whereJson.toString());
|
||||
String vehicle_code = whereJson.getString("vehicle_code");
|
||||
String weight = whereJson.getString("weight");
|
||||
String type = whereJson.getString("type");
|
||||
if (StrUtil.isEmpty(type)) {
|
||||
throw new BadRequestException("任务类型不能为空!");
|
||||
@@ -422,6 +424,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
if (StrUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("木箱码不能为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(weight)) {
|
||||
throw new BadRequestException("重量不能为空!");
|
||||
}
|
||||
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + vehicle_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sub_jo)) {
|
||||
throw new BadRequestException("未查询到该木箱对应的包装关系!");
|
||||
@@ -447,7 +452,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
JSONObject print_jo = new JSONObject();
|
||||
print_jo.put("box_no", vehicle_code);
|
||||
print_jo.put("print_type", print_info.getString("print_id"));
|
||||
printService.customerPrint(print_jo);
|
||||
print_jo.put("box_weight", weight);
|
||||
new PrintServiceImpl().customerPrint2(print_jo);
|
||||
} else if (type.equals("2")) {
|
||||
if (StrUtil.isEmpty(vehicle_code)) {
|
||||
throw new BadRequestException("木箱码不能为空!");
|
||||
|
||||
@@ -24,6 +24,13 @@ public interface PrintService {
|
||||
*/
|
||||
JSONObject customerPrint(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 获取单据类型
|
||||
* @param whereJson /
|
||||
* @return JSONObject /
|
||||
*/
|
||||
JSONObject customerPrint2(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 获取单据类型
|
||||
* @param whereJson /
|
||||
|
||||
@@ -171,6 +171,136 @@ public class PrintServiceImpl implements PrintService {
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject customerPrint2(JSONObject whereJson) {
|
||||
JSONObject jo = new JSONObject();
|
||||
WQLObject printTab = WQLObject.getWQLObject("pdm_bi_printinfo");
|
||||
WQLObject custTab = WQLObject.getWQLObject("md_cs_customerbase");
|
||||
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
|
||||
|
||||
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 package_box_sn1 = "";
|
||||
String package_box_sn2 = "";
|
||||
try {
|
||||
// 木箱1
|
||||
package_box_sn1 = package_box_sn.substring(0,package_box_sn.indexOf("@")+1);
|
||||
// 木箱2
|
||||
package_box_sn2 = package_box_sn.substring(package_box_sn.indexOf("@") + 1, package_box_sn.length());
|
||||
} catch (Exception e) {
|
||||
package_box_sn2 = 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("thickness_request")+"*"+box_jo.getString("width_standard");
|
||||
|
||||
//入库日期:取此箱子中最晚的入库日期
|
||||
JSONObject jsonInbound= subTab.query("package_box_sn = '" + box_no + "' order by date_of_fg_inbound DESC").uniqueResult(0);
|
||||
String date_of_FG_inbound = jsonInbound.getString("date_of_fg_inbound");
|
||||
//毛重
|
||||
String box_weight = NumberUtil.round(whereJson.getString("box_weight"),2).toString();
|
||||
//生产日期:取此箱子中最晚的生产日期
|
||||
JSONObject jsonProduction = subTab.query("package_box_sn = '" + box_no + "' order by date_of_production DESC").uniqueResult(0);
|
||||
String date_of_production = jsonProduction.getString("date_of_production");
|
||||
//批号
|
||||
String pcsn = jsonProduction.getString("date_of_production");
|
||||
if (ObjectUtil.isNotEmpty(pcsn)) {
|
||||
pcsn = pcsn.replaceAll("[[\\s-:punct:]]", "");
|
||||
}
|
||||
//卷数
|
||||
String quanlity_in_box = box_jo.getString("quanlity_in_box");
|
||||
//保质期
|
||||
String quality_guaran_period = box_jo.getString("quality_guaran_period");
|
||||
//检验员
|
||||
String nspector = "1";
|
||||
//储存条件
|
||||
String storage_conditions = "";
|
||||
|
||||
// 根据客户条件选择对应模板
|
||||
JSONObject jsonCust = custTab.query("cust_code = '" + box_jo.getString("customer_name") + "' and is_delete = '0' and is_used = '1'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonCust)) throw new BadRequestException("客户不存在或未启用");
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonCust.getString("bz_print_no"))) throw new BadRequestException("请先设置客户打印模板");
|
||||
String bz_print_no = jsonCust.getString("bz_print_no");
|
||||
|
||||
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文件
|
||||
JSONObject jsonPrint = printTab.query("print_id = '" + whereJson.getString("print_type") + "'").uniqueResult(0);
|
||||
//10.1.3.21/LMSPrinter/
|
||||
String filePath = jsonPrint.getString("print_route")+ "外包标签.txt";
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
fw = new FileWriter(filePath);
|
||||
OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(file), "utf-8");
|
||||
BufferedWriter bw = new BufferedWriter(write);
|
||||
bw.write("bz_print_no,package_box_sn1,package_box_sn2,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,customer_name,customer_description,thickness,mass_per_unit_area,length,box_type,sap_pcsn,box_length,box_width,box_high\n");
|
||||
|
||||
bw.write(bz_print_no + ","
|
||||
+package_box_sn1 + ","
|
||||
+ package_box_sn2 + ","
|
||||
+ sale_order_name + ","
|
||||
+ product_description + ","
|
||||
+ product_name + ","
|
||||
+ width + ","
|
||||
+ pcsn + ","
|
||||
+ date_of_FG_inbound + ","
|
||||
+ box_weight + "KG,"
|
||||
+ date_of_production + ","
|
||||
+ quanlity_in_box + ","
|
||||
+ quality_guaran_period + ","
|
||||
+ nspector + ","
|
||||
+ storage_conditions + ","
|
||||
+ NumberUtil.round(weight,2).toString() + "KG,"
|
||||
+ box_jo.getString("customer_name") + ","
|
||||
+ box_jo.getString("customer_description") + ","
|
||||
+ box_jo.getString("thickness") + ","
|
||||
+ box_jo.getString("mass_per_unit_area") + ","
|
||||
+ box_jo.getString("length") + ","
|
||||
+ box_jo.getString("box_type") + ","
|
||||
+ box_jo.getString("sap_pcsn") + ","
|
||||
+ box_jo.getString("box_length") + ","
|
||||
+ box_jo.getString("box_width") + ","
|
||||
+ box_jo.getString("box_high") + "\n"
|
||||
);
|
||||
|
||||
bw.close();
|
||||
jo.put("message", "打印成功!");
|
||||
} catch (Exception e) {
|
||||
jo.put("message", "打印失败!"+e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (Exception e) {
|
||||
jo.put("message", "打印失败!"+e.getMessage());
|
||||
}
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject printType(JSONObject whereJson){
|
||||
JSONArray rows = WQL.getWO("PDA_ST_01").addParam("flag","6").process().getResultJSONArray(0);
|
||||
|
||||
Reference in New Issue
Block a user