From 411c7bcfb64581060c459d6a124b58cafadd983a Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 11 四月 2024 20:35:37 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/controller/BasShuttleController.java | 143 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 139 insertions(+), 4 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 21b798f..0d519de 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
@@ -2,25 +2,45 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zy.asrs.framework.common.BaseRes;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
+import com.zy.asrs.framework.common.SnowflakeIdWorker;
import com.zy.asrs.wcs.common.annotation.OperationLog;
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;
+import com.zy.asrs.wcs.core.entity.Task;
+import com.zy.asrs.wcs.core.entity.TaskCtg;
+import com.zy.asrs.wcs.core.kernel.AnalyzeService;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
+import com.zy.asrs.wcs.core.model.enums.TaskStsType;
import com.zy.asrs.wcs.core.service.BasShuttleService;
+import com.zy.asrs.wcs.core.service.MotionService;
+import com.zy.asrs.wcs.core.service.TaskCtgService;
+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.thread.ShuttleThread;
import com.zy.asrs.wcs.system.controller.BaseController;
import com.zy.asrs.wcs.utils.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@RestController
@RequestMapping("/api")
@@ -28,6 +48,18 @@
@Autowired
private BasShuttleService basShuttleService;
+ @Autowired
+ private TaskCtgService taskCtgService;
+ @Autowired
+ private SnowflakeIdWorker snowflakeIdWorker;
+ @Autowired
+ private TaskService taskService;
+ @Autowired
+ private AnalyzeService analyzeService;
+ @Autowired
+ private MotionService motionService;
+ @Autowired
+ private DeviceService deviceService;
@PreAuthorize("hasAuthority('core:basShuttle:list')")
@PostMapping("/basShuttle/page")
@@ -99,4 +131,107 @@
ExcelUtil.build(ExcelUtil.create(basShuttleService.list(), BasShuttle.class), response);
}
+ //鎵嬪姩鎿嶄綔
+ @PreAuthorize("hasAuthority('core:basShuttle:operator')")
+ @PostMapping("/basShuttle/operator/shuttle")
+ @Transactional
+ public synchronized R shuttleOperator(@RequestBody ShuttleOperatorParam param) {
+ if (Cools.isEmpty(param.getShuttleNo(), param.getShuttleTaskMode())) {
+ return R.error("鍙傛暟涓虹┖");
+ }
+
+ Integer shuttleNo = param.getShuttleNo();
+
+ //鑾峰彇杩佺Щ浠诲姟绫诲瀷
+ TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
+ .eq(TaskCtg::getFlag, "MANUAL")
+ .eq(TaskCtg::getStatus, 1));
+ if (taskCtg == null) {
+ return R.error();
+ }
+
+ String targetLoc = null;//浠诲姟鐩爣(鍊熺敤瀛楁)
+ String targetSite = param.getShuttleTaskMode();//浠诲姟绫诲瀷(鍊熺敤瀛楁)
+ if (param.getShuttleTaskMode().equals("moveLoc")) {
+ //杩佺Щ浠诲姟
+ targetLoc = param.getTargetLocNo();
+ }
+
+ Task task = new Task();
+ task.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
+ task.setTaskNo(String.valueOf(Utils.getTaskNo("MANUAL")));
+ task.setTaskSts(TaskStsType.NEW_MANUAL.sts);
+ task.setTaskCtg(taskCtg.getId());
+ task.setPriority(10);
+ task.setOriginSite(null);
+ task.setOriginLoc(null);
+ task.setDestSite(targetSite);
+ task.setDestLoc(targetLoc);
+ task.setIoTime(new Date());
+ task.setStartTime(new Date());
+ task.setStatus(1);
+ task.setMemo("manual");
+ task.setShuttleNo(param.getShuttleNo());
+ boolean result = taskService.save(task);
+ if (!result) {
+ return R.error();
+ }
+
+ task = taskService.getById(task.getId());
+
+ // generate motion list
+ List<Motion> motionList = analyzeService.generateShuttleManualMotion(task);
+ if (Cools.isEmpty(motionList)) {
+ News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鎵嬪姩浠诲姟澶辫触!!!", shuttleNo);
+ return R.error();
+ }
+ motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()));
+
+ task.setTaskSts(TaskStsType.ANALYZE_MANUAL.sts);
+ if (!taskService.updateById(task)) {
+ News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鎵嬪姩浠诲姟澶辫触!!!", shuttleNo);
+ return R.error();
+ }
+ return R.ok();
+ }
+
+ //璺戝簱绯荤粺
+ @PreAuthorize("hasAuthority('core:basShuttle:operator')")
+ @PostMapping("/basShuttle/moveLoc")
+ @Transactional
+ public synchronized R shuttleMoveLoc(@RequestBody ShuttleMoveLocParam param) {
+ Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
+ .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())
+ .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