浏览代码

******************WX *********************
关系总览,添加关系同步

zhangweixin 4 年之前
父节点
当前提交
ae3cce9a1c

+ 9 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/controllers/dict/DictGatherControllers.kt

@@ -36,5 +36,14 @@ class DictGatherControllers {
     }
 
 
+    /**
+     * 同步项目字典
+     */
+    @Operation(summary = "同步项目字典", description = "")
+    @GetMapping(value = ["/dict/code/syn"])
+    fun dictSynCode(@RequestParam groupCode: String,@RequestParam projectId: String): SBaseResponse {
+        return DClassDefService.synCodeProject(groupCode,projectId)
+    }
+
 
 }

+ 40 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/controllers/obj/RelFromToControllers.kt

@@ -7,6 +7,7 @@ import com.persagy.server.datacenter.models.entities.objects.Equipment
 import com.persagy.server.datacenter.models.entities.objects.Floor
 import com.persagy.server.datacenter.models.entities.objects.ZoneSpace
 import com.persagy.server.datacenter.models.entities.rel.*
+import com.persagy.server.syn.Configure
 import com.persagy.server.syn.models.api.obj.EquipApi
 import com.persagy.service.SBaseService
 import com.persagy.service.SObjectService
@@ -423,4 +424,43 @@ class RelFromToControllers {
 
     }
 
+    /**
+     * 设备和设备关系
+     */
+    @Operation(summary= "设备和设备关系 同步到数据中心", description = "")
+    @PostMapping("/eq2eq")
+    fun eq2Eq(@RequestParam projectId: String,@RequestParam graphCode: String,@RequestParam relCode: String): SBaseResponse{
+        try {
+        val dictProject = dictProjectService.select(SFilter.eq("id", projectId)).entity()
+        if (dictProject!=null) {
+            val relList = EquipApi.getRel(dictProject.groupCode!!, projectId, graphCode, relCode)
+            if (!relList.isNullOrEmpty()){
+                val relType = Configure.relContrastEq(graphCode, relCode)
+                if (!relType.isNullOrEmpty()){
+                    for ( rel in relList) {
+                        try {
+                            val fromId = rel["objFrom"].toString()
+                            val toId = rel["objTo"].toString()
+                            val rEq2Eq = REq2Eq()
+                            rEq2Eq.id1 = fromId
+                            rEq2Eq.id2 = toId
+                            rEq2Eq.sign = 1
+                            rEq2Eq.projectId = projectId
+                            rEq2Eq.type = relType
+                            rEq2EqService.replace(rEq2Eq)
+                        } catch (e: Exception) {
+                            e.printStackTrace()
+                        }
+                    }
+                }
+
+            }
+        }
+            return SBaseResponse(SResponseType.success)
+        } catch (e: Exception) {
+            e.printStackTrace()
+            return SBaseResponse(SResponseType.failure)
+        }
+    }
+
 }

+ 27 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/services/dict/DClassDefService.kt

@@ -62,6 +62,8 @@ object DClassDefService : SObjectService<DefClass>(SMybatisDao(DefClass::class.j
     private val defClassService = SBaseService(SMybatisDao(DefClass::class.java))
     /** 详细信息点 */
     private val defFuncIdService = SBaseService(SMybatisDao(DefFuncId::class.java))
+    /** 详细信息点 */
+    private val defFuncIdProjectService = SBaseService(SMybatisDao(DefFuncIdProject::class.java))
     /** 详细信息点 需采集信息点配置 */
     private val defFuncIdGather = SBaseService(SMybatisDao(DefFuncIdGather::class.java))
     /** 专业 */
@@ -1692,4 +1694,29 @@ object DClassDefService : SObjectService<DefClass>(SMybatisDao(DefClass::class.j
     } // Fun dictPlatformInfo()
 
 
+    fun synCodeProject(groupCode: String,projectId: String): SBaseResponse {
+        try {
+            val select = defFuncIdProjectService.select(SFilter.eq("type", "common"))
+            select.tableName = "dict.def_funcid"
+            val defFuncIdList = select.exec()
+            if (defFuncIdList.size>0) {
+                for (defFuncId in defFuncIdList) {
+                    try {
+                        defFuncId.projectId = projectId
+                        defFuncId.type = "project"
+                        defFuncId.groupCode = groupCode
+                        defFuncId.visible = null
+                        defFuncIdProjectService.replace(defFuncId)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
+                }
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+        return SBaseResponse(SResponseType.success)
+    }
+
+
 } // Object DClassDefService