2025-05-07 15:04:08 +08:00
|
|
|
|
package com.czlis.system.config;
|
|
|
|
|
|
|
2025-08-20 14:22:17 +08:00
|
|
|
|
import com.czlis.common.asyncmanager.AsyncManager;
|
|
|
|
|
|
import com.czlis.common.utils.ComDictUtils;
|
|
|
|
|
|
import com.czlis.interfaceCommon.mapper.ComDictMapper;
|
|
|
|
|
|
import com.czlis.quartz.service.impl.SysJobServiceImpl;
|
|
|
|
|
|
import com.czlis.system.service.impl.SysConfigServiceImpl;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2025-05-07 15:04:08 +08:00
|
|
|
|
import org.mybatis.spring.annotation.MapperScan;
|
2025-08-20 14:22:17 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2025-05-07 15:04:08 +08:00
|
|
|
|
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
|
|
|
|
|
|
2025-08-20 14:22:17 +08:00
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
import java.util.List;
|
2025-05-07 15:04:08 +08:00
|
|
|
|
import java.util.TimeZone;
|
2025-08-20 14:22:17 +08:00
|
|
|
|
import java.util.TimerTask;
|
2025-05-07 15:04:08 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 程序注解配置
|
2025-08-20 14:22:17 +08:00
|
|
|
|
* 项目初始化运行逻辑
|
2025-05-07 15:04:08 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @author admin
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Configuration
|
|
|
|
|
|
// 表示通过aop框架暴露该代理对象,AopContext能够访问
|
|
|
|
|
|
@EnableAspectJAutoProxy(exposeProxy = true)
|
|
|
|
|
|
// 指定要扫描的Mapper类的包的路径
|
|
|
|
|
|
@MapperScan("com.czlis.**.mapper")
|
2025-08-20 14:22:17 +08:00
|
|
|
|
@Slf4j
|
2025-05-07 15:04:08 +08:00
|
|
|
|
public class ApplicationConfig {
|
2025-08-20 14:22:17 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ComDictMapper comDictMapper;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private SysConfigServiceImpl sysConfigService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private SysJobServiceImpl sysJobService;
|
|
|
|
|
|
|
|
|
|
|
|
//选择性提供缓存的字典类别
|
|
|
|
|
|
private List<String> list = Arrays.asList("GROUP","AU","BT","DG", "DP", "FT", "HOS","LG","PT","PW","SRD","SX","UT","CM","VF");
|
|
|
|
|
|
|
2025-05-07 15:04:08 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 时区配置
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
|
|
|
|
|
|
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
|
|
|
|
|
|
}
|
2025-08-20 14:22:17 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 加载字典缓存数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
public void loadingDictCache() {
|
|
|
|
|
|
TimerTask task = new TimerTask(){
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
//清空所有com_dict缓存
|
|
|
|
|
|
ComDictUtils.clearDictCache();
|
|
|
|
|
|
list.stream().forEach(zdlb -> ComDictUtils.setDictCache(zdlb, comDictMapper.getComDictListByZdlb(zdlb)));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("获取lis代码字典失败,异步执行{}方法失败",this, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
AsyncManager.me().execute(task);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 加载系统配置缓存
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
public void loadingSysConfigCache() {
|
|
|
|
|
|
TimerTask task = new TimerTask(){
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
sysConfigService.loadingConfigCache();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("获取系统配置字典失败,异步执行{}方法失败",this, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
AsyncManager.me().execute(task);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 加载定时任务列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
public void loadingSysJobCache() {
|
|
|
|
|
|
TimerTask task = new TimerTask(){
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
sysJobService.init();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("获取系统配置字典失败,异步执行{}方法失败",this, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
AsyncManager.me().execute(task);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-07 15:04:08 +08:00
|
|
|
|
}
|