Compare commits
No commits in common. "6bf1f7da7fd61fa8aa9358fd7713874fd502da96" and "627d5151ef165b809a1e76ea41f7bf5096698088" have entirely different histories.
6bf1f7da7f
...
627d5151ef
@ -2,8 +2,6 @@ package cn.iocoder.yudao.module.system;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目的启动类
|
* 项目的启动类
|
||||||
@ -15,7 +13,6 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableCaching
|
|
||||||
public class SystemServerApplication {
|
public class SystemServerApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.config;
|
||||||
|
|
||||||
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
|
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: XxlJobConfig
|
||||||
|
* @Description: xxl-job依赖配置
|
||||||
|
* @author:
|
||||||
|
* @date: 2022年12月07日 08:37
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Configuration //是否开启xxl-job定时任务,注释掉 //@Configuration 则不开启定时任务
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
public class XxlJobConfig {
|
||||||
|
|
||||||
|
@Value("${xxl.job.admin.addresses}")
|
||||||
|
private String adminAddresses;
|
||||||
|
|
||||||
|
@Value("${xxl.job.accessToken}")
|
||||||
|
private String accessToken;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.appname}")
|
||||||
|
private String appname;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.address}")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.ip}")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.port}")
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.logpath}")
|
||||||
|
private String logPath;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.logretentiondays}")
|
||||||
|
private int logRetentionDays;
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public XxlJobSpringExecutor xxlJobExecutor() {
|
||||||
|
XxlJobHelper.log(">>>>>>>>>>> xxl-job config init.>>>>>>>>>>>");
|
||||||
|
System.out.println("=============== xxl-job config init.===============");
|
||||||
|
|
||||||
|
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||||
|
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
||||||
|
xxlJobSpringExecutor.setAppname(appname);
|
||||||
|
xxlJobSpringExecutor.setAddress(address);
|
||||||
|
xxlJobSpringExecutor.setIp(ip);
|
||||||
|
xxlJobSpringExecutor.setPort(port);
|
||||||
|
xxlJobSpringExecutor.setAccessToken(accessToken);
|
||||||
|
xxlJobSpringExecutor.setLogPath(logPath);
|
||||||
|
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
||||||
|
|
||||||
|
return xxlJobSpringExecutor;
|
||||||
|
}
|
||||||
|
}
|
@ -10,10 +10,9 @@ import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
|
|||||||
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@ -31,6 +30,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@ -44,7 +44,6 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
@Slf4j
|
|
||||||
public class PositionMapServiceImpl extends ServiceImpl<PositionMapMapper, PositionMapDO> implements PositionMapService {
|
public class PositionMapServiceImpl extends ServiceImpl<PositionMapMapper, PositionMapDO> implements PositionMapService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -259,13 +258,16 @@ public class PositionMapServiceImpl extends ServiceImpl<PositionMapMapper, Posit
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "pngBase64", key = "#floor + '_' + #area")
|
|
||||||
public String downloadPngBase64(Integer floor, String area) {
|
public String downloadPngBase64(Integer floor, String area) {
|
||||||
|
String key = "pngBase64" + "_" + floor + "_" + area;
|
||||||
|
Boolean b = stringRedisTemplate.hasKey(key);
|
||||||
|
if (b) {
|
||||||
|
return stringRedisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
// 根据楼层和区域查找对应的PNG文件路径
|
// 根据楼层和区域查找对应的PNG文件路径
|
||||||
String basePath = UPLOAD_DIR + floor + "/" + area + "/";
|
String basePath = UPLOAD_DIR + floor + "/" + area + "/";
|
||||||
File directory = new File(basePath);
|
File directory = new File(basePath);
|
||||||
if (!directory.exists() || !directory.isDirectory()) {
|
if (!directory.exists() || !directory.isDirectory()) {
|
||||||
log.error("Directory not found for floor: {}, area: {}", floor, area);
|
|
||||||
throw exception(AGV_MAP_NOT_FOUND);
|
throw exception(AGV_MAP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +279,6 @@ public class PositionMapServiceImpl extends ServiceImpl<PositionMapMapper, Posit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pngFile == null || !pngFile.exists()) {
|
if (pngFile == null || !pngFile.exists()) {
|
||||||
log.error("PNG file not found for floor: {}, area: {}", floor, area);
|
|
||||||
throw exception(AGV_MAP_NOT_FOUND);
|
throw exception(AGV_MAP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
String encodedString = null;
|
String encodedString = null;
|
||||||
@ -286,14 +287,13 @@ public class PositionMapServiceImpl extends ServiceImpl<PositionMapMapper, Posit
|
|||||||
byte[] fileContent = Files.readAllBytes(pngFile.toPath());
|
byte[] fileContent = Files.readAllBytes(pngFile.toPath());
|
||||||
// 将文件内容转换为Base64字符串
|
// 将文件内容转换为Base64字符串
|
||||||
encodedString = Base64.getEncoder().encodeToString(fileContent);
|
encodedString = Base64.getEncoder().encodeToString(fileContent);
|
||||||
// 添加MIME类型前缀
|
|
||||||
encodedString = "data:image/png;base64," + encodedString;
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to convert PNG to Base64 for floor: {}, area: {}", floor, area, e);
|
e.printStackTrace();
|
||||||
throw exception(AGV_IMAGE_CONVERSION_TO_BASE64_FAILED);
|
throw exception(AGV_IMAGE_CONVERSION_TO_BASE64_FAILED);
|
||||||
}
|
}
|
||||||
|
// -- 缓存30分钟
|
||||||
|
stringRedisTemplate.opsForValue().set(key, encodedString, 30, TimeUnit.MINUTES);
|
||||||
return encodedString;
|
return encodedString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ spring:
|
|||||||
config: # 【注册中心】配置项
|
config: # 【注册中心】配置项
|
||||||
namespace: dev # 命名空间。这里使用 dev 开发环境
|
namespace: dev # 命名空间。这里使用 dev 开发环境
|
||||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||||
cache:
|
|
||||||
type: redis
|
|
||||||
--- #################### 数据库相关配置 ####################
|
--- #################### 数据库相关配置 ####################
|
||||||
spring:
|
spring:
|
||||||
# 数据源配置项
|
# 数据源配置项
|
||||||
@ -104,10 +103,9 @@ spring:
|
|||||||
|
|
||||||
xxl:
|
xxl:
|
||||||
job:
|
job:
|
||||||
enabled: true # 是否开启调度中心,默认为 true 开启
|
enabled: false # 是否开启调度中心,默认为 true 开启
|
||||||
admin:
|
admin:
|
||||||
addresses: http://127.0.0.1:9999/xxl-job-admin # 调度中心部署跟地址
|
addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址
|
||||||
|
|
||||||
|
|
||||||
--- #################### 服务保障相关配置 ####################
|
--- #################### 服务保障相关配置 ####################
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user