package com.bofeng.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.bofeng.entity.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Mapper
@Repository
public interface RbMapper extends BaseMapper<sysUptownUnit> {

    @Select("select DISTINCT c.report_status as reportStatus,a.house_id as houseId,a.doorplate as doorplate,c.report_id as reportId,c.ms_status as msStatus,b.unit_id as unitId from sys_uptown_house a " +
            "inner join sys_uptown_unit b on a.unit_id = b.unit_id " +
            "inner join sys_owner d on d.uptown_id = b.uptown_id " +
            "inner join sys_user_role e on e.property_id = d.owner_id and e.role_id = 2 " +
            "left join ms_report c on c.house_id = a.house_id and DATE_FORMAT(c.time_update,'%Y-%m-%d') = #{dateStr} " +
            "where b.unit_id = #{str}")
    List<SysUptownHouse> selectMp(@Param("str") Long str,@Param("dateStr") String dateStr);
    // and c.time_update = #{date}

    @Select("select c.ridgepole as ridgepole,c.unit as unit,c.unit_id as unitId from sys_user_role a " +
            "inner join sys_owner b on b.owner_id = a.property_id and a.role_id = 2 " +
            "inner join sys_uptown_unit c on c.uptown_id = b.uptown_id " +
            "where a.user_id = #{userId}")
    List<sysUptownUnit> selectDY(@Param("userId") Long userId);


    @Select("select e.ridgepole as ridgepole,e.unit as unit,b.doorplate as doorplate,a.safety_num as safetyNum,a.sure_num as sureNum,a.suspected_num as suspectedNum," +
            "c.user_name as userName,c.cough as cough,c.muscle as muscle,c.dyspnea as dyspnea," +
            "c.chest as chest,c.fatigue as fatigue,c.diarrhea as diarrhea,c.others as others " +
            "from ms_report a " +
            "inner join sys_uptown_house b on b.house_id = a.house_id " +
            "inner join sys_uptown_unit e on e.unit_id = b.unit_id " +
            "left join ms_suspected c on c.report_id = a.report_id " +
            "where b.house_id = #{houseId} and DATE_FORMAT(a.time_update,'%Y-%m-%d') = #{dateStr}")
    List<MsSuspected> selectYcXq(@Param("houseId") Long houseId, @Param("dateStr") String dateStr);
}
