From e450c3de95f2a019aac40748c78600e01ab93bf2 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Mon, 5 Jun 2023 18:26:39 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=8F=8D=E9=A6=88=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agv/server/impl/NDCAgvServiceImpl.java | 5 +- .../run/OneNDCSocketConnectionAutoRun.java | 4 +- .../agv/ndcone/AgvNdcOneDeviceDriver.java | 33 ++++++++ .../service/impl/InstructionServiceImpl.java | 20 +---- .../task/service/impl/TaskServiceImpl.java | 20 ++--- .../nl/modules/quartz/task/ToAgvDevice.java | 83 +++++++++++++------ .../main/resources/config/application-dev.yml | 4 +- .../resources/config/application-prod.yml | 2 +- .../src/main/resources/config/application.yml | 2 +- 9 files changed, 110 insertions(+), 63 deletions(-) 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 9060072..ad71a28 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 @@ -65,7 +65,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { }; log.info("下发删除AGV指令--{}", Bytes2HexString(b)); -// NDCSocketConnectionAutoRun.write(b); + OneNDCSocketConnectionAutoRun.write(b); System.out.println("下发删除agv指令数据:" + Bytes2HexString(b)); } @@ -146,6 +146,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { (byte) fhghigh, (byte) fhglow }; log.info("下发AGV作业指令--{}", str1); + log.info("下发agv指令数据{}" ,Bytes2HexString(b)); OneNDCSocketConnectionAutoRun.write(b); System.out.println("下发agv指令数据:" + Bytes2HexString(b)); } @@ -167,7 +168,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { (byte) 0X00, (byte) 0X6D, (byte) 0X00, (byte) 0X06, (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, + (byte) 0X01, (byte) 0X14, (byte) phasehigh, (byte) phaselow }; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index e1fa800..a7683ae 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -187,8 +187,8 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } else { //上报异常信息 //(不需要WCS反馈) - if (phase == 0x67) { - device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); + if (phase == 0x67 || phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74 ) { + device = deviceAppService.findDeviceByCode(Integer.toString(arr[18] * 256 + arr[19])); } else { device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); } 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 f7249b7..16b0fdc 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 @@ -379,6 +379,39 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } else if (phase == 0x51) {//离开交通灯区域 data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + } else if (phase == 0x67) {//agv异常 +// if (ikey == 0) { +// this.setErrorInfo(ikey, "0", "正常"); +// } else { +// Map error = ErrorUtil.getAgvErrorMsg(ikey); +// String code = error.get("code"); +// String info = error.get("info"); +// this.setErrorInfo(ikey, code, info); +// } +// if (error != last_error) { +// DeviceErrorLogDto dto = new DeviceErrorLogDto(); +// dto.setDevice_code(this.getDevice().getDevice_code()); +// dto.setError_code(String.valueOf(error_code)); +// dto.setError_info(error_message); +// deviceErrorLogService.create(dto); +// } + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + last_error = error; + } else if (phase == 0x70) { + //x坐标 + x = ikey; + } else if (phase == 0x71) { + //y坐标 + y = ikey; + } else if (phase == 0x72) { + //车辆角度 + angle = ikey; + } else if (phase == 0x73) { + //agv电量 + electric_qty = ikey; + } else if (phase == 0x74) { + //三色灯状态 + status = ikey; } if (!ObjectUtil.isEmpty(data)) { logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); 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 25c5d0b..27fdc1e 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 @@ -360,22 +360,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu if (ObjectUtil.isEmpty(route)) { throw new BadRequestException("未查询到相关路由!"); } - if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) { - // 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统 - if (!StrUtil.equals(task.getAgv_system_type(), "0") - && ObjectUtil.isNotEmpty(task.getAgv_system_type())) { - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); - } else { - // Boolean result = createLkInst(task.getStorage_task_type(),dto); - Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(), dto); - if (StrUtil.equals(resp.result, "true")) { - dto.setSend_status("1"); - } else { - dto.setSend_status("2"); - } - } - } + NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); + ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); + + } catch (Exception e) { dto.setSend_status("2"); e.printStackTrace(); 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 e5f42b2..af8143b 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 @@ -445,6 +445,12 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { task_code = CodeUtil.getNewCode("TASK_NO"); task_code = "-" + task_code; } + if(ObjectUtil.isEmpty(dto.getStart_height())){ + dto.setStart_height("0"); + } + if(ObjectUtil.isEmpty(dto.getNext_height())){ + dto.setNext_height("0"); + } String start_point_code = dto.getStart_point_code(); String next_point_code = dto.getNext_point_code(); String start_device_code = dto.getStart_device_code(); @@ -492,15 +498,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) { - // if (nextdevice.getDeviceDriver() instanceof - // StandardOrdinarySiteDeviceDriver) { - // standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) - // nextdevice.getDeviceDriver(); - // if (nextdevice.getHas_goods() != 0) { - // throw new Exception("任务终点需满足无货!"); - // } - // } - JSONObject jo = new JSONObject(); JSONObject jo2 = new JSONObject(); if (!StrUtil.isEmpty(dto.getMaterial())) { @@ -538,12 +535,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { wo.insert(json); synchronized (TaskServiceImpl.class) { - System.out.println("-------------------" + dto.getTask_code()); - System.out.println("-------------1" + tasks.size()); - tasks.add(dto); - System.out.println("-------------2" + tasks.size()); - } } diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java index 76f136c..0c2c606 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java @@ -36,41 +36,74 @@ public class ToAgvDevice { for (AgvDto agvDto : agv_map.values()) { row.put("device_code", agvDto.getName()); row.put("energyLevel", agvDto.getEnergyLevel()); - if (agvDto.getState().equals("UNKNOWN")) { +// 车状态: +// 1:关机 +// 2:运行中 +// 3:交通管制 +// 4:任务等待 +// 5:充电中 +// 6:故障中 +// 7:低电量 + if (agvDto.getState().equals("1")) { + row.put("device_status", "UNKNOWN"); + row.put("status_name", "关机"); + } else if (agvDto.getState().equals("2")) { + row.put("device_status", "EXECUTING"); row.put("status_name", "有任务"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("UNAVAILABLE")) { - row.put("status_name", "网络异常"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("ERROR")) { - row.put("status_name", "机器错误"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("IDLE")) { + } else if (agvDto.getState().equals("3")) { +// row.put("device_status", "EXECUTING"); +// row.put("status_name", "交通管制"); + } else if (agvDto.getState().equals("4")) { + row.put("device_status", "IDLE"); row.put("status_name", "空闲"); - row.put("flag", "0"); - } - if (agvDto.getState().equals("EXECUTING")) { - row.put("status_name", "运行中"); - row.put("flag", "0"); - } - if (agvDto.getState().equals("CHARGING")) { - row.put("status_name", "充电中"); - row.put("flag", "0"); + } else if (agvDto.getState().equals("5")) { + row.put("device_status", "CHARGING"); + row.put("status_name", "充电"); + } else if (agvDto.getState().equals("6")) { + row.put("device_status", "ERROR"); + row.put("status_name", "故障"); + } else if (agvDto.getState().equals("7")) { +// row.put("device_status", "ERROR"); +// row.put("status_name", "低电量"); } + + +// if (agvDto.getState().equals("UNKNOWN")) { +// row.put("status_name", "有任务"); +// row.put("status_name", "有任务"); +// row.put("flag", "1"); +// } +// if (agvDto.getState().equals("UNAVAILABLE")) { +// row.put("status_name", "网络异常"); +// row.put("flag", "1"); +// } +// if (agvDto.getState().equals("ERROR")) { +// row.put("status_name", "机器错误"); +// row.put("flag", "1"); +// } +// if (agvDto.getState().equals("IDLE")) { +// row.put("status_name", "空闲"); +// row.put("flag", "0"); +// } +// if (agvDto.getState().equals("EXECUTING")) { +// row.put("status_name", "运行中"); +// row.put("flag", "0"); +// } +// if (agvDto.getState().equals("CHARGING")) { +// row.put("status_name", "充电中"); +// row.put("flag", "0"); +// } row.put("transportOrder", agvDto.getTransportOrder()); row.put("positionX", agvDto.getPositionX()); row.put("positionY", agvDto.getPositionY()); row.put("positionAngle", agvDto.getPositionAngle()); agv_rows.add(row); } - json.put("agv_rows", agv_rows); - SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO); - WebSocketServer.sendInfo(deviceInfo, "toAgvDevice_data"); +// json.put("agv_rows", agv_rows); +// SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO); +// WebSocketServer.sendInfo(deviceInfo, "toAgvDevice_data"); - // acsToWmsService.feedbackAgv(row); + acsToWmsService.feedbackAgv(agv_rows); } } diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index d135cf0..95893cb 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -13,11 +13,11 @@ spring: driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy # url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:wzgj_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:weidaqi}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true username: ${DB_USER:root} # password: ${DB_PWD:P@ssw0rd} # password: ${DB_PWD:Root.123456} - password: ${DB_PWD:password} + password: ${DB_PWD:123456} # 初始连接数 initial-size: 5 diff --git a/acs/nladmin-system/src/main/resources/config/application-prod.yml b/acs/nladmin-system/src/main/resources/config/application-prod.yml index e22d641..b299bff 100644 --- a/acs/nladmin-system/src/main/resources/config/application-prod.yml +++ b/acs/nladmin-system/src/main/resources/config/application-prod.yml @@ -11,7 +11,7 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:weidaqi}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true username: ${DB_USER:root} password: ${DB_PWD:123456} # 初始连接数 diff --git a/acs/nladmin-system/src/main/resources/config/application.yml b/acs/nladmin-system/src/main/resources/config/application.yml index f943602..cfc52fe 100644 --- a/acs/nladmin-system/src/main/resources/config/application.yml +++ b/acs/nladmin-system/src/main/resources/config/application.yml @@ -2,7 +2,7 @@ spring: freemarker: check-template-location: false profiles: - active: dev + active: prod jackson: time-zone: GMT+8 data: