<?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.EquMaintenancePredictivePlanDao">

    <select id="queryDateByids" resultType="com.rongwei.bsentity.domain.EquMaintenancePredictivePlanVo">
        SELECT
        a.*,
        DATE_ADD(a.LASTMAINTENANCEDATE, INTERVAL a.FREQUENCY DAY) AS NEXTMAINTENANCEDATE,
        b.NEXTTASKID
        FROM
        equ_maintenance_predictive_plan a
        LEFT JOIN (
        SELECT PREDICTIVEMAINTENANCEPLANID, GROUP_CONCAT(TASKID) AS NEXTTASKID
        FROM equ_maintenance_task
        WHERE DELETED = '0' AND TASKSTATE IN ('20', '70', '30', '15', '10')
        GROUP BY PREDICTIVEMAINTENANCEPLANID
        ) b ON a.ID = b.PREDICTIVEMAINTENANCEPLANID
        <where>
            a.DELETED ='0'
            and  DATEDIFF(DATE_ADD(a.LASTMAINTENANCEDATE, INTERVAL a.FREQUENCY DAY), CURDATE()) &lt; 30
            and b.NEXTTASKID is null and a.ISOUTOFSERVICE='启用'
            <if test="ids != null and ids.size()>0">
                AND a.ID in
                <foreach collection="ids" item="id" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>
</mapper>
