add:1.增加后台管理强制取消任务接口。2.修改设置车辆冰量和水量逻辑。3.增加OTA远程更新功能。4.补充国际化。5.增加调度任务不存在同步取消数据库任务。
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -49,6 +49,13 @@ public interface TaskAPI {
|
|||||||
*/
|
*/
|
||||||
WebResponse cancelTask(String taskCode);
|
WebResponse cancelTask(String taskCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 强制取消任务
|
||||||
|
* @param taskCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
WebResponse forceCancelTask(String taskCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据房间号查询任务信息
|
* 根据房间号查询任务信息
|
||||||
* @param room
|
* @param room
|
||||||
|
|||||||
@@ -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<Object> getStatus(@RequestParam String vehicleId){
|
||||||
|
return new ResponseEntity<>(otaAgentService.getStatus(vehicleId), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/confirm")
|
||||||
|
@Log("确认更新Agent")
|
||||||
|
public ResponseEntity<Object> confirm(@RequestBody ConfirmParam confirmParam){
|
||||||
|
return new ResponseEntity<>(otaAgentService.confirm(confirmParam), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/postpone")
|
||||||
|
@Log("暂不更新Agent")
|
||||||
|
public ResponseEntity<Object> postpone(@RequestBody PostponeParam postponeParam){
|
||||||
|
return new ResponseEntity<>(otaAgentService.postpone(postponeParam), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,14 +3,12 @@ package org.nl.schedule.modular.setting.controller;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.nl.logging.annotation.Log;
|
import org.nl.logging.annotation.Log;
|
||||||
import org.nl.schedule.modular.setting.param.NetworkParam;
|
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.param.VolumeParam;
|
||||||
import org.nl.schedule.modular.setting.service.ScheduleSettingService;
|
import org.nl.schedule.modular.setting.service.ScheduleSettingService;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dsh
|
* @author dsh
|
||||||
@@ -34,4 +32,10 @@ public class ScheduleSettingController {
|
|||||||
public ResponseEntity<Object> settingVolume(@RequestBody VolumeParam param){
|
public ResponseEntity<Object> settingVolume(@RequestBody VolumeParam param){
|
||||||
return new ResponseEntity<>(scheduleSettingService.settingVolume(param), HttpStatus.OK);
|
return new ResponseEntity<>(scheduleSettingService.settingVolume(param), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log("设置车辆水量和电量阈值")
|
||||||
|
@PostMapping("/settingThresholds")
|
||||||
|
public ResponseEntity<Object> settingBatteryThresholds(@RequestBody ThresholdsParam param, @RequestParam String vehicleId){
|
||||||
|
return new ResponseEntity<>(scheduleSettingService.settingThresholds(param,vehicleId), HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package org.nl.schedule.modular.setting.service;
|
|||||||
|
|
||||||
import org.nl.response.WebResponse;
|
import org.nl.response.WebResponse;
|
||||||
import org.nl.schedule.modular.setting.param.NetworkParam;
|
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.param.VolumeParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,4 +25,11 @@ public interface ScheduleSettingService {
|
|||||||
*/
|
*/
|
||||||
WebResponse settingVolume(VolumeParam param);
|
WebResponse settingVolume(VolumeParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 水量电量阈值设置
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
WebResponse settingThresholds(ThresholdsParam param,String vehicleId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.nl.config.language.LangProcess;
|
|||||||
import org.nl.exception.BadRequestException;
|
import org.nl.exception.BadRequestException;
|
||||||
import org.nl.response.WebResponse;
|
import org.nl.response.WebResponse;
|
||||||
import org.nl.schedule.modular.setting.param.NetworkParam;
|
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.param.VolumeParam;
|
||||||
import org.nl.schedule.modular.setting.service.ScheduleSettingService;
|
import org.nl.schedule.modular.setting.service.ScheduleSettingService;
|
||||||
import org.nl.util.URLConstant;
|
import org.nl.util.URLConstant;
|
||||||
@@ -68,4 +69,25 @@ public class ScheduleSettingServiceImpl implements ScheduleSettingService {
|
|||||||
}
|
}
|
||||||
throw new BadRequestException(LangProcess.msg("setting_volume_failed"));
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,4 +83,14 @@ public class VehicleInfoDto{
|
|||||||
* 车辆模式(0配送,1循环)
|
* 车辆模式(0配送,1循环)
|
||||||
*/
|
*/
|
||||||
private String vehicleMode;
|
private String vehicleMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性
|
||||||
|
*/
|
||||||
|
private JSONObject attributes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电量阈值
|
||||||
|
*/
|
||||||
|
private JSONObject batteryThresholds;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,10 +19,7 @@ import org.nl.util.URLConstant;
|
|||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ public class Param implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值(英文)
|
||||||
|
*/
|
||||||
|
private String en_value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.nl.enums.TaskSourceEnum;
|
|||||||
import org.nl.logging.annotation.Log;
|
import org.nl.logging.annotation.Log;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +34,12 @@ public class ManagerTaskController {
|
|||||||
return new ResponseEntity<>(taskAPI.cancelTask(taskCode), HttpStatus.OK);
|
return new ResponseEntity<>(taskAPI.cancelTask(taskCode), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/forceCancelTask")
|
||||||
|
@Log("后台管理系统强制取消任务")
|
||||||
|
public ResponseEntity<Object> forceCancelTask(@RequestParam String taskCode){
|
||||||
|
return new ResponseEntity<>(taskAPI.forceCancelTask(taskCode), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@Log("后台管理系统一键任务")
|
@Log("后台管理系统一键任务")
|
||||||
@PostMapping("/oneClickOperation")
|
@PostMapping("/oneClickOperation")
|
||||||
public ResponseEntity<Object> oneClickOperation(@RequestBody OneClickOperationRequestParam oneClickOperationRequestParam){
|
public ResponseEntity<Object> oneClickOperation(@RequestBody OneClickOperationRequestParam oneClickOperationRequestParam){
|
||||||
|
|||||||
@@ -102,6 +102,13 @@ public class TaskAPIProvider implements TaskAPI {
|
|||||||
return taskService.cancelTask(param);
|
return taskService.cancelTask(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebResponse forceCancelTask(String taskCode) {
|
||||||
|
CancelTaskRequestParam param = new CancelTaskRequestParam();
|
||||||
|
param.setTask_code(taskCode);
|
||||||
|
return taskService.forceCancelTask(param);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WebResponse queryTaskInfoByRoom(String room) {
|
public WebResponse queryTaskInfoByRoom(String room) {
|
||||||
// 获取当前存在的任务
|
// 获取当前存在的任务
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import org.nl.task.param.*;
|
|||||||
import org.nl.task.service.TaskService;
|
import org.nl.task.service.TaskService;
|
||||||
import org.nl.util.IdUtil;
|
import org.nl.util.IdUtil;
|
||||||
import org.nl.util.TaskCodeGeneratorUtil;
|
import org.nl.util.TaskCodeGeneratorUtil;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -91,27 +92,33 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper,Task> implements Tas
|
|||||||
Collectors.toList()
|
Collectors.toList()
|
||||||
));
|
));
|
||||||
for (Task task : taskList) {
|
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 = "";
|
String newTaskState = "";
|
||||||
if (ScheduleTaskStatusEnum.FINISHED.name().equals(scheduleTaskState)){
|
HttpResponse result = scheduleTaskAPI.queryTaskStatusByTaskId(task.getTask_code());
|
||||||
newTaskState = TaskStatusEnum.FINISHED.getCode();
|
if (result.isOk()){
|
||||||
} else if (ScheduleTaskStatusEnum.isFinalState(scheduleTaskState)) {
|
JSONObject scheduleTaskStatusJSON = JSONObject.parseObject(result.body());
|
||||||
newTaskState = TaskStatusEnum.CANCELED.getCode();
|
String scheduleTaskState = scheduleTaskStatusJSON.getString("state");
|
||||||
task.setRemark("无路由或取消:" + scheduleTaskState);
|
|
||||||
} else if (ScheduleTaskStatusEnum.BEING_PROCESSED.name().equals(scheduleTaskState)) {
|
if (ScheduleTaskStatusEnum.FINISHED.name().equals(scheduleTaskState)){
|
||||||
newTaskState = TaskStatusEnum.EXECUTING.getCode();
|
newTaskState = TaskStatusEnum.FINISHED.getCode();
|
||||||
// 充电和加水任务的目标点是调度分配的,在查询任务状态时更新目标点。
|
} else if (ScheduleTaskStatusEnum.isFinalState(scheduleTaskState)) {
|
||||||
if (StrUtil.isBlank(task.getDestinations()) && ObjectUtil.isNotEmpty(scheduleTaskStatusJSON.getJSONArray("destinations"))){
|
newTaskState = TaskStatusEnum.CANCELED.getCode();
|
||||||
JSONObject destination = scheduleTaskStatusJSON.getJSONArray("destinations").getJSONObject(0);
|
task.setRemark("无路由或取消:" + scheduleTaskState);
|
||||||
task.setDestinations(destination.getString("locationName"));
|
} 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())){
|
if (StrUtil.isNotBlank(newTaskState) && !newTaskState.equals(task.getStatus())){
|
||||||
|
|||||||
@@ -10,4 +10,9 @@ public class URLConstant {
|
|||||||
* 调度IP及端口
|
* 调度IP及端口
|
||||||
*/
|
*/
|
||||||
public static String SCHEDULE_IP_PORT = "127.0.0.1:55200";
|
public static String SCHEDULE_IP_PORT = "127.0.0.1:55200";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* otaAgent端口
|
||||||
|
*/
|
||||||
|
public static String OTA_AGENT_PORT = "19090";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ file:
|
|||||||
path: /home/pi/nl_robot/map/
|
path: /home/pi/nl_robot/map/
|
||||||
qrcode: /home/pi/nl_robot/qrcode/
|
qrcode: /home/pi/nl_robot/qrcode/
|
||||||
avatar: /home/pi/nl_robot/avatar/
|
avatar: /home/pi/nl_robot/avatar/
|
||||||
|
# docker 模式用以下路径
|
||||||
|
# path: /app/data/file/
|
||||||
|
# qrcode: /app/data/qrcode/
|
||||||
|
# avatar: /app/data/avatar/
|
||||||
windows:
|
windows:
|
||||||
path: C:\eladmin\file\currentMap\
|
path: C:\eladmin\file\currentMap\
|
||||||
qrcode: C:\eladmin\qrcode\
|
qrcode: C:\eladmin\qrcode\
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ security:
|
|||||||
- /schedule/setting/**
|
- /schedule/setting/**
|
||||||
- /external/api/**
|
- /external/api/**
|
||||||
- /task/**
|
- /task/**
|
||||||
|
- /api/otaAgent/**
|
||||||
- /mapinfo/**
|
- /mapinfo/**
|
||||||
- /security/**
|
- /security/**
|
||||||
- /mapMonitor/**
|
- /mapMonitor/**
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ setting_charge_call_value_empty = 修改充电时是否可呼叫,设置值和是
|
|||||||
setting_usable_task_failed = 设置调度可接任务阈值失败
|
setting_usable_task_failed = 设置调度可接任务阈值失败
|
||||||
setting_update_failed = 更新设置失败:{0}
|
setting_update_failed = 更新设置失败:{0}
|
||||||
setting_volume_failed = 更新音量失败
|
setting_volume_failed = 更新音量失败
|
||||||
|
setting_thresholds_failed = 更新水量和电量阈值失败
|
||||||
|
|
||||||
# 任务相关
|
# 任务相关
|
||||||
task_type_not_exist = 任务类型不存在
|
task_type_not_exist = 任务类型不存在
|
||||||
@@ -142,4 +143,10 @@ validation_schedule_one_click_type_empty = 调度一键任务类型不能为空
|
|||||||
validation_speed_empty = 速度不能为空
|
validation_speed_empty = 速度不能为空
|
||||||
validation_role_name_empty = 角色名称不能为空
|
validation_role_name_empty = 角色名称不能为空
|
||||||
validation_dept_name_empty = 部门名称不能为空
|
validation_dept_name_empty = 部门名称不能为空
|
||||||
validation_dept_is_used_empty = 部门状态不能为空
|
validation_dept_is_used_empty = 部门状态不能为空
|
||||||
|
|
||||||
|
# otaAgent相关
|
||||||
|
otaAgentGetStatusFailed = 检测更新失败
|
||||||
|
otaAgentConfirmFailed = 确认更新失败
|
||||||
|
otaAgentPostponeFailed = 推迟更新通知失败
|
||||||
|
otaAgentConfirmCheckFailed = 升级条件不满足:电量不能低于50,当前不能存在任务
|
||||||
|
|||||||
@@ -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_usable_task_failed = Failed to set schedule usable task threshold
|
||||||
setting_update_failed = Failed to update setting: {0}
|
setting_update_failed = Failed to update setting: {0}
|
||||||
setting_volume_failed = Failed to update volume
|
setting_volume_failed = Failed to update volume
|
||||||
|
setting_thresholds_failed = Failing to update water and battery thresholds
|
||||||
|
|
||||||
# Task related
|
# Task related
|
||||||
task_type_not_exist = Task type does not exist
|
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_role_name_empty = Role name cannot be empty
|
||||||
validation_dept_name_empty = Department name cannot be empty
|
validation_dept_name_empty = Department name cannot be empty
|
||||||
validation_dept_is_used_empty = Department status 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
|
||||||
@@ -34,6 +34,7 @@ setting_charge_call_value_empty = 修改充电时是否可呼叫,设置值和是
|
|||||||
setting_usable_task_failed = 设置调度可接任务阈值失败
|
setting_usable_task_failed = 设置调度可接任务阈值失败
|
||||||
setting_update_failed = 更新设置失败:{0}
|
setting_update_failed = 更新设置失败:{0}
|
||||||
setting_volume_failed = 更新音量失败
|
setting_volume_failed = 更新音量失败
|
||||||
|
setting_thresholds_failed = 更新水量和电量阈值失败
|
||||||
|
|
||||||
# 任务相关
|
# 任务相关
|
||||||
task_type_not_exist = 任务类型不存在
|
task_type_not_exist = 任务类型不存在
|
||||||
@@ -143,3 +144,9 @@ validation_speed_empty = 速度不能为空
|
|||||||
validation_role_name_empty = 角色名称不能为空
|
validation_role_name_empty = 角色名称不能为空
|
||||||
validation_dept_name_empty = 部门名称不能为空
|
validation_dept_name_empty = 部门名称不能为空
|
||||||
validation_dept_is_used_empty = 部门状态不能为空
|
validation_dept_is_used_empty = 部门状态不能为空
|
||||||
|
|
||||||
|
# otaAgent相关
|
||||||
|
otaAgentGetStatusFailed = 检测更新失败
|
||||||
|
otaAgentConfirmFailed = 确认更新失败
|
||||||
|
otaAgentPostponeFailed = 推迟更新通知失败
|
||||||
|
otaAgentConfirmCheckFailed = 升级条件不满足:电量不能低于50,当前不能存在任务
|
||||||
Reference in New Issue
Block a user