|
|
@ -232,17 +232,18 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
} else { |
|
|
|
this.createOutInstruction(this.currentDeviceCode); |
|
|
|
} |
|
|
|
} else if (this.mode == 6 && move > 0 && !requireSuccess) { |
|
|
|
//向上位申请任务
|
|
|
|
this.applyInTask(); |
|
|
|
} else if (this.mode == 2 && this.move > 0 && StrUtil.isEmpty(this.barcode) && !requireSuccess) { |
|
|
|
//下发输送线指令信息
|
|
|
|
this.distribute(); |
|
|
|
} else if (this.mode == 6 && move > 0 && !requireSuccess) { |
|
|
|
//向上位申请任务
|
|
|
|
this.applyInTask(); |
|
|
|
} else if (this.mode == 7 && this.move > 0 && StrUtil.isNotEmpty(this.barcode) && !requireSuccess) { |
|
|
|
this.applyAgvTask(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isTimeValid(long currentTimeMillis) { |
|
|
|
return currentTimeMillis - this.requireTime >= this.requireTimeOut; |
|
|
|
} |
|
|
@ -267,6 +268,41 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 扫码申请AGV任务 |
|
|
|
*/ |
|
|
|
private void applyAgvTask() { |
|
|
|
long currentTimeMillis = System.currentTimeMillis(); |
|
|
|
if (!isTimeValid(currentTimeMillis)) { |
|
|
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); |
|
|
|
} else { |
|
|
|
this.requireTime = currentTimeMillis; |
|
|
|
JSONObject requestParam = new JSONObject(); |
|
|
|
requestParam.put("device_code1", this.currentDeviceCode); |
|
|
|
requestParam.put("type", RequestTypeEnum.APPLY_IN_TASK.getType()); |
|
|
|
requestParam.put("barcode1", this.barcode); |
|
|
|
UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam); |
|
|
|
if (response.isSuccess()) { |
|
|
|
this.requireSuccess = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 自动申请AGV任务 |
|
|
|
* |
|
|
|
* @param barcode |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private UnifiedResponse<JSONObject> applyAgvTask(String barcode) { |
|
|
|
JSONObject requestParam = new JSONObject(); |
|
|
|
requestParam.put("device_code1", this.currentDeviceCode); |
|
|
|
requestParam.put("type", RequestTypeEnum.APPLY_IN_TASK.getType()); |
|
|
|
requestParam.put("barcode1", barcode); |
|
|
|
return acsToWmsService.applyTaskToWms(requestParam); |
|
|
|
} |
|
|
|
|
|
|
|
public void createInInstruction() { |
|
|
|
long currentTimeMillis = System.currentTimeMillis(); |
|
|
|
if (!isTimeValid(currentTimeMillis)) { |
|
|
@ -497,6 +533,13 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
instructionService.update(instruction); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "指令号:" + instruction.getInstruction_code() + ", 修改指令状态为 -> " + InstructionStatusEnum.BUSY.getName())); |
|
|
|
} else if ((InstructionStatusEnum.BUSY.getIndex().equals(instruction.getInstruction_status()) || InstructionStatusEnum.READY.getIndex().equals(instruction.getInstruction_status())) && this.currentDeviceCode.equals(instruction.getNext_device_code())) { |
|
|
|
Boolean applyTaskFlag = Optional.ofNullable(this.getExtraValue().get("applyTask")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); |
|
|
|
if (applyTaskFlag) { |
|
|
|
UnifiedResponse<JSONObject> response = this.applyAgvTask(instruction.getVehicle_code()); |
|
|
|
if (!response.isSuccess()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
instruction.setInstruction_status(InstructionStatusEnum.FINISHED.getIndex()); |
|
|
|
instruction.setExecute_device_code(this.currentDeviceCode); |
|
|
|
instructionService.finish(instruction); |
|
|
|