yanguofeng před 2 roky
rodič
revize
99756c477a
13 změnil soubory, kde provedl 244 přidání a 51 odebrání
  1. 2 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/common/AdmConst.java
  2. 0 1
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/controller/AdmFileController.java
  3. 4 21
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/entity/db/AdmFile.java
  4. 1 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/entity/db/AdmQrCode.java
  5. 9 27
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/SyncAppImpl.java
  6. 17 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/CriteriaUtils.java
  7. 62 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/DownLoadDataDeal.java
  8. 14 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillBuildingDataChain.java
  9. 1 1
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillCad.java
  10. 36 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillFile.java
  11. 57 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillObject.java
  12. 38 0
      adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillQrCode.java
  13. 3 1
      adm-business/adm-server/src/main/resources/db/init/schema.sql

+ 2 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/common/AdmConst.java

@@ -25,6 +25,8 @@ public interface AdmConst {
 
 	String OBJ_TYPE_EQUIPMENT = "equipment";
 
+	String OBJ_TYPE_ISPACE = "ispace";
+
 
 	/** 数据创建者,数据同步服务 */
 	String CREATOR_SYNC = APP_ID + "_sync";

+ 0 - 1
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/controller/AdmFileController.java

@@ -35,7 +35,6 @@ public class AdmFileController {
     /**
      * CAD文件查询接口
      */
-
     @PostMapping("/queryCadFiles")
     public CommonResult<List<AdmCad>> queryCadFiles(@RequestBody CadFileQueryParam queryParam){
         AppContext context = AppContext.getContext();

+ 4 - 21
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/entity/db/AdmFile.java

@@ -1,5 +1,6 @@
 package com.persagy.adm.server.custom.entity.db;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 @Data
@@ -69,29 +70,11 @@ public class AdmFile extends BaseAdmDataEntity{
      */
     private String fileId;
 
+    private String groupCode;
+
 
     @Override
     public String toString() {
-        return "AdmFile{" +
-                "id=" + id +
-                ", fileType=" + fileType +
-                ", bizType=" + bizType +
-                ", filePath=" + filePath +
-                ", clientPath=" + clientPath +
-                ", refObjId=" + refObjId +
-                ", refInfoCode=" + refInfoCode +
-                ", remark=" + remark +
-                ", orderNum=" + orderNum +
-                ", projectId=" + projectId +
-                ", floorId=" + floorId +
-                ", buildingId=" + buildingId +
-                ", creator=" + creator +
-                ", creationTime=" + creationTime +
-                ", modifier=" + modifier +
-                ", modifiedTime=" + modifiedTime +
-                ", valid=" + valid +
-                ", fileId=" + fileId +
-                ", ts=" + ts +
-                "}";
+        return JSON.toJSONString(this);
     }
 }

+ 1 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/entity/db/AdmQrCode.java

@@ -15,6 +15,7 @@ import java.io.IOException;
 @Data
 @TableName(value = "adm_qr_code",autoResultMap = true)
 public class AdmQrCode extends BaseAdmDataEntity {
+    private String groupCode;
 
     private String qrCode;
 

+ 9 - 27
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/SyncAppImpl.java

@@ -264,47 +264,29 @@ public class SyncAppImpl implements ISyncApp {
 
     @Override
     public BuildingData downloadBuildingData(AdmRequest admRequest) {
-        String groupCode = admRequest.getGroupCode();
         String projectId = admRequest.getProjectId();
         String userId = admRequest.getUserId();
         String clientId = admRequest.getClientId();
         String buildingId = admRequest.getBuildingId();
-        Long bdtpDownloadTs = admRequest.getBdtpDownloadTs();
         Long admDownloadTs = admRequest.getAdmDownloadTs();
         String operator = getOperator(clientId, userId);
 
-        //从bdtp下载对象(空间、竖井、系统、设备、元空间)
-        QueryCriteria criteria = ServiceUtil.getQueryCriteria(objectMapper, AdmConst.OBJ_TYPE_SPACE, AdmConst.OBJ_TYPE_SHAFT, AdmConst.OBJ_TYPE_SYSTEM, AdmConst.OBJ_TYPE_EQUIPMENT, "ispace");
-        buildDownloadQueryCriteria(criteria, operator, bdtpDownloadTs);
-        criteria.getCriteria().put("buildingId", buildingId);
-
-        List<ObjectNode> objs = ServiceUtil.queryAllPage(() -> objectClient.query(groupCode, projectId, AdmConst.APP_ID, userId, criteria), criteria, new Pagination(500));
-        if (objs == null)
-            objs = new ArrayList<>(0);
-
-        packInfos(objs);
-        test4Ts(objs);
-
         //关系数据按项目下载,不在建筑数据中处理
 
-        //管道数据,实验方案
-        List<AdmPipe> pipes = pipeMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmPipe>(), projectId, buildingId, operator, admDownloadTs));
+        //管道数据,实验方案 暂时不需要
+//        List<AdmPipe> pipes = pipeMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmPipe>(), projectId, buildingId, operator, admDownloadTs));
 
-        //任务相关数据查询
-        List<AdmJobSpace> jobSpace = jobSpaceMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmJobSpace>(), projectId, buildingId, operator, admDownloadTs));
+        //任务相关数据查询 细节待产品细化
+//        List<AdmJobSpace> jobSpace = jobSpaceMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmJobSpace>(), projectId, buildingId, operator, admDownloadTs));
 
-        List<AdmFile> file = fileMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmFile>(), projectId, buildingId, operator, admDownloadTs));
-        List<AdmQrCode> qrCode = qrCodeMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmQrCode>(), projectId, buildingId, operator, admDownloadTs));
-        List<AdmServeArea> serveArea = serveAreaMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmServeArea>(), projectId, buildingId, operator, admDownloadTs));
+        // 暂时涉及不到,不明白是干嘛的
+//        List<AdmServeArea> serveArea = serveAreaMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmServeArea>(), projectId, buildingId, operator, admDownloadTs));
 
         BuildingData data = new BuildingData();
         data.setBuildingId(buildingId);
-        data.setObjects(objs);
-        data.setPipes(pipes);
-        data.setJobSpace(jobSpace);
-        data.setFile(file);
-        data.setQrCode(qrCode);
-        data.setServeArea(serveArea);
+//        data.setPipes(pipes);
+//        data.setJobSpace(jobSpace);
+//        data.setServeArea(serveArea);
         fillBuildingDataChain.fill(admRequest,data);
         data.buildDownloadTs();
 

+ 17 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/CriteriaUtils.java

@@ -0,0 +1,17 @@
+package com.persagy.adm.server.custom.service.impl.offline_data_download;
+
+import com.persagy.dmp.basic.model.QueryCriteria;
+
+public class CriteriaUtils {
+
+    public static void buildDownloadQueryCriteria(QueryCriteria criteria, String operator, Long lastDownloadTime) {
+        if (lastDownloadTime != null && lastDownloadTime > 0) {
+            criteria.getCriteria().putObject("ts").put("$gt", lastDownloadTime);
+            criteria.getCriteria().putObject("modifier").put("$ne", operator); //TODO 暂时只能处理modifier
+        }
+    }
+
+    public static String getOperator(String clientId, String userId) {
+        return userId + ':' + clientId;
+    }
+}

+ 62 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/DownLoadDataDeal.java

@@ -0,0 +1,62 @@
+package com.persagy.adm.server.custom.service.impl.offline_data_download;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.adm.server.custom.util.DataExtrasUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class DownLoadDataDeal {
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    public void packInfos(List<ObjectNode> dataList) {
+        if (dataList != null) {
+            for (ObjectNode node : dataList) {
+                handle4Download(node);
+                DataExtrasUtil.packObjExtras(node);
+            }
+        }
+    }
+
+    /**
+     * 下载前处理数据结构
+     */
+    public void handle4Download(ObjectNode node) {
+        JsonNode ol = node.get("outline");
+        if (ol != null) {
+            try {
+                node.set("outline", objectMapper.readValue(ol.asText(), ArrayNode.class));
+            } catch (Exception e) {
+
+            }
+        }
+        JsonNode bl = node.get("bimLocation");
+        if (bl != null) {
+            try {
+                String[] arr = bl.asText().split(",");
+                ObjectNode ln = objectMapper.createObjectNode();
+                ln.put("x", Double.parseDouble(arr[0]));
+                ln.put("y", Double.parseDouble(arr[1]));
+                ln.put("z", Double.parseDouble(arr[2]));
+                node.set("location", ln);
+                node.remove("bimLocation");
+            } catch (Exception e) {
+
+            }
+        }
+    }
+
+    public void test4Ts(List<ObjectNode> dataList) {
+        long ts = System.currentTimeMillis();
+        for (ObjectNode data : dataList) {
+            if (data.get("ts") == null)
+                data.put("ts", ts);
+        }
+    }
+}

+ 14 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillBuildingDataChain.java

@@ -19,14 +19,28 @@ public class FillBuildingDataChain implements FillData<BuildingData>{
     FillProblem fillProblem;
     @Autowired
     FillCad fillCad;
+    @Autowired
+    FillFile fillFile;
+    @Autowired
+    FillQrCode fillQrCode;
+    @Autowired
+    FillObject fillObject;
 
     @PostConstruct
     public void init(){
         fillList = Lists.newArrayList();
+        /* ADM数据库数据*/
         // 问题数据
         fillList.add(fillProblem);
         // CAD图纸
         fillList.add(fillCad);
+        // 附件现场照片等
+        fillList.add(fillFile);
+        // 二维码数据
+        fillList.add(fillQrCode);
+        /* BDTP数据库数据*/
+        // 对象数据
+        fillList.add(fillObject);
     }
 
     @Override

+ 1 - 1
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillCad.java

@@ -29,6 +29,6 @@ public class FillCad implements FillData<BuildingData>{
                 .eq(AdmCad::getBuildingId,admRequest.getBuildingId())
                 .gt(admDownloadTs != null && admDownloadTs != 0,AdmCad::getTs,admDownloadTs));
         buildingData.setAdmCads(admCads);
-        log.info("填充CAD图纸数据开始");
+        log.info("填充CAD图纸数据结束");
     }
 }

+ 36 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillFile.java

@@ -0,0 +1,36 @@
+package com.persagy.adm.server.custom.service.impl.offline_data_download;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.persagy.adm.server.custom.common.AdmRequest;
+import com.persagy.adm.server.custom.dao.AdmFileMapper;
+import com.persagy.adm.server.custom.entity.BuildingData;
+import com.persagy.adm.server.custom.entity.db.AdmFile;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 离线数据-核查问题现场照片附件
+ */
+@Component
+@Slf4j
+public class FillFile implements FillData<BuildingData>{
+    @Autowired
+    AdmFileMapper fileMapper;
+    @Override
+    public void fill(AdmRequest admRequest, BuildingData buildingData) {
+        log.info("填充现场照片附件数据开始");
+        LambdaQueryWrapper<AdmFile> queryWrapper = Wrappers.lambdaQuery(AdmFile.class)
+                .eq(AdmFile::getGroupCode,admRequest.getGroupCode())
+                .eq(AdmFile::getProjectId,admRequest.getProjectId())
+                .eq(AdmFile::getBuildingId,admRequest.getBuildingId())
+                .eq(admRequest.getAdmDownloadTs() != null && admRequest.getAdmDownloadTs() != 0 ,AdmFile::getTs,admRequest.getAdmDownloadTs())
+                .eq(admRequest.getAdmDownloadTs() != null && admRequest.getAdmDownloadTs() != 0 ,AdmFile::getModifier,CriteriaUtils.getOperator(admRequest.getClientId(),admRequest.getUserId()));
+        List<AdmFile> files = fileMapper.selectList(queryWrapper);
+        buildingData.setFile(files);
+        log.info("填充现场照片附件数据结束");
+    }
+}

+ 57 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillObject.java

@@ -0,0 +1,57 @@
+package com.persagy.adm.server.custom.service.impl.offline_data_download;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.adm.server.custom.common.AdmConst;
+import com.persagy.adm.server.custom.common.AdmRequest;
+import com.persagy.adm.server.custom.entity.BuildingData;
+import com.persagy.adm.server.custom.entity.Pagination;
+import com.persagy.adm.server.custom.service.ServiceUtil;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.digital.client.DigitalObjectClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 离线数据下载-对象实例数据
+ */
+@Component
+@Slf4j
+public class FillObject implements FillData<BuildingData>{
+    @Autowired
+    private ObjectMapper objectMapper;
+    @Autowired
+    private DigitalObjectClient objectClient;
+    @Autowired
+    DownLoadDataDeal downLoadDataDeal;
+
+    @Override
+    public void fill(AdmRequest admRequest, BuildingData buildingData) {
+        log.info("填充对象实例纸数据开始");
+        //从bdtp下载对象(空间、竖井、系统、设备、元空间)
+        QueryCriteria criteria = ServiceUtil.getQueryCriteria(objectMapper, AdmConst.OBJ_TYPE_SPACE, AdmConst.OBJ_TYPE_SHAFT, AdmConst.OBJ_TYPE_SYSTEM, AdmConst.OBJ_TYPE_EQUIPMENT, AdmConst.OBJ_TYPE_ISPACE);
+        String operator = CriteriaUtils.getOperator(admRequest.getClientId(), admRequest.getUserId());
+        CriteriaUtils.buildDownloadQueryCriteria(criteria,operator,admRequest.getBdtpDownloadTs());
+
+        // 增量数据下载
+        if (admRequest.getBdtpDownloadTs() != null && admRequest.getBdtpDownloadTs() > 0){
+            criteria.getCriteria().putObject("ts").put("$gt", admRequest.getBdtpDownloadTs());
+            criteria.getCriteria().putObject("modifier").put("$ne", operator);
+        }
+        criteria.getCriteria().put("buildingId", admRequest.getBuildingId());
+        List<ObjectNode> objs = ServiceUtil.queryAllPage(() -> objectClient.query(admRequest.getGroupCode(), admRequest.getProjectId(), AdmConst.APP_ID, admRequest.getUserId(), criteria), criteria, new Pagination(500));
+        if (objs == null)
+            objs = new ArrayList<>(0);
+
+        // 处理下载数据并压缩公共字段
+        downLoadDataDeal.packInfos(objs);
+        // 填充ts
+        downLoadDataDeal.test4Ts(objs);
+        buildingData.setObjects(objs);
+        log.info("填充对象实例数据结束");
+    }
+}

+ 38 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/service/impl/offline_data_download/FillQrCode.java

@@ -0,0 +1,38 @@
+package com.persagy.adm.server.custom.service.impl.offline_data_download;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.persagy.adm.server.custom.common.AdmRequest;
+import com.persagy.adm.server.custom.dao.AdmQrCodeMapper;
+import com.persagy.adm.server.custom.entity.BuildingData;
+import com.persagy.adm.server.custom.entity.db.AdmQrCode;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 离线数据下载-二维码数据
+ */
+@Component
+@Slf4j
+public class FillQrCode implements FillData<BuildingData>{
+
+    @Autowired
+    AdmQrCodeMapper qrCodeMapper;
+
+    @Override
+    public void fill(AdmRequest admRequest, BuildingData buildingData) {
+        log.info("填充二维码数据开始");
+        LambdaQueryWrapper<AdmQrCode> queryWrapper = Wrappers.lambdaQuery(AdmQrCode.class)
+                .eq(AdmQrCode::getGroupCode,admRequest.getGroupCode())
+                .eq(AdmQrCode::getProjectId,admRequest.getProjectId())
+                .eq(AdmQrCode::getBuildingId,admRequest.getBuildingId())
+                .eq(admRequest.getAdmDownloadTs() != null && admRequest.getAdmDownloadTs() != 0 ,AdmQrCode::getTs,admRequest.getAdmDownloadTs())
+                .eq(admRequest.getAdmDownloadTs() != null && admRequest.getAdmDownloadTs() != 0 ,AdmQrCode::getModifier,CriteriaUtils.getOperator(admRequest.getClientId(),admRequest.getUserId()));
+        List<AdmQrCode> qrCode = qrCodeMapper.selectList(queryWrapper);
+        buildingData.setQrCode(qrCode);
+        log.info("填充二维码数据开始");
+    }
+}

+ 3 - 1
adm-business/adm-server/src/main/resources/db/init/schema.sql

@@ -8,7 +8,7 @@ CREATE TABLE IF NOT EXISTS `adm_cad`  (
   `floor_id` varchar(255) NOT NULL COMMENT '楼层ID',
   `building_id` varchar(255) NOT NULL COMMENT '建筑ID',
   `project_id` varchar(255) NOT NULL COMMENT '项目ID',
-  `group_code` varchar(255) NOT NULL COMMENT '集团编码',
+  `group_code` varchar(40) NOT NULL COMMENT '集团编码',
   `creator` varchar(32) NULL DEFAULT NULL COMMENT '创建人',
   `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
   `modifier` varchar(32) NULL DEFAULT NULL COMMENT '最后修改人',
@@ -97,6 +97,7 @@ CREATE TABLE IF NOT EXISTS `adm_file`  (
   `ref_info_code` varchar(40) NULL DEFAULT NULL COMMENT '关联的对象信息点code',
   `remark` varchar(200) NULL DEFAULT NULL COMMENT '描述',
   `order_num` tinyint(0) NULL DEFAULT NULL COMMENT '文件附件(照片)的排序序号',
+  `group_code` varchar(40) NOT NULL COMMENT '集团编码',
   `project_id` varchar(40) NOT NULL COMMENT '项目id',
   `floor_id` varchar(60) NULL DEFAULT NULL COMMENT '楼层id',
   `building_id` varchar(60) NULL DEFAULT NULL COMMENT '建筑id',
@@ -275,6 +276,7 @@ CREATE TABLE IF NOT EXISTS `adm_qr_code`  (
   `floor_id` varchar(60) NOT NULL COMMENT '楼层id',
   `location` json NOT NULL COMMENT '位置坐标({x:1,y:1,z:1})',
   `remark` varchar(200) NULL DEFAULT NULL COMMENT '描述信息(临时记录二维码粘贴位置)',
+  `group_code` varchar(40) NOT NULL COMMENT '集团编码',
   `project_id` varchar(40) NOT NULL COMMENT '项目id',
   `building_id` varchar(60) NOT NULL COMMENT '建筑id',
   `creator` varchar(32) NULL DEFAULT NULL COMMENT '创建人',