k 1 рік тому
батько
коміт
7524fd298e

+ 25 - 26
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/AciService.java

@@ -2,6 +2,7 @@ package com.ruoyi.ams.agv.ndc;
 
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.thread.ThreadUtil;
 import com.alibaba.fastjson.JSON;
 import com.ruoyi.ams.agv.ndc.common.Aci;
 import com.ruoyi.ams.agv.ndc.common.ByteUtil;
@@ -141,31 +142,29 @@ public class AciService {
                             continue;
                         }
 //                        try {
-                            String order = amsHexdefineDetailService.concatOrder(t, basTask);
-                            log.info("writeOrder:" + order);
-                            if (t.getBusinessType().equals("m") ||
-                                    t.getBusinessType().equals("01")
-                            ) {
-
-                                buffer.put(ByteUtil.hexString2ByteArray(order));
-                                buffer.flip();
-                                socketChannel.write(buffer);
-                                buffer.clear();
-                                if (DateUtil.between(t.getAddtime(), new Date(), DateUnit.MINUTE) > 2) {
-                                    t.setAciAccept(2);
-                                    t.setRoadway("下发超时2分钟未接收自动取消");
-                                    amsTaskService.updateAmsTask(t);
-                                }
-                            } else {
-                                buffer.put(ByteUtil.hexString2ByteArray(order));
-                                buffer.flip();
-                                socketChannel.write(buffer);
-                                buffer.clear();
-                                // 修改已发送
-                                t.setAciAccept(1);
-                                t.setRoadway("TS请求反馈任务发送成功!");
+                        String order = amsHexdefineDetailService.concatOrder(t, basTask);
+                        log.info("writeOrder:" + order);
+                        if (t.getBusinessType().equals("01")) {
+
+                            buffer.put(ByteUtil.hexString2ByteArray(order));
+                            buffer.flip();
+                            socketChannel.write(buffer);
+                            buffer.clear();
+                            if (DateUtil.between(t.getAddtime(), new Date(), DateUnit.MINUTE) > 2) {
+                                t.setAciAccept(2);
+                                t.setRoadway("下发超时2分钟未接收自动取消");
                                 amsTaskService.updateAmsTask(t);
                             }
+                        } else {
+                            buffer.put(ByteUtil.hexString2ByteArray(order));
+                            buffer.flip();
+                            socketChannel.write(buffer);
+                            buffer.clear();
+                            // 修改已发送
+                            t.setAciAccept(1);
+                            t.setRoadway("TS请求反馈任务发送成功!");
+                            amsTaskService.updateAmsTask(t);
+                        }
 //                        } catch (Exception e) {
 //                            e.printStackTrace();
 //                            t.setServerAck(0);
@@ -220,14 +219,14 @@ public class AciService {
                     e.printStackTrace();
                 }
 
-            }catch (IOException i) {
-                log.error("NDC通讯异常!" ,i);
+            } catch (IOException i) {
+                log.error("NDC通讯异常!", i);
                 try {
                     socketChannel.close();
                 } catch (Exception exception) {
                     i.printStackTrace();
                 }
-            }catch (Exception e) {
+            } catch (Exception e) {
                 e.printStackTrace();
                 try {
                     socketChannel.close();

+ 11 - 5
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/ChargerButtService.java

@@ -95,7 +95,7 @@ public class ChargerButtService {
         /***
          * A
          */
-        A(1, 1),
+        A(1004, 1),
         /***
          * B
          */
@@ -205,7 +205,7 @@ public class ChargerButtService {
 
         // 充电机号
         Integer chargerNo = chargingSite;
-        boolean xx = chargerNo == 2;
+        boolean xx = !(chargerNo == 1004);
         // 从节点ID 充电机根据不同的ip地址区分,从节点地址默认都是1
         Integer slaveId = CHARGING_SLAVEID_MAPPING.getSlaveIdByChargerNo(chargingSite);
         // 确认是否故障
@@ -258,8 +258,8 @@ public class ChargerButtService {
         }
 
         // 充电期间循环充电机状态
-        executorService.execute(new CyclicJudgmentOfChargerStatus(wcsTaskService, amsTaskService,
-                this, feedbackTS, chargingMachineClient, index, chargingSite, slaveId, agvNo, taskNo, xx));
+//        executorService.execute(new CyclicJudgmentOfChargerStatus(wcsTaskService, amsTaskService,
+//                this, feedbackTS, chargingMachineClient, index, chargingSite, slaveId, agvNo, taskNo, xx));
     }
 
     /**
@@ -282,7 +282,7 @@ public class ChargerButtService {
         WcsTask wcsTask = null;
         // 充电机号
         Integer chargerNo = chargingSite;
-        boolean xx = chargerNo == 2;
+        boolean xx = !(chargerNo == 1004);
         // 从节点ID
         Integer slaveId = CHARGING_SLAVEID_MAPPING.getSlaveIdByChargerNo(chargingSite);
         // 从Redis拿到充电信息
@@ -348,6 +348,12 @@ public class ChargerButtService {
             wcsTask.setExt4("1");
             wcsTaskService.updateWcsTask(wcsTask);
         }
+        // 设置Redis充电状态为停止
+        Map<String, Object> agvInfoMapU = redisCache.getCacheMap(KEY_PREFIX + agvNo);
+        if (agvInfoMapU != null) {
+            agvInfoMapU.put(KEY_AGV_STS, AGV_CHARGING_STS.STOP.toString());
+            redisCache.setCacheMap(KEY_PREFIX + agvNo, agvInfoMapU);
+        }
     }
 
     /**

+ 5 - 5
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/FeedbackTS.java

@@ -28,19 +28,19 @@ public class FeedbackTS {
         /***
          * 让AGV退出充电点并重进
          */
-        RE_ENTRY("1", "0001"),
+        RE_ENTRY("01", "0001"),
         /***
          * 充电机故障
          */
-        FAULT("1", "0002"),
+        FAULT("01", "0002"),
         /***
          * 正常充电
          */
-        NORMAL("1", "0003"),
+        NORMAL("01", "0003"),
         /***
          * 结束充电
          */
-        AGV_STOP("1", "0004");
+        AGV_STOP("01", "0004");
 
         private String address;
         private String value;
@@ -114,7 +114,7 @@ public class FeedbackTS {
         addTaskForm.setPriority(1);
         addTaskForm.setRemark(taskNo);
         // 固定写法
-        addTaskForm.setExt2(agvNo.toString());
+        addTaskForm.setExt2("0" + agvNo.toString());
         addTaskForm.setExt3("0004");
 
         // 如果ams_task已经有此任务的待接收消息,则不生成新的消息

+ 3 - 2
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/impl/SocketBufferServiceImpl.java

@@ -319,8 +319,9 @@ public class SocketBufferServiceImpl implements SocketBufferService {
 
                     // 存放当前充电车号和index,充电桩号对应关系
                     Map<String, Object> agvParamsMap = redisCache.getCacheMap(KEY_PREFIX + agvNo200);
-                    if (agvParamsMap == null
-                            || !agvParamsMap.get(KEY_AGV_INDEX).equals(index200) || !agvParamsMap.get(KEY_CHARGING_SITE).equals(chargingSite200)) {
+                    if (agvParamsMap == null || agvParamsMap.get(KEY_AGV_INDEX) == null || agvParamsMap.get(KEY_CHARGING_SITE) == null
+                            || !agvParamsMap.get(KEY_AGV_INDEX).equals(index200)
+                            || !agvParamsMap.get(KEY_CHARGING_SITE).equals(chargingSite200)) {
                         Map<String, Object> chargingMap = new HashMap<>();
                         chargingMap.put(KEY_CHARGING_SITE, chargingSite200);
                         chargingMap.put(KEY_AGV_INDEX, index200);

+ 2 - 2
warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java

@@ -192,10 +192,10 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         wcsTask.setCreateDate(new Date());
         wcsTask.setCreateUser("TS");
         int i = wcsTaskService.insertWcsTask(wcsTask);
-        if (i<=0) {
+        if (i <= 0) {
             return AjaxResult.error("生成充电WcsTask任务失败!");
         }
-        return AjaxResult.success(taskNo);
+        return AjaxResult.success("", taskNo);
     }
 
     /**