This commit is contained in:
2023-03-16 13:58:27 +08:00
parent 6a2c853e8e
commit 83af221f02
2 changed files with 107 additions and 16 deletions

View File

@@ -29,6 +29,8 @@ public class ItemProtocol {
public static String item_barcode_length = "barcode_length"; public static String item_barcode_length = "barcode_length";
//条码 //条码
public static String item_barcode = "barcode"; public static String item_barcode = "barcode";
//重量
public static String item_weight = "weight";
//下发命令 //下发命令
@@ -66,6 +68,9 @@ public class ItemProtocol {
public int getMove() { public int getMove() {
return this.getOpcIntegerValue(item_move); return this.getOpcIntegerValue(item_move);
} }
public int getWeight() {
return this.getOpcIntegerValue(item_weight);
}
public int getCarrier_direction() { public int getCarrier_direction() {
return this.getOpcIntegerValue(item_carrier_direction); return this.getOpcIntegerValue(item_carrier_direction);
@@ -126,6 +131,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_task, "任务号", "DB101.D260")); list.add(new ItemDto(item_task, "任务号", "DB101.D260"));
list.add(new ItemDto(item_barcode_length, "条码长度", "DB101.B800")); list.add(new ItemDto(item_barcode_length, "条码长度", "DB101.B800"));
list.add(new ItemDto(item_barcode, "条码", "DB101.STRING802.50")); list.add(new ItemDto(item_barcode, "条码", "DB101.STRING802.50"));
list.add(new ItemDto(item_weight, "重量", "DB101.D702"));
return list; return list;
} }

View File

@@ -18,6 +18,8 @@ import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.ScannerDeviceDriver; import org.nl.acs.device_driver.ScannerDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.instruction.service.dto.Instruction;
@@ -72,6 +74,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
protected String barcode = null; protected String barcode = null;
protected String formatcode = null; protected String formatcode = null;
private Date require_apply_labeling_time = new Date();
private Date instruction_require_time = new Date(); private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date(); private Date instruction_finished_time = new Date();
private Date instruction_apply_time = new Date(); private Date instruction_apply_time = new Date();
@@ -84,6 +87,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
int action = 0; int action = 0;
int error = 0; int error = 0;
int task = 0; int task = 0;
int weight = 0;
int to_task = 0; int to_task = 0;
String plcbarcode = null; String plcbarcode = null;
String last_plcbarcode = null; String last_plcbarcode = null;
@@ -101,6 +105,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
int last_move = 0; int last_move = 0;
int last_error = 0; int last_error = 0;
int last_task = 0; int last_task = 0;
int last_weight = 0;
String last_container; String last_container;
String inst_message; String inst_message;
String device_code; String device_code;
@@ -195,6 +200,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
plcbarcode = this.itemProtocol.getplcBarCode(); plcbarcode = this.itemProtocol.getplcBarCode();
plcbarcode_length = this.itemProtocol.getBarCode_length(); plcbarcode_length = this.itemProtocol.getBarCode_length();
to_task = this.itemProtocol.getTotTask(); to_task = this.itemProtocol.getTotTask();
weight = this.itemProtocol.getWeight();
if (mode != last_mode) { if (mode != last_mode) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode +"复位请求标记"); logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode +"复位请求标记");
if(mode == 2){ if(mode == 2){
@@ -225,6 +231,9 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
if (task != last_task) { if (task != last_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task+ "->" + task); logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task+ "->" + task);
} }
if (weight != last_weight) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号weight" + last_weight+ "->" + weight);
}
if (mode == 2 && move != 0 && task > 0) { if (mode == 2 && move != 0 && task > 0) {
//inst_message //inst_message
inst = instructionService.findByCodeFromCache(String.valueOf(task)); inst = instructionService.findByCodeFromCache(String.valueOf(task));
@@ -287,6 +296,25 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
if (move > 0 && !StrUtil.isEmpty(newBarcode) && !applySucess) { if (move > 0 && !StrUtil.isEmpty(newBarcode) && !applySucess) {
instruction_apply(newBarcode.trim()); instruction_apply(newBarcode.trim());
} }
break;
case 5:
String newBarcodes = null;
//申请任务
if(!StrUtil.isEmpty(barcode())){
newBarcodes = barcode();
} else {
//
if(plcbarcode_length>2){
newBarcodes = plcbarcode;
} else {
break;
}
}
// 申请贴标
if (move > 0 && !StrUtil.isEmpty(newBarcodes) && !requireSucess) {
applyLabeling(newBarcodes);
}
break;
} }
switch (flag) { switch (flag) {
//取货完成 //取货完成
@@ -306,6 +334,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
last_task = task; last_task = task;
last_plcbarcode_length = plcbarcode_length; last_plcbarcode_length = plcbarcode_length;
last_plcbarcode = plcbarcode; last_plcbarcode = plcbarcode;
last_weight = weight;
} }
public boolean exe_error() { public boolean exe_error() {
@@ -337,22 +366,6 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
map3.put("code","to_command"); map3.put("code","to_command");
map3.put("value","0"); map3.put("value","0");
list.add(map3); list.add(map3);
Map map4 = new HashMap();
map4.put("code","to_strap_times");
map4.put("value","0");
list.add(map4);
Map map5 = new HashMap();
map5.put("code","to_length");
map5.put("value","0");
list.add(map5);
Map map6 = new HashMap();
map6.put("code","to_weight");
map6.put("value","0");
list.add(map6);
Map map7 = new HashMap();
map7.put("code","to_height");
map7.put("value","0");
list.add(map7);
this.writing(list); this.writing(list);
message = null; message = null;
} }
@@ -798,6 +811,78 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
} }
// 申请贴标
public synchronized void applyLabeling(String newBarcodes) {
Date date = new Date();
if (date.getTime() - this.require_apply_labeling_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_apply_labeling_time = date;
// String vehicle_code = "";
if (weight == 0) {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备重量:" + weight + "异常");
message = "申请贴标电气设备重量:" + weight + "异常";
throw new RuntimeException("重量为空!");
}
// if (task > 0) {
// Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
// if (ObjectUtil.isEmpty(instruction)) {
// instruction = instructionService.findByCode(String.valueOf(task));
// }
// vehicle_code = instruction.getVehicle_code();
// } else {
// logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常");
// message = "申请贴标电气设备任务号:" + task + "异常";
// throw new RuntimeException("任务号为空!");
// }
if (StrUtil.isEmpty(newBarcodes)) {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备载具号为空!");
message = "申请贴标电气设备载具号为空";
throw new RuntimeException("载具号为空!");
}
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
new ApplyLabelingAndBindingRequest();
JSONObject device_json =
WQLObject.getWQLObject("acs_storage_cell")
.query("storage_code ='" + this.device_code + "'")
.uniqueResult(0);
String start_point_code = null;
if (!ObjectUtil.isEmpty(device_json)) {
start_point_code =
(String) device_json.get("parent_storage_code") == null
? this.device_code
: (String) device_json.get("parent_storage_code");
}
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
applyLabelingAndBindingRequest.setType("1");
applyLabelingAndBindingRequest.setVehicle_code(newBarcodes);
applyLabelingAndBindingRequest.setWeight(String.valueOf((float) weight / 100));
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse =
acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,请求参数:"+JSON.toJSONString(applyLabelingAndBindingRequest));
if (applyLabelingAndBindingResponse.getstatus() == 200) {
message = "申请贴标成功";
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", "5");
list.add(map);
this.writing(list);
this.writing(list);
message = "申请贴标下发电气信号成功";
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:"+JSON.toJSONString(applyLabelingAndBindingResponse));
requireSucess = true;
} else {
message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:"+JSON.toJSONString(applyLabelingAndBindingResponse));
}
}
}
public void writing(List list) { public void writing(List list) {
Map<String, Object> itemMap = new HashMap<String, Object>(); Map<String, Object> itemMap = new HashMap<String, Object>();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {