| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?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.nb.web.service.bus.mapper.BusDeviceConfigurationMapper">
- <resultMap id="deviceConfigurationResult" type="com.nb.web.service.bus.service.dto.DeviceConfigurationResult">
- <result column="id" property="id"/>
- <result column="device_id" property="deviceId"/>
- <result column="alias" property="alias"/>
- <result column="type" property="type"/>
- <result column="total_dose" property="totalDose"/>
- <result column="first_dose" property="firstDose"/>
- <result column="max_dose" property="maxDose"/>
- <result column="append_dose" property="appendDose"/>
- <result column="continue_dose" property="continueDose"/>
- <result column="self_control_lock_time" property="selfControlLockTime"/>
- <result column="patient_code" property="patientCode"/>
- </resultMap>
- <select id="selectByQuery" resultMap="deviceConfigurationResult" parameterType="com.nb.web.service.bus.service.dto.DeviceConfigurationQuery">
- SELECT
- dc.id AS id,
- d.device_id AS device_id,
- d.alias AS alias,
- d.type AS type,
- dc.total_dose as total_dose,
- dc.first_dose as first_dose,
- dc.max_dose as max_dose,
- dc.append_dose as append_dose,
- dc.continue_dose as continue_dose,
- dc.self_control_lock_time as self_control_lock_time,
- dc.patient_code as patient_code
- FROM
- (select * from bus_device
- <where>
- <if test="query.deviceId!=null">
- device_id = #{query.deviceId}
- </if>
- <if test="query.alias!=null">
- and alias like concat('%',#{query.alias},'%')
- </if>
- </where>
- )AS d
- LEFT JOIN bus_device_configuration AS dc ON d.device_id = dc.device_id
- <where>
- <if test="query.deviceTypes != null and query.deviceTypes.size > 0">
- d.type in
- <foreach item="type" index="index" collection="query.deviceTypes" open="(" separator="," close=")">
- #{type, jdbcType=VARCHAR}
- </foreach>
- </if>
- </where>
- ORDER BY
- device_id
- </select>
- <insert id="insertNew" parameterType="com.nb.web.api.entity.BusDeviceConfigurationEntity">
- INSERT INTO bus_device_configuration ( device_id, alias, type, tenant_id, total_dose, first_dose, max_dose, append_dose, continue_dose, self_control_lock_time, patient_code ) SELECT
- #{entity.deviceId},
- #{entity.alias},
- #{entity.type, jdbcType=VARCHAR},
- #{entity.tenantId},
- #{entity.totalDose},
- #{entity.firstDose},
- #{entity.maxDose},
- #{entity.appendDose},
- #{entity.continueDose},
- #{entity.selfControlLockTime},
- #{entity.patientCode}
- FROM
- DUAL
- WHERE
- NOT EXISTS (
- SELECT
- device_id
- FROM
- bus_device_configuration
- WHERE
- device_id = #{entity.deviceId}
- )
- </insert>
- <update id="updateByDeviceId" parameterType="com.nb.web.api.entity.BusDeviceConfigurationEntity">
- UPDATE bus_device_configuration
- <set>
- alias = #{entity.alias},
- type = #{entity.type, jdbcType=VARCHAR},
- tenant_id = #{entity.tenantId},
- total_dose = #{entity.totalDose},
- first_dose = #{entity.firstDose},
- max_dose = #{entity.maxDose},
- append_dose = #{entity.appendDose},
- continue_dose = #{entity.continueDose},
- self_control_lock_time = #{entity.selfControlLockTime},
- patient_code = #{entity.patientCode}
- </set>
- WHERE
- device_id = #{entity.deviceId}
- </update>
- </mapper>
|