package com.persagy.server.datacenter.syn.jms

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.persagy.base.extensions.toJson
import com.persagy.server.datacenter.models.jms.SynchronousMessage
import com.persagy.server.datacenter.models.jms.SynchronousMessageRel
import com.persagy.server.datacenter.syn.services.jms.DataCenterBuilding
import com.persagy.server.datacenter.syn.services.jms.DataCenterComponent
import com.persagy.server.datacenter.syn.services.jms.DataCenterSpace
import com.persagy.server.datacenter.syn.services.jms.rel.AutomaticCalculationSync
import com.persagy.server.datacenter.syn.services.jms.rel.EquipinSpaceSync
import com.persagy.server.syn.Configure
import com.persagy.server.syn.services.jms.*
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

/**
 * 数据中心 - 数据处理
 *
 * @author wx  <zhangweixin@sagacloud.com>
 * @date  2020/11/1 22:22
 */
@Service
class DataCenterSync {

    companion object {
        /** 日志 */
        private val logger = LoggerFactory.getLogger(DataCenterSync::class.java)
    } // Companion object
    /** 建筑 */
    @Autowired
    lateinit var dataCenterBuilding: DataCenterBuilding
    /** 楼层 */
    @Autowired
    lateinit var dataCenterFloor: DataCenterFloor
    /** 设备 */
    @Autowired
    lateinit var dataCenterEquip: DataCenterEquipment
    /** 部件 */
    @Autowired
    lateinit var dataCenterComponent: DataCenterComponent
    /** 竖井 */
    @Autowired
    lateinit var dataCenterShaft: DataCenterShaft
    /** 系统 */
    @Autowired
    lateinit var dataCenterSystem: DataCenterSystem
    /** 空间 */
    @Autowired
    lateinit var dataCenterSpace: DataCenterSpace
    /** 租户 */
    @Autowired
    lateinit var dataCenterVOTn: DataCenterVOTn
    /** 设备所在的业务空间 */
    @Autowired
    lateinit var equipInSpaceSync: EquipinSpaceSync
    /** 计算关系 */
    @Autowired
    lateinit var automaticCalculationSync: AutomaticCalculationSync

    /**
     * 数据中心到 - 中台数据
     *
     * @param messageList   消息列表
     */
    fun dataSync(messageList:ArrayList<SynchronousMessage>): Boolean {
        for (message in messageList){
            when(message.objectType){
                Configure.PROJECT -> { /** 项目信息 */}
                Configure.BUILDING -> {
                    /** 建筑 */
                    dataCenterBuilding.buildingType(message)
                }
                Configure.FLOOR -> {
                    /** 楼层 */
                    dataCenterFloor.floorType(message)
                }
                Configure.EQUIPMENT -> {

                    /** 设备 */
                    dataCenterEquip.equipType(message)
                }

                Configure.COMPONENT -> {
                    /** 部件 */
                    dataCenterComponent.equipType(message)
                }
                Configure.SHAFT -> {
                    /** 竖井 */
                    dataCenterShaft.shaftType(message)
                }
                Configure.SYSTEM -> {
                    /** 系统 */
                    dataCenterSystem.systemType(message)
                }
                Configure.SPACE -> {
                    /** 空间 */
                    dataCenterSpace.spaceType(message)
                }
                Configure.VOTN -> {
                    /** 租户 */
//                    dataCenterVOTn.tenantType(message)
                }
                "equip" -> {
                    dataCenterEquip.equipAllUpDate(message)
                }
            }
        }
        return true
    }


    /**
     * 处理关系数据到数据中台
     */
    fun  dataSyncRel(messageList:ArrayList<SynchronousMessageRel>){
        val type = object : TypeToken<ArrayList<String>>() {
        }.type
        for (message in messageList){
            logger.debug("消息类型 = ${message.type}")
            when(message.type){
                "EquipinSpace" -> {
                    logger.debug("消息01 = ${message.toJson()}")
                    /** 设备所在的空间  */
                    when(message.ops){

                        "11" -> { // 创建关系

                            equipInSpaceSync.equipInSpaceCreate(message,"MechInArch","Eq2Sp",null)
                        }
                        "12" -> { // 删除关系
                            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("Sp")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)

                                equipInSpaceSync.addRelSuperpositionFan(message,ids,"MechInArch","Eq2Sp")
                            }
                        }
                        "14" -> {  // 添加不替换
                            if (message.fromId!!.startsWith("Sp")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                logger.debug("id= ${ids.toJson()}**************************")
                                equipInSpaceSync.equipInSpaceCreate(message,"MechInArch","Eq2Sp",ids)
                            }
                        }
                    }
                }
                "SystemEquip" -> {
                    /** 系统下的设备设施 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechSubset", "Sy2Eq", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechSubset", "Sy2Eq")
                        }
                        "13" ->{
                            if (message.fromId!!.startsWith("Eq")){
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                equipInSpaceSync.addRelSuperposition(message,ids,"MechSubset","Sy2Eq")

                            } else if (message.fromId!!.startsWith("Sy")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)

                                equipInSpaceSync.addRelSuperpositionFan(message,ids,"MechSubset","Sy2Eq")
                            }

                        }
                        "14" ->{
                            if (message.fromId!!.startsWith("Sy")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                logger.debug("id= ${ids.toJson()}**************************")
                                equipInSpaceSync.equipInSpaceCreate(message,"MechSubset","Sy2Eq",ids)
                            }
                        }



                    }
                }
                "Sy2Sh" -> {
                    /** 系统所在竖井 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechInArch", "Sy2Sh", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechInArch", "Sy2Sh")
                        }
                        "13" ->{
                            if (message.fromId!!.startsWith("Sy")){
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                equipInSpaceSync.addRelSuperposition(message,ids,"MechInArch","Sy2Sh")

                            } else if (message.fromId!!.startsWith("Sh")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)

                                equipInSpaceSync.addRelSuperpositionFan(message,ids,"MechInArch","Sy2Sh")
                            }

                        }
                        "14" ->{
                            if (message.fromId!!.startsWith("Sy")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                equipInSpaceSync.equipInSpaceCreate(message,"MechInArch","Sy2Sh",ids)
                            }
                        }

                    }
                }
                "Sy2Sp" -> {
                    /** 系统所在业务空间 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechInArch", "Sy2Sp", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechInArch", "Sy2Sp")
                        }
                        "13" ->{
                            if (message.fromId!!.startsWith("Sy")){
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                equipInSpaceSync.addRelSuperposition(message,ids,"MechInArch","Sy2Sp")

                            } else if (message.fromId!!.startsWith("Sp")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)

                                equipInSpaceSync.addRelSuperpositionFan(message,ids,"MechInArch","Sy2Sp")
                            }
                        }
                        "14" ->{
                            if (message.fromId!!.startsWith("Sy")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                equipInSpaceSync.equipInSpaceCreate(message,"MechInArch","Sy2Sp",ids)
                            } else if (message.fromId!!.startsWith("Sp")){
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                equipInSpaceSync.equipInSpaceCreateTwo(message,"MechInArch","Sy2Sp",ids)
                            }
                        }
                    }
                }
                "Eq2Bd" -> {
                    /** 设备服务于建筑的关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Eq2Bd", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechForArch", "Eq2Bd")
                        }
                    }
                }
                "Eq2Fl" -> {
                    /** 设备服务于楼层的关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Eq2Fl", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechForArch", "Eq2Fl")
                        }
                    }
                }
                "Eq2Sh" -> {
                    /** 设备服务于竖井的关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Eq2Sh", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechForArch", "Eq2Sh")
                        }
                    }
                }
                "EquipforSpace" -> {
                    /** 设备设施服务于业务空间的关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Eq2Sp", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechForArch", "Eq2Sp")
                        }
                        "13" -> { // 清除之前的关系，替换
                            if (message.fromId!!.startsWith("Eq")){
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                equipInSpaceSync.addRelSuperposition(message,ids,"MechForArch","Eq2Sp")

                            } else if (message.fromId!!.startsWith("Sp")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)

                                equipInSpaceSync.addRelSuperpositionFan(message,ids,"MechForArch","Eq2Sp")
                            }
                        }
                        "14" -> {  // 添加不替换
                            if (message.fromId!!.startsWith("Sp")) {
                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
                                logger.debug("id= ${ids.toJson()}**************************")
                                equipInSpaceSync.equipInSpaceCreate(message,"MechForArch","Eq2Sp",ids)
                            }
                        }
                    }
                }
                "EquipinShaft" -> {
                    /** 设备所在竖井的关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechInArch", "Eq2Sh", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechInArch", "Eq2Sh")
                        }
                    }
                }
                "Fl2Fl" -> {
                    /** 楼层贯通关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ThroughRelationship", "Fl2Fl", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ThroughRelationship", "Fl2Fl")
                        }
                    }
                }
                "Sh2Sh" -> {
                    /** 竖井贯通关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ThroughRelationship", "Sh2Sh", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ThroughRelationship", "Sh2Sh")
                        }
                    }
                }
                "sy2sp_for" -> {
                    /** 系统服务于业务空间 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Sy2Sp", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechForArch", "Sy2Sp")
                        }
                    }
                }
                "sy2sh_for" -> {
                    /** 系统服务于竖井 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Sy2Sh", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechForArch", "Sy2Sh")
                        }
                    }
                }
                "sy2fl_for" ->{
                    /** 系统服务于楼层 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Sy2Fl", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechForArch", "Sy2Fl")
                        }
                    }
                }
                "sy2bd_for" -> {
                    /** 系统服务于建筑体 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Sy2Bd", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechForArch", "Sy2Bd")
                        }
                    }
                }
                "sp2sp_ConvectionNetwork_1" ->{
                    /**空间 空气自然对流 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ConvectionNetwork", "Natural", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ConvectionNetwork", "Natural")
                        }
                        "20" -> {
                            /** 计算 */
                            automaticCalculationSync.sp2SpConvectionNetwork01(message)
                        }
                    }
                }
                "sp2sp_ConvectionNetwork_2" ->{
                    /** 空气混合机械通风 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ConvectionNetwork", "MixMech", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ConvectionNetwork", "MixMech")
                        }
                    }
                }
                "sp2sp_ConvectionNetwork_3" -> {
                    /** 空气单向机械通风 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ConvectionNetwork", "OnewayMech", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ConvectionNetwork", "OnewayMech")
                        }
                    }
                }
                "sp2sp_SpaceNeighborhood_5" ->{
                    /** 空间连通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "SpaceNeighborhood", "Connect", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "SpaceNeighborhood", "Connect")
                        }
                        "20" -> {
                            /** 计算 */
                            automaticCalculationSync.sp2SpSpaceNeighborhood5(message)
                        }
                    }
                }
                "sp2sp_SpaceNeighborhood_2" -> {
                    /** 空间隔断有门 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "SpaceNeighborhood", "Door", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "SpaceNeighborhood", "Door")
                        }
                    }
                }
                "sp2sp_SpaceNeighborhood_4" -> {
                    /** 空间隔断有门窗 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "SpaceNeighborhood", "DoorWindow", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "SpaceNeighborhood", "DoorWindow")
                        }
                    }
                }
                "sp2sp_TrafficNetwork_3" -> {
                    /** 空间消防常关交通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "TrafficNetwork", "FFClose", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "TrafficNetwork", "FFClose")
                        }
                    }
                }
                "sp2sp_TrafficNetwork_2" -> {
                    /** 空间 消防常开交通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "TrafficNetwork", "FFOpen", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "TrafficNetwork", "FFOpen")
                        }
                    }
                }
                "sp2sp_RadiationNetwork_1" -> {
                    /** 空间光照连通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "RadiationNetwork", "Connect", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "RadiationNetwork", "Connect")
                        }
                        "20" -> {
                            /** 计算 */
                            automaticCalculationSync.sp2SpRadiationNetwork1(message)
                        }
                    }
                }
                "sp2sp_RadiationNetwork_2" -> {
                    /** 空间光照透明隔断 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "RadiationNetwork", "Transparent", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "RadiationNetwork", "Transparent")
                        }
                    }
                }
                "sp2sp_SpaceNeighborhood_1" -> {
                    /** 空间隔断无门窗 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "SpaceNeighborhood", "None", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "SpaceNeighborhood", "None")
                        }
                    }
                }
                "sp2sp_TrafficNetwork_1" -> {
                    /** 普通交通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "TrafficNetwork", "Normal", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "TrafficNetwork", "Normal")
                        }
                        "20" -> {
                            /** 计算 */
                            automaticCalculationSync.sp2SpTrafficNetwork1(message)
                        }
                    }
                }
                "sp2sp_SpaceNeighborhood_3" -> {
                    /** 空间隔断有窗 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "SpaceNeighborhood", "Window", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "SpaceNeighborhood", "Window")
                        }
                    }
                }
                "eq2eq_LUDistribution_1" -> {
                    /** 低压配电普通连接 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "LUDistribution", "Normal", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "LUDistribution", "Normal")
                        }
                    }
                }
                "eq2eq_LUDistribution_2" ->{
                    /** 低压配电互备连接 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "LUDistribution", "Backup", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "LUDistribution", "Backup")
                        }
                    }
                }
                "eq2eq_HUDistribution_1" ->{
                    /** 高压变配电普通连接 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "HUDistribution", "Normal", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "HUDistribution", "Normal")
                        }
                    }
                }
                "eq2eq_HUDistribution_2" ->{
                    /** 高压变配电互备连接 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "HUDistribution", "Backup", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "HUDistribution", "Backup")
                        }
                    }
                }
                "eq2eq_EquipPower_1" ->{
                    /** 设备常规电源 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechPower", "EqNormal", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechPower", "EqNormal")
                        }
                    }
                }
                "eq2eq_EquipPower_2" ->{
                    /** 设备备用电源 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechPower", "EqBackup", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechPower", "EqBackup")
                        }
                    }
                }
                "eq2eq_EquipPower_3" ->{
                    /** 系统常规电源 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechPower", "SyNormal", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechPower", "SyNormal")
                        }
                    }
                }
                "eq2eq_EquipPower_4" ->{
                    /** 系统备用电源 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechPower", "SyBackup", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechPower", "SyBackup")
                        }
                    }
                }
                "eq2eq_ACAirNetwork_1" ->{
                    /** 空调送风 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ACAirNetwork", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ACAirNetwork", "Supply")
                        }
                    }
                }
                "eq2eq_ACAirNetwork_3" ->{
                    /** 空调排风 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ACAirNetwork", "Discharge", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ACAirNetwork", "Discharge")
                        }
                    }
                }
                "eq2eq_ACAirNetwork_2" ->{
                    /** 空调回风 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ACAirNetwork", "Return", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ACAirNetwork", "Return")
                        }
                    }
                }
                "eq2eq_ChillWaterLoop_4" ->{
                    /** 空调冷冻水补水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ChillWaterLoop", "Fill", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ChillWaterLoop", "Fill")
                        }
                    }
                }
                "eq2eq_ChillWaterLoop_1" -> {
                    /** 空调冷冻水供水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ChillWaterLoop", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ChillWaterLoop", "Supply")
                        }
                    }
                }
                "eq2eq_ChillWaterLoop_3" ->{
                    /** 空调冷冻水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ChillWaterLoop", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ChillWaterLoop", "Bypass")
                        }
                    }
                }
                "eq2eq_ChillWaterLoop_2" -> {
                    /**  空调冷冻水回水 *********************************************************************************/
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ChillWaterLoop", "Return", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ChillWaterLoop", "Return")
                        }
                    }
                }
                "eq2eq_CondWaterNetwork_1" -> {
                    /** 空调冷凝水网络   空调冷凝水排水*/
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "CondWaterNetwork", "Discharge", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "CondWaterNetwork", "Discharge")
                        }
                    }
                }
                "eq2eq_CoolingWaterLoop_4" -> {
                    /** 空调冷却水补水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "CoolingWaterLoop", "Fill", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "CoolingWaterLoop", "Fill")
                        }
                    }
                }
                "eq2eq_CoolingWaterLoop_1" ->{
                    /** 空调冷却水供水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "CoolingWaterLoop", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "CoolingWaterLoop", "Supply")
                        }
                    }
                }
                "eq2eq_CoolingWaterLoop_3" -> {
                    /** 空调冷却水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "CoolingWaterLoop", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "CoolingWaterLoop", "Bypass")
                        }
                    }
                }
                "eq2eq_CoolingWaterLoop_2" -> {
                    /** 空调冷却水回水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "CoolingWaterLoop", "Return", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "CoolingWaterLoop", "Return")
                        }
                    }
                }
                "eq2eqFreshAirNetwork_1" -> {
                    /** 新风管网 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "FreshAirNetwork", "Fresh", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "FreshAirNetwork", "Fresh")
                        }
                    }
                }
                "eq2eq_HeatWaterLoop_4" -> {
                    /** 采暖水回水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "HeatWaterLoop", "Return", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "HeatWaterLoop", "Return")
                        }
                    }
                }
                "eq2eq_HeatWaterLoop_1" -> {
                    /** 采暖水供水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "HeatWaterLoop", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "HeatWaterLoop", "Supply")
                        }
                    }
                }
                "eq2eq_HeatWaterLoop_3" ->{
                    /** 采暖水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "HeatWaterLoop", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "HeatWaterLoop", "Bypass")
                        }
                    }
                }
                "eq2eq_HeatWaterLoop_2" ->{
                    /** 采暖水回水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "HeatWaterLoop", "Return", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "HeatWaterLoop", "Return")
                        }
                    }
                }
                "eq2eq_VentNetwork_1" -> {
                    /** 通风送风 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "VentNetwork", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "VentNetwork", "Supply")
                        }
                    }
                }
                "eq2eq_VentNetwork_3" ->{
                    /** 通风不确定 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "VentNetwork", "Uncertain", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "VentNetwork", "Uncertain")
                        }
                    }
                }
                "eq2eq_VentNetwork_2" ->{
                    /** 通风排风 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "VentNetwork", "Discharge", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "VentNetwork", "Discharge")
                        }
                    }
                }
                "eq2eq_VRFNetwork_1" -> {
                    /** 多联机供回制冷剂 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "VRFNetwork", "SupplyReturn", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "VRFNetwork", "SupplyReturn")
                        }
                    }
                }
                "eq2eq_SupplyWaterNetwork_1" ->{
                    /** 生活给水供水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "DomesticWaterNetwork", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "DomesticWaterNetwork", "Supply")
                        }
                    }
                }
                "eq2eq_SupplyWaterNetwork_2" -> {
                    /** 生活给水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "DomesticWaterNetwork", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "DomesticWaterNetwork", "Bypass")
                        }
                    }
                }
                "eq2eq_DrainingWaterNetwork_1" -> {
                    /** 污水排水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "DrainingWaterNetwork", "Discharge", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "DrainingWaterNetwork", "Discharge")
                        }
                    }
                }
                "eq2eq_DrainingWaterNetwork_2" -> {
                    /** 污水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "DrainingWaterNetwork", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "DrainingWaterNetwork", "Bypass")
                        }
                    }
                }
                "eq2eq_DrinkingWaterNetwork_1" -> {
                    /** 直饮水供水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "DrinkingWaterNetwork", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "DrinkingWaterNetwork", "Supply")
                        }
                    }
                }
                "eq2eq_DrinkingWaterNetwork_2" -> {
                    /** 直饮水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "DrinkingWaterNetwork", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "DrinkingWaterNetwork", "Bypass")
                        }
                    }
                }
                "eq2eq_DHWNetwork_1" -> {
                    /** 生活热水供水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "DHWNetwork", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "DHWNetwork", "Supply")
                        }
                    }
                }
                "eq2eq_DHWNetwork_2" -> {
                    /** 生活热水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "DHWNetwork", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "DHWNetwork", "Bypass")
                        }
                    }
                }
                "eq2eq_GasNetwork_1" -> {
                    /** 燃气供气 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "GasNetwork", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "GasNetwork", "Supply")
                        }
                    }
                }
                "eq2eq_GasNetwork_2" -> {
                    /** 燃气旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "GasNetwork", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "GasNetwork", "Bypass")
                        }
                    }
                }
                "eq2eq_FireWaterNetwork_1" -> {
                    /** 消防供水网络    消防给水旁通*/
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "FireWaterNetwork", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "FireWaterNetwork", "Bypass")
                        }
                    }
                }
                "eq2eq_FireWaterNetwork_2" -> {
                    /** 消防给水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "FireWaterNetwork", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "FireWaterNetwork", "Bypass")
                        }
                    }
                }
                "eq2eq_FireVentNetwork_1" -> {
                    /** 消防排烟 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "FireVentNetwork", "Discharge", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "FireVentNetwork", "Discharge")
                        }
                    }
                }
                "eq2eq_RecycleWaterNetwork_1" ->{
                    /** 中水供水 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "RecycleWaterNetwork", "Supply", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "RecycleWaterNetwork", "Supply")
                        }
                    }
                }
                "eq2eq_RecycleWaterNetwork_2" -> {
                    /** 中水旁通 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "RecycleWaterNetwork", "Bypass", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "RecycleWaterNetwork", "Bypass")
                        }
                    }
                }
                "eq2eq_SensorNetwork_1" -> {
                    /** 通信连接  新名称 弱电通信连接  */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "WENetwork", "Normal", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "WENetwork", "Normal")
                        }
                    }
                }
                "eq2eq_ControlRelation_1" -> {
                    /** 设备控制关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechCtrl", "EqCtrl", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechCtrl", "EqCtrl")
                        }
                        "20" -> {
                            automaticCalculationSync.eq2eqControlRelation1(message)
                        }
                    }
                }
                "eq2eq_SensorRelationship_ss2eq" -> {
                    /** 传感器测量设备关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "SensorRelationship", "Ss2Eq", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "SensorRelationship", "Ss2Eq")
                        }
                        "20" -> {
                            /** 计算 */
                            automaticCalculationSync.eq2EqSensorRelationshipSs2eq(message)
                        }
                    }
                }
                "eq2eq_ValveRelationship_vv2eq" -> {
                    /** 阀门限制设备关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ValveRelationship", "Vv2Eq", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ValveRelationship", "Vv2Eq")
                        }
                    }
                }
                "eq2eq_ControlEquipNetwork" -> {
                    /** 暂不同步 */
                }
                "eq2eq_ControlRelation_2" -> {
                    /** 系统控制关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "MechCtrl", "SyCtrl", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "MechCtrl", "SyCtrl")
                        }
                    }
                }
                "eq2sy_SensorRelationship_ss2sy" -> {
                    /** 传感器测量系统关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "SensorRelationship", "Ss2Sy", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "SensorRelationship", "Ss2Sy")
                        }
                    }
                }
                "eq2sy_ValveRelationship_vv2sy" -> {
                    /** 阀门限制系统关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "ValveRelationship", "Vv2Sy", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "ValveRelationship", "Vv2Sy")
                        }
                    }
                }
                "eq2sp_SensorRelationship_ss2sp" -> {
                    /** 传感器测量空间关系 */
                    when(message.ops) {

                        "11" -> { // 创建关系
                            equipInSpaceSync.equipInSpaceCreate(message, "SensorRelationship", "Ss2Sp", null)
                        }
                        "12" -> { // 删除关系
                            equipInSpaceSync.delRel(message, "SensorRelationship", "Ss2Sp")
                        }
                        "20" ->{
                            automaticCalculationSync.eq2SpSensorRelationshipSs2sp(message)
                        }
                    }
                }
                "eq2sp_x" -> { /** 暂不同步 */
                    /** 设备空间其他关系 */
//                    when(message.ops) {
//
//                        "11" -> { // 创建关系
//                            equipInSpaceSync.equipInSpaceCreate(message, "MechSubset", "Sy2Eq", null)
//                        }
//                        "12" -> { // 删除关系
//                            equipInSpaceSync.delRel(message, "MechSubset", "Sy2Eq")
//                        }
//                    }

                }
                "Eq2Bd_in" -> {
                    /** 设备设施服务于建筑 */
                    when(message.ops){
                        "20" -> {
                            automaticCalculationSync.eq2BdFor(message)
                        }
                    }
                }
                "Eq2Sh_in" -> {
                    /** 设备设施所在竖井 */
                    when(message.ops){
                        "20" -> {
                            automaticCalculationSync.eq2ShIn(message)
                        }
                    }
                }
                "Eq2Sp_in" ->{
                    /** 设备设施所在空间 */
                    when(message.ops){
                        "20" -> {
                            automaticCalculationSync.eq2SpIn(message)
                        }
                    }
                }
                "Fl2Fl_Through" -> {
                    /** 楼层贯通关系 */
                    when(message.ops){
                        "20" -> {
                            automaticCalculationSync.fl2FlThrough(message)
                        }
                    }
                }
                "Fl2Sp_in" -> {
                    /** 楼层下的业务空间 */
                    when(message.ops){
                        "20" -> {
                            automaticCalculationSync.fl2SpIn(message)
                        }
                    }

                }
                "Bd2Sh_in" -> {
                    /** 建筑下的竖井 */
                    when(message.ops){
                        "20" -> {
                            automaticCalculationSync.bd2ShIn(message)
                        }
                    }
                }
                "Sh2Sh_Through" -> {
                    /** 竖井贯通 */
                    when(message.ops) {
                        "20" -> {
                            automaticCalculationSync.sh2ShThrough(message)
                        }
                    }

                }
                "syeq2bd" -> {
                    /** 建筑下的系统设备部件 */
                    when(message.ops) {
                        "20" -> {
                            automaticCalculationSync.syeq2bd(message)
                        }
                    }
                }
                "Sy2Fl_in" -> {
                    /** 系统所在楼层 */
                    when(message.ops) {
                        "20" -> {
                            automaticCalculationSync.sy2FlIn(message)
                        }
                    }

                }
                "Sy2Sh_in" -> {
                    /** 系统所在竖井 */
                    when(message.ops) {
                        "20" -> {
                            automaticCalculationSync.sy2ShIn(message)
                        }
                    }
                }
                "Sy2Sp_in" -> {
                    /** 系统所在业务空间 */
                    when(message.ops) {
                        "20" -> {
                            automaticCalculationSync.sy2SpIn(message)
                        }
                    }

                }
                "fengkou_for" -> {
                    /** 风口（空调风口、通风风口） 服务  */
                    when(message.ops) {
                        "20" -> {
                            automaticCalculationSync.fengkouFor(message)
                        }
                    }
                }

            }
        }
    }


}