| | |
| | | d.management_number device_number, |
| | | d.specification_model, |
| | | d.management_number, |
| | | d.storage_point |
| | | d.storage_point, |
| | | (select count(*) from device_maintenance dm |
| | | where dm.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id) has_record |
| | | from device_maintenance_plan_details dmpd |
| | | left join device d on dmpd.device_id = d.id |
| | | where dmpd.maintenance_plan_id = #{maintenancePlanId} |
| | | order by has_record desc, |
| | | (select count(*) from device_maintenance dm2 |
| | | where dm2.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id |
| | | and dm2.review_status = 1) desc, |
| | | dmpd.maintenance_plan_detail_id desc |
| | | </select> |
| | | |
| | | <!-- 设备保养计划详情列表(含到点标红、关联的保养记录与审核状态) --> |
| | |
| | | case when d.next_maintenance_date is not null |
| | | and d.next_maintenance_date <= date_add(curdate(), interval 1 month) |
| | | and (d.last_maintenance_date is null or d.last_maintenance_date < dmpd.maintenance_date) |
| | | then 1 else 0 end as red_flag |
| | | then 1 else 0 end as red_flag, |
| | | (select count(*) from device_maintenance_attachment a |
| | | where a.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id) attachment_count |
| | | from device_maintenance_plan_details dmpd |
| | | left join device d on dmpd.device_id = d.id |
| | | left join device_maintenance dm on dm.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id |