/*
 * *********************************************************************************************************************
 *
 *          !!
 *        .F88X
 *        X8888Y
 *      .}888888N;
 *        i888888N;        .:!              .I$WI:
 *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
 *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
 *            +888888N;  .8888888Y                                  "&&8Y.}8,
 *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
 *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
 *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
 *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
 *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
 *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
 *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
 *      .:R888888I
 *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
 *        ~8888'
 *        .!88~                                                                     All rights reserved.
 *
 * *********************************************************************************************************************
 */

package com.persagy.server.controllers

import com.persagy.server.datacenter.models.entities.objects.Equipment
import com.persagy.server.datacenter.models.entities.objects.GeneralSystem
import com.persagy.server.datacenter.models.entities.objects.ZoneIspace
import com.persagy.server.datacenter.models.entities.objects.ZoneSpace
import com.persagy.server.datacenter.models.requests.UpZoneSpaceBaseRequest
import com.persagy.server.models.requests.ZoneISpaceQueryRequest
import com.persagy.server.service.objects.*
import com.persagy.service.models.requests.SQueryRequest
import com.persagy.service.models.requests.SUpdateRequest
import com.persagy.service.models.responses.SBaseResponse
import com.persagy.service.models.responses.SQueryResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * 空间接口
 *
 * @author 张维新
 */
@Tag(name = "空间相关接口")
@RestController
@RequestMapping("/space")
class SpaceController {

    @Autowired
    lateinit var service: ZoneSpaceService

    /**
     * 查询没有和当前空间绑定的系统
     *
     * @param   type        空间类型
     * @param   spaceId     空间id
     */
   @Operation(summary="查询没有和当前空间绑定的系统", description= "例如：prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 " +
            "spaceId 为当前空间id type为当前空间类型 ")
    @PostMapping(value = ["/unspace-in-sys"])
    fun unSpaceSys( type: String, spaceId: String,@RequestBody request: SQueryRequest): SQueryResponse<GeneralSystem> {
        return GeneralSystemService.unSpaceSys(type,spaceId, request)
    } // Function unSpaceSys()

   @Operation(summary="查询没有和当前空间绑定的设备", description ="例如：prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 " +
            "spaceId 为当前空间id type为当前空间类型 ")
    @PostMapping(value = ["/unspace-in-eq"])
    fun  unSpaceEq(type: String, spaceId: String,@RequestBody request: SQueryRequest): SQueryResponse<Equipment> {
        return EquipmentService.pageQueryEquip(type,spaceId,request)
    } // Function unSpaceEq()

   @Operation(summary="查询没有服务于当前空间的设备", description ="例如：prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 " +
            "spaceId 为当前空间id type为当前空间类型 ")
    @PostMapping(value = ["/unspace-for-eq"])
    fun  unSpaceForEq(type: String, spaceId: String,@RequestBody request: SQueryRequest): SQueryResponse<Equipment> {
        return EquipmentService.pageQueryForEquip(type,spaceId,request)
    } // Function unSpaceEq()

    /**
     * 空间内没有服务于当前空间的设备 根据坐标计算
     */
   @Operation(summary=" 空间内没有服务于当前空间的设备 根据坐标计算", description ="")
    @PostMapping(value = ["/unspace-for-eq-point"])
    fun unSpaceForEqPoint(type: String, spaceId: String,@RequestBody request: SQueryRequest): SQueryResponse<Equipment> {
        return  EquipmentService.unSpaceForEqPoint(type,spaceId,request)
    } // Function unSpaceForEqPoint()

    /**
     * 空间内没有和空间关联的设备 根据坐标计算
     */
   @Operation(summary=" 空间内没有和空间关联的设备 根据坐标计算", description ="")
    @PostMapping(value = ["/unspace-fIn-eq-point"])
    fun unSpaceInEqPoint(type: String, spaceId: String,@RequestBody request: SQueryRequest): SQueryResponse<Equipment> {
        return  EquipmentService.unSpaceInEqPoint(type,spaceId,request)
    } // Function unSpaceForEqPoint()

    /**
     * 未关联业务空间的元空间
     */
   @Operation(summary=" 未关联业务空间的元空间", description ="")
    @PostMapping(value = ["/unspace-ispace"])
    fun unSpaceIspace(objectType: String, @RequestBody request: ZoneISpaceQueryRequest): SQueryResponse<ZoneIspace> {
        return ISpaceService.unSpaceIspace(objectType,request)
    } // Function unSpaceIspace()

    /**
    * 同一建筑楼层中，包含该位置标签坐标的所有类型的业务空间实例
     * projectId = Pj1101080029
     * x = 148409.372029545
     * y = -200252.644431612
     * {
        "Filters": " buildingId = 'Bd1101080029dddbfba4cdef11e9a316497519c1daff' and floorId = 'Fl110108002946c52d23cf9311e985165f9ca2299edb'",
        "PageNumber": 1,
        "PageSize": 50
       }
    */
   @Operation(summary="同一建筑楼层中，包含该位置标签坐标的所有类型的业务空间实例", description ="  projectId = Pj1101080029\n" +
            "      x = 148409.372029545\n" +
            "      y = -200252.644431612\n{\n" +
            "        \"Filters\": \" buildingId = 'Bd1101080029dddbfba4cdef11e9a316497519c1daff' and floorId = 'Fl110108002946c52d23cf9311e985165f9ca2299edb'\",\n" +
            "        \"PageNumber\": 1,\n" +
            "        \"PageSize\": 50\n" +
            "       }")
    @PostMapping(value = ["/in-bdfl-zonespacebase"])
    fun inBdflZoneSpace(X: String, Y: String, @RequestBody request: SQueryRequest): SQueryResponse<ZoneSpace> {
        return service.inBdflZoneSpace(X,Y,request)
    } // Function unSpaceIspace()

    /**
     * 修改空间图片信息
     * @param request 空间信息
     */
   @Operation(summary="修改空间图片信息", description ="（全部必传）ObjectType 空间类型 RoomID，Pic")
    @PostMapping(value = ["/update-space-picinfo"])
    fun updateSpacePicInfo(@RequestBody request: SUpdateRequest<UpZoneSpaceBaseRequest>): SBaseResponse {
        return service.updateSpacePicInfo(request)
    } // Function updateSpacePicInfo

//    /**
//     * 统计 属于多建筑楼层的空间
//     */
//   @Operation(summary="统计 属于多建筑楼层的空间", description ="")
//    @PostMapping(value = ["/space-bd-fl"])
//    fun spaceBdFl(): SCountResponse {
//        return ZoneAirConditioningService.spaceBdFls()
//    } // Function spaceBdFl()

    /**
     * 统计 属于多建筑楼层的空间数据
     */
   @Operation(summary="统计 属于多建筑楼层的空间数据", description ="")
    @PostMapping(value = ["/space-bd-fl-data"])
    fun spaceBdFlObj(@RequestBody request: SQueryRequest): SQueryResponse<ZoneSpace> {
        return ZoneSpaceBaseService.pageQuery(request)
    } // Function spaceBdFl()

    /**
     * 查询元空间关系 邻接关系、建筑交通网络 、 空气流通网络、 光照辐射网络
     */
//   @Operation(summary="查询元空间关系 邻接关系SpaceNeighborhood、建筑交通网络TrafficNetwork 、 空气流通网络ConvectionNetwork、 光照辐射网络RadiationNetwork", description ="")
//    @PostMapping(value = ["/space-rel"])
//    fun spatialRelationship(@RequestBody spatialRelationship: SpatialRelationship): SQueryResponse<RSpatialConnection>{
//        return ZoneSpaceBaseService.spatialRelationship(spatialRelationship)
//    }

}  // Class SpaceController