FsPrescribeDrugMapper.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.his.mapper.FsPrescribeDrugMapper">
  6. <resultMap type="FsPrescribeDrug" id="FsPrescribeDrugResult">
  7. <result property="drugId" column="drug_id" />
  8. <result property="prescribeId" column="prescribe_id" />
  9. <result property="drugName" column="drug_name" />
  10. <result property="drugSpec" column="drug_spec" />
  11. <result property="usageMethod" column="usage_method" />
  12. <result property="usageFrequencyUnit" column="usage_frequency_unit" />
  13. <result property="usagePerUseCount" column="usage_per_use_count" />
  14. <result property="usagePerUseUnit" column="usage_per_use_unit" />
  15. <result property="usageDays" column="usage_days" />
  16. <result property="drugPrice" column="drug_price" />
  17. <result property="drugNum" column="drug_num" />
  18. <result property="drugUnit" column="drug_unit" />
  19. <result property="instructions" column="instructions" />
  20. <result property="drugImgUrl" column="drug_img_url" />
  21. <result property="productId" column="product_id" />
  22. <result property="productAttrValueId" column="product_attr_value_id" />
  23. <result property="remark" column="remark" />
  24. <result property="drugType" column="drug_type" />
  25. <result property="isDrug" column="is_drug" />
  26. </resultMap>
  27. <sql id="selectFsPrescribeDrugVo">
  28. select drug_id, prescribe_id,is_drug, drug_name, drug_spec, usage_method, usage_frequency_unit, usage_per_use_count, usage_per_use_unit, usage_days, drug_num,drug_price, drug_unit, instructions,drug_img_url, product_id,product_attr_value_id,remark,drug_type from fs_prescribe_drug
  29. </sql>
  30. <select id="selectFsPrescribeDrugList" parameterType="FsPrescribeDrug" resultMap="FsPrescribeDrugResult">
  31. <include refid="selectFsPrescribeDrugVo"/>
  32. <where>
  33. <if test="prescribeId != null "> and prescribe_id = #{prescribeId}</if>
  34. <if test="drugName != null and drugName != ''"> and drug_name like concat('%', #{drugName}, '%')</if>
  35. <if test="drugSpec != null and drugSpec != ''"> and drug_spec = #{drugSpec}</if>
  36. <if test="usageMethod != null and usageMethod != ''"> and usage_method = #{usageMethod}</if>
  37. <if test="usageFrequencyUnit != null and usageFrequencyUnit != ''"> and usage_frequency_unit = #{usageFrequencyUnit}</if>
  38. <if test="usagePerUseCount != null and usagePerUseCount != ''"> and usage_per_use_count = #{usagePerUseCount}</if>
  39. <if test="usagePerUseUnit != null and usagePerUseUnit != ''"> and usage_per_use_unit = #{usagePerUseUnit}</if>
  40. <if test="usageDays != null and usageDays != ''"> and usage_days = #{usageDays}</if>
  41. <if test="instructions != null and instructions != ''"> and instructions = #{instructions}</if>
  42. <if test="productId != null "> and product_id = #{productId}</if>
  43. </where>
  44. </select>
  45. <select id="selectFsPrescribeDrugByDrugId" parameterType="Long" resultMap="FsPrescribeDrugResult">
  46. <include refid="selectFsPrescribeDrugVo"/>
  47. where drug_id = #{drugId}
  48. </select>
  49. <select id="selectDrugList" resultType="com.fs.his.domain.FsPrescribeDrugDTO">
  50. SELECT
  51. fpd.drug_id,
  52. fpd.prescribe_id,
  53. fpd.is_drug,
  54. fpd.drug_name,
  55. fpd.drug_spec,
  56. fpd.usage_method,
  57. fpd.usage_frequency_unit,
  58. fpd.usage_per_use_count,
  59. fpd.usage_per_use_unit,
  60. fpd.usage_days,
  61. fpd.drug_num,
  62. fpd.drug_price,
  63. fpd.drug_unit,
  64. fpd.instructions,
  65. fpd.drug_img_url,
  66. fpd.product_id,
  67. fpd.product_attr_value_id,
  68. fpd.remark,
  69. fpd.drug_type,
  70. fsp.bar_code
  71. FROM
  72. fs_prescribe_drug fpd
  73. LEFT JOIN fs_store_product fsp ON fsp.product_id = fpd.prescribe_id
  74. WHERE fpd.prescribe_id = #{prescribeId}
  75. </select>
  76. <insert id="insertFsPrescribeDrug" parameterType="FsPrescribeDrug" useGeneratedKeys="true" keyProperty="drugId">
  77. insert into fs_prescribe_drug
  78. <trim prefix="(" suffix=")" suffixOverrides=",">
  79. <if test="prescribeId != null">prescribe_id,</if>
  80. <if test="drugName != null">drug_name,</if>
  81. <if test="drugSpec != null">drug_spec,</if>
  82. <if test="usageMethod != null">usage_method,</if>
  83. <if test="usageFrequencyUnit != null">usage_frequency_unit,</if>
  84. <if test="usagePerUseCount != null">usage_per_use_count,</if>
  85. <if test="usagePerUseUnit != null">usage_per_use_unit,</if>
  86. <if test="usageDays != null">usage_days,</if>
  87. <if test="drugPrice != null">drug_price,</if>
  88. <if test="drugNum != null">drug_num,</if>
  89. <if test="drugUnit != null">drug_unit,</if>
  90. <if test="instructions != null">instructions,</if>
  91. <if test="productId != null">product_id,</if>
  92. <if test="drugImgUrl != null">drug_img_url,</if>
  93. <if test="productAttrValueId != null">product_attr_value_id,</if>
  94. <if test="remark != null">remark,</if>
  95. <if test="drugType != null">drug_type,</if>
  96. <if test="isDrug != null">is_drug,</if>
  97. </trim>
  98. <trim prefix="values (" suffix=")" suffixOverrides=",">
  99. <if test="prescribeId != null">#{prescribeId},</if>
  100. <if test="drugName != null">#{drugName},</if>
  101. <if test="drugSpec != null">#{drugSpec},</if>
  102. <if test="usageMethod != null">#{usageMethod},</if>
  103. <if test="usageFrequencyUnit != null">#{usageFrequencyUnit},</if>
  104. <if test="usagePerUseCount != null">#{usagePerUseCount},</if>
  105. <if test="usagePerUseUnit != null">#{usagePerUseUnit},</if>
  106. <if test="usageDays != null">#{usageDays},</if>
  107. <if test="drugPrice != null">#{drugPrice},</if>
  108. <if test="drugNum != null">#{drugNum},</if>
  109. <if test="drugUnit != null">#{drugUnit},</if>
  110. <if test="instructions != null">#{instructions},</if>
  111. <if test="productId != null">#{productId},</if>
  112. <if test="drugImgUrl != null">#{drugImgUrl},</if>
  113. <if test="productAttrValueId != null">#{productAttrValueId},</if>
  114. <if test="remark != null">#{remark},</if>
  115. <if test="drugType != null">#{drugType},</if>
  116. <if test="isDrug != null">#{isDrug},</if>
  117. </trim>
  118. </insert>
  119. <update id="updateFsPrescribeDrug" parameterType="FsPrescribeDrug">
  120. update fs_prescribe_drug
  121. <trim prefix="SET" suffixOverrides=",">
  122. <if test="prescribeId != null">prescribe_id = #{prescribeId},</if>
  123. <if test="drugName != null">drug_name = #{drugName},</if>
  124. <if test="drugSpec != null">drug_spec = #{drugSpec},</if>
  125. <if test="usageMethod != null">usage_method = #{usageMethod},</if>
  126. <if test="usageFrequencyUnit != null">usage_frequency_unit = #{usageFrequencyUnit},</if>
  127. <if test="usagePerUseCount != null">usage_per_use_count = #{usagePerUseCount},</if>
  128. <if test="usagePerUseUnit != null">usage_per_use_unit = #{usagePerUseUnit},</if>
  129. <if test="usageDays != null">usage_days = #{usageDays},</if>
  130. <if test="drugPrice != null">drug_price = #{drugPrice},</if>
  131. <if test="drugNum != null">drug_num = #{drugNum},</if>
  132. <if test="drugUnit != null">drug_unit = #{drugUnit},</if>
  133. <if test="instructions != null">instructions = #{instructions},</if>
  134. <if test="productId != null">product_id = #{productId},</if>
  135. <if test="drugImgUrl != null">drug_img_url = #{drugImgUrl},</if>
  136. <if test="productAttrValueId != null">product_attr_value_id = #{productAttrValueId},</if>
  137. <if test="remark != null">remark = #{remark},</if>
  138. <if test="drugType != null">drug_type = #{drugType},</if>
  139. <if test="isDrug != null">is_drug = #{isDrug},</if>
  140. </trim>
  141. where drug_id = #{drugId}
  142. </update>
  143. <delete id="deleteFsPrescribeDrugByDrugId" parameterType="Long">
  144. delete from fs_prescribe_drug where drug_id = #{drugId}
  145. </delete>
  146. <delete id="deleteFsPrescribeDrugByDrugIds" parameterType="String">
  147. delete from fs_prescribe_drug where drug_id in
  148. <foreach item="drugId" collection="array" open="(" separator="," close=")">
  149. #{drugId}
  150. </foreach>
  151. </delete>
  152. </mapper>