add:1.增加后台管理强制取消任务接口。2.修改设置车辆冰量和水量逻辑。3.增加OTA远程更新功能。4.补充国际化。5.增加调度任务不存在同步取消数据库任务。
This commit is contained in:
@@ -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<Object> settingVolume(@RequestBody VolumeParam param){
|
||||
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.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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,4 +83,14 @@ public class VehicleInfoDto{
|
||||
* 车辆模式(0配送,1循环)
|
||||
*/
|
||||
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.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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user