SparePartInfoMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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.platform.dao.mapper.sqarepartmanage.SparePartInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.platform.dao.entity.sqarepartmanage.SparePartInfo">
  5. <id column="id" jdbcType="VARCHAR" property="id"/>
  6. <result column="unite_no" jdbcType="VARCHAR" property="uniteNo"/>
  7. <result column="no" jdbcType="VARCHAR" property="no"/>
  8. <result column="init_no" jdbcType="VARCHAR" property="initNo"/>
  9. <result column="name_no" jdbcType="VARCHAR" property="nameNo"/>
  10. <result column="gg_no" jdbcType="VARCHAR" property="ggNo"/>
  11. <result column="name" jdbcType="VARCHAR" property="name"/>
  12. <result column="type_id" jdbcType="VARCHAR" property="typeId"/>
  13. <result column="parent_type_id" jdbcType="VARCHAR" property="parentTypeId"/>
  14. <result column="middle_type_id" jdbcType="VARCHAR" property="middleTypeId"/>
  15. <result column="child_type_id" jdbcType="VARCHAR" property="childTypeId"/>
  16. <result column="parent_no" jdbcType="VARCHAR" property="parentNo"/>
  17. <result column="middle_no" jdbcType="VARCHAR" property="middleNo"/>
  18. <result column="child_no" jdbcType="VARCHAR" property="childNo"/>
  19. <result column="image" jdbcType="VARCHAR" property="image"/>
  20. <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
  21. <result column="level" jdbcType="SMALLINT" property="level"/>
  22. <result column="initial_value" jdbcType="DOUBLE" property="initialValue"/>
  23. <result column="producer_id" jdbcType="VARCHAR" property="producerId"/>
  24. <result column="supplier_id" jdbcType="VARCHAR" property="supplierId"/>
  25. <result column="unit" jdbcType="SMALLINT" property="unit"/>
  26. <result column="unit_bz" jdbcType="SMALLINT" property="unitBz"/>
  27. <result column="unit_rate" jdbcType="DOUBLE" property="unitRate"/>
  28. <result column="max_stock" jdbcType="DOUBLE" property="maxStock"/>
  29. <result column="min_stock" jdbcType="DOUBLE" property="minStock"/>
  30. <result column="init_stock" jdbcType="DOUBLE" property="initStock"/>
  31. <result column="zbh" jdbcType="VARCHAR" property="zbh"/>
  32. <result column="ggxh" jdbcType="VARCHAR" property="ggxh"/>
  33. <result column="english_name" jdbcType="VARCHAR" property="englishName"/>
  34. <result column="zjm" jdbcType="VARCHAR" property="zjm"/>
  35. <result column="cd" jdbcType="INTEGER" property="cd"/>
  36. <result column="yt" jdbcType="INTEGER" property="yt"/>
  37. <result column="purchase_period" jdbcType="DATE" property="purchasePeriod"/>
  38. <result column="use_period" jdbcType="DATE" property="usePeriod"/>
  39. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  40. <result column="created_user_id" jdbcType="VARCHAR" property="createdUserId"/>
  41. <result column="update_user_id" jdbcType="VARCHAR" property="updateUserId"/>
  42. <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
  43. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  44. <association column="type_id" javaType="string" property="typeName"
  45. select="com.platform.dao.mapper.sqarepartmanage.SpareTypeMapper.selectNameById"/>
  46. <association column="producer_id" javaType="string" property="producerName"
  47. select="com.platform.dao.mapper.firm.FirmProducerMapper.selectNameById"/>
  48. <association column="supplier_id" javaType="string" property="supplierName"
  49. select="com.platform.dao.mapper.purchase.SupplierMapper.selectNameById"/>
  50. </resultMap>
  51. <sql id="Base_Column_List">
  52. id, no, unite_no, gg_no, name_no, name, type_id, level, initial_value, producer_id,
  53. unit,
  54. purchase_period,
  55. use_period,
  56. unit_bz,
  57. unit_rate,
  58. image,
  59. qr_code,
  60. max_stock, min_stock,init_stock,supplier_id,
  61. remark, created_user_id, update_user_id, created_time, update_time,
  62. zbh,init_no,
  63. parent_type_id,
  64. child_type_id,
  65. middle_type_id,
  66. child_no,
  67. parent_no,
  68. middle_no,
  69. ggxh,
  70. english_name,
  71. zjm,
  72. cd,
  73. yt
  74. </sql>
  75. <select id="selectPageList" parameterType="com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO"
  76. resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
  77. select info.*
  78. from t_spare_part_info info
  79. <if test="storeId != null and storeId != ''">
  80. LEFT JOIN t_spare_store spare on spare.spare_id = info.id
  81. </if>
  82. <where>
  83. <if test="keyword != null and keyword != ''">
  84. AND ( info.name like concat('%',#{keyword},'%') or
  85. info.no like concat('%',#{keyword},'%'))
  86. </if>
  87. <if test="name != null and name != ''">
  88. AND info.name = #{name}
  89. </if>
  90. <if test="ggxh != null and ggxh != ''">
  91. AND info.ggxh like concat('%',#{ggxh},'%')
  92. </if>
  93. <if test="initNo != null and initNo != ''">
  94. AND info.init_no like concat('%',#{initNo},'%')
  95. </if>
  96. <if test="yt != null">
  97. AND info.yt=#{yt}
  98. </if>
  99. <if test="storeId != null and storeId != ''">
  100. AND spare.store_id=#{storeId}
  101. </if>
  102. <if test="level != null and level != ''">
  103. AND info.level=#{level}
  104. </if>
  105. <if test="typeIds != null and typeIds.size > 0">
  106. AND info.type_id in
  107. <foreach item="item" index="index" collection="typeIds" open="(" close=")" separator=",">
  108. #{item}
  109. </foreach>
  110. </if>
  111. <if test="producerId != null and producerId != ''">
  112. AND info.producer_id=#{producerId}
  113. </if>
  114. <if test="supplierId != null and producerId != ''">
  115. AND info.supplier_id=#{supplierId}
  116. </if>
  117. <if test="parentTypeId != null and parentTypeId != ''">
  118. AND info.parent_type_id=#{parentTypeId}
  119. </if>
  120. <!-- <if test="typeId != null and typeId != ''">
  121. AND info.type_id=#{typeId}
  122. </if>-->
  123. <if test="parentNo != null and parentNo != ''">
  124. AND info.parent_no=#{parentNo}
  125. </if>
  126. <if test="childNo != null and childNo != ''">
  127. AND info.child_no=#{childNo}
  128. </if>
  129. </where>
  130. </select>
  131. <select id="selectById" parameterType="java.lang.Object" resultMap="BaseResultMap">
  132. select
  133. <include refid="Base_Column_List"/>
  134. from t_spare_part_info
  135. where id = #{value}
  136. </select>
  137. <select id="selectNameById" parameterType="java.lang.Object" resultType="java.lang.String">
  138. select name
  139. from t_spare_part_info
  140. where id = #{value}
  141. </select>
  142. <select id="selectSpareInfoList" resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
  143. select spare.id as spareId, spare.no, spare.unite_no, spare.name, spare.type_id, spare.level,
  144. spare.initial_value, spare.producer_id,
  145. spare.unit,
  146. spare.unit_bz,
  147. spare.unit_rate,
  148. spare.image,
  149. spare.qr_code,
  150. spare.zbh,spare.init_no,
  151. spare.gg_no, spare.name_no,
  152. spare.ggxh,
  153. spare.english_name,
  154. spare.zjm,
  155. spare.cd,
  156. spare.yt,
  157. tcpsr.id as id,
  158. tcpsr.period,
  159. tcpsr.period_type as periodType,
  160. tcpsr.sb_id as sbId, tcpsr.num as num,
  161. part.name as sbPartName
  162. from t_spare_part_info spare
  163. left join t_sb_model_spare_bom tcpsr on tcpsr.spare_id=spare.id
  164. LEFT JOIN t_part_info part on tcpsr.sb_part_id = part.id
  165. where tcpsr.model_id = #{id}
  166. </select>
  167. <select id="selectSpareInfoListBySbId" resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
  168. select spare.id as spareId, spare.no, spare.unite_no, spare.name, spare.type_id, spare.level,
  169. spare.initial_value, spare.producer_id,
  170. spare.unit,
  171. spare.unit_bz,
  172. spare.unit_rate,
  173. spare.image,
  174. spare.qr_code,
  175. spare.zbh,spare.init_no,
  176. spare.gg_no, spare.name_no,
  177. spare.ggxh,
  178. spare.english_name,
  179. spare.zjm,
  180. spare.cd,
  181. spare.yt,
  182. tcpsr.id as id,
  183. tcpsr.period,
  184. tcpsr.period_type as periodType,
  185. tcpsr.model_id as modelId, tcpsr.num as num,
  186. part.name as sbPartName
  187. from t_spare_part_info spare
  188. left join t_sb_model_spare_bom tcpsr on tcpsr.spare_id=spare.id
  189. LEFT JOIN t_part_info part on tcpsr.sb_part_id = part.id
  190. where tcpsr.sb_id = #{id}
  191. </select>
  192. <update id="updateBatch" parameterType="java.util.List">
  193. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  194. update t_spare_part_info
  195. <set>
  196. <if test="item.parentTypeId != null">
  197. parent_type_id = #{item.parentTypeId},
  198. </if>
  199. <if test="item.childTypeId != null">
  200. child_type_id = #{item.childTypeId},
  201. </if>
  202. <if test="item.middleTypeId != null">
  203. middle_type_id = #{item.middleTypeId},
  204. </if>
  205. <if test="item.parentTypeId == null">
  206. parent_type_id = null,
  207. </if>
  208. <if test="item.childTypeId == null">
  209. child_type_id = null,
  210. </if>
  211. <if test="item.middleTypeId == null">
  212. middle_type_id = null,
  213. </if>
  214. <if test="item.parentNo != null">
  215. parent_no = #{item.parentNo},
  216. </if>
  217. <if test="item.middleNo != null">
  218. middle_no = #{item.middleNo},
  219. </if>
  220. <if test="item.unit != null">
  221. child_no = #{item.childNo},
  222. </if>
  223. <if test="item.typeId != null">
  224. type_id = #{item.typeId},
  225. </if>
  226. <if test="item.ggxh != null">
  227. ggxh = #{item.ggxh},
  228. </if>
  229. <if test="item.name != null">
  230. name = #{item.name},
  231. </if>
  232. <if test="item.unit != null">
  233. unit = #{item.unit},
  234. </if>
  235. <if test="item.initNo != null">
  236. init_no = #{item.initNo},
  237. </if>
  238. <if test="item.initialValue != null">
  239. initial_value = #{item.initialValue}
  240. </if>
  241. </set>
  242. where id = #{item.id}
  243. </foreach>
  244. </update>
  245. </mapper>