|  |  | 
 |  |  |     </where> | 
 |  |  |     limit 1 | 
 |  |  |   </select> | 
 |  |  |   <select id="userSalaryPage" parameterType="doumeemes.dao.ext.dto.QueryUserSalaryListDTO" resultType="doumeemes.dao.ext.vo.UserSalaryListVO"> | 
 |  |  |     select a.WORKORDER_ID,b.`CODE` as workorderCode,c.`NAME` as materialName,c.code as materialCode | 
 |  |  |     ,d.name as unitName,a.PROCEDURE_ID,f.`NAME` as procedureName,a.CREATE_USER as userId | 
 |  |  |     ,sum(a.QUALIFIED_NUM) as qualifiedNum | 
 |  |  |     ,sum(a.UNQUALIFIED_NUM) as unQualifiedNum | 
 |  |  |     ,sum(a.num) as NUM | 
 |  |  |     from `workorder_record` a | 
 |  |  |     left join workorder b on a.WORKORDER_ID=b.id | 
 |  |  |     left join material_distribute m on b.MATERIAL_ID = m.ID | 
 |  |  |     left join material c on m.MATERIAL_ID = c.ID | 
 |  |  |     left join unit d on a.UNIT_ID = d.ID | 
 |  |  |     left join procedures f on a.PROCEDURE_ID =f.ID | 
 |  |  |     where a.DELETED = 0 | 
 |  |  |     <if test="rootDepartId != null"> | 
 |  |  |       AND  a.`ROOT_DEPART_ID` = #{rootDepartId} | 
 |  |  |     </if> | 
 |  |  |     <if test="procedureId != null"> | 
 |  |  |       AND  a.`PROCEDURE_ID` = #{procedureId} | 
 |  |  |     </if> | 
 |  |  |     <if test="materialName != null and materialName !=''"> | 
 |  |  |       AND  (c.`name` like concat('%', #{materialName},'%') or c.`code` like concat('%', #{materialName},'%')) | 
 |  |  |     </if> | 
 |  |  |     <if test="startDate != null"> | 
 |  |  |       AND  a.`CREATE_TIME` >= #{startDate} | 
 |  |  |     </if> | 
 |  |  |     <if test="endDate != null"> | 
 |  |  |       AND   #{endDate} >= a.`CREATE_TIME` | 
 |  |  |     </if> | 
 |  |  |     <if test="userId != null"> | 
 |  |  |       AND  a.`CREATE_USER` = #{userId} | 
 |  |  |     </if> | 
 |  |  |     group by  a.`WORKORDER_ID` | 
 |  |  |     order by a.CREATE_TIME desc | 
 |  |  |   </select> | 
 |  |  |   <select id="salaryStatistic" parameterType="doumeemes.dao.ext.dto.QuerySalaryStatisticDTO" resultType="doumeemes.dao.ext.vo.SalaryStatisticsListVO"> | 
 |  |  |     select `CREATE_USER` as userId ,sum(CASE  WHEN salary_type=0 THEN salary ELSE 0 END ) as jijianSalary | 
 |  |  |     ,sum(CASE  WHEN salary_type=0 THEN  0 ELSE salary  END ) as jishiSalary | 
 |  |  |     ,count(id) as num | 
 |  |  |     ,sum(salary) as totalSalary | 
 |  |  |     from `workorder_record` | 
 |  |  |     where `DELETED` =0 and `SALARY` >0 | 
 |  |  |     <if test="rootDepartId != null"> | 
 |  |  |       AND  `ROOT_DEPART_ID` = #{rootDepartId} | 
 |  |  |     </if> | 
 |  |  |     <if test="userId != null"> | 
 |  |  |       AND  `CREATE_USER` = #{userId} | 
 |  |  |     </if> | 
 |  |  |     <if test="startDate != null"> | 
 |  |  |       AND  a.`CREATE_TIME` >= #{startDate} | 
 |  |  |     </if> | 
 |  |  |     <if test="endDate != null"> | 
 |  |  |       AND   #{endDate} >= a.`CREATE_TIME` | 
 |  |  |     </if> | 
 |  |  |     group by  `CREATE_USER` | 
 |  |  |    <!-- order by `CREATE_TIME` desc--> | 
 |  |  |   </select> | 
 |  |  |   <select id="selectListNew" parameterType="doumeemes.dao.ext.dto.QueryWorkorderRecordExtDTO" resultMap="WorkorderRecordExtListVO"> | 
 |  |  |     SELECT | 
 |  |  |       `a`.`ID`, | 
 |  |  | 
 |  |  |     MATERIAL_DONETYPE, | 
 |  |  |     MATERIAL_PROCEDURE_ID, | 
 |  |  |     RELOBJ_ID, | 
 |  |  |     RELOBJ_TYPE | 
 |  |  |     RELOBJ_TYPE, | 
 |  |  |     `DURATION`, | 
 |  |  |     `SALARY`, | 
 |  |  |     `SALARY_PRICE`, | 
 |  |  |     `SALARY_NUM`, | 
 |  |  |     `SALARY_TIMES`, | 
 |  |  |     `SALARY_UNQUALIFIED`, | 
 |  |  |     `SALARY_TYPE` | 
 |  |  |     ) | 
 |  |  |     values <foreach collection="list" separator="," item="item"> | 
 |  |  |            ( | 
 |  |  | 
 |  |  |             #{item.materialDonetype}, | 
 |  |  |             #{item.materialProcedureId}, | 
 |  |  |             #{item.relobjId}, | 
 |  |  |             #{item.relobjType} | 
 |  |  |             #{item.relobjType}, | 
 |  |  |             #{item.duration}, | 
 |  |  |             #{item.salary}, | 
 |  |  |             #{item.salaryPrice}, | 
 |  |  |             #{item.salaryNum}, | 
 |  |  |             #{item.salaryTimes}, | 
 |  |  |             #{item.salaryUnqualified}, | 
 |  |  |             #{item.salaryType} | 
 |  |  |            ) | 
 |  |  |   </foreach> | 
 |  |  |   </insert> |