BusDeviceConfigurationMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.nb.web.service.bus.mapper.BusDeviceConfigurationMapper">
  4. <resultMap id="deviceConfigurationResult" type="com.nb.web.service.bus.service.dto.DeviceConfigurationResult">
  5. <result column="id" property="id"/>
  6. <result column="device_id" property="deviceId"/>
  7. <result column="alias" property="alias"/>
  8. <result column="type" property="type"/>
  9. <result column="total_dose" property="totalDose"/>
  10. <result column="first_dose" property="firstDose"/>
  11. <result column="max_dose" property="maxDose"/>
  12. <result column="append_dose" property="appendDose"/>
  13. <result column="continue_dose" property="continueDose"/>
  14. <result column="self_control_lock_time" property="selfControlLockTime"/>
  15. <result column="patient_code" property="patientCode"/>
  16. </resultMap>
  17. <select id="selectByQuery" resultMap="deviceConfigurationResult" parameterType="com.nb.web.service.bus.service.dto.DeviceConfigurationQuery">
  18. SELECT
  19. dc.id AS id,
  20. d.device_id AS device_id,
  21. d.alias AS alias,
  22. d.type AS type,
  23. dc.total_dose as total_dose,
  24. dc.first_dose as first_dose,
  25. dc.max_dose as max_dose,
  26. dc.append_dose as append_dose,
  27. dc.continue_dose as continue_dose,
  28. dc.self_control_lock_time as self_control_lock_time,
  29. dc.patient_code as patient_code
  30. FROM
  31. (select * from bus_device
  32. <where>
  33. <if test="query.deviceId!=null">
  34. device_id = #{query.deviceId}
  35. </if>
  36. <if test="query.alias!=null">
  37. and alias like concat('%',#{query.alias},'%')
  38. </if>
  39. </where>
  40. )AS d
  41. LEFT JOIN bus_device_configuration AS dc ON d.device_id = dc.device_id
  42. <where>
  43. <if test="query.deviceTypes != null and query.deviceTypes.size > 0">
  44. d.type in
  45. <foreach item="type" index="index" collection="query.deviceTypes" open="(" separator="," close=")">
  46. #{type, jdbcType=VARCHAR}
  47. </foreach>
  48. </if>
  49. </where>
  50. ORDER BY
  51. device_id
  52. </select>
  53. <insert id="insertNew" parameterType="com.nb.web.api.entity.BusDeviceConfigurationEntity">
  54. 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
  55. #{entity.deviceId},
  56. #{entity.alias},
  57. #{entity.type, jdbcType=VARCHAR},
  58. #{entity.tenantId},
  59. #{entity.totalDose},
  60. #{entity.firstDose},
  61. #{entity.maxDose},
  62. #{entity.appendDose},
  63. #{entity.continueDose},
  64. #{entity.selfControlLockTime},
  65. #{entity.patientCode}
  66. FROM
  67. DUAL
  68. WHERE
  69. NOT EXISTS (
  70. SELECT
  71. device_id
  72. FROM
  73. bus_device_configuration
  74. WHERE
  75. device_id = #{entity.deviceId}
  76. )
  77. </insert>
  78. <update id="updateByDeviceId" parameterType="com.nb.web.api.entity.BusDeviceConfigurationEntity">
  79. UPDATE bus_device_configuration
  80. <set>
  81. alias = #{entity.alias},
  82. type = #{entity.type, jdbcType=VARCHAR},
  83. tenant_id = #{entity.tenantId},
  84. total_dose = #{entity.totalDose},
  85. first_dose = #{entity.firstDose},
  86. max_dose = #{entity.maxDose},
  87. append_dose = #{entity.appendDose},
  88. continue_dose = #{entity.continueDose},
  89. self_control_lock_time = #{entity.selfControlLockTime},
  90. patient_code = #{entity.patientCode}
  91. </set>
  92. WHERE
  93. device_id = #{entity.deviceId}
  94. </update>
  95. </mapper>