From 656429e94f5989911bdf07848ef44b1cc71dfaf1 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 19 三月 2026 12:55:31 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/BasStationPathPolicyController.java | 102 ++++++++++++++++++++++++---------------------------
1 files changed, 48 insertions(+), 54 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/BasStationPathPolicyController.java b/src/main/java/com/zy/asrs/controller/BasStationPathPolicyController.java
index 1d5ae33..33d83e2 100644
--- a/src/main/java/com/zy/asrs/controller/BasStationPathPolicyController.java
+++ b/src/main/java/com/zy/asrs/controller/BasStationPathPolicyController.java
@@ -18,11 +18,7 @@
import com.zy.asrs.service.StationPathPolicyService;
import com.zy.common.model.NavigateNode;
import com.zy.common.utils.NavigateUtils;
-import com.zy.common.utils.RedisUtil;
import com.zy.common.web.BaseController;
-import com.zy.core.enums.RedisKeyType;
-import com.zy.system.entity.Config;
-import com.zy.system.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -41,16 +37,10 @@
@RequestMapping("/basStationPathPolicy")
public class BasStationPathPolicyController extends BaseController {
- private static final String CFG_DEFAULT_PROFILE_CODE = "stationPathDefaultProfileCode";
-
@Autowired
private BasStationPathProfileService basStationPathProfileService;
@Autowired
private BasStationPathRuleService basStationPathRuleService;
- @Autowired
- private ConfigService configService;
- @Autowired
- private RedisUtil redisUtil;
@Autowired
private StationPathPolicyService stationPathPolicyService;
@Autowired
@@ -63,11 +53,14 @@
@RequestMapping("/data/auth")
@ManagerAuth
public R data() {
+ List<BasStationPathProfile> profileList = basStationPathProfileService.list(new QueryWrapper<BasStationPathProfile>()
+ .orderByDesc("is_default")
+ .orderByAsc("priority", "id"));
Map<String, Object> data = new HashMap<>();
- data.put("profiles", basStationPathProfileService.list(new QueryWrapper<BasStationPathProfile>().orderByAsc("priority", "id")));
+ data.put("profiles", profileList);
data.put("rules", basStationPathRuleService.list(new QueryWrapper<BasStationPathRule>().orderByAsc("priority", "id")));
data.put("scoreMode", "twoStage");
- data.put("defaultProfileCode", getSystemConfig(CFG_DEFAULT_PROFILE_CODE, "default"));
+ data.put("defaultProfileCode", resolveDefaultProfileCode(profileList));
data.put("stations", buildStationSummaryList());
data.put("levList", basMapService.getLevList());
return R.ok(data);
@@ -78,11 +71,6 @@
public R save(@RequestBody JSONObject payload) {
JSONArray profiles = payload.getJSONArray("profiles");
JSONArray rules = payload.getJSONArray("rules");
-
- upsertSystemConfig("绔欑偣璺緞榛樿妯℃澘缂栫爜", CFG_DEFAULT_PROFILE_CODE, defaultIfBlank(payload.getString("defaultProfileCode"), "default"), "String");
-
- basStationPathProfileService.remove(new QueryWrapper<>());
- basStationPathRuleService.remove(new QueryWrapper<>());
List<BasStationPathProfile> profileList = new ArrayList<>();
if (profiles != null) {
@@ -99,6 +87,7 @@
profile.setProfileName(defaultIfBlank(item.getString("profileName"), item.getString("profileCode")));
profile.setPriority(item.getInteger("priority") == null ? 100 : item.getInteger("priority"));
profile.setStatus(item.getShort("status") == null ? (short) 1 : item.getShort("status"));
+ profile.setIsDefault((short) 0);
profile.setMemo(item.getString("memo"));
Object configObj = item.get("config");
if (configObj != null) {
@@ -109,6 +98,29 @@
profileList.add(profile);
}
}
+ if (profileList.isEmpty()) {
+ return R.error("鑷冲皯闇�瑕佷繚鐣欎竴涓ā鏉�");
+ }
+
+ String defaultProfileCode = defaultIfBlank(payload.getString("defaultProfileCode"), profileList.get(0).getProfileCode());
+ BasStationPathProfile defaultProfile = null;
+ for (BasStationPathProfile profile : profileList) {
+ if (profile != null && defaultProfileCode.equals(profile.getProfileCode())) {
+ profile.setIsDefault((short) 1);
+ defaultProfile = profile;
+ break;
+ }
+ }
+ if (defaultProfile == null) {
+ return R.error("榛樿妯℃澘缂栫爜娌℃湁瀵瑰簲妯℃澘");
+ }
+ if (!Short.valueOf((short) 1).equals(defaultProfile.getStatus())) {
+ return R.error("榛樿妯℃澘蹇呴』鍚敤");
+ }
+
+ basStationPathProfileService.remove(new QueryWrapper<>());
+ basStationPathRuleService.remove(new QueryWrapper<>());
+
if (!profileList.isEmpty()) {
basStationPathProfileService.saveBatch(profileList);
}
@@ -143,8 +155,6 @@
if (!ruleList.isEmpty()) {
basStationPathRuleService.saveBatch(ruleList);
}
-
- refreshSystemConfigCache();
stationPathPolicyService.evictCache();
return R.ok();
}
@@ -265,44 +275,28 @@
return result;
}
- private void upsertSystemConfig(String name, String code, String value, String selectType) {
- String finalValue = value == null ? "" : value.trim();
- Config config = configService.getOne(new QueryWrapper<Config>().eq("code", code));
- if (config == null) {
- config = new Config(name, code, finalValue, (short) 1, (short) 1);
- config.setSelectType(selectType);
- configService.save(config);
- } else {
- config.setName(name);
- config.setValue(finalValue);
- config.setType((short) 1);
- config.setStatus((short) 1);
- config.setSelectType(selectType);
- configService.updateById(config);
+ private String resolveDefaultProfileCode(List<BasStationPathProfile> profileList) {
+ if (profileList == null || profileList.isEmpty()) {
+ return "default";
}
- }
-
- private void refreshSystemConfigCache() {
- HashMap<String, String> systemConfigMap = new HashMap<>();
- List<Config> configList = configService.list(new QueryWrapper<>());
- for (Config config : configList) {
- systemConfigMap.put(config.getCode(), config.getValue());
- }
- redisUtil.set(RedisKeyType.SYSTEM_CONFIG_MAP.key, systemConfigMap);
- }
-
- private String getSystemConfig(String code, String defaultValue) {
- Object mapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
- if (mapObj instanceof Map) {
- Object value = ((Map<?, ?>) mapObj).get(code);
- if (value != null) {
- String text = String.valueOf(value).trim();
- if (!text.isEmpty()) {
- return text;
- }
+ for (BasStationPathProfile profile : profileList) {
+ if (profile != null
+ && Short.valueOf((short) 1).equals(profile.getIsDefault())
+ && !isBlank(profile.getProfileCode())) {
+ return profile.getProfileCode();
}
}
- return defaultValue;
+ for (BasStationPathProfile profile : profileList) {
+ if (profile != null && "default".equals(profile.getProfileCode())) {
+ return profile.getProfileCode();
+ }
+ }
+ for (BasStationPathProfile profile : profileList) {
+ if (profile != null && !isBlank(profile.getProfileCode())) {
+ return profile.getProfileCode();
+ }
+ }
+ return "default";
}
private List<Integer> parseStationIdArray(JSONArray array) {
--
Gitblit v1.9.1