From deb10b28cff67e731d0f6b268a91b9af5e76c3d9 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 10 四月 2024 14:41:13 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java |   69 +++++++++++++++++++++++++++++++++-
 1 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java
index 763cdfe..905f5ec 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java
@@ -10,6 +10,7 @@
 import com.zy.asrs.wcs.common.domain.BaseParam;
 import com.zy.asrs.wcs.common.domain.KeyValVo;
 import com.zy.asrs.wcs.common.domain.PageParam;
+import com.zy.asrs.wcs.core.domain.param.ShuttleMoveLocParam;
 import com.zy.asrs.wcs.core.domain.param.ShuttleOperatorParam;
 import com.zy.asrs.wcs.core.entity.BasShuttle;
 import com.zy.asrs.wcs.core.entity.Motion;
@@ -23,6 +24,14 @@
 import com.zy.asrs.wcs.core.service.TaskService;
 import com.zy.asrs.wcs.core.utils.Utils;
 import com.zy.asrs.wcs.rcs.News;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.entity.DeviceType;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
+import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
+import com.zy.asrs.wcs.rcs.service.DeviceService;
+import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
+import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
 import com.zy.asrs.wcs.system.controller.BaseController;
 import com.zy.asrs.wcs.utils.ExcelUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +58,10 @@
     private AnalyzeService analyzeService;
     @Autowired
     private MotionService motionService;
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private DeviceTypeService deviceTypeService;
 
     @PreAuthorize("hasAuthority('core:basShuttle:list')")
     @PostMapping("/basShuttle/page")
@@ -120,10 +133,11 @@
         ExcelUtil.build(ExcelUtil.create(basShuttleService.list(), BasShuttle.class), response);
     }
 
+    //鎵嬪姩鎿嶄綔
     @PreAuthorize("hasAuthority('core:basShuttle:operator')")
     @PostMapping("/basShuttle/operator/shuttle")
     @Transactional
-    public R shuttleOperator(@RequestBody ShuttleOperatorParam param) {
+    public synchronized R shuttleOperator(@RequestBody ShuttleOperatorParam param) {
         if (Cools.isEmpty(param.getShuttleNo(), param.getShuttleTaskMode())) {
             return R.error("鍙傛暟涓虹┖");
         }
@@ -148,7 +162,7 @@
         Task task = new Task();
         task.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
         task.setTaskNo(String.valueOf(Utils.getTaskNo("MANUAL")));
-        task.setTaskSts(TaskStsType.NEW_MANUAL.getId());
+        task.setTaskSts(TaskStsType.NEW_MANUAL.sts);
         task.setTaskCtg(taskCtg.getId());
         task.setPriority(10);
         task.setOriginSite(null);
@@ -165,6 +179,8 @@
             return R.error();
         }
 
+        task = taskService.getById(task.getId());
+
         // generate motion list
         List<Motion> motionList = analyzeService.generateShuttleManualMotion(task);
         if (Cools.isEmpty(motionList)) {
@@ -173,7 +189,7 @@
         }
         motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()));
 
-        task.setTaskSts(TaskStsType.ANALYZE_MANUAL.getId());
+        task.setTaskSts(TaskStsType.ANALYZE_MANUAL.sts);
         if (!taskService.updateById(task)) {
             News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鎵嬪姩浠诲姟澶辫触!!!", shuttleNo);
             return R.error();
@@ -181,4 +197,51 @@
         return R.ok();
     }
 
+    //璺戝簱绯荤粺
+    @PreAuthorize("hasAuthority('core:basShuttle:operator')")
+    @PostMapping("/basShuttle/moveLoc")
+    @Transactional
+    public synchronized R shuttleMoveLoc(@RequestBody ShuttleMoveLocParam param) {
+        DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>()
+                .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))
+                .eq(DeviceType::getStatus, 1)
+                .eq(DeviceType::getHostId, getHostId()));
+        if (deviceType == null) {
+            return R.error();
+        }
+
+        Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
+                .eq(Device::getDeviceType, deviceType.getId())
+                .eq(Device::getStatus, 1)
+                .eq(Device::getHostId, getHostId())
+                .eq(Device::getDeviceNo, param.getShuttleNo()));
+        if (device == null) {
+            return R.error();
+        }
+
+        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+        if (shuttleThread == null) {
+            return R.error();
+        }
+
+        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+        if (shuttleProtocol == null) {
+            return R.error();
+        }
+
+        if (!shuttleThread.isIdle()) {
+            return R.error("灏忚溅蹇欑涓�");
+        }
+
+        shuttleProtocol.setMoveLoc(true);//寮�鍚窇搴�
+        shuttleProtocol.setMoveType(param.getMoveType());
+        shuttleProtocol.setXStart(param.getStartX());
+        shuttleProtocol.setXTarget(param.getTargetX());
+        shuttleProtocol.setXCurrent(param.getStartX());
+        shuttleProtocol.setYStart(param.getStartY());
+        shuttleProtocol.setYTarget(param.getTargetY());
+        shuttleProtocol.setYCurrent(param.getStartY());
+        return R.ok();
+    }
+
 }

--
Gitblit v1.9.1