<?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.bonus.sgzb.app.mapper.AppMapper">


    <select id="getDayLeaseNum" resultType="java.lang.Integer">
        select COALESCE(SUM(pre_num), 0)
        from lease_apply_details
        WHERE create_time &gt;= #{startTime} AND create_time &lt;= #{endTime} AND status in ('1','2')
    </select>
    <select id="getDayBackNum" resultType="java.lang.Integer">
        select COALESCE(sum(pre_num), 0)
        from back_apply_details
        WHERE create_time &gt;= #{startTime} AND create_time &lt;= #{endTime};
    </select>
    <select id="getDayInputNum" resultType="java.lang.Integer">
        select COALESCE(sum(input_num), 0)
        from input_apply_details
        WHERE create_time &gt;= #{startTime} AND create_time &lt;= #{endTime};
    </select>
    <select id="getDayOutNum" resultType="java.lang.Integer">
        select COALESCE(sum(out_num), 0)
        from lease_out_details
        WHERE create_time &gt;= #{startTime} AND create_time &lt;= #{endTime};
    </select>
    <select id="getLeaseNum" resultType="java.lang.Integer">
        select count(1)
        from tm_task
        where task_type = '29' and task_status in ('30','31','32') and status = '1'
    </select>
    <select id="getBackNum" resultType="java.lang.Integer">
        select count(1)
        from tm_task
        where task_type = '36' and task_status = '37' and status = '1'
    </select>
    <select id="getScrapNum" resultType="java.lang.Integer">
        select count(1)
        from tm_task
        where task_type = '57' and task_status = '58' and status = '1'
    </select>
    <select id="getTrialNum" resultType="java.lang.Integer">
        select count(1)
        from tm_task
        where task_type = '45' and task_status = '46' and status = '1'
    </select>
    <select id="getVersion" resultType="com.bonus.sgzb.app.domain.AppVersion">
        SELECT version,
               version_name   as versionName,
               apk_name       AS apkName,
               apk_path       AS apkPath,
               update_content AS updateContent,
               deploy_time    AS deployTime,
               deploy_user    AS deployUser,
               remark
        FROM app_version
        WHERE is_active = '1'
        ORDER BY version + 0 DESC LIMIT 1
    </select>
</mapper>
