diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/SystemController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/SystemController.java index c28a99d..a37d11d 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/SystemController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/SystemController.java @@ -2,33 +2,32 @@ package cn.estsh.i3plus.core.apiservice.controller.base; import cn.estsh.i3plus.core.api.iservice.busi.ISysDictionaryService; import cn.estsh.i3plus.icloud.wms.sdk.IWmsCommonCloud; -import cn.estsh.i3plus.pojo.base.bean.BaseConstWords; -import cn.estsh.i3plus.pojo.base.bean.BaseResultBean; +import cn.estsh.i3plus.platform.common.util.PlatformConstWords; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; -import cn.estsh.i3plus.pojo.platform.bean.SysDictionary; +import cn.estsh.impp.framework.boot.configuration.SystemConfig; import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; +import cn.estsh.impp.framework.boot.util.ImppRedis; import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ValidatorBean; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.AbstractEnvironment; import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.PropertySource; -import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import javax.annotation.Resource; +import java.util.*; /** * @Description : @@ -42,15 +41,23 @@ import java.util.TreeMap; @RequestMapping("/system") public class SystemController { + private static final Logger LOGGER = LoggerFactory.getLogger(SystemController.class); + @Autowired private Environment environment; @Autowired private IWmsCommonCloud wmsCommonCloud; + @Resource(name="redisCore") + protected ImppRedis redisCore; + @Autowired private ISysDictionaryService sysDictionaryService; + @Autowired + private SystemConfig systemConfig; + @GetMapping("/get-properties") @ApiOperation(value = "获取系统配置信息", notes = "获取系统配置信息") public ResultBean getProperties(){ @@ -87,48 +94,43 @@ public class SystemController { @ApiOperation(value = "获取系统配置信息", notes = "获取系统配置信息") public ResultBean getProperties(@PathVariable("id") Integer id){ try { - ValidatorBean.checkIsNumber(id, "参数错误"); + + ValidatorBean.checkIsNumber(id, "平台类型不能为空"); CommonEnumUtil.SOFT_TYPE softType = CommonEnumUtil.SOFT_TYPE.valueOf(id); - Map resultMap = null; - BaseResultBean resultBean; - switch (softType) { - case CORE: - resultMap = getStringObjectMap(); - break; - case FORM: - break; - case REPORT: - resultMap = getStringObjectMap(); - break; - case GATEWAY: - resultMap = getStringObjectMap(); - break; - case CENTER: - resultMap = getStringObjectMap(); - break; - case WMS: - break; - } + ValidatorBean.checkIsNumber(id, "错误平台信息"); + + String redisKey = PlatformConstWords.REDIS_SYSTEM_PROPERTIES+ ":" + softType.getCode()+ "*"; + Set redisKeys = redisCore.getKeysSet(redisKey); + TreeMap> result = new TreeMap<>(); - // 根据字典查询 不查看的配置信息 - List softTypeAndParentCode = sysDictionaryService.findSysDictionaryBySoftTypeAndParentCode( - CommonEnumUtil.SOFT_TYPE.CORE.getValue(), BaseConstWords.DICTIONARY_PROPERTIES); + LOGGER.info("系统配置信息 redisKey中:{}",redisKey); + Object redisValue = redisCore.getObject(redisKey); + if(redisKeys != null){ + redisKeys.forEach(key ->{ + String configInfo = key.substring(redisKey.length(), key.length()).replace("_",":"); + LOGGER.info("系统配置信息 IP-port:{}",configInfo); + Map redisCacheMap = redisCore.getHashMap(key); - // 删除无效key - if (!CollectionUtils.isEmpty(softTypeAndParentCode)) { - for (Iterator> it = resultMap.entrySet().iterator(); it.hasNext(); ) { + if(redisCacheMap != null && redisCacheMap.size() > 0){ + redisCacheMap.forEach((k,v) ->{ + if(k != null && StringUtils.isNotBlank(k.toString())){ + Map map = result.get(k); + if(map == null){ + map = new HashMap<>(); + } - Map.Entry item = it.next(); - for (SysDictionary dictionary : softTypeAndParentCode) { - if (StringUtils.equalsIgnoreCase(item.getKey(), dictionary.getDictionaryValue())) { - it.remove(); - } + map.put(configInfo,v); + result.put(k.toString(),map); + } + }); } - } + }); } + LOGGER.info("系统配置信息 result中值size:{}",result.size()); + return ResultBean.success("操作成功") - .setResultMap(resultMap) + .setResultMap(result) .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); } catch (ImppBusiException busExcep) { return ResultBean.fail(busExcep);