package com.sky.ioc.mapper;

import com.sky.ioc.entity.domain.canteen.Order;
import com.sky.ioc.entity.domain.space.BuildingSpace;
import com.sky.ioc.entity.params.IocParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MeetingMapper {

    @Select("<script>" +
            "SELECT coalesce(avg(used),0)  " +
            "FROM meeting where 1=1 " +
            "<if test='iocParam!=null and iocParam.floorId != null  '>" +
            " and floor_id=#{iocParam.floorId} " +
            "</if>"+
            "</script>")
    Double getUsedByFloorId(@Param("iocParam")IocParam iocParam);

    @Select("<script>" +
            "SELECT coalesce(avg(saturation),0) " +
            "FROM meeting where 1=1 " +
            "<if test='iocParam!=null and iocParam.floorId != null  '>" +
            " and floor_id=#{iocParam.floorId} " +
            "</if>"+
            "</script>")
    Double getSaturationByFloorId(@Param("iocParam")IocParam iocParam);

    @Select("<script>" +
            "SELECT  coalesce(sum(cost),0) " +
            "FROM meeting where 1=1 " +
            "<if test='iocParam!=null and iocParam.floorId != null  '>" +
            " and floor_id=#{iocParam.floorId} " +
            "</if>"+
            "</script>")
    Double getCostByFloorId(@Param("iocParam")IocParam iocParam);

    @Select("<script>" +
            "SELECT  coalesce(sum(person_cost),0)  " +
            "FROM meeting where 1=1 " +
            "<if test='iocParam!=null and iocParam.floorId != null  '>" +
            " and floor_id=#{iocParam.floorId} " +
            "</if>"+
            "</script>")
    Double getPersonCostByFloorId(@Param("iocParam")IocParam iocParam);

}
