细节优化

定时任务-公用消息推送
文件大小限制
yun-zuoyi
汪云昊 6 years ago
parent 0ecc7308e2
commit f4e0d6da4d

@ -88,56 +88,57 @@ public class AppStartSystemInit implements CommandLineRunner {
/**
*
* cn.estsh.i3plus.core.apiservice.serviceimpl.base.SystemInitService
*/
public void packIMPPResources() {
/**
*
* code <lang : value>
* code
*/
HashMap<String, HashMap<String, String>> resMap = new HashMap();
HashMap<String, String> lanMap = null;
HashMap<String, HashMap<String, String>> webLangMap = new HashMap<>();
HashMap<String, String> webResMap;
//语言数量
List<SysLocaleLanguage> langList = systemResourceService.listSysLocaleLanguage(null);
//查询所有资源
List<SysLocaleResource> resourceList = systemResourceService.listSysLocaleResource(null);
LOGGER.info("【加载平台资源】共有{}个资源,{}种语言。", resourceList.size(), langList.size());
for (SysLocaleResource res : resourceList) {
//遍历资源放入map中
lanMap = resMap.get(res.getResourceKey());
//判断是否已存在资源信息
if (lanMap == null) {
lanMap = new HashMap<String, String>();
//将key/代码放入
resMap.put(res.getResourceKey(), lanMap);
}
//根据语言放入
lanMap.put(res.getLanguageCode(), res.getResourceValue());
// web 资源
if (!webLangMap.containsKey(res.getLanguageCode())) {
webLangMap.put(res.getLanguageCode(), new HashMap<>());
}
// 放入资源信息
webResMap = webLangMap.get(res.getLanguageCode());
webResMap.put(res.getResourceKey(), res.getResourceValue());
}
for (String key : resMap.keySet()) {
//放入缓存
redisRes.putHashMap(key, resMap.get(key), 0);
}
for (String key : webLangMap.keySet()) {
//放入缓存
redisRes.putHashMap(key, webLangMap.get(key), 0);
}
LOGGER.info("【资源配置文件已全部加载:{}个】", resMap.size());
// /**
// * 整体数据结构:
// * code <lang : value>
// * 先根据code查询判断是否存在然后通过语言获取对应的值
// */
// HashMap<String, HashMap<String, String>> resMap = new HashMap();
// HashMap<String, String> lanMap = null;
// HashMap<String, HashMap<String, String>> webLangMap = new HashMap<>();
// HashMap<String, String> webResMap;
//
// //语言数量
// List<SysLocaleLanguage> langList = systemResourceService.listSysLocaleLanguage(null);
//
// //查询所有资源
// List<SysLocaleResource> resourceList = systemResourceService.listSysLocaleResource(null);
// LOGGER.info("【加载平台资源】共有{}个资源,{}种语言。", resourceList.size(), langList.size());
// for (SysLocaleResource res : resourceList) {
// //遍历资源放入map中
// lanMap = resMap.get(res.getResourceKey());
// //判断是否已存在资源信息
// if (lanMap == null) {
// lanMap = new HashMap<String, String>();
// //将key/代码放入
// resMap.put(res.getResourceKey(), lanMap);
// }
// //根据语言放入
// lanMap.put(res.getLanguageCode(), res.getResourceValue());
//
// // web 资源
// if (!webLangMap.containsKey(res.getLanguageCode())) {
// webLangMap.put(res.getLanguageCode(), new HashMap<>());
// }
// // 放入资源信息
// webResMap = webLangMap.get(res.getLanguageCode());
// webResMap.put(res.getResourceKey(), res.getResourceValue());
// }
//
// for (String key : resMap.keySet()) {
// //放入缓存
// redisRes.putHashMap(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE + ":" + key, resMap.get(key), 0);
// }
//
// for (String key : webLangMap.keySet()) {
// //放入缓存
// redisRes.putHashMap(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE + ":" + key, webLangMap.get(key), 0);
// }
//
// LOGGER.info("【资源配置文件已全部加载:{}个】", resMap.size());
/*
//资源集合

@ -3,6 +3,7 @@ package cn.estsh.i3plus.core.apiservice.controller.base;
import cn.estsh.i3plus.core.api.iservice.base.ISystemInitService;
import cn.estsh.i3plus.core.api.iservice.base.ISystemLoginService;
import cn.estsh.i3plus.core.api.iservice.busi.*;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.ServletRequestTool;
import cn.estsh.i3plus.platform.common.tool.StringTool;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
@ -16,7 +17,6 @@ import cn.estsh.impp.framework.base.controller.CoreBaseController;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.fastdfs.FastDFSClient;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import cn.estsh.impp.framework.boot.util.ResultBean;

@ -0,0 +1,38 @@
package cn.estsh.i3plus.core.apiservice.schedulejob;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.impp.framework.base.schedule.BaseImppScheduleJob;
import cn.estsh.impp.framework.boot.init.ApplicationProperties;
import io.swagger.annotations.ApiOperation;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Description : job
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-05-04 16:02
* @Modify:
**/
@ApiOperation("通用消息推送job")
public class CoreMessagePushJob extends BaseImppScheduleJob {
public static final Logger LOGGER = LoggerFactory.getLogger(CoreMessagePushJob.class);
public CoreMessagePushJob() {
super(CoreMessagePushJob.class,"通用消息推送job");
}
/**
* rabbitMQ
*/
@Autowired
private RabbitTemplate rabbitTemplate;
@Override
public void executeImppJob(JobExecutionContext context, ApplicationProperties applicationProperties) {
rabbitTemplate.convertAndSend(getJobParam(),CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
}
}

@ -64,7 +64,7 @@ public class SystemInitService implements ISystemInitService {
String redisKey = null;
List<SysConfig> list = configRDao.findAll();
for (SysConfig config : list) {
redisKey = CommonConstWords.REDIS_PREFIX_CACHE_CONFIG + "_" + config.getConfigCode();
redisKey = CommonConstWords.REDIS_PREFIX_CACHE_CONFIG + ":" + config.getConfigCode();
//存放于缓存
putDataToCache(redisKey, config,SysConfig.class);
@ -84,12 +84,12 @@ public class SystemInitService implements ISystemInitService {
for (String key : parentCodeMap.keySet()) {
//存放于缓存
putDataToCache(CommonConstWords.REDIS_PREFIX_CACHE_DICTIONARY + "_" + key,
putDataToCache(CommonConstWords.REDIS_PREFIX_CACHE_DICTIONARY + ":" + key,
parentCodeMap.get(key),List.class);
}
for (long key : parentIdMap.keySet()) {
putDataToCache(CommonConstWords.REDIS_PREFIX_CACHE_DICTIONARY + "_" + key,
putDataToCache(CommonConstWords.REDIS_PREFIX_CACHE_DICTIONARY + ":" + key,
parentIdMap.get(key),List.class);
}
}
@ -142,12 +142,12 @@ public class SystemInitService implements ISystemInitService {
for (String key : resMap.keySet()) {
//放入缓存
redisRes.putHashMap(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE + key,resMap.get(key),0);
redisRes.putHashMap(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE + ":"+ key,resMap.get(key),0);
}
for(String key : webLangMap.keySet()){
//放入缓存
redisRes.putHashMap(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE + key,webLangMap.get(key),0);
redisRes.putHashMap(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE + ":" + key,webLangMap.get(key),0);
}
}

Loading…
Cancel
Save