gongchunyi
7 天以前 2e021dbbcaee9c2af592ca639831eac66a4edd07
src/main/resources/mapper/device/DeviceMaintenanceMapper.xml
@@ -19,34 +19,49 @@
        dm.tenant_id,
        dm.maintenance_actually_name,
        dl.device_name,
        dm.machinery_category,
        dl.device_model,
        su.nick_name as create_user_name
        from device_maintenance dm
        left join device_ledger dl on dm.device_ledger_id = dl.id
        left join sys_user su on dm.create_user = su.user_id
        <where>
            1 = 1
            <if test="deviceMaintenanceDto.deviceName != null">
                and dl.device_name like concat('%',#{deviceMaintenanceDto.deviceName},'%')
            <if test="deviceMaintenanceDto.deviceName != null and deviceMaintenanceDto.deviceName != ''">
                and dl.device_name like concat('%', #{deviceMaintenanceDto.deviceName}, '%')
            </if>
            <if test="deviceMaintenanceDto.deviceModel != null">
                and dl.device_model like concat('%',#{deviceMaintenanceDto.deviceModel},'%')
            <if test="deviceMaintenanceDto.deviceModel != null and deviceMaintenanceDto.deviceModel != ''">
                and dl.device_model like concat('%', #{deviceMaintenanceDto.deviceModel}, '%')
            </if>
            <if test="deviceMaintenanceDto.status != null">
                and dm.status = #{deviceMaintenanceDto.status}
            </if>
            <if test="deviceMaintenanceDto.maintenanceActuallyName != null">
                and dm.maintenance_actually_name like concat('%',#{deviceMaintenanceDto.maintenanceActuallyName},'%')
            <if test="deviceMaintenanceDto.maintenanceActuallyName != null and deviceMaintenanceDto.maintenanceActuallyName != ''">
                and dm.maintenance_actually_name like concat('%', #{deviceMaintenanceDto.maintenanceActuallyName}, '%')
            </if>
            <if test="deviceMaintenanceDto.maintenancePlanTimeReq != null">
                and dm.maintenance_plan_time like concat('%',#{deviceMaintenanceDto.maintenancePlanTimeReq},'%')
            <if test="deviceMaintenanceDto.maintenancePlanTime != null">
                and dm.maintenance_plan_time = #{deviceMaintenanceDto.maintenancePlanTime}
            </if>
            <if test="deviceMaintenanceDto.maintenanceActuallyTimeReq != null">
                and dm.maintenance_actually_time like concat('%',#{deviceMaintenanceDto.maintenanceActuallyTimeReq},'%')
            <if test="deviceMaintenanceDto.maintenanceActuallyTime != null">
                and dm.maintenance_actually_time &gt;= str_to_date(#{deviceMaintenanceDto.maintenanceActuallyTime},
                '%Y-%m-%d')
                and dm.maintenance_actually_time &lt;
                date_add(str_to_date(#{deviceMaintenanceDto.maintenanceActuallyTime}, '%Y-%m-%d'), interval 1 day)
            </if>
        </where>
        order by
        <!--    待保养(0)优先排在上面,已完结(1)在下面 -->
        dm.status asc,
        case
        <!-- 当状态是 0(待保养)时,按计划时间升序,即时间最远的单子在最上面 -->
        when dm.status = 0 then dm.maintenance_plan_time
        end asc,
        case
        <!-- 当状态是 1(已完结)时,按实际保养时间降序,最近刚保养完的单子在已完结里排最前 -->
        when dm.status = 1 then dm.maintenance_actually_time
        end desc
    </select>
    <select id="detailById" resultType="com.ruoyi.device.dto.DeviceMaintenanceDto">
    <select id="detailById" resultType="com.ruoyi.device.vo.DeviceMaintenanceVo">
        select dm.id,
               dm.device_ledger_id,
               dm.maintenance_plan_time,
@@ -58,6 +73,7 @@
               dm.create_user,
               dm.update_user,
               dm.tenant_id,
               dm.machinery_category,
               dm.maintenance_actually_name,
               dl.device_name,
               dl.device_model,