|  |  | 
 |  |  |         AND `a`.`SALESORDER` like concat('%',#{salesorder},'%') | 
 |  |  |       </if> | 
 |  |  |       <if test="startDateStart != null and startDateStart != ''"> | 
 |  |  |         AND `a`.`START_DATE` >= concat(#{planDateStart},' 00:00:00') | 
 |  |  |         AND `a`.`START_DATE` >= concat(#{startDateStart},' 00:00:00') | 
 |  |  |       </if> | 
 |  |  |       <if test="startDateEnd != null and startDateEnd != ''"> | 
 |  |  |         AND concat(#{planDateEnd},' 23:59:59') >= `a`.`START_DATE` | 
 |  |  |         AND concat(#{startDateEnd},' 23:59:59') >= `a`.`START_DATE` | 
 |  |  |       </if> | 
 |  |  |       <if test="planDateStart != null and planDateStart != ''"> | 
 |  |  |         AND `a`.`PLAN_DATE` >= concat(#{planDateStart},' 00:00:00') | 
 |  |  | 
 |  |  |     </where> | 
 |  |  |         order by a.START_DATE desc, a.CREATE_TIME  desc | 
 |  |  |   </select> | 
 |  |  |   <select id="getPlansStaticticsData" parameterType="doumeemes.dao.ext.dto.QueryWorkPlansDTO" resultType="doumeemes.dao.business.dto.statistics.StatisticsPlanDataModel"> | 
 |  |  |     SELECT count(a.id) as ingNum, | 
 |  |  |     (select count(b.id)  FROM `work_plans` b where b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId}  AND  (b.`STATUS` = 1 and   to_days(now()) > to_days(b.plan_Date) )) as delayNum, | 
 |  |  |     (select count(distinct(b.CREATE_USER))  FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where to_days(b.create_time)=to_days(now()) and b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId}  AND c.status in (0,1,2,3,4,7)) as prouserNum, | 
 |  |  |     (select count(distinct(b.PRO_GROUP_ID))  FROM `workorder` b    where  to_days(b.create_time)=to_days(now()) and  b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId}  AND b.status in (0,1,2,3,4,7)) as deviceNum, | 
 |  |  |     (select sum(ifnull(b.UNQUALIFIED_NUM,0))  FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where   b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId}  AND to_days(b.create_time)=to_days(now()) and c.status=4 ) as unqualifiedNum, | 
 |  |  |     (select sum(ifnull(b.NUM,0))              FROM `workorder_record` b left join workorder c on b.workorder_id =c.id where    b.DELETED = 0 AND b.ROOT_DEPART_ID = #{rootDepartId} AND b.DEPART_ID = #{departId}  AND to_days(b.create_time)=to_days(now()) and  c.status=4) as doneNum | 
 |  |  |      FROM `work_plans` `a` | 
 |  |  |     where | 
 |  |  |         a.DELETED = 0 AND a.ROOT_DEPART_ID = #{rootDepartId} AND a.DEPART_ID = #{departId}  AND a.`STATUS` = 1 | 
 |  |  |   </select> | 
 |  |  |   <select id="selectStatisticsList" parameterType="doumeemes.dao.ext.dto.QueryWorkPlansDTO" resultType="doumeemes.dao.business.dto.statistics.WorkPlansPageModel"> | 
 |  |  |     select a.status,a.plan_code as code,a.num,a.id,a.NUM,m.id as materialId,m.name as materialName,m.code as materialCode | 
 |  |  |    <!-- ,(select sum(b.num) from workorder_record b left join plans c on b.PLAN_ID=c.id where b.type=1 and b.DELETED=0 and c.WORK_PLANS_ID=a.id) as doneNum | 
 |  |  |     ,(select sum(b.QUALIFIED_NUM) from workorder_record b left join plans c on b.PLAN_ID=c.id where b.type=1 and b.DELETED=0 and c.WORK_PLANS_ID=a.id) as qualifiedNum | 
 |  |  |     -->,(select b.route_id from bom b where b.MATERIAL_ID=c.id and b.ROOT_DEPART_ID=a.ROOT_DEPART_ID) as routeId | 
 |  |  |     FROM `work_plans` `a` | 
 |  |  |     LEFT JOIN `material_distribute` c ON a.MATERIAL_ID=c.ID | 
 |  |  |     LEFT JOIN `material` m ON c.MATERIAL_ID=m.ID | 
 |  |  |     where ( a.status= 1  or (a.status=6 and EXISTS(select b.id from workorder_record b left join plans c on b.PLAN_ID=c.id where b.type=1  and to_days(b.create_time)=to_days(now()) and b.DELETED=0 and c.WORK_PLANS_ID=a.id) )) | 
 |  |  |     and  a.deleted=0 and a.ROOT_DEPART_ID=#{rootDepartId} and a.DEPART_ID=#{departId} | 
 |  |  |     order by a.CREATE_TIME | 
 |  |  |  | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |  | 
 |  |  |   <select id="getWorkPlansVODetail" parameterType="doumeemes.dao.ext.dto.QueryWorkPlansDTO" resultMap="WorkPlansVO"> |