<?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.testor.module.mq.dao.WeatherDao">
    <select id="getInfoByList" parameterType="java.lang.String" resultType="com.testor.module.mq.vo.WeatherWarnInfoVO">
        select   id, signal_type_code as code,record_time as warnTime,sender,signal_level_code as colorMsg,sender_area_code as
        areaCode from t_weather_notice
        <where>
            record_time>=#{date}
            <if test="list != null and list.size()>0">
                AND sender_area_code IN
                <foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
        order by record_time desc
    </select>

    <select id="getInfoByListTemp" parameterType="java.lang.String" resultType="com.testor.module.mq.vo.WeatherWarnInfoVO">
        select   id, signal_type_code as code,record_time as warnTime,sender,signal_level_code as colorMsg,sender_area_code as
        areaCode from t_weather_notice
        order by record_time desc
        limit 50
    </select>


    <select id="selectDirct" resultType="java.lang.String">
        select message
        from t_weather_dict
        where code = #{code}
    </select>
    <select id="numberOfUsers" resultType="java.lang.Integer">
        SELECT COUNT(tsu.user_id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_sys_user AS tsu ON tso.org_id = tsu.org_id AND tsu.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="dutyLogQuantity" resultType="java.lang.Integer">

        SELECT COUNT(tsdl.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_sys_duty_log AS tsdl ON tso.org_id = tsdl.company_id AND tsdl.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfRiskSources" resultType="java.lang.Integer">
        SELECT COUNT(tsrs.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_safe_risk_source AS tsrs ON tso.org_id = tsrs.org_id AND tsrs.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfRiskPoints" resultType="java.lang.Integer">
        SELECT COUNT(tsrp.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_safe_risk_point AS tsrp ON tso.org_id = tsrp.org_id AND tsrp.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="theNumberOfHiddenLedger" resultType="java.lang.Integer">
        SELECT COUNT(tsho.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_safe_hazard_org AS tsho ON tso.org_id = tsho.org_id AND tsho.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfMonitoringDevices" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_video_equipment_info t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="totalAlarm" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_global_alarm t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfHazardousOperations" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_job_statistics t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfInterestedParties" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_partner_org_res t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfRelevantPartyPersonnel" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_partner_staff t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>

    <select id="numberOfEmergencyPlans" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_contingency_plan t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfStaffTraining" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_train_my_management t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="trisimultaneousQuantity" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_three_time t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="energyConservationQuantity" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_environment_monthly t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfBrightSpots" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_fives_tool_use t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfAccidents" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_accident_report t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="quantityOfAnnouncement" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_sys_notice t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="newsQuantity" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_sys_news t
                           on tso.org_id = t.release_org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="numberOfRentalWarehouses" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_lease_bank t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="equipmentLedgerEntryQuantity" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_safe_equipment t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="spaceLedgerEntryQuantity" resultType="java.lang.Integer">
        SELECT count(t.id)
        FROM t_sys_org AS tso
                 LEFT JOIN t_safe_space t
                           on tso.org_id = t.org_id and t.status = '0'
        WHERE tso.org_id = #{orgId}
        GROUP BY tso.org_id, tso.org_name;
    </select>
    <select id="selectToDoList" resultType="java.lang.Integer" parameterType="com.tongtech.tfw.workflow.apis.task.model.dto.TodoTaskSqlParam">
        SELECT DISTINCT
        count(task.ID_)
        FROM
        act_ru_task task
        LEFT JOIN
        act_hi_procinst hiproc ON task.PROC_INST_ID_ = hiproc.PROC_INST_ID_
        LEFT JOIN
        act_re_procdef procdef ON task.PROC_DEF_ID_ = procdef.ID_
        LEFT JOIN
        act_ru_identitylink idl ON task.ID_ = idl.TASK_ID_
        LEFT JOIN
        act_id_user usr ON hiproc.START_USER_ID_ = usr.ID_
        WHERE
        ((task.ASSIGNEE_ = #{todo.userId})
        OR (
        task.ASSIGNEE_ IS NULL and idl.USER_ID_ = #{todo.userId}
        OR (task.ASSIGNEE_ IS NULL and idl.GROUP_ID_ IN (SELECT
        g1.GROUP_ID_
        FROM
        act_id_membership g1
        WHERE
        g1.user_id_ = #{todo.userId}))
        ))
        ORDER BY task.CREATE_TIME_ desc
    </select>
</mapper>
