Browse Source

fix bug:信息点(高度)无法修改成功

lijie 3 years ago
parent
commit
89f504c773

+ 18 - 0
src/main/java/com/persagy/proxy/adm/constant/AdmDictConstant.java

@@ -1,5 +1,9 @@
 package com.persagy.proxy.adm.constant;
 
+import cn.hutool.core.collection.CollUtil;
+
+import java.util.Set;
+
 /**
  * @ClassName AdmDictConstant
  * @Description: 字典常量
@@ -22,4 +26,18 @@ public interface AdmDictConstant {
     String HIS_FIRST_BASE_TAG="基础参数";
     /** 一级标签历史名称-基本参数 */
     String HIS_FIRST_BASE_TAG_TWO="基本参数";
+    /** 高度 */
+    String HEIGHT="height";
+    /** 图片 */
+    String PIC="pic";
+    /** 表的信息点 */
+    Set<String> TABLE_INFOS= CollUtil.newHashSet("id","name","localId","localName",
+            "qRCodePic","defaultQRCode","rFID","cADID","bimId","bimTypeId","bimLocation","bimFamilyName",
+            "bimFamilySymbol","equipSerial","modelId","note","introduction","businessFloorNum","officeFloorNum",
+            "shaftSequenceId","outline","buildQRCode","bimIdPre","floorSequenceId","floorSequenceID",
+            "permanentPeopleNum","floorIdentity","depth","width","buildArea","netArea","height","intro",
+            "ratedCoolingP","ratedHeatingP","acType","zoneOrientation","roomFuncType","roomSerial",
+            "projRoomFuncType","ratedLightP","zoneType","tenantType","tenant","elecCap","pollutionDegree",
+            "groupCode","projectId","objType","classCode","grouping","virtualCodes","createApp","updateApp",
+            "creator","creationTime","modifier","modifiedTime","valid");
 }

+ 1 - 11
src/main/java/com/persagy/proxy/dictionary/service/impl/AbstractAdmDictBaseServiceImpl.java

@@ -44,16 +44,6 @@ import java.util.Set;
 @Slf4j
 public class AbstractAdmDictBaseServiceImpl<T> implements IAdmDictBaseService<T> {
 
-    private static final Set<String> TABLE_INFOS=CollUtil.newHashSet("id","name","localId","localName",
-            "qRCodePic","defaultQRCode","rFID","cADID","bimId","bimTypeId","bimLocation","bimFamilyName",
-            "bimFamilySymbol","equipSerial","modelId","note","introduction","businessFloorNum","officeFloorNum",
-            "shaftSequenceId","outline","buildQRCode","bimIdPre","floorSequenceId","floorSequenceID",
-            "permanentPeopleNum","floorIdentity","depth","width","buildArea","netArea","height","intro",
-            "ratedCoolingP","ratedHeatingP","acType","zoneOrientation","roomFuncType","roomSerial",
-            "projRoomFuncType","ratedLightP","zoneType","tenantType","tenant","elecCap","pollutionDegree",
-            "groupCode","projectId","objType","classCode","grouping","virtualCodes","createApp","updateApp",
-            "creator","creationTime","modifier","modifiedTime","valid");
-
     @Autowired
     private DmpRwdClient rwdClient;
 
@@ -243,7 +233,7 @@ public class AbstractAdmDictBaseServiceImpl<T> implements IAdmDictBaseService<T>
             admVO.setPath(AdmDictConstant.INFOS_EX+admVO.getCode());
             return;
         }
-        if (TABLE_INFOS.contains(admVO.getCode())
+        if (AdmDictConstant.TABLE_INFOS.contains(admVO.getCode())
                 || ((AdmDictConstant.FIRST_BASE_TAG.equals(admVO.getFirstName())
                 || AdmDictConstant.HIS_FIRST_BASE_TAG.equals(admVO.getFirstName())
                 || AdmDictConstant.HIS_FIRST_BASE_TAG_TWO.equals(admVO.getFirstName()))

+ 31 - 0
src/main/java/com/persagy/proxy/object/controller/AdmSpaceController.java

@@ -1,12 +1,15 @@
 package com.persagy.proxy.object.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.ReflectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.basic.utils.JsonNodeUtils;
+import com.persagy.proxy.adm.constant.AdmDictConstant;
 import com.persagy.proxy.adm.request.*;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.ws.rs.QueryParam;
+import java.lang.reflect.Field;
 import java.util.*;
 
 /**
@@ -119,6 +123,33 @@ public class AdmSpaceController {
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmSpace> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         List<AdmSpace> vos = CollUtil.newArrayList(createRequest.getContent());
+        // 特殊处理一下AdmSpace的infos
+        if (CollUtil.isEmpty(vos)){
+            return AdmResponse.success(new ArrayList<>());
+        }
+        Map<String, Field> fieldMap = JsonNodeUtils.getFieldMap(AdmSpace.class);
+        Set<String> fields = fieldMap.keySet();
+        for (AdmSpace space : vos) {
+            Map<String, Object> infos = space.getInfos();
+            if (MapUtil.isEmpty(infos)){
+                continue;
+            }
+            Set<String> mapKeys = infos.keySet();
+            for (String mapKey : mapKeys) {
+                if ((AdmDictConstant.TABLE_INFOS.contains(mapKey)
+                        && !AdmDictConstant.HEIGHT.equals(mapKey))
+                        || AdmDictConstant.PIC.equals(mapKey)){
+                    // 这些信息就算在infos也不更新,
+                    // 和com.persagy.proxy.dictionary.service.impl.AbstractAdmDictBaseServiceImpl.handleObjectInfoPath
+                    // 的判断逻辑保持一致
+                    continue;
+                }
+                if (fields.contains(mapKey)){
+                    // 如果属性值存在
+                    ReflectUtil.setFieldValue(space,fieldMap.get(mapKey),infos.get(mapKey));
+                }
+            }
+        }
         return service.doUpdate(vos);
     }