<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.BusDeviceHistoryMapper">
    
    <resultMap type="BusDeviceHistory" id="BusDeviceHistoryResult">
        <result property="id"    column="id"    />
        <result property="dId"    column="d_id"    />
        <result property="pId"    column="p_id"    />
        <result property="signTime"    column="sign_time"    />
        <result property="treatmentProject"    column="treatment_project"    />
        <result property="alarm"    column="alarm"    />
        <result property="uploadTime"    column="upload_time"    />
        <result property="machineModel"    column="machine_model"    />
        <result property="filterModel"    column="filter_model"    />
        <result property="hemodialysisModel"    column="hemodialysis_model"    />
        <result property="treatmentTime"    column="treatment_time"    />
        <result property="targetDehydration"    column="target_dehydration"    />
        <result property="bloodPumpRate"    column="blood_pump_rate"    />
        <result property="flow"    column="flow"    />
        <result property="k"    column="k"    />
        <result property="ca"    column="ca"    />
        <result property="na"    column="na"    />
        <result property="hco3"    column="hco3"    />
        <result property="antithrombotic"    column="antithrombotic"    />
        <result property="firstDose"    column="first_dose"    />
        <result property="additionalDose"    column="additional_dose"    />
        <result property="vascularAccess"    column="vascular_access"    />
        <result property="doctor"    column="doctor"    />
        <result property="nurse"    column="nurse"    />
        <result property="verifyPrescription"    column="verify_prescription"    />
        <result property="targetWeight"    column="target_weight"    />
        <result property="lastWeight"    column="last_weight"    />
        <result property="beforeWeight"    column="before_weight"    />
        <result property="addWeight"    column="add_weight"    />
        <result property="beforeSbp"    column="before_sbp"    />
        <result property="beforeDbp"    column="before_dbp"    />
        <result property="beforeSphygmus"    column="before_sphygmus"    />
        <result property="beforeRr"    column="before_rr"    />
        <result property="beforeTemperature"    column="before_temperature"    />
        <result property="urineVolume"    column="urine_volume"    />
        <result property="gainWeight"    column="gain_weight"    />
        <result property="verifyBefore"    column="verify_before"    />
        <result property="preDialysisWeight"    column="pre_dialysis_weight"    />
        <result property="lossWeight"    column="loss_weight"    />
        <result property="afterTemperature"    column="after_temperature"    />
        <result property="afterSbp"    column="after_sbp"    />
        <result property="afterDbp"    column="after_dbp"    />
        <result property="afterSphygmus"    column="after_sphygmus"    />
        <result property="afterRr"    column="after_rr"    />
        <result property="verifyAfter"    column="verify_after"    />
        <result property="deviceId"    column="device_id"    />
        <result property="area"    column="area"    />
        <result property="bed"    column="bed"    />
        <result property="brandName"    column="brand_name"    />
        <result property="model"    column="model"    />
        <result property="manufactureId"    column="manufacture_id"    />
        <result property="price"    column="price"    />
        <result property="infection"    column="infection"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="gender"    column="gender"    />
        <result property="height"    column="height"    />
        <result property="age"    column="age"    />
        <result property="weight"    column="weight"    />
        <result property="source"    column="source"    />
        <result property="address"    column="address"    />
        <result property="createTime"    column="create_time"    />
        <result property="phone"    column="phone"    />
        <result property="relationName"    column="relation_name"    />
        <result property="relationPhone"    column="relation_phone"    />
        <result property="dieTime"    column="die_time"    />
        <result property="isDelete"    column="is_delete"    />
        <result property="status"    column="status"    />
        <result property="currentStatus"    column="current_Status"    />
    </resultMap>

    <sql id="selectBusDeviceHistoryVo">
        select id, d_id, p_id, sign_time, treatment_project, alarm, upload_time, machine_model, filter_model, hemodialysis_model, treatment_time, target_dehydration, blood_pump_rate, flow, k, ca, na, hco3, antithrombotic, first_dose, additional_dose, vascular_access, doctor, nurse, verify_prescription, target_weight, last_weight, before_weight, add_weight, before_sbp, before_dbp, before_sphygmus, before_rr, before_temperature, urine_volume, gain_weight, verify_before, pre_dialysis_weight, loss_weight, after_temperature, after_sbp, after_dbp, after_sphygmus, after_rr, verify_after, device_id, area, bed, brand_name, model, manufacture_id, price, infection, code, name, gender, height, age, weight, source, address, create_time, phone, relation_name, relation_phone, die_time, is_delete, status, current_Status from bus_device_history
    </sql>

    <select id="selectBusDeviceHistoryList" parameterType="BusDeviceHistory" resultMap="BusDeviceHistoryResult">
        <include refid="selectBusDeviceHistoryVo"/>
        <where>  
            <if test="dId != null "> and d_id = #{dId}</if>
            <if test="pId != null "> and p_id = #{pId}</if>
            <if test="params.beginSignTime != null and params.beginSignTime != '' and params.endSignTime != null and params.endSignTime != ''"> and sign_time between #{params.beginSignTime} and #{params.endSignTime}</if>
            <if test="treatmentProject != null  and treatmentProject != ''"> and treatment_project = #{treatmentProject}</if>
            <if test="alarm != null "> and alarm = #{alarm}</if>
            <if test="uploadTime != null "> and upload_time = #{uploadTime}</if>
            <if test="machineModel != null  and machineModel != ''"> and machine_model = #{machineModel}</if>
            <if test="filterModel != null  and filterModel != ''"> and filter_model = #{filterModel}</if>
            <if test="hemodialysisModel != null  and hemodialysisModel != ''"> and hemodialysis_model = #{hemodialysisModel}</if>
            <if test="treatmentTime != null  and treatmentTime != ''"> and treatment_time = #{treatmentTime}</if>
            <if test="targetDehydration != null  and targetDehydration != ''"> and target_dehydration = #{targetDehydration}</if>
            <if test="bloodPumpRate != null  and bloodPumpRate != ''"> and blood_pump_rate = #{bloodPumpRate}</if>
            <if test="flow != null  and flow != ''"> and flow = #{flow}</if>
            <if test="k != null  and k != ''"> and k = #{k}</if>
            <if test="ca != null  and ca != ''"> and ca = #{ca}</if>
            <if test="na != null  and na != ''"> and na = #{na}</if>
            <if test="hco3 != null  and hco3 != ''"> and hco3 = #{hco3}</if>
            <if test="antithrombotic != null  and antithrombotic != ''"> and antithrombotic = #{antithrombotic}</if>
            <if test="firstDose != null  and firstDose != ''"> and first_dose = #{firstDose}</if>
            <if test="additionalDose != null  and additionalDose != ''"> and additional_dose = #{additionalDose}</if>
            <if test="vascularAccess != null  and vascularAccess != ''"> and vascular_access = #{vascularAccess}</if>
            <if test="doctor != null  and doctor != ''"> and doctor = #{doctor}</if>
            <if test="nurse != null  and nurse != ''"> and nurse = #{nurse}</if>
            <if test="verifyPrescription != null "> and verify_prescription = #{verifyPrescription}</if>
            <if test="targetWeight != null  and targetWeight != ''"> and target_weight = #{targetWeight}</if>
            <if test="lastWeight != null  and lastWeight != ''"> and last_weight = #{lastWeight}</if>
            <if test="beforeWeight != null  and beforeWeight != ''"> and before_weight = #{beforeWeight}</if>
            <if test="addWeight != null  and addWeight != ''"> and add_weight = #{addWeight}</if>
            <if test="beforeSbp != null  and beforeSbp != ''"> and before_sbp = #{beforeSbp}</if>
            <if test="beforeDbp != null  and beforeDbp != ''"> and before_dbp = #{beforeDbp}</if>
            <if test="beforeSphygmus != null  and beforeSphygmus != ''"> and before_sphygmus = #{beforeSphygmus}</if>
            <if test="beforeRr != null  and beforeRr != ''"> and before_rr = #{beforeRr}</if>
            <if test="beforeTemperature != null  and beforeTemperature != ''"> and before_temperature = #{beforeTemperature}</if>
            <if test="urineVolume != null  and urineVolume != ''"> and urine_volume = #{urineVolume}</if>
            <if test="gainWeight != null  and gainWeight != ''"> and gain_weight = #{gainWeight}</if>
            <if test="verifyBefore != null "> and verify_before = #{verifyBefore}</if>
            <if test="preDialysisWeight != null  and preDialysisWeight != ''"> and pre_dialysis_weight = #{preDialysisWeight}</if>
            <if test="lossWeight != null  and lossWeight != ''"> and loss_weight = #{lossWeight}</if>
            <if test="afterTemperature != null  and afterTemperature != ''"> and after_temperature = #{afterTemperature}</if>
            <if test="afterSbp != null  and afterSbp != ''"> and after_sbp = #{afterSbp}</if>
            <if test="afterDbp != null  and afterDbp != ''"> and after_dbp = #{afterDbp}</if>
            <if test="afterSphygmus != null  and afterSphygmus != ''"> and after_sphygmus = #{afterSphygmus}</if>
            <if test="afterRr != null  and afterRr != ''"> and after_rr = #{afterRr}</if>
            <if test="verifyAfter != null "> and verify_after = #{verifyAfter}</if>
            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
            <if test="area != null  and area != ''"> and area = #{area}</if>
            <if test="bed != null  and bed != ''"> and bed = #{bed}</if>
            <if test="brandName != null  and brandName != ''"> and brand_name like concat('%', #{brandName}, '%')</if>
            <if test="model != null  and model != ''"> and model = #{model}</if>
            <if test="manufactureId != null  and manufactureId != ''"> and manufacture_id = #{manufactureId}</if>
            <if test="price != null  and price != ''"> and price = #{price}</if>
            <if test="infection != null "> and infection = #{infection}</if>
            <if test="code != null  and code != ''"> and code like concat('%', #{code}, '%')</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="gender != null "> and gender = #{gender}</if>
            <if test="height != null "> and height = #{height}</if>
            <if test="age != null "> and age = #{age}</if>
            <if test="weight != null "> and weight = #{weight}</if>
            <if test="source != null "> and source = #{source}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="relationName != null  and relationName != ''"> and relation_name like concat('%', #{relationName}, '%')</if>
            <if test="relationPhone != null  and relationPhone != ''"> and relation_phone = #{relationPhone}</if>
            <if test="dieTime != null "> and die_time = #{dieTime}</if>
            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="currentStatus != null  and currentStatus != ''"> and current_Status = #{currentStatus}</if>
        </where>
    </select>
    
    <select id="selectBusDeviceHistoryById" parameterType="Long" resultMap="BusDeviceHistoryResult">
        <include refid="selectBusDeviceHistoryVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBusDeviceHistory" parameterType="BusDeviceHistory" useGeneratedKeys="true" keyProperty="id">
        insert into bus_device_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dId != null">d_id,</if>
            <if test="pId != null">p_id,</if>
            <if test="signTime != null">sign_time,</if>
            <if test="treatmentProject != null">treatment_project,</if>
            <if test="alarm != null">alarm,</if>
            <if test="uploadTime != null">upload_time,</if>
            <if test="machineModel != null">machine_model,</if>
            <if test="filterModel != null">filter_model,</if>
            <if test="hemodialysisModel != null">hemodialysis_model,</if>
            <if test="treatmentTime != null">treatment_time,</if>
            <if test="targetDehydration != null">target_dehydration,</if>
            <if test="bloodPumpRate != null">blood_pump_rate,</if>
            <if test="flow != null">flow,</if>
            <if test="k != null">k,</if>
            <if test="ca != null">ca,</if>
            <if test="na != null">na,</if>
            <if test="hco3 != null">hco3,</if>
            <if test="antithrombotic != null">antithrombotic,</if>
            <if test="firstDose != null">first_dose,</if>
            <if test="additionalDose != null">additional_dose,</if>
            <if test="vascularAccess != null">vascular_access,</if>
            <if test="doctor != null">doctor,</if>
            <if test="nurse != null">nurse,</if>
            <if test="verifyPrescription != null">verify_prescription,</if>
            <if test="targetWeight != null">target_weight,</if>
            <if test="lastWeight != null">last_weight,</if>
            <if test="beforeWeight != null">before_weight,</if>
            <if test="addWeight != null">add_weight,</if>
            <if test="beforeSbp != null">before_sbp,</if>
            <if test="beforeDbp != null">before_dbp,</if>
            <if test="beforeSphygmus != null">before_sphygmus,</if>
            <if test="beforeRr != null">before_rr,</if>
            <if test="beforeTemperature != null">before_temperature,</if>
            <if test="urineVolume != null">urine_volume,</if>
            <if test="gainWeight != null">gain_weight,</if>
            <if test="verifyBefore != null">verify_before,</if>
            <if test="preDialysisWeight != null">pre_dialysis_weight,</if>
            <if test="lossWeight != null">loss_weight,</if>
            <if test="afterTemperature != null">after_temperature,</if>
            <if test="afterSbp != null">after_sbp,</if>
            <if test="afterDbp != null">after_dbp,</if>
            <if test="afterSphygmus != null">after_sphygmus,</if>
            <if test="afterRr != null">after_rr,</if>
            <if test="verifyAfter != null">verify_after,</if>
            <if test="deviceId != null">device_id,</if>
            <if test="area != null">area,</if>
            <if test="bed != null">bed,</if>
            <if test="brandName != null">brand_name,</if>
            <if test="model != null">model,</if>
            <if test="manufactureId != null">manufacture_id,</if>
            <if test="price != null">price,</if>
            <if test="infection != null">infection,</if>
            <if test="code != null">code,</if>
            <if test="name != null">name,</if>
            <if test="gender != null">gender,</if>
            <if test="height != null">height,</if>
            <if test="age != null">age,</if>
            <if test="weight != null">weight,</if>
            <if test="source != null">source,</if>
            <if test="address != null">address,</if>
            <if test="createTime != null">create_time,</if>
            <if test="phone != null">phone,</if>
            <if test="relationName != null">relation_name,</if>
            <if test="relationPhone != null">relation_phone,</if>
            <if test="dieTime != null">die_time,</if>
            <if test="isDelete != null">is_delete,</if>
            <if test="status != null">status,</if>
            <if test="currentStatus != null">current_Status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dId != null">#{dId},</if>
            <if test="pId != null">#{pId},</if>
            <if test="signTime != null">#{signTime},</if>
            <if test="treatmentProject != null">#{treatmentProject},</if>
            <if test="alarm != null">#{alarm},</if>
            <if test="uploadTime != null">#{uploadTime},</if>
            <if test="machineModel != null">#{machineModel},</if>
            <if test="filterModel != null">#{filterModel},</if>
            <if test="hemodialysisModel != null">#{hemodialysisModel},</if>
            <if test="treatmentTime != null">#{treatmentTime},</if>
            <if test="targetDehydration != null">#{targetDehydration},</if>
            <if test="bloodPumpRate != null">#{bloodPumpRate},</if>
            <if test="flow != null">#{flow},</if>
            <if test="k != null">#{k},</if>
            <if test="ca != null">#{ca},</if>
            <if test="na != null">#{na},</if>
            <if test="hco3 != null">#{hco3},</if>
            <if test="antithrombotic != null">#{antithrombotic},</if>
            <if test="firstDose != null">#{firstDose},</if>
            <if test="additionalDose != null">#{additionalDose},</if>
            <if test="vascularAccess != null">#{vascularAccess},</if>
            <if test="doctor != null">#{doctor},</if>
            <if test="nurse != null">#{nurse},</if>
            <if test="verifyPrescription != null">#{verifyPrescription},</if>
            <if test="targetWeight != null">#{targetWeight},</if>
            <if test="lastWeight != null">#{lastWeight},</if>
            <if test="beforeWeight != null">#{beforeWeight},</if>
            <if test="addWeight != null">#{addWeight},</if>
            <if test="beforeSbp != null">#{beforeSbp},</if>
            <if test="beforeDbp != null">#{beforeDbp},</if>
            <if test="beforeSphygmus != null">#{beforeSphygmus},</if>
            <if test="beforeRr != null">#{beforeRr},</if>
            <if test="beforeTemperature != null">#{beforeTemperature},</if>
            <if test="urineVolume != null">#{urineVolume},</if>
            <if test="gainWeight != null">#{gainWeight},</if>
            <if test="verifyBefore != null">#{verifyBefore},</if>
            <if test="preDialysisWeight != null">#{preDialysisWeight},</if>
            <if test="lossWeight != null">#{lossWeight},</if>
            <if test="afterTemperature != null">#{afterTemperature},</if>
            <if test="afterSbp != null">#{afterSbp},</if>
            <if test="afterDbp != null">#{afterDbp},</if>
            <if test="afterSphygmus != null">#{afterSphygmus},</if>
            <if test="afterRr != null">#{afterRr},</if>
            <if test="verifyAfter != null">#{verifyAfter},</if>
            <if test="deviceId != null">#{deviceId},</if>
            <if test="area != null">#{area},</if>
            <if test="bed != null">#{bed},</if>
            <if test="brandName != null">#{brandName},</if>
            <if test="model != null">#{model},</if>
            <if test="manufactureId != null">#{manufactureId},</if>
            <if test="price != null">#{price},</if>
            <if test="infection != null">#{infection},</if>
            <if test="code != null">#{code},</if>
            <if test="name != null">#{name},</if>
            <if test="gender != null">#{gender},</if>
            <if test="height != null">#{height},</if>
            <if test="age != null">#{age},</if>
            <if test="weight != null">#{weight},</if>
            <if test="source != null">#{source},</if>
            <if test="address != null">#{address},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="phone != null">#{phone},</if>
            <if test="relationName != null">#{relationName},</if>
            <if test="relationPhone != null">#{relationPhone},</if>
            <if test="dieTime != null">#{dieTime},</if>
            <if test="isDelete != null">#{isDelete},</if>
            <if test="status != null">#{status},</if>
            <if test="currentStatus != null">#{currentStatus},</if>
         </trim>
    </insert>

    <update id="updateBusDeviceHistory" parameterType="BusDeviceHistory">
        update bus_device_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="dId != null">d_id = #{dId},</if>
            <if test="pId != null">p_id = #{pId},</if>
            <if test="signTime != null">sign_time = #{signTime},</if>
            <if test="treatmentProject != null">treatment_project = #{treatmentProject},</if>
            <if test="alarm != null">alarm = #{alarm},</if>
            <if test="uploadTime != null">upload_time = #{uploadTime},</if>
            <if test="machineModel != null">machine_model = #{machineModel},</if>
            <if test="filterModel != null">filter_model = #{filterModel},</if>
            <if test="hemodialysisModel != null">hemodialysis_model = #{hemodialysisModel},</if>
            <if test="treatmentTime != null">treatment_time = #{treatmentTime},</if>
            <if test="targetDehydration != null">target_dehydration = #{targetDehydration},</if>
            <if test="bloodPumpRate != null">blood_pump_rate = #{bloodPumpRate},</if>
            <if test="flow != null">flow = #{flow},</if>
            <if test="k != null">k = #{k},</if>
            <if test="ca != null">ca = #{ca},</if>
            <if test="na != null">na = #{na},</if>
            <if test="hco3 != null">hco3 = #{hco3},</if>
            <if test="antithrombotic != null">antithrombotic = #{antithrombotic},</if>
            <if test="firstDose != null">first_dose = #{firstDose},</if>
            <if test="additionalDose != null">additional_dose = #{additionalDose},</if>
            <if test="vascularAccess != null">vascular_access = #{vascularAccess},</if>
            <if test="doctor != null">doctor = #{doctor},</if>
            <if test="nurse != null">nurse = #{nurse},</if>
            <if test="verifyPrescription != null">verify_prescription = #{verifyPrescription},</if>
            <if test="targetWeight != null">target_weight = #{targetWeight},</if>
            <if test="lastWeight != null">last_weight = #{lastWeight},</if>
            <if test="beforeWeight != null">before_weight = #{beforeWeight},</if>
            <if test="addWeight != null">add_weight = #{addWeight},</if>
            <if test="beforeSbp != null">before_sbp = #{beforeSbp},</if>
            <if test="beforeDbp != null">before_dbp = #{beforeDbp},</if>
            <if test="beforeSphygmus != null">before_sphygmus = #{beforeSphygmus},</if>
            <if test="beforeRr != null">before_rr = #{beforeRr},</if>
            <if test="beforeTemperature != null">before_temperature = #{beforeTemperature},</if>
            <if test="urineVolume != null">urine_volume = #{urineVolume},</if>
            <if test="gainWeight != null">gain_weight = #{gainWeight},</if>
            <if test="verifyBefore != null">verify_before = #{verifyBefore},</if>
            <if test="preDialysisWeight != null">pre_dialysis_weight = #{preDialysisWeight},</if>
            <if test="lossWeight != null">loss_weight = #{lossWeight},</if>
            <if test="afterTemperature != null">after_temperature = #{afterTemperature},</if>
            <if test="afterSbp != null">after_sbp = #{afterSbp},</if>
            <if test="afterDbp != null">after_dbp = #{afterDbp},</if>
            <if test="afterSphygmus != null">after_sphygmus = #{afterSphygmus},</if>
            <if test="afterRr != null">after_rr = #{afterRr},</if>
            <if test="verifyAfter != null">verify_after = #{verifyAfter},</if>
            <if test="deviceId != null">device_id = #{deviceId},</if>
            <if test="area != null">area = #{area},</if>
            <if test="bed != null">bed = #{bed},</if>
            <if test="brandName != null">brand_name = #{brandName},</if>
            <if test="model != null">model = #{model},</if>
            <if test="manufactureId != null">manufacture_id = #{manufactureId},</if>
            <if test="price != null">price = #{price},</if>
            <if test="infection != null">infection = #{infection},</if>
            <if test="code != null">code = #{code},</if>
            <if test="name != null">name = #{name},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="height != null">height = #{height},</if>
            <if test="age != null">age = #{age},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="source != null">source = #{source},</if>
            <if test="address != null">address = #{address},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="relationName != null">relation_name = #{relationName},</if>
            <if test="relationPhone != null">relation_phone = #{relationPhone},</if>
            <if test="dieTime != null">die_time = #{dieTime},</if>
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="status != null">status = #{status},</if>
            <if test="currentStatus != null">current_Status = #{currentStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateStatusByIds">
        update bus_device_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">status = #{status},</if>
        </trim>
        where id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>


    <delete id="deleteBusDeviceHistoryById" parameterType="Long">
        delete from bus_device_history where id = #{id}
    </delete>

    <delete id="deleteBusDeviceHistoryByIds" parameterType="String">
        delete from bus_device_history where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>