yangkang
2023-09-13 51ebb09a85d622cae75dc169b4c86723977d3756
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml
@@ -3,75 +3,44 @@
<mapper namespace="org.jeecg.modules.eam.mapper.EamEquipmentMapper">
    <select id="getResumeUseRecordList"  parameterType="Map" resultType="Map">
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备领借' AS 'type',
            t3.item_text AS businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_unloading t1
        LEFT JOIN mom_eam_equipment_unloading_borrow_detail t2 ON t1.id = t2.equipment_unloading_id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'business_type' ) t3 ON t3.item_value = t1.business_type
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
        select * from (
            SELECT DISTINCT
                t1.id,
                t1.num,
                '设备调入' AS 'type',
                t1.create_time AS createTime,
                t1.create_by AS createBy
            FROM
                mom_eam_equipment_transfer t1
            left join mom_eam_equipment_transfer_in_detail t2 on t1.id = t2.equipment_transfer_id
            where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
        UNION All
            UNION
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备归还' AS 'type',
            t3.item_text AS businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_unloading t1
        LEFT JOIN mom_eam_equipment_unloading_return_detail t2 ON t1.id = t2.equipment_unloading_id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'business_type' ) t3 ON t3.item_value = t1.business_type
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
            SELECT DISTINCT
                t1.id,
                t1.num,
                '设备调出' AS 'type',
                t1.create_time AS createTime,
                t1.create_by AS createBy
            FROM
                mom_eam_equipment_transfer t1
            left join mom_eam_equipment_transfer_out_detail t2 on t1.id = t2.equipment_transfer_id
            where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
        UNION All
            UNION
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备调入' AS 'type',
            '' as  businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_transfer t1
        left join mom_eam_equipment_transfer_in_detail t2 on t1.id = t2.equipment_transfer_id
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
        UNION All
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备调出' AS 'type',
            '' as  businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_transfer t1
        left join mom_eam_equipment_transfer_out_detail t2 on t1.id = t2.equipment_transfer_id
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
        UNION All
        SELECT DISTINCT
            t1.id,
            t1.num,
            '设备变动' AS 'type',
            '' as  businessType,
            t1.create_time AS createTime,
            t1.create_by AS createBy
        FROM
            mom_eam_equipment_change t1
        left join mom_eam_equipment_change_detail t2 on t1.id = t2.equipment_change_id
        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
            SELECT DISTINCT
                t1.id,
                t1.num,
                '设备变动' AS 'type',
                t1.create_time AS createTime,
                t1.create_by AS createBy
            FROM
                mom_eam_equipment_change t1
            left join mom_eam_equipment_change_detail t2 on t1.id = t2.equipment_change_id
            where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
        ) as equipmentChange
    </select>
    <select id="getResumeInspectionRecordList"  parameterType="Map" resultType="Map">
@@ -89,61 +58,46 @@
        left join mom_base_team t3 on t1.team_id = t3.id
        left join sys_user t4 on t1.inspection_user_id = t4.id
        left join mom_eam_inspection_cycle t5 on t1.inspection_cycle_id = t5.id
        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t5.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t5.del_flag= '0' and t2.equipment_id = ${params.equipmentId}
--         UNION All
--
--         SELECT DISTINCT
--             t1.id,
--             '专业点检' as inspectionType,
--             t1.num,
--             t1.inspection_time as inspectionTime,
--             t3.name as teamName,
--             t4.realname as inspectionUserName,
--             t1.plan_end_time as actualEndTime
--         FROM
--             mom_eam_specialty_inspection_order t1
--         LEFT JOIN mom_eam_specialty_inspection_order_detail t2 on t1.id = t2.specialty_inspection_order_id
--         left join sys_user t4 on t1.inspection_user_id = t4.id
--         left join mom_eam_specialty_inspection_plan t5 on t1.specialty_inspection_plan_id = t5.id
--         left join mom_base_team t3 on t5.team_id = t3.id
--         WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t5.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
    </select>
    <select id="getResumeMaintenanceRecordList"  parameterType="Map" resultType="Map">
        SELECT DISTINCT
            t1.id,
            '日常保养' as maintenanceType,
            t1.num,
            t4.name as teamName,
            t5.realname as maintenanceuserName,
            t1.actual_start_time as actualStartTime,
            t1.actual_end_time as actualEndTime
        FROM
            mom_eam_daily_maintenance_order t1
        LEFT JOIN mom_eam_daily_maintenance_order_detail t2 ON t1.id = t2.daily_maintenance_order_id
        left join mom_eam_equipment t3 on t1.equipment_id = t3.id
        left join mom_base_team t4 on t3.team_id = t4.id
        left join sys_user t5 on t5.id= t1.maintenance_user_id
        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t1.equipment_id = #{params.equipmentId}
        select * from (
            SELECT DISTINCT
                t1.id,
                '日常保养' as maintenanceType,
                t1.num,
                t4.name as teamName,
                t5.realname as maintenanceuserName,
                t1.actual_start_time as actualStartTime,
                t1.actual_end_time as actualEndTime
            FROM
                mom_eam_daily_maintenance_order t1
            LEFT JOIN mom_eam_daily_maintenance_order_detail t2 ON t1.id = t2.daily_maintenance_order_id
            left join mom_eam_equipment t3 on t1.equipment_id = t3.id
            left join mom_base_team t4 on t3.team_id = t4.id
            left join sys_user t5 on t5.id= t1.maintenance_user_id
            WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t1.equipment_id = #{params.equipmentId}
        UNION All
            UNION
        SELECT DISTINCT
            t1.id,
            '专业保养' AS maintenanceType,
            t1.num,
            t4.name as teamName,
            t5.realname as maintenanceuserName,
            t1.actual_start_time as actualStartTime,
            t1.actual_end_time as actualEndTime
        FROM
            mom_eam_specialty_maintenance_order t1
        left join mom_eam_specialty_maintenance_order_detail t2 on t1.id = t2.specialty_maintenance_order_id
        left join mom_eam_equipment t3 on t2.equipment_id = t3.id
        left join mom_base_team t4 on t3.team_id = t4.id
        left join sys_user t5 on t5.id= t1.maintenance_user_id
        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
            SELECT DISTINCT
                t1.id,
                '专业保养' AS maintenanceType,
                t1.num,
                t4.name as teamName,
                t5.realname as maintenanceuserName,
                t1.actual_start_time as actualStartTime,
                t1.actual_end_time as actualEndTime
            FROM
                mom_eam_specialty_maintenance_order t1
            left join mom_eam_specialty_maintenance_order_detail t2 on t1.id = t2.specialty_maintenance_order_id
            left join mom_eam_equipment t3 on t2.equipment_id = t3.id
            left join mom_base_team t4 on t3.team_id = t4.id
            left join sys_user t5 on t5.id= t1.maintenance_user_id
            WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
        ) as maintenance
    </select>
    <select id="getResumeRepairRecordList"  parameterType="Map" resultType="Map">
@@ -197,4 +151,26 @@
        LEFT JOIN mom_eam_equipment_scrap_detail t5 ON t1.id = t5.equipment_change_id
        where t1.del_flag = '0'  and (t2.equipment_id = #{params.equipmentId} or t3.equipment_id = #{params.equipmentId} or t4.equipment_id = #{params.equipmentId} or t5.equipment_id = #{params.equipmentId})
    </select>
    <select id="pageEquipment"  parameterType="Map" resultType="org.jeecg.modules.eam.entity.Equipment">
        SELECT
        t1.id,
        t1.num,
        t1.name,
        t1.model,
        t1.specification,
        t1.equipment_status equipmentStatus,
        t2.item_text equipmentStatus_dictText
        FROM
        mom_eam_equipment t1
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'equipment_status' ) t2 ON t1.equipment_status = t2.item_value
        WHERE t1.del_flag = '0'
        <if test="params.num != 'null' and params.num != ''">
            and t1.num like concat('%',#{params.num},'%')
        </if>
        <if test="params.name != 'null' and params.name != ''">
            and t1.name like concat('%',#{params.name},'%')
        </if>
    </select>
</mapper>