WMS获取系统配置信息

yun-zuoyi
曾贞一 6 years ago
parent 642c074aa1
commit 6c46e9d9a1

@ -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<String, Object> 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<String, Object> 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<String, Object> getStringObjectMap() {
String[] profiles = environment.getDefaultProfiles();
Map<String, Object> 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<String, Object> resultMap = null;
switch (softType) {
case WMS:
resultMap = wmsCommonCloud.getSystemProperties().getResultMap();
break;
case CORE:
resultMap = getStringObjectMap();
break;
}
// 根据字典查询 不查看的配置信息
List<SysDictionary> softTypeAndParentCode = sysDictionaryService.findSysDictionaryBySoftTypeAndParentCode(
CommonEnumUtil.SOFT_TYPE.CORE.getValue(), BaseConstWords.DICTIONARY_PROPERTIES);
// 删除无效key
if (!CollectionUtils.isEmpty(softTypeAndParentCode)) {
for (Iterator<Map.Entry<String, Object>> it = resultMap.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, Object> 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);

Loading…
Cancel
Save