|  |  | 
 |  |  |   </select> | 
 |  |  |   <!-- 管理页面查询 --> | 
 |  |  |   <select id="sumOrderNum" parameterType="doumeemes.dao.ext.dto.QueryWorkorderExtDTO" resultType="java.lang.Integer"> | 
 |  |  |     SELECT sum(`a`.num) | 
 |  |  |     SELECT sum(`a`.id) | 
 |  |  |     FROM `workorder` `a` | 
 |  |  |     <where> | 
 |  |  |     <if test="id != null"> | 
 |  |  | 
 |  |  |     `pgmodel`.`GROUP_ID` AS PGMODEL_GROUP_ID, | 
 |  |  |     `pgmodel`.`SERIAL_NUM` AS PGMODEL_SERIAL_NUM, | 
 |  |  |      p.name as procedureName, | 
 |  |  |         u.realname as proUserName, | 
 |  |  |      u.realname as proUserName, | 
 |  |  |      uc.realname as createUserName, | 
 |  |  |     (select sum(ifnull(num,0)) from workorder_record r where r.deleted=0 and r.type=1 and r.workorder_id=a.id) as proNum | 
 |  |  |     <if test="checkTouliao!=null and checkTouliao==1"> | 
 |  |  |       ,(select r.id from workorder_record r where r.deleted=0 and r.type=0 and r.workorder_id=a.id limit 1) as touliaoId | 
 |  |  | 
 |  |  |     LEFT JOIN `device` `pgmodel` ON a.PRO_GROUP_ID=pgmodel.ID | 
 |  |  |     LEFT JOIN `procedures` `p` ON a.`PROCEDURE_ID`=p.ID | 
 |  |  |     LEFT JOIN `system_user` `u` ON `a`.`PRO_USER_ID`=u.ID | 
 |  |  |     LEFT JOIN `system_user` `uc` ON `a`.`CREATE_USER`=uc.ID | 
 |  |  |         <where> | 
 |  |  |       <if test="id != null"> | 
 |  |  |         AND `a`.`ID` = #{id} | 
 |  |  | 
 |  |  |           <choose> | 
 |  |  |             <when test="departIds != null and departIds.size()>0"> | 
 |  |  |               AND (  `a`.`CREATE_USER` = #{createUser}  or | 
 |  |  |               exists (select d.id from workorder_user d where d.WORKORDER_ID=a.id and d.DELETED=0 and d.PRO_USER_ID=#{createUser} ) | 
 |  |  |               or exists (select d.id from company_user d where  d.user_id= a.CREATE_USER  and d.department_id | 
 |  |  |               exists ( select d.id from workorder_user d where d.WORKORDER_ID=a.id and d.DELETED=0 and d.PRO_USER_ID=#{createUser} ) | 
 |  |  |               or exists ( select d.id from company_user d where  d.user_id= a.CREATE_USER  and d.department_id | 
 |  |  |               in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach>) | 
 |  |  |               or exists (select d.id from workorder_user wu left join  company_user d on wu.PRO_USER_ID=d.USER_ID and d.DELETED=0 where  wu.WORKORDER_ID= a.id  and d.department_id | 
 |  |  |               in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach>) | 
 |  |  | 
 |  |  |               </if> | 
 |  |  |             </otherwise> | 
 |  |  |           </choose> | 
 |  |  |       <if test="startDate != null"> | 
 |  |  |       <if test="startDate != null and startDate!=''"> | 
 |  |  |         AND `a`.`PLAN_DATE` >= #{startDate} | 
 |  |  |       </if> | 
 |  |  |       <if test="endDate != null"> | 
 |  |  |       <if test="endDate != null and endDate!=''"> | 
 |  |  |         AND   #{endDate} >= `a`.`PLAN_DATE` | 
 |  |  |       </if> | 
 |  |  |       <if test="mixParam != null and mixParam!=''"> |