package com.fs.his.mapper;

import java.util.List;
import com.fs.his.domain.FsDrugReportCount;
import com.fs.his.domain.FsFollowReport;
import com.fs.his.param.FsDrugReportCountParam;
import com.fs.his.vo.FsDrugReportCountListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 咨询统计Mapper接口
 *
 * @author fs
 * @date 2024-04-23
 */
public interface FsDrugReportCountMapper
{
    /**
     * 查询咨询统计
     *
     * @param id 咨询统计主键
     * @return 咨询统计
     */
    public FsDrugReportCount selectFsDrugReportCountById(Long id);

    /**
     * 查询咨询统计列表
     *
     * @param fsDrugReportCount 咨询统计
     * @return 咨询统计集合
     */
    public List<FsDrugReportCount> selectFsDrugReportCountList(FsDrugReportCount fsDrugReportCount);

    /**
     * 新增咨询统计
     *
     * @param fsDrugReportCount 咨询统计
     * @return 结果
     */
    public int insertFsDrugReportCount(FsDrugReportCount fsDrugReportCount);

    /**
     * 修改咨询统计
     *
     * @param fsDrugReportCount 咨询统计
     * @return 结果
     */
    public int updateFsDrugReportCount(FsDrugReportCount fsDrugReportCount);

    /**
     * 删除咨询统计
     *
     * @param id 咨询统计主键
     * @return 结果
     */
    public int deleteFsDrugReportCountById(Long id);

    /**
     * 批量删除咨询统计
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsDrugReportCountByIds(Long[] ids);

    @Select({"<script> "+
            "select * from fs_drug_report_count  where user_id=#{userId} and doctor_id=#{doctorId}  and `month`=#{moth} "+
            "<if test=\"companyId != null and companyId != ''\"> and company_id = #{companyId}</if>\n"+
            "<if test=\"companyId == null or companyId == '' \"> and company_id is null </if>\n"+
            "</script>"})
    FsDrugReportCount selectFsFollowReportByCompanyIdAndUseridAndDoctorId(@Param("userId")long userId, @Param("doctorId") long doctorId, @Param("companyId") Long companyId, @Param("moth") String moth);
    @Select({"<script> " +
            "select fr.*,c.company_name,s.store_name,u.nick_name,u.phone from fs_drug_report_count fr LEFT JOIN company c  ON c.company_id=fr.company_id LEFT JOIN fs_store s ON s.store_id=fr.store_id " +
            " LEFT JOIN fs_user u ON u.user_id=fr.user_id " +
            "<where>\n" +
            "            <if test=\"userId != null \"> and fr.user_id = #{userId}</if>\n" +
            "            <if test=\"patientName != null  and patientName != ''\"> and fr.patient_name like concat( #{patientName}, '%')</if>\n" +
            "            <if test=\"doctorId != null \"> and fr.doctor_id = #{doctorId}</if>\n" +
            "            <if test=\"doctorAccount != null  and doctorAccount != ''\"> and fr.doctor_account = #{doctorAccount}</if>\n" +
            "            <if test=\"doctorName != null  and doctorName != ''\"> and fr.doctor_name like concat( #{doctorName}, '%')</if>\n" +
            "            <if test=\"companyId != null \"> and fr.company_id = #{companyId}</if>\n" +
            "            <if test=\"storeId != null \"> and fr.store_id = #{storeId}</if>\n" +
            "            <if test=\"count != null \"> and fr.count = #{count}</if>\n" +
            "            <if test=\"month != null \"> and fr.month = #{month}</if>\n" +
            "            <if test=\"phone != null \"> and u.phone like concat( #{phone}, '%')</if>\n" +
            "        </where> order by id desc"+
            "</script>"})
    List<FsDrugReportCountListVO> selectFsDrugReportCountListVO(FsDrugReportCountParam fsDrugReportCount);

}
