SparePartInfoMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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="is_special" jdbcType="SMALLINT" property="isSpecial"/>
  23. <result column="initial_value" jdbcType="DOUBLE" property="initialValue"/>
  24. <result column="producer_id" jdbcType="VARCHAR" property="producerId"/>
  25. <result column="supplier_id" jdbcType="VARCHAR" property="supplierId"/>
  26. <result column="unit" jdbcType="VARCHAR" property="unit"/>
  27. <result column="warn_status" jdbcType="SMALLINT" property="warnStatus"/>
  28. <result column="forecast_status" jdbcType="SMALLINT" property="forecastStatus"/>
  29. <result column="unit_bz" jdbcType="SMALLINT" property="unitBz"/>
  30. <result column="unit_rate" jdbcType="DOUBLE" property="unitRate"/>
  31. <result column="max_stock" jdbcType="DOUBLE" property="maxStock"/>
  32. <result column="min_stock" jdbcType="DOUBLE" property="minStock"/>
  33. <result column="init_stock" jdbcType="DOUBLE" property="initStock"/>
  34. <result column="zbh" jdbcType="VARCHAR" property="zbh"/>
  35. <result column="ggxh" jdbcType="VARCHAR" property="ggxh"/>
  36. <result column="english_name" jdbcType="VARCHAR" property="englishName"/>
  37. <result column="zjm" jdbcType="VARCHAR" property="zjm"/>
  38. <result column="cd" jdbcType="INTEGER" property="cd"/>
  39. <result column="yt" jdbcType="INTEGER" property="yt"/>
  40. <result column="purchase_period" jdbcType="DECIMAL" property="purchasePeriod"/>
  41. <result column="age_period" jdbcType="DECIMAL" property="agePeriod"/>
  42. <result column="use_period" jdbcType="DECIMAL" property="usePeriod"/>
  43. <result column="params" jdbcType="VARCHAR" property="params"/>
  44. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  45. <result column="created_user_id" jdbcType="VARCHAR" property="createdUserId"/>
  46. <result column="update_user_id" jdbcType="VARCHAR" property="updateUserId"/>
  47. <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
  48. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  49. <association column="type_id" javaType="string" property="typeName"
  50. select="com.platform.dao.mapper.sqarepartmanage.SpareTypeMapper.selectNameById"/>
  51. <association column="producer_id" javaType="string" property="producerName"
  52. select="com.platform.dao.mapper.firm.FirmProducerMapper.selectNameById"/>
  53. <association column="supplier_id" javaType="string" property="supplierName"
  54. select="com.platform.dao.mapper.purchase.SupplierMapper.selectNameById"/>
  55. </resultMap>
  56. <sql id="Base_Column_List">
  57. id, no, unite_no, gg_no, name_no, name, type_id, level, initial_value, producer_id,
  58. unit,
  59. is_special,
  60. purchase_period,
  61. use_period,age_period,
  62. unit_bz,
  63. warn_status,forecast_status,
  64. unit_rate,
  65. image,
  66. qr_code,
  67. max_stock, min_stock,init_stock,supplier_id,
  68. remark, created_user_id, update_user_id, created_time, update_time,
  69. zbh,init_no,
  70. parent_type_id,
  71. child_type_id,
  72. middle_type_id,
  73. child_no,
  74. parent_no,
  75. middle_no,
  76. ggxh,
  77. english_name,
  78. zjm,
  79. cd,
  80. yt
  81. </sql>
  82. <select id="selectPageList" parameterType="com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO"
  83. resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
  84. select info.*, SUM(spareStore.num) currentStock
  85. from t_spare_part_info info
  86. LEFT JOIN t_spare_store spareStore on spareStore.spare_id = info.id
  87. <if test="producerName != null and producerName != ''">
  88. LEFT JOIN t_firm_producer producer on producer.id = info.producer_id
  89. </if>
  90. <if test="supplierName != null and supplierName != ''">
  91. LEFT JOIN t_supplier supplier on supplier.id = info.supplier_id
  92. </if>
  93. <where>
  94. <if test="spareIdList != null and spareIdList.size > 0">
  95. and sparestore.spare_id in
  96. <foreach item="item" index="index" collection="spareIdList" open="(" close=")" separator=",">
  97. #{item}
  98. </foreach>
  99. </if>
  100. <if test="warnStatusList != null and warnStatusList.size > 0">
  101. AND info.warn_status in
  102. <foreach item="item" index="index" collection="warnStatusList" open="(" close=")" separator=",">
  103. #{item}
  104. </foreach>
  105. </if>
  106. <if test="forecastStatusList != null and forecastStatusList.size > 0">
  107. AND info.forecast_status in
  108. <foreach item="item" index="index" collection="forecastStatusList" open="(" close=")" separator=",">
  109. #{item}
  110. </foreach>
  111. </if>
  112. <if test="typeId != null and typeId != ''">
  113. and info.type_id = #{typeId}
  114. </if>
  115. <if test="isSpecial != null and isSpecial != ''">
  116. and info.is_special = #{isSpecial}
  117. </if>
  118. <if test="producerName != null and producerName != ''">
  119. AND producer.name like concat('%',#{producerName},'%')
  120. </if>
  121. <if test="supplierName != null and supplierName != ''">
  122. AND supplier.name like concat('%',#{supplierName},'%')
  123. </if>
  124. <if test="keyword != null and keyword != ''">
  125. AND ( info.name like concat('%',#{keyword},'%') or
  126. info.no like concat('%',#{keyword},'%'))
  127. </if>
  128. <if test="name != null and name != ''">
  129. AND info.name = #{name}
  130. </if>
  131. <if test="warnStatus != null and warnStatus != ''">
  132. AND info.warn_status = #{warnStatus}
  133. </if>
  134. <if test="forecastStatus != null and forecastStatus != ''">
  135. AND info.forecast_status = #{forecastStatus}
  136. </if>
  137. <if test="ggxh != null and ggxh != ''">
  138. AND info.ggxh like concat('%',#{ggxh},'%')
  139. </if>
  140. <if test="initNo != null and initNo != ''">
  141. AND info.init_no like concat('%',#{initNo},'%')
  142. </if>
  143. <if test="yt != null">
  144. AND info.yt=#{yt}
  145. </if>
  146. <if test="storeId != null and storeId != ''">
  147. AND spare.store_id=#{storeId}
  148. </if>
  149. <if test="level != null and level != ''">
  150. AND info.level=#{level}
  151. </if>
  152. <if test="typeIds != null and typeIds.size > 0">
  153. AND info.type_id in
  154. <foreach item="item" index="index" collection="typeIds" open="(" close=")" separator=",">
  155. #{item}
  156. </foreach>
  157. </if>
  158. <if test="producerId != null and producerId != ''">
  159. AND info.producer_id=#{producerId}
  160. </if>
  161. <if test="supplierId != null and producerId != ''">
  162. AND info.supplier_id=#{supplierId}
  163. </if>
  164. <if test="parentTypeId != null and parentTypeId != ''">
  165. AND info.parent_type_id=#{parentTypeId}
  166. </if>
  167. <!-- <if test="typeId != null and typeId != ''">
  168. AND info.type_id=#{typeId}
  169. </if>-->
  170. <if test="parentNo != null and parentNo != ''">
  171. AND info.parent_no=#{parentNo}
  172. </if>
  173. <if test="childNo != null and childNo != ''">
  174. AND info.child_no=#{childNo}
  175. </if>
  176. <if test="searchMinStockWarn">
  177. AND info.min_stock is not null
  178. </if>
  179. <if test="searchMinStockWarn">
  180. AND info.warn_status = 0
  181. </if>
  182. <if test="searchType">
  183. AND info.type_id not in (select id from t_spare_type)
  184. </if>
  185. </where>
  186. group by info.id
  187. <if test="searchMinStockWarn">
  188. HAVING info.min_stock > SUM( spareStore.num )
  189. </if>
  190. </select>
  191. <select id="selectMaxNo" parameterType="java.lang.Object" resultType="java.lang.String">
  192. select max(no) from t_spare_part_info
  193. where type_id = #{value}
  194. </select>
  195. <select id="selectById" parameterType="java.lang.Object" resultMap="BaseResultMap">
  196. select
  197. <include refid="Base_Column_List"/>
  198. from t_spare_part_info
  199. where id = #{value}
  200. </select>
  201. <select id="selectNameById" parameterType="java.lang.Object" resultType="java.lang.String">
  202. select name
  203. from t_spare_part_info
  204. where id = #{value}
  205. </select>
  206. <select id="selectSpareInfoList" resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
  207. select spare.id as spareId, spare.no, spare.unite_no, spare.name, spare.type_id, spare.level,
  208. spare.initial_value, spare.producer_id,
  209. spare.unit,
  210. spare.unit_bz,spare.warn_status, spare.forecast_status,
  211. spare.unit_rate,
  212. spare.image,
  213. spare.qr_code,
  214. spare.zbh,spare.init_no,
  215. spare.gg_no, spare.name_no,
  216. spare.ggxh,
  217. spare.english_name,
  218. spare.zjm,
  219. spare.cd,
  220. spare.yt,
  221. tcpsr.id as id,
  222. tcpsr.period,
  223. tcpsr.period_type as periodType,
  224. tcpsr.sb_id as sbId, tcpsr.num as num,
  225. part.name as sbPartName
  226. from t_spare_part_info spare
  227. left join t_sb_model_spare_bom tcpsr on tcpsr.spare_id=spare.id
  228. LEFT JOIN t_part_info part on tcpsr.sb_part_id = part.id
  229. where tcpsr.sb_id = #{id}
  230. </select>
  231. <select id="selectSpareInfoListBySbId" resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
  232. select spare.id as spareId, spare.no, spare.unite_no, spare.name, spare.type_id, spare.level,
  233. spare.initial_value, spare.producer_id,
  234. spare.unit,
  235. spare.unit_bz,spare.warn_status, spare.forecast_status,
  236. spare.unit_rate,
  237. spare.image,
  238. spare.qr_code,
  239. spare.zbh,spare.init_no,
  240. spare.gg_no, spare.name_no,
  241. spare.ggxh,
  242. spare.english_name,
  243. spare.zjm,
  244. spare.cd,
  245. spare.yt,
  246. tcpsr.id as id,
  247. tcpsr.period,
  248. tcpsr.period_type as periodType,
  249. tcpsr.model_id as modelId,
  250. tcpsr.sb_id as sbId,
  251. part.name as sbPartName
  252. from t_spare_part_info spare
  253. left join t_sb_model_spare_bom tcpsr on tcpsr.spare_id=spare.id
  254. LEFT JOIN t_part_info part on tcpsr.sb_part_id = part.id
  255. where tcpsr.sb_id = #{id}
  256. </select>
  257. <update id="updateBatch" parameterType="java.util.List">
  258. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  259. update t_spare_part_info
  260. <set>
  261. <if test="item.parentTypeId != null">
  262. parent_type_id = #{item.parentTypeId},
  263. </if>
  264. <if test="item.childTypeId != null">
  265. child_type_id = #{item.childTypeId},
  266. </if>
  267. <if test="item.middleTypeId != null">
  268. middle_type_id = #{item.middleTypeId},
  269. </if>
  270. <if test="item.parentTypeId == null">
  271. parent_type_id = null,
  272. </if>
  273. <if test="item.childTypeId == null">
  274. child_type_id = null,
  275. </if>
  276. <if test="item.middleTypeId == null">
  277. middle_type_id = null,
  278. </if>
  279. <if test="item.parentNo != null">
  280. parent_no = #{item.parentNo},
  281. </if>
  282. <if test="item.middleNo != null">
  283. middle_no = #{item.middleNo},
  284. </if>
  285. <if test="item.warnStatus != null">
  286. warn_status = #{item.warnStatus},
  287. </if>
  288. <if test="item.forecastStatus != null">
  289. forecast_status = #{item.forecastStatus},
  290. </if>
  291. <if test="item.isSpecial != null">
  292. is_special = #{item.isSpecial},
  293. </if>
  294. <if test="item.unit != null">
  295. child_no = #{item.childNo},
  296. </if>
  297. <if test="item.typeId != null">
  298. type_id = #{item.typeId},
  299. </if>
  300. <if test="item.ggxh != null">
  301. ggxh = #{item.ggxh},
  302. </if>
  303. <if test="item.name != null">
  304. name = #{item.name},
  305. </if>
  306. <if test="item.unit != null">
  307. unit = #{item.unit},
  308. </if>
  309. <if test="item.initNo != null">
  310. init_no = #{item.initNo},
  311. </if>
  312. <if test="item.initialValue != null">
  313. initial_value = #{item.initialValue}
  314. </if>
  315. </set>
  316. where id = #{item.id}
  317. </foreach>
  318. </update>
  319. </mapper>