From c9dd732db0c5d0eb4bbbfcf740dd03b704c0bd2f Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Thu, 28 Mar 2024 16:57:57 +0800 Subject: [PATCH] =?UTF-8?q?rev:=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/agv/server/NDCAgvService.java | 2 ++ .../agv/server/impl/NDCAgvServiceImpl.java | 30 ++++++++++++++++++ .../agv/ndcone/AgvNdcOneDeviceDriver.java | 20 ++++++------ .../acs/ext/wms/rest/WmsToAcsController.java | 8 +++++ .../acs/ext/wms/service/WmsToAcsService.java | 1 + .../wms/service/impl/WmsToAcsServiceImpl.java | 31 +++++++++++++++++-- .../service/impl/InstructionServiceImpl.java | 3 ++ .../task/service/impl/TaskServiceImpl.java | 12 ++++--- 8 files changed, 89 insertions(+), 18 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index abc3185..60dc5cf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -40,4 +40,6 @@ public interface NDCAgvService { * @return */ public boolean createChargingTaskToNDC(String carno); + + public boolean deviceOption(String option); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index b6abb27..f1bc4cf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -16,6 +16,7 @@ import org.nl.acs.log.LokiLogType; import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.system.service.ParamService; import org.nl.modules.system.util.CodeUtil; import org.nl.modules.wql.util.SpringContextHolder; @@ -228,6 +229,35 @@ public class NDCAgvServiceImpl implements NDCAgvService { return true; } + @Override + public boolean deviceOption(String option) { + byte high; + byte low; + if (option.equals("1")) { + high = (byte) IntToHexHigh(00); + low = (byte) IntToHexHigh(01); + } else if (option.equals("2")) { + high = (byte) IntToHexHigh(00); + low = (byte) IntToHexHigh(00); + } else { + throw new BadRequestException("操作类型有误!"); + } + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0C, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X08, + (byte) 0X32, (byte) 0X80, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X01, + (byte) high, (byte) low + }; + log.info("下发AGV设备暂停恢复--{}", Bytes2HexString(b)); + OneNDCSocketConnectionAutoRun.write(b); + return true; + } + String hexToString(int i) { return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase(); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index cc060e1..49a7266 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -114,9 +114,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (phase == 0x67) { //故障信息 - if (arr[18] * 256 + arr[19] == 0) { + this.error = 0; - } data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); } @@ -159,8 +158,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空"); return; } - if (ObjectUtil.isEmpty(device)){ - log.info(agvaddr + "对应设备号{},对应的设备信息为空!",device_code); + if (ObjectUtil.isEmpty(device)) { + log.info(agvaddr + "对应设备号{},对应的设备信息为空!", device_code); return; } //校验agv上报站点编号与指令起始点相同 @@ -229,8 +228,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); return; } - if (ObjectUtil.isEmpty(device)){ - log.info(agvaddr + "对应设备号{},对应的设备信息为空!",device_code); + if (ObjectUtil.isEmpty(device)) { + log.info(agvaddr + "对应设备号{},对应的设备信息为空!", device_code); return; } //校验agv上报站点编号与指令起始点相同 @@ -298,8 +297,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic log.info(agvaddr + "对应设备号为空!"); return; } - if (ObjectUtil.isEmpty(device)){ - log.info(agvaddr + "对应设备号{},对应的设备信息为空!",device_code); + if (ObjectUtil.isEmpty(device)) { + log.info(agvaddr + "对应设备号{},对应的设备信息为空!", device_code); return; } //校验agv上报站点编号与指令起始点相同 @@ -368,8 +367,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic log.info(agvaddr + "对应设备号为空!"); return; } - if (ObjectUtil.isEmpty(device)){ - log.info(agvaddr + "对应设备号{},对应的设备信息为空!",device_code); + if (ObjectUtil.isEmpty(device)) { + log.info(agvaddr + "对应设备号{},对应的设备信息为空!", device_code); return; } //校验agv上报站点编号与指令起始点相同 @@ -462,6 +461,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic jo.put("positionY", this.getY()); //角度 jo.put("positionAngle", this.getAngle()); + jo.put("errorCode", this.getError()); return jo; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index b3c4f19..5396eb9 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -48,6 +48,14 @@ public class WmsToAcsController { return new ResponseEntity<>(wmstoacsService.cancelFromWms(reqs), HttpStatus.OK); } + @PostMapping("/deviceOption") + @Log(value = "设备暂停恢复",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @ApiOperation("设备暂停恢复") + @SaIgnore + public ResponseEntity deviceOption(@RequestBody JSONObject param) throws Exception { + return new ResponseEntity<>(wmstoacsService.deviceOption(param), HttpStatus.OK); + } + @PostMapping("/updateDeviceGoodsFromWms") @Log(value = "WMS修改点位状态",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) @ApiOperation("WMS修改点位状态") diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index 873bc37..164bb57 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -85,4 +85,5 @@ public interface WmsToAcsService { Map test(); + Map deviceOption(JSONObject param); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 47016f1..fef2fe1 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/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,7 @@ import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; +import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.common.IDriverService; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver; @@ -36,6 +38,7 @@ import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.exception.WDKException; import org.nl.modules.wql.util.SpringContextHolder; import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; @@ -58,6 +61,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { private final DeviceAppService deviceAppService; private final RouteLineService routeLineService; private final AcsToLiKuService acsToLiKuService; + @Autowired + private NDCAgvService ndcAgvService; private String log_file_type = "log_file_type"; @@ -453,9 +458,29 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override public Map test() { System.out.println("进来了......"); - Map map = new HashMap<>(); - map.put("a","a"); - map.put("b","b"); + Map map = new HashMap<>(); + map.put("a", "a"); + map.put("b", "b"); + return map; + } + + @Override + public Map deviceOption(JSONObject param) { + String option = param.getString("option"); + Assert.notBlank(option, "参数不能为空"); + try { + ndcAgvService.deviceOption(option); + } catch (Exception e) { + Map map = new HashMap<>(); + map.put("status", 400); + map.put("message", e.getMessage()); + map.put("data", new JSONObject()); + return map; + } + Map map = new HashMap<>(); + map.put("status", 200); + map.put("message", "操作成功!"); + map.put("data", new JSONObject()); return map; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 97bd083..356b91d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -1070,6 +1070,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } removeByCodeFromCache(entity.getInstruction_code()); + TaskDto taskDto = taskService.findByCodeFromCache(entity.getTask_code()); + taskDto.setTask_status("3"); + taskService.update(taskDto); } @Override diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 72bafcf..d48c6aa 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -1015,11 +1015,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code()); - String type = shortPathsList.get(0).getType(); - // != 0 为agv任务 - if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - agvService.markComplete(entity.getTask_code()); + if (ObjectUtil.isNotEmpty(shortPathsList)){ + String type = shortPathsList.get(0).getType(); + // != 0 为agv任务 + if (!StrUtil.equals(type, "0")) { + if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { + agvService.markComplete(entity.getTask_code()); + } } } }