From 8b60bf565eb475c13e39caa305c4415b34d8ec02 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期五, 05 十二月 2025 08:49:19 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/OpenController.java | 253 ++++++++++++++++++--------------------------------
1 files changed, 93 insertions(+), 160 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 0aa3632..d2d65e8 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,25 +1,32 @@
package com.zy.asrs.controller;
-import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.R;
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.enums.SlaveType;
import com.zy.core.enums.WrkIoType;
+import com.zy.core.model.protocol.CrnProtocol;
+import com.zy.core.model.protocol.RgvProtocol;
+import com.zy.core.thread.CrnThread;
+import com.zy.core.thread.RgvThread;
+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;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -28,16 +35,18 @@
@RequestMapping("/openapi")
public class OpenController {
+ @Value("${mainProcessPlugin}")
+ private String mainProcessPlugin;
@Autowired
private CommonService commonService;
- @Autowired
- private NotifyUtils notifyUtils;
- @Autowired
- private ApiLogService apiLogService;
@Autowired
private LocMastService locMastService;
@Autowired
private WrkMastService wrkMastService;
+ @Autowired
+ private ConfigService configService;
+ @Autowired
+ private DeviceConfigService deviceConfigService;
//绉诲簱浠诲姟
@PostMapping("/createLocMoveTask")
@@ -47,22 +56,6 @@
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean result = commonService.createLocMoveTask(param);
- apiLogService.insert(new ApiLog(
- null
- , "绉诲簱浠诲姟"
- , "/createLocMoveTask"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , null
- , null
- , result ? 1 : 0
- , 1
- , new Date()
- , null
- , null
- ));
if (result) {
return R.ok();
}
@@ -77,22 +70,6 @@
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean result = commonService.createInTask(param);
- apiLogService.insert(new ApiLog(
- null
- , "鍏ュ簱浠诲姟"
- , "/createInTask"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , null
- , null
- , result ? 1 : 0
- , 1
- , new Date()
- , null
- , null
- ));
if (result) {
return R.ok();
}
@@ -107,22 +84,6 @@
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean result = commonService.createOutTask(param);
- apiLogService.insert(new ApiLog(
- null
- , "鍑哄簱浠诲姟"
- , "/createOutTask"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , null
- , null
- , result ? 1 : 0
- , 1
- , new Date()
- , null
- , null
- ));
if (result) {
return R.ok();
}
@@ -136,22 +97,6 @@
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean completeTask = commonService.completeTask(param);
- apiLogService.insert(new ApiLog(
- null
- , "浠诲姟瀹屾垚"
- , "/completeTask"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , null
- , null
- , completeTask ? 1 : 0
- , 1
- , new Date()
- , null
- , null
- ));
if (completeTask) {
return R.ok();
}
@@ -165,22 +110,6 @@
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean completeTask = commonService.cancelTask(param);
- apiLogService.insert(new ApiLog(
- null
- , "浠诲姟鍙栨秷"
- , "/cancelTask"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , null
- , null
- , completeTask ? 1 : 0
- , 1
- , new Date()
- , null
- , null
- ));
if (completeTask) {
return R.ok();
}
@@ -191,61 +120,42 @@
// @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);
-// }
-//
-// //鑾峰彇鎻愬崌鏈烘暟鎹�
-// 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);
+ //鑾峰彇鍫嗗灈鏈烘暟鎹�
+ ArrayList<CrnProtocol> crnProtocols = new ArrayList<>();
+ List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Crn)));
+ for (DeviceConfig device : crnList) {
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, device.getDeviceNo());
+ if (crnThread == null) {
+ continue;
+ }
+ CrnProtocol crnProtocol = crnThread.getStatus();
+ if (crnProtocol == null) {
+ continue;
+ }
+ crnProtocols.add(crnProtocol);
+ }
+
+ //鑾峰彇RGV鏁版嵁
+ ArrayList<RgvProtocol> rgvProtocols = new ArrayList<>();
+ List<DeviceConfig> rgvList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Rgv)));
+ for (DeviceConfig device : rgvList) {
+ RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, device.getDeviceNo());
+ if (rgvThread == null) {
+ continue;
+ }
+
+ RgvProtocol rgvProtocol = rgvThread.getStatus();
+ if (rgvProtocol == null) {
+ continue;
+ }
+ rgvProtocols.add(rgvProtocol);
+ }
+
+ map.put("crn", crnList);
+ map.put("rgv", rgvList);
return R.ok().add(map);
}
@@ -302,23 +212,6 @@
wrapper.eq("io_type", ioType.id);
}
List<WrkMast> wrkMasts = wrkMastService.selectList(wrapper);
- apiLogService.insert(new ApiLog(
- null
- , "鏌ヨ浠诲姟"
- , "/queryTask"
- , null
- , null
- , null
- , JSON.toJSONString(param)
- , JSON.toJSONString(wrkMasts)
- , null
- , null
- , 1
- , new Date()
- , null
- , null
- ));
-
return R.ok().add(wrkMasts);
}
@@ -327,4 +220,44 @@
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