chenlu
3 天以前 2a243dc744898018adf7523dcb2d10ded968b432
north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml
@@ -63,10 +63,71 @@
    </insert>
    <select id="selectMaintenanceMp" resultMap="DeviceMaintenanceMapper">
        select * from device_maintenance
        select id,
               device_id,
               device_name,
               type,
               date(fault_time) as fault_time,
               fault_reason,
               date(maintenance_time) as maintenance_time,
               maintenance_illustrate,
               date(start_time) as start_time,
               date(stop_time) as stop_time,
               process,
               personnel,
               cost
        from device_maintenance
        where DATE_FORMAT((create_time), '%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }
    </select>
    <delete id="deleteMaintenanceMp">
        delete from device_maintenance where id = #{id}
    </delete>
    <select id="selectMachineMp">
        select dm.device_id,dm.device_name,
        if(dm.type=1,'维修','保养') as type,
        (select count(*) from device_maintenance where id = dm.id and type = 1) as faultCount,
        (select count(*) from device_maintenance where id = dm.id and type = 2) as maintenanceCount,
        (select date(fault_time) from device_maintenance where id = dm.id and type = 1 order by fault_time desc limit 1) as faultLastTime,
        (select date(maintenance_time) from device_maintenance where id = dm.id and type = 2 order by maintenance_time desc limit 1) as maintenanceLastTime,
        (select sum(cost) from device_maintenance where id = dm.id and dm.type=1) as faultCost,
        (select sum(cost) from device_maintenance where id = dm.id and dm.type=2) as maintenanceCost,
        dm.process
        from device_maintenance as dm
        group by dm.device_id
    </select>
    <select id="openSelectIdMp">
    select id,
           device_id,
           device_name,
           type,
           date(fault_time) as fault_time,
           fault_reason,
           date(maintenance_time) as maintenance_time,
           maintenance_illustrate,
           date(start_time) as start_time,
           date(stop_time) as stop_time,
           process,
           personnel,
           cost from device_maintenance where id = #{id}
    </select>
    <update id="updateMaintenanceMp">
        update device_maintenance set
        device_name = #{deviceName},
        type = #{type},
        fault_time = #{faultTime},
        fault_reason = #{faultReason},
        maintenance_time = #{maintenanceTime},
        maintenance_illustrate = #{maintenanceIllustrate},
        start_time = #{startTime},
        stop_time = #{stopTime},
        process = #{process},
        personnel = #{personnel},
        cost = #{cost}
        where id = #{id}
    </update>
</mapper>