瀏覽代碼

Merge branch 'develop' of http://39.106.8.246:3003/BDTP/adm-middleware into develop

 Conflicts:
	.gitignore
lijie 3 年之前
父節點
當前提交
e6cdf3d2ff
共有 33 個文件被更改,包括 1063 次插入84 次删除
  1. 15 28
      .gitignore
  2. 6 0
      pom.xml
  3. 20 0
      src/main/java/com/persagy/proxy/adm/constant/AdmCommonConstant.java
  4. 4 4
      src/main/java/com/persagy/proxy/adm/controller/AdmBuildingController.java
  5. 12 14
      src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java
  6. 5 4
      src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java
  7. 7 6
      src/main/java/com/persagy/proxy/adm/controller/AdmFloorController.java
  8. 182 0
      src/main/java/com/persagy/proxy/adm/controller/AdmLocationPointController.java
  9. 0 2
      src/main/java/com/persagy/proxy/adm/controller/AdmProjectController.java
  10. 105 0
      src/main/java/com/persagy/proxy/adm/controller/ReportDownloadController.java
  11. 4 1
      src/main/java/com/persagy/proxy/adm/model/AdmBuilding.java
  12. 1 1
      src/main/java/com/persagy/proxy/adm/model/AdmComponent.java
  13. 27 5
      src/main/java/com/persagy/proxy/adm/model/AdmEquipment.java
  14. 2 1
      src/main/java/com/persagy/proxy/adm/model/AdmFloor.java
  15. 70 0
      src/main/java/com/persagy/proxy/adm/model/AdmLocationPoint.java
  16. 29 0
      src/main/java/com/persagy/proxy/adm/model/AdmPointImage.java
  17. 1 1
      src/main/java/com/persagy/proxy/adm/model/AdmProperty.java
  18. 49 0
      src/main/java/com/persagy/proxy/adm/service/IAdmComAndEquipService.java
  19. 11 0
      src/main/java/com/persagy/proxy/adm/service/IAdmComponentService.java
  20. 33 0
      src/main/java/com/persagy/proxy/adm/service/IAdmEquipmentService.java
  21. 13 0
      src/main/java/com/persagy/proxy/adm/service/IAdmFloorService.java
  22. 13 0
      src/main/java/com/persagy/proxy/adm/service/IAdmLocationPointService.java
  23. 55 1
      src/main/java/com/persagy/proxy/adm/service/impl/AdmComponentServiceImpl.java
  24. 272 1
      src/main/java/com/persagy/proxy/adm/service/impl/AdmEquipmentServiceImpl.java
  25. 49 1
      src/main/java/com/persagy/proxy/adm/service/impl/AdmFloorServiceImpl.java
  26. 16 0
      src/main/java/com/persagy/proxy/adm/service/impl/AdmLocationPointServiceImpl.java
  27. 13 7
      src/main/java/com/persagy/proxy/adm/service/impl/AdmModelKeyServiceImpl.java
  28. 1 1
      src/main/java/com/persagy/proxy/adm/utils/AdmEntityTransferUtil.java
  29. 39 0
      src/main/java/com/persagy/proxy/adm/utils/ObjectNameUtil.java
  30. 8 0
      src/main/java/com/persagy/proxy/common/client/DmpRwdClient.java
  31. 1 6
      src/main/resources/bootstrap.yml
  32. 二進制
      src/main/resources/template/equip_template.xlsx
  33. 二進制
      src/main/resources/template/relation-template.xlsx

+ 15 - 28
.gitignore

@@ -1,5 +1,8 @@
+HELP.md
 target/
 !.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
 
 ### STS ###
 .apt_generated
@@ -8,40 +11,24 @@ target/
 .project
 .settings
 .springBeans
-.gitignore
->.gitignore
-.DS_Store
+.sts4-cache
 
 ### IntelliJ IDEA ###
-.idea/
+.idea
 *.iws
 *.iml
 *.ipr
 
 ### NetBeans ###
-nbproject/private/
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
 build/
-nbbuild/
-dist/
-nbdist/
-.nb-gradle/
-mvnw.cmd
-mvnw
-.mvn/
+!**/src/main/**/build/
+!**/src/test/**/build/
 
-### JRebel ###
-rebel.xml
-rebel-remote.xml
-
-### Sonar ###
-.scannerwork
-
-### Windows ###
-Thumbs.db
-ehthumbs.db
-Desktop.ini
-
-### Others ###
-*.log
-*/log
-LOG_PATH_IS_UNDEFINED/
+### VS Code ###
+.vscode/
+/logs/

+ 6 - 0
pom.xml

@@ -41,6 +41,7 @@
 	</repositories>
 	<properties>
 		<java.version>1.8</java.version>
+		<easyexcel.version>2.2.8</easyexcel.version>
 	</properties>
 	<dependencies>
 		<!-- 配置中心(包含注册中心) -->
@@ -65,5 +66,10 @@
 			<artifactId>jsr311-api</artifactId>
 			<version>1.1.1</version>
 		</dependency>
+		<dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>${easyexcel.version}</version>
+        </dependency>
     </dependencies>
 </project>

+ 20 - 0
src/main/java/com/persagy/proxy/adm/constant/AdmCommonConstant.java

@@ -6,6 +6,26 @@ package com.persagy.proxy.adm.constant;
  * @date 2021-08-16
  */
 public interface AdmCommonConstant {
+	
+	/** 项目根路径*/
+	String SERVER_ROOT_PATH = System.getProperty("user.dir");
+	
     /** appId */
     String APP_ID = "ADM";
+    
+    /** 集团编码 header key*/
+    String GROUP_CODE_HEADER = "groupCode";
+
+    /** 项目ID header key*/
+    String PROJECT_ID_HEADER = "projectId";
+    
+    /** appID header key*/
+    String APP_ID_HEADER = "appId";
+    
+    /** userID header key*/
+    String USER_ID_HEADER = "userId";
+    
+    /** excel文件后缀*/
+    String EXCEL_SUFFIX_XLSX = ".xlsx";
+    
 }

+ 4 - 4
src/main/java/com/persagy/proxy/adm/controller/AdmBuildingController.java

@@ -77,15 +77,15 @@ public class AdmBuildingController {
 
     /**
      * 更新
-     * @param request
+     * @param createRequest
      * @return
      * @throws Exception
      */
     @PostMapping("/update")
-    public AdmResponse update(@RequestBody AdmQueryCriteria request) throws Exception {
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmBuilding> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, null, AdmCommonConstant.APP_ID);
-        List<AdmBuilding> vos = CollUtil.newArrayList();
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<AdmBuilding> vos = CollUtil.newArrayList(createRequest.getContent());
         vos = service.doUpdate(context, AdmBuilding.class, vos);
         return AdmResponse.success(vos);
     }

+ 12 - 14
src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java

@@ -1,14 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmComponent;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
-import com.persagy.proxy.adm.service.IAdmEquipmentService;
-import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.adm.service.IAdmComponentService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -30,7 +28,7 @@ import java.util.List;
 @RequestMapping("/object/component")
 public class AdmComponentController {
     @Autowired
-    private IAdmEquipmentService service;
+    private IAdmComponentService service;
     @Value("${middleware.group.code}")
     private String groupCode;
 
@@ -48,7 +46,7 @@ public class AdmComponentController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("component");
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmEquipment.class);
+        return service.doQuery(context, request, AdmComponent.class);
     }
     /**
      * 创建
@@ -57,11 +55,11 @@ public class AdmComponentController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmComponent> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsert(context, AdmEquipment.class, vos);
+        List<AdmComponent> vos = CollUtil.newArrayList(createRequest.getContent());
+        vos = service.doInsertExt(context, AdmComponent.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -72,7 +70,7 @@ public class AdmComponentController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmEquipment> vos) throws Exception {
+    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmComponent> vos) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         service.doDelete(context, vos);
@@ -86,11 +84,11 @@ public class AdmComponentController {
      * @throws Exception
      */
     @PostMapping("/update")
-    public AdmResponse update(@RequestBody AdmCreateRequest<AdmEquipment> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmComponent> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmEquipment.class, vos);
+        List<AdmComponent> vos = CollUtil.newArrayList(createRequest.getContent());
+        vos = service.doUpdate(context, AdmComponent.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -107,6 +105,6 @@ public class AdmComponentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("component");
-        return service.doQuery(context, request, AdmEquipment.class);
+        return service.doQuery(context, request, AdmComponent.class);
     }
 }

+ 5 - 4
src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java

@@ -1,7 +1,7 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import cn.hutool.core.util.StrUtil;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmEquipment;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
@@ -58,7 +58,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsert(context, AdmEquipment.class, vos);
+        vos = service.doInsertEuip(context, AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -88,6 +88,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
+        //vos = service.doUpdateEuip(context, AdmEquipment.class, vos);
         vos = service.doUpdate(context, AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
@@ -152,7 +153,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         //request.setName("equipment");
-        if(StringUtils.isNotEmpty(request.getFilters())){
+        if(StrUtil.isNotEmpty(request.getFilters())){
             request.setFilters(String.join(";",request.getFilters(),"objType in ['equipment','component']"));
         }else{
             request.setFilters("objType in ['equipment','component']");
@@ -171,7 +172,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
-        vos = service.doInsert(context, AdmEquipment.class, vos);
+        vos = service.doInsertExt(context, AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 

+ 7 - 6
src/main/java/com/persagy/proxy/adm/controller/AdmFloorController.java

@@ -42,8 +42,8 @@ public class AdmFloorController {
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmFloor> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        List<AdmFloor> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsert(context, AdmFloor.class, vos);
+        //List<AdmFloor> vos = CollUtil.newArrayList(createRequest.getContent());
+        List<AdmFloor> vos = service.doInsert(context, AdmFloor.class, createRequest.getContent());
         return AdmResponse.success(vos);
     }
 
@@ -92,6 +92,7 @@ public class AdmFloorController {
 
     /**
      * 更新 outline
+     * TODO 暂时不知道具体的参数,先做所有字段的更新,之后有具体场景再做细化
      * @param admFloor
      * @return
      * @throws Exception
@@ -99,9 +100,9 @@ public class AdmFloorController {
     @PostMapping("/update-outline")
     public AdmResponse updateOutline(@RequestBody AdmCreateRequest<AdmFloor> admFloor, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, null, AdmCommonConstant.APP_ID);
-        List<AdmFloor> vos = CollUtil.newArrayList();
-        vos = service.doUpdate(context, AdmFloor.class, vos);
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<AdmFloor> vos = CollUtil.newArrayList(admFloor.getContent());
+        vos = service.doUpdateOutLine(context, AdmFloor.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -136,7 +137,7 @@ public class AdmFloorController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("floor");
-        return service.doQuery(context, request, AdmFloor.class);
+        return service.doQueryOutLine(context, request, AdmFloor.class);
     }
 
 }

+ 182 - 0
src/main/java/com/persagy/proxy/adm/controller/AdmLocationPointController.java

@@ -0,0 +1,182 @@
+package com.persagy.proxy.adm.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.model.AdmLocationPoint;
+
+import com.persagy.proxy.adm.model.AdmPointImage;
+import com.persagy.proxy.adm.request.AdmCreateRequest;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmLocationPointService;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.ws.rs.QueryParam;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName AdmLocationPointController
+ * @Description: 点位标签
+ * @Author linhuili
+ * @Date 2021/8/31 09:44
+ * @Version V1.0
+ **/
+@RestController
+@RequestMapping("/object/location-point")
+@Slf4j
+public class AdmLocationPointController {
+
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    @Autowired
+    private IAdmLocationPointService service;
+
+    /**
+     * 统计点位标签
+     * @param projectId
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/count")
+    public AdmResponse count(@QueryParam("projectId") String projectId,
+                             @RequestBody AdmQueryCriteria request) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        request.setName("point");
+        request.setOnlyCount(true);
+        return service.doQuery(context, request, AdmLocationPoint.class);
+    }
+
+    /**
+     * 查询信息点标签
+     * @param projectId
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/query")
+    public AdmResponse query(@QueryParam("projectId") String projectId,
+                             @RequestBody AdmQueryCriteria request) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        request.setName("point");
+        // 查询信息点标签
+        AdmResponse admResponse = service.doQuery(context, request, AdmLocationPoint.class);
+        // 查询结果处理
+        handleQueryLocationPointResult(admResponse);
+        return  admResponse;
+    }
+
+    /**
+     * 创建点位标签信息
+     * @param createRequest
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/create")
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmLocationPoint> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<AdmLocationPoint> vos = CollUtil.newArrayList(createRequest.getContent());
+        log.info("创建条件"+vos.toString());
+        vos = service.doInsert(context, AdmLocationPoint.class, vos);
+        return AdmResponse.success(vos);
+    }
+
+
+    /**
+     * 更新点位标签信息
+     * @param createRequest
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/update")
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmLocationPoint> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<AdmLocationPoint> vos = CollUtil.newArrayList(createRequest.getContent());
+        vos = service.doUpdate(context, AdmLocationPoint.class, vos);
+        return AdmResponse.success(vos);
+    }
+
+
+    /**
+     * 删除点位标签
+     * @param vos
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/delete")
+    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmLocationPoint> vos) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        service.doDelete(context, vos);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 删除点位图片
+     * @param vos
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/delete-image")
+    public AdmResponse deleteImage(@QueryParam("projectId") String projectId, @RequestBody List<AdmPointImage> vos) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        // 删除图片参数转换
+        List<AdmLocationPoint> points = deleteImageParamRevert(vos);
+        service.doUpdate(context,AdmLocationPoint.class, points);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 删除图片参数转换
+     * @param vos
+     * @return
+     */
+    private List<AdmLocationPoint> deleteImageParamRevert(List<AdmPointImage> vos){
+        if(CollUtil.isEmpty(vos)){
+            return new ArrayList<>();
+        }
+        ArrayList<AdmLocationPoint> points = new ArrayList<>();
+        for (AdmPointImage vo : vos) {
+            AdmLocationPoint point = new AdmLocationPoint();
+            point.setId(vo.getObjectId());
+            point.setImageList(new ArrayList<>());
+            points.add(point);
+        }
+        return points;
+    }
+
+    /**
+     * 查询标签信息结果处理
+     * @param admResponse
+     */
+    private void handleQueryLocationPointResult(AdmResponse admResponse){
+        if(!DmpResult.SUCCESS.equals(admResponse.getResult())){
+            return;
+        }
+        List<AdmLocationPoint> points = (List<AdmLocationPoint>) admResponse.getContent();
+        for (AdmLocationPoint point : points) {
+            ArrayList<AdmPointImage> imageList = point.getImageList();
+            if(CollUtil.isEmpty(imageList)){
+                continue;
+            }
+            imageList.forEach(item->{
+                item.setObjectId(point.getId());
+            });
+        }
+    }
+}

+ 0 - 2
src/main/java/com/persagy/proxy/adm/controller/AdmProjectController.java

@@ -1,12 +1,10 @@
 package com.persagy.proxy.adm.controller;
 
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmProject;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmProjectService;
-import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;

+ 105 - 0
src/main/java/com/persagy/proxy/adm/controller/ReportDownloadController.java

@@ -0,0 +1,105 @@
+package com.persagy.proxy.adm.controller;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.util.ResourceUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 报表/模板下载
+ * 
+ * @version 1.0.0
+ * @company persagy
+ * @author zhangqiankun
+ * @date 2021年8月30日 下午7:41:56
+ */
+@Slf4j
+@RestController
+public class ReportDownloadController {
+
+	/**
+	 * 下载报告-设备静态信息维护模板
+	 * 
+	 * @param request
+	 * @param response
+	 */
+	@RequestMapping("/graphic/downloads/equip/template")
+	public void downloadEquipTemplate(HttpServletRequest request, HttpServletResponse response) {
+		ExcelWriter excelWriter = null;
+		try {
+			response.setContentType("application/vnd.ms-excel");
+			String encode = StandardCharsets.UTF_8.name();
+			response.setCharacterEncoding(encode);
+			// 防止中文乱码
+			String fileName = URLEncoder.encode("台账信息导入模板", encode);
+			response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+			
+			File file = null;
+			try {
+				file = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX + "template/equip_template.xlsx");
+			} catch (FileNotFoundException e) {
+			}
+			if (file == null || !file.exists()) {
+				file = ResourceUtils.getFile(AdmCommonConstant.SERVER_ROOT_PATH + "/template/equip_template.xlsx");
+			}
+			
+			excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(file).build();
+		} catch (Exception e) {
+			log.error("设备静态信息维护模板下载失败", e);
+		} finally {
+			if (excelWriter != null) {
+				excelWriter.finish();
+			}
+		}
+	}
+
+	/**
+	 * 下载报告-点表
+	 * 
+	 * @param request
+	 * @param response
+	 */
+	@RequestMapping("/graphic/downloads/point")
+	public void downloadPoint(@RequestParam(required = false) String key, HttpServletRequest request, HttpServletResponse response) {
+		ExcelWriter excelWriter = null;
+		try {
+			response.setContentType("application/vnd.ms-excel");
+			String encode = StandardCharsets.UTF_8.name();
+			response.setCharacterEncoding(encode);
+			response.setHeader("Content-disposition", "attachment;filename=" + key);
+			
+			File file = null;
+			try {
+				file = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX + "template/upload/" + key);
+			} catch (FileNotFoundException e) {
+				file = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX + "template/relation-template.xlsx");
+			}
+			if (file == null || !file.exists()) {
+				file = ResourceUtils.getFile(AdmCommonConstant.SERVER_ROOT_PATH + "/template/relation-template.xlsx");
+			}
+			
+			excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(file).build();
+		} catch (Exception e) {
+			log.error("设备静态信息维护模板下载失败", e);
+		} finally {
+			if (excelWriter != null) {
+				excelWriter.finish();
+			}
+		}
+	}
+
+}

+ 4 - 1
src/main/java/com/persagy/proxy/adm/model/AdmBuilding.java

@@ -44,5 +44,8 @@ public class AdmBuilding {
     private AdmProject project;
     /** 级联-楼层 */
     @CascadeColumn(graphCode = "ArchSubset", relCode = "Bd2Fl")
-    private List<AdmProject> floor;
+    private List<AdmFloor> floor;
+
+    /** 建筑类型code */
+    private String classCode = "building";
 }

+ 1 - 1
src/main/java/com/persagy/proxy/adm/model/AdmComponent.java

@@ -88,7 +88,7 @@ public class AdmComponent {
         /** 最后更新日期 */
         private Date lastUpdate;
         /** 对象类型 */
-        private String objectType = "equipment";
+        private String objectType = "component";
 
         /** 信息点 */
         private Map<String, Object> infos;

+ 27 - 5
src/main/java/com/persagy/proxy/adm/model/AdmEquipment.java

@@ -50,6 +50,27 @@ public class AdmEquipment {
     /** 设备关联的资产id */
     private String propertyId;
 
+    /** 参见 EquipmentProSy **/
+    /** 品牌型号id */
+    private String dpManufacturerId;
+
+    /** 供应商信息id */
+    private String dpSupplierId;
+
+    /** 维修商信息id */
+    private String dpMaintainerId;
+
+    /** 保险公司信息id */
+    private String dpInsurerId;
+
+    /** 设备型号id */
+    private String dpSpecificationId;
+
+    /** 品牌id */
+    private String dpBrandId;
+    
+    
+
     /** Revit族 */
     private String bimFamilyName;
     /** Revit族类型 */
@@ -95,8 +116,9 @@ public class AdmEquipment {
     private Map<String, Object> infos;
     /** 统计信息 */
     private Map<String, Object> statistics;
-    /** 资产信息实体类 */
-    @CascadeColumn
+
+    /** 资产信息实体类   资产对应设备设施关系 资产→设备设施*/
+    @CascadeColumn(graphCode = "Property2Mech", relCode = "Pe2Eq", selectToObj = false)
     private AdmProperty property;
     /** 建筑信息实体类 */
     @CascadeColumn(graphCode = "MechForArch", relCode = "Eq2Bd")
@@ -119,10 +141,10 @@ public class AdmEquipment {
     @CascadeColumn(graphCode = "MechInArch", relCode = "Eq2Sh")
     private List<AdmShaft> shaftList;
     /** 资产列表 */
-    @CascadeColumn
+    @CascadeColumn(graphCode = "Property2Mech", relCode = "Pe2Eq", selectToObj = false)
     private List<AdmProperty> propertyList;
     /** 级联-部件 */
-    @CascadeColumn
-    private List<AdmEquipment> component;
+    @CascadeColumn(graphCode = "MechSubset", relCode = "Eq2Ec")
+    private List<AdmComponent> component;
 
 }

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

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.model;
 
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 
@@ -57,7 +58,7 @@ public class AdmFloor {
     private String modelId;
 
     /** 楼层选定区域轮廓线 */
-    private List<AdmPointPosition> outline;
+    private List<ObjectNode> outline;
 
     /** 数量 */
     private String count;

+ 70 - 0
src/main/java/com/persagy/proxy/adm/model/AdmLocationPoint.java

@@ -0,0 +1,70 @@
+package com.persagy.proxy.adm.model;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+
+/**
+ * @ClassName AdmLocationPoint
+ * @Description: ADM点位坐标实体类
+ * @Author linhuili
+ * @Date 2021/8/31 09:44
+ * @Version V1.0
+ **/
+@Data
+public class AdmLocationPoint {
+
+    /** 点位标签ID */
+    private String id;
+
+    /** 名称 */
+    private String name;
+
+    /** 本地编码 */
+    private String localId;
+
+    /** 本地名称 */
+    private String localName;
+
+    /** 项目ID */
+    private String projectId;
+
+    /** 建筑ID */
+    private String buildId;
+
+    /** 楼层ID */
+    private String floorId;
+
+    /** 空间id */
+    private String spaceId;
+
+    /** BimId编码 */
+    private String bimId;
+
+    /** beaconID */
+    private String beaconId;
+
+    /** 位置 */
+    private String position;
+
+    /** 信息类型 */
+    private String type;
+
+    /** X坐标 */
+    private String x;
+
+    /** Y坐标 */
+    private String y;
+
+    /** 备注 */
+    private String note;
+
+    /** 图片信息 */
+    private ArrayList<AdmPointImage> imageList;
+
+    /** 类型编码,默认:LocationPoint */
+    private String classCode="LocationPoint";
+
+    /** 对象类型,默认:point */
+    private String objType="point";
+}

+ 29 - 0
src/main/java/com/persagy/proxy/adm/model/AdmPointImage.java

@@ -0,0 +1,29 @@
+package com.persagy.proxy.adm.model;
+
+import lombok.Data;
+
+/**
+ * @ClassName AdmLocationPoint
+ * @Description: ADM点位图片
+ * @Author linhuili
+ * @Date 2021/8/31 09:44
+ * @Version V1.0
+ **/
+@Data
+public class AdmPointImage {
+
+    /** 图片 id */
+    private String id;
+
+    /** 图片 key */
+   private String key;
+
+    /** 图片类型 */
+    private String type;
+
+    /** 图片名称 */
+    private String name;
+
+    /** 对象id */
+    private String objectId;
+}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/model/AdmProperty.java

@@ -54,7 +54,7 @@ public class AdmProperty {
     /** 信息点 */
     private Map<String, Object> infos;
     /** 对象类型 */
-    private String objectType = "equipment";
+    private String objectType = "property";
     /** 位置信息 */
     private String position;
     /** 贴码状态 */

+ 49 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmComAndEquipService.java

@@ -0,0 +1,49 @@
+package com.persagy.proxy.adm.service;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+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.define.entity.ObjectTypeDefine;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author lvxy
+ * @date 2021/9/2
+ */
+
+public interface IAdmComAndEquipService {
+    default QueryCriteria getDmpCriteria(InstanceUrlParam context, Set<String> classCodes, String objType){
+        QueryCriteria criteriaObject = new QueryCriteria();
+        ObjectNode criteriaEq = JsonNodeFactory.instance.objectNode();
+
+        ArrayNode array = criteriaEq.putObject("code").putArray("$in");
+        classCodes.forEach(code -> array.add(code));
+
+        criteriaEq.put("objType", objType);
+        criteriaObject.setCriteria(criteriaEq);
+        criteriaObject.setSize(classCodes.size() * 1L);
+        criteriaObject.setPage(1L);
+        criteriaObject.setWithoutCount(true);
+        return criteriaObject;
+    }
+
+    default Map<String, ObjectTypeDefine> getDefineMap(DmpResult<JSONArray> resultDef){
+        Map<String, ObjectTypeDefine> defClassMap = new HashMap<String, ObjectTypeDefine>();
+        if(resultDef.getResult().equals(DmpResult.SUCCESS)){
+            JSONArray defArr = resultDef.getData();
+            List<ObjectTypeDefine> defineList = JSONUtil.toList(defArr.toString(), ObjectTypeDefine.class);
+            defClassMap = CollUtil.fieldValueMap(defineList, "code");
+        }
+        return defClassMap;
+    }
+}

+ 11 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmComponentService.java

@@ -1,6 +1,9 @@
 package com.persagy.proxy.adm.service;
 
 import com.persagy.proxy.adm.model.AdmComponent;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+import java.util.List;
 
 /**
  * ADM 组件 接口
@@ -8,4 +11,12 @@ import com.persagy.proxy.adm.model.AdmComponent;
  * @date 2021/8/19
  */
 public interface IAdmComponentService extends IAdmBaseService<AdmComponent>{
+    /**
+     * 新增
+     * @param context
+     * @param clazz
+     * @param voList
+     * @return
+     */
+    List<AdmComponent> doInsertExt(InstanceUrlParam context, Class<AdmComponent> clazz, List<AdmComponent> voList);
 }

+ 33 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmEquipmentService.java

@@ -1,6 +1,9 @@
 package com.persagy.proxy.adm.service;
 
 import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+import java.util.List;
 
 /**
  * ADM 设备接口
@@ -8,4 +11,34 @@ import com.persagy.proxy.adm.model.AdmEquipment;
  * @date 2021/8/18
  */
 public interface IAdmEquipmentService extends IAdmBaseService<AdmEquipment>{
+
+    /**
+     * 新增
+     * @param context
+     * @param clazz
+     * @param voList
+     * @return
+     */
+    List<AdmEquipment> doInsertEuip(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList);
+
+    /**
+     * 修改 资产现在前端隐藏
+     * @param context
+     * @param clazz
+     * @param voList
+     * @return
+     */
+    @Deprecated
+    List<AdmEquipment> doUpdateEuip(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList);
+
+    /**
+     * 删除 资产现在前端隐藏
+     * @param context
+     * @param voList
+     * @return
+     */
+    @Deprecated
+    void doDeleteEuip(InstanceUrlParam context, List<AdmEquipment> voList);
+    @Deprecated
+    public List<AdmEquipment> doInsertExt(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList);
 }

+ 13 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmFloorService.java

@@ -1,6 +1,11 @@
 package com.persagy.proxy.adm.service;
 
 import com.persagy.proxy.adm.model.AdmFloor;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+import java.util.List;
 
 /**
  * ADM 楼层 接口类
@@ -8,4 +13,12 @@ import com.persagy.proxy.adm.model.AdmFloor;
  * @date 2021/8/16
  */
 public interface IAdmFloorService extends IAdmBaseService<AdmFloor>{
+
+    public List<AdmFloor> doUpdateOutLine(InstanceUrlParam context, Class<AdmFloor> clazz, List<AdmFloor> voList);
+    /**
+     * 查询outLine
+     * @param request
+     * @return
+     */
+    AdmResponse doQueryOutLine(InstanceUrlParam context, AdmQueryCriteria request, Class<AdmFloor> clazz);
 }

+ 13 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmLocationPointService.java

@@ -0,0 +1,13 @@
+package com.persagy.proxy.adm.service;
+
+import com.persagy.proxy.adm.model.AdmLocationPoint;
+
+/**
+ * @ClassName IAdmLocationPointService
+ * @Description: 点位标签
+ * @Author linhuili
+ * @Date 2021/8/30 16:07
+ * @Version V1.0
+ **/
+public interface IAdmLocationPointService extends IAdmBaseService<AdmLocationPoint>{
+}

+ 55 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AdmComponentServiceImpl.java

@@ -1,14 +1,68 @@
 package com.persagy.proxy.adm.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.proxy.adm.model.AdmComponent;
+import com.persagy.proxy.adm.service.IAdmComAndEquipService;
 import com.persagy.proxy.adm.service.IAdmComponentService;
+import com.persagy.proxy.adm.utils.ObjectNameUtil;
+import com.persagy.proxy.common.client.DmpRwdClient;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 /**
  * ADM 组件 服务
  * @author lvxy
  * @date 2021/8/19
  */
 @Service
-public class AdmComponentServiceImpl extends AbstractAdmBaseServiceImpl<AdmComponent> implements IAdmComponentService {
+public class AdmComponentServiceImpl extends AbstractAdmBaseServiceImpl<AdmComponent> implements IAdmComponentService, IAdmComAndEquipService {
+
+    @Autowired
+    private DmpRwdClient rwdClient;
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public List<AdmComponent> doInsertExt(InstanceUrlParam context, Class<AdmComponent> clazz, List<AdmComponent> voList) {
+        if(CollUtil.isEmpty(voList)) {
+            return null;
+        }
+        Set<String> classCodes = voList.stream().map(AdmComponent::getClassCode).collect(Collectors.toSet());
+        //查询定义类型
+        QueryCriteria criteriaObject = getDmpCriteria(context, classCodes, "component");
+        JSONObject paraPe = null;
+        try {
+            String paraStr = objectMapper.writeValueAsString(criteriaObject);
+            paraPe = JSONObject.parseObject(paraStr);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException("转换查询条件出错:" + e.getMessage());
+        }
+        DmpResult<JSONArray> resultDef = rwdClient.queryDefClass(context, paraPe);
+        Map<String, ObjectTypeDefine> finalDefClassMap = getDefineMap(resultDef);
+        // 设备名字处理
+        voList.forEach(component -> {
+            if (StrUtil.isNotEmpty(component.getName()) && CollUtil.isNotEmpty(finalDefClassMap) && finalDefClassMap.containsKey(component.getClassCode())) {
+                ObjectTypeDefine defclass = finalDefClassMap.get(component.getClassCode());
+                component.setName(ObjectNameUtil.objectName(defclass.getName()+"-"));
+            }else{
+                component.setName(ObjectNameUtil.objectName("部件-"));
+            }
+        });
+        return doInsert(context, clazz, voList);
+    }
+
 }

+ 272 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AdmEquipmentServiceImpl.java

@@ -1,14 +1,285 @@
 package com.persagy.proxy.adm.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+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.common.model.entity.BaseEntity;
+import com.persagy.dmp.define.entity.ObjectTypeDefine;
+import com.persagy.dmp.digital.client.DigitalRelationFacade;
+import com.persagy.dmp.digital.entity.ObjectRelation;
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmProperty;
+import com.persagy.proxy.adm.service.IAdmComAndEquipService;
 import com.persagy.proxy.adm.service.IAdmEquipmentService;
+import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
+import com.persagy.proxy.adm.utils.ObjectNameUtil;
+import com.persagy.proxy.common.client.DmpRwdClient;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.common.entity.ObjRelationDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 /**
  * ADM 设备 实现
  * @author lvxy
  * @date 2021/8/18
  */
+@Slf4j
 @Service
-public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquipment> implements IAdmEquipmentService {
+public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquipment> implements IAdmEquipmentService, IAdmComAndEquipService {
+
+    @Autowired
+    private DmpRwdClient rwdClient;
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public List<AdmEquipment> doInsertEuip(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList) {
+        if(CollUtil.isEmpty(voList)) {
+            return null;
+        }
+        Set<String> classCodes = voList.stream().map(AdmEquipment::getClassCode).collect(Collectors.toSet());
+        //查询定义类型
+        QueryCriteria criteriaObject = getDmpCriteria(context, classCodes, "equipment");
+        JSONObject paraPe = null;
+        try {
+            String paraStr = objectMapper.writeValueAsString(criteriaObject);
+            paraPe = JSONObject.parseObject(paraStr);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException("转换查询条件出错:" + e.getMessage());
+        }
+        DmpResult<JSONArray> resultDef = rwdClient.queryDefClass(context, paraPe);
+        Map<String, ObjectTypeDefine> finalDefClassMap = getDefineMap(resultDef);
+        // 设备名字处理
+        voList.forEach(equip -> {
+            if (StrUtil.isNotEmpty(equip.getName())) {
+                if(CollUtil.isNotEmpty(finalDefClassMap) && finalDefClassMap.containsKey(equip.getClassCode())){
+                    ObjectTypeDefine defclass = finalDefClassMap.get(equip.getClassCode());
+                    equip.setName(ObjectNameUtil.objectName(defclass.getName()+"-"));
+                }else{
+                    equip.setName(ObjectNameUtil.objectName("设备-"));
+                }
+            }
+        });
+        return doInsert(context, clazz, voList);
+    }
+
+    @Override
+    public List<AdmEquipment> doUpdateEuip(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList) {
+        //TODO 处理关系标记
+        /*try {
+         *//** 处理关系标记 *//*
+            val listtype = ArrayList<String>()
+            listtype.add("pe2bd")
+            listtype.add("pe2fl")
+            listtype.add("pe2sh")
+            listtype.add("pe2sp")
+            for (type in listtype){
+                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("relationType", type)).entity()
+                if (entity!=null){
+                    entity.computationalState = 2
+                    relationTypeProjectservice.update(entity)
+                }
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }*/
+        Map<String, AdmEquipment> voMap = CollUtil.fieldValueMap(voList, BaseEntity.PROP_ID);
+        //查询设备对应的资产 关系 Pe2Eq (1:N,一个资产关联多个设备,设备是最小单位 by:lvxianyun)
+        DmpResult<List<ObjRelationDTO>> relationRes = queryRelation(context, voMap);
+        boolean isDealDataSucc = false;
+        //不是绑定关系,清理绑定关系,重新绑定
+        if(CollUtil.isNotEmpty(relationRes.getData())){
+            isDealDataSucc = updateRelation2Pe(context, relationRes, voMap);
+        }else {
+            //不存在关系,需要新绑定关系,更新per,插入关系
+            isDealDataSucc = insertRelation2Pe(context, voList, voMap);
+        }
+        return isDealDataSucc ? doUpdate(context, clazz, voList) : null;
+    }
+
+    @Override
+    public void doDeleteEuip(InstanceUrlParam context, List<AdmEquipment> voList) {
+        Map<String, AdmEquipment> voMap = CollUtil.fieldValueMap(voList, BaseEntity.PROP_ID);
+        DmpResult<List<ObjRelationDTO>> relationRes = queryRelation(context, voMap);
+        //清理绑定关系
+        if(CollUtil.isNotEmpty(relationRes.getData())){
+            updateRelation2Pe(context, relationRes, voMap);
+        }
+        doDelete(context,voList);
+    }
+
+    @Override
+    public List<AdmEquipment> doInsertExt(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList) {
+
+        //创建设备
+        List<AdmEquipment> vos = doInsert(context, AdmEquipment.class, voList);
+        //创建资产
+        //创建设备和系统关系 systemList
+        return null;
+    }
+
+
+
+
+    private DmpResult<List<ObjRelationDTO>> queryRelation(InstanceUrlParam context, Map<String, AdmEquipment> voMap){
+        QueryCriteria dmpRequest = new QueryCriteria();
+        ObjectNode criteria = JsonNodeFactory.instance.objectNode();
+        ArrayNode array = criteria.putObject("objTo").putArray("$in");
+        voMap.keySet().forEach(equipId -> array.add(equipId));
+        criteria.put("relCode", "Pe2Eq");
+        criteria.put("graphCode", "Property2Mech");
+        dmpRequest.setCriteria(criteria);
+        dmpRequest.setSize(voMap.size() * 1L);
+        dmpRequest.setPage(1L);
+        dmpRequest.setWithoutCount(true);
+        // 转换参数
+        JSONObject paraRel = null;
+        try {
+            String paraStr = objectMapper.writeValueAsString(dmpRequest);
+            paraRel = JSONObject.parseObject(paraStr);
+        } catch (JsonProcessingException e) {
+            log.error(e.getMessage(), e);
+            return null;
+        }
+        return rwdClient.queryRelation(context, dmpRequest);
+    }
+
+    private DmpResult<JSONArray> queryObject(InstanceUrlParam context, Map<String, AdmEquipment> peMap){
+        QueryCriteria criteriaObject = new QueryCriteria();
+        ObjectNode criteriaPe = JsonNodeFactory.instance.objectNode();
+        ArrayNode array = criteriaPe.putObject("id").putArray("$in");
+        peMap.keySet().forEach(equipId -> array.add(equipId));
+        criteriaPe.put("classCode", "property");
+        criteriaPe.put("objType", "property");
+        criteriaObject.setCriteria(criteriaPe);
+        criteriaObject.setSize(peMap.size() * 1L);
+        criteriaObject.setPage(1L);
+        criteriaObject.setWithoutCount(true);
+        // 转换参数
+        JSONObject paraPe = null;
+        try {
+            String paraStr = objectMapper.writeValueAsString(criteriaObject);
+            paraPe = JSONObject.parseObject(paraStr);
+        } catch (JsonProcessingException e) {
+            log.error(e.getMessage(), e);
+            return null;
+        }
+        return rwdClient.queryObject(context, paraPe);
+    }
+
+    private AdmProperty createPropertyObj(String id, String equipId, Boolean isBimIdNull){
+        AdmProperty admProperty = new AdmProperty();
+        admProperty.setId(id);
+        admProperty.setEquipId(equipId);
+        if(isBimIdNull){
+            admProperty.setBimId(null);
+        }
+        return admProperty;
+    }
+
+    private ObjectNode creatRelationObj(String objTo,String objFrom){
+        ObjectNode relationNew = JsonNodeFactory.instance.objectNode();
+        relationNew.put("relCode", "Pe2Eq");
+        relationNew.put("graphCode", "Property2Mech");
+        relationNew.put("graphCode", "Property2Mech001");
+        relationNew.put("objTo", objTo);
+        relationNew.put("objFrom", objFrom);
+        return relationNew;
+    }
+
+
+    /**
+     * 更新设备关联的资产(资产中的equipId 信息点) 以及设备资产关系
+     * @return
+     */
+    private Boolean updateRelation2Pe(InstanceUrlParam context, DmpResult<List<ObjRelationDTO>> relationRes, Map<String, AdmEquipment> voMap){
+        boolean isDealDataSucc = false;
+        List<AdmProperty> updatePropertyList = new ArrayList<AdmProperty>();
+        List<String> del_relationIds = new ArrayList<>(relationRes.getData().size());
+        Map<String, ObjRelationDTO> relationMap = CollUtil.fieldValueMap(relationRes.getData(), "objTo");
+        relationMap.keySet().forEach(euipId -> {
+            //存在绑定的资产
+            if(voMap.keySet().contains(euipId)){
+                AdmEquipment admEquipment = voMap.get(euipId);
+                ObjRelationDTO relation = relationMap.get(euipId);
+                String propertyId = relation.getObjFrom();
+                if(StrUtil.isNotEmpty(admEquipment.getPropertyId()) && StrUtil.isNotEmpty(propertyId)
+                        && !admEquipment.getPropertyId().equals(propertyId)){
+                    //1 与设备提供的资产绑定
+                    AdmProperty propertyFrom = createPropertyObj(admEquipment.getPropertyId(), euipId, false);
+                    propertyFrom.setId(admEquipment.getPropertyId());
+                    propertyFrom.setEquipId(euipId);
+                    updatePropertyList.add(propertyFrom);
+
+                    //2 从关系中查询出的资产与当前设备解绑
+                    //更新资产中的信息点
+                    AdmProperty property = createPropertyObj(propertyId, null, true);
+                    updatePropertyList.add(property);
+
+                    //更新关系
+                    del_relationIds.add(relation.getId());
+                }
+            }
+        });
+        DigitalRelationFacade.delete(context.getGroupCode(),context.getProjectId(), AdmCommonConstant.APP_ID,null,del_relationIds);
+        DmpResult propertyResult = rwdClient.updateObject(context, JSONArray.parseArray(updatePropertyList.toString()));
+        if(propertyResult.getResult().equals(DmpResult.SUCCESS)){
+            isDealDataSucc = true;
+        }
+        return isDealDataSucc;
+    }
+
+
+    /**
+     * 不存在关系,需要新绑定关系,更新per,插入关系
+     * @param context
+     * @param voList
+     * @param voMap
+     * @return
+     */
+    private Boolean insertRelation2Pe(InstanceUrlParam context, List<AdmEquipment> voList, Map<String, AdmEquipment> voMap){
+        boolean isDealDataSucc = false;
+        Map<String, AdmEquipment> peMap = CollUtil.fieldValueMap(voList, "propertyId");
+        //查询资产
+        DmpResult<JSONArray> resultPe = queryObject(context, peMap);
+        if (CollUtil.isNotEmpty(resultPe.getData())) {
+            //更新资产 创建资产设备关系
+            List<AdmProperty> propertyList = AdmEntityTransferUtil.toAdmMultiEntity(resultPe.getData(), null, AdmProperty.class);
+            List<ObjectNode> objRelationDTONews = new ArrayList<>();
+            propertyList.forEach(property -> {
+                //存在绑定的资产 更新
+                AdmEquipment admEquipment = peMap.get(property.getId());
+                property.setEquipId(admEquipment.getId());
+                //创建新的设备资产关系
+                ObjectNode relationNew = creatRelationObj( admEquipment.getId(), property.getId());
+                objRelationDTONews.add(relationNew);
+            });
+
+            List<ObjectRelation> relationList = DigitalRelationFacade.create(context.getGroupCode(),context.getProjectId(), AdmCommonConstant.APP_ID,null,objRelationDTONews);
+            if(CollUtil.isNotEmpty(relationList)){
+                DmpResult<JSONArray> propertyRes = rwdClient.updateObject(context, JSONArray.parseArray(propertyList.toString()));
+                if(propertyRes.getResult().equals(DmpResult.SUCCESS)){
+                    isDealDataSucc = true;
+                }
+            }
+        }
+        return isDealDataSucc;
+    }
 }

+ 49 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AdmFloorServiceImpl.java

@@ -1,9 +1,15 @@
 package com.persagy.proxy.adm.service.impl;
 
 import com.persagy.proxy.adm.model.AdmFloor;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmFloorService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * ADM 楼层 实现类
  * @author lvxy
@@ -11,4 +17,46 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class AdmFloorServiceImpl extends AbstractAdmBaseServiceImpl<AdmFloor> implements IAdmFloorService {
-}
+    @Override
+    public List<AdmFloor> doUpdateOutLine(InstanceUrlParam context, Class<AdmFloor> clazz, List<AdmFloor> voList) {
+        //根据楼层id 更新中台的floor中infos.outline中的信息,outline中的id默认为空或者省略,查询需要单独处理
+        //更新outLing信息
+        List<AdmFloor> vList = doUpdate(context, clazz, voList);
+        //修改关系计算相关信息
+       /* List<String> listtype = new ArrayList<String>();
+        listtype.add("Sh2Bd");
+        listtype.add("Bd2Sp");
+        listtype.add("Fl2Sp");
+        listtype.add("Sy2Bd");
+        listtype.add("Sy2Fl");
+        listtype.add("Eq2Fl");
+        listtype.add("Pe2Bd");
+        listtype.add("Pe2Fl");
+        for (String type : listtype){
+            JSONObject entity =  EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("relationType", type)).entity()
+            if (entity!=null){
+                entity.computationalState = 2
+                EquipmentService.relationTypeProjectservice.update(entity)
+            }
+        }*/
+        return vList;
+    }
+
+    @Override
+    public AdmResponse doQueryOutLine(InstanceUrlParam context, AdmQueryCriteria request, Class<AdmFloor> clazz) {
+        request.setProjection(null);
+        List<String> list = new ArrayList<>();
+        list.add("id");
+        list.add("name");
+        list.add("localId");
+        list.add("localName");
+        list.add("outline");
+        list.add("floorSequenceId");
+        list.add("modelId");
+        list.add("infos");
+        list.add("properties");
+        request.setProjection(list);
+        return doQuery(context, request, clazz);
+    }
+
+}

+ 16 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AdmLocationPointServiceImpl.java

@@ -0,0 +1,16 @@
+package com.persagy.proxy.adm.service.impl;
+
+import com.persagy.proxy.adm.model.AdmLocationPoint;
+import com.persagy.proxy.adm.service.IAdmLocationPointService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @ClassName AdmLocationPointServiceImpl
+ * @Description: 点位标签实现类
+ * @Author linhuili
+ * @Date 2021/8/31 09:47
+ * @Version V1.0
+ **/
+@Service
+public class AdmLocationPointServiceImpl extends AbstractAdmBaseServiceImpl<AdmLocationPoint> implements IAdmLocationPointService {
+}

+ 13 - 7
src/main/java/com/persagy/proxy/adm/service/impl/AdmModelKeyServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
@@ -66,21 +67,26 @@ public class AdmModelKeyServiceImpl implements IAdmModelKeyService {
             return result;
         }
 
-        //拼接查询条件
+        //拼接中台查询条件
         criteria.remove("floorId");
         criteria.put("objType", "equipment");
-        JSONObject relationFrom = new JSONObject();
+
+        JsonNodeFactory factory = JsonNodeFactory.instance;
+        ObjectNode relationFrom = factory.objectNode();
         relationFrom.put("objTo", objTo);
         relationFrom.put("relCode", "Eq2Fl");
         relationFrom.put("graphCode", "MechInArch");
-        criteria.put("relationFrom", relationFrom.toJSONString());
+        criteria.putPOJO("relationFrom", relationFrom);
+
 
         JSONObject jsonBimId = new JSONObject();
-        jsonBimId.put("$isnull", false);
-        criteria.put("bimId",jsonBimId.toJSONString());
+        jsonBimId.put("$null", false);
+        criteria.putPOJO("bimId",jsonBimId);
 
         dmpRequest.setCriteria(criteria);
-
+        dmpRequest.setSize(1L);
+        dmpRequest.setPage(1L);
+        dmpRequest.setWithoutCount(true);
         // 转换参数
         JSONObject paraEquip = null;
         try {
@@ -92,7 +98,7 @@ public class AdmModelKeyServiceImpl implements IAdmModelKeyService {
         }
         result = rwdClient.queryObject(context, paraEquip);
         //处理成目标对象
-        if(result.getCount() == 1){
+        if(result.getResult().equals(DmpResult.SUCCESS)){
             JSONArray jsonArray = result.getData();
             JSONObject object = result.getData().getJSONObject(0);
             JSONObject model = new JSONObject();

+ 1 - 1
src/main/java/com/persagy/proxy/adm/utils/AdmEntityTransferUtil.java

@@ -89,7 +89,7 @@ public class AdmEntityTransferUtil {
         // 转换属性名 TODO 目前只有创建时间和修改时间需要转换,后续有其他时通过建立映射在此转换即可
         copyProperty(node, "creationTime", "createTime");
         copyProperty(node, "modifiedTime", "lastUpdate");
-        copyProperty(node, "objectType", "objType");
+        copyProperty(node, "objType", "objectType");
         removeProperty(node, projection);
     }
 

+ 39 - 0
src/main/java/com/persagy/proxy/adm/utils/ObjectNameUtil.java

@@ -0,0 +1,39 @@
+package com.persagy.proxy.adm.utils;
+
+import cn.hutool.core.util.RandomUtil;
+
+/**
+ * 根据中心数据规则生成对象名字
+ * 参见 datacenterShaftNameUtil
+ * @author lvxy
+ * @date 2021/8/31
+ */
+public class ObjectNameUtil {
+
+    /**
+     * 竖井名字
+     *
+     * @param   name    名字
+     */
+    public static String objectName(String name){
+        return name + getCode(5);
+    } // Function shaftName()
+
+    /**
+     * 字母和数字组合的随机数
+     *
+     * @param   n   随机数的位数
+     */
+    private static String getCode(int n) {
+        String str = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";//保存数字0-9 和 大小写字母
+        char[] ch = new char[n]; //声明一个字符数组对象ch 保存 验证码
+        for (int i=0 ; i< n; i++) {
+            //创建一个新的随机数生成器
+            int index = RandomUtil.getRandom().nextInt(str.length());//返回[0,string.length)范围的int值    作用:保存下标
+            ch[i] = str.charAt(index);//charAt() : 返回指定索引处的 char 值   ==》保存到字符数组对象ch里面
+        }
+        //将char数组类型转换为String类型保存到result
+        return  String.valueOf(ch);
+    }
+
+}

+ 8 - 0
src/main/java/com/persagy/proxy/common/client/DmpRwdClient.java

@@ -40,6 +40,14 @@ public interface DmpRwdClient {
      */
     @PostMapping(DmpUrlConstant.OBJECT_QUERY)
     DmpResult<JSONArray> queryObject(@SpringQueryMap InstanceUrlParam objectUrlParam, @RequestBody JSONObject criteria);
+    /**
+     * @description: 查询定义类型
+     * @param: objectUrlParam 对象请求url通用参数
+     * @param: criteria post请求参数
+     * @return: com.persagy.dmp.common.DmpResult
+     */
+    @PostMapping(DmpUrlConstant.DEF_CLASS)
+    DmpResult<JSONArray> queryDefClass(@SpringQueryMap InstanceUrlParam objectUrlParam, @RequestBody JSONObject criteria);
 
     /**
      * @description: 创建对象

+ 1 - 6
src/main/resources/bootstrap.yml

@@ -1,11 +1,6 @@
 server:
-  port: 8868
+  port: 8876
 spring:
   application:
     # 应用名称
     name: adm-middleware
-
-config: 
-  file: 
-    absolute: 
-      path: ${CONFIG_FILE_PATH:D:\SpringCloud}

二進制
src/main/resources/template/equip_template.xlsx


二進制
src/main/resources/template/relation-template.xlsx