<?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.rongwei.bscommon.sys.dao.EquOverhaulPlanningTasksMapperDao">

    <select id="selectAllOverdueTaskQuantity" resultType="com.rongwei.bsentity.domain.EquOverhaulPlanningTasksVo">
        SELECT
        ID,PLANYEAR,TENANTID,BELONGFACTORY,count(TENANTID) 'TASKQUANTITY'
        FROM
        equ_overhaul_planning_tasks
        WHERE
        PLANSTARTTIME >= DATE( NOW( ) ) - INTERVAL 1 YEAR
        AND DATE( NOW( ) ) >= PLANENDTIME
        AND TASKSTATUS in (10,30,70,15)
        AND DELETED = 0
        GROUP BY TENANTID
        HAVING count(TENANTID) > 1
    </select>

    <select id="selectTasksByFactoryId" resultType="com.rongwei.bsentity.domain.EquOverhaulPlanningTasksVo">
        SELECT
         *
        FROM
        equ_overhaul_planning_tasks
        WHERE
        PLANSTARTTIME >= DATE( NOW( ) ) - INTERVAL 1 YEAR
        AND DATE( NOW( ) ) >= PLANENDTIME
        AND TASKSTATUS in (10,30,70,15)
        AND DELETED = 0
        <if test="tenantId != null and tenantId != ''"> and TENANTID = #{tenantId}</if>
    </select>

</mapper>
