|
|
@@ -1134,44 +1134,63 @@
|
|
|
and status = #{status}
|
|
|
</update>
|
|
|
|
|
|
- <!-- 年度保养计划表:按设备类别/设备名称/保养负责人聚合,
|
|
|
- 当年每月只要有已完成(status=3)的保养任务则该月打勾√,排除按天(period_type=1)的保养 -->
|
|
|
+ <!-- 年度保养计划表:以“保养标准(t_check_standard)”为行来源,排除按天(period_type=1)的保养,
|
|
|
+ 即使该标准尚未执行任何任务也会显示一行(月份不打勾);
|
|
|
+ 当年某设备每月只要有已完成(status=3)的保养任务则该月打勾√ -->
|
|
|
<select id="selectAnnualPlan" parameterType="com.platform.dao.dto.check.CheckJobDTO"
|
|
|
resultType="com.platform.dao.vo.query.check.CheckJobAnnualPlanVO">
|
|
|
select
|
|
|
sbtype.name as category,
|
|
|
sbinfo.name as sbName,
|
|
|
- coalesce(u.real_name, dept.name) as owner,
|
|
|
+ <!-- 保养负责人与任务生成逻辑保持一致:
|
|
|
+ 1-使用人取设备保管人(save_user),2-维修人取设备第一维修人(repair_user),
|
|
|
+ 3-指定取标准上已绑定的人(保存时=维修人),4-班组取部门 -->
|
|
|
+ case standard.check_user_type
|
|
|
+ when 1 then su_save.real_name
|
|
|
+ when 2 then su_repair.real_name
|
|
|
+ when 3 then coalesce(su.real_name, su_repair.real_name)
|
|
|
+ when 4 then sdept.name
|
|
|
+ else coalesce(su.real_name, sdept.name)
|
|
|
+ end as owner,
|
|
|
count(distinct sbinfo.id) as sbNum,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 1 then '√' else '' end) as month1,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 2 then '√' else '' end) as month2,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 3 then '√' else '' end) as month3,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 4 then '√' else '' end) as month4,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 5 then '√' else '' end) as month5,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 6 then '√' else '' end) as month6,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 7 then '√' else '' end) as month7,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 8 then '√' else '' end) as month8,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 9 then '√' else '' end) as month9,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 10 then '√' else '' end) as month10,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 11 then '√' else '' end) as month11,
|
|
|
- max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 12 then '√' else '' end) as month12
|
|
|
- from t_check_job checkjob
|
|
|
- inner join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
|
|
|
- inner join t_check_standard standard on standard.id = checkjob.standard_id
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 1 then '√' else '' end) as month1,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 2 then '√' else '' end) as month2,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 3 then '√' else '' end) as month3,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 4 then '√' else '' end) as month4,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 5 then '√' else '' end) as month5,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 6 then '√' else '' end) as month6,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 7 then '√' else '' end) as month7,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 8 then '√' else '' end) as month8,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 9 then '√' else '' end) as month9,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 10 then '√' else '' end) as month10,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 11 then '√' else '' end) as month11,
|
|
|
+ max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 12 then '√' else '' end) as month12
|
|
|
+ from t_check_standard standard
|
|
|
+ inner join t_sb_info sbinfo on sbinfo.id = standard.sb_id
|
|
|
left join t_sb_type sbtype on sbtype.id = sbinfo.type_id
|
|
|
- left join t_sys_user u on checkjob.check_user_id = u.user_id
|
|
|
- left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
|
|
|
- <where>
|
|
|
- checkjob.status = 3
|
|
|
- and standard.period_type != 1
|
|
|
+ left join t_sys_user su on standard.check_user_id = su.user_id
|
|
|
+ left join t_sys_dept sdept on standard.check_dept_id = sdept.dept_id
|
|
|
+ left join t_sys_user su_save on sbinfo.save_user = su_save.user_id
|
|
|
+ left join t_sys_user su_repair on sbinfo.repair_user = su_repair.user_id
|
|
|
+ left join t_check_job job on job.standard_id = standard.id
|
|
|
+ and job.status = 3
|
|
|
<if test="searchYear != null">
|
|
|
- and year(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = #{searchYear}
|
|
|
+ and year(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = #{searchYear}
|
|
|
</if>
|
|
|
+ <where>
|
|
|
+ standard.period_type != 1
|
|
|
<if test="type != null">
|
|
|
- and checkjob.type = #{type}
|
|
|
+ and standard.type = #{type}
|
|
|
</if>
|
|
|
</where>
|
|
|
- group by sbtype.name, sbinfo.name, coalesce(u.real_name, dept.name)
|
|
|
+ group by sbtype.name, sbinfo.name,
|
|
|
+ case standard.check_user_type
|
|
|
+ when 1 then su_save.real_name
|
|
|
+ when 2 then su_repair.real_name
|
|
|
+ when 3 then coalesce(su.real_name, su_repair.real_name)
|
|
|
+ when 4 then sdept.name
|
|
|
+ else coalesce(su.real_name, sdept.name)
|
|
|
+ end
|
|
|
order by sbtype.name asc, sbinfo.name asc
|
|
|
</select>
|
|
|
</mapper>
|