This commit is contained in:
2023-03-23 15:03:58 +08:00
parent 5a93095845
commit 74445eaf7d

View File

@@ -148,7 +148,8 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
scanner.cleanBarcode(); scanner.cleanBarcode();
logServer.deviceExecuteLog(this.device_code, "", "", "清理条码"); logServer.deviceExecuteLog(this.device_code, "", "", "清理条码");
} }
public synchronized boolean finish_instruction(){
public synchronized boolean finish_instruction() {
try { try {
instructionService.finish(inst); instructionService.finish(inst);
} catch (Exception e) { } catch (Exception e) {
@@ -189,7 +190,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
@Override @Override
public void execute(){ public void execute() {
try { try {
device_code = this.getDeviceCode(); device_code = this.getDeviceCode();
heartbeat = this.itemProtocol.getHeartbeat(); heartbeat = this.itemProtocol.getHeartbeat();
@@ -197,13 +198,13 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
move = this.itemProtocol.getMove(); move = this.itemProtocol.getMove();
error = this.itemProtocol.getError(); error = this.itemProtocol.getError();
task = this.itemProtocol.getTask(); task = this.itemProtocol.getTask();
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(); 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) {
this.setRequireSucess(false); this.setRequireSucess(false);
this.setApplySucess(false); this.setApplySucess(false);
message = null; message = null;
@@ -224,15 +225,15 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
if (plcbarcode_length != last_plcbarcode_length) { if (plcbarcode_length != last_plcbarcode_length) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号plcbarcode_length" + last_plcbarcode_length + "->" + plcbarcode_length); logServer.deviceExecuteLog(this.device_code, "", "", "信号plcbarcode_length" + last_plcbarcode_length + "->" + plcbarcode_length);
} }
if (!StrUtil.equals(plcbarcode,last_plcbarcode) ) { if (!StrUtil.equals(plcbarcode, last_plcbarcode)) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号plcbarcode" + last_plcbarcode + "->" + plcbarcode); logServer.deviceExecuteLog(this.device_code, "", "", "信号plcbarcode" + last_plcbarcode + "->" + plcbarcode);
} }
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) { if (weight != last_weight) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号weight" + last_weight+ "->" + 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
@@ -266,7 +267,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
} else { } else {
this.setIsonline(true); this.setIsonline(true);
this.setIserror(false); this.setIserror(false);
if(error>0){ if (error > 0) {
this.setIserror(true); this.setIserror(true);
} }
Instruction instruction = null; Instruction instruction = null;
@@ -279,11 +280,11 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
//申请任务 //申请任务
String newBarcode = null; String newBarcode = null;
if(!StrUtil.isEmpty(barcode())){ if (!StrUtil.isEmpty(barcode())) {
newBarcode = barcode(); newBarcode = barcode();
} else { } else {
// //
if(plcbarcode_length>2){ if (plcbarcode_length > 2) {
newBarcode = plcbarcode; newBarcode = plcbarcode;
} else { } else {
break; break;
@@ -300,11 +301,11 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
case 5: case 5:
String newBarcodes = null; String newBarcodes = null;
//申请任务 //申请任务
if(!StrUtil.isEmpty(barcode())){ if (!StrUtil.isEmpty(barcode())) {
newBarcodes = barcode(); newBarcodes = barcode();
} else { } else {
// //
if(plcbarcode_length>2){ if (plcbarcode_length > 2) {
newBarcodes = plcbarcode; newBarcodes = plcbarcode;
} else { } else {
break; break;
@@ -355,16 +356,16 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
this.set_last_container(container); this.set_last_container(container);
List list = new ArrayList(); List list = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","0"); map.put("value", "0");
list.add(map); list.add(map);
Map map2 = new HashMap(); Map map2 = new HashMap();
map2.put("code","to_task"); map2.put("code", "to_task");
map2.put("value","0"); map2.put("value", "0");
list.add(map2); list.add(map2);
Map map3 = new HashMap(); Map map3 = new HashMap();
map3.put("code","to_command"); map3.put("code", "to_command");
map3.put("value","0"); map3.put("value", "0");
list.add(map3); list.add(map3);
this.writing(list); this.writing(list);
message = null; message = null;
@@ -439,7 +440,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
return instruction_require(container_code, WcsConfig.task_container_type_default_desc); return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
} }
public synchronized boolean instruction_apply(String container_code) { public synchronized boolean instruction_apply(String container_code) {
Date date = new Date(); Date date = new Date();
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
@@ -448,44 +449,45 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
this.instruction_apply_time = date; this.instruction_apply_time = date;
//container_code //container_code
TaskDto task = taskserver.findByContainer(container_code); TaskDto task = taskserver.findByContainer(container_code);
logServer.deviceExecuteLog(device_code, "", "", "申请任务时,根据托盘号:" + container_code + ",查询出来得任务信息是:" + JSON.toJSONString(task));
if (!ObjectUtil.isEmpty(task)) { if (!ObjectUtil.isEmpty(task)) {
Instruction instdto = instructionService.findByTaskcodeAndStatus(task.getTask_code()); Instruction instdto = instructionService.findByTaskcodeAndStatus(task.getTask_code());
if(!StrUtil.equals(instdto.getStart_device_code(),this.device_code)){ if (!StrUtil.equals(instdto.getStart_device_code(), this.device_code)) {
message ="当前载具号"+container_code+"查找对应指令起点与当前设备不符"; message = "当前载具号" + container_code + "查找对应指令起点与当前设备不符";
// this.setIserror(true); // this.setIserror(true);
return false; return false;
} }
if(ObjectUtil.isNotEmpty(instdto)){ if (ObjectUtil.isNotEmpty(instdto)) {
List list = new ArrayList(); List list = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
if(StrUtil.isNotEmpty(task.getTo_z())){ if (StrUtil.isNotEmpty(task.getTo_z())) {
if(StrUtil.equals(task.getTo_z(),"01")){ if (StrUtil.equals(task.getTo_z(), "01")) {
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","102"); map.put("value", "102");
} else if(StrUtil.equals(task.getTo_z(),"02")){ } else if (StrUtil.equals(task.getTo_z(), "02")) {
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","201"); map.put("value", "201");
} else if(StrUtil.equals(task.getTo_z(),"03")){ } else if (StrUtil.equals(task.getTo_z(), "03")) {
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","301"); map.put("value", "301");
} }
} }
list.add(map); list.add(map);
Map map2 = new HashMap(); Map map2 = new HashMap();
map2.put("code","to_task"); map2.put("code", "to_task");
map2.put("value",instdto.getInstruction_code()); map2.put("value", instdto.getInstruction_code());
list.add(map2); list.add(map2);
Map map3 = new HashMap(); Map map3 = new HashMap();
map3.put("code","to_command"); map3.put("code", "to_command");
map3.put("value","1"); map3.put("value", "1");
list.add(map3); list.add(map3);
this.writing(list); this.writing(list);
message = "下发电气任务号成功"; message = "下发电气任务号成功";
requireSucess = true; requireSucess = true;
applySucess = true; applySucess = true;
} else { } else {
message = "任务号:"+ task.getTask_code()+"未找到指令"; message = "任务号:" + task.getTask_code() + "未找到指令";
} }
} else { } else {
@@ -498,6 +500,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
/** /**
* 请求指令 * 请求指令
* 定点任务时请求这里 * 定点任务时请求这里
*
* @param container_code * @param container_code
* @param container_type * @param container_type
*/ */
@@ -510,15 +513,16 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
this.instruction_require_time = date; this.instruction_require_time = date;
//container_code //container_code
TaskDto taskdto = taskserver.findByContainer(container_code); TaskDto taskdto = taskserver.findByContainer(container_code);
logServer.deviceExecuteLog(device_code, "", "", "申请任务时,根据托盘号:" + container_code + ",查询出来得任务信息是:" + JSON.toJSONString(taskdto));
if (!ObjectUtil.isEmpty(taskdto)) { if (!ObjectUtil.isEmpty(taskdto)) {
if (!ObjectUtils.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) { if (!ObjectUtils.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) {
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号"+container_code logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code
+"已存在对应任务,不再请求"); + "已存在对应任务,不再请求");
Instruction instdto = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); Instruction instdto = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code());
if(!StrUtil.equals(instdto.getStart_device_code(),this.device_code)){ if (!StrUtil.equals(instdto.getStart_device_code(), this.device_code)) {
message ="当前载具号"+container_code+"查找对应指令起点与当前设备不符"; message = "当前载具号" + container_code + "查找对应指令起点与当前设备不符";
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务" logServer.deviceExecuteLog(this.device_code, "", "", "申请任务"
+"当前载具号"+container_code+"查找对应指令起点与当前设备不符"); + "当前载具号" + container_code + "查找对应指令起点与当前设备不符");
return false; return false;
} }
this.setIserror(false); this.setIserror(false);
@@ -549,8 +553,8 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
list.add(map3); list.add(map3);
this.writing(list); this.writing(list);
message = "下发电气任务号成功"; message = "下发电气任务号成功";
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号"+container_code logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code
+"已存在对应任务,下发电气信号"); + "已存在对应任务,下发电气信号");
requireSucess = true; requireSucess = true;
applySucess = true; applySucess = true;
} else { } else {
@@ -559,10 +563,10 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
return true; return true;
} else { } else {
//需要判断指令中的指令 再次请求不能生成 //需要判断指令中的指令 再次请求不能生成
if (!ObjectUtils.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code(),"1"))) { if (!ObjectUtils.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code(), "1"))) {
{ {
Instruction instdto = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code(),"1"); Instruction instdto = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code(), "1");
if(to_task != Integer.parseInt(instdto.getInstruction_code())){ if (to_task != Integer.parseInt(instdto.getInstruction_code())) {
List list = new ArrayList(); List list = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
if (StrUtil.isNotEmpty(taskdto.getTo_z())) { if (StrUtil.isNotEmpty(taskdto.getTo_z())) {
@@ -653,8 +657,8 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
next_point_code = next_device_code; next_point_code = next_device_code;
} }
if(!StrUtil.equals(taskdto.getStart_device_code(),this.device_code)){ if (!StrUtil.equals(taskdto.getStart_device_code(), this.device_code)) {
message ="当前载具号"+container_code+"查找对应指令起点与当前设备不符"; message = "当前载具号" + container_code + "查找对应指令起点与当前设备不符";
// List list = new ArrayList(); // List list = new ArrayList();
// Map map = new HashMap(); // Map map = new HashMap();
// map.put("code","to_target"); // map.put("code","to_target");
@@ -695,8 +699,8 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
instructionService.create(instdto); instructionService.create(instdto);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("指令创建失败!",e.getMessage()); log.error("指令创建失败!", e.getMessage());
return false; return false;
} }
//创建指令后修改任务状态 //创建指令后修改任务状态
taskdto.setTask_status("1"); taskdto.setTask_status("1");
@@ -706,26 +710,26 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
List list = new ArrayList(); List list = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
if(StrUtil.isNotEmpty(taskdto.getTo_z())){ if (StrUtil.isNotEmpty(taskdto.getTo_z())) {
if(StrUtil.equals(taskdto.getTo_z(),"01")){ if (StrUtil.equals(taskdto.getTo_z(), "01")) {
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","102"); map.put("value", "102");
} else if(StrUtil.equals(taskdto.getTo_z(),"02")){ } else if (StrUtil.equals(taskdto.getTo_z(), "02")) {
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","201"); map.put("value", "201");
} else if(StrUtil.equals(taskdto.getTo_z(),"03")){ } else if (StrUtil.equals(taskdto.getTo_z(), "03")) {
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","301"); map.put("value", "301");
} }
} }
list.add(map); list.add(map);
Map map2 = new HashMap(); Map map2 = new HashMap();
map2.put("code","to_task"); map2.put("code", "to_task");
map2.put("value",instdto.getInstruction_code()); map2.put("value", instdto.getInstruction_code());
list.add(map2); list.add(map2);
Map map3 = new HashMap(); Map map3 = new HashMap();
map3.put("code","to_command"); map3.put("code", "to_command");
map3.put("value","1"); map3.put("value", "1");
list.add(map3); list.add(map3);
this.writing(list); this.writing(list);
// if(task != Integer.parseInt(instdto.getInstruction_code()) ){ // if(task != Integer.parseInt(instdto.getInstruction_code()) ){
@@ -740,24 +744,24 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
JSONObject apply = new JSONObject(); JSONObject apply = new JSONObject();
apply.put("vehicle_code", container_code); apply.put("vehicle_code", container_code);
apply.put("device_code", device_code); apply.put("device_code", device_code);
apply.put("type","1"); apply.put("type", "1");
logServer.deviceExecuteLog(this.device_code, "", "", "申请入库,请求参数:"+apply.toString()); logServer.deviceExecuteLog(this.device_code, "", "", "申请入库,请求参数:" + apply.toString());
String str = acsToWmsService.applyTaskToWms(apply); String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str); JSONObject jo = JSON.parseObject(str);
logServer.deviceExecuteLog(this.device_code, "", "", "申请入库,返回参数:"+jo.toString()); logServer.deviceExecuteLog(this.device_code, "", "", "申请入库,返回参数:" + jo.toString());
if (ObjectUtil.isEmpty(jo)) { if (ObjectUtil.isEmpty(jo)) {
message = "接口不通"; message = "接口不通";
List list = new ArrayList(); List list = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","1011"); map.put("value", "1011");
list.add(map); list.add(map);
Map map2 = new HashMap(); Map map2 = new HashMap();
map2.put("code","to_command"); map2.put("code", "to_command");
map2.put("value","1"); map2.put("value", "1");
Map map3 = new HashMap(); Map map3 = new HashMap();
map3.put("code","to_task"); map3.put("code", "to_task");
map3.put("value","0"); map3.put("value", "0");
list.add(map3); list.add(map3);
this.writing(list); this.writing(list);
requireSucess = true; requireSucess = true;
@@ -769,25 +773,25 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
requireSucess = true; requireSucess = true;
applySucess = false; applySucess = false;
} else { } else {
if (jo.get("message")!=null){ if (jo.get("message") != null) {
message = jo.get("message").toString(); message = jo.get("message").toString();
} }
List list = new ArrayList(); List list = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
map.put("code","to_target"); map.put("code", "to_target");
map.put("value","1011"); map.put("value", "1011");
list.add(map); list.add(map);
Map map2 = new HashMap(); Map map2 = new HashMap();
map2.put("code","to_command"); map2.put("code", "to_command");
map2.put("value","1"); map2.put("value", "1");
list.add(map2); list.add(map2);
Map map3 = new HashMap(); Map map3 = new HashMap();
map3.put("code","to_task"); map3.put("code", "to_task");
map3.put("value","0"); map3.put("value", "0");
list.add(map3); list.add(map3);
this.writing(list); this.writing(list);
message = "申请任务失败下发退回,"+message; message = "申请任务失败下发退回," + message;
requireSucess = true; requireSucess = true;
} }
@@ -861,7 +865,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
applyLabelingAndBindingRequest.setWeight(String.valueOf((float) weight / 100)); applyLabelingAndBindingRequest.setWeight(String.valueOf((float) weight / 100));
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse =
acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,请求参数:"+JSON.toJSONString(applyLabelingAndBindingRequest)); logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,请求参数:" + JSON.toJSONString(applyLabelingAndBindingRequest));
if (applyLabelingAndBindingResponse.getstatus() == 200) { if (applyLabelingAndBindingResponse.getstatus() == 200) {
message = "申请贴标成功"; message = "申请贴标成功";
@@ -873,11 +877,11 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
this.writing(list); this.writing(list);
this.writing(list); this.writing(list);
message = "申请贴标下发电气信号成功"; message = "申请贴标下发电气信号成功";
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:"+JSON.toJSONString(applyLabelingAndBindingResponse)); logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:" + JSON.toJSONString(applyLabelingAndBindingResponse));
requireSucess = true; requireSucess = true;
} else { } else {
message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage(); message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:"+JSON.toJSONString(applyLabelingAndBindingResponse)); logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:" + JSON.toJSONString(applyLabelingAndBindingResponse));
} }
} }