Prechádzať zdrojové kódy

添加管网计算的逻辑类

lijie 3 rokov pred
rodič
commit
d0ac1e74f4

+ 4 - 1
pom.xml

@@ -8,7 +8,6 @@
         <version>1.0.0</version>
 		<relativePath/> <!-- lookup parent from repository -->
 	</parent>
-	<groupId>com.persagy</groupId>
 	<artifactId>adm-middleware</artifactId>
     <packaging>jar</packaging>
 	<version>1.0.0</version>
@@ -100,5 +99,9 @@
 			<artifactId>gt-main</artifactId>
 			<version>23.0</version>
 		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter</artifactId>
+		</dependency>
 	</dependencies>
 </project>

+ 67 - 0
src/main/java/com/persagy/proxy/adm/controller/AdmMepSystemCalcController.java

@@ -0,0 +1,67 @@
+package com.persagy.proxy.adm.controller;
+
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmMepSourceTypeEntity;
+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.AdmMepSystemCalcService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import javax.ws.rs.QueryParam;
+
+/***
+ * Description: 机电管网系统关系计算
+ * @author : lijie
+ * @date :2021/9/14 23:15
+ * Update By lijie 2021/9/14 23:15
+ */
+@RestController
+@RequestMapping("/mep-system-calc/source/")
+@RequiredArgsConstructor
+public class AdmMepSystemCalcController {
+
+    private final AdmMepSystemCalcService admMepSystemCalcService;
+
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    /***
+     * Description: 添加源端设备类型
+     * @param projectId : 项目id
+     * @param request : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/9/14 23:20
+     * Update By lijie 2021/9/14 23:20
+     */
+    @PostMapping("add")
+    public AdmResponse add(@QueryParam("projectId") String projectId,
+                           @RequestBody AdmCreateRequest<AdmMepSourceTypeEntity> request) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        return admMepSystemCalcService.add(context, request);
+    }
+    /***
+     * Description: 查询源端设备类型
+     * @param projectId : 项目id
+     * @param calcName : 关系名称
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/9/14 23:20
+     * Update By lijie 2021/9/14 23:20
+     */
+    @GetMapping("query")
+    public AdmResponse query(@QueryParam("projectId") String projectId,
+                             @QueryParam("calcName") String calcName) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        return admMepSystemCalcService.query(context, calcName);
+    }
+
+
+}

+ 2 - 0
src/main/java/com/persagy/proxy/adm/model/AdmDCSQueryRequest.java

@@ -2,6 +2,7 @@ package com.persagy.proxy.adm.model;
 
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 import java.util.List;
 
@@ -11,6 +12,7 @@ import java.util.List;
  * @date 2021/9/8
  */
 @Data
+@EqualsAndHashCode(callSuper=true)
 public class AdmDCSQueryRequest extends AdmQueryCriteria {
     /** 楼层id */
     

+ 2 - 0
src/main/java/com/persagy/proxy/adm/model/AdmDictQueryCriteria.java

@@ -2,6 +2,7 @@ package com.persagy.proxy.adm.model;
 
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 /**
  * @ClassName AdmEquipFamilyCategory
@@ -11,6 +12,7 @@ import lombok.Data;
  * @Version V1.0
  **/
 @Data
+@EqualsAndHashCode(callSuper=true)
 public class AdmDictQueryCriteria extends AdmQueryCriteria {
 
     /** 查询类型 */

+ 38 - 0
src/main/java/com/persagy/proxy/adm/model/AdmMepSourceTypeEntity.java

@@ -0,0 +1,38 @@
+package com.persagy.proxy.adm.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/***
+ * Description: 源末端关系设置
+ * @author : lijie
+ * @date :2021/9/14 23:18
+ * Update By lijie 2021/9/14 23:18
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class AdmMepSourceTypeEntity {
+    /** 项目id */
+    private String projectId;
+
+    /** 计算卡片名称 */
+    private String calcName;
+
+    /** 源端设备类型 */
+    private String sourceType;
+
+    /** 前台使用源端设备类型 */
+    private String frontType;
+
+    /** 创建时间 */
+    private Date createTime;
+
+    /** 源端设备类型 */
+    private Integer sourceCount;
+}

+ 35 - 0
src/main/java/com/persagy/proxy/adm/service/AdmMepSystemCalcService.java

@@ -0,0 +1,35 @@
+package com.persagy.proxy.adm.service;
+
+import com.persagy.proxy.adm.model.AdmMepSourceTypeEntity;
+import com.persagy.proxy.adm.request.AdmCreateRequest;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+/***
+ * Description: 源末端关系设置逻辑处理类
+ * @author : lijie
+ * @date :2021/9/14 23:21
+ * Update By lijie 2021/9/14 23:21
+ */
+public interface AdmMepSystemCalcService {
+    /***
+     * Description: 添加源末端关系
+     * @param context : 请求上下文
+     * @param request : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/9/14 23:23
+     * Update By lijie 2021/9/14 23:23
+     */
+    AdmResponse add(InstanceUrlParam context, AdmCreateRequest<AdmMepSourceTypeEntity> request);
+    /***
+     * Description: 查询源端设备类型
+     * @param context : 参数
+     * @param calcName : 关系名称
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/9/14 23:20
+     * Update By lijie 2021/9/14 23:20
+     */
+    AdmResponse query(InstanceUrlParam context, String calcName);
+}

+ 90 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AdmMepSystemCalcServiceImpl.java

@@ -0,0 +1,90 @@
+package com.persagy.proxy.adm.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.persagy.dmp.basic.dto.DefineRequestData;
+import com.persagy.dmp.common.constant.CommonConstant;
+import com.persagy.dmp.common.model.response.CommonResult;
+import com.persagy.dmp.define.client.DigitalEquipClassRelFacade;
+import com.persagy.dmp.define.entity.DigitalEquipClassRel;
+import com.persagy.proxy.adm.model.AdmMepSourceTypeEntity;
+import com.persagy.proxy.adm.request.AdmCreateRequest;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.AdmMepSystemCalcService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/***
+ * Description: 源末端关系设置逻辑处理类
+ * @author : lijie
+ * @date :2021/9/14 23:21
+ * Update By lijie 2021/9/14 23:21
+ */
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class AdmMepSystemCalcServiceImpl implements AdmMepSystemCalcService {
+    /***
+     * Description: 添加源末端关系
+     * @param context : 请求上下文
+     * @param request : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/9/14 23:23
+     * Update By lijie 2021/9/14 23:23
+     */
+    @Override
+    public AdmResponse add(InstanceUrlParam context, AdmCreateRequest<AdmMepSourceTypeEntity> request) {
+        List<AdmMepSourceTypeEntity> content = request.getContent();
+        if (CollUtil.isEmpty(content)){
+            return AdmResponse.success(new ArrayList<>());
+        }
+        List<DigitalEquipClassRel> relList = new ArrayList<>();
+        content.forEach(entity->{
+            DigitalEquipClassRel rel = new DigitalEquipClassRel();
+            rel.setProjectId(context.getProjectId());
+            rel.setCalcName(entity.getCalcName());
+            rel.setSourceEquipCode(entity.getSourceType());
+            relList.add(rel);
+        });
+        DigitalEquipClassRelFacade
+                .createBatch(context.getGroupCode(), context.getProjectId(),
+                        context.getAppId(), CommonConstant.DEFAULT_ID, relList);
+        return AdmResponse.success(content);
+    }
+    /***
+     * Description: 查询源端设备类型
+     * @param context : 参数
+     * @param calcName : 关系名称
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/9/14 23:20
+     * Update By lijie 2021/9/14 23:20
+     */
+    @Override
+    public AdmResponse query(InstanceUrlParam context, String calcName) {
+        // 先根据边类型名称查询图类型编码及边类型编码
+        CommonResult<List<DigitalEquipClassRel>> result = DigitalEquipClassRelFacade
+                .queryListByRelNames(context.getGroupCode(), context.getProjectId(), context.getAppId(),
+                CommonConstant.DEFAULT_ID, DefineRequestData.builder().relNames(CollUtil.newHashSet(calcName)).build());
+        List<DigitalEquipClassRel> data = result.getData();
+        if (CollUtil.isEmpty(data)){
+            return AdmResponse.success(new ArrayList<>());
+        }
+        // 组装ADM数据
+        List<AdmMepSourceTypeEntity> resultData = new ArrayList<>();
+        data.forEach(digitalEquipClassRel -> {
+            resultData.add(AdmMepSourceTypeEntity.builder()
+                .calcName(digitalEquipClassRel.getCalcName())
+                .sourceType(digitalEquipClassRel.getSourceEquipCode())
+                .projectId(digitalEquipClassRel.getProjectId())
+                .createTime(digitalEquipClassRel.getCreationTime().getDate())
+                .build());
+        });
+        return AdmResponse.success(resultData);
+    }
+}