From 59627fe84f35917a9144f6ec329fb3e1d32e1ba0 Mon Sep 17 00:00:00 2001 From: liejiu946 Date: Fri, 26 Jun 2026 10:54:04 +0800 Subject: [PATCH] =?UTF-8?q?add:1.=E5=A2=9E=E5=8A=A0=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=BC=BA=E5=88=B6=E5=8F=96=E6=B6=88=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=8E=A5=E5=8F=A3=E3=80=822.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=BD=A6=E8=BE=86=E5=86=B0=E9=87=8F=E5=92=8C?= =?UTF-8?q?=E6=B0=B4=E9=87=8F=E9=80=BB=E8=BE=91=E3=80=823.=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0OTA=E8=BF=9C=E7=A8=8B=E6=9B=B4=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=824.=E8=A1=A5=E5=85=85=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E3=80=825.=E5=A2=9E=E5=8A=A0=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=95=B0=E6=8D=AE=E5=BA=93=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vehicle/api/ScheduleVehicleAPI.java | 21 +++ .../java/org/nl/api/task/api/TaskAPI.java | 7 + .../controller/OTAAgentController.java | 42 ++++++ .../monitor/otaAgent/params/ConfirmParam.java | 24 ++++ .../otaAgent/params/PostponeParam.java | 24 ++++ .../otaAgent/service/OTAAgentService.java | 30 +++++ .../service/impl/OTAAgentServiceImpl.java | 123 ++++++++++++++++++ .../controller/ScheduleSettingController.java | 12 +- .../setting/param/BatteryThresholdsParam.java | 32 +++++ .../setting/param/ThresholdsParam.java | 22 ++++ .../setting/param/WaterThresholdsParam.java | 31 +++++ .../service/ScheduleSettingService.java | 8 ++ .../impl/ScheduleSettingServiceImpl.java | 22 ++++ .../modular/vehicle/dto/VehicleInfoDto.java | 10 ++ .../provider/ScheduleVehicleAPIProvider.java | 33 +++++ .../service/impl/VehicleServiceImpl.java | 5 +- .../backgroundmanagement/param/dao/Param.java | 5 + .../controller/ManagerTaskController.java | 7 + .../org/nl/task/provider/TaskAPIProvider.java | 7 + .../nl/task/service/impl/TaskServiceImpl.java | 45 ++++--- .../main/java/org/nl/util/URLConstant.java | 5 + .../resources/config/application-prod.yml | 4 + .../src/main/resources/config/application.yml | 1 + .../resources/language/buss/buss.properties | 9 +- .../language/buss/buss_en_US.properties | 7 + .../language/buss/buss_zh_CN.properties | 7 + 26 files changed, 515 insertions(+), 28 deletions(-) create mode 100644 nl-business-api/src/main/java/org/nl/api/schedule/vehicle/api/ScheduleVehicleAPI.java create mode 100644 nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/controller/OTAAgentController.java create mode 100644 nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/params/ConfirmParam.java create mode 100644 nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/params/PostponeParam.java create mode 100644 nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/service/OTAAgentService.java create mode 100644 nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/service/impl/OTAAgentServiceImpl.java create mode 100644 nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/BatteryThresholdsParam.java create mode 100644 nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/ThresholdsParam.java create mode 100644 nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/WaterThresholdsParam.java create mode 100644 nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/provider/ScheduleVehicleAPIProvider.java diff --git a/nl-business-api/src/main/java/org/nl/api/schedule/vehicle/api/ScheduleVehicleAPI.java b/nl-business-api/src/main/java/org/nl/api/schedule/vehicle/api/ScheduleVehicleAPI.java new file mode 100644 index 0000000..8ee9457 --- /dev/null +++ b/nl-business-api/src/main/java/org/nl/api/schedule/vehicle/api/ScheduleVehicleAPI.java @@ -0,0 +1,21 @@ +package org.nl.api.schedule.vehicle.api; + +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONObject; +import org.nl.api.schedule.task.core.ScheduleAPICreateTaskParam; + +/** + * 调度车辆API + * @author dsh + * 2026/4/30 + */ +public interface ScheduleVehicleAPI { + + /** + * 根据车号获取车辆信息 + * @param vehicleId + * @return + */ + JSONObject getVehicleIPByNumber(String vehicleId); + +} diff --git a/nl-business-api/src/main/java/org/nl/api/task/api/TaskAPI.java b/nl-business-api/src/main/java/org/nl/api/task/api/TaskAPI.java index b649cc5..1ca0d8b 100644 --- a/nl-business-api/src/main/java/org/nl/api/task/api/TaskAPI.java +++ b/nl-business-api/src/main/java/org/nl/api/task/api/TaskAPI.java @@ -49,6 +49,13 @@ public interface TaskAPI { */ WebResponse cancelTask(String taskCode); + /** + * 强制取消任务 + * @param taskCode + * @return + */ + WebResponse forceCancelTask(String taskCode); + /** * 根据房间号查询任务信息 * @param room diff --git a/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/controller/OTAAgentController.java b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/controller/OTAAgentController.java new file mode 100644 index 0000000..6f482bf --- /dev/null +++ b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/controller/OTAAgentController.java @@ -0,0 +1,42 @@ +package org.nl.monitor.otaAgent.controller; + +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.nl.logging.annotation.Log; +import org.nl.monitor.otaAgent.params.ConfirmParam; +import org.nl.monitor.otaAgent.params.PostponeParam; +import org.nl.monitor.otaAgent.service.OTAAgentService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +/** + * @author dsh + * 2026/4/30 + */ +@RestController +@RequestMapping("/api/otaAgent") +@Slf4j +public class OTAAgentController { + + @Resource + private OTAAgentService otaAgentService; + + @GetMapping("/getStatus") + @Log("查看Agent状态") + public ResponseEntity getStatus(@RequestParam String vehicleId){ + return new ResponseEntity<>(otaAgentService.getStatus(vehicleId), HttpStatus.OK); + } + + @PostMapping("/confirm") + @Log("确认更新Agent") + public ResponseEntity confirm(@RequestBody ConfirmParam confirmParam){ + return new ResponseEntity<>(otaAgentService.confirm(confirmParam), HttpStatus.OK); + } + + @PostMapping("/postpone") + @Log("暂不更新Agent") + public ResponseEntity postpone(@RequestBody PostponeParam postponeParam){ + return new ResponseEntity<>(otaAgentService.postpone(postponeParam), HttpStatus.OK); + } +} diff --git a/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/params/ConfirmParam.java b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/params/ConfirmParam.java new file mode 100644 index 0000000..8ccfc69 --- /dev/null +++ b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/params/ConfirmParam.java @@ -0,0 +1,24 @@ +package org.nl.monitor.otaAgent.params; + +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +/** + * @author dsh + * 2026/4/30 + */ +@Data +public class ConfirmParam { + + /** + * 车号 + */ + @NotBlank + private String vehicleId; + + /** + * 确认人 + */ + @NotBlank + private String confirmed_by; +} diff --git a/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/params/PostponeParam.java b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/params/PostponeParam.java new file mode 100644 index 0000000..64f3194 --- /dev/null +++ b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/params/PostponeParam.java @@ -0,0 +1,24 @@ +package org.nl.monitor.otaAgent.params; + +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +/** + * @author dsh + * 2026/4/30 + */ +@Data +public class PostponeParam { + + /** + * 车号 + */ + @NotBlank + private String vehicleId; + + /** + * 原因 + */ + @NotBlank + private String reason; +} diff --git a/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/service/OTAAgentService.java b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/service/OTAAgentService.java new file mode 100644 index 0000000..7d5b4ff --- /dev/null +++ b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/service/OTAAgentService.java @@ -0,0 +1,30 @@ +package org.nl.monitor.otaAgent.service; + +import org.nl.monitor.otaAgent.params.ConfirmParam; +import org.nl.monitor.otaAgent.params.PostponeParam; +import org.nl.response.WebResponse; + +/** + * @author dsh + * 2026/4/30 + */ +public interface OTAAgentService { + + /** + * 获取otaAgent状态 + * @return + */ + WebResponse getStatus(String vehicleId); + + /** + * 确认otaAgent更新 + * @return + */ + WebResponse confirm(ConfirmParam confirmParam); + + /** + * 暂不更新otaAgent更新 + * @return + */ + WebResponse postpone(PostponeParam postponeParam); +} diff --git a/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/service/impl/OTAAgentServiceImpl.java b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/service/impl/OTAAgentServiceImpl.java new file mode 100644 index 0000000..de4f5d7 --- /dev/null +++ b/nl-business-monitor/src/main/java/org/nl/monitor/otaAgent/service/impl/OTAAgentServiceImpl.java @@ -0,0 +1,123 @@ +package org.nl.monitor.otaAgent.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONObject; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.nl.api.schedule.vehicle.api.ScheduleVehicleAPI; +import org.nl.api.task.api.TaskAPI; +import org.nl.config.language.LangProcess; +import org.nl.exception.BadRequestException; +import org.nl.monitor.otaAgent.params.ConfirmParam; +import org.nl.monitor.otaAgent.params.PostponeParam; +import org.nl.monitor.otaAgent.service.OTAAgentService; +import org.nl.response.WebResponse; +import org.nl.util.URLConstant; +import org.springframework.stereotype.Service; + +/** + * @author dsh + * 2026/4/30 + */ +@Service +@Slf4j +public class OTAAgentServiceImpl implements OTAAgentService { + + @Resource + private ScheduleVehicleAPI vehicleAPI; + + @Resource + private TaskAPI taskAPI; + + @Override + public WebResponse getStatus(String vehicleId) { +// JSONObject vehicleData = vehicleAPI.getVehicleIPByNumber(vehicleId); +// if (vehicleData == null){ +// throw new BadRequestException(LangProcess.msg("otaAgentGetStatusFailed")); +// } +// String ip = vehicleData.getString("ip"); +// String agentUrl = ip + ":" + URLConstant.OTA_AGENT_PORT; + // todo 测试用例暂时使用固定IP + String agentUrl = "192.168.10.231:" + URLConstant.OTA_AGENT_PORT; + log.info("查询otaAgent状态"); + HttpResponse result = null; + try { + result = HttpRequest + .get(agentUrl+"/ota/status") + .execute(); + + log.info("查询otaAgent状态响应结果:{}",result.body()); + }catch (Exception e){ + log.error("查询otaAgent状态失败:{}",e.getMessage()); + } + if (result != null && result.isOk()) { + return WebResponse.requestParamOk(JSONObject.parseObject(result.body())); + } + throw new BadRequestException(LangProcess.msg("otaAgentGetStatusFailed")); + } + + @Override + public WebResponse confirm(ConfirmParam confirmParam) { +// JSONObject vehicleData = vehicleAPI.getVehicleIPByNumber(confirmParam.getVehicleId()); +// if (vehicleData == null){ +// throw new BadRequestException(LangProcess.msg("otaAgentConfirmFailed")); +// } +// if (vehicleData.getInteger("batteryLevel") < 50 || !BeanUtil.isEmpty(taskAPI.queryCurrentTaskByVehicleNumber(confirmParam.getVehicleId()))){ +// throw new BadRequestException(LangProcess.msg("otaAgentConfirmCheckFailed")); +// } +// String ip = vehicleData.getString("ip"); +// String agentUrl = ip + ":" + URLConstant.OTA_AGENT_PORT; + // todo 测试用例暂时使用固定IP + String agentUrl = "192.168.10.231:" + URLConstant.OTA_AGENT_PORT; + log.info("确认otaAgent更新参数:{}",confirmParam); + JSONObject param = new JSONObject(); + param.put("confirmed_by", confirmParam.getConfirmed_by()); + HttpResponse result = null; + try { + result = HttpRequest + .post(agentUrl+"/ota/confirm") + .body(String.valueOf(param)) + .execute(); + + log.info("确认otaAgent更新响应结果:{}",result.body()); + }catch (Exception e){ + log.error("确认otaAgent更新失败:{}",e.getMessage()); + } + if (result != null && result.isOk()) { + return WebResponse.requestParamOk(JSONObject.parseObject(result.body())); + } + throw new BadRequestException(LangProcess.msg("otaAgentConfirmFailed")); + } + + @Override + public WebResponse postpone(PostponeParam postponeParam) { +// JSONObject vehicleData = vehicleAPI.getVehicleIPByNumber(postponeParam.getVehicleId()); +// if (vehicleData == null){ +// throw new BadRequestException(LangProcess.msg("otaAgentPostponeFailed")); +// } +// String ip = vehicleData.getString("ip"); +// String agentUrl = ip + ":" + URLConstant.OTA_AGENT_PORT; + // todo 测试用例暂时使用固定IP + String agentUrl = "192.168.10.231:" + URLConstant.OTA_AGENT_PORT; + log.info("推迟otaAgent更新参数:{}",postponeParam); + JSONObject param = new JSONObject(); + param.put("reason", postponeParam.getReason()); + HttpResponse result = null; + try { + result = HttpRequest + .post(agentUrl+"/ota/postpone") + .body(String.valueOf(param)) + .execute(); + + log.info("推迟otaAgent更新响应结果:{}",result.body()); + }catch (Exception e){ + log.error("推迟otaAgent更新失败:{}",e.getMessage()); + } + if (result != null && result.isOk()) { + return WebResponse.requestParamOk(JSONObject.parseObject(result.body())); + } + throw new BadRequestException(LangProcess.msg("otaAgentPostponeFailed")); + } +} diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/controller/ScheduleSettingController.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/controller/ScheduleSettingController.java index c1aae2a..c6b1061 100644 --- a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/controller/ScheduleSettingController.java +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/controller/ScheduleSettingController.java @@ -3,14 +3,12 @@ package org.nl.schedule.modular.setting.controller; import jakarta.annotation.Resource; import org.nl.logging.annotation.Log; import org.nl.schedule.modular.setting.param.NetworkParam; +import org.nl.schedule.modular.setting.param.ThresholdsParam; import org.nl.schedule.modular.setting.param.VolumeParam; import org.nl.schedule.modular.setting.service.ScheduleSettingService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * @author dsh @@ -34,4 +32,10 @@ public class ScheduleSettingController { public ResponseEntity settingVolume(@RequestBody VolumeParam param){ return new ResponseEntity<>(scheduleSettingService.settingVolume(param), HttpStatus.OK); } + + @Log("设置车辆水量和电量阈值") + @PostMapping("/settingThresholds") + public ResponseEntity settingBatteryThresholds(@RequestBody ThresholdsParam param, @RequestParam String vehicleId){ + return new ResponseEntity<>(scheduleSettingService.settingThresholds(param,vehicleId), HttpStatus.OK); + } } diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/BatteryThresholdsParam.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/BatteryThresholdsParam.java new file mode 100644 index 0000000..7862e34 --- /dev/null +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/BatteryThresholdsParam.java @@ -0,0 +1,32 @@ +package org.nl.schedule.modular.setting.param; + +import lombok.Data; + +/** + * 电量阈值参数 + * @author dsh + * 2026/5/29 + */ +@Data +public class BatteryThresholdsParam { + + /** + * 低于该阈值,接收任务,空闲时自动加水 + */ + private Integer idleServiceBelow; + + /** + * 高于该阈值,不执行任何动作。 + */ + private Integer noConstraintAbove; + + /** + * 充电时 电量高于该阈值后才会执行任务 + */ + private Integer recoverAbove; + + /** + * 电量低于值以下拒绝执行任务,调度会自动触发充电任务 + */ + private Integer rejectBelow; +} diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/ThresholdsParam.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/ThresholdsParam.java new file mode 100644 index 0000000..711d1fe --- /dev/null +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/ThresholdsParam.java @@ -0,0 +1,22 @@ +package org.nl.schedule.modular.setting.param; + +import lombok.Data; + +/** + * 水量电量阈值参数 + * @author dsh + * 2026/6/1 + */ +@Data +public class ThresholdsParam { + + /** + * 电量阈值 + */ + private BatteryThresholdsParam batteryThresholds; + + /** + * 水量阈值 + */ + private WaterThresholdsParam waterThresholds; +} diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/WaterThresholdsParam.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/WaterThresholdsParam.java new file mode 100644 index 0000000..b2a73cd --- /dev/null +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/param/WaterThresholdsParam.java @@ -0,0 +1,31 @@ +package org.nl.schedule.modular.setting.param; + +import lombok.Data; + +/** + * 水量阈值参数 + * @author dsh + * 2026/5/29 + */ +@Data +public class WaterThresholdsParam { + /** + * 低于该阈值,接收任务,空闲时自动加水 + */ + private Integer idleServiceBelow; + + /** + * 高于该阈值,不执行任何动作。 + */ + private Integer noConstraintAbove; + + /** + * 加水时 水量高于该阈值后才会执行任务 + */ + private Integer recoverAbove; + + /** + * 水量低于值以下拒绝执行任务,调度会自动触发充电任务 + */ + private Integer rejectBelow; +} diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/service/ScheduleSettingService.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/service/ScheduleSettingService.java index 734f147..8460334 100644 --- a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/service/ScheduleSettingService.java +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/service/ScheduleSettingService.java @@ -2,6 +2,7 @@ package org.nl.schedule.modular.setting.service; import org.nl.response.WebResponse; import org.nl.schedule.modular.setting.param.NetworkParam; +import org.nl.schedule.modular.setting.param.ThresholdsParam; import org.nl.schedule.modular.setting.param.VolumeParam; /** @@ -24,4 +25,11 @@ public interface ScheduleSettingService { */ WebResponse settingVolume(VolumeParam param); + /** + * 水量电量阈值设置 + * @param param + * @return + */ + WebResponse settingThresholds(ThresholdsParam param,String vehicleId); + } diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/service/impl/ScheduleSettingServiceImpl.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/service/impl/ScheduleSettingServiceImpl.java index 3655095..1d1f408 100644 --- a/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/service/impl/ScheduleSettingServiceImpl.java +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/setting/service/impl/ScheduleSettingServiceImpl.java @@ -11,6 +11,7 @@ import org.nl.config.language.LangProcess; import org.nl.exception.BadRequestException; import org.nl.response.WebResponse; import org.nl.schedule.modular.setting.param.NetworkParam; +import org.nl.schedule.modular.setting.param.ThresholdsParam; import org.nl.schedule.modular.setting.param.VolumeParam; import org.nl.schedule.modular.setting.service.ScheduleSettingService; import org.nl.util.URLConstant; @@ -68,4 +69,25 @@ public class ScheduleSettingServiceImpl implements ScheduleSettingService { } throw new BadRequestException(LangProcess.msg("setting_volume_failed")); } + + @Override + public WebResponse settingThresholds(ThresholdsParam param, String vehicleId) { + if (StrUtil.isEmpty(vehicleId)){ + throw new BadRequestException(LangProcess.msg("param_is_null")); + } + log.info("调度设置水量和电量阈值参数:{}", param); + HttpResponse result = null; + try { + result = HttpRequest.put(URLConstant.SCHEDULE_IP_PORT+"/vehicles/"+ vehicleId +"/thresholds") + .body(String.valueOf(JSONObject.toJSON(param))) + .execute(); + if (result !=null && result.isOk()){ + log.info("调度设置水量和电量阈值响应结果:{}",result.body()); + return WebResponse.requestOk(); + } + }catch (Exception e){ + log.info("调度设置水量和电量阈值失败"); + } + throw new BadRequestException(LangProcess.msg("setting_thresholds_failed")); + } } diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/dto/VehicleInfoDto.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/dto/VehicleInfoDto.java index 45c9346..b64bbe3 100644 --- a/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/dto/VehicleInfoDto.java +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/dto/VehicleInfoDto.java @@ -83,4 +83,14 @@ public class VehicleInfoDto{ * 车辆模式(0配送,1循环) */ private String vehicleMode; + + /** + * 属性 + */ + private JSONObject attributes; + + /** + * 电量阈值 + */ + private JSONObject batteryThresholds; } diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/provider/ScheduleVehicleAPIProvider.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/provider/ScheduleVehicleAPIProvider.java new file mode 100644 index 0000000..471ce2a --- /dev/null +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/provider/ScheduleVehicleAPIProvider.java @@ -0,0 +1,33 @@ +package org.nl.schedule.modular.vehicle.provider; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONObject; +import jakarta.annotation.Resource; +import org.nl.api.schedule.vehicle.api.ScheduleVehicleAPI; +import org.nl.schedule.modular.vehicle.dto.VehicleInfoDto; +import org.nl.schedule.modular.vehicle.service.VehicleService; +import org.springframework.boot.actuate.autoconfigure.metrics.SystemMetricsAutoConfiguration; +import org.springframework.stereotype.Service; + +/** + * @author dsh + * 2026/4/30 + */ +@Service +public class ScheduleVehicleAPIProvider implements ScheduleVehicleAPI { + + @Resource + private VehicleService vehicleService; + private SystemMetricsAutoConfiguration systemMetricsAutoConfiguration; + + @Override + public JSONObject getVehicleIPByNumber(String vehicleId) { + VehicleInfoDto vehicleInfoDto = vehicleService.getVehicleInfoByNumber(vehicleId); + if (StrUtil.isBlank(vehicleInfoDto.getIp())){ + return null; + } + return JSONObject.parseObject(JSONObject.toJSONString(vehicleInfoDto)); + } +} diff --git a/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/service/impl/VehicleServiceImpl.java b/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/service/impl/VehicleServiceImpl.java index 29ee3b1..3d73de5 100644 --- a/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/service/impl/VehicleServiceImpl.java +++ b/nl-business-schedule/src/main/java/org/nl/schedule/modular/vehicle/service/impl/VehicleServiceImpl.java @@ -19,10 +19,7 @@ import org.nl.util.URLConstant; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; diff --git a/nl-business-sys/src/main/java/org/nl/sys/modular/backgroundmanagement/param/dao/Param.java b/nl-business-sys/src/main/java/org/nl/sys/modular/backgroundmanagement/param/dao/Param.java index 4bbbc17..fc93351 100644 --- a/nl-business-sys/src/main/java/org/nl/sys/modular/backgroundmanagement/param/dao/Param.java +++ b/nl-business-sys/src/main/java/org/nl/sys/modular/backgroundmanagement/param/dao/Param.java @@ -43,6 +43,11 @@ public class Param implements Serializable { */ private String value; + /** + * 值(英文) + */ + private String en_value; + /** * 备注 */ diff --git a/nl-business-sys/src/main/java/org/nl/sys/modular/backgroundmanagement/task/controller/ManagerTaskController.java b/nl-business-sys/src/main/java/org/nl/sys/modular/backgroundmanagement/task/controller/ManagerTaskController.java index 6628a8c..54adc4f 100644 --- a/nl-business-sys/src/main/java/org/nl/sys/modular/backgroundmanagement/task/controller/ManagerTaskController.java +++ b/nl-business-sys/src/main/java/org/nl/sys/modular/backgroundmanagement/task/controller/ManagerTaskController.java @@ -8,6 +8,7 @@ import org.nl.enums.TaskSourceEnum; import org.nl.logging.annotation.Log; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** @@ -33,6 +34,12 @@ public class ManagerTaskController { return new ResponseEntity<>(taskAPI.cancelTask(taskCode), HttpStatus.OK); } + @PostMapping("/forceCancelTask") + @Log("后台管理系统强制取消任务") + public ResponseEntity forceCancelTask(@RequestParam String taskCode){ + return new ResponseEntity<>(taskAPI.forceCancelTask(taskCode), HttpStatus.OK); + } + @Log("后台管理系统一键任务") @PostMapping("/oneClickOperation") public ResponseEntity oneClickOperation(@RequestBody OneClickOperationRequestParam oneClickOperationRequestParam){ diff --git a/nl-business-task/src/main/java/org/nl/task/provider/TaskAPIProvider.java b/nl-business-task/src/main/java/org/nl/task/provider/TaskAPIProvider.java index 28f6587..3c7bfb4 100644 --- a/nl-business-task/src/main/java/org/nl/task/provider/TaskAPIProvider.java +++ b/nl-business-task/src/main/java/org/nl/task/provider/TaskAPIProvider.java @@ -102,6 +102,13 @@ public class TaskAPIProvider implements TaskAPI { return taskService.cancelTask(param); } + @Override + public WebResponse forceCancelTask(String taskCode) { + CancelTaskRequestParam param = new CancelTaskRequestParam(); + param.setTask_code(taskCode); + return taskService.forceCancelTask(param); + } + @Override public WebResponse queryTaskInfoByRoom(String room) { // 获取当前存在的任务 diff --git a/nl-business-task/src/main/java/org/nl/task/service/impl/TaskServiceImpl.java b/nl-business-task/src/main/java/org/nl/task/service/impl/TaskServiceImpl.java index 18e062c..7c924de 100644 --- a/nl-business-task/src/main/java/org/nl/task/service/impl/TaskServiceImpl.java +++ b/nl-business-task/src/main/java/org/nl/task/service/impl/TaskServiceImpl.java @@ -34,6 +34,7 @@ import org.nl.task.param.*; import org.nl.task.service.TaskService; import org.nl.util.IdUtil; import org.nl.util.TaskCodeGeneratorUtil; +import org.springframework.http.HttpStatus; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -91,27 +92,33 @@ public class TaskServiceImpl extends ServiceImpl implements Tas Collectors.toList() )); for (Task task : taskList) { - HttpResponse result = scheduleTaskAPI.queryTaskStatusByTaskId(task.getTask_code()); - if (result == null || !result.isOk()){ - log.info("获取调度任务状态失败"); - continue; - } - JSONObject scheduleTaskStatusJSON = JSONObject.parseObject(result.body()); - String scheduleTaskState = scheduleTaskStatusJSON.getString("state"); String newTaskState = ""; - if (ScheduleTaskStatusEnum.FINISHED.name().equals(scheduleTaskState)){ - newTaskState = TaskStatusEnum.FINISHED.getCode(); - } else if (ScheduleTaskStatusEnum.isFinalState(scheduleTaskState)) { - newTaskState = TaskStatusEnum.CANCELED.getCode(); - task.setRemark("无路由或取消:" + scheduleTaskState); - } else if (ScheduleTaskStatusEnum.BEING_PROCESSED.name().equals(scheduleTaskState)) { - newTaskState = TaskStatusEnum.EXECUTING.getCode(); - // 充电和加水任务的目标点是调度分配的,在查询任务状态时更新目标点。 - if (StrUtil.isBlank(task.getDestinations()) && ObjectUtil.isNotEmpty(scheduleTaskStatusJSON.getJSONArray("destinations"))){ - JSONObject destination = scheduleTaskStatusJSON.getJSONArray("destinations").getJSONObject(0); - task.setDestinations(destination.getString("locationName")); + HttpResponse result = scheduleTaskAPI.queryTaskStatusByTaskId(task.getTask_code()); + if (result.isOk()){ + JSONObject scheduleTaskStatusJSON = JSONObject.parseObject(result.body()); + String scheduleTaskState = scheduleTaskStatusJSON.getString("state"); + + if (ScheduleTaskStatusEnum.FINISHED.name().equals(scheduleTaskState)){ + newTaskState = TaskStatusEnum.FINISHED.getCode(); + } else if (ScheduleTaskStatusEnum.isFinalState(scheduleTaskState)) { + newTaskState = TaskStatusEnum.CANCELED.getCode(); + task.setRemark("无路由或取消:" + scheduleTaskState); + } else if (ScheduleTaskStatusEnum.BEING_PROCESSED.name().equals(scheduleTaskState)) { + newTaskState = TaskStatusEnum.EXECUTING.getCode(); + // 充电和加水任务的目标点是调度分配的,在查询任务状态时更新目标点。 + if (StrUtil.isBlank(task.getDestinations()) && ObjectUtil.isNotEmpty(scheduleTaskStatusJSON.getJSONArray("destinations"))){ + JSONObject destination = scheduleTaskStatusJSON.getJSONArray("destinations").getJSONObject(0); + task.setDestinations(destination.getString("locationName")); + } + task.setProcessingVehicle(scheduleTaskStatusJSON.getString("processingVehicle")); + } + }else { + log.info("获取调度任务状态失败"); + // status = 404 调度返回未找到该任务 任务状态更新成已取消 + if (result.getStatus() == HttpStatus.NOT_FOUND.value()){ + newTaskState = TaskStatusEnum.CANCELED.getCode(); + task.setRemark("调度不存在该任务"); } - task.setProcessingVehicle(scheduleTaskStatusJSON.getString("processingVehicle")); } // 任务状态改变 进行更新 if (StrUtil.isNotBlank(newTaskState) && !newTaskState.equals(task.getStatus())){ diff --git a/nl-common/src/main/java/org/nl/util/URLConstant.java b/nl-common/src/main/java/org/nl/util/URLConstant.java index 470dd0c..3e7694f 100644 --- a/nl-common/src/main/java/org/nl/util/URLConstant.java +++ b/nl-common/src/main/java/org/nl/util/URLConstant.java @@ -10,4 +10,9 @@ public class URLConstant { * 调度IP及端口 */ public static String SCHEDULE_IP_PORT = "127.0.0.1:55200"; + + /** + * otaAgent端口 + */ + public static String OTA_AGENT_PORT = "19090"; } diff --git a/nl-web-app/src/main/resources/config/application-prod.yml b/nl-web-app/src/main/resources/config/application-prod.yml index 112ad86..b76911a 100644 --- a/nl-web-app/src/main/resources/config/application-prod.yml +++ b/nl-web-app/src/main/resources/config/application-prod.yml @@ -77,6 +77,10 @@ file: path: /home/pi/nl_robot/map/ qrcode: /home/pi/nl_robot/qrcode/ avatar: /home/pi/nl_robot/avatar/ +# docker 模式用以下路径 +# path: /app/data/file/ +# qrcode: /app/data/qrcode/ +# avatar: /app/data/avatar/ windows: path: C:\eladmin\file\currentMap\ qrcode: C:\eladmin\qrcode\ diff --git a/nl-web-app/src/main/resources/config/application.yml b/nl-web-app/src/main/resources/config/application.yml index 1236ad1..e73a05e 100644 --- a/nl-web-app/src/main/resources/config/application.yml +++ b/nl-web-app/src/main/resources/config/application.yml @@ -48,6 +48,7 @@ security: - /schedule/setting/** - /external/api/** - /task/** + - /api/otaAgent/** - /mapinfo/** - /security/** - /mapMonitor/** diff --git a/nl-web-app/src/main/resources/language/buss/buss.properties b/nl-web-app/src/main/resources/language/buss/buss.properties index e731ab5..85e750a 100644 --- a/nl-web-app/src/main/resources/language/buss/buss.properties +++ b/nl-web-app/src/main/resources/language/buss/buss.properties @@ -34,6 +34,7 @@ setting_charge_call_value_empty = 修改充电时是否可呼叫,设置值和是 setting_usable_task_failed = 设置调度可接任务阈值失败 setting_update_failed = 更新设置失败:{0} setting_volume_failed = 更新音量失败 +setting_thresholds_failed = 更新水量和电量阈值失败 # 任务相关 task_type_not_exist = 任务类型不存在 @@ -142,4 +143,10 @@ validation_schedule_one_click_type_empty = 调度一键任务类型不能为空 validation_speed_empty = 速度不能为空 validation_role_name_empty = 角色名称不能为空 validation_dept_name_empty = 部门名称不能为空 -validation_dept_is_used_empty = 部门状态不能为空 \ No newline at end of file +validation_dept_is_used_empty = 部门状态不能为空 + +# otaAgent相关 +otaAgentGetStatusFailed = 检测更新失败 +otaAgentConfirmFailed = 确认更新失败 +otaAgentPostponeFailed = 推迟更新通知失败 +otaAgentConfirmCheckFailed = 升级条件不满足:电量不能低于50,当前不能存在任务 diff --git a/nl-web-app/src/main/resources/language/buss/buss_en_US.properties b/nl-web-app/src/main/resources/language/buss/buss_en_US.properties index a8e1be1..8a992e9 100644 --- a/nl-web-app/src/main/resources/language/buss/buss_en_US.properties +++ b/nl-web-app/src/main/resources/language/buss/buss_en_US.properties @@ -34,6 +34,7 @@ setting_charge_call_value_empty = Modify charge call, setting value and enable v setting_usable_task_failed = Failed to set schedule usable task threshold setting_update_failed = Failed to update setting: {0} setting_volume_failed = Failed to update volume +setting_thresholds_failed = Failing to update water and battery thresholds # Task related task_type_not_exist = Task type does not exist @@ -143,3 +144,9 @@ validation_speed_empty = Speed cannot be empty validation_role_name_empty = Role name cannot be empty validation_dept_name_empty = Department name cannot be empty validation_dept_is_used_empty = Department status cannot be empty + +# otaAgent相关 +otaAgentGetStatusFailed = Detection update failed +otaAgentConfirmFailed = Confirm that the update failed +otaAgentPostponeFailed = Delay update notifications fail +otaAgentConfirmCheckFailed = Upgrade conditions are not met: The battery cannot be less than 50, and there are currently no missions \ No newline at end of file diff --git a/nl-web-app/src/main/resources/language/buss/buss_zh_CN.properties b/nl-web-app/src/main/resources/language/buss/buss_zh_CN.properties index ea15b36..01ea4e3 100644 --- a/nl-web-app/src/main/resources/language/buss/buss_zh_CN.properties +++ b/nl-web-app/src/main/resources/language/buss/buss_zh_CN.properties @@ -34,6 +34,7 @@ setting_charge_call_value_empty = 修改充电时是否可呼叫,设置值和是 setting_usable_task_failed = 设置调度可接任务阈值失败 setting_update_failed = 更新设置失败:{0} setting_volume_failed = 更新音量失败 +setting_thresholds_failed = 更新水量和电量阈值失败 # 任务相关 task_type_not_exist = 任务类型不存在 @@ -143,3 +144,9 @@ validation_speed_empty = 速度不能为空 validation_role_name_empty = 角色名称不能为空 validation_dept_name_empty = 部门名称不能为空 validation_dept_is_used_empty = 部门状态不能为空 + +# otaAgent相关 +otaAgentGetStatusFailed = 检测更新失败 +otaAgentConfirmFailed = 确认更新失败 +otaAgentPostponeFailed = 推迟更新通知失败 +otaAgentConfirmCheckFailed = 升级条件不满足:电量不能低于50,当前不能存在任务 \ No newline at end of file