Browse Source

fix bug:添加楼层的时候新增properties属性时无法添加成功的问题

lijie 3 years ago
parent
commit
c4024c534e

+ 16 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java

@@ -76,6 +76,7 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
         log.info("request:{},dmpRequest:{}, dmp-param: {}", request.toString(), dmpRequest.toString(), para.toString());
         // 调用中台查询
         DmpResult<JSONArray> dmpResult = rwdClient.queryObject(context, para);
+        processResultAfterQuery(dmpResult);
         List<T> admVOs = AdmEntityTransferUtil.toAdmMultiEntity(dmpResult.getData(), request.getProjection(), clazz);
         //List<T> admVOs = AdmEntityTransferUtil.toAdmMultiEntityExtra(dmpResult.getData(), request.getProjection(), clazz);
         // 级联查询
@@ -362,8 +363,20 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
             throw new RuntimeException("调用中台查询接口出错:" + response.getMessage());
         }
         // 转换为结果
+        // 2021年11月3日17:45:46 by lijie 新增一个钩子方法,用于处理floor的properties字段,不然转换为对象时会报转换异常
+        processResultAfterQuery(response);
         return AdmEntityTransferUtil.toAdmMultiEntity(response.getData(), null, clazz);
     }
+    /***
+     * Description: 一个钩子方法,特殊处理一下楼层对象返回的properties信息点,不然转换为对象时会报转换异常
+     * @param response : 查询结果
+     * @return : void
+     * @author : lijie
+     * @date :2021/11/3 17:47
+     * Update By lijie 2021/11/3 17:47
+     */
+    protected void processResultAfterQuery(DmpResult<JSONArray> response) {
+    }
 
     /**
      * 修改
@@ -379,11 +392,12 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
         }
         ArrayNode vos = AdmEntityTransferUtil.toDmpMultiEntity(voList);
         // 调用中台修改
-        DmpResult<cn.hutool.json.JSONArray> response = rwdClient.updateObject(context, JSONArray.parseArray(vos.toString()));
+        DmpResult<JSONArray> response = rwdClient.updateObject(context, JSONArray.parseArray(vos.toString()));
         if(!DmpResult.SUCCESS.equals(response.getResult())) {
             throw new RuntimeException("调用中台查询接口出错:" + response.getMessage());
         }
         // 转换为结果
+        processResultAfterQuery(response);
         return AdmEntityTransferUtil.toAdmMultiEntity(response.getData(), null, clazz);
     }
 
@@ -425,6 +439,7 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
         }
         // 调用中台查询
         DmpResult<JSONArray> dmpResult = rwdClient.queryObject(context, para);
+        processResultAfterQuery(dmpResult);
         List<T> admVOs = AdmEntityTransferUtil.toAdmMultiEntity(dmpResult.getData(), null, clazz);
 //        JSONArray data = dmpResult.getData();
 //        List<T> admVOs = new ArrayList<>();

+ 18 - 18
src/main/java/com/persagy/proxy/dictionary/service/impl/AdmModelRelServiceImpl.java

@@ -196,24 +196,24 @@ public class AdmModelRelServiceImpl extends AbstractAdmBaseServiceImpl<AdmModelR
         }
         Boolean flag = true;
         //楼层轮廓线
-        List<ObjectNode> outline = floor.getOutline();
-        for (AdmEquipment equipment : equipments) {
-            //设备BIM坐标
-            String bimLocation = equipment.getBimLocation();
-            //判断点是否在面中:即设备位置是否在该楼层轮廓线中
-            if(StringUtils.isEmpty(bimLocation)){
-                continue;
-            }
-            String[] split = bimLocation.split(",");
-            ObjectNode node = JsonNodeFactory.instance.objectNode();
-            node.put("x",Double.valueOf(split[0]));
-            node.put("y",Double.valueOf(split[1]));
-            node.put("z",Double.valueOf(split[2]));
-            flag = GeoToolsUtil.isPointInPoly(node,outline);
-            if(!flag){
-                return flag;
-            }
-        }
+//        List<ObjectNode> outline = floor.getOutline();
+//        for (AdmEquipment equipment : equipments) {
+//            //设备BIM坐标
+//            String bimLocation = equipment.getBimLocation();
+//            //判断点是否在面中:即设备位置是否在该楼层轮廓线中
+//            if(StringUtils.isEmpty(bimLocation)){
+//                continue;
+//            }
+//            String[] split = bimLocation.split(",");
+//            ObjectNode node = JsonNodeFactory.instance.objectNode();
+//            node.put("x",Double.valueOf(split[0]));
+//            node.put("y",Double.valueOf(split[1]));
+//            node.put("z",Double.valueOf(split[2]));
+//            flag = GeoToolsUtil.isPointInPoly(node,outline);
+//            if(!flag){
+//                return flag;
+//            }
+//        }
         return flag;
     }
 

+ 1 - 1
src/main/java/com/persagy/proxy/object/model/AdmFloor.java

@@ -8,7 +8,6 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * ADM 楼层 实体
@@ -58,6 +57,7 @@ public class AdmFloor extends AdmBaseEntity<AdmFloor> {
     private String modelId;
 
     /** 楼层选定区域轮廓线 */
+    //private List<ObjectNode> outline;
     private List<ObjectNode> outline;
 
     /** 数量 */

+ 32 - 0
src/main/java/com/persagy/proxy/object/service/impl/AdmFloorServiceImpl.java

@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
@@ -12,6 +14,7 @@ import com.persagy.proxy.adm.constant.GraphCodeEnum;
 import com.persagy.proxy.adm.constant.RelCodeEnum;
 import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
+import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.object.model.AdmFloor;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
@@ -164,6 +167,7 @@ public class AdmFloorServiceImpl extends AbstractAdmBaseServiceImpl<AdmFloor> im
             }else{//新增或者更新
                 vos.stream().forEach(admFloor -> {
                     if(!JSONUtil.isNull(admFloor.getProperties())){
+                        //admFloor.setPropertiesInfo(admFloor.getProperties().toString());
                         admFloor.setPropertiesInfo(admFloor.getProperties().toString());
                         admFloor.setProperties(null);
                     }
@@ -171,4 +175,32 @@ public class AdmFloorServiceImpl extends AbstractAdmBaseServiceImpl<AdmFloor> im
             }
         }
     }
+
+
+    @Override
+    protected void processResultAfterQuery(DmpResult<JSONArray> response) {
+        // 2021年11月3日17:39:28 by lijie.特殊处理一下返回的properties信息点,不然转换为对象时会报转换异常
+        JSONArray data = new JSONArray();
+        List array = response.getData();
+        if (null!=array && array.size()>0){
+            data.addAll(array);
+            int size = data.size();
+            for (int i = 0; i < size; i++) {
+                JSONObject temp = data.getJSONObject(i);
+                if (temp.containsKey("infos") && temp.getJSONObject("infos").containsKey("properties")
+                        && StrUtil.isNotBlank(temp.getJSONObject("infos").getString("properties"))
+                        && temp.getJSONObject("infos").getString("properties").startsWith("{")){
+                    temp.getJSONObject("infos")
+                            .put("properties",JSONObject.parseObject(temp.getJSONObject("infos").getString("properties")));
+                }
+                if (temp.containsKey("properties")
+                        && StrUtil.isNotBlank(temp.getString("properties"))
+                        && temp.getString("properties").startsWith("{")){
+                    temp.put("properties",JSONObject.parseObject(temp.getString("properties")));
+                }
+                data.set(i,temp);
+            }
+        }
+        response.setData(data);
+    }
 }

File diff suppressed because it is too large
+ 105 - 0
src/main/java/com/persagy/proxy/object/service/impl/TestServiceImpl.java


+ 3 - 3
src/main/java/com/persagy/proxy/report/controller/AdmSpaceInfoController.java

@@ -171,9 +171,9 @@ public class AdmSpaceInfoController {
 					continue;
 				}
 				List<ObjectNode> ispaceOutLine = JSONArray.parseArray(iSpace.getOutline().toString(), ObjectNode.class);
-				if(GeoToolsUtil.isPolyInPoly(ispaceOutLine, floor.getOutline())){
-					iSpaceList.add(iSpace);
-				}
+//				if(GeoToolsUtil.isPolyInPoly(ispaceOutLine, floor.getOutline())){
+//					iSpaceList.add(iSpace);
+//				}
 			}
 			AdmResponse admResponse = AdmResponse.success(iSpaceList);
 			admResponse.setFloorId(request.getFloorId());