diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/ItemProtocol.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/ItemProtocol.java index d82c2ad..5e06d6e 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/ItemProtocol.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/ItemProtocol.java @@ -14,7 +14,7 @@ public enum ItemProtocol implements DeviceDriverBaseReader.KeyProvider { STACKER_ERROR("stacker_error", "堆垛机主体报警", "DB101.B3"), ACTION("action", "行走动作信号", "DB101.B5"), FRONT_COMMAND("front_command", "前叉作业状态", "DB101.B31"), - FRONT_TASK("front_task", "前叉任务号", "DB101.B32"), + FRONT_TASK("front_task", "前叉任务号", "DB101.D32"), FRONT_YERROR("front_Yerror", "前叉Y轴报警(载货台)", "DB101.B36"), FRONT_ZERROR("front_Zerror", "前叉Z轴报警(货叉)", "DB101.B37"), FRONT_Z("front_z", "前叉行走排号", "DB101.B38"), @@ -26,7 +26,7 @@ public enum ItemProtocol implements DeviceDriverBaseReader.KeyProvider { FRONT_FORKLOCATION("front_forkLocation", "前叉货叉位置信号", "DB101.B49"), FRONT_FORKACTION("front_forkAction", "前叉货叉动作信号", "DB101.B50"), BACK_COMMAND("back_command", "后叉作业状态", "DB101.B101"), - BACK_TASK("back_task", "后叉任务号", "DB101.B102"), + BACK_TASK("back_task", "后叉任务号", "DB101.D102"), BACK_YERROR("back_Yerror", "后叉Y轴报警(载货台)", "DB101.B106"), BACK_ZERROR("back_Zerror", "后叉Z轴报警(货叉)", "DB101.B107"), BACK_Z("back_z", "后叉行走排号", "DB101.B108"), @@ -39,7 +39,7 @@ public enum ItemProtocol implements DeviceDriverBaseReader.KeyProvider { BACK_FORKACTION("back_forkAction", "后叉货叉动作信号", "DB101.B120"), TO_DEVICE_CODE("to_device_code", "调度号", "DB100.B1"), TO_COMMAND("to_command", "作业命令", "DB100.B2"), - TO_CHOOSE_FORK("to_choose_fork", "货叉选择", "DB100.B4"), + TO_CHOOSE_FORK("to_choose_fork", "货叉选择", "DB100.W4"), TO_Z("to_z", "作业排", "DB100.B6"), TO_X("to_x", "作业列", "DB100.B7"), TO_Y("to_y", "作业层", "DB100.B8"), diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java index 63c59b3..8da0c77 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java @@ -290,6 +290,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme */ private int stackerNum = 1; + private boolean againRequireSuccess = false; + + @Override public Device getDevice() { return this.device; @@ -382,13 +385,132 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme return device == null ? false : device.getDeviceDriver() instanceof StandardStorageDeviceDriver; } + private static final List AGAIN_ERROR = Arrays.asList(5, 6, 16); + + @SneakyThrows @Override public void executeLogic() { stackerNum = Optional.ofNullable(this.getExtraValue().get("stackerNum")).map(Object::toString).map(Integer::parseInt).orElse(1); + if (this.back_command != this.lastBack_command || this.front_command != this.lastFront_command) { this.requireSuccess = false; } + + if (front_Zerror != lastFront_Zerror || back_Zerror != lastBack_Zerror) { + if (AGAIN_ERROR.contains(front_Zerror) || AGAIN_ERROR.contains(back_Zerror)) { + this.againRequireSuccess = false; + } + } + + //前叉满入 + if (front_Zerror == 5) { + //先解警 + //重新下发放货点位信息 + // + if (!againRequireSuccess) { + List keys = Arrays.asList(ItemProtocol.TO_Z.getKey(), ItemProtocol.TO_X.getKey(), ItemProtocol.TO_Y.getKey(), ItemProtocol.TO_FRONT_TASK.getKey(), ItemProtocol.TO_CHOOSE_FORK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(2, 25, 5, this.front_task, SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_TWO.getSignalNum()); + this.writing(ItemProtocol.TO_COMMAND.getKey(), 5); + this.writing(keys, values); + this.againRequireSuccess = true; + } + return; + } + //后叉满入 + else if (back_Zerror == 5) { + //先解警 + //重新下发放货点位信息 + if (!againRequireSuccess) { + List keys = Arrays.asList(ItemProtocol.TO_Z.getKey(), ItemProtocol.TO_X.getKey(), ItemProtocol.TO_Y.getKey(), ItemProtocol.TO_BACK_TASK.getKey(), ItemProtocol.TO_CHOOSE_FORK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(2, 30, 6, this.back_task, SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_TWO.getSignalNum()); + this.writing(ItemProtocol.TO_COMMAND.getKey(), 5); + this.writing(keys, values); + this.againRequireSuccess = true; + } + return; + } + + + //前叉空出 + if (front_Zerror == 6) { + //先解警 + //重新下发取货点位信息 + if (!againRequireSuccess) { + List keys = Arrays.asList(ItemProtocol.TO_Z.getKey(), ItemProtocol.TO_X.getKey(), ItemProtocol.TO_Y.getKey(), ItemProtocol.TO_FRONT_TASK.getKey(), ItemProtocol.TO_CHOOSE_FORK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(2, 25, 5, this.front_task, SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()); + this.writing(ItemProtocol.TO_COMMAND.getKey(), 5); + this.writing(keys, values); + this.againRequireSuccess = true; + } + return; + } + //后叉空出 + else if (back_Zerror == 6) { + //先解警 + //重新下发取货点位信息 + if (!againRequireSuccess) { + List keys = Arrays.asList(ItemProtocol.TO_Z.getKey(), ItemProtocol.TO_X.getKey(), ItemProtocol.TO_Y.getKey(), ItemProtocol.TO_BACK_TASK.getKey(), ItemProtocol.TO_CHOOSE_FORK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(2, 30, 5, this.front_task, SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()); + this.writing(ItemProtocol.TO_COMMAND.getKey(), 5); + this.writing(keys, values); + this.againRequireSuccess = true; + } + return; + } + + //前叉浅货位有货 + if (front_Zerror == 16) { + //先解警 + //重新下发取放货点位信息 + if (!againRequireSuccess) { + //判断是取货阻挡还是放货阻挡 + //取货阻挡 + if (this.front_command == 1) { + List keys = Arrays.asList(ItemProtocol.TO_Z.getKey(), ItemProtocol.TO_X.getKey(), ItemProtocol.TO_Y.getKey(), ItemProtocol.TO_FRONT_TASK.getKey(), ItemProtocol.TO_CHOOSE_FORK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(3, 18, 6, this.front_task, SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()); + this.writing(ItemProtocol.TO_COMMAND.getKey(), 5); + this.writing(keys, values); + this.againRequireSuccess = true; + } + //放货阻挡 + else if (this.front_command == 3) { + List keys = Arrays.asList(ItemProtocol.TO_Z.getKey(), ItemProtocol.TO_X.getKey(), ItemProtocol.TO_Y.getKey(), ItemProtocol.TO_FRONT_TASK.getKey(), ItemProtocol.TO_CHOOSE_FORK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(3, 22, 6, this.front_task, SendSignalEnum.CHOOSE_FORK_ONE.getSignalNum(), SendSignalEnum.COMMAND_TWO.getSignalNum()); + this.writing(ItemProtocol.TO_COMMAND.getKey(), 5); + this.writing(keys, values); + this.againRequireSuccess = true; + } + } + return; + } + //后叉前货位有货 + else if (back_Zerror == 16) { + //先解警 + //重新下发取放货点位信息 + if (!againRequireSuccess) { + //判断是取货阻挡还是放货阻挡 + //取货阻挡 + if (this.back_command == 1) { + List keys = Arrays.asList(ItemProtocol.TO_Z.getKey(), ItemProtocol.TO_X.getKey(), ItemProtocol.TO_Y.getKey(), ItemProtocol.TO_BACK_TASK.getKey(), ItemProtocol.TO_CHOOSE_FORK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(3, 50, 2, this.front_task, SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()); + this.writing(ItemProtocol.TO_COMMAND.getKey(), 5); + this.writing(keys, values); + this.againRequireSuccess = true; + } + //放货阻挡 + else if (this.back_command == 3) { + List keys = Arrays.asList(ItemProtocol.TO_Z.getKey(), ItemProtocol.TO_X.getKey(), ItemProtocol.TO_Y.getKey(), ItemProtocol.TO_BACK_TASK.getKey(), ItemProtocol.TO_CHOOSE_FORK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(3, 60, 2, this.back_task, SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_TWO.getSignalNum()); + this.writing(ItemProtocol.TO_COMMAND.getKey(), 5); + this.writing(keys, values); + this.againRequireSuccess = true; + } + } + return; + } + this.updateInstStatus(); + if (!this.online) { this.message = "设备离线"; } else if (this.mode != ModeEnum.MODE_3.getNum()) { @@ -407,10 +529,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (ObjectUtil.isEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) { if (this.to_command != 0) { this.writing(ItemProtocol.TO_COMMAND.getKey(), 0); + Thread.sleep(1000); } this.applyTask(); } else { this.sendPutInfoToPlc(frontInst, backInst); + this.requireSuccess = true; } } //取货中 diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index e00483b..b6def5e 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -1,5 +1,6 @@ package org.nl.acs.ext.wms.service.impl; +import cn.hutool.core.lang.Assert; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -10,6 +11,9 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device.domain.Device; +import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor.AppearanceInspectionScannerConveyorDeviceDriver; +import org.nl.acs.device.driver.conveyor.strip_conveyor.StripConveyorDeviceDriver; import org.nl.acs.ext.wms.data.*; import org.nl.acs.ext.wms.service.AcsToLiKuService; @@ -20,6 +24,7 @@ import org.nl.acs.storage_cell.domain.StorageCell; import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; import org.nl.config.SpringContextHolder; import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.system.service.param.ISysParamService; @@ -29,6 +34,7 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; +import java.util.Optional; @Service @RequiredArgsConstructor @@ -354,4 +360,97 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { return null; } + @Override + public JSONObject switchInOut(JSONObject reqs) { + Assert.notNull(reqs); + String device_code = reqs.getString("device_code"); + if (StrUtil.isBlank(device_code)) { + throw new BadRequestException("设备号不能为空!"); + } + String type = reqs.getString("type"); + if (StrUtil.isBlank(type)) { + throw new BadRequestException("出入库类型不能为空!"); + } + Device device = deviceAppService.findDeviceByCode(device_code); + String belongToConveyorDeviceCode = Optional.ofNullable(device.getExtraValue().get("belongToConveyor")).map(Object::toString).orElse(null); + Device belongToConveyorDevice = deviceAppService.findDeviceByCode(belongToConveyorDeviceCode); + if (belongToConveyorDevice != null && belongToConveyorDevice.getDeviceDriver() instanceof StripConveyorDeviceDriver) { + StripConveyorDeviceDriver stripConveyorDeviceDriver = (StripConveyorDeviceDriver) belongToConveyorDevice.getDeviceDriver(); + //切换为入库 + if ("1".equals(type)) { + String samePoint = Optional.ofNullable(device.getExtraValue().get("samePoint")).map(Object::toString).orElse(null); + TaskDto taskDto; + if (StrUtil.isNotEmpty(samePoint)) { + taskDto = taskserver.findByNextCode(samePoint); + } else { + taskDto = taskserver.findByNextCode(device_code); + } + if (ObjectUtil.isNotEmpty(taskDto)) { + throw new BadRequestException("ACS存在出库任务,无法切换为入库模式"); + } + if (stripConveyorDeviceDriver.getInOutMode() == 0) { + throw new BadRequestException("已经是入库模式,无法再次切换为入库模式"); + } else { + if (stripConveyorDeviceDriver.getSwitchInOut() == 0) { + throw new BadRequestException("输送线不允许切换为入库模式"); + } + } + stripConveyorDeviceDriver.writing("toCommand", 0); + } + //切换为出库 + else if ("2".equals(type)) { + String samePoint = Optional.ofNullable(device.getExtraValue().get("samePoint")).map(Object::toString).orElse(null); + TaskDto taskDto; + if (StrUtil.isNotEmpty(samePoint)) { + taskDto = taskserver.findByStartCode(samePoint); + } else { + taskDto = taskserver.findByStartCode(device_code); + } + if (ObjectUtil.isNotEmpty(taskDto)) { + throw new BadRequestException("ACS存在入库任务,无法切换为出库模式"); + } + if (stripConveyorDeviceDriver.getInOutMode() == 1) { + throw new BadRequestException("已经是出库模式,无法再次切换为出库模式"); + } else { + if (stripConveyorDeviceDriver.getSwitchInOut() == 0) { + throw new BadRequestException("输送线不允许切换为出库模式"); + } + } + stripConveyorDeviceDriver.writing("toCommand", 1); + } + } + JSONObject resp = new JSONObject(); + resp.put("status", 200); + resp.put("message", "切换出入库模式成功"); + return null; + } + + @Override + public JSONObject pinkStartStop(JSONObject reqs) { + Assert.notNull(reqs); + JSONObject resp = new JSONObject(); + String device_code = reqs.getString("device_code"); + if (StrUtil.isBlank(device_code)) { + throw new BadRequestException("设备号不能为空!"); + } + String type = reqs.getString("type"); + if (StrUtil.isEmpty(type)) { + throw new BadRequestException("启停类型不能为空!"); + } + Device device = deviceAppService.findDeviceByCode(device_code); + if (device != null && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { + AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) device.getDeviceDriver(); + if ("1".equals(type)) { + appearanceInspectionScannerConveyorDeviceDriver.writing("mode", 2); + } else { + appearanceInspectionScannerConveyorDeviceDriver.writing("mode", 0); + } + } else { + throw new BadRequestException("设备不存在"); + } + resp.put("status", 200); + resp.put("message", "切换成功"); + return resp; + } + } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/config/mqtt2/MqttService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/config/mqtt2/MqttService.java index 1e5dadf..08e65b0 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/config/mqtt2/MqttService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/config/mqtt2/MqttService.java @@ -222,7 +222,7 @@ public class MqttService { topicMap.get(topic).add(payload); System.out.println("接收到消息---" + topic + "内容:" + payload); } else { - log.info("topic---{} does not exist", topic); + log.info("topic---{} , payload----{} ", topic, payload); } } diff --git a/nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue b/nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue index 10da301..04804fa 100644 --- a/nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue +++ b/nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue @@ -65,103 +65,255 @@ - - - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + - - - - - + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -198,7 +350,6 @@ size="small" style="width: 100%;margin-bottom: 15px" > - @@ -334,7 +485,19 @@ export default { address: '', cacheDeviceCode: '', pinkDeviceCode: '', - checkoutStartDeviceCode: null + checkoutStartDeviceCode: null, + targetDeviceCode: null, + stackerDock: false, + stackerDoubleTask: false, + conveyorStartPoint: false, + linkPinkDevice: false, + conveyorEndPoint: false, + conveyorCachePoint: false, + pinkDevicePoint: false, + toWay: false, + belongToConveyor: null, + linkInOutDevice: '', + samePoint: false }, rules: {} } diff --git a/nladmin-ui/src/views/acs/device/index.vue b/nladmin-ui/src/views/acs/device/index.vue index b2b9686..cbfcce8 100644 --- a/nladmin-ui/src/views/acs/device/index.vue +++ b/nladmin-ui/src/views/acs/device/index.vue @@ -160,7 +160,7 @@ - +