|
|
@@ -25,10 +25,12 @@ public class DMSService {
|
|
|
private static final class QueryResult {
|
|
|
final LocalDateTime time = LocalDateTime.now();
|
|
|
final List<JSONObject> dmsResult;
|
|
|
+
|
|
|
private QueryResult(List<JSONObject> dmsResult) {
|
|
|
this.dmsResult = dmsResult;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private final Map<DMSQuery, QueryResult> queryCache = new HashMap<>();
|
|
|
|
|
|
private JSONObject sendQueryToDms(DMSRequest request) {
|
|
|
@@ -44,8 +46,9 @@ public class DMSService {
|
|
|
Collections.singletonMap("token", request.token));
|
|
|
break;
|
|
|
}
|
|
|
- case JOIN_LIST: {
|
|
|
- response = "";
|
|
|
+ case Beautified: {
|
|
|
+ response = HttpUtil.requestPost(path + "/content/selectBeautified", params,
|
|
|
+ Collections.singletonMap("token", request.token));
|
|
|
break;
|
|
|
}
|
|
|
default: {
|
|
|
@@ -62,34 +65,35 @@ public class DMSService {
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
- public void updateToDms(Collection<JSONObject> objs,String token,DMSColumn column) {
|
|
|
+ public void updateToDms(Collection<JSONObject> objs, String token, DMSColumn column) {
|
|
|
if (objs == null || objs.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
|
|
- params.add("modelId",column.getModelId());
|
|
|
- params.add("json",JSON.toJSONString(objs));
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
+ params.add("modelId", column.getModelId());
|
|
|
+ params.add("json", JSON.toJSONString(objs));
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("token", token);
|
|
|
- HttpUtil.requestPost(path+"/content/updateContentByJson",params,headers);
|
|
|
+ HttpUtil.requestPost(path + "/content/updateContentByJson", params, headers);
|
|
|
}
|
|
|
+
|
|
|
public String importToDms(Resource resource, String token, DMSImport importType) {
|
|
|
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
|
|
- params.add("columnId",importType.getColumn().getId());
|
|
|
- params.add("contentParam",importType.getContent());
|
|
|
- params.add("titleParam",importType.getTitle());
|
|
|
- params.add("parseArray",importType.getRelation());
|
|
|
- params.add("secretLevel",0);
|
|
|
- params.add("file",resource);
|
|
|
- params.add("update",importType.isUpdate()?"true":"false");
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
+ params.add("columnId", importType.getColumn().getId());
|
|
|
+ params.add("contentParam", importType.getContent());
|
|
|
+ params.add("titleParam", importType.getTitle());
|
|
|
+ params.add("parseArray", importType.getRelation());
|
|
|
+ params.add("secretLevel", 0);
|
|
|
+ params.add("file", resource);
|
|
|
+ params.add("update", importType.isUpdate() ? "true" : "false");
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("token", token);
|
|
|
- return HttpUtil.requestPost(path+"/content/importBeautifiedExcel",params,headers);
|
|
|
+ return HttpUtil.requestPost(path + "/content/importBeautifiedExcel", params, headers);
|
|
|
}
|
|
|
|
|
|
private List<JSONObject> queryDmsList(DMSRequest request, String token, String columnId) {
|
|
|
request.token = token;
|
|
|
- request.type = DMSRequest.DMSRequestType.List;
|
|
|
+ if (request.type == null) request.type = DMSRequest.DMSRequestType.List;
|
|
|
request.setColumnId(columnId);
|
|
|
request.setState();
|
|
|
int page = 0;
|
|
|
@@ -120,16 +124,29 @@ public class DMSService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ public List<ClueFollow> queryClueFollow(String token, String cClueName, String cEnterpriseName, String constructionMethod) {
|
|
|
+
|
|
|
+ List<JSONObject> dmsResult;
|
|
|
+ DMSRequest request = DMSQuery.CLUE_FOLLOW.preRequest(null);
|
|
|
+ if (cClueName != null) request.addWhere("c_clue_name", "2", cClueName);
|
|
|
+ if (cEnterpriseName != null) request.addWhere("c_enterprise_name", "2", cEnterpriseName);
|
|
|
+ if (constructionMethod != null) request.addWhere("construction_method", "2", constructionMethod);
|
|
|
+
|
|
|
+ dmsResult = queryDmsList(request, token, DMSQuery.CLUE_FOLLOW.getColumnId());
|
|
|
+
|
|
|
+ return dmsResult.stream().map(jsonObject -> JSON.toJavaObject(jsonObject, ClueFollow.class)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
public List<JSONObject> simpleQuery(String token, String columId) {
|
|
|
return queryDmsList(new DMSRequest(), token, columId);
|
|
|
}
|
|
|
|
|
|
- public List<JSONObject> queryBeautified(String token,DMSColumn column) {
|
|
|
+ public List<JSONObject> queryBeautified(String token, DMSColumn column) {
|
|
|
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
|
|
- params.add("columnId",column.getId());
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
+ params.add("columnId", column.getId());
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("token", token);
|
|
|
- JSONObject object = JSON.parseObject(HttpUtil.requestPost(path+"/content/selectBeautified",params,headers));
|
|
|
+ JSONObject object = JSON.parseObject(HttpUtil.requestPost(path + "/content/selectBeautified", params, headers));
|
|
|
if (Objects.equals(object.getString("code"), "200")) {
|
|
|
JSONArray content = object.getJSONArray("content");
|
|
|
List<JSONObject> list = new ArrayList<>();
|
|
|
@@ -142,6 +159,15 @@ public class DMSService {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
+ public List<JSONObject> queryBeautifiedClue(String token, String cClueName, String cEnterpriseName, String constructionMethod) {
|
|
|
+ DMSRequest request = new DMSRequest();
|
|
|
+ request.type = DMSRequest.DMSRequestType.Beautified;
|
|
|
+ if (cClueName != null) request.addWhere("c_clue_name", "2", cClueName);
|
|
|
+ if (cEnterpriseName != null) request.addWhere("c_enterprise_name", "2", cEnterpriseName);
|
|
|
+ if (constructionMethod != null) request.addWhere("construction_method", "2", constructionMethod);
|
|
|
+ return queryDmsList(request, token, DMSColumn.CLUE.getId());
|
|
|
+ }
|
|
|
+
|
|
|
public int getLargestCode(String token, String columId, String codeColumn, String today) {
|
|
|
DMSRequest request = new DMSRequest();
|
|
|
request.addWhere(codeColumn, "2", "%" + today + "%");
|
|
|
@@ -168,9 +194,9 @@ public class DMSService {
|
|
|
return max;
|
|
|
}
|
|
|
|
|
|
- private List<JSONObject> getQueryCache(DMSQuery query){
|
|
|
+ private List<JSONObject> getQueryCache(DMSQuery query) {
|
|
|
QueryResult queryResult = queryCache.get(query);
|
|
|
- if (queryResult!=null&&Duration.between(queryResult.time,LocalDateTime.now()).compareTo(Duration.ofSeconds(15)) <= 0) {
|
|
|
+ if (queryResult != null && Duration.between(queryResult.time, LocalDateTime.now()).compareTo(Duration.ofSeconds(15)) <= 0) {
|
|
|
return queryResult.dmsResult;
|
|
|
}
|
|
|
return null;
|
|
|
@@ -185,20 +211,20 @@ public class DMSService {
|
|
|
dmsResult = getQueryCache(query);
|
|
|
if (dmsResult == null) {
|
|
|
dmsResult = queryDmsList(query.preRequest(now), token, query.getColumnId());
|
|
|
- queryCache.put(query,new QueryResult(dmsResult));
|
|
|
+ queryCache.put(query, new QueryResult(dmsResult));
|
|
|
}
|
|
|
|
|
|
return dmsResult.stream().map(jsonObject -> JSON.toJavaObject(jsonObject, clazz)).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
//下面几个接口是重计算用的,有重新插入的需求,不能放进queryEnum,不能领域化
|
|
|
- public List<JSONObject> getAllParkByLy(String lyCode,String token) {
|
|
|
+ public List<JSONObject> getAllParkByLy(String lyCode, String token) {
|
|
|
DMSRequest requestChildren = new DMSRequest();
|
|
|
requestChildren.addWhere("parent_cyy_code", "1", lyCode);
|
|
|
List<JSONObject> result = queryDmsList(requestChildren, token, DMSColumn.INDUSTRIAL_PARK.getId());
|
|
|
DMSRequest requestFarther = new DMSRequest();
|
|
|
requestFarther.addWhere("c_park_code", "1", lyCode);
|
|
|
- result.addAll( queryDmsList(requestFarther, token, DMSColumn.INDUSTRIAL_PARK.getId()));
|
|
|
+ result.addAll(queryDmsList(requestFarther, token, DMSColumn.INDUSTRIAL_PARK.getId()));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -207,19 +233,19 @@ public class DMSService {
|
|
|
return queryDmsList(request, token, DMSColumn.INDUSTRIAL_PARK.getId());
|
|
|
}
|
|
|
|
|
|
- public List<JSONObject> getAllLeaseByRooms(Set<String> roomString,String token) {
|
|
|
+ public List<JSONObject> getAllLeaseByRooms(Set<String> roomString, String token) {
|
|
|
DMSRequest request = new DMSRequest();
|
|
|
- request.addWhere("c_room_code","5",roomString);
|
|
|
- return queryDmsList(request,token,DMSColumn.LEASE_DETAIL.getId());
|
|
|
+ request.addWhere("c_room_code", "5", roomString);
|
|
|
+ return queryDmsList(request, token, DMSColumn.LEASE_DETAIL.getId());
|
|
|
}
|
|
|
|
|
|
public List<JSONObject> getAllLease(String token) {
|
|
|
DMSRequest request = new DMSRequest();
|
|
|
- return queryDmsList(request,token,DMSColumn.LEASE_DETAIL.getId());
|
|
|
+ return queryDmsList(request, token, DMSColumn.LEASE_DETAIL.getId());
|
|
|
}
|
|
|
|
|
|
- public List<JSONObject> getAllInvestmentTarget(String token){
|
|
|
+ public List<JSONObject> getAllInvestmentTarget(String token) {
|
|
|
DMSRequest request = new DMSRequest();
|
|
|
- return queryDmsList(request,token,DMSColumn.INVESTMENT_TARGET.getId());
|
|
|
+ return queryDmsList(request, token, DMSColumn.INVESTMENT_TARGET.getId());
|
|
|
}
|
|
|
}
|