package com.persagy.server.mappers

import com.persagy.server.datacenter.models.entities.graphtype.block.ConnectedBlockSource
import com.persagy.server.datacenter.models.entities.graphtype.block.EquipIdUUIDMap
import com.persagy.server.datacenter.models.entities.task.SpaceType
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.SelectProvider
import org.springframework.stereotype.Repository

@Mapper
@Repository
interface MepSystemMapper {

    /**
     * 根据BIMID获取设备
     *@param projectId 项目id
     *@param tables 参与计算的表的全名称, 带schema名, 以英文逗号隔开
     */
    @SelectProvider(type = RelationProvider::class , method = "getEquipByBimId")
    fun getEquipByBimId(@Param("projectId") projectId: String, @Param("buildingId") buildingId : String?, @Param("mepSystemType") mepSystemType: ArrayList<String>,
                      @Param("bimId") bimId: ArrayList<String>): ArrayList<ConnectedBlockSource>

    /**
     * 获取模型里的设备uuid到数据中心设备的映射
     *@param projectId 项目id
     *@param equipIds 设备uuid集合
     */
    @SelectProvider(type = RelationProvider::class , method = "getEquipIdUUIDMap")
    fun getDCEquipModelEquipMap(@Param("projectId") projectId: String, @Param("equipIds") equipIds : Set<String>): ArrayList<EquipIdUUIDMap>

    /**
     * 获取模型里的部件uuid到数据中心部件的映射
     *@param projectId 项目id
     *@param equipPartIds 部件uuid集合
     */
    @SelectProvider(type = RelationProvider::class , method = "getEquipPartIdUUIDMap")
    fun getDCEquipPartModelEquipPartMap(@Param("projectId") projectId: String, @Param("equipPartIds") equipPartIds : Set<String>): ArrayList<EquipIdUUIDMap>


    @Select("SELECT s.object_type as type,d.name  FROM zone_space_base s LEFT JOIN dict.dict_space_project d ON s.object_type = d.id WHERE s.project_id = #{projectId} AND d.project_id = #{projectId}  GROUP BY object_type, d.name")
    fun getObjectType(projectId: String):ArrayList<SpaceType>


} // Interface MepSystemMapper