From aef500a5cebed741c69e2bc3426bc8342db30bf1 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 24 四月 2026 16:10:53 +0800
Subject: [PATCH] #堆垛机命令增加排映射关系V3.0.0.8
---
src/main/java/com/zy/asrs/controller/OpenController.java | 110 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 89 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index b9436ce..eb65d3b 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -6,6 +6,7 @@
import com.core.exception.CoolException;
import com.zy.asrs.domain.Result.CancelTaskBatchResult;
import com.zy.asrs.domain.param.*;
+import com.core.annotations.ManagerAuth;
import com.zy.asrs.entity.DeviceConfig;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
@@ -21,13 +22,13 @@
import com.zy.core.model.protocol.DualCrnProtocol;
import com.zy.core.model.protocol.RgvProtocol;
import com.zy.core.model.protocol.StationProtocol;
+import com.zy.core.network.fake.FakeConfigKeys;
import com.zy.core.thread.CrnThread;
import com.zy.core.thread.DualCrnThread;
import com.zy.core.thread.RgvThread;
import com.zy.core.thread.StationThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
-import com.zy.system.service.HighPrivilegeGrantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,12 +36,12 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
-import jakarta.servlet.http.HttpServletRequest;
-
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
@Slf4j
@RestController
@@ -63,10 +64,6 @@
private ConfigService configService;
@Autowired
private DeviceConfigService deviceConfigService;
- @Autowired
- private HighPrivilegeGrantService highPrivilegeGrantService;
- @Autowired
- private HttpServletRequest request;
// 绉诲簱浠诲姟
@PostMapping("/createLocMoveTask")
@@ -144,13 +141,7 @@
if (param == null) {
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
- boolean directCancel = false;
- try {
- highPrivilegeGrantService.assertGranted(request.getHeader("token"), "鍙栨秷浠诲姟");
- directCancel = true;
- } catch (CoolException ignore) {
- }
- boolean completeTask = commonService.cancelTask(param, directCancel);
+ boolean completeTask = commonService.cancelTask(param);
if (completeTask) {
return R.ok();
}
@@ -176,13 +167,7 @@
if (param == null) {
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
- boolean directCancel = false;
- try {
- highPrivilegeGrantService.assertGranted(request.getHeader("token"), "鍙栨秷浠诲姟");
- directCancel = true;
- } catch (CoolException ignore) {
- }
- CancelTaskBatchResult result = commonService.cancelTaskBatch(param, directCancel);
+ CancelTaskBatchResult result = commonService.cancelTaskBatch(param);
return R.ok().add(result);
}
@@ -443,4 +428,87 @@
return R.ok();
}
+ @GetMapping("/fakeConfig/auth")
+ @ManagerAuth
+ public R getFakeConfig() {
+ LinkedHashMap<String, Object> map = new LinkedHashMap<>();
+ for (String key : FakeConfigKeys.ALL_KEYS) {
+ String defaultValue = FakeConfigKeys.DEFAULTS.get(key);
+ map.put(key, configService.getConfigValue(key, defaultValue));
+ }
+ return R.ok().add(map);
+ }
+
+ @PostMapping("/fakeConfig/save/auth")
+ @ManagerAuth
+ public R saveFakeConfig(@RequestBody FakeConfigSaveParam param) {
+ if (param == null || param.getConfigMap() == null || param.getConfigMap().isEmpty()) {
+ return R.error("鍙傛暟涓嶈兘涓虹┖");
+ }
+ Set<String> allowKeys = FakeConfigKeys.ALL_KEYS;
+ Map<String, String> normalizedMap = new LinkedHashMap<>();
+ for (Map.Entry<String, Object> entry : param.getConfigMap().entrySet()) {
+ String key = entry.getKey();
+ if (!allowKeys.contains(key)) {
+ return R.error("涓嶆敮鎸佺殑閰嶇疆椤�: " + key);
+ }
+ normalizedMap.put(key, normalizeFakeConfigValue(key, entry.getValue()));
+ }
+ validateFakeCrnLaserConfig(normalizedMap);
+ for (Map.Entry<String, String> entry : normalizedMap.entrySet()) {
+ if (!configService.saveConfigValue(entry.getKey(), entry.getValue())) {
+ return R.error("淇濆瓨澶辫触: " + entry.getKey());
+ }
+ }
+ configService.refreshSystemConfigCache();
+ return getFakeConfig();
+ }
+
+ private void validateFakeCrnLaserConfig(Map<String, String> normalizedMap) {
+ long bayMin = resolveFakeLongValue(normalizedMap, FakeConfigKeys.FAKE_CRN_BAY_MIN);
+ long bayMax = resolveFakeLongValue(normalizedMap, FakeConfigKeys.FAKE_CRN_BAY_MAX);
+ long laserMin = resolveFakeLongValue(normalizedMap, FakeConfigKeys.FAKE_CRN_LASER_MIN);
+ long laserMax = resolveFakeLongValue(normalizedMap, FakeConfigKeys.FAKE_CRN_LASER_MAX);
+ if (bayMax <= bayMin) {
+ throw new CoolException("鍫嗗灈鏈� bay 鏈�澶у�煎繀椤诲ぇ浜庢渶灏忓��");
+ }
+ if (laserMax <= laserMin) {
+ throw new CoolException("鍫嗗灈鏈洪暛灏勬渶澶у�煎繀椤诲ぇ浜庢渶灏忓��");
+ }
+ }
+
+ private long resolveFakeLongValue(Map<String, String> normalizedMap, String key) {
+ String value = normalizedMap.get(key);
+ if (value == null) {
+ value = configService.getConfigValue(key, FakeConfigKeys.DEFAULTS.get(key));
+ }
+ return Long.parseLong(value);
+ }
+
+ private String normalizeFakeConfigValue(String key, Object rawValue) {
+ if (rawValue == null) {
+ throw new CoolException(key + " 鍙傛暟涓嶈兘涓虹┖");
+ }
+ String value = String.valueOf(rawValue).trim();
+ if (FakeConfigKeys.BOOLEAN_KEYS.contains(key)) {
+ if (!"Y".equalsIgnoreCase(value) && !"N".equalsIgnoreCase(value)) {
+ throw new CoolException(key + " 浠呮敮鎸� Y/N");
+ }
+ return value.toUpperCase();
+ }
+ if (FakeConfigKeys.LONG_KEYS.contains(key)) {
+ long parsed;
+ try {
+ parsed = Long.parseLong(value);
+ } catch (Exception e) {
+ throw new CoolException(key + " 蹇呴』涓洪潪璐熸暣鏁�");
+ }
+ if (parsed < 0) {
+ throw new CoolException(key + " 蹇呴』涓洪潪璐熸暣鏁�");
+ }
+ return String.valueOf(parsed);
+ }
+ throw new CoolException("涓嶆敮鎸佺殑閰嶇疆椤�: " + key);
+ }
+
}
--
Gitblit v1.9.1