From 1ae2f3acafa9d036dfe4f14f8dcc5c4b5815c46a Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期一, 01 十二月 2025 16:33:09 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/OpenController.java | 291 +++++++++++++++++++++-------------------------------------
1 files changed, 105 insertions(+), 186 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 17b89b6..0522ff4 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -3,30 +3,23 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.R;
-import com.zy.asrs.domain.ShuttleGatherResult;
-import com.zy.asrs.domain.enums.NotifyMsgType;
import com.zy.asrs.domain.param.*;
import com.zy.asrs.entity.ApiLog;
-import com.zy.asrs.entity.DeviceConfig;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.ApiLogService;
-import com.zy.asrs.service.DeviceConfigService;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.common.annotations.OpenApiLog;
import com.zy.common.service.CommonService;
-import com.zy.core.cache.SlaveConnection;
-import com.zy.core.dispatcher.ShuttleDispatchUtils;
-import com.zy.core.enums.SlaveType;
import com.zy.core.enums.WrkIoType;
-import com.zy.core.model.protocol.ForkLiftProtocol;
-import com.zy.core.model.protocol.ShuttleProtocol;
-import com.zy.core.thread.ForkLiftThread;
-import com.zy.core.thread.ShuttleThread;
+import com.zy.system.entity.Config;
+import com.zy.system.service.ConfigService;
+
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@@ -39,10 +32,10 @@
@RequestMapping("/openapi")
public class OpenController {
+ @Value("${mainProcessPlugin}")
+ private String mainProcessPlugin;
@Autowired
private CommonService commonService;
- @Autowired
- private ShuttleDispatchUtils shuttleDispatchUtils;
@Autowired
private NotifyUtils notifyUtils;
@Autowired
@@ -52,36 +45,7 @@
@Autowired
private WrkMastService wrkMastService;
@Autowired
- private DeviceConfigService deviceConfigService;
-
- @PostMapping("/createMoveTask")
- @OpenApiLog(memo = "灏忚溅绉诲姩浠诲姟")
- public R createMoveTask(@RequestBody CreateMoveTaskParam param) {
- if (param == null) {
- return R.error("鍙傛暟涓嶈兘涓虹┖");
- }
- boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(null, param.getLocNo(), param.getShuttleNo());
- apiLogService.insert(new ApiLog(
- null
- , "灏忚溅绉诲姩浠诲姟"
- , "/createMoveTask"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , null
- , null
- , dispatchShuttle ? 1 : 0
- , 1
- , new Date()
- , null
- , null
- ));
- if (dispatchShuttle) {
- return R.ok();
- }
- return R.error("鐢熸垚澶辫触");
- }
+ private ConfigService configService;
//绉诲簱浠诲姟
@PostMapping("/createLocMoveTask")
@@ -231,63 +195,64 @@
return R.error("浠诲姟鍙栨秷澶辫触");
}
- @PostMapping("/deviceStatus")
- @OpenApiLog(memo = "鑾峰彇璁惧鐘舵��")
+ @RequestMapping("/deviceStatus")
+// @OpenApiLog(memo = "鑾峰彇璁惧鐘舵��")
public R getDeviceStatus() {
HashMap<String, Object> map = new HashMap<>();
- //鑾峰彇灏忚溅鏁版嵁
- ArrayList<ShuttleProtocol> shuttleProtocols = new ArrayList<>();
- List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
- .eq("device_type", String.valueOf(SlaveType.Shuttle)));
- for (DeviceConfig device : shuttleList) {
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
- if (shuttleThread == null) {
- continue;
- }
-
- ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
- if (shuttleProtocol == null) {
- continue;
- }
- shuttleProtocols.add(shuttleProtocol);
- }
-
- //鑾峰彇璐у弶鎻愬崌鏈烘暟鎹�
- ArrayList<ForkLiftProtocol> forkLiftProtocols = new ArrayList<>();
- List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
- .eq("device_type", String.valueOf(SlaveType.ForkLift)));
- for (DeviceConfig device : forkLiftList) {
- ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo());
- if (forkLiftThread == null) {
- continue;
- }
-
- ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
- if (forkLiftProtocol == null) {
- continue;
- }
- forkLiftProtocols.add(forkLiftProtocol);
- }
-
- map.put("shuttle", shuttleProtocols);
- map.put("forkLift", forkLiftProtocols);
-
- apiLogService.insert(new ApiLog(
- null
- , "鑾峰彇璁惧鐘舵��"
- , "/deviceStatus"
- , null
- , null
- , null
- , null
- , JSON.toJSONString(map)
- , null
- , null
- , 1
- , new Date()
- , null
- , null
- ));
+// //鑾峰彇灏忚溅鏁版嵁
+// ArrayList<ShuttleProtocol> shuttleProtocols = new ArrayList<>();
+// List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+// .eq("device_type", String.valueOf(SlaveType.Shuttle)));
+// for (DeviceConfig device : shuttleList) {
+// ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
+// if (shuttleThread == null) {
+// continue;
+// }
+//
+// ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+// if (shuttleProtocol == null) {
+// continue;
+// }
+// shuttleProtocols.add(shuttleProtocol);
+// }
+//
+// //鑾峰彇璐у弶鎻愬崌鏈烘暟鎹�
+// ArrayList<ForkLiftProtocol> forkLiftProtocols = new ArrayList<>();
+// List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+// .eq("device_type", String.valueOf(SlaveType.ForkLift)));
+// for (DeviceConfig device : forkLiftList) {
+// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo());
+// if (forkLiftThread == null) {
+// continue;
+// }
+//
+// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
+// if (forkLiftProtocol == null) {
+// continue;
+// }
+// forkLiftProtocols.add(forkLiftProtocol);
+// }
+//
+// //鑾峰彇鎻愬崌鏈烘暟鎹�
+// ArrayList<LiftProtocol> liftProtocols = new ArrayList<>();
+// List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+// .eq("device_type", String.valueOf(SlaveType.Lift)));
+// for (DeviceConfig device : liftList) {
+// LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo());
+// if (liftThread == null) {
+// continue;
+// }
+//
+// LiftProtocol liftProtocol = liftThread.getStatus();
+// if (liftProtocol == null) {
+// continue;
+// }
+// liftProtocols.add(liftProtocol);
+// }
+//
+// map.put("shuttle", shuttleProtocols);
+// map.put("forkLift", forkLiftProtocols);
+// map.put("lift", liftProtocols);
return R.ok().add(map);
}
@@ -306,23 +271,6 @@
HashMap<String, Object> map = new HashMap<>();
map.put("locNo", locMast.getLocNo());
map.put("locSts", locMast.getLocSts());
-
- apiLogService.insert(new ApiLog(
- null
- , "鑾峰彇鎸囧畾搴撲綅淇℃伅"
- , "/getLocInformation"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , JSON.toJSONString(map)
- , null
- , null
- , 1
- , new Date()
- , null
- , null
- ));
return R.ok().add(map);
}
@@ -343,74 +291,7 @@
list.add(map);
}
- apiLogService.insert(new ApiLog(
- null
- , "鑾峰彇鍏ㄩ儴搴撲綅淇℃伅"
- , "/getAllLocInformation"
- , null
- , null
- , null
- , null
- , JSON.toJSONString(list)
- , null
- , null
- , 1
- , new Date()
- , null
- , null
- ));
-
return R.ok().add(list);
- }
-
- @PostMapping("/shuttleGather")
- @OpenApiLog(memo = "灏忚溅闆嗗悎")
- public R shuttleGather(@RequestBody ShuttleGatherParam param) {
- List<ShuttleGatherResult> shuttleGather = shuttleDispatchUtils.shuttleGather(param);
-
- apiLogService.insert(new ApiLog(
- null
- , "灏忚溅闆嗗悎"
- , "/shuttleGather"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , JSON.toJSONString(shuttleGather)
- , null
- , null
- , 1
- , new Date()
- , null
- , null
- ));
-
- return R.ok().add(shuttleGather);
- }
-
- @PostMapping("/shuttleDemo")
- @OpenApiLog(memo = "灏忚溅婕旂ず")
- public R shuttleDemo(@RequestBody ShuttleDemoParam param) {
- shuttleDispatchUtils.shuttleDemo(param);
-
- apiLogService.insert(new ApiLog(
- null
- , "灏忚溅婕旂ず"
- , "/shuttleDemo"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , null
- , null
- , null
- , 1
- , new Date()
- , null
- , null
- ));
-
- return R.ok();
}
@PostMapping("/queryTask")
@@ -449,10 +330,48 @@
return R.ok().add(wrkMasts);
}
- @GetMapping("/test")
- public R test() {
- notifyUtils.notify("task", 1, "9999", "W9999", NotifyMsgType.SHUTTLE_MOVING, "data");
- notifyUtils.notify(String.valueOf(SlaveType.Shuttle), 2, "9999", "W9999", NotifyMsgType.SHUTTLE_MOVE_COMPLETE);
+ @GetMapping("/systemStatus")
+ public R systemStatus() {
+ return R.ok();
+ }
+
+ @GetMapping("/getFakeSystemRunStatus")
+ public R getFakeSystemRunStatus() {
+ HashMap<String, Object> map = new HashMap<>();
+ if(mainProcessPlugin.equals("FakeProcess")) {
+ map.put("running", false);
+ map.put("isFake", true);
+ Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+ if(config != null) {
+ if(config.getValue().equals("Y")) {
+ map.put("running", true);
+ }
+ }
+ } else {
+ map.put("isFake", false);
+ }
+ return R.ok().add(map);
+ }
+
+ @PostMapping("/startFakeSystem")
+ @OpenApiLog(memo = "鍚姩浠跨湡妯℃嫙")
+ public R startFakeSystem() {
+ Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+ if(config != null) {
+ config.setValue("Y");
+ configService.updateById(config);
+ }
+ return R.ok();
+ }
+
+ @PostMapping("/stopFakeSystem")
+ @OpenApiLog(memo = "鍋滄浠跨湡妯℃嫙")
+ public R stopFakeSystem() {
+ Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+ if(config != null) {
+ config.setValue("N");
+ configService.updateById(config);
+ }
return R.ok();
}
--
Gitblit v1.9.1