|
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.util.concurrent.Uninterruptibles; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.Setter; |
|
|
@ -32,6 +33,8 @@ import org.nl.acs.instruction.service.InstructionService; |
|
|
|
import org.nl.acs.monitor.DeviceStageMonitor; |
|
|
|
import org.nl.acs.route.service.RouteLineService; |
|
|
|
import org.nl.acs.route.service.dto.RouteLineDto; |
|
|
|
import org.nl.acs.task.enums.AgvSystemTypeEnum; |
|
|
|
import org.nl.acs.task.enums.InstTypeEnum; |
|
|
|
import org.nl.acs.task.enums.TaskStatusEnum; |
|
|
|
import org.nl.acs.task.enums.TaskTypeEnum; |
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
@ -46,6 +49,7 @@ import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.locks.Lock; |
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
|
|
|
|
@ -241,8 +245,14 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
|
|
|
|
@Override |
|
|
|
public void execute() { |
|
|
|
this.currentDeviceCode = this.getDevice().getDevice_code(); |
|
|
|
this.loadAssignData(currentDeviceCode, ItemProtocol.class); |
|
|
|
try { |
|
|
|
this.currentDeviceCode = this.getDevice().getDevice_code(); |
|
|
|
this.loadAssignData(currentDeviceCode, ItemProtocol.class); |
|
|
|
} catch (Exception e) { |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错,错误信息: " + e.getMessage())); |
|
|
|
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错,错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); |
|
|
|
Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void executeLogicBefore() { |
|
|
@ -253,7 +263,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
if (this.mode != this.lastMode) { |
|
|
|
this.requireSuccess = false; |
|
|
|
} |
|
|
|
if (!StrUtil.equals(this.barcode,this.lastBarcode) && this.isWithStationRequireSuccess()){ |
|
|
|
if (!StrUtil.equals(this.barcode, this.lastBarcode) && this.isWithStationRequireSuccess()) { |
|
|
|
this.requireSuccess = false; |
|
|
|
this.withStationRequireSuccess = false; |
|
|
|
} |
|
|
@ -296,9 +306,9 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
} |
|
|
|
|
|
|
|
//CTU取货申请满足条件
|
|
|
|
if (this.mode == 2 && this.status == 1 && this.move == 1 && this.action == 1 && this.reqTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqTakeInstCode) ){ |
|
|
|
if (this.mode == 2 && this.status == 1 && this.move == 1 && this.action == 1 && this.reqTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqTakeInstCode)) { |
|
|
|
Instruction instruction = instructionService.findByCodeFromCache(this.reqTakeInstCode); |
|
|
|
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_device_code(),this.currentDeviceCode)){ |
|
|
|
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_device_code(), this.currentDeviceCode)) { |
|
|
|
//调用CTU的取货申请通过接口
|
|
|
|
BoxApplyPassReq bapReq = BoxApplyPassReq.builder() |
|
|
|
.taskCode(this.reqTakeInstCode) |
|
|
@ -308,16 +318,16 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
// .data(bapReq)
|
|
|
|
// .build();
|
|
|
|
UnifiedResponse<String> unifiedResponse = acsToHkService.boxApplyPass(bapReq, String.class); |
|
|
|
if (unifiedResponse.isSuccess()){ |
|
|
|
if (unifiedResponse.isSuccess()) { |
|
|
|
this.reqTakeRequireSuccess = false; |
|
|
|
this.reqTakeInstCode = null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//CTU放货申请满足条件
|
|
|
|
if (this.mode == 2 && this.status == 1 && this.move == 0 && this.action == 1 && this.reqPutRequireSuccess && ObjectUtil.isNotEmpty(this.reqPutInstCode) ){ |
|
|
|
if (this.mode == 2 && this.status == 1 && this.move == 0 && this.action == 1 && this.reqPutRequireSuccess && ObjectUtil.isNotEmpty(this.reqPutInstCode)) { |
|
|
|
Instruction instruction = instructionService.findByCodeFromCache(this.reqPutInstCode); |
|
|
|
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_device_code(),this.currentDeviceCode)){ |
|
|
|
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_device_code(), this.currentDeviceCode)) { |
|
|
|
//调用CTU的放货申请通过接口
|
|
|
|
BoxApplyPassReq bapReq = BoxApplyPassReq.builder() |
|
|
|
.taskCode(this.reqPutInstCode) |
|
|
@ -327,7 +337,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
// .data(bapReq)
|
|
|
|
// .build();
|
|
|
|
UnifiedResponse<String> unifiedResponse = acsToHkService.boxApplyPass(bapReq, String.class); |
|
|
|
if (unifiedResponse.isSuccess()){ |
|
|
|
if (unifiedResponse.isSuccess()) { |
|
|
|
this.reqPutRequireSuccess = false; |
|
|
|
this.reqPutInstCode = null; |
|
|
|
} |
|
|
@ -527,7 +537,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
this.unExecutedMessage = "任务起点与当前设备号不一致,查找入库任务结束"; |
|
|
|
return; |
|
|
|
} |
|
|
|
if (StrUtil.equals(taskDto.getTask_type(), TaskTypeEnum.AGV_TASK.getCode()) || StrUtil.equals(taskDto.getTask_type(), TaskTypeEnum.CTU_TASK.getCode())){ |
|
|
|
if (StrUtil.equals(taskDto.getTask_type(), TaskTypeEnum.AGV_TASK.getCode()) || StrUtil.equals(taskDto.getTask_type(), TaskTypeEnum.CTU_TASK.getCode())) { |
|
|
|
this.unExecutedMessage = "查询到当前任务类型是AGV任务或CTU任务,查找入库任务结束"; |
|
|
|
return; |
|
|
|
} |
|
|
@ -567,7 +577,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
break; |
|
|
|
} else { |
|
|
|
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); |
|
|
|
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver){ |
|
|
|
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
assignedDto = deviceAssignedDto; |
|
|
|
break; |
|
|
|
} |
|
|
@ -576,7 +586,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
} else { |
|
|
|
assignedDto = assignedDtos.get(0); |
|
|
|
} |
|
|
|
if (ObjectUtil.isEmpty(assignedDto)){ |
|
|
|
if (ObjectUtil.isEmpty(assignedDto)) { |
|
|
|
this.unExecutedMessage = "未查询到可用平均分配, 查找入库任务结束"; |
|
|
|
} |
|
|
|
start_device_code = assignedDto.getDevice_code(); |
|
|
@ -696,7 +706,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
TaskDto taskDto = taskService.findReadyTaskByNextDeviceCode(deviceCode, checkoutStartDeviceCode); |
|
|
|
Instruction instDto = instructionService.findReadyInstByEnd(deviceCode); |
|
|
|
if (ObjectUtil.isNotEmpty(taskDto) && ObjectUtil.isEmpty(instDto)) { |
|
|
|
if (StrUtil.equals(taskDto.getTask_type(), TaskTypeEnum.AGV_TASK.getCode()) || StrUtil.equals(taskDto.getTask_type(), TaskTypeEnum.CTU_TASK.getCode())){ |
|
|
|
if (StrUtil.equals(taskDto.getTask_type(), TaskTypeEnum.AGV_TASK.getCode()) || StrUtil.equals(taskDto.getTask_type(), TaskTypeEnum.CTU_TASK.getCode())) { |
|
|
|
this.unExecutedMessage = "查询到当前任务类型是AGV任务或CTU任务,查找出库任务结束"; |
|
|
|
return; |
|
|
|
} |
|
|
@ -944,6 +954,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey()), Arrays.asList(inst.getInstruction_code(), address)); |
|
|
|
//this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey()), Arrays.asList(address));
|
|
|
|
// }
|
|
|
|
this.requireSuccess = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1054,6 +1065,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
instdto.setTask_id(taskDto.getTask_id()); |
|
|
|
instdto.setTask_code(taskDto.getTask_code()); |
|
|
|
instdto.setVehicle_code(taskDto.getVehicle_code()); |
|
|
|
instdto.setVehicle_type(taskDto.getVehicle_type()); |
|
|
|
String now = DateUtil.now(); |
|
|
|
instdto.setCreate_time(now); |
|
|
|
instdto.setCreate_by(SecurityUtils.getCurrentNickName()); |
|
|
@ -1065,6 +1077,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); |
|
|
|
instdto.setExecute_device_code(start_device_code); |
|
|
|
instdto.setInstruction_type(taskDto.getTask_type()); |
|
|
|
if (StrUtil.equals(next_device_code, "3101")) { |
|
|
|
instdto.setInstruction_type(InstTypeEnum.CTU_OUT_TASK.getCode()); |
|
|
|
instdto.setAgv_system_type(AgvSystemTypeEnum.HK_SYSTEM_TYPE.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void setInstruction(Instruction instdto, TaskDto taskDto, String start_device_code, String start_point_code, String next_device_code, String next_point_code) { |
|
|
@ -1077,6 +1093,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
instdto.setTask_id(taskDto.getTask_id()); |
|
|
|
instdto.setTask_code(taskDto.getTask_code()); |
|
|
|
instdto.setVehicle_code(taskDto.getVehicle_code()); |
|
|
|
instdto.setVehicle_type(taskDto.getVehicle_type()); |
|
|
|
String now = DateUtil.now(); |
|
|
|
instdto.setCreate_time(now); |
|
|
|
instdto.setCreate_by(SecurityUtils.getCurrentNickName()); |
|
|
@ -1088,6 +1105,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc |
|
|
|
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); |
|
|
|
instdto.setExecute_device_code(start_device_code); |
|
|
|
instdto.setInstruction_type(taskDto.getTask_type()); |
|
|
|
if (StrUtil.equals(next_device_code, "3101")) { |
|
|
|
instdto.setInstruction_type(InstTypeEnum.CTU_OUT_TASK.getCode()); |
|
|
|
instdto.setAgv_system_type(AgvSystemTypeEnum.HK_SYSTEM_TYPE.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|