Browse Source

提交

master
汪菘 2 years ago
parent
commit
63f0c8de15
  1. 4
      nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/HaiLiangLabelingDeviceDriver.java
  2. 200
      nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java
  3. 2
      nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderdetailServiceImpl.java
  4. 2
      nladmin-system/src/main/java/org/nl/acs/order/service/impl/Test.java
  5. BIN
      nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls

4
nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/HaiLiangLabelingDeviceDriver.java

@ -229,6 +229,10 @@ public class HaiLiangLabelingDeviceDriver extends AbstractOpcDeviceDriver implem
last_order = order; last_order = order;
last_order_detail = order_detail; last_order_detail = order_detail;
last_detail_qty = detail_qty; last_detail_qty = detail_qty;
last_one_qty = one_qty;
last_labeling_index = labeling_index;
last_detail_qualified_qty = detail_qualified_qty;
detail_qty = last_detail_qty;
} }

200
nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java

@ -17,6 +17,8 @@ import com.spire.xls.Workbook;
import com.spire.xls.Worksheet; import com.spire.xls.Worksheet;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.config.AcsConfig;
import org.nl.acs.config.server.AcsConfigService;
import org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk.HaiLiangFeedingTrunkDeviceDriver; import org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk.HaiLiangFeedingTrunkDeviceDriver;
import org.nl.acs.device_driver.hailiang.hailiang_labeling.HaiLiangLabelingDeviceDriver; import org.nl.acs.device_driver.hailiang.hailiang_labeling.HaiLiangLabelingDeviceDriver;
import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppService;
@ -65,6 +67,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
@Autowired @Autowired
ProduceshiftorderdetailService produceshiftorderdetailService; ProduceshiftorderdetailService produceshiftorderdetailService;
@Autowired
AcsConfigService acsConfigService;
@Override @Override
public void autoInitial() throws Exception { public void autoInitial() throws Exception {
this.reload(); this.reload();
@ -310,6 +315,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder");
JSONObject json = (JSONObject) JSONObject.toJSON(orderDto); JSONObject json = (JSONObject) JSONObject.toJSON(orderDto);
wo.insert(json); wo.insert(json);
this.reload();
} }
@Override @Override
@ -498,7 +504,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
iterator.remove(); iterator.remove();
} }
} }
if (!StrUtil.equals(entity.getOrder_id(), "07") && !StrUtil.equals(entity.getOrder_id(), "08") && !StrUtil.equals(entity.getOrder_id(), "09")) { if (!StrUtil.equals(entity.getOrder_status(), "07") && !StrUtil.equals(entity.getOrder_status(), "08") && !StrUtil.equals(entity.getOrder_status(), "09")) {
order.add(entity); order.add(entity);
} }
@ -539,9 +545,10 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
iterator.remove(); iterator.remove();
} }
} }
if (!StrUtil.equals(entity.getOrder_id(), "07") && !StrUtil.equals(entity.getOrder_id(), "08") && !StrUtil.equals(entity.getOrder_id(), "09")) { if (!StrUtil.equals(entity.getOrder_status(), "07") && !StrUtil.equals(entity.getOrder_status(), "08") && !StrUtil.equals(entity.getOrder_status(), "09")) {
order.add(entity); order.add(entity);
} }
produceshiftorderdetailService.reload();
} }
@Override @Override
@ -644,9 +651,10 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
jo.put("inspector",detaildto.getInspector()); jo.put("inspector",detaildto.getInspector());
jo.put("mg_weight",detaildto.getMg_weight()); jo.put("mg_weight",detaildto.getMg_weight());
//打印纸张大小 //打印纸张大小
//1cm = 118px jo.put("page_length","500");
jo.put("page_length",590); jo.put("page_height","400");
jo.put("page_height",472); jo.put("labeling_template",detaildto.getLabeling_template());
print(jo); print(jo);
} }
@ -1000,81 +1008,117 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
@Override @Override
public Boolean print(JSONObject whereJson) { public Boolean print(JSONObject whereJson) {
String order_id = whereJson.getString("order_id"); // String order_id = whereJson.getString("order_id");
String template_id = whereJson.getString("template_id"); // String template_id = whereJson.getString("template_id");
//
WQLObject mst = WQLObject.getWQLObject("acs_produceshiftorder"); // 主表 // WQLObject mst = WQLObject.getWQLObject("acs_produceshiftorder"); // 主表
//
// 1.根据明细找主表 // // 1.根据明细找主表
JSONObject jsonMst = mst.query("order_id = '" + order_id + "' and is_deleted ='0'").uniqueResult(0); // JSONObject jsonMst = mst.query("order_id = '" + order_id + "' and is_deleted ='0'").uniqueResult(0);
//
// 2.根据明细template_id 找到对应的模板 // // 2.根据明细template_id 找到对应的模板
JSONObject jsonStor = WQL.getWO("QPRODUCESHIFTORDER").addParam("flag", "3").addParam("storage_id", template_id).process().uniqueResult(0); // JSONObject jsonStor = WQL.getWO("QPRODUCESHIFTORDER").addParam("flag", "3").addParam("storage_id", template_id).process().uniqueResult(0);
//
// 3.创建模板工作簿 并指定储存路径 // // 3.创建模板工作簿 并指定储存路径
String path = jsonStor.getString("path"); // String path = jsonStor.getString("path");
String pathName = whereJson.getString("url"); // String pathName = whereJson.getString("url");
ExcelWriter workBook = EasyExcel.write(pathName).withTemplate(path).build(); // ExcelWriter workBook = EasyExcel.write(pathName).withTemplate(path).build();
// 获取第一个sheet // // 获取第一个sheet
WriteSheet sheet = EasyExcel.writerSheet().build(); // WriteSheet sheet = EasyExcel.writerSheet().build();
//
// 4.将主表当中的属性填充到excel当中 // // 4.将主表当中的属性填充到excel当中
HashMap<String, String> map = new HashMap<>(); // HashMap<String, String> map = new HashMap<>();
map.put("alloy",whereJson.getString("alloy")); // map.put("alloy",whereJson.getString("alloy"));
map.put("temper",whereJson.getString("temper")); // map.put("temper",whereJson.getString("temper"));
map.put("material_spec",whereJson.getString("material_spec")); // map.put("material_spec",whereJson.getString("material_spec"));
map.put("number",whereJson.getString("number")); // map.put("number",whereJson.getString("number"));
map.put("outer_diameter",whereJson.getString("outer_diameter")); // map.put("outer_diameter",whereJson.getString("outer_diameter"));
map.put("standard",whereJson.getString("standard")); // map.put("standard",whereJson.getString("standard"));
map.put("batch",whereJson.getString("batch")); // map.put("batch",whereJson.getString("batch"));
map.put("prod_date",whereJson.getString("prod_date")); // map.put("prod_date",whereJson.getString("prod_date"));
map.put("present_strap_pack_number",whereJson.getString("present_strap_pack_number")); // map.put("present_strap_pack_number",whereJson.getString("present_strap_pack_number"));
map.put("inspector",whereJson.getString("inspector")); // map.put("inspector",whereJson.getString("inspector"));
map.put("mg_weight",whereJson.getString("mg_weight")); // map.put("mg_weight",whereJson.getString("mg_weight"));
workBook.fill(map, sheet); // workBook.fill(map, sheet);
workBook.finish(); // workBook.finish();
// Book book=new Book();
Book book=new Book(); // Workbook loDoc = new Workbook();
Workbook loDoc = new Workbook(); // loDoc.loadFromFile(pathName);
loDoc.loadFromFile(pathName); // Worksheet worksheet = loDoc.getWorksheets().get(0);
Worksheet worksheet = loDoc.getWorksheets().get(0); // PageSetup pageSetup = worksheet.getPageSetup();
PageSetup pageSetup = worksheet.getPageSetup(); // String printArea="A2:B8";
String printArea="A2:B8"; // pageSetup.setPrintArea(printArea);
pageSetup.setPrintArea(printArea); // pageSetup.setLeftMargin(0);
pageSetup.setLeftMargin(0); // pageSetup.setRightMargin(0);
pageSetup.setRightMargin(0); // pageSetup.setTopMargin(0);
pageSetup.setTopMargin(0); // pageSetup.setBottomMargin(0);
pageSetup.setBottomMargin(0); // CellRange cellRanges = worksheet.getCellRange(printArea);
CellRange cellRanges = worksheet.getCellRange(printArea); // int height=0;
int height=0; // for (CellRange row : cellRanges.getRows()) {
for (CellRange row : cellRanges.getRows()) { // height+= worksheet.getRowHeightPixels(row.getRow());
height+= worksheet.getRowHeightPixels(row.getRow()); // }
} //
// int width=0;
int width=0; // for (CellRange column : cellRanges.getColumns()) {
for (CellRange column : cellRanges.getColumns()) { // width+=worksheet.getColumnWidthPixels(column.getColumn());
width+=worksheet.getColumnWidthPixels(column.getColumn()); // }
//
// PrinterJob loPrinterJob = PrinterJob.getPrinterJob();
// PageFormat loPageFormat = loPrinterJob.defaultPage();
// Paper loPaper = loPageFormat.getPaper();
//
// loPaper.setImageableArea(0, 0, loPageFormat.getWidth(), loPageFormat.getHeight());
//
// String page_height = whereJson.getString("page_height");
// String page_length = whereJson.getString("page_length");
//
// loPaper.setSize(Double.parseDouble(page_length),Double.parseDouble(page_height));
//// loPaper.setSize(width/96.0*72,height/96.0*72);
// loPageFormat.setPaper(loPaper);
// loPrinterJob.setCopies(1);
// loPrinterJob.setPrintable(loDoc, loPageFormat);
// book.append(loDoc,loPageFormat);
// loPrinterJob.setPageable(book);
// try {
// // 执行打印
// loPrinterJob.print();
// } catch (PrinterException e) {
// e.printStackTrace();
// return false;
// }
String url = acsConfigService.findConfigFromCache().get(AcsConfig.PRINTURL);
String printName = acsConfigService.findConfigFromCache().get(AcsConfig.PRINTNAME);
String labeling_template = whereJson.get("labeling_template").toString();
String alloy = whereJson.getString("alloy");
String temper = whereJson.getString("temper");
String material_spec =whereJson.getString("material_spec");
String number = whereJson.getString("number");
String outer_diameter= whereJson.getString("outer_diameter");
String standard = whereJson.getString("standard");
String batch = whereJson.getString("batch");
String prod_date = whereJson.getString("prod_date");
String present_strap_pack_number= whereJson.getString("present_strap_pack_number");
String inspector = whereJson.getString("inspector");
String mg_weight = whereJson.getString("mg_weight");
Process printProcess;
try
{
printProcess = Runtime
.getRuntime()
.exec(new String[] {
url,
"PrinterName=" + printName,
"LabelName=Label" + labeling_template + ".ct",
"alloy="+ alloy ,"temper="+temper,"size="+material_spec,"pcs="+number,"outer_diameter="+outer_diameter,
"standard="+standard, "batch="+batch,"prod_date="+prod_date,"present_strap_pack_number="+present_strap_pack_number,
"inspector="+inspector,"mg_weight="+mg_weight});
} }
catch (Exception e)
PrinterJob loPrinterJob = PrinterJob.getPrinterJob(); {
PageFormat loPageFormat = loPrinterJob.defaultPage();
Paper loPaper = loPageFormat.getPaper();
loPaper.setImageableArea(0, 0, loPageFormat.getWidth(), loPageFormat.getHeight());
loPaper.setSize(142,113);
// loPaper.setSize(width/96.0*72,height/96.0*72);
loPageFormat.setPaper(loPaper);
loPrinterJob.setCopies(1);
loPrinterJob.setPrintable(loDoc, loPageFormat);
book.append(loDoc,loPageFormat);
loPrinterJob.setPageable(book);
try {
// 执行打印
loPrinterJob.print();
} catch (PrinterException e) {
e.printStackTrace(); e.printStackTrace();
return false; System.out.println("aaa");
} }
return true; return true;
} }

2
nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderdetailServiceImpl.java

@ -206,7 +206,7 @@ public class ProduceshiftorderdetailServiceImpl implements Produceshiftorderdeta
} }
public synchronized void reload() { public synchronized void reload() {
this.detail = this.queryAllOrderDteail(" (order_detail_status != '05' and and order_detail_status != '06' and order_detail_status != '07') and is_deleted =0 order by order_detail_code"); this.detail = this.queryAllOrderDteail(" (order_detail_status != '05' and order_detail_status != '06' and order_detail_status != '07') and is_deleted =0 order by order_detail_code");
} }
@Override @Override

2
nladmin-system/src/main/java/org/nl/acs/order/service/impl/Test.java

@ -5,7 +5,7 @@ public class Test {
public static void main(String[] args) { public static void main(String[] args) {
Process printProcess; Process printProcess;
String printName ="PDF24"; String printName ="Zebra ZE500-4 RH (300 dpi)";
try try
{ {
printProcess = Runtime printProcess = Runtime

BIN
nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls

Binary file not shown.
Loading…
Cancel
Save