Browse Source

********************WX***********************
同步关系

zhangweixin 4 years ago
parent
commit
a84133b0f0

+ 7 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/Configure.kt

@@ -28,6 +28,8 @@ package com.persagy.server.syn
 
 import com.alibaba.fastjson.JSONArray
 import com.alibaba.fastjson.JSONObject
+import com.persagy.base.extensions.toJson
+import org.slf4j.LoggerFactory
 
 /**
  * 配置文件
@@ -36,7 +38,8 @@ import com.alibaba.fastjson.JSONObject
  * @date  2020/11/1 21:45
  */
 object Configure {
-
+    /** 日志 */
+    private val logger = LoggerFactory.getLogger(Configure::class.java)
 
     /** 标记 */
     var flag: Boolean = true
@@ -142,6 +145,7 @@ object Configure {
      * @param objTo         从对象 id
      */
     fun toJsonObjFromList(graphCode: String, relCode: String, objFroms: ArrayList<String>, objTo: String): JSONArray {
+
         /** 列表 */
         val jsonArray = JSONArray()
         for (id in objFroms){
@@ -156,7 +160,8 @@ object Configure {
             /** 从对象 id */
             jsonObject["objTo"] = objTo
             /** 添加到列表 */
-            jsonArray.plus(jsonObject)
+            jsonArray.add(jsonObject)
+            logger.debug("数组001 ${jsonArray?.toJson() }   **************************************************************************")
         }
         return jsonArray
     }

+ 14 - 5
datasyn/src/main/kotlin/com/persagy/server/syn/jms/DataCenterSync.kt

@@ -111,7 +111,7 @@ class DataCenterSync {
         val type = object : TypeToken<ArrayList<String>>() {
         }.type
         for (message in messageList){
-            logger.debug("消息 = ${message.toJson()}")
+            logger.debug("消息类型 = ${message.type}")
             when(message.type){
                 "EquipinSpace" -> {
                     logger.debug("消息01 = ${message.toJson()}")
@@ -125,22 +125,24 @@ class DataCenterSync {
                             equipInSpaceSync.delRel(message,"MechInArch","Eq2Sp")
                         }
                         "13" -> { // 清除之前的关系,替换
-
                             if (message.fromId!!.startsWith("Eq")){
                                 var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                 equipInSpaceSync.addRelSuperposition(message,ids,"MechInArch","Eq2Sp")
 
-                            } else if (message.fromId!!.startsWith("Sq")) {
+                            } else if (message.fromId!!.startsWith("Sp")) {
                                 var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
 
                                 equipInSpaceSync.addRelSuperpositionFan(message,ids,"MechInArch","Eq2Sp")
                             }
                         }
                         "14" -> {  // 添加不替换
-                            if (message.fromId!!.startsWith("Sq")) {
+                            if (message.fromId!!.startsWith("Sp")) {
                                 var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
-                                logger.debug("数组= ${ids.toJson()}")
+                                logger.debug("id= ${ids.toJson()}**************************")
                                 equipInSpaceSync.equipInSpaceCreate(message,"MechInArch","Eq2Sp",ids)
+                            }else {
+                                logger.debug("没识别**************************")
+
                             }
                         }
                     }
@@ -227,6 +229,13 @@ class DataCenterSync {
                         "12" -> { // 删除关系
                             equipInSpaceSync.delRel(message, "MechForArch", "Eq2Sp")
                         }
+                        "13" -> {
+
+                        }
+                        "14" -> {
+
+                        }
+
                     }
                 }
                 "EquipinShaft" -> {

+ 7 - 5
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/rel/EquipinSpaceSync.kt

@@ -1,6 +1,6 @@
 package com.persagy.server.syn.services.jms.rel
 
-import com.persagy.base.extensions.toJson
+import com.alibaba.fastjson.JSONArray
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.entities.dictnew.DictProject
@@ -36,17 +36,19 @@ class EquipinSpaceSync {
      */
     fun equipInSpaceCreate(synchronousMessageRel: SynchronousMessageRel,graphCode: String,relCode: String,fromIds:ArrayList<String>?){
         try {
-            logger.debug("数组 ${fromIds?.toJson() }   **************************************************************************")
+
             val dictProject = dictProjectService.select(SFilter.eq("id", synchronousMessageRel.projectId!!)).entity()
             if (dictProject!=null) {
                 synchronousMessageRel.sign = 0
-                val toJsonObjArray = if (!fromIds.isNullOrEmpty()){
+                val toJsonObjArray :JSONArray
+                    if (!fromIds.isNullOrEmpty()){
                     /** 关系列表 */
-                    Configure.toJsonObjFromList(graphCode, relCode, fromIds, synchronousMessageRel.toId!!)
+                        toJsonObjArray= Configure.toJsonObjFromList(graphCode, relCode, fromIds, synchronousMessageRel.fromId!!)
                 } else {
                     /** 关系列表 */
-                    Configure.toJsonObjArray(graphCode, relCode, synchronousMessageRel.fromId!!, synchronousMessageRel.toId!!)
+                        toJsonObjArray = Configure.toJsonObjArray(graphCode, relCode, synchronousMessageRel.fromId!!, synchronousMessageRel.toId!!)
                 }
+
                 val createRel = EquipApi.createRel(dictProject.groupCode!!, synchronousMessageRel.projectId!!, toJsonObjArray)
                 if (!createRel ){
                     synchronousMessageRel.sign = 2

+ 2 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/task/SchedulerTaskRel.kt

@@ -52,8 +52,8 @@ class SchedulerTaskRel {
 
     //cron表达式:每隔5秒执行一次
 //    @Scheduled(cron = "0 */3 * * * ?")
-//    @Scheduled(cron="0/5 * *  * * ? ")   //每5秒执行一次
-    @Scheduled(cron = "0 */1 * * * ?")
+    @Scheduled(cron="0/5 * *  * * ? ")   //每5秒执行一次
+//    @Scheduled(cron = "0 */1 * * * ?")
     fun scheduled() {
         logger.info("同步数据中心任务开始至数据中台-关系数据")
         messageProcessing.syncDataCenterRel()