From 6c46e9d9a1fc7f69d71f2c4cd79b28c244fab8f2 Mon Sep 17 00:00:00 2001 From: "jimmy.zeng" Date: Wed, 10 Jul 2019 20:03:59 +0800 Subject: [PATCH] =?UTF-8?q?WMS=E8=8E=B7=E5=8F=96=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/base/SystemController.java | 87 +++++++++++++++++++--- 1 file changed, 76 insertions(+), 11 deletions(-) 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 8f13ff1..07717ff 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 @@ -1,22 +1,33 @@ 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.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; +import cn.estsh.i3plus.pojo.platform.bean.SysDictionary; import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; 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.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; 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.*; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; /** * @Description : @@ -33,25 +44,79 @@ public class SystemController { @Autowired private Environment environment; + @Autowired + private IWmsCommonCloud wmsCommonCloud; + + @Autowired + private ISysDictionaryService sysDictionaryService; + @GetMapping("/get-properties") @ApiOperation(value = "获取系统配置信息", notes = "获取系统配置信息") public ResultBean getProperties(){ try { //条件验证 - String[] profiles = environment.getDefaultProfiles(); - Map map = new HashMap(); - for(Iterator it = ((AbstractEnvironment) environment).getPropertySources().iterator(); it.hasNext(); ) { - PropertySource propertySource = (PropertySource) it.next(); - if (propertySource instanceof MapPropertySource) { - MapPropertySource source = (MapPropertySource) propertySource; - for (String key : source.getPropertyNames()) { - map.put(key,source.getProperty(key)); + Map map = getStringObjectMap(); + + return ResultBean.success("操作成功") + .setResultMap(map) + .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); + } catch (ImppBusiException busExcep) { + return ResultBean.fail(busExcep); + } catch (Exception e) { + return ImppExceptionBuilder.newInstance().buildExceptionResult(e); + } + } + + private Map getStringObjectMap() { + String[] profiles = environment.getDefaultProfiles(); + Map map = new TreeMap<>(); + for(Iterator it = ((AbstractEnvironment) environment).getPropertySources().iterator(); it.hasNext(); ) { + PropertySource propertySource = (PropertySource) it.next(); + if (propertySource instanceof MapPropertySource) { + MapPropertySource source = (MapPropertySource) propertySource; + for (String key : source.getPropertyNames()) { + map.put(key,source.getProperty(key)); + } + } + } + return map; + } + + @GetMapping("/cloud-properties/{id}") + @ApiOperation(value = "获取系统配置信息", notes = "获取系统配置信息") + public ResultBean getProperties(@PathVariable("id") Integer id){ + try { + ValidatorBean.checkIsNumber(id, "参数错误"); + CommonEnumUtil.SOFT_TYPE softType = CommonEnumUtil.SOFT_TYPE.valueOf(id); + Map resultMap = null; + switch (softType) { + case WMS: + resultMap = wmsCommonCloud.getSystemProperties().getResultMap(); + break; + case CORE: + resultMap = getStringObjectMap(); + break; + } + + // 根据字典查询 不查看的配置信息 + List softTypeAndParentCode = sysDictionaryService.findSysDictionaryBySoftTypeAndParentCode( + CommonEnumUtil.SOFT_TYPE.CORE.getValue(), BaseConstWords.DICTIONARY_PROPERTIES); + + // 删除无效key + if (!CollectionUtils.isEmpty(softTypeAndParentCode)) { + for (Iterator> it = resultMap.entrySet().iterator(); it.hasNext(); ) { + + Map.Entry item = it.next(); + for (SysDictionary dictionary : softTypeAndParentCode) { + if (StringUtils.equalsIgnoreCase(item.getKey(), dictionary.getDictionaryValue())) { + it.remove(); + } } } } return ResultBean.success("操作成功") - .setResultMap(map) + .setResultMap(resultMap) .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); } catch (ImppBusiException busExcep) { return ResultBean.fail(busExcep);