Переглянути джерело

平面图查询设备bug修复

linhuili 3 роки тому
батько
коміт
7aaef2eae9

+ 14 - 8
src/main/java/com/persagy/proxy/dictionary/service/impl/AdmPlanarServiceImpl.java

@@ -268,15 +268,21 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
         queryCriteria.setCriteria(criteria);
         List<ObjectRelation> relationList = relationService.queryByCondition(context, queryCriteria);
         Set<String> equipIds = relationList.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toSet());
-
+        if(CollUtil.isEmpty(equipIds)){
+            return new ArrayList<>();
+        }
         //查询设备信息
-        QueryCriteria equipQueryCriteria = new QueryCriteria();
-        ObjectNode equipCriteria = JsonNodeFactory.instance.objectNode();
-        ArrayNode idNode = equipCriteria.putArray("id");
-        equipIds.forEach(id -> idNode.add(id));
-        ArrayNode classCodeNode = equipCriteria.putArray("classCode");
-        requests.getEquipTypes().forEach(classCode -> classCodeNode.add(classCode));
-        equipQueryCriteria.setCriteria(equipCriteria);
+        StringBuilder filters = new StringBuilder();
+        if(CollUtil.isNotEmpty(requests.getEquipTypes())){
+            filters.append("classCode in "+"(\'" + java.lang.String.join("\',\'", requests.getEquipTypes()) + "\')");
+        }
+        if(CollUtil.isNotEmpty(equipIds)){
+            filters.append("id in "+"(\'" + java.lang.String.join("\',\'", equipIds) + "\')");
+        }
+        AdmQueryCriteria equipQueryCriteria = new AdmQueryCriteria();
+        equipQueryCriteria.setFilters(filters.toString());
+        equipQueryCriteria.setOrders("createTime desc, id desc");
+
         AdmResponse admResponse = equipmentService.doQuery(context, equipQueryCriteria, clazz);
 
         return (List<AdmEquipment>) admResponse.getContent();