提交 471c68b1 authored 作者: zjm's avatar zjm

fix(配套设备): 添加形态的筛选且添加形态中文字段供前端使用

添加形态的筛选且添加形态中文字段供前端使用
上级 d7778fcc
...@@ -32,6 +32,8 @@ public class ConfigCache { ...@@ -32,6 +32,8 @@ public class ConfigCache {
private Map<Integer, String> storageLocationMap; private Map<Integer, String> storageLocationMap;
private Map<Integer, String> matchingTypeMap;
public ConfigCache(List<SystemConfig> systemConfigs){ public ConfigCache(List<SystemConfig> systemConfigs){
this.lifeStatusMap = systemConfigs.stream().filter(systemConfig -> "lifeStatus".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel)); this.lifeStatusMap = systemConfigs.stream().filter(systemConfig -> "lifeStatus".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
...@@ -45,7 +47,7 @@ public class ConfigCache { ...@@ -45,7 +47,7 @@ public class ConfigCache {
this.positionMap = systemConfigs.stream().filter(systemConfig -> "position".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel)); this.positionMap = systemConfigs.stream().filter(systemConfig -> "position".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
this.allotTypeMap = systemConfigs.stream().filter(systemConfig -> "allotType".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel)); this.allotTypeMap = systemConfigs.stream().filter(systemConfig -> "allotType".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
this.storageLocationMap = systemConfigs.stream().filter(systemConfig -> "storageLocation".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel)); this.storageLocationMap = systemConfigs.stream().filter(systemConfig -> "storageLocation".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
this.matchingTypeMap=systemConfigs.stream().filter(systemConfig -> "matchingType".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
} }
public Map<Integer, String> getMatchingRangeMap() { public Map<Integer, String> getMatchingRangeMap() {
...@@ -92,6 +94,9 @@ public class ConfigCache { ...@@ -92,6 +94,9 @@ public class ConfigCache {
return storageLocationMap; return storageLocationMap;
} }
public Map<Integer, String> getMatchingTypeMap() {
return matchingTypeMap;
}
public ConfigCache refresh(List<SystemConfig> systemConfigs){ public ConfigCache refresh(List<SystemConfig> systemConfigs){
this.lifeStatusMap = systemConfigs.stream().filter(systemConfig -> "lifeStatus".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel)); this.lifeStatusMap = systemConfigs.stream().filter(systemConfig -> "lifeStatus".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
...@@ -105,6 +110,7 @@ public class ConfigCache { ...@@ -105,6 +110,7 @@ public class ConfigCache {
this.positionMap = systemConfigs.stream().filter(systemConfig -> "position".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel)); this.positionMap = systemConfigs.stream().filter(systemConfig -> "position".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
this.allotTypeMap = systemConfigs.stream().filter(systemConfig -> "allotType".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel)); this.allotTypeMap = systemConfigs.stream().filter(systemConfig -> "allotType".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
this.storageLocationMap = systemConfigs.stream().filter(systemConfig -> "storageLocation".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel)); this.storageLocationMap = systemConfigs.stream().filter(systemConfig -> "storageLocation".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
this.matchingTypeMap=systemConfigs.stream().filter(systemConfig -> "matchingType".equals(systemConfig.getEnglishName())).collect(Collectors.toMap(SystemConfig::getValue, SystemConfig::getLabel));
return this; return this;
} }
} }
...@@ -354,8 +354,15 @@ public class MatchingDeviceController { ...@@ -354,8 +354,15 @@ public class MatchingDeviceController {
Page<MatchingDeviceLibrary> deviceLibraryEntities = PageUtil.getPerPage(matchingDeviceSelectVo.getPage(), Page<MatchingDeviceLibrary> deviceLibraryEntities = PageUtil.getPerPage(matchingDeviceSelectVo.getPage(),
matchingDeviceSelectVo.getSize(), matchingDeviceLibraryList, matchingDeviceSelectVo.getPageable()); matchingDeviceSelectVo.getSize(), matchingDeviceLibraryList, matchingDeviceSelectVo.getPageable());
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
matchingDeviceLibraryList = matchingDeviceLibraryList.stream().map(MatchingDeviceLibrary::setConfigName).collect(Collectors.toList());
map.put("pages",deviceLibraryEntities); map.put("pages",deviceLibraryEntities);
ConfigCache configCache = SpringUtils.getBean("initConfigCache");
List<String> types = matchingDeviceLibraryList.stream().map(MatchingDeviceLibrary::getType).collect(Collectors.toList());
List<String> finalTypes = types.stream().distinct().collect(Collectors.toList());
assert configCache != null;
Map<Integer, String> matchingTypeMap = configCache.getMatchingTypeMap().entrySet().stream().filter(map1->finalTypes.contains(map1.getKey().toString())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
map.put("type",matchingTypeMap);
//修改 增加排序 //修改 增加排序
//做一下去重 //做一下去重
List<String> models = matchingDeviceLibraryList.stream().map(MatchingDeviceLibrary::getModel).collect(Collectors.toList()); List<String> models = matchingDeviceLibraryList.stream().map(MatchingDeviceLibrary::getModel).collect(Collectors.toList());
......
...@@ -125,10 +125,16 @@ public class MatchingDeviceLibrary { ...@@ -125,10 +125,16 @@ public class MatchingDeviceLibrary {
@Transient @Transient
private String lifeStatusName; private String lifeStatusName;
@ApiModelProperty(value = "形态名称")
@Transient
private String typeName;
public MatchingDeviceLibrary setConfigName(){ public MatchingDeviceLibrary setConfigName(){
ConfigCache configCache = SpringUtils.getBean("initConfigCache"); ConfigCache configCache = SpringUtils.getBean("initConfigCache");
if (configCache != null) { if (configCache != null) {
setLifeStatusName(configCache.getLifeStatusMap().get(this.lifeStatus)==null?"-":configCache.getLifeStatusMap().get(this.lifeStatus)); setLifeStatusName(configCache.getLifeStatusMap().get(this.lifeStatus)==null?"-":configCache.getLifeStatusMap().get(this.lifeStatus));
setTypeName(configCache.getMatchingTypeMap().get(Integer.valueOf(this.type))==null?"-":configCache.getMatchingTypeMap().get(Integer.valueOf(this.type)));
} }
return this; return this;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论