package com.persagy.server.services.rel

import com.persagy.server.synchronize.MessageHandler
import com.persagy.server.datacenter.models.entities.rel.REq2Sp
import com.persagy.mybatis.SMybatisDao
import com.persagy.service.SObjectService
import com.persagy.service.SPageContext
import com.persagy.service.utils.SSpringContextUtil
import org.json.JSONObject

object REq2SpService: SObjectService<REq2Sp>(SMybatisDao(REq2Sp::class.java)) {

    /** MQ消息对象 */
    val messageHandler by lazy {
        SSpringContextUtil.getBean(MessageHandler::class.java) as MessageHandler
    }

    override fun onDeleteSuccess(rEqInSpZoneLightingList: ArrayList<REq2Sp>) {
        val projectId = SPageContext.getHeader("ProjectId")
        for(rEqInSpZoneLighting in rEqInSpZoneLightingList){
            val jsonObject = JSONObject()
            jsonObject.put("type", "12")
            jsonObject.put("projectId", projectId)
            jsonObject.put("id", rEqInSpZoneLighting.id2)
            jsonObject.put("obj_type", "EquipinSpace")
            jsonObject.put("linkId",rEqInSpZoneLighting.id1)

            /** 发送消息 */
            messageHandler.sendMessage(jsonObject.toString())
//            kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipinSpace", "12", IdUtils.uuidCreate(), rEqInSpZoneLighting.spaceId!!, rEqInSpZoneLighting.equipId),false)
        }
    } // Fun onDeleteSuccess

} //  Object REq2SpService