Browse Source

按钮盒:
(1)裹膜区 -> 仓储区
(2)硫酸镍废料下线
(3)氯化镍废料下线
(4)硫酸镍废料退空

k 1 year ago
parent
commit
3ef2518895

+ 35 - 2
ruoyi-admin/src/main/java/com/ruoyi/init/StartService.java

@@ -2,8 +2,7 @@ package com.ruoyi.init;
 
 import com.ruoyi.ams.agv.ndc.AciService;
 import com.ruoyi.ams.agv.ndc.config.InitTaskConfig;
-import com.ruoyi.ams.agv.ndc.thread.AciServiceThread;
-import com.ruoyi.ams.agv.ndc.thread.AutoTaskThread;
+import com.ruoyi.ams.agv.ndc.thread.*;
 import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import lombok.extern.slf4j.Slf4j;
@@ -23,6 +22,15 @@ public class StartService implements CommandLineRunner {
     private AciService aciService;
     @Autowired
     private IBaseLocationInfoService baseLocationInfoService;
+    @Autowired
+    private AutoButtonBoxTask autoButtonBoxTask;
+    @Autowired
+    private AutoButtonBoxTask01 autoButtonBoxTask01;
+    @Autowired
+    private AutoButtonBoxTask02 autoButtonBoxTask02;
+    @Autowired
+    private AutoButtonBoxTask03 autoButtonBoxTask03;
+
 
     @Override
     public void run(String... args) throws Exception {
@@ -38,4 +46,29 @@ public class StartService implements CommandLineRunner {
             thread.start();
         }
     }
+
+    /**
+     * 自动按钮盒监控任务 - 裹膜区 -> 仓储区
+     */
+    public void autoButtonBoxTask() {
+        autoButtonBoxTask.run();
+    }
+    /**
+     * 自动按钮盒监控任务 - 硫酸镍废料下线
+     */
+    public void autoButtonBoxTask01() {
+        autoButtonBoxTask01.run();
+    }
+    /**
+     * 自动按钮盒监控任务 - 氯化镍废料下线
+     */
+    public void autoButtonBoxTask02() {
+        autoButtonBoxTask02.run();
+    }
+    /**
+     * 自动按钮盒监控任务 - 硫酸镍废料退空
+     */
+    public void autoButtonBoxTask03() {
+        autoButtonBoxTask03.run();
+    }
 }

+ 42 - 87
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/thread/AutoButtonBoxTask.java

@@ -1,19 +1,12 @@
 package com.ruoyi.ams.agv.ndc.thread;
 
-import com.ruoyi.ams.business.IBusinessService;
-import com.ruoyi.ams.config.domain.dto.AgvCallDTO;
-import com.ruoyi.ams.config.domain.dto.AgvCallItemDTO;
-import com.ruoyi.ams.config.domain.dto.LotattDTO;
-import com.ruoyi.base.constant.Constant;
+import com.ruoyi.ams.nieyan.service.AgvCallProxyService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.hard.modbus.tcp.ButtonBoxClient;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.List;
-
 @Slf4j
 @Service
 public class AutoButtonBoxTask {
@@ -21,90 +14,52 @@ public class AutoButtonBoxTask {
     @Autowired(required = false)
     private ButtonBoxClient buttonBoxClient;
     @Autowired
-    private IBusinessService businessService;
-
+    private AgvCallProxyService agvCallProxyService;
+    // 裹膜区库位id
+    public static final String FILM_WRAPPING_AREA_POINT = "10639";
 
-    /**
-     * 1.读取按钮是否被按下
-     * 2.根据按下的按钮触发模具搬运任务
-     * 3.任务生成成功,按钮盒灭灯,并且清除按下标记
-     */
     public void run() {
-//        Boolean readBtn01 = buttonBoxClient.readBtn01();
-//        Boolean readBtn02 = buttonBoxClient.readBtn02();
-//        if (readBtn01) {
-//            buttonTask01();
-//        }
-//        if (readBtn02) {
-//            buttonTask02();
-//        }
+
+        ButtonBoxClient.BUTTON_BOX_NO button_box_no = ButtonBoxClient.BUTTON_BOX_NO.A;
+
+        Boolean readBtn01 = buttonBoxClient.readBtn01(button_box_no);
+        Boolean readBtn02 = buttonBoxClient.readBtn02(button_box_no);
+        if (readBtn01) {
+            buttonTask01(button_box_no);
+        }
+        // 两个按钮同时按下,只会生效一个
+        if (!readBtn01 && readBtn02) {
+            buttonTask02(button_box_no);
+        }
     }
 
-    /**
-     * 按钮1业务(冲边任务)
-     */
-    public void buttonTask01() {
-//        log.info("按钮1已经被按下");
-//        // 下发模具搬运任务(冲边)
-//        AgvCallDTO agvCallDTO = new AgvCallDTO();
-//        agvCallDTO.setWarehouseId(Constant.WAREHOUSE_ID);
-//        agvCallDTO.setLocationFrom("");
-//        List<AgvCallItemDTO> agvCallItemDTOList = new ArrayList<>();
-//        AgvCallItemDTO agvCallItemDTO = new AgvCallItemDTO();
-//        agvCallItemDTO.setSku("冲边模具");
-//        LotattDTO lotattDTO = new LotattDTO();
-//        lotattDTO.setLotatt01("冲边模具");
-//        agvCallItemDTO.setLotattDTO(lotattDTO);
-//        agvCallItemDTOList.add(agvCallItemDTO);
-//        agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
-//        AjaxResult ajaxResult = businessService.agvCall(1l, agvCallDTO);
-//        if (!ajaxResult.isSuccess()) {
-//            log.error("下发模具搬运任务(冲边)失败:" + ajaxResult.getMsg());
-//            return;
-//        }
-//        try {
-//            Thread.sleep(10000);
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
-//        }
-//        // 清除按下标记
-//        buttonBoxClient.clearBtn01();
-//        // 灭灯
-//        buttonBoxClient.writeLamp01Death();
-//        log.info("按钮1已经灭灯");
+    public void buttonTask01(ButtonBoxClient.BUTTON_BOX_NO button_box_no) {
+        log.info("裹膜区-按钮1已经被按下");
+        AjaxResult ajaxResult = agvCallProxyService.productsDownLineWrappingFilmLSN(FILM_WRAPPING_AREA_POINT, null
+                , "按钮盒", null);
+        if (!ajaxResult.isSuccess()) {
+            log.info(ajaxResult.getMsg());
+            return;
+        }
+        // 清除按下标记
+        buttonBoxClient.clearBtn01(button_box_no);
+        // 灭灯
+        buttonBoxClient.writeLamp01Death(button_box_no);
+        log.info("裹膜区-按钮1已经灭灯");
     }
 
-    /**
-     * 按钮2业务(硫化任务)
-     */
-    public void buttonTask02() {
-//        log.info("按钮2已经被按下");
-//        // 下发模具搬运任务(硫化)
-//        AgvCallDTO agvCallDTO = new AgvCallDTO();
-//        agvCallDTO.setWarehouseId(Constant.WAREHOUSE_ID);
-//        agvCallDTO.setLocationFrom("");
-//        List<AgvCallItemDTO> agvCallItemDTOList = new ArrayList<>();
-//        AgvCallItemDTO agvCallItemDTO = new AgvCallItemDTO();
-//        agvCallItemDTO.setSku("硫化模具");
-//        LotattDTO lotattDTO = new LotattDTO();
-//        lotattDTO.setLotatt01("硫化模具");
-//        agvCallItemDTO.setLotattDTO(lotattDTO);
-//        agvCallItemDTOList.add(agvCallItemDTO);
-//        agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
-//        AjaxResult ajaxResult = businessService.agvCall(1l, agvCallDTO);
-//        if (!ajaxResult.isSuccess()) {
-//            log.error("下发模具搬运任务(硫化)失败:" + ajaxResult.getMsg());
-//            return;
-//        }
-//        try {
-//            Thread.sleep(10000);
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
-//        }
-//        // 清除按下标记
-//        buttonBoxClient.clearBtn02();
-//        // 灭灯
-//        buttonBoxClient.writeLamp02Death();
-//        log.info("按钮2已经灭灯");
+    public void buttonTask02(ButtonBoxClient.BUTTON_BOX_NO button_box_no) {
+        log.info("裹膜区-按钮2已经被按下");
+        AjaxResult ajaxResult = agvCallProxyService.productsDownLineWrappingFilmLHN(FILM_WRAPPING_AREA_POINT, null
+                , "按钮盒", null);
+        if (!ajaxResult.isSuccess()) {
+            log.info(ajaxResult.getMsg());
+            return;
+        }
+        // 清除按下标记
+        buttonBoxClient.clearBtn02(button_box_no);
+        // 灭灯
+        buttonBoxClient.writeLamp02Death(button_box_no);
+        log.info("裹膜区-按钮2已经灭灯");
     }
 }

+ 54 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/thread/AutoButtonBoxTask01.java

@@ -0,0 +1,54 @@
+package com.ruoyi.ams.agv.ndc.thread;
+
+import com.ruoyi.ams.nieyan.service.AgvCallProxyService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.hard.modbus.tcp.ButtonBoxClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class AutoButtonBoxTask01 {
+
+    @Autowired(required = false)
+    private ButtonBoxClient buttonBoxClient;
+    @Autowired
+    private AgvCallProxyService agvCallProxyService;
+    // 硫酸镍废料下线库位id
+    public static final String LSN_FL_POINT = "10386";
+
+    public void run() {
+
+        ButtonBoxClient.BUTTON_BOX_NO button_box_no = ButtonBoxClient.BUTTON_BOX_NO.B;
+
+        Boolean readBtn01 = buttonBoxClient.readBtn01(button_box_no);
+        Boolean readBtn02 = buttonBoxClient.readBtn02(button_box_no);
+        if (readBtn01) {
+            buttonTask01(button_box_no);
+        }
+        // 两个按钮同时按下,只会生效一个
+        if (!readBtn01 && readBtn02) {
+            buttonTask02(button_box_no);
+        }
+    }
+
+    public void buttonTask01(ButtonBoxClient.BUTTON_BOX_NO button_box_no) {
+        log.info("硫酸镍废料-按钮已经被按下");
+        AjaxResult ajaxResult = agvCallProxyService.accessoriesHandlingLSN(LSN_FL_POINT, null
+                , "按钮盒");
+        if (!ajaxResult.isSuccess()) {
+            log.info(ajaxResult.getMsg());
+            return;
+        }
+        // 清除按下标记
+        buttonBoxClient.clearBtn01(button_box_no);
+        // 灭灯
+        buttonBoxClient.writeLamp01Death(button_box_no);
+        log.info("硫酸镍废料-按钮已经灭灯");
+    }
+
+    public void buttonTask02(ButtonBoxClient.BUTTON_BOX_NO button_box_no) {
+        this.buttonTask01(button_box_no);
+    }
+}

+ 54 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/thread/AutoButtonBoxTask02.java

@@ -0,0 +1,54 @@
+package com.ruoyi.ams.agv.ndc.thread;
+
+import com.ruoyi.ams.nieyan.service.AgvCallProxyService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.hard.modbus.tcp.ButtonBoxClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class AutoButtonBoxTask02 {
+
+    @Autowired(required = false)
+    private ButtonBoxClient buttonBoxClient;
+    @Autowired
+    private AgvCallProxyService agvCallProxyService;
+    // 氯化镍废料下线库位id
+    public static final String LHN_FL_POINT = "10390";
+
+    public void run() {
+
+        ButtonBoxClient.BUTTON_BOX_NO button_box_no = ButtonBoxClient.BUTTON_BOX_NO.C;
+
+        Boolean readBtn01 = buttonBoxClient.readBtn01(button_box_no);
+        Boolean readBtn02 = buttonBoxClient.readBtn02(button_box_no);
+        if (readBtn01) {
+            buttonTask01(button_box_no);
+        }
+        // 两个按钮同时按下,只会生效一个
+        if (!readBtn01 && readBtn02) {
+            buttonTask02(button_box_no);
+        }
+    }
+
+    public void buttonTask01(ButtonBoxClient.BUTTON_BOX_NO button_box_no) {
+        log.info("氯化镍废料-按钮已经被按下");
+        AjaxResult ajaxResult = agvCallProxyService.accessoriesHandlingLHN(LHN_FL_POINT, null
+                , "按钮盒");
+        if (!ajaxResult.isSuccess()) {
+            log.info(ajaxResult.getMsg());
+            return;
+        }
+        // 清除按下标记
+        buttonBoxClient.clearBtn01(button_box_no);
+        // 灭灯
+        buttonBoxClient.writeLamp01Death(button_box_no);
+        log.info("氯化镍废料-按钮已经灭灯");
+    }
+
+    public void buttonTask02(ButtonBoxClient.BUTTON_BOX_NO button_box_no) {
+        this.buttonTask01(button_box_no);
+    }
+}

+ 54 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/thread/AutoButtonBoxTask03.java

@@ -0,0 +1,54 @@
+package com.ruoyi.ams.agv.ndc.thread;
+
+import com.ruoyi.ams.nieyan.service.AgvCallProxyService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.hard.modbus.tcp.ButtonBoxClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class AutoButtonBoxTask03 {
+
+    @Autowired(required = false)
+    private ButtonBoxClient buttonBoxClient;
+    @Autowired
+    private AgvCallProxyService agvCallProxyService;
+    // 硫酸镍废料下线库位id
+    public static final String LSN_FL_R_POINT = "10387";
+
+    public void run() {
+
+        ButtonBoxClient.BUTTON_BOX_NO button_box_no = ButtonBoxClient.BUTTON_BOX_NO.D;
+
+        Boolean readBtn01 = buttonBoxClient.readBtn01(button_box_no);
+        Boolean readBtn02 = buttonBoxClient.readBtn02(button_box_no);
+        if (readBtn01) {
+            buttonTask01(button_box_no);
+        }
+        // 两个按钮同时按下,只会生效一个
+        if (!readBtn01 && readBtn02) {
+            buttonTask02(button_box_no);
+        }
+    }
+
+    public void buttonTask01(ButtonBoxClient.BUTTON_BOX_NO button_box_no) {
+        log.info("硫酸镍废料退空-按钮已经被按下");
+        AjaxResult ajaxResult = agvCallProxyService.accessoriesReturnEmptyLSN(LSN_FL_R_POINT, null
+                , "按钮盒");
+        if (!ajaxResult.isSuccess()) {
+            log.info(ajaxResult.getMsg());
+            return;
+        }
+        // 清除按下标记
+        buttonBoxClient.clearBtn01(button_box_no);
+        // 灭灯
+        buttonBoxClient.writeLamp01Death(button_box_no);
+        log.info("硫酸镍废料退空-按钮已经灭灯");
+    }
+
+    public void buttonTask02(ButtonBoxClient.BUTTON_BOX_NO button_box_no) {
+        this.buttonTask01(button_box_no);
+    }
+}

+ 36 - 3
warewms-ams/src/main/java/com/ruoyi/ams/nieyan/service/AgvCallProxyService.java

@@ -209,6 +209,10 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        // 增加硫酸镍标识
+        for (AgvCallItemDTO agvCallItemDTO : agvCallItemDTOList) {
+            agvCallItemDTO.getLotattDTO().setLotatt18("Y"); //是否硫酸镍,Y代表否
+        }
         return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.EIGHT.getValue(), agvCallDTO);
     }
 
@@ -245,6 +249,8 @@ public class AgvCallProxyService {
      */
     public AjaxResult productsDownLineWrappingFilmLSN(String locationFrom, String locationTo, String createUser
             , Boolean theWeighing) {
+        // 是否硫酸镍
+        Boolean isLSN = true;
         // 查出裹膜位的库存
         List<InvLotLocIdLotattVO> invLotLocIdLotattVOList = invLotLocIdService.selectInvLocIdLotattByLocationId(Long.valueOf(locationFrom));
         if (invLotLocIdLotattVOList.size() > 0) {
@@ -255,6 +261,11 @@ public class AgvCallProxyService {
             }else {
                 theWeighing = false;
             }
+            // 判断下料是否为硫酸镍
+            if (invLotLocIdLotattVO.getLotatt18() != null
+                    && invLotLocIdLotattVO.getLotatt18().equals(Constant.IS_YES.N.name())) {
+                isLSN = false;
+            }
         }else {
             return AjaxResult.error("裹膜点无货!");
         }
@@ -263,7 +274,13 @@ public class AgvCallProxyService {
         agvCallDTO.setLocationTo(locationTo);
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
-        return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.TEN.getValue(), agvCallDTO);
+        if (isLSN) {
+            // 硫酸镍
+            return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.TEN.getValue(), agvCallDTO);
+        }else {
+            // 氯化镍
+            return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.THIRTEEN.getValue(), agvCallDTO);
+        }
     }
 
     /**
@@ -285,6 +302,10 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        // 增加氯化镍标识
+        for (AgvCallItemDTO agvCallItemDTO : agvCallItemDTOList) {
+            agvCallItemDTO.getLotattDTO().setLotatt18("N"); //是否硫酸镍,N代表否
+        }
         return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.ELEVEN.getValue(), agvCallDTO);
     }
 
@@ -320,6 +341,8 @@ public class AgvCallProxyService {
      */
     public AjaxResult productsDownLineWrappingFilmLHN(String locationFrom, String locationTo, String createUser
             , Boolean theWeighing) {
+        // 是否硫酸镍
+        Boolean isLSN = false;
         // 查出裹膜位的库存
         List<InvLotLocIdLotattVO> invLotLocIdLotattVOList = invLotLocIdService.selectInvLocIdLotattByLocationId(Long.valueOf(locationFrom));
         if (invLotLocIdLotattVOList.size() > 0) {
@@ -330,6 +353,11 @@ public class AgvCallProxyService {
             }else {
                 theWeighing = false;
             }
+            // 判断下料是否为硫酸镍
+            if (invLotLocIdLotattVO.getLotatt18() != null
+                    && invLotLocIdLotattVO.getLotatt18().equals(Constant.IS_YES.Y.name())) {
+                isLSN = true;
+            }
         }else{
             return AjaxResult.error("裹膜点无货!");
         }
@@ -338,8 +366,13 @@ public class AgvCallProxyService {
         agvCallDTO.setLocationTo(locationTo);
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
-        return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.THIRTEEN.getValue(), agvCallDTO);
-    }
+        if (isLSN) {
+            // 硫酸镍
+            return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.TEN.getValue(), agvCallDTO);
+        }else {
+            // 氯化镍
+            return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.THIRTEEN.getValue(), agvCallDTO);
+        }    }
 
     /**
      * 成品出库(硫酸镍)

+ 4 - 5
warewms-hard/src/main/java/com/ruoyi/hard/modbus/tcp/ButtonBoxClient.java

@@ -2,7 +2,6 @@ package com.ruoyi.hard.modbus.tcp;
 
 import com.jwk.spring.boot.autoconfigure.ModbusTcpMasterTemplate;
 import com.jwk.spring.boot.modbus4j.ModbusMasterUtil;
-import com.ruoyi.common.core.domain.AjaxResult;
 import com.serotonin.modbus4j.msg.ReadResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -73,19 +72,19 @@ public class ButtonBoxClient {
      */
     public enum BUTTON_BOX_NO {
         /***
-         * 按钮盒1
+         * 裹膜区->仓储区
          */
         A("1"),
         /***
-         * 按钮盒2
+         * 硫酸镍废料
          */
         B("2"),
         /***
-         * 按钮盒3
+         * 氯化镍废料
          */
         C("3"),
         /***
-         * 按钮盒4
+         * 硫酸镍废料退空
          */
         D("4");