浏览代码

设备服务业务空间关系计算

caiaf 4 年之前
父节点
当前提交
d6666158c6

+ 5 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/rel/REq2Sp.kt

@@ -80,4 +80,9 @@ class REq2Sp : RBaseInfo(){
     @Column(name = "sign")
     var sign: Int? = null
 
+//    /** 计算标记 1 为手动 2为自动 */
+    @Schema(description = "计算标记 3 ")
+    @Column(name = "sign0")
+    var sign0: Int? = null
+
 }

+ 22 - 0
datacenter/src/main/kotlin/com/persagy/server/mappers/IRelationCalcMapper.kt

@@ -26,6 +26,8 @@
 
 package com.persagy.server.mappers
 
+import org.apache.ibatis.annotations.Delete
+import org.apache.ibatis.annotations.Insert
 import org.apache.ibatis.annotations.Mapper
 import org.apache.ibatis.annotations.Select
 import org.springframework.stereotype.Repository
@@ -78,6 +80,26 @@ interface IRelationCalcMapper {
     @Select("select public.f_rel_calc('rel_eq2sp', #{projectId}, 'zone_space_base','relationship.r_eq2sp', 2, 2)")
     fun calcEq2Sp( projectId: String): Int?
 
+//    /**
+//     * 删除关联业务空间
+//     *
+//     *@param projectId 项目id
+//     */
+//    @Select("delete from 'relationship.r_eq2sp' as r where r.sign0 = 3 and r.project_id = #{projectId}")
+//    fun deletesp( projectId: String): Int?
+
+    /**
+     * 插入关联业务空间
+     *
+     *@param projectId 项目id
+     */
+    @Insert("insert into relationship.r_eq2sp(eq_id, sp_id, project_id, sign, type, zone_type,sign0) " +
+            "select eq.id2 as eqid,ep.sp_id as spid,ep.project_id as project_id,ep.sign as sign,ep.type as type,ep.zone_type as zone_type,3  from relationship.r_eq2eq  as eq " +
+            "inner join relationship.r_eq2sp  as ep on eq.id1 = ep.eq_id  where ep.project_id = #{projectId} union\n" +
+            "select eq.id1 as eqid,ep.sp_id as spid,ep.project_id as project_id,ep.sign as sign,ep.type as type,ep.zone_type as zone_type,3  from relationship.r_eq2eq  as eq " +
+            "inner join relationship.r_eq2sp as ep  on eq.id2= ep.eq_id where ep.project_id = #{projectId}")
+    fun insertsp( projectId: String): Int?
+
     /**
      * 楼层贯通关系
      *

+ 18 - 16
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/CalcSpecialService.kt

@@ -91,25 +91,27 @@ open class CalcSpecialService {
                         }
                     }
                     // 设置源
-                    val sourceType = mepSystemCalcService.setSourceType(projectId, calcName, null, systemName)
-                    if (!sourceType) {
-                        upDateBiaoji(projectId,relationType ,5)
-                        return SBaseResponse(SResponseType.success)
-                    }
+//                    val sourceType = mepSystemCalcService.setSourceType(projectId, calcName, null, systemName)
+//
+//                    if (!sourceType) {
+//                        upDateBiaoji(projectId,relationType ,5)
+//                        return SBaseResponse(SResponseType.success)
+//                    }
                     // 计算流向
-                    val exec = connectedBlockService.select(SFilter.eq("projectId", projectId), SFilter.inList("mepSystemType", systemName)).group("mepSystemType", "blockId").projection(arrayListOf("mepSystemType", "blockId")).exec()
-                    exec.forEach {
-                        val domain = toolsMap(it.mepSystemType!!)
-                        val result = mapper.sysDirection(projectId, buildingId, it.blockId!!, it.mepSystemType!!, domain, true)
-                        if (!result) {
-                            upDateBiaoji(projectId,relationType ,5)
-                            return SBaseResponse(SResponseType.success)
-                        }
-                    }
+//                    val exec = connectedBlockService.select(SFilter.eq("projectId", projectId), SFilter.inList("mepSystemType", systemName)).group("mepSystemType", "blockId").projection(arrayListOf("mepSystemType", "blockId")).exec()
+//                    exec.forEach {
+//                        val domain = toolsMap(it.mepSystemType!!)
+//                        val result = mapper.sysDirection(projectId, buildingId, it.blockId!!, it.mepSystemType!!, domain, true)
+//                        if (!result) {
+//                            upDateBiaoji(projectId,relationType ,5)
+//                            return SBaseResponse(SResponseType.success)
+//                        }
+//                    }
                     try {
                         // 生成数据中心使用的关系
-                        val generateRelation = mepSystemCalcService.generateRelation(projectId, relationType, null, systemName)
-                        generateRelation.addAll(mepSystemCalcService.generateNonDirectionalRelation(projectId, relationType, null, systemName))
+//                        val generateRelation = mepSystemCalcService.generateRelation(projectId, relationType, null, systemName)
+//                        generateRelation.addAll(mepSystemCalcService.generateNonDirectionalRelation(projectId, relationType, null, systemName))
+                        val generateRelation = mepSystemCalcService.generateNonDirectionalRelation(projectId, relationType, null, systemName)
                         if (generateRelation.size>0){
                             val delete = rEq2EqService.delete(SFilter.eq("projectId", projectId), SFilter.eq("type", relationType), SFilter.eq("sign", 2))
 

+ 12 - 8
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/MepSystemCalcService.kt

@@ -178,15 +178,19 @@ class MepSystemCalcService {
         }
         val mepSystemTransformer = MepSystemTransformer()
         originData.forEach {
-            if(it.direction == 1){
-                mepSystemTransformer.insertRelData(it.id1!!, it.type1!!, it.id2!!, it.type2!!)
-            }else if(it.direction == -1){
-                mepSystemTransformer.insertRelData(it.id2!!, it.type2!!, it.id1!!, it.type1!!)
-            }else if(it.direction == 0){
-                mepSystemTransformer.insertRelData(it.id1!!, it.type1!!, it.id2!!, it.type2!!)
-                mepSystemTransformer.insertRelData(it.id2!!, it.type2!!, it.id1!!, it.type1!!)
-            }
+            mepSystemTransformer.insertNonDirectionalRelData(it.id1!!, it.type1!!, it.id2!!, it.type2!!)
         }
+
+//        originData.forEach {
+//            if(it.direction == 1){
+//                mepSystemTransformer.insertRelData(it.id1!!, it.type1!!, it.id2!!, it.type2!!)
+//            }else if(it.direction == -1){
+//                mepSystemTransformer.insertRelData(it.id2!!, it.type2!!, it.id1!!, it.type1!!)
+//            }else if(it.direction == 0){
+//                mepSystemTransformer.insertRelData(it.id1!!, it.type1!!, it.id2!!, it.type2!!)
+//                mepSystemTransformer.insertRelData(it.id2!!, it.type2!!, it.id1!!, it.type1!!)
+//            }
+//        }
         mepSystemTransformer.trim()
         val eq2EqRelation = mepSystemTransformer.getEq2EqNonDirectionalRelation()
         val involvedEquip = mepSystemTransformer.getInvolvedEquip(eq2EqRelation, true)

+ 10 - 0
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/RelationCalcService.kt

@@ -1103,6 +1103,16 @@ open class RelationCalcService {
             /** 启动计算 */
             val result = mapper.calcEq2Sp(projectId)
             logger.debug("计算结果= ${result}")
+            try{
+//                val r1 = mapper.deletesp(projectId)
+                val r1 = REq2SpService.delete(SFilter.eq("projectId", projectId),SFilter.eq("sign0", 3))
+                val r2 = mapper.insertsp(projectId)
+                logger.debug("设备关联业务空间计算结果= ${r1}+${r2}")
+            }catch (e: Exception){
+                e.printStackTrace()
+            }
+
+
             if(result!=null && result == 0){
                 try {
                     /** 发送消息 */