feat:条码解析初始化缓存

yun-zuoyi
汪云昊 5 years ago
parent 85f11d7d0a
commit 17d655bf1f

@ -55,4 +55,7 @@ public interface ISystemInitService {
@ApiOperation(value = "定时任务日志等级") @ApiOperation(value = "定时任务日志等级")
void reloadTaskPlanLogLevel(); void reloadTaskPlanLogLevel();
@ApiOperation(value = "定时任务日志等级")
void reloadBarcodeRule();
} }

@ -127,8 +127,12 @@ public class AuthController extends CoreBaseController {
@GetMapping(value = "/menu/find-home-list") @GetMapping(value = "/menu/find-home-list")
@ApiOperation(value = "获取登录用户功能权限信息", notes = "获取首页权限信息") @ApiOperation(value = "获取登录用户功能权限信息", notes = "获取首页权限信息")
public ResultBean findHomeList() { public ResultBean findHomeList() {
Long startTime = System.currentTimeMillis();
List<SysMenu> menuList = memTreeService.packTreeSysMenuByUserId(getSessionUser().getUser().getId()); List<SysMenu> menuList = memTreeService.packTreeSysMenuByUserId(getSessionUser().getUser().getId());
Long menuSelectTime = System.currentTimeMillis();
LOGGER.info("第一段耗时:{}",menuSelectTime-startTime);
List<SysMenu> list = memTreeService.packTreeSysMenuByParentIdAndMenuType(menuList, CommonConstWords.SYSTEM_MENU_ROOT_ID, CommonEnumUtil.METHOD_LEVEL.PLUGIN.getValue()); List<SysMenu> list = memTreeService.packTreeSysMenuByParentIdAndMenuType(menuList, CommonConstWords.SYSTEM_MENU_ROOT_ID, CommonEnumUtil.METHOD_LEVEL.PLUGIN.getValue());
LOGGER.info("第二段耗时:{}", System.currentTimeMillis() - menuSelectTime);
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
// 内存排序 Sort 降序 code 升序 // 内存排序 Sort 降序 code 升序

@ -127,6 +127,21 @@ public class PressureTestController extends CoreBaseController {
} }
} }
@GetMapping("/redis-get")
@ApiOperation(value = "redisGet", notes = "redisGet")
public ResultBean redisGet(){
try {
for (int i = 0; i < 1000; i++) {
imppRedis.getObject(i + "");
}
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep);
}catch(Exception e){
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping("/redis-put-test") @GetMapping("/redis-put-test")
@ApiOperation(value = "redisPutTest", notes = "redisPutTest") @ApiOperation(value = "redisPutTest", notes = "redisPutTest")
public ResultBean redisPutTest(){ public ResultBean redisPutTest(){

@ -2,6 +2,7 @@ package cn.estsh.i3plus.core.apiservice.controller.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysBarcodeRuleService; import cn.estsh.i3plus.core.api.iservice.busi.ISysBarcodeRuleService;
import cn.estsh.i3plus.core.apiservice.util.BarcodeParseUtil; import cn.estsh.i3plus.core.apiservice.util.BarcodeParseUtil;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.platform.common.util.PlatformConstWords; import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
@ -12,6 +13,7 @@ import cn.estsh.impp.framework.base.controller.CoreBaseController;
import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum; import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean; import cn.estsh.impp.framework.boot.util.ValidatorBean;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -21,6 +23,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map; import java.util.Map;
/** /**
@ -40,6 +43,9 @@ public class SysBarcodeRuleController extends CoreBaseController {
@Autowired @Autowired
private ISysBarcodeRuleService sysBarcodeRuleService; private ISysBarcodeRuleService sysBarcodeRuleService;
@Resource(name= CommonConstWords.IMPP_REDIS_RES)
private ImppRedis redisRes;
/** /**
* *
* @param sysBarcodeRule * @param sysBarcodeRule
@ -55,7 +61,10 @@ public class SysBarcodeRuleController extends CoreBaseController {
.notNull("barcodeRuleCode",sysBarcodeRule.getBarcodeRuleCode()) .notNull("barcodeRuleCode",sysBarcodeRule.getBarcodeRuleCode())
.notNull("barcodeRule",sysBarcodeRule.getBarcodeRule()); .notNull("barcodeRule",sysBarcodeRule.getBarcodeRule());
sysBarcodeRuleService.insertSysBarcodeRule(sysBarcodeRule); sysBarcodeRule = sysBarcodeRuleService.insertSysBarcodeRule(sysBarcodeRule);
saveRedis(sysBarcodeRule);
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){ }catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep); return ResultBean.fail(busExcep);
@ -80,6 +89,9 @@ public class SysBarcodeRuleController extends CoreBaseController {
.notNull("barcodeRule",sysBarcodeRule.getBarcodeRule()); .notNull("barcodeRule",sysBarcodeRule.getBarcodeRule());
sysBarcodeRuleService.updateSysBarcodeRule(sysBarcodeRule); sysBarcodeRuleService.updateSysBarcodeRule(sysBarcodeRule);
saveRedis(sysBarcodeRule);
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){ }catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep); return ResultBean.fail(busExcep);
@ -112,6 +124,9 @@ public class SysBarcodeRuleController extends CoreBaseController {
} }
sysBarcodeRuleService.deleteSysBarcodeRuleById(Long.parseLong(idStr)); sysBarcodeRuleService.deleteSysBarcodeRuleById(Long.parseLong(idStr));
removeRedis(sysBarcodeRule);
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){ }catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep); return ResultBean.fail(busExcep);
@ -171,4 +186,14 @@ public class SysBarcodeRuleController extends CoreBaseController {
} }
} }
private void saveRedis(SysBarcodeRule barcodeRule){
String redisKey = CommonConstWords.REDIS_PREFIX_BARCODE_RULE + ":" + barcodeRule.getBarcodeRuleCode();
redisRes.putObject(redisKey, barcodeRule, -1);
}
private void removeRedis(SysBarcodeRule barcodeRule){
String redisKey = CommonConstWords.REDIS_PREFIX_BARCODE_RULE + ":" + barcodeRule.getBarcodeRuleCode();
redisRes.deleteKey(redisKey);
}
} }

@ -69,6 +69,9 @@ public class SystemInitService implements ISystemInitService {
@Autowired @Autowired
private ISysTaskPlanService sysTaskPlanService; private ISysTaskPlanService sysTaskPlanService;
@Autowired
private ISysBarcodeRuleService sysBarcodeRuleService;
@Resource(name= CommonConstWords.IMPP_REDIS_RES) @Resource(name= CommonConstWords.IMPP_REDIS_RES)
private ImppRedis redisRes; private ImppRedis redisRes;
@ -104,6 +107,10 @@ public class SystemInitService implements ISystemInitService {
LOGGER.info("加载 定时任务日志等级"); LOGGER.info("加载 定时任务日志等级");
reloadTaskPlanLogLevel(); reloadTaskPlanLogLevel();
LOGGER.info("加载 定时任务日志等级 信息完成"); LOGGER.info("加载 定时任务日志等级 信息完成");
LOGGER.info("加载 条码规则");
reloadBarcodeRule();
LOGGER.info("加载 条码规则 信息完成");
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -114,9 +121,7 @@ public class SystemInitService implements ISystemInitService {
public void putAndLoadSysConfig() { public void putAndLoadSysConfig() {
List<SysConfig> list = configRDao.findAll(); List<SysConfig> list = configRDao.findAll();
if(list != null && list.size() > 0){ if(list != null && list.size() > 0){
list.forEach(config -> { list.forEach(RedisCacheTool::setSysConfigByConfigCode);
RedisCacheTool.setSysConfigByConfigCode(config);
});
LOGGER.info("加载系统配置数量:【{}】",list.size()); LOGGER.info("加载系统配置数量:【{}】",list.size());
} }
} }
@ -430,4 +435,15 @@ public class SystemInitService implements ISystemInitService {
} }
} }
} }
@Override
public void reloadBarcodeRule() {
List<SysBarcodeRule> sysBarcodeRuleList = sysBarcodeRuleService.listSysBarcodeRule();
if (CollectionUtils.isNotEmpty(sysBarcodeRuleList)) {
for (SysBarcodeRule barcodeRule : sysBarcodeRuleList) {
String redisKey = CommonConstWords.REDIS_PREFIX_BARCODE_RULE + ":" + barcodeRule.getBarcodeRuleCode();
redisRes.putObject(redisKey, barcodeRule, -1);
}
}
}
} }

Loading…
Cancel
Save