opt:1.新增国际化准备工作。
This commit is contained in:
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.api.schedule.map.api.ScheduleMapAPI;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.monitor.map.dto.StationInfoDto;
|
||||
import org.nl.monitor.map.service.MapMonitorService;
|
||||
@@ -30,7 +31,7 @@ public class MapMonitorServiceImpl implements MapMonitorService {
|
||||
public WebResponse queryCurrentMapPoint() {
|
||||
HttpResponse httpResponse = scheduleMapAPI.queryCurrentMapPointInfo();
|
||||
if (httpResponse == null || !httpResponse.isOk()){
|
||||
throw new BadRequestException("获取调度当前地图点位信息失败");
|
||||
throw new BadRequestException(LangProcess.msg("error_schedule_point"));
|
||||
}
|
||||
List<StationInfoDto> result = new ArrayList<>();
|
||||
JSONArray jsonArray = JSONArray.parseArray(httpResponse.body());
|
||||
|
||||
@@ -46,7 +46,7 @@ public class VehicleServiceImpl implements VehicleService {
|
||||
/**
|
||||
* 定时更新车辆信息(每秒执行)
|
||||
*/
|
||||
@Scheduled(fixedRate = 7000) // 每秒执行一次
|
||||
@Scheduled(fixedRate = 1000) // 每秒执行一次
|
||||
public void updateVehicleInfo() {
|
||||
try {
|
||||
List<VehicleInfoDto> vehicles = getAllVehicles();
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.sys.modular.anomalyInfo.dao.ErrorHandling;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -83,7 +84,7 @@ public class ErrorHandlingListener extends AnalysisEventListener<ErrorHandling>
|
||||
log.info("成功批量插入 {} 条数据。", cachedDataList.size());
|
||||
} else {
|
||||
log.error("批量插入数据失败!");
|
||||
throw new BadRequestException("操作失败");
|
||||
throw new BadRequestException(LangProcess.msg("failed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.sys.modular.anomalyInfo.dao.ErrorInfo;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -84,7 +85,7 @@ public class ErrorInfoListener extends AnalysisEventListener<ErrorInfo> {
|
||||
log.info("成功批量插入 {} 条数据。", cachedDataList.size());
|
||||
} else {
|
||||
log.error("批量插入数据失败!");
|
||||
throw new BadRequestException("操作失败");
|
||||
throw new BadRequestException(LangProcess.msg("failed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.logging.annotation.Log;
|
||||
import org.nl.sys.modular.backgroundmanagement.common.base.TableDataInfo;
|
||||
@@ -76,7 +77,7 @@ public class UserController {
|
||||
@Log("修改用户:个人中心")
|
||||
public ResponseEntity<Object> center(@RequestBody SysUser resources){
|
||||
if(!resources.getUser_id().equals(StpUtil.getLoginIdAsLong())){
|
||||
throw new BadRequestException("不能修改他人资料");
|
||||
throw new BadRequestException(LangProcess.msg("error_cannot_update"));
|
||||
}
|
||||
userService.saveOrUpdate(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
|
||||
@@ -4,10 +4,7 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.logging.annotation.Log;
|
||||
import org.nl.enums.TaskSourceEnum;
|
||||
import org.nl.task.param.CancelTaskRequestParam;
|
||||
import org.nl.task.param.CreateTaskRequestParam;
|
||||
import org.nl.task.param.OneClickOperationRequestParam;
|
||||
import org.nl.task.param.PauseAndResumeTaskParam;
|
||||
import org.nl.task.param.*;
|
||||
import org.nl.task.service.TaskService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -32,6 +29,12 @@ public class TaskController {
|
||||
return new ResponseEntity<>(taskService.createTask(createTaskRequestParam, TaskSourceEnum.SCREEN.getName()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryTask")
|
||||
@Log("查询任务")
|
||||
public ResponseEntity<Object> queryTask(@RequestBody @Validated QueryTaskRequestParam queryTaskRequestParam){
|
||||
return new ResponseEntity<>(taskService.queryTask(queryTaskRequestParam), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/cancelTask")
|
||||
@Log("取消任务")
|
||||
public ResponseEntity<Object> cancelTask(@RequestBody @Validated CancelTaskRequestParam cancelTaskRequestParam){
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.nl.task.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/12/1
|
||||
*/
|
||||
@Getter
|
||||
public enum OneClickTaskTypeEnum {
|
||||
|
||||
/**
|
||||
* 一键充电
|
||||
*/
|
||||
CHARGE("Charge", "CHARGE", "一键充电"),
|
||||
/**
|
||||
* 一键加水
|
||||
*/
|
||||
REFILL("Refill", "WATER", "一键加水");
|
||||
|
||||
private String code;
|
||||
private String scheduleType;
|
||||
private String desc;
|
||||
|
||||
|
||||
OneClickTaskTypeEnum(String code, String scheduleType, String desc) {
|
||||
this.code = code;
|
||||
this.scheduleType = scheduleType;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static String mappingScheduleTypeByCode(String code){
|
||||
for (OneClickTaskTypeEnum oneClickTaskTypeEnum: OneClickTaskTypeEnum.values()){
|
||||
if (oneClickTaskTypeEnum.code.equals(code)){
|
||||
return oneClickTaskTypeEnum.scheduleType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.nl.task.param;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2026/2/3
|
||||
*/
|
||||
@Data
|
||||
public class QueryTaskRequestParam {
|
||||
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
@NotNull(message = "当前页不能为空")
|
||||
private Integer pageNum;
|
||||
|
||||
/**
|
||||
* 页数大小
|
||||
*/
|
||||
@NotNull(message = "页数大小不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
private String task_code;
|
||||
|
||||
/**
|
||||
* 任务状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 目标点
|
||||
*/
|
||||
private String destinations;
|
||||
|
||||
/**
|
||||
* 任务类型
|
||||
*/
|
||||
private String type;
|
||||
}
|
||||
@@ -3,10 +3,7 @@ package org.nl.task.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.response.WebResponse;
|
||||
import org.nl.task.entity.Task;
|
||||
import org.nl.task.param.CancelTaskRequestParam;
|
||||
import org.nl.task.param.CreateTaskRequestParam;
|
||||
import org.nl.task.param.OneClickOperationRequestParam;
|
||||
import org.nl.task.param.PauseAndResumeTaskParam;
|
||||
import org.nl.task.param.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,6 +19,12 @@ public interface TaskService extends IService<Task>{
|
||||
*/
|
||||
WebResponse createTask(CreateTaskRequestParam createTaskRequestParam, String taskSource);
|
||||
|
||||
/**
|
||||
* 查询任务
|
||||
* @return WebResponse
|
||||
*/
|
||||
WebResponse queryTask(QueryTaskRequestParam queryTaskRequestParam);
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
* @return WebResponse
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -21,14 +23,12 @@ import org.nl.enums.YesOrNoEnum;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.response.WebResponse;
|
||||
import org.nl.task.entity.Task;
|
||||
import org.nl.task.enums.OneClickTaskTypeEnum;
|
||||
import org.nl.task.enums.ScheduleTaskStatusEnum;
|
||||
import org.nl.task.enums.TaskStatusEnum;
|
||||
import org.nl.task.enums.TaskTypeEnum;
|
||||
import org.nl.task.mapper.TaskMapper;
|
||||
import org.nl.task.param.CancelTaskRequestParam;
|
||||
import org.nl.task.param.CreateTaskRequestParam;
|
||||
import org.nl.task.param.OneClickOperationRequestParam;
|
||||
import org.nl.task.param.PauseAndResumeTaskParam;
|
||||
import org.nl.task.param.*;
|
||||
import org.nl.task.service.TaskService;
|
||||
import org.nl.util.IdUtil;
|
||||
import org.nl.util.TaskCodeGeneratorUtil;
|
||||
@@ -77,7 +77,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper,Task> implements Tas
|
||||
.lt(Task::getStatus,TaskStatusEnum.FINISHED.getCode())
|
||||
);
|
||||
currentTaskList.clear();
|
||||
currentTaskList = taskList;
|
||||
currentTaskList.addAll(taskList);
|
||||
taskInfoList.clear();
|
||||
//根据车辆编号分类 车辆任务队列。
|
||||
if (!taskList.isEmpty()) {
|
||||
@@ -161,6 +161,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper,Task> implements Tas
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebResponse queryTask(QueryTaskRequestParam param) {
|
||||
Page<Task> page = new Page<>(param.getPageNum(),param.getPageSize());
|
||||
IPage<Task> infoPage = taskMapper.selectPage(page,new LambdaQueryWrapper<>(Task.class)
|
||||
.likeRight(StrUtil.isNotBlank(param.getTask_code()),Task::getTask_code,param.getTask_code())
|
||||
.eq(StrUtil.isNotBlank(param.getStatus()),Task::getStatus,param.getStatus())
|
||||
.eq(StrUtil.isNotBlank(param.getDestinations()),Task::getDestinations,param.getDestinations())
|
||||
.eq(StrUtil.isNotBlank(param.getType()),Task::getType,param.getType())
|
||||
);
|
||||
return WebResponse.requestParamOk(infoPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public WebResponse cancelTask(CancelTaskRequestParam cancelTaskRequestParam) {
|
||||
@@ -296,6 +308,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper,Task> implements Tas
|
||||
taskMapper.insert(task);
|
||||
|
||||
ScheduleAPICreateOneClickTaskParam scheduleAPICreateOneClickTaskParam = BeanUtil.copyProperties(task, ScheduleAPICreateOneClickTaskParam.class);
|
||||
scheduleAPICreateOneClickTaskParam.setType(OneClickTaskTypeEnum.mappingScheduleTypeByCode(oneClickOperationRequestParam.getType()));
|
||||
HttpResponse result = scheduleTaskAPI.oneClickOperationTask(scheduleAPICreateOneClickTaskParam);
|
||||
if (result == null || !result.isOk()){
|
||||
throw new BadRequestException("调度生成一键任务失败");
|
||||
|
||||
20
nl-common/src/main/java/org/nl/config/CallBack.java
Normal file
20
nl-common/src/main/java/org/nl/config/CallBack.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package org.nl.config;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/8/25
|
||||
*/
|
||||
public interface CallBack {
|
||||
/**
|
||||
* 回调执行方法
|
||||
*/
|
||||
void executor();
|
||||
|
||||
/**
|
||||
* 本回调任务名称
|
||||
* @return /
|
||||
*/
|
||||
default String getCallBackName() {
|
||||
return Thread.currentThread().getId() + ":" + this.getClass().getName();
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,10 @@ public class CorsConfig implements WebMvcConfigurer {
|
||||
FileProperties.ElPath path = properties.getPath();
|
||||
String qrcodeUtl = "file:" + path.getQrcode().replace("\\","/");
|
||||
String pathUtl = "file:" + path.getPath().replace("\\","/");
|
||||
String avatarUtl = "file:" + path.getAvatar().replace("\\","/");
|
||||
registry.addResourceHandler("/qrcode/**").addResourceLocations(qrcodeUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
||||
}
|
||||
|
||||
|
||||
20
nl-common/src/main/java/org/nl/config/MapOf.java
Normal file
20
nl-common/src/main/java/org/nl/config/MapOf.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package org.nl.config;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/11/29 2:55 下午
|
||||
*/
|
||||
public class MapOf implements Serializable {
|
||||
|
||||
public static <K> HashMap of(K... key){
|
||||
HashMap map = new HashMap<>();
|
||||
for (int i = 0; i < (key.length & ~1); i=i+2) {
|
||||
map.put(key[i],key[i+1]);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
141
nl-common/src/main/java/org/nl/config/SpringContextHolder.java
Normal file
141
nl-common/src/main/java/org/nl/config/SpringContextHolder.java
Normal file
@@ -0,0 +1,141 @@
|
||||
package org.nl.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/8/25
|
||||
*/
|
||||
@Slf4j
|
||||
public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
|
||||
private static ApplicationContext applicationContext = null;
|
||||
//数据库连接的bean名字
|
||||
public static String dataSourceBeanName="dataSource";
|
||||
private static final List<CallBack> CALL_BACKS = new ArrayList<>();
|
||||
private static boolean addCallback = true;
|
||||
|
||||
/**
|
||||
* 针对 某些初始化方法,在SpringContextHolder 未初始化时 提交回调方法。
|
||||
* 在SpringContextHolder 初始化后,进行回调使用
|
||||
*
|
||||
* @param callBack 回调函数
|
||||
*/
|
||||
public synchronized static void addCallBacks(CallBack callBack) {
|
||||
if (addCallback) {
|
||||
SpringContextHolder.CALL_BACKS.add(callBack);
|
||||
} else {
|
||||
log.warn("CallBack:{} 已无法添加!立即执行", callBack.getCallBackName());
|
||||
callBack.executor();
|
||||
}
|
||||
}
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return applicationContext;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String name) {
|
||||
assertContextInjected();
|
||||
return (T) applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
public static <T> T getBean(Class<T> requiredType) {
|
||||
assertContextInjected();
|
||||
return applicationContext.getBean(requiredType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SpringBoot 配置信息
|
||||
*
|
||||
* @param property 属性key
|
||||
* @param defaultValue 默认值
|
||||
* @param requiredType 返回类型
|
||||
* @return /
|
||||
*/
|
||||
public static <T> T getProperties(String property, T defaultValue, Class<T> requiredType) {
|
||||
T result = defaultValue;
|
||||
try {
|
||||
result = getBean(Environment.class).getProperty(property, requiredType);
|
||||
} catch (Exception ignored) {}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SpringBoot 配置信息
|
||||
*
|
||||
* @param property 属性key
|
||||
* @return /
|
||||
*/
|
||||
public static String getProperties(String property) {
|
||||
return getProperties(property, null, String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SpringBoot 配置信息
|
||||
*
|
||||
* @param property 属性key
|
||||
* @param requiredType 返回类型
|
||||
* @return /
|
||||
*/
|
||||
public static <T> T getProperties(String property, Class<T> requiredType) {
|
||||
return getProperties(property, null, requiredType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查ApplicationContext不为空.
|
||||
*/
|
||||
private static void assertContextInjected() {
|
||||
if (applicationContext == null) {
|
||||
throw new IllegalStateException("applicaitonContext属性未注入, 请在applicationContext" +
|
||||
".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除SpringContextHolder中的ApplicationContext为Null.
|
||||
*/
|
||||
private static void clearHolder() {
|
||||
log.debug("清除SpringContextHolder中的ApplicationContext:"
|
||||
+ applicationContext);
|
||||
applicationContext = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
SpringContextHolder.clearHolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (SpringContextHolder.applicationContext != null) {
|
||||
log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext);
|
||||
}
|
||||
SpringContextHolder.applicationContext = applicationContext;
|
||||
if (addCallback) {
|
||||
for (CallBack callBack : SpringContextHolder.CALL_BACKS) {
|
||||
callBack.executor();
|
||||
}
|
||||
CALL_BACKS.clear();
|
||||
}
|
||||
SpringContextHolder.addCallback = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.nl.config.language;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.nl.config.MapOf;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/8/25
|
||||
*/
|
||||
public class InitLocaleResolver implements LocaleResolver {
|
||||
|
||||
public static Map<String,String> Language_Country = MapOf.of("vi","vi-VN","id","in-ID","in","in-ID","en-US,en;q=0.9","en-US","en","en-US","zh","zh-CN","ko","ko-KR");
|
||||
public static String language = "";
|
||||
|
||||
@Override
|
||||
public Locale resolveLocale(HttpServletRequest request) {
|
||||
String header = request.getHeader("Accept-Language");
|
||||
if (StrUtil.isNotEmpty(header)){
|
||||
String lang = Language_Country.get(header);
|
||||
language = lang;
|
||||
if (StrUtil.isNotEmpty(lang)){
|
||||
String[] l = lang.split("-");
|
||||
//印尼的ISO标准国家代码为id-ID
|
||||
return new Locale(l[0], l[1]);
|
||||
}
|
||||
}
|
||||
return Locale.getDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
|
||||
|
||||
}
|
||||
|
||||
public String getLanguage(){
|
||||
return language;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.config.language;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/8/25
|
||||
*/
|
||||
public class LangProcess {
|
||||
|
||||
public static String msg(String code,String...args){
|
||||
MessageSource bean = SpringContextHolder.getBean(MessageSource.class);
|
||||
if (StrUtil.isEmpty(code)){
|
||||
return " ";
|
||||
}
|
||||
String message = bean.getMessage(code, args, LocaleContextHolder.getLocale());
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
21
nl-common/src/main/java/org/nl/config/language/RcsLang.java
Normal file
21
nl-common/src/main/java/org/nl/config/language/RcsLang.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package org.nl.config.language;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.nl.config.MapOf;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2025/8/27
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class RcsLang {
|
||||
public static Map<String,String> Language_Country = MapOf.of("en","EN","zh","ZH");
|
||||
|
||||
public static String getRcsLanguage(String language) {
|
||||
return Language_Country.get(language);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.nl.response;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.nl.config.language.LangProcess;
|
||||
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
@@ -35,7 +36,7 @@ public class WebResponse<T> {
|
||||
*/
|
||||
public static WebResponse requestOk() {
|
||||
return WebResponse.builder()
|
||||
.message("成功")
|
||||
.message(LangProcess.msg("successful"))
|
||||
.code(OK.value())
|
||||
.build();
|
||||
}
|
||||
@@ -57,7 +58,7 @@ public class WebResponse<T> {
|
||||
*/
|
||||
public static <T> WebResponse requestParamOk(T data) {
|
||||
return WebResponse.builder()
|
||||
.message("成功")
|
||||
.message(LangProcess.msg("successful"))
|
||||
.data(data)
|
||||
.code(OK.value())
|
||||
.build();
|
||||
|
||||
@@ -17,9 +17,11 @@ import com.alicp.jetcache.anno.config.EnableMethodCache;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@@ -49,6 +51,11 @@ public class Application {
|
||||
System.setProperty("druid.mysql.usePingMethod","false");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringContextHolder springContextHolder() {
|
||||
return new SpringContextHolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 主启动函数
|
||||
*
|
||||
|
||||
@@ -79,7 +79,7 @@ file:
|
||||
avatar: /home/pi/nl_robot/avatar/
|
||||
windows:
|
||||
path: C:\eladmin\file\currentMap\
|
||||
qrcode: C:\eladmin\qrcode\currentMap\
|
||||
qrcode: C:\eladmin\qrcode\
|
||||
avatar: C:\eladmin\avatar\
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
@@ -100,4 +100,59 @@ sa-token:
|
||||
# token风格
|
||||
token-style: random-128
|
||||
# 是否输出操作日志
|
||||
is-log: true
|
||||
is-log: true
|
||||
jwt-secret-key: opsjajisdnnca0sdkksdfaaasdfwwq
|
||||
# token 前缀
|
||||
token-prefix: Bearer
|
||||
sso:
|
||||
# Ticket有效期 (单位: 秒),默认五分钟
|
||||
ticket-timeout: 300
|
||||
# 所有允许的授权回调地址
|
||||
allow-url: "*"
|
||||
# 是否打开单点注销功能
|
||||
is-slo: true
|
||||
|
||||
# ------- SSO-模式三相关配置 (下面的配置在SSO模式三并且 is-slo=true 时打开)
|
||||
# 是否打开模式三
|
||||
isHttp: true
|
||||
# 接口调用秘钥(用于SSO模式三的单点注销功能)
|
||||
secretkey: kQwIOrYvnXmSDkwEiFngrKidMcdrgKor
|
||||
# ---- 除了以上配置项,你还需要为 Sa-Token 配置http请求处理器(文档有步骤说明)
|
||||
is-read-cookie: true
|
||||
is-print: false
|
||||
# 未登录 StpUtil.getTokenSession() 设置值,获取值 @SaIgnore 得忽略接口
|
||||
token-session-check-login: false
|
||||
alone-redis:
|
||||
# Redis数据库索引(默认为0)
|
||||
database: 2
|
||||
# Redis服务器地址
|
||||
host: 192.168.29.130
|
||||
# Redis服务器连接端口
|
||||
port: 6379
|
||||
# Redis服务器连接密码(默认为空)
|
||||
password: 123456
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
|
||||
# 登录相关配置
|
||||
login:
|
||||
# 登录缓存
|
||||
cache-enable: true
|
||||
# 是否限制单用户登录
|
||||
single-login: false
|
||||
# 验证码
|
||||
login-code:
|
||||
# 验证码类型配置 查看 LoginProperties 类
|
||||
code-type: arithmetic
|
||||
# 登录图形验证码有效时间/分钟
|
||||
expiration: 2
|
||||
# 验证码高度
|
||||
width: 111
|
||||
# 验证码宽度
|
||||
heigth: 36
|
||||
# 内容长度
|
||||
length: 2
|
||||
# 字体名称,为空则使用默认字体
|
||||
font-name:
|
||||
# 字体大小
|
||||
font-size: 25
|
||||
|
||||
@@ -7,7 +7,7 @@ spring:
|
||||
basename: language/task/task,language/error/error,language/buss/buss
|
||||
encoding: UTF-8
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
|
||||
@@ -43,6 +43,9 @@ security:
|
||||
- /sys-user-do/**
|
||||
# frobot屏幕操作
|
||||
- /schedule/vehicle/**
|
||||
- /task/**
|
||||
- /mapinfo/**
|
||||
- /security/**
|
||||
- /mapMonitor/**
|
||||
- /api/scheduleTask/**
|
||||
- /setting/**
|
||||
|
||||
@@ -1,29 +1,2 @@
|
||||
error_request_vehicle = 访问车体接口异常:
|
||||
error_request_rcs = 访问RCS接口异常:
|
||||
error_starting_mapping = 开始建图失败
|
||||
error_cut_manually = 切手动失败
|
||||
error_cut_automatically = 切自动失败
|
||||
error_end_mapping = 结束建图失败
|
||||
error_set_station = 设置站点失败
|
||||
error_get_Maps = 获取地图列表失败
|
||||
error_deploy_maps = 部署地图失败
|
||||
error_app_maps = 应用地图失败
|
||||
error_get_map_pack = 获取地图包失败
|
||||
error_map_pack_isNull = "地图包数据为空,扫描失败。请重新建图"
|
||||
error_map_pgm = 地图PGM转换失败
|
||||
error_yaml_isNull = .YAML文件内容为空
|
||||
error_formatting_error = 格式错误
|
||||
error_parsing = YAML解析失败:
|
||||
error_process_map_pack = 处理地图包数据失败:
|
||||
error_png_convert_transparency = .png点云图将灰度图像转换为透明背景图像失败:
|
||||
error_p5 = 不支持的PGM格式,仅支持P5二进制格式
|
||||
error_invalid_size = 无效的尺寸格式
|
||||
error_pgm_parse = PGM解析错误:
|
||||
error_synchronized_map = 同步地图失败
|
||||
error_relocate = 重定位指令下发失败
|
||||
error_restart = 车体程序重启失败
|
||||
error_abandon_mapping = 放弃建图失败
|
||||
error_auto_back = 自动返回上一个点失败
|
||||
error_restart_system = 重启系统失败
|
||||
error_initializing_system = 初始化底层系统失败
|
||||
error_set_forkLegs= 操作叉腿避障失败
|
||||
error_schedule_point = 获取调度地图点位信息失败
|
||||
error_cannot_update = 不能修改他人资料
|
||||
@@ -1,28 +1,2 @@
|
||||
error_request_vehicle = Abnormal access to the vehicle body interface
|
||||
error_request_rcs = Accessing the RCS interface is abnormal
|
||||
error_starting_mapping = Failed to start mapping
|
||||
error_cut_manually = Cut manual failure
|
||||
error_cut_automatically = Cut automatically fails
|
||||
error_end_mapping = End mapping failed
|
||||
error_set_station = Setting up the site failed
|
||||
error_get_Maps = Failed to get the map list
|
||||
error_deploy_maps = Deploying the map failed
|
||||
error_app_maps = Applying the map failed
|
||||
error_get_map_pack = Failed to get the map package
|
||||
error_map_pack_isNull = The map package data is empty and the scan fails. Please rebuild the map
|
||||
error_map_pgm = Map PGM conversion failed
|
||||
error_yaml_isNull = .yaml file content is empty
|
||||
error_parsing = YAML parsing failed:
|
||||
error_process_map_pack = Failed to process map packet data:
|
||||
error_png_convert_transparency = Converting a grayscale image to a transparent background image .png a point cloud plot fails:
|
||||
error_p5 = PGM format is not supported, only P5 binary format is supported
|
||||
error_invalid_size = Invalid size format
|
||||
error_pgm_parse = PGM parsing error:
|
||||
error_synchronized_map = Syncing maps failed
|
||||
error_relocate = The relocation instruction failed to be issued
|
||||
error_restart = The body program restarts failed
|
||||
error_abandon_mapping = Abandoned mapping failed
|
||||
error_auto_back = Automatically returning to the previous point failed
|
||||
error_restart_system = Rebooting the system failed
|
||||
error_initializing_system = Initializing the underlying system failed
|
||||
error_set_forkLegs= The operation of the fork leg to avoid obstacles failed
|
||||
error_schedule_point = Failed to obtain the dispatch map location information
|
||||
error_cannot_update = You cannot modify other people's information
|
||||
|
||||
@@ -1,28 +1,2 @@
|
||||
error_request_vehicle = 访问车体接口异常
|
||||
error_request_rcs = 访问RCS接口异常
|
||||
error_starting_mapping = 开始建图失败
|
||||
error_cut_manually = 切手动失败
|
||||
error_cut_automatically = 切自动失败
|
||||
error_end_mapping = 结束建图失败
|
||||
error_set_station = 设置站点失败
|
||||
error_get_Maps = 获取地图列表失败
|
||||
error_deploy_maps = 部署地图失败
|
||||
error_app_maps = 应用地图失败
|
||||
error_get_map_pack = 获取地图包失败
|
||||
error_map_pack_isNull = "地图包数据为空,扫描失败。请重新建图"
|
||||
error_map_pgm = 地图PGM转换失败
|
||||
error_yaml_isNull = .YAML文件内容为空
|
||||
error_parsing = YAML解析失败:
|
||||
error_process_map_pack = 处理地图包数据失败:
|
||||
error_png_convert_transparency = .png点云图将灰度图像转换为透明背景图像失败:
|
||||
error_p5 = 不支持的PGM格式,仅支持P5二进制格式
|
||||
error_invalid_size = 无效的尺寸格式
|
||||
error_pgm_parse = PGM解析错误:
|
||||
error_synchronized_map = 同步地图失败
|
||||
error_relocate = 重定位指令下发失败
|
||||
error_restart = 车体程序重启失败
|
||||
error_abandon_mapping = 放弃建图失败
|
||||
error_auto_back = 自动返回上一个点失败
|
||||
error_restart_system = 重启系统失败
|
||||
error_initializing_system = 初始化底层系统失败
|
||||
error_set_forkLegs= 操作叉腿避障失败
|
||||
error_schedule_point = 获取调度地图点位信息失败
|
||||
error_cannot_update = 不能修改他人资料
|
||||
Reference in New Issue
Block a user