<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jcs.api.mapper.SignMapper">


    <select id="queryForPage"
            resultType="com.yeejoin.amos.boot.module.jcs.api.dto.SignDto">
        SELECT
        sign.`sequence_nbr` sequenceNbr,
        sign.name ,
        sign.`job_title` jobTitle,
        sign.`user_id` signUserId,
        sign.type ,
        sign.`biz_org_code` bizOrgCode,
        sign.`biz_org_name` bizOrgName,
        sign.`sign_time` signTime,
        sign.remarks
        FROM
        cb_sign sign
        <where>
            <if test="dto.name!=null and dto.name!=''">
                and sign.`name` like CONCAT('%',#{dto.name},'%')
            </if>
            <if test="dto.type!=null and dto.type!=''">
                and sign.type=#{dto.type}
            </if>
            <if test="dto.signTimeBIGGER!=null and dto.signTimeBIGGER!=''">
                and sign.sign_time >= #{dto.signTimeBIGGER}
            </if>
            <if test="dto.bizOrgName!=null and dto.bizOrgName!=''">
                and sign.biz_org_Name like CONCAT('%',#{dto.bizOrgName},'%')
            </if>
            <if test="dto.signTimeLESS!=null and dto.signTimeLESS!=''">
                and #{dto.signTimeLESS} >= sign.sign_time
            </if>
            <if test="dto.bizOrgCode!=null and dto.bizOrgCode!=''">
                and sign.biz_org_code like CONCAT(#{dto.bizOrgCode},'%')
            </if>
            <if test="dto.date!=null and dto.date!=''">
                and sign.date= #{dto.date}
            </if>
        </where>
        order by sign.rec_date desc
    </select>
    <select id="queryStaticForPage" resultType="com.yeejoin.amos.boot.module.jcs.api.dto.SinStaticDto">

        select date,count(userId) signNum,bizOrgName,bizOrgCode,personOfDay from (
        SELECT
        DISTINCT sign.user_id  userId,
        date,
        biz_org_Name bizOrgName,
        biz_org_code bizOrgCode,
        person_of_day personOfDay
        FROM
        cb_sign sign
        <where>
            <if test="dto.dateBIGGER!=null and dto.dateBIGGER!=''">
                and sign.sign_time >= #{dto.dateBIGGER}
            </if>
            <if test="dto.dateLESS!=null and dto.dateLESS!=''">
                and #{dto.dateLESS} >= sign.sign_time
            </if>
            <if test="dto.bizOrgCode!=null and dto.bizOrgCode!=''">
                and sign.biz_org_code like CONCAT(#{dto.bizOrgCode},'%')
            </if>
            <if test="dto.bizOrgName!=null and dto.bizOrgName!=''">
                and sign.biz_org_Name like CONCAT(#{dto.bizOrgName},'%')
            </if>
        </where>
        group by
        date,
        biz_org_code,
        user_id
        order by
        sign.sign_time desc
        )  s  group by date,bizOrgCode
    </select>
    <select id="queryPersonNum" resultType="java.lang.Integer">
        select count(*) from cb_firefighters where biz_org_code  like CONCAT('%',#{bizOgrCode}, '%') AND people_type = '1601'
           AND is_delete = 0 AND now()  > rec_date
    </select>

<!--    <select id="getSignStatistic" resultType="Map">-->

<!--    </select>-->
</mapper>
