吴羡
2 天以前 8ad863082097ffdcab4a8e7f426d344a1fe6f892
cnas-device/src/main/resources/mapper/DeviceMaintenancePlanDetailsMapper.xml
@@ -11,10 +11,17 @@
            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>
    <!-- 设备保养计划详情列表(含到点标红、关联的保养记录与审核状态) -->
@@ -53,7 +60,9 @@
            case when d.next_maintenance_date is not null
                and d.next_maintenance_date &lt;= date_add(curdate(), interval 1 month)
                and (d.last_maintenance_date is null or d.last_maintenance_date &lt; 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