Commit 5f7ea357 authored by tianyiming's avatar tianyiming

fix(core): 使用新的UnitTypeNewEnum替换旧的UnitTypeEnum

parent cd66077f
package com.yeejoin.amos.boot.module.statistics.api.enums;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
@AllArgsConstructor
@Getter
public enum UnitTypeNewEnum {
/**
* *注册单位类型
*/
sydw("使用单位", "1232", "use"),
czdw("充装单位", "1231", "license"),
jydw("检验单位", "1233", "license"),
jcdw("检测单位", "1233", "license"),
azgzwxdw("安装改造维修单位", "1234", "license"),
zzdw("制造单位", "1236", "license"),
sjdw("设计单位", "1235", "license"),
grzt("个人主体", "6599", "use");
private String name;
private String code;
private String type;
public static Map<String, String> getName = new HashMap<>();
public static Map<String, String> getCode = new HashMap<>();
static {
for (UnitTypeNewEnum e : UnitTypeNewEnum.values()) {
getName.put(e.code, e.name);
getCode.put(e.name, e.code);
}
}
public static JSONArray getAll() {
JSONArray jsonArray = new JSONArray();
for (UnitTypeNewEnum e : UnitTypeNewEnum.values()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("label", e.name);
jsonObject.put("value", e.name);
jsonObject.put("key", e.code);
jsonArray.add(jsonObject);
}
return jsonArray;
}
public static JSONArray getUnitTypeByType(String category) {
if (ObjectUtils.isEmpty(category)) {
return getAll();
}
JSONArray jsonArray = new JSONArray();
for (UnitTypeNewEnum e : UnitTypeNewEnum.values()) {
if (e.type.equals(category)) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("label", e.name);
jsonObject.put("value", e.name);
jsonObject.put("key", e.code);
jsonArray.add(jsonObject);
}
}
return jsonArray;
}
}
...@@ -254,7 +254,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -254,7 +254,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if (k.equals("unitCategory")) { if (k.equals("unitCategory")) {
if (!ObjectUtils.isEmpty(v) && ((JSONArray) v).size() == 1) { if (!ObjectUtils.isEmpty(v) && ((JSONArray) v).size() == 1) {
String category = ((JSONArray) v).get(0).toString(); String category = ((JSONArray) v).get(0).toString();
JSONArray unitTypeByType = UnitTypeEnum.getUnitTypeByType(category); JSONArray unitTypeByType = UnitTypeNewEnum.getUnitTypeByType(category);
List<String> list = unitTypeByType.stream().map(e -> JSONObject.parseObject(JSONObject.toJSONString(e)).get("value").toString()).collect(Collectors.toList()); List<String> list = unitTypeByType.stream().map(e -> JSONObject.parseObject(JSONObject.toJSONString(e)).get("value").toString()).collect(Collectors.toList());
list.forEach(item -> boolMust.should(QueryBuilders.wildcardQuery("unitType.keyword", "*" + item + "*")).minimumShouldMatch(1)); list.forEach(item -> boolMust.should(QueryBuilders.wildcardQuery("unitType.keyword", "*" + item + "*")).minimumShouldMatch(1));
} }
...@@ -507,7 +507,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -507,7 +507,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if (k.equals("unitCategory")) { if (k.equals("unitCategory")) {
if (!ObjectUtils.isEmpty(v) && ((JSONArray) v).size() == 1) { if (!ObjectUtils.isEmpty(v) && ((JSONArray) v).size() == 1) {
String category = ((JSONArray) v).get(0).toString(); String category = ((JSONArray) v).get(0).toString();
JSONArray unitTypeByType = UnitTypeEnum.getUnitTypeByType(category); JSONArray unitTypeByType = UnitTypeNewEnum.getUnitTypeByType(category);
List<String> list = unitTypeByType.stream().map(e -> JSONObject.parseObject(JSONObject.toJSONString(e)).get("value").toString()).collect(Collectors.toList()); List<String> list = unitTypeByType.stream().map(e -> JSONObject.parseObject(JSONObject.toJSONString(e)).get("value").toString()).collect(Collectors.toList());
list.forEach(item -> boolMust.should(QueryBuilders.wildcardQuery("unitType.keyword", "*" + item + "*")).minimumShouldMatch(1)); list.forEach(item -> boolMust.should(QueryBuilders.wildcardQuery("unitType.keyword", "*" + item + "*")).minimumShouldMatch(1));
} }
...@@ -892,7 +892,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -892,7 +892,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private BigDecimal getPipeLength(BoolQueryBuilder boolMust, SearchSourceBuilder builder) { private BigDecimal getPipeLength(BoolQueryBuilder boolMust, SearchSourceBuilder builder) {
SearchRequest request = new SearchRequest(); SearchRequest request = new SearchRequest();
BigDecimal pipeLong = BigDecimal.ZERO; BigDecimal pipeLong = BigDecimal.ZERO;
// boolMust.must(QueryBuilders.termQuery("EQU_LIST_CODE", "8000"));
builder.query(boolMust); builder.query(boolMust);
builder.from(0); builder.from(0);
builder.size(10000000); builder.size(10000000);
...@@ -1569,7 +1568,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1569,7 +1568,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
public JSONArray queryUnitType(String type) { public JSONArray queryUnitType(String type) {
return UnitTypeEnum.getUnitTypeByType(type); return UnitTypeNewEnum.getUnitTypeByType(type);
} }
public JSONObject queryCompanySearchData(String type) { public JSONObject queryCompanySearchData(String type) {
...@@ -1577,7 +1576,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1577,7 +1576,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
//获取企业分类 //获取企业分类
result.put("unitCategory", getUnitCategory()); result.put("unitCategory", getUnitCategory());
//获取企业类型 //获取企业类型
result.put("unitType", UnitTypeEnum.getUnitTypeByType(type)); result.put("unitType", UnitTypeNewEnum.getUnitTypeByType(type));
//获取企业等级 //获取企业等级
result.put("regulatoryLabels", deployDictionary(dataDictionaryService.getByType("QYBQ"))); result.put("regulatoryLabels", deployDictionary(dataDictionaryService.getByType("QYBQ")));
...@@ -1729,7 +1728,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1729,7 +1728,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
//获取企业分类 //获取企业分类
result.put("unitCategory", getUnitCategory()); result.put("unitCategory", getUnitCategory());
//获取企业类型 //获取企业类型
result.put("unitType", UnitTypeEnum.getUnitTypeByType(type)); result.put("unitType", UnitTypeNewEnum.getUnitTypeByType(type));
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment