| | |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.DeviceConfigService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.RuntimeConfigService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.common.annotations.OpenApiLog; |
| | | import com.zy.common.service.CommonService; |
| | |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | | private RuntimeConfigService runtimeConfigService; |
| | | |
| | | // 移库任务 |
| | | @PostMapping("/createLocMoveTask") |
| | |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | @PostMapping("/runtimeConfig/update") |
| | | @OpenApiLog(memo = "修改运行参数") |
| | | public R updateRuntimeConfig(@RequestBody RuntimeConfigUpdateParam param) { |
| | | if (param == null || param.getConfigMap() == null || param.getConfigMap().isEmpty()) { |
| | | return R.error("参数不能为空"); |
| | | } |
| | | return R.ok().add(runtimeConfigService.updateRuntimeConfig(param.getConfigMap())); |
| | | } |
| | | |
| | | @GetMapping("/getFakeSystemRunStatus") |
| | | public R getFakeSystemRunStatus() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | |
| | | 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); |
| | | } |
| | | String normalized = normalizeFakeConfigValue(key, entry.getValue()); |
| | | if (!configService.saveConfigValue(key, normalized)) { |
| | | 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 + " 参数不能为空"); |