opt:1.管理后台系统优化国际化。2.添加巡航模式任务接口。

This commit is contained in:
2026-03-03 19:46:06 +08:00
parent 4247b41831
commit 65c6d41e4b
31 changed files with 545 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ package org.nl.api.schedule.task.api;
import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.nl.api.schedule.task.core.ScheduleAPICreateCruiseTaskParam;
import org.nl.api.schedule.task.core.ScheduleAPICreateOneClickTaskParam; import org.nl.api.schedule.task.core.ScheduleAPICreateOneClickTaskParam;
import org.nl.api.schedule.task.core.ScheduleAPICreateTaskParam; import org.nl.api.schedule.task.core.ScheduleAPICreateTaskParam;
@@ -55,4 +56,11 @@ public interface ScheduleTaskAPI {
* @return * @return
*/ */
HttpResponse oneClickOperationTask(ScheduleAPICreateOneClickTaskParam scheduleAPICreateOneClickTaskParam); HttpResponse oneClickOperationTask(ScheduleAPICreateOneClickTaskParam scheduleAPICreateOneClickTaskParam);
/**
* 创建调度巡航任务
* @param param
* @return
*/
HttpResponse createCruiseTask(ScheduleAPICreateCruiseTaskParam param);
} }

View File

@@ -0,0 +1,37 @@
package org.nl.api.schedule.task.core;
import lombok.Data;
import java.util.List;
/**
* @author dsh
* 2026/3/3
*/
@Data
public class ScheduleAPICreateCruiseTaskParam {
/**
* 任务号
*/
private String task_code;
/**
* 目标点
*/
private List<String> destinations;
/**
* 任务类型
*/
private String type;
/**
* 任务优先级 (1-10数字越低优先级越高)
*/
private String priority;
/**
* 指定车号
*/
private String vehicle_number;
}

View File

@@ -9,11 +9,11 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>nl-business-media</artifactId> <artifactId>nl-business-externalApi</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<description> <description>
媒体模块 外部API模块
处理音乐和SOP文档 提供外部访问API
</description> </description>
<properties> <properties>

View File

@@ -1,4 +1,4 @@
package org.nl.media; package org.nl.externalApi;
/** /**
* @Author: lyd * @Author: lyd

View File

@@ -0,0 +1,49 @@
package org.nl.externalApi.task.controller;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.nl.externalApi.task.param.CreateTaskParam;
import org.nl.externalApi.task.service.ExternalTaskService;
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.*;
/**
* @author dsh
* 2026/2/24
*/
@RestController
@RequestMapping("/external/api")
@Validated
@Slf4j
public class ExternalTaskController {
@Resource
private ExternalTaskService externalTaskService;
@PostMapping("/createTask")
@Log("外部API:创建任务")
public ResponseEntity<Object> createTask(@RequestBody CreateTaskParam createTaskParam){
return new ResponseEntity<>(externalTaskService.createTask(createTaskParam), HttpStatus.OK);
}
@PostMapping("/cancelTask/{id}")
@Log("外部API:取消任务任务")
public ResponseEntity<Object> cancelTask(@PathVariable String id){
return new ResponseEntity<>(externalTaskService.cancelTask(id), HttpStatus.OK);
}
@GetMapping("/getTaskInfos")
@Log("外部API:查询所有未完成的任务")
public ResponseEntity<Object> getTaskInfos(){
return new ResponseEntity<>(externalTaskService.getTaskInfos(), HttpStatus.OK);
}
@GetMapping("/getTaskInfos/{id}")
@Log("外部API:根据任务号查询任务")
public ResponseEntity<Object> getTaskInfosById(@PathVariable String id){
return new ResponseEntity<>(externalTaskService.getTaskInfosById(id), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,35 @@
package org.nl.externalApi.task.param;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
/**
* 外部API创建任务参数
* @author dsh
* 2026/2/24
*/
@Data
public class CreateTaskParam {
/**
* 目的地
*/
@NotBlank(message = "目的地不能为空")
private String destinations;
/**
* 任务类型
*/
@NotBlank(message = "任务类型不能为空")
private String type;
/**
* 优先级
*/
private String priority;
/**
* 指定车辆
*/
private String vehicle_number;
}

View File

@@ -0,0 +1,38 @@
package org.nl.externalApi.task.service;
import org.nl.externalApi.task.param.CreateTaskParam;
import org.nl.response.WebResponse;
/**
* @author dsh
* 2026/2/24
*/
public interface ExternalTaskService {
/**
* 外部API 创建任务
* @param createTaskParam
* @return WebResponse
*/
WebResponse createTask(CreateTaskParam createTaskParam);
/**
* 外部API 取消任务
* @param task_code
* @return WebResponse
*/
WebResponse cancelTask(String task_code);
/**
* 外部API 查询所有未完成的任务信息
* @return WebResponse
*/
WebResponse getTaskInfos();
/**
* 根据任务号查询任务信息
* @param task_code
* @return WebResponse
*/
WebResponse getTaskInfosById(String task_code);
}

View File

@@ -0,0 +1,39 @@
package org.nl.externalApi.task.service.impl;
import jakarta.annotation.Resource;
import org.nl.api.task.api.TaskAPI;
import org.nl.externalApi.task.param.CreateTaskParam;
import org.nl.externalApi.task.service.ExternalTaskService;
import org.nl.response.WebResponse;
import org.springframework.stereotype.Service;
/**
* @author dsh
* 2026/2/24
*/
@Service
public class ExternalTaskServiceImpl implements ExternalTaskService {
@Resource
private TaskAPI taskAPI;
@Override
public WebResponse createTask(CreateTaskParam createTaskParam) {
return null;
}
@Override
public WebResponse cancelTask(String task_code) {
return null;
}
@Override
public WebResponse getTaskInfos() {
return null;
}
@Override
public WebResponse getTaskInfosById(String task_code) {
return null;
}
}

View File

@@ -0,0 +1,28 @@
package org.nl.schedule.modular.setting.controller;
import jakarta.annotation.Resource;
import org.nl.schedule.modular.setting.param.NetworkParam;
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;
/**
* @author dsh
* 2026/3/2
*/
@RestController
@RequestMapping("/schedule/setting")
public class ScheduleSettingController {
@Resource
private ScheduleSettingService scheduleSettingService;
@PostMapping("/networkOperation")
public ResponseEntity<Object> networkOperation(@RequestBody NetworkParam param){
return new ResponseEntity<>(scheduleSettingService.networkOperation(param), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,30 @@
package org.nl.schedule.modular.setting.param;
import lombok.Data;
/**
* @author dsh
* 2026/3/2
*/
@Data
public class NetworkParam {
/**
* 命令 取值范围:[connectdisconnectstatusscan]分别是连接断开wifi状态扫描wifi
*/
private String command;
/**
* 车号
*/
private String agvId;
/**
* wifi名称
*/
private String ssid;
/**
* wifi密码
*/
private String password;
}

View File

@@ -0,0 +1,18 @@
package org.nl.schedule.modular.setting.service;
import org.nl.response.WebResponse;
import org.nl.schedule.modular.setting.param.NetworkParam;
/**
* @author dsh
* 2026/3/2
*/
public interface ScheduleSettingService {
/**
*
* @param param
* @return
*/
WebResponse networkOperation(NetworkParam param);
}

View File

@@ -0,0 +1,45 @@
package org.nl.schedule.modular.setting.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
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.service.ScheduleSettingService;
import org.nl.util.URLConstant;
import org.springframework.stereotype.Service;
/**
* @author dsh
* 2026/3/2
*/
@Slf4j
@Service
public class ScheduleSettingServiceImpl implements ScheduleSettingService {
@Override
public WebResponse networkOperation(NetworkParam param) {
if (ObjectUtil.isEmpty(param)){
throw new BadRequestException(LangProcess.msg("schedule_wifi_param_empty"));
}
log.info("调度网络操作参数:{}", param);
HttpResponse result = null;
try {
result = HttpRequest.post(URLConstant.SCHEDULE_IP_PORT+"/system/network/wifi")
.body(String.valueOf(JSONObject.toJSON(param)))
.execute();
if (result !=null && result.isOk()){
log.info("调度网络操作响应结果:{}",result.body());
return WebResponse.requestParamOk(JSON.parseObject(result.body()));
}
}catch (Exception e){
log.info("调度网络操作参数失败");
}
throw new BadRequestException(LangProcess.msg("schedule_wifi_param_error"));
}
}

View File

@@ -1,5 +1,6 @@
package org.nl.schedule.modular.task.provider; package org.nl.schedule.modular.task.provider;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpResponse;
@@ -7,6 +8,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.api.schedule.task.api.ScheduleTaskAPI; import org.nl.api.schedule.task.api.ScheduleTaskAPI;
import org.nl.api.schedule.task.core.ScheduleAPICreateCruiseTaskParam;
import org.nl.api.schedule.task.core.ScheduleAPICreateOneClickTaskParam; import org.nl.api.schedule.task.core.ScheduleAPICreateOneClickTaskParam;
import org.nl.api.schedule.task.core.ScheduleAPICreateTaskParam; import org.nl.api.schedule.task.core.ScheduleAPICreateTaskParam;
import org.nl.config.language.LangProcess; import org.nl.config.language.LangProcess;
@@ -15,6 +17,8 @@ import org.nl.schedule.core.util.ScheduleUtil;
import org.nl.util.URLConstant; import org.nl.util.URLConstant;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @author dsh * @author dsh
* 2025/12/1 * 2025/12/1
@@ -181,4 +185,51 @@ public class ScheduleTaskAPIProvider implements ScheduleTaskAPI {
} }
return result; return result;
} }
@Override
public HttpResponse createCruiseTask(ScheduleAPICreateCruiseTaskParam param) {
String task_code = param.getTask_code();
List<String> destinations = param.getDestinations();
String type = param.getType();
if (StrUtil.isBlank(task_code)){
throw new BadRequestException(LangProcess.msg("schedule_task_code_empty"));
}
if (ObjectUtil.isEmpty(destinations)){
throw new BadRequestException(LangProcess.msg("schedule_destinations_empty"));
}
if (StrUtil.isBlank(type)){
throw new BadRequestException(LangProcess.msg("schedule_operation_type_empty"));
}
JSONObject request_body = new JSONObject();
request_body.put("deadline", ScheduleUtil.getNextDay(1));
if (StrUtil.isNotBlank(param.getVehicle_number())){
request_body.put("intendedVehicle", param.getVehicle_number());
}
JSONArray body_destinations = new JSONArray();
for (String destination : destinations){
JSONObject body_destination = new JSONObject();
body_destination.put("locationName", destination);
body_destination.put("operation", type);
body_destinations.add(body_destination);
}
request_body.put("destinations", body_destinations);
if (StrUtil.isNotBlank(param.getPriority())){
request_body.put("priority", Integer.parseInt(param.getPriority()));
}
log.info("下发调度巡航任务参数:{}", request_body);
HttpResponse result = null;
try {
result = HttpRequest
.post(URLConstant.SCHEDULE_IP_PORT+"/tasks/"+param.getTask_code())
.body(String.valueOf(request_body))
.execute();
log.info("下发调度巡航任务响应结果:{}",result.body());
}catch (Exception e){
log.error("下发调度巡航任务失败:{}",e.getMessage());
}
return result;
}
} }

View File

@@ -78,4 +78,9 @@ public class VehicleInfoDto{
* 最后更新时间 * 最后更新时间
*/ */
private String lastUpdated; private String lastUpdated;
/**
* 车辆模式(0配送,1循环)
*/
private String vehicleMode;
} }

View File

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.api.setting.api.SettingAPI;
import org.nl.api.sys.anomalyInfo.api.ErrorInfoAPI; import org.nl.api.sys.anomalyInfo.api.ErrorInfoAPI;
import org.nl.api.task.api.TaskAPI; import org.nl.api.task.api.TaskAPI;
import org.nl.response.WebResponse; import org.nl.response.WebResponse;
@@ -43,6 +44,9 @@ public class VehicleServiceImpl implements VehicleService {
@Resource @Resource
private ErrorInfoAPI errorInfoAPI; private ErrorInfoAPI errorInfoAPI;
@Resource
private SettingAPI settingAPI;
/** /**
* 定时更新车辆信息(每秒执行) * 定时更新车辆信息(每秒执行)
*/ */
@@ -60,6 +64,8 @@ public class VehicleServiceImpl implements VehicleService {
if (vehicle.getError_code()!=0) { if (vehicle.getError_code()!=0) {
vehicle.setError_info(errorInfoAPI.queryErrorInfoByCode(vehicle.getError_code())); vehicle.setError_info(errorInfoAPI.queryErrorInfoByCode(vehicle.getError_code()));
} }
// 查询车辆模式
vehicle.setVehicleMode(settingAPI.querySettingParamByCode("mode").getJSONObject("data").getString("value"));
vehicleCache.put(vehicle.getVehicleNumber(), vehicle); vehicleCache.put(vehicle.getVehicleNumber(), vehicle);
} }

View File

@@ -104,4 +104,13 @@ public class Dict implements Serializable {
*/ */
private String update_time; private String update_time;
/**
* 中文字典标签
*/
private String zh_label;
/**
* 英文字典标签
*/
private String en_label;
} }

View File

@@ -60,6 +60,16 @@ public class SysMenu implements Serializable {
*/ */
private String title; private String title;
/**
* 菜单标题
*/
private String zh_title;
/**
* 菜单标题
*/
private String en_title;
/** /**
* 组件名称 * 组件名称
*/ */

View File

@@ -34,6 +34,8 @@ public class MenuDto extends BaseDTO implements Serializable {
private String permission; private String permission;
private String title; private String title;
private String zh_title;
private String en_title;
private Integer menu_sort; private Integer menu_sort;
@@ -90,4 +92,14 @@ public class MenuDto extends BaseDTO implements Serializable {
public int hashCode() { public int hashCode() {
return Objects.hash(menu_id); return Objects.hash(menu_id);
} }
public String getLocalTitle(String local){
if ("en".equals(local)){
return en_title;
}
if ("zh".equals(local)){
return zh_title;
}
return title;
}
} }

View File

@@ -27,6 +27,7 @@ import org.nl.sys.modular.backgroundmanagement.menu.mapper.SysMenuMapper;
import org.nl.sys.modular.backgroundmanagement.menu.service.ISysMenuService; import org.nl.sys.modular.backgroundmanagement.menu.service.ISysMenuService;
import org.nl.util.IdUtil; import org.nl.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -259,11 +260,12 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
@Override @Override
public List<MenuVo> buildMenus(List<MenuDto> menuDtos) { public List<MenuVo> buildMenus(List<MenuDto> menuDtos) {
List<MenuVo> list = new LinkedList<>(); List<MenuVo> list = new LinkedList<>();
String lang = LocaleContextHolder.getLocale().getLanguage();
menuDtos.forEach(menuDTO -> { menuDtos.forEach(menuDTO -> {
if (menuDTO != null) { if (menuDTO != null) {
List<MenuDto> menuDtoList = menuDTO.getChildren(); List<MenuDto> menuDtoList = menuDTO.getChildren();
MenuVo menuVo = new MenuVo(); MenuVo menuVo = new MenuVo();
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getTitle()); menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getLocalTitle(lang));
// 一级目录需要加斜杠,不然会报警告 // 一级目录需要加斜杠,不然会报警告
menuVo.setPath(ObjectUtil.isEmpty(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath()); menuVo.setPath(ObjectUtil.isEmpty(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath());
menuVo.setHidden(menuDTO.getHidden()); menuVo.setHidden(menuDTO.getHidden());
@@ -278,7 +280,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
menuVo.setComponent(menuDTO.getComponent()); menuVo.setComponent(menuDTO.getComponent());
} }
} }
menuVo.setMeta(new MenuMetaVo(menuDTO.getTitle(), menuDTO.getIcon(), !menuDTO.getCache())); menuVo.setMeta(new MenuMetaVo(menuDTO.getLocalTitle(lang), menuDTO.getIcon(), !menuDTO.getCache()));
if (menuDtoList != null && menuDtoList.size() != 0) { if (menuDtoList != null && menuDtoList.size() != 0) {
menuVo.setAlwaysShow(true); menuVo.setAlwaysShow(true);
menuVo.setRedirect("noredirect"); menuVo.setRedirect("noredirect");
@@ -397,12 +399,13 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
@Override @Override
public List<MenuVo> buildMenus(List<MenuDto> menuDtos, String pid) { public List<MenuVo> buildMenus(List<MenuDto> menuDtos, String pid) {
List<MenuVo> list = new LinkedList<>(); List<MenuVo> list = new LinkedList<>();
String lang = LocaleContextHolder.getLocale().getLanguage();
//剔除系统级菜单 //剔除系统级菜单
menuDtos.forEach(menuDTO -> { menuDtos.forEach(menuDTO -> {
if (menuDTO != null) { if (menuDTO != null) {
List<MenuDto> menuDtoList = menuDTO.getChildren(); List<MenuDto> menuDtoList = menuDTO.getChildren();
MenuVo menuVo = new MenuVo(); MenuVo menuVo = new MenuVo();
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getTitle()); menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getLocalTitle(lang));
// 一级目录需要加斜杠,不然会报警告 // 一级目录需要加斜杠,不然会报警告
menuVo.setPath(pid.equals(menuDTO.getPid())? "/" + menuDTO.getPath() : menuDTO.getPath()); menuVo.setPath(pid.equals(menuDTO.getPid())? "/" + menuDTO.getPath() : menuDTO.getPath());
menuVo.setHidden(menuDTO.getHidden()); menuVo.setHidden(menuDTO.getHidden());
@@ -417,7 +420,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
menuVo.setComponent(menuDTO.getComponent()); menuVo.setComponent(menuDTO.getComponent());
} }
} }
menuVo.setMeta(new MenuMetaVo(menuDTO.getTitle(), menuDTO.getIcon(), !menuDTO.getCache())); menuVo.setMeta(new MenuMetaVo(menuDTO.getLocalTitle(lang), menuDTO.getIcon(), !menuDTO.getCache()));
if (menuDtoList != null && menuDtoList.size() != 0) { if (menuDtoList != null && menuDtoList.size() != 0) {
menuVo.setAlwaysShow(true); menuVo.setAlwaysShow(true);
menuVo.setRedirect("noredirect"); menuVo.setRedirect("noredirect");

View File

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.nl.api.setting.api.SettingAPI;
import org.nl.api.task.api.TaskAPI; import org.nl.api.task.api.TaskAPI;
import org.nl.api.task.core.TaskRequestParam; import org.nl.api.task.core.TaskRequestParam;
import org.nl.config.language.LangProcess; import org.nl.config.language.LangProcess;
@@ -44,6 +45,9 @@ public class QRCodeServiceImpl implements QRCodeService {
@Resource @Resource
private QRcodeInfoMapper qrcodeInfoMapper; private QRcodeInfoMapper qrcodeInfoMapper;
@Resource
private SettingAPI settingAPI;
@Resource @Resource
private TaskAPI taskAPI; private TaskAPI taskAPI;
@@ -150,8 +154,12 @@ public class QRCodeServiceImpl implements QRCodeService {
@Override @Override
public WebResponse createTask(TaskRequestParam qrCodeTaskRequestParam) { public WebResponse createTask(TaskRequestParam qrCodeTaskRequestParam) {
taskAPI.createTask(qrCodeTaskRequestParam, TaskSourceEnum.QRCODE.getName()); String mode = settingAPI.querySettingParamByCode("mode").getJSONObject("data").getString("value");
return null; // 判断是否在巡航模式 再巡航模式不能下发二维码任务
if ("1".equals(mode)){
throw new BadRequestException(LangProcess.msg("qrcode_create_failed_mode"));
}
return taskAPI.createTask(qrCodeTaskRequestParam, TaskSourceEnum.QRCODE.getName());
} }
@Override @Override

View File

@@ -77,4 +77,10 @@ public class TaskController {
return new ResponseEntity<>(taskService.queryCurrentTaskInfo(),HttpStatus.OK); return new ResponseEntity<>(taskService.queryCurrentTaskInfo(),HttpStatus.OK);
} }
@PostMapping("/createCruiseTask")
@Log("创建巡航任务")
public ResponseEntity<Object> createCruiseTask(@RequestBody @Validated CreateCruiseTaskRequestParam createCruiseTaskRequestParam){
return new ResponseEntity<>(taskService.createCruiseTask(createCruiseTaskRequestParam), HttpStatus.OK);
}
} }

View File

@@ -24,7 +24,11 @@ public enum TaskTypeEnum {
/** /**
* 移动 * 移动
*/ */
MOVE("3", "Move", "移动"); MOVE("3", "Move", "移动"),
/**
* 巡航
*/
CRUISE("4", "cruise", "巡航");
private String code; private String code;
private String name; private String name;
@@ -46,7 +50,8 @@ public enum TaskTypeEnum {
return TaskTypeEnum.DELIVER.getName().equals(taskType) return TaskTypeEnum.DELIVER.getName().equals(taskType)
|| TaskTypeEnum.CHARGE.getName().equals(taskType) || TaskTypeEnum.CHARGE.getName().equals(taskType)
|| TaskTypeEnum.REFILL.getName().equals(taskType) || TaskTypeEnum.REFILL.getName().equals(taskType)
|| TaskTypeEnum.MOVE.getName().equals(taskType); || TaskTypeEnum.MOVE.getName().equals(taskType)
|| TaskTypeEnum.CRUISE.getName().equals(taskType);
} }

View File

@@ -0,0 +1,30 @@
package org.nl.task.param;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import java.util.List;
/**
* @author dsh
* 2026/3/3
*/
@Data
public class CreateCruiseTaskRequestParam {
/**
* 巡航站点集合
*/
private List<String> destinations;
/**
* 任务类型
*/
@NotBlank(message = "任务类型不能为空")
private String type;
/**
* 指定车号
*/
private String vehicle_number;
}

View File

@@ -73,4 +73,11 @@ public interface TaskService extends IService<Task>{
* @return List<Task> * @return List<Task>
*/ */
List<Task> queryCurrentTaskInfo(); List<Task> queryCurrentTaskInfo();
/**
* 创建巡航任务
* @return WebResponse
*/
WebResponse createCruiseTask(CreateCruiseTaskRequestParam param);
} }

View File

@@ -16,10 +16,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.api.schedule.task.api.ScheduleTaskAPI; import org.nl.api.schedule.task.api.ScheduleTaskAPI;
import org.nl.api.schedule.task.core.ScheduleAPICreateCruiseTaskParam;
import org.nl.api.schedule.task.core.ScheduleAPICreateOneClickTaskParam; import org.nl.api.schedule.task.core.ScheduleAPICreateOneClickTaskParam;
import org.nl.api.schedule.task.core.ScheduleAPICreateTaskParam; import org.nl.api.schedule.task.core.ScheduleAPICreateTaskParam;
import org.nl.config.language.LangProcess; import org.nl.config.language.LangProcess;
import org.nl.enums.ScheduleTaskReportStatusEnum; import org.nl.enums.ScheduleTaskReportStatusEnum;
import org.nl.enums.TaskSourceEnum;
import org.nl.enums.YesOrNoEnum; import org.nl.enums.YesOrNoEnum;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.response.WebResponse; import org.nl.response.WebResponse;
@@ -326,4 +328,38 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper,Task> implements Tas
return currentTaskList; return currentTaskList;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public WebResponse createCruiseTask(CreateCruiseTaskRequestParam param) {
try {
if (!TaskTypeEnum.CRUISE.getName().equals(param.getType())) {
throw new BadRequestException(LangProcess.msg("create_cruise_task_error"));
}
Task task = BeanUtil.copyProperties(param, Task.class);
task.setDestinations(TaskTypeEnum.CRUISE.getName());
task.setId(IdUtil.getStringId());
if (StrUtil.isBlank(task.getTask_code())){
task.setTask_code(TaskCodeGeneratorUtil.generateTaskId());
}
task.setType(param.getType());
task.setSource(TaskSourceEnum.SCREEN.getName());
task.setStatus(TaskStatusEnum.CREATE.getCode());
task.setIsPause(YesOrNoEnum.NO.getCode());
task.setVehicleReportStatus("0");
task.setCreate_time(DateUtil.now());
taskMapper.insert(task);
ScheduleAPICreateCruiseTaskParam scheduleAPICreateCruiseTaskParam = BeanUtil.copyProperties(task, ScheduleAPICreateCruiseTaskParam.class);
scheduleAPICreateCruiseTaskParam.setDestinations(param.getDestinations());
HttpResponse result = scheduleTaskAPI.createCruiseTask(scheduleAPICreateCruiseTaskParam);
if (result == null || !result.isOk()){
throw new BadRequestException(LangProcess.msg("task_schedule_create_failed"));
}
return WebResponse.requestOk();
}catch (Exception e){
log.error("创建巡航任务失败:{}",e.getMessage());
throw new BadRequestException(LangProcess.msg("task_create_failed",e.getMessage()));
}
}
} }

View File

@@ -36,7 +36,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.nl</groupId> <groupId>org.nl</groupId>
<artifactId>nl-business-media</artifactId> <artifactId>nl-business-externalApi</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.nl</groupId> <groupId>org.nl</groupId>

View File

@@ -9,7 +9,7 @@ spring:
basename: language/task/task,language/error/error,language/buss/buss basename: language/task/task,language/error/error,language/buss/buss
encoding: UTF-8 encoding: UTF-8
profiles: profiles:
active: dev active: prod
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
@@ -45,6 +45,7 @@ security:
- /sys-user-do/** - /sys-user-do/**
# frobot屏幕操作 # frobot屏幕操作
- /schedule/vehicle/** - /schedule/vehicle/**
- /schedule/setting/**
- /task/** - /task/**
- /mapinfo/** - /mapinfo/**
- /security/** - /security/**

View File

@@ -9,6 +9,8 @@ password_error = 账号或密码错误
# 调度相关 # 调度相关
schedule_speed_param_empty = 调度设置配送速度参数不能为空 schedule_speed_param_empty = 调度设置配送速度参数不能为空
schedule_charge_param_empty = 调度设置充电参数不能为空 schedule_charge_param_empty = 调度设置充电参数不能为空
schedule_wifi_param_empty = 调度设置wifi参数不能为空
schedule_wifi_param_error = 调度设置网络wifi操作失败
schedule_task_code_empty = 任务号不能为空 schedule_task_code_empty = 任务号不能为空
schedule_destinations_empty = 目标点不能为空 schedule_destinations_empty = 目标点不能为空
schedule_operation_type_empty = 任务操作类型不能为空 schedule_operation_type_empty = 任务操作类型不能为空
@@ -45,6 +47,7 @@ task_station_code_empty = 站号不能为空
task_report_not_arrived = 未上报到达点位,无法确认到达 task_report_not_arrived = 未上报到达点位,无法确认到达
task_confirm_arrival_failed = 任务到达确认失败 task_confirm_arrival_failed = 任务到达确认失败
task_next_station_failed = 任务下一站失败:{0} task_next_station_failed = 任务下一站失败:{0}
create_cruise_task_error = 任务类型不是巡航类型
# 异常信息相关 # 异常信息相关
error_info = 异常信息 error_info = 异常信息
@@ -104,6 +107,7 @@ qrcode_id_empty = 二维码标识不能为空
qrcode_delete_file_failed = 删除二维码文件失败 qrcode_delete_file_failed = 删除二维码文件失败
qrcode_delete_failed = 删除二维码失败 qrcode_delete_failed = 删除二维码失败
qrcode_station_code_empty = 站号不能为空 qrcode_station_code_empty = 站号不能为空
qrcode_create_failed_mode = 巡航模式中,无法下发任务
# 安全相关 # 安全相关
security_password_error = 密码错误 security_password_error = 密码错误

View File

@@ -9,6 +9,8 @@ password_error = Wrong account or password
# Schedule related # Schedule related
schedule_speed_param_empty = Dispatch setting delivery speed parameter cannot be empty schedule_speed_param_empty = Dispatch setting delivery speed parameter cannot be empty
schedule_charge_param_empty = Dispatch setting charging parameter cannot be empty schedule_charge_param_empty = Dispatch setting charging parameter cannot be empty
schedule_wifi_param_empty = The wifi parameter set for scheduling cannot be empty
schedule_wifi_param_error = The scheduling network wifi operation failed
schedule_task_code_empty = Task number cannot be empty schedule_task_code_empty = Task number cannot be empty
schedule_destinations_empty = Destination cannot be empty schedule_destinations_empty = Destination cannot be empty
schedule_operation_type_empty = Task operation type cannot be empty schedule_operation_type_empty = Task operation type cannot be empty
@@ -45,6 +47,7 @@ task_station_code_empty = Station code cannot be empty
task_report_not_arrived = Not reported arrival location, unable to confirm arrival task_report_not_arrived = Not reported arrival location, unable to confirm arrival
task_confirm_arrival_failed = Failed to confirm task arrival task_confirm_arrival_failed = Failed to confirm task arrival
task_next_station_failed = Failed to go to next station:{0} task_next_station_failed = Failed to go to next station:{0}
create_cruise_task_error = The mission type is not a cruise type
# Anomaly related # Anomaly related
error_info = Anomaly information error_info = Anomaly information
@@ -104,6 +107,7 @@ qrcode_id_empty = QR code ID cannot be empty
qrcode_delete_file_failed = Failed to delete QR code file qrcode_delete_file_failed = Failed to delete QR code file
qrcode_delete_failed = Failed to delete QR code qrcode_delete_failed = Failed to delete QR code
qrcode_station_code_empty = Station code cannot be empty qrcode_station_code_empty = Station code cannot be empty
qrcode_create_failed_mode = In cruise mode, missions cannot be issued
# Security related # Security related
security_password_error = Password error security_password_error = Password error

View File

@@ -9,6 +9,8 @@ password_error = 账号或密码错误
# 调度相关 # 调度相关
schedule_speed_param_empty = 调度设置配送速度参数不能为空 schedule_speed_param_empty = 调度设置配送速度参数不能为空
schedule_charge_param_empty = 调度设置充电参数不能为空 schedule_charge_param_empty = 调度设置充电参数不能为空
schedule_wifi_param_empty = 调度设置wifi参数不能为空
schedule_wifi_param_error = 调度设置网络wifi操作失败
schedule_task_code_empty = 任务号不能为空 schedule_task_code_empty = 任务号不能为空
schedule_destinations_empty = 目标点不能为空 schedule_destinations_empty = 目标点不能为空
schedule_operation_type_empty = 任务操作类型不能为空 schedule_operation_type_empty = 任务操作类型不能为空
@@ -45,6 +47,7 @@ task_station_code_empty = 站号不能为空
task_report_not_arrived = 未上报到达点位,无法确认到达 task_report_not_arrived = 未上报到达点位,无法确认到达
task_confirm_arrival_failed = 任务到达确认失败 task_confirm_arrival_failed = 任务到达确认失败
task_next_station_failed = 任务下一站失败:{0} task_next_station_failed = 任务下一站失败:{0}
create_cruise_task_error = 任务类型不是巡航类型
# 异常信息相关 # 异常信息相关
error_info = 异常信息 error_info = 异常信息
@@ -104,6 +107,7 @@ qrcode_id_empty = 二维码标识不能为空
qrcode_delete_file_failed = 删除二维码文件失败 qrcode_delete_file_failed = 删除二维码文件失败
qrcode_delete_failed = 删除二维码失败 qrcode_delete_failed = 删除二维码失败
qrcode_station_code_empty = 站号不能为空 qrcode_station_code_empty = 站号不能为空
qrcode_create_failed_mode = 巡航模式中,无法下发任务
# 安全相关 # 安全相关
security_password_error = 密码错误 security_password_error = 密码错误

View File

@@ -19,8 +19,8 @@
<module>nl-business-task</module> <module>nl-business-task</module>
<!-- 地图模块 --> <!-- 地图模块 -->
<module>nl-business-map</module> <module>nl-business-map</module>
<!-- 媒体模块 --> <!-- 外部API模块 -->
<module>nl-business-media</module> <module>nl-business-externalApi</module>
<!-- 系统模块 --> <!-- 系统模块 -->
<module>nl-business-sys</module> <module>nl-business-sys</module>
<!-- 调度模块 --> <!-- 调度模块 -->
@@ -82,7 +82,7 @@
<dependency> <dependency>
<groupId>org.nl</groupId> <groupId>org.nl</groupId>
<artifactId>nl-business-media</artifactId> <artifactId>nl-business-externalApi</artifactId>
<version>${nl.version}</version> <version>${nl.version}</version>
</dependency> </dependency>