diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/DoubleStationStackerDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/DoubleStationStackerDeviceDriver.java index c99a87b..f938659 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/DoubleStationStackerDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/DoubleStationStackerDeviceDriver.java @@ -1,11 +1,15 @@ package org.nl.acs.device_driver.basedriver.double_station_stacker; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; + import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -17,6 +21,8 @@ import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.basedriver.belt_conveyor.BeltConveyorDeviceDriver; +import org.nl.acs.device_driver.basedriver.double_station_stacker.enums.CommandEnum; +import org.nl.acs.device_driver.basedriver.double_station_stacker.enums.SortEnum; import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; @@ -31,9 +37,7 @@ import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.route.service.impl.RouteLineServiceImpl; import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; import java.util.*; import java.util.stream.Collectors; @@ -41,22 +45,23 @@ import java.util.stream.Collectors; /** * 双工位堆垛机驱动 */ +@EqualsAndHashCode(callSuper = true) @Slf4j @Data @RequiredArgsConstructor public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired + + TaskService takeover = SpringContextHolder.getBean("taskServiceImpl"); + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); - @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); public static final Integer MAX_Y = 6; @@ -64,98 +69,98 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im //心跳 Integer heartbeat = 0; - Integer last_heartbeat = 0; + Integer lastHeartbeat = 0; //堆垛机号 - Integer item_deviceCode = 0; - Integer last_item_deviceCode = 0; + Integer itemDeviceCode = 0; + Integer lastItemDeviceCode = 0; //工作模式 Integer mode = 0; - Integer last_mode = 0; + Integer lastMode = 0; //行走开关信号 Float move = 0F; - Float last_move = 0F; + Float lastMove = 0F; //行走动作信号 Float action = 0F; - Float last_action = 0F; + Float lastAction = 0F; //前叉作业状态 - Integer front_command = 0; - Integer last_front_command = 0; + Integer frontCommand = 0; + Integer lastFrontCommand = 0; //前叉任务号 - Integer front_task = 0; - Integer last_front_task = 0; + Integer frontTask = 0; + Integer lastFrontTask = 0; //行走激光数值 Integer distancex = 0; - Integer last_distancex = 0; + Integer lastDistancex = 0; //特殊开关量1 Float special1 = 0F; - Float last_special1 = 0F; + Float lastSpecial1 = 0F; //特殊开关量2 Float special2 = 0F; - Float last_special2 = 0F; + Float lastSpecial2 = 0F; //水箱和消防缓存位有无货 - Float storage_cache = 0F; - Float last_storage_cache = 0F; + Float storageCache = 0F; + Float lastStorageCache = 0F; //后叉作业状态 - Integer back_command = 0; - Integer last_back_command = 0; + Integer backCommand = 0; + Integer lastBackCommand = 0; //后叉任务号 - Integer back_task = 0; - Integer last_back_task = 0; + Integer backTask = 0; + Integer lastBackTask = 0; //前叉Z轴报警(货叉) - Integer front_ZError = 0; - Integer last_front_ZError = 0; + Integer frontZerror = 0; + Integer lastFrontZerror = 0; //后叉Z轴报警(货叉) - Integer back_ZError = 0; - Integer last_back_ZError = 0; + Integer backZerror = 0; + Integer lastBackZerror = 0; //前叉行走排号 - Integer front_z = 0; - Integer last_front_z = 0; + Integer frontZ = 0; + Integer lastFrontZ = 0; //前行走列号 - Integer front_x = 0; - Integer last_front_x = 0; + Integer frontX = 0; + Integer lastFrontX = 0; //前行走层号 - Integer front_y = 0; - Integer last_front_y = 0; + Integer frontY = 0; + Integer lastFrontY = 0; //后叉行走排号 - Integer back_z = 0; - Integer last_back_z = 0; + Integer backZ = 0; + Integer lastBackZ = 0; //后行走列号 - Integer back_x = 0; - Integer last_back_x = 0; + Integer backX = 0; + Integer lastBackX = 0; //后行走层号 - Integer back_y = 0; - Integer last_back_y = 0; + Integer backY = 0; + Integer lastBackY = 0; //前货叉探货信号 - Float front_forkCargo = 0F; - Float last_front_forkCargo = 0F; + Float frontForkCargo = 0F; + Float lastFrontForkCargo = 0F; //后货叉探货信号 - Float back_forkCargo = 0F; - Float last_back_forkCargo = 0F; + Float backForkCargo = 0F; + Float lastBackForkCargo = 0F; //前货叉位置信号 - Float front_forkLocation = 0F; - Float last_front_forkLocation = 0F; + Float frontForkLocation = 0F; + Float lastFrontForkLocation = 0F; //后货叉位置信号 - Float back_forkLocation = 0F; - Float last_back_forkLocation = 0F; + Float backForkLocation = 0F; + Float lastBackForkLocation = 0F; //前货叉动作信号 - Float front_forkAction = 0F; - Float last_front_forkAction = 0F; + Float frontForkAction = 0F; + Float lastFrontForkAction = 0F; //后货叉动作信号 - Float back_forkAction = 0F; - Float last_back_forkAction = 0F; + Float backForkAction = 0F; + Float lastBackForkAction = 0F; String message = null; @@ -164,12 +169,12 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im String notCreateInstMessage = null; - private int instruction_require_time_out = 3000; - private int instruction_update_time_out = 3000; - private Date instruction_require_time = new Date(); - private Date instruction_update_time = new Date(); - List getDeviceCodeList = null; - List putDeviceCodeList = null; + private int instructionRequireTimeOut = 3000; + private int instructionUpdateTimeOut = 3000; + private Date instructionRequireTime = new Date(); + private Date instructionUpdateTime = new Date(); + List getdevice_codeList = null; + List putdevice_codeList = null; //请求成功标记 Boolean requireSucess = false; @@ -181,7 +186,7 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im } @Override - public void execute() throws Exception { + public void execute() { try { //设置参数 setData(); @@ -196,180 +201,190 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im var17.printStackTrace(); logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); } - - if (mode != 3) { message = "未联机"; - } else if (front_ZError != 0 || back_ZError != 0) { + } else if (frontZerror != 0 || backZerror != 0) { message = "有报警"; } else { - HashMap map = new HashMap(); - if ( front_command == 0 || back_command ==0 ){ + HashMap map = new HashMap<>(); + if (CommandEnum.STANDY.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.STANDY.getStatus())){ applyTask(); requireSucess = true; } + if (CommandEnum.PICKUP.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.PICKUP.getStatus())){ + message = "取货中"; + } + if (CommandEnum.PICKUP_COMPLETE.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.PICKUP_COMPLETE.getStatus())){ + message = "取货完成"; + LinkedList inst = new LinkedList<>(); + getIns(inst); + if (CollectionUtil.isNotEmpty(inst)&&ObjectUtil.isNotEmpty(inst.get(0))) { + String startdevice_code = inst.get(0).getStart_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(startdevice_code); + writeStorageOrConveyor(inst,startdevice_code,startDevice,map); + } + if (CollectionUtil.isNotEmpty(inst)&&ObjectUtil.isEmpty(inst.get(0))) { + String startdevice_code = inst.get(1).getStart_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(startdevice_code); + writeStorageOrConveyor(inst,startdevice_code,startDevice,map); + } + map.put("to_command", CommandEnum.PICKUP_COMPLETE.getStatus()); + requireSucess = true; + } + if (CommandEnum.RELEASE.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.RELEASE.getStatus())){ + message = "放货中"; + } + if (CommandEnum.UNLOAD.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.UNLOAD.getStatus())){ + message = "请求卸货(申请卸货)"; + LinkedList inst = new LinkedList<>(); + getIns(inst); + if (CollectionUtil.isNotEmpty(inst)&&ObjectUtil.isNotEmpty(inst.get(0))) { + String nextdevice_code = inst.get(0).getNext_device_code(); + Device nextDevice = deviceAppService.findDeviceByCode(nextdevice_code); + //指令为执行 + if (unloadCheck(nextDevice)) return; + map.put("to_command", 3); + requireSucess = true; + } + if (CollectionUtil.isNotEmpty(inst)&&ObjectUtil.isEmpty(inst.get(0))) { + String nextdevice_code = inst.get(1).getNext_device_code(); + Device nextDevice = deviceAppService.findDeviceByCode(nextdevice_code); + if (unloadCheck(nextDevice)) return; + map.put("to_command", 3); + requireSucess = true; + } + } + if (CommandEnum.UNLOAD_COMPLETE.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.UNLOAD_COMPLETE.getStatus())){ + message = "放货完成"; + map.put("to_command", 5); + LinkedList inst = new LinkedList<>(); + getIns(inst); + try { + if (CollectionUtil.isNotEmpty(inst)){ + for (Instruction instruction : inst) { + finishInstruction(instruction); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + requireSucess = true; + } - switch (front_command) { - case 0: - applyTask(); - requireSucess = true; - break; - case 1: - message = "取货中"; - break; - case 2: - message = "取货完成"; - Instruction instruction = null; - String next_device_code = instruction.getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.conveyor.name())) { - List list = deviceExtraService.list(Wrappers.lambdaQuery(DeviceExtra.class).eq(DeviceExtra::getDevice_code, next_device_code)); - for (DeviceExtra deviceExtra : list) { - if ("x".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_x", deviceExtra.getExtra_value()); - } - if ("z".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_z", deviceExtra.getExtra_value()); - } - if ("y".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_y", deviceExtra.getExtra_value()); - } - } - } - if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.storage.name())) { - map.put("to_y", instruction.getFrom_z()); - if (instruction.getFrom_x().length() > 1) { - String substring = instruction.getFrom_x().substring(1); - map.put("to_z", substring); - } else { - map.put("to_z", instruction.getFrom_x()); - } - map.put("to_x", instruction.getFrom_y()); - } - map.put("to_command", 2); - requireSucess = true; - break; - case 3: - message = "放货中"; - break; - case 4: - message = "请求卸货(申请卸货)"; - Instruction instruction1 = null; - String next_device_code1 = instruction1.getNext_device_code(); - Device nextDevice1 = deviceAppService.findDeviceByCode(next_device_code1); - if (ObjectUtil.isNotNull(instruction1)) { - //指令为执行 - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (nextDevice1.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice1.getDeviceDriver(); - if (siemensConveyorDeviceDriver.getMode() != 2 || siemensConveyorDeviceDriver.getMove() == 1) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + siemensConveyorDeviceDriver.getDevice_code() + - "有货或未联机,无法下发指令!指令号:" ; - return; - } - } - map.put("to_command", 3); - } - requireSucess = true; - break; - case 5: - message = "放货完成"; - map.put("to_command", 5); - Instruction inst = null; - try { - finish_instruction(inst); - } catch (Exception e) { - e.printStackTrace(); - } - requireSucess = true; - break; - case 6: - message = "取货准备(会库位台)"; - map.put("to_command", 6); - requireSucess = true; - break; - case 7: - message = "召回"; - map.put("to_command", 7); - requireSucess = true; - break; - case 8: - message = "急停"; - map.put("to_command", 8); - requireSucess = true; - break; - default: - message = "不明"; - requireSucess = true; - break; + if (CommandEnum.PICKUP_PREPARATION.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.PICKUP_PREPARATION.getStatus())){ + message = "取货准备(会库位台)"; + map.put("to_command", 6); + requireSucess = true; + } + if (CommandEnum.RECALL.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.RECALL.getStatus())){ + message = "召回"; + map.put("to_command", 7); + requireSucess = true; + } + if (CommandEnum.STOP.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.STOP.getStatus())){ + message = "急停"; + map.put("to_command", 8); + requireSucess = true; } if (ObjectUtil.isNotNull(map)) { this.writing(map); } - } - last_heartbeat = heartbeat; - last_item_deviceCode = item_deviceCode; - last_mode = mode; - last_front_command = front_command; - last_back_command = back_command; - last_front_task = front_task; - last_back_task = back_task; - last_move = move; - last_front_ZError = front_ZError; - last_back_ZError = back_ZError; - last_front_z = front_z; - last_back_z = back_z; - last_front_x = front_x; - last_back_x = back_x; - last_front_y = front_y; - last_back_y = back_y; - last_action = action; - last_distancex = distancex; - last_front_forkCargo = front_forkCargo; - last_back_forkCargo = back_forkCargo; - last_front_forkLocation = front_forkLocation; - last_back_forkLocation = back_forkLocation; - last_front_forkAction = front_forkAction; - last_back_forkAction = back_forkAction; - last_special1 = special1; - last_special2 = special2; - last_storage_cache = storage_cache; + lastHeartbeat = heartbeat; + lastItemDeviceCode = itemDeviceCode; + lastMode = mode; + lastFrontCommand = frontCommand; + lastBackCommand = backCommand; + lastFrontTask = frontTask; + lastBackTask = backTask; + lastMove = move; + lastFrontZerror = frontZerror; + lastBackZerror = backZerror; + lastFrontZ = frontZ; + lastBackZ = backZ; + lastFrontX = frontX; + lastBackX = backX; + lastFrontY = frontY; + lastBackY = backY; + lastAction = action; + lastDistancex = distancex; + lastFrontForkCargo = frontForkCargo; + lastBackForkCargo = backForkCargo; + lastFrontForkLocation = frontForkLocation; + lastBackForkLocation = backForkLocation; + lastFrontForkAction = frontForkAction; + lastBackForkAction = backForkAction; + lastSpecial1 = special1; + lastSpecial2 = special2; + lastStorageCache = storageCache; + + } + + private boolean unloadCheck(Device nextDevice) { + SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { + siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice.getDeviceDriver(); + if (siemensConveyorDeviceDriver.getMode() != 2 || siemensConveyorDeviceDriver.getMove() == 1) { + notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + siemensConveyorDeviceDriver.getDeviceCode() + + "有货或未联机,无法下发指令!指令号:"; + return true; + } + } + return false; + } + + private void getIns(LinkedList inst) { + if (ObjectUtil.isNotEmpty(this.frontTask)) { + Instruction instructionFront = instructionService.findByCodeFromCache(String.valueOf(frontTask)); + if (ObjectUtil.isNotEmpty(instructionFront)){ + inst.add(instructionFront); + } + } + if (ObjectUtil.isNotEmpty(this.backTask)) { + Instruction instructionBack = instructionService.findByCodeFromCache(String.valueOf(backTask)); + if (CollectionUtil.isNotEmpty(inst) && ObjectUtil.isNotEmpty(instructionBack)){ + inst.add(instructionBack); + }if (CollectionUtil.isEmpty(inst) && ObjectUtil.isNotEmpty(instructionBack)){ + inst.add(null); + inst.add(instructionBack); + } + } } private void updateAllstatues() { - if (mode == 3 && front_task > 0) { + if (mode == 3 && frontTask > 0) { Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + if (date.getTime() - this.instructionUpdateTime.getTime() < (long) this.instructionUpdateTimeOut) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instructionUpdateTimeOut); } else { - this.instruction_update_time = date; - updateInstructionStatus(front_task); + this.instructionUpdateTime = date; + updateInstructionStatus(frontTask); } } - if (mode == 3 && back_task > 0) { + if (mode == 3 && backTask > 0) { Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + if (date.getTime() - this.instructionUpdateTime.getTime() < (long) this.instructionUpdateTimeOut) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instructionUpdateTimeOut); } else { - this.instruction_update_time = date; + this.instructionUpdateTime = date; //更改指令状态 - updateInstructionStatus(back_task); + updateInstructionStatus(backTask); } } - if (mode == 3 && back_task > 0 && front_task > 0) { + if (mode == 3 && backTask > 0 && frontTask > 0) { Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + if (date.getTime() - this.instructionUpdateTime.getTime() < (long) this.instructionUpdateTimeOut) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instructionUpdateTimeOut); } else { - this.instruction_update_time = date; + this.instructionUpdateTime = date; //更改指令状态 - updateInstructionStatus(front_task); + updateInstructionStatus(frontTask); + updateInstructionStatus(backTask); } } } @@ -390,18 +405,17 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im /** * 申请任务 * - * @param */ public synchronized boolean applyTask() { Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + if (date.getTime() - this.instructionRequireTime.getTime() < (long) this.instructionRequireTimeOut) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instructionRequireTimeOut); return false; } else { - this.instruction_require_time = date; + this.instructionRequireTime = date; //输入:指令类型多种\ 指令状态多种\ Instruction instruction1 = new Instruction(); - instruction1.setInstruction_status("0"); + instruction1.setInstruction_status(InstructionStatusEnum.READY.getIndex()); List instructions = instructionService.findByDeviceCodes(instruction1, false); List instructionList = new ArrayList<>(); //根据路由过滤指令 @@ -409,18 +423,18 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im if (CollUtil.isEmpty(instructionList) || instructionList.size() < 1) { return false; } - instructionList = this.sortInst(instructionList); + this.sortInst(instructionList); Instruction inst = instructionList.get(0); - List instructionsAll = new ArrayList<>(); - instructions.add(inst); + LinkedList instructionsAll = new LinkedList<>(); + //找出有相邻的列的指令,如果没有按照单叉走,有按照双叉走 if (findInstruction(instructionList, inst, instructionsAll)) return false; - if (instructionsAll.size()==0){ - //写信号 - if (wirteData(inst)) return false; - } + + //写信号 + if (wirteData(instructionsAll)) return false; + } @@ -459,75 +473,149 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im return false; } - private boolean wirteData(Instruction inst) { - if (StrUtil.equals(inst.getInstruction_status(), "0")) { - String start_device_code = inst.getStart_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + private boolean wirteData(LinkedList inst) { + if (StrUtil.equals(inst.get(0).getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { + String startdevice_code = inst.get(0).getStart_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(startdevice_code); BeltConveyorDeviceDriver beltConveyorDeviceDriver; if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver(); if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 0) { notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getDevice_code() + - "无货或未联机,无法下发指令!指令号:" + inst.getInstruction_code(); + "无货或未联机,无法下发指令!指令号:" + inst.get(0).getInstruction_code(); return true; } } - HashMap map = new HashMap(); - map.put("to_device_code", this.getDevice().getAddress()); - map.put("to_command", 1); -// map.put("to_type", inst.getMaterial()); - map.put("to_task", inst.getInstruction_code()); + //前叉信号写入 + HashMap map = new HashMap<>(); + if (inst.size()==1&& ObjectUtil.isNotEmpty(inst.get(0))) { + map.put("to_device_code", this.getDevice().getAddress()); + map.put("to_command", CommandEnum.PICKUP.getStatus()); + map.put("to_front_task", inst.get(0).getInstruction_code()); - if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) { - List list = deviceExtraService.list(Wrappers.lambdaQuery(DeviceExtra.class).eq(DeviceExtra::getDevice_code, start_device_code)); - for (DeviceExtra deviceExtra : list) { - if ("x".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_x", deviceExtra.getExtra_value()); - } - if ("z".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_z", deviceExtra.getExtra_value()); - } - if ("y".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_y", deviceExtra.getExtra_value()); - } - } } - if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) { - map.put("to_y", inst.getFrom_z()); - if (inst.getFrom_x().length() > 1) { - String substring = inst.getFrom_x().substring(1); - map.put("to_z", substring); - } else { - map.put("to_z", inst.getFrom_x()); - } - map.put("to_x", inst.getFrom_y()); + if (inst.size()>1 && ObjectUtil.isNotEmpty(inst.get(1))) { + map.put("to_device_code", this.getDevice().getAddress()); + map.put("to_command", CommandEnum.PICKUP.getStatus()); + map.put("to_back_task", inst.get(1).getInstruction_code()); + }else{ + map.put("to_device_code", this.getDevice().getAddress()); + map.put("to_command", CommandEnum.PICKUP.getStatus()); + map.put("to_front_task", inst.get(0).getInstruction_code()); + map.put("to_back_task", inst.get(1).getInstruction_code()); } + writeStorageOrConveyor(inst, startdevice_code, startDevice, map); this.writing(map); } return false; } - private boolean findInstruction(List instructionList, Instruction inst, List instructionsAll) { + private void writeStorageOrConveyor(LinkedList inst, String startDeviceCode, Device startDevice, Map map) { + if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) { + List list = deviceExtraService.list(Wrappers.lambdaQuery(DeviceExtra.class).eq(DeviceExtra::getDevice_code, startDeviceCode)); + for (DeviceExtra deviceExtra : list) { + if ("x".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { + map.put("to_x", deviceExtra.getExtra_value()); + } + if ("z".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { + map.put("to_z", deviceExtra.getExtra_value()); + } + if ("y".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { + map.put("to_y", deviceExtra.getExtra_value()); + } + } + } + if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) { + if (ObjectUtil.isNotEmpty(inst.get(0))) { + map.put("to_y", inst.get(0).getFrom_z()); + if (inst.get(0).getFrom_x().length() > 1) { + String substring = inst.get(0).getFrom_x().substring(1); + map.put("to_z", substring); + } else { + map.put("to_z", inst.get(0).getFrom_x()); + } + map.put("to_x", inst.get(0).getFrom_y()); + }else { + //只存在后叉的情况 + map.put("to_y", Integer.parseInt(inst.get(0).getFrom_z())+1); + if (inst.get(0).getFrom_x().length() > 1) { + String substring = inst.get(0).getFrom_x().substring(1); + map.put("to_z", Integer.parseInt(substring)+1); + } else { + map.put("to_z", Integer.parseInt(inst.get(0).getFrom_x())+1); + } + map.put("to_x", Integer.parseInt(inst.get(0).getFrom_y())+1); + } + } + } + + private boolean findInstruction(List instructionList, Instruction inst, LinkedList instructionsAll) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(DeviceExtra::getExtra_name,"no_front_y","no_front_x","no_back_y","no_back_x","sort"); + List deviceExtras = deviceExtraMapper.selectList(wrapper); + //默认第一条指令为前叉判断是否符合 if (StringUtils.isEmpty(inst.getNext_point_code())&&!StringUtils.contains(inst.getNext_point_code(),"-")){ + return true; + }else { - String[] split = inst.getNext_point_code().split("-"); - if (Integer.valueOf(split[1]).equals(MIN_Y)){ + String[] splitFront = inst.getNext_point_code().split("-"); + List frontY = deviceExtras.stream().filter(item -> "no_front_y".equals(item.getExtra_name())).collect(Collectors.toList()); + List frontX = deviceExtras.stream().filter(item -> "no_front_x".equals(item.getExtra_name())).collect(Collectors.toList()); + List backY = deviceExtras.stream().filter(item -> "no_back_y".equals(item.getExtra_name())).collect(Collectors.toList()); + List backX = deviceExtras.stream().filter(item -> "no_back_x".equals(item.getExtra_name())).collect(Collectors.toList()); + List sort = deviceExtras.stream().filter(item -> "sort".equals(item.getExtra_name())).collect(Collectors.toList()); + //存在配置的禁止前排列 + if (checkY(splitFront, frontY)) return true; + if (checkX(splitFront, frontX)) { return true; } - if (Integer.valueOf(split[1]).equals(MAX_Y)){ - String nextPointCodeDown = split[0] + "-" + (Integer.parseInt(split[1]) - 1) + "-" + split[2]; - List instructionNextPointList = instructionList.stream().filter(item -> item.getNext_point_code().equals(nextPointCodeDown)).collect(Collectors.toList()); + + if (Integer.valueOf(splitFront[1]).equals(MIN_Y)){ + return true; + } + //根据排序进行加减 + String nextPointCodeDown = splitFront[0] + "-" + (Integer.parseInt(splitFront[1]) - 1) + "-" + splitFront[2]; + String nextPointCodeUp = splitFront[0] + "-" + (Integer.parseInt(splitFront[1]) + 1) + "-" + splitFront[2]; + if (CollectionUtil.isNotEmpty(sort)&&SortEnum.BACK.getCode().equals(sort.get(0).getExtra_value())){ + nextPointCodeDown = splitFront[0] + "-" + (Integer.parseInt(splitFront[1]) + 1) + "-" + splitFront[2]; + nextPointCodeUp = splitFront[0] + "-" + (Integer.parseInt(splitFront[1]) - 1) + "-" + splitFront[2]; + } + + if (Integer.valueOf(splitFront[1]).equals(MAX_Y)){ + String finalNextPointCodeDown = nextPointCodeDown; + List instructionNextPointList = instructionList.stream().filter(item -> item.getNext_point_code().equals(finalNextPointCodeDown)).collect(Collectors.toList()); if (instructionNextPointList.size()>0){ + String[] splitBack = instructionNextPointList.get(0).getNext_point_code().split("-"); + if (checkY(splitBack, backY)) return true; + if (checkX(splitBack, backX)) return true; instructionsAll.add(instructionNextPointList.get(0)); } }else { - String nextPointCodeUp = split[0] + "-" + (Integer.parseInt(split[1]) - 1) + "-" + split[2]; - String nextPointCodeDown = split[0] + "-" + (Integer.parseInt(split[1]) - 1) + "-" + split[2]; - List instructionNextPointList = instructionList.stream().filter(item -> item.getNext_point_code().equals(nextPointCodeDown)||item.getNext_point_code().equals(nextPointCodeUp)).collect(Collectors.toList()); - if (instructionNextPointList.size()>0){ - instructionsAll.add(instructionNextPointList.get(0)); + String finalNextPointCodeDown1 = nextPointCodeDown; + List instructionNextPointList1 = instructionList.stream().filter(item -> item.getNext_point_code().equals(finalNextPointCodeDown1)).collect(Collectors.toList()); + String finalNextPointCodeUp = nextPointCodeUp; + List instructionNextPointList2 = instructionList.stream().filter(item -> item.getNext_point_code().equals(finalNextPointCodeUp)).collect(Collectors.toList()); + + if (instructionNextPointList1.size()>0){ + String[] splitBack = instructionNextPointList1.get(0).getNext_point_code().split("-"); + if (checkY(splitBack, backY)) return true; + if (checkX(splitBack, backX)) return true; + instructionsAll.add(instructionNextPointList1.get(0)); + return false; + } + if (instructionNextPointList2.size()>0){ + //前叉的上一列有指令,此时前叉变成后叉,重新校验 + String[] splitBack = instructionNextPointList2.get(0).getNext_point_code().split("-"); + if (checkY(splitBack, frontY)) return true; + if (checkX(splitBack, frontX)) return true; + instructionsAll.addFirst(null); + if (checkY(splitFront, backY)) return true; + if (checkX(splitFront, backX)) return true; + instructionsAll.removeFirst(); + instructionsAll.addFirst(instructionNextPointList2.get(0)); + return false; } } @@ -535,14 +623,32 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im return false; } + private boolean checkX(String[] split, List x) { + if (x.size()!=0&& StringUtils.isNotEmpty(x.get(0).getExtra_value())){ + String[] splitValue = x.get(0).getExtra_value().split(","); + Set set = new HashSet<>(Arrays.asList(splitValue)); + return set.contains(split[0]); + } + return false; + } + + private boolean checkY(String[] split, List y) { + if (y.size()!=0&& StringUtils.isNotEmpty(y.get(0).getExtra_value())){ + String[] splitValue = y.get(0).getExtra_value().split(","); + Set set = new HashSet<>(Arrays.asList(splitValue)); + return set.contains(split[1]); + } + return false; + } + + /** * 将指令根据优先级和创建时间排序 * * @param instructions - * @return */ - private List sortInst(List instructions) { - Collections.sort(instructions, (t1, t2) -> { + private void sortInst(List instructions) { + instructions.sort((t1, t2) -> { //优先级从大到小 int i = t2.getPriority().compareTo(t1.getPriority()); //如果优先级相等 @@ -552,14 +658,13 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im } return i; }); - return instructions; } @Override - public JSONObject getDeviceStatusName() throws Exception { + public JSONObject getDeviceStatusName() { return null; } @@ -572,10 +677,9 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im * 完成指令 * * @param inst - * @return * @throws Exception */ - public synchronized boolean finish_instruction(Instruction inst) throws Exception { + public synchronized boolean finishInstruction(Instruction inst) throws Exception { instructionService.finish(inst); return true; } @@ -598,23 +702,6 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im } } - public List sortTask(List taskDtos) { - Collections.sort(taskDtos, new Comparator() { - @Override - public int compare(TaskDto t1, TaskDto t2) { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - } - }); - return taskDtos; - } - //将扩展表中的字符串数据转换成集合 @Override @@ -626,8 +713,8 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im String devicesString = extraValue.substring(1, extraValue.length() - 1); List devicesList = new ArrayList<>(); String[] devices = devicesString.split(","); - for (int i = 0; i < devices.length; i++) { - String s = devices[i].replace("\"", "").replace("\"", ""); + for (String value : devices) { + String s = value.replace("\"", "").replace("\"", ""); devicesList.add(s); } return devicesList; @@ -636,143 +723,143 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im private void setData() { device_code = this.getDeviceCode(); heartbeat = this.itemProtocol.getItem_heartbeat(); - item_deviceCode = this.itemProtocol.getItem_deviceCode(); + itemDeviceCode= this.itemProtocol.getItem_device_Code(); mode = this.itemProtocol.getItem_mode(); move = this.itemProtocol.getItem_move(); - front_command = this.itemProtocol.getItem_front_command(); - back_command = this.itemProtocol.getItem_back_command(); - front_task = this.itemProtocol.getItem_front_task(); - front_ZError = this.itemProtocol.getItem_front_ZError(); - back_ZError = this.itemProtocol.getItem_back_ZError(); - front_z = this.itemProtocol.getItem_front_z(); - front_x = this.itemProtocol.getItem_front_x(); - front_y = this.itemProtocol.getItem_front_y(); - back_z = this.itemProtocol.getItem_back_z(); - back_x = this.itemProtocol.getItem_back_x(); - back_y = this.itemProtocol.getItem_back_y(); - front_forkCargo = this.itemProtocol.getItem_front_forkCargo(); - back_forkCargo = this.itemProtocol.getItem_back_forkCargo(); - front_forkLocation = this.itemProtocol.getItem_front_forkLocation(); - back_forkLocation = this.itemProtocol.getItem_back_forkLocation(); - back_forkAction = this.itemProtocol.getItem_back_forkAction(); - front_forkAction = this.itemProtocol.getItem_front_forkAction(); + frontCommand = this.itemProtocol.getItem_front_command(); + backCommand = this.itemProtocol.getItem_back_command(); + frontTask = this.itemProtocol.getItem_front_task(); + frontZerror = this.itemProtocol.getItem_front_ZError(); + backZerror = this.itemProtocol.getItem_back_ZError(); + frontZ = this.itemProtocol.getItem_front_z(); + frontX = this.itemProtocol.getItem_front_x(); + frontY = this.itemProtocol.getItem_front_y(); + backZ = this.itemProtocol.getItem_back_z(); + backX = this.itemProtocol.getItem_back_x(); + backY = this.itemProtocol.getItem_back_y(); + frontForkCargo = this.itemProtocol.getItem_front_forkCargo(); + backForkCargo = this.itemProtocol.getItem_back_forkCargo(); + frontForkLocation = this.itemProtocol.getItem_front_forkLocation(); + backForkLocation = this.itemProtocol.getItem_back_forkLocation(); + backForkAction = this.itemProtocol.getItem_back_forkAction(); + frontForkAction = this.itemProtocol.getItem_front_forkAction(); special1 = this.itemProtocol.getItem_special1(); special2 = this.itemProtocol.getItem_special2(); - storage_cache = this.itemProtocol.getItem_storage_cache(); + storageCache = this.itemProtocol.getItem_storage_cache(); } private void setLog() { - if (!item_deviceCode.equals(last_item_deviceCode)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(item_deviceCode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号item_deviceCode:" + last_item_deviceCode + "->" + item_deviceCode); + if (!itemDeviceCode.equals(lastItemDeviceCode)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(itemDeviceCode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号item_device_code:" + lastItemDeviceCode + "->" + itemDeviceCode); } - if (!mode.equals(last_mode)) { + if (!mode.equals(lastMode)) { requireSucess = false; logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + lastMode + "->" + mode); } - if (!front_command.equals(last_front_command)) { + if (!frontCommand.equals(lastFrontCommand)) { requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_command)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_command:" + last_front_command + "->" + front_command); + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontCommand)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_command:" + lastFrontCommand + "->" + frontCommand); } - if (!back_command.equals(last_back_command)) { + if (!backCommand.equals(lastBackCommand)) { requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_command)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_command:" + last_back_command + "->" + back_command); + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backCommand)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_command:" + lastBackCommand + "->" + backCommand); } - if (!front_task.equals(last_front_task)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_task:" + last_front_task + "->" + front_task); + if (!frontTask.equals(lastFrontTask)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontTask)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_task:" + lastFrontTask + "->" + frontTask); } - if (!back_task.equals(last_back_task)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_task:" + last_back_task + "->" + back_task); + if (!backTask.equals(lastBackTask)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backTask)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_task:" + lastBackTask + "->" + backTask); } - if (!front_ZError.equals(last_front_ZError)) { - if (0 != front_ZError) { + if (!frontZerror.equals(lastFrontZerror)) { + if (0 != frontZerror) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontZerror)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_ZError:" + lastFrontZerror + "->" + frontZerror); } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_ZError)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_ZError:" + last_front_ZError + "->" + front_ZError); } - if (!back_ZError.equals(last_back_ZError)) { - if (0 != back_ZError) { + if (!backZerror.equals(lastBackZerror)) { + if (0 != backZerror) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backZerror)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_ZError:" + lastBackZerror + "->" + backZerror); } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_ZError)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_ZError:" + last_back_ZError + "->" + back_ZError); } - if (!back_z.equals(last_back_z)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_z)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_z:" + last_back_z + "->" + back_z); + if (!backZ.equals(lastBackZ)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backZ)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_z:" + lastBackZ + "->" + backZ); } - if (!back_x.equals(last_back_x)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_x)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_x:" + last_back_x + "->" + back_x); + if (!backX.equals(lastBackX)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backX)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_x:" + lastBackX + "->" + backX); } - if (!back_y.equals(last_back_y)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_y:" + last_back_y + "->" + back_y); + if (!backY.equals(lastBackY)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backY)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_y:" + lastBackY + "->" + backY); } - if (!front_z.equals(last_front_z)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_z)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_z:" + last_front_z + "->" + front_z); + if (!frontZ.equals(lastFrontZ)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontZ)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_z:" + lastFrontZ + "->" + frontZ); } - if (!front_x.equals(last_front_x)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_x)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_x:" + last_front_x + "->" + front_x); + if (!frontX.equals(lastFrontX)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontX)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_x:" + lastFrontX + "->" + frontX); } - if (!front_y.equals(last_front_y)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_y:" + last_front_y + "->" + front_y); + if (!frontY.equals(lastFrontY)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontY)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_y:" + lastFrontY + "->" + frontY); } - if (!move.equals(last_move)) { + if (!move.equals(lastMove)) { logServer.deviceItemValue(this.device_code, "mode", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + lastMove + "->" + move); } - if (!action.equals(last_action)) { + if (!action.equals(lastAction)) { logServer.deviceItemValue(this.device_code, "mode", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + lastAction + "->" + action); } - if (!distancex.equals(last_distancex)) { + if (!distancex.equals(lastDistancex)) { logServer.deviceItemValue(this.device_code, "mode", String.valueOf(distancex)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号distancex:" + last_distancex + "->" + distancex); + logServer.deviceExecuteLog(this.device_code, "", "", "信号distancex:" + lastDistancex + "->" + distancex); } - if (!front_forkCargo.equals(last_front_forkCargo)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_forkCargo)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkCargo:" + last_front_forkCargo + "->" + front_forkCargo); + if (!frontForkCargo.equals(lastFrontForkCargo)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontForkCargo)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkCargo:" + lastFrontForkCargo + "->" + frontForkCargo); } - if (!front_forkLocation.equals(last_front_forkLocation)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_forkLocation)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkLocation:" + last_front_forkLocation + "->" + front_forkLocation); + if (!frontForkLocation.equals(lastFrontForkLocation)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontForkLocation)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkLocation:" + lastFrontForkLocation + "->" + frontForkLocation); } - if (!front_forkAction.equals(last_front_forkAction)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(front_forkAction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkAction:" + last_front_forkAction + "->" + front_forkAction); + if (!frontForkAction.equals(lastFrontForkAction)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontForkAction)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkAction:" + lastFrontForkAction + "->" + frontForkAction); } - if (!back_forkCargo.equals(last_back_forkCargo)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_forkCargo)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkCargo:" + last_back_forkCargo + "->" + back_forkCargo); + if (!backForkCargo.equals(lastBackForkCargo)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backForkCargo)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkCargo:" + lastBackForkCargo + "->" + backForkCargo); } - if (!back_forkLocation.equals(last_back_forkLocation)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_forkLocation)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkLocation:" + last_back_forkLocation + "->" + back_forkLocation); + if (!backForkLocation.equals(lastBackForkLocation)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backForkLocation)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkLocation:" + lastBackForkLocation + "->" + backForkLocation); } - if (!back_forkAction.equals(last_back_forkAction)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(back_forkAction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkAction:" + last_back_forkAction + "->" + back_forkAction); + if (!backForkAction.equals(lastBackForkAction)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backForkAction)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkAction:" + lastBackForkAction + "->" + backForkAction); } - if (!special1.equals(last_special1)) { + if (!special1.equals(lastSpecial1)) { logServer.deviceItemValue(this.device_code, "mode", String.valueOf(special1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号special1:" + last_special1 + "->" + special1); + logServer.deviceExecuteLog(this.device_code, "", "", "信号special1:" + lastSpecial1 + "->" + special1); } - if (!special2.equals(last_special2)) { + if (!special2.equals(lastSpecial2)) { logServer.deviceItemValue(this.device_code, "mode", String.valueOf(special2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号special2:" + last_special2 + "->" + special2); + logServer.deviceExecuteLog(this.device_code, "", "", "信号special2:" + lastSpecial2 + "->" + special2); } - if (!storage_cache.equals(last_storage_cache)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(storage_cache)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号storage_cache:" + last_storage_cache + "->" + storage_cache); + if (!storageCache.equals(lastStorageCache)) { + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(storageCache)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号storage_cache:" + lastStorageCache + "->" + storageCache); } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/ItemProtocol.java index 6b1fe15..03e1457 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/ItemProtocol.java @@ -208,7 +208,7 @@ public class ItemProtocol { public Integer getItem_heartbeat(){ return this.getOpcIntegerValue(item_heartbeat); } - public Integer getItem_deviceCode(){ + public Integer getItem_device_Code(){ return this.getOpcIntegerValue(item_deviceCode); } public Integer getItem_mode(){ diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/enums/CommandEnum.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/enums/CommandEnum.java new file mode 100644 index 0000000..898eba6 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/enums/CommandEnum.java @@ -0,0 +1,37 @@ +/** + * @author ls + * @date 2023/12/4 13:42 + */ +package org.nl.acs.device_driver.basedriver.double_station_stacker.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.nl.acs.task.enums.TaskStatusEnum; + +@Getter +@AllArgsConstructor +public enum CommandEnum { + STANDY(0,"待机"), + PICKUP(1,"取货中"), + PICKUP_COMPLETE(2,"取货完成"), + RELEASE(3,"放货中"), + UNLOAD(4,"请求卸货"), + UNLOAD_COMPLETE(5,"卸货完成"), + PICKUP_PREPARATION(6,"取货准备"), + RECALL(7,"召回"), + STOP(8,"急停"); + + private Integer status; + private String desc; + + public static String getDesc(Integer status) { + for (CommandEnum c : CommandEnum.values()) { + if (c.getStatus().equals(status)) { + return c.getDesc(); + } + } + return null; + } + + +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/enums/SortEnum.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/enums/SortEnum.java new file mode 100644 index 0000000..3aa98d7 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/double_station_stacker/enums/SortEnum.java @@ -0,0 +1,18 @@ +/** + * @author ls + * @date 2023/12/4 17:43 + */ +package org.nl.acs.device_driver.basedriver.double_station_stacker.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum SortEnum { + PRONT("1","正序"), + BACK("2","倒序"); + + private String code; + private String desc; +} diff --git a/acs/nladmin-ui/src/views/acs/device/driver/double_station_stacker.vue b/acs/nladmin-ui/src/views/acs/device/driver/double_station_stacker.vue index 818efd6..0bafa74 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/double_station_stacker.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/double_station_stacker.vue @@ -78,8 +78,8 @@ label-width="78px" > - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -280,6 +318,7 @@ export default { options: [], data1: [], data2: [], + sortX: [{ code: '1', name: '正序' }, { code: '2', name: '倒序' }], form: { inspect_in_stocck: true, ignore_pickup_check: true, @@ -291,7 +330,12 @@ export default { is_release: true, link_device_code: [], get_device_code: [], - put_device_code: [] + put_device_code: [], + no_front_y: '', + no_front_x: '', + no_back_y: '', + no_back_x: '', + sort: '' }, rules: {} }