Browse Source

完善PLC对接,打包机上空写入呼叫成功信号

zhifei 1 year ago
parent
commit
574c2d702a

+ 10 - 4
ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java

@@ -47,6 +47,8 @@ import com.ruoyi.base.utils.IdSequenceUtils;
 import com.ruoyi.system.enums.PLCConnectNameEnum;
 import com.ruoyi.common.core.domain.DeviceLog;
 import com.ruoyi.taiye.service.IDeviceLogService;
+import com.ruoyi.taiye.service.ProcessService;
+import com.ruoyi.taiye.service.impl.ProcessServiceImpl;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -314,12 +316,15 @@ public class WarehouseTest {
     private IInvLotLocIdService invLotLocIdService;
     @Autowired
     private IInvLotAttService iInvLotAttService;
+
+    @Autowired
+    private ProcessService processService;
     @Test
     public void testAms() {
-        iInvLotAttService.deleteInvLotAttBylocationId(100003L);
-        invLotLocIdService.deleteInvLotLocIdById(100003L);
-        baseLocationInfoService.updateLocationIdleAndEmpty(100003L, Constant.WAREHOUSE_ID, "AMS");
-
+//        iInvLotAttService.deleteInvLotAttBylocationId(100003L);
+//        invLotLocIdService.deleteInvLotLocIdById(100003L);
+//        baseLocationInfoService.updateLocationIdleAndEmpty(100003L, Constant.WAREHOUSE_ID, "AMS");
+        processService.createPackingMachineUpEmptyPallets("PM_UP_1", 100005L);
     }
 
 
@@ -364,4 +369,5 @@ public class WarehouseTest {
         }
 
     }
+
 }

+ 15 - 12
ruoyi-dongfangyaiye/src/main/java/com/ruoyi/taiye/service/impl/ProcessServiceImpl.java

@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.xml.transform.Source;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -116,22 +117,11 @@ public class ProcessServiceImpl implements ProcessService {
                 plcConnectServiceRunner.getPlcServer(PLCConnectNameEnum.PACKING_MACHINE_3.getMetadata()).writeBoolean(PLCEnum.PACKING_MACHINE_UNLOADING_RECEPTION_3.getMetadata(), true);
                 SpringUtil.getApplicationContext().publishEvent(new DeviceLog(PLCConnectNameEnum.PACKING_MACHINE_3.getMetadata(), PLCConnectNameEnum.PACKING_MACHINE_3.getMetaName(), "任务完成修改PLC数值,地址:" + PLCEnum.PACKING_MACHINE_UNLOADING_RECEPTION_3.getMetadata() + "值:true", "1"));
             }
-            if (taskType.equals(Constant.FLOW_CONFIG_ID.PM_UP_1.name())) {
-                plcConnectServiceRunner.getPlcServer(PLCConnectNameEnum.PACKING_MACHINE_1.getMetadata()).writeBoolean(PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_1.getMetadata(), true);
-                SpringUtil.getApplicationContext().publishEvent(new DeviceLog(PLCConnectNameEnum.PACKING_MACHINE_1.getMetadata(), PLCConnectNameEnum.PACKING_MACHINE_1.getMetaName(), "任务完成修改PLC数值,地址:" + PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_1.getMetadata() + "值:true", "1"));
-            }
-            if (taskType.equals(Constant.FLOW_CONFIG_ID.PM_UP_2.name())) {
-                plcConnectServiceRunner.getPlcServer(PLCConnectNameEnum.PACKING_MACHINE_2.getMetadata()).writeBoolean(PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_2.getMetadata(), true);
-                SpringUtil.getApplicationContext().publishEvent(new DeviceLog(PLCConnectNameEnum.PACKING_MACHINE_2.getMetadata(), PLCConnectNameEnum.PACKING_MACHINE_2.getMetaName(), "任务完成修改PLC数值,地址:" + PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_2.getMetadata() + "值:true", "1"));
-            }
-            if (taskType.equals(Constant.FLOW_CONFIG_ID.PM_UP_3.name())) {
-                plcConnectServiceRunner.getPlcServer(PLCConnectNameEnum.PACKING_MACHINE_3.getMetadata()).writeBoolean(PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_3.getMetadata(), true);
-                SpringUtil.getApplicationContext().publishEvent(new DeviceLog(PLCConnectNameEnum.PACKING_MACHINE_3.getMetadata(), PLCConnectNameEnum.PACKING_MACHINE_3.getMetaName(), "任务完成修改PLC数值,地址:" + PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_3.getMetadata() + "值:true", "1"));
-            }
         }
     }
 
     @Override
+    @Transactional
     public void createPackingMachineUpEmptyPallets(String taskType, Long to) {
         WcsTask wcsTask = new WcsTask();
         wcsTask.setLocationTo(to + "");
@@ -152,6 +142,19 @@ public class ProcessServiceImpl implements ProcessService {
         agvCallDTO.setLocationTo(to + "");
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
         iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.valueOf(taskType).getValue(), agvCallDTO);
+
+        if (taskType.equals(Constant.FLOW_CONFIG_ID.PM_UP_1.name())) {
+            plcConnectServiceRunner.getPlcServer(PLCConnectNameEnum.PACKING_MACHINE_1.getMetadata()).writeBoolean(PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_1.getMetadata(), true);
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog(PLCConnectNameEnum.PACKING_MACHINE_1.getMetadata(), PLCConnectNameEnum.PACKING_MACHINE_1.getMetaName(), "任务完成修改PLC数值,地址:" + PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_1.getMetadata() + "值:true", "1"));
+        }
+        if (taskType.equals(Constant.FLOW_CONFIG_ID.PM_UP_2.name())) {
+            plcConnectServiceRunner.getPlcServer(PLCConnectNameEnum.PACKING_MACHINE_2.getMetadata()).writeBoolean(PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_2.getMetadata(), true);
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog(PLCConnectNameEnum.PACKING_MACHINE_2.getMetadata(), PLCConnectNameEnum.PACKING_MACHINE_2.getMetaName(), "任务完成修改PLC数值,地址:" + PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_2.getMetadata() + "值:true", "1"));
+        }
+        if (taskType.equals(Constant.FLOW_CONFIG_ID.PM_UP_3.name())) {
+            plcConnectServiceRunner.getPlcServer(PLCConnectNameEnum.PACKING_MACHINE_3.getMetadata()).writeBoolean(PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_3.getMetadata(), true);
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog(PLCConnectNameEnum.PACKING_MACHINE_3.getMetadata(), PLCConnectNameEnum.PACKING_MACHINE_3.getMetaName(), "任务完成修改PLC数值,地址:" + PLCEnum.PACKING_MACHINE_UP_EMPTY_RECEPTION_3.getMetadata() + "值:true", "1"));
+        }
     }
 
 }

+ 1 - 1
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/impl/StatusUpdateServiceImpl.java

@@ -214,7 +214,7 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
             }
             log.info("正在请求:PLC:{}请求写入地址{},请求进入地址{}",PLCConnectName,theAddressOfTheRequest,enterTheSignalAddress);
             plcConnectServiceRunner.getPlcServer(PLCConnectName).writeBoolean(theAddressOfTheRequest, true);
-            Thread.sleep(1000L);
+            Thread.sleep(2000L);
             plcConnectServiceRunner.getPlcServer(PLCConnectName).writeBoolean(theAddressOfTheRequest, false);
             return plcConnectServiceRunner.getPlcServer(PLCConnectName).readBoolean(enterTheSignalAddress);
         } catch (Exception e) {