ReceiveGoodsMapper.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.tld.mapper.ReceiveGoodsMapper">
  5. <!-- 查询收货单 -->
  6. <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
  7. select
  8. a.id,
  9. a.order_code,
  10. b.name as materialName,
  11. c.name as supplierName,
  12. a.purchase_num,
  13. a.arrival_num,
  14. a.type,
  15. a.qualified_num,
  16. a.disqualification_num,
  17. a.arrival_time,
  18. c.code as wllbCode
  19. from tld_receive_goods a
  20. left join tld_material b on a.material_id = b.tld_id
  21. left join tld_customer c on a.supplier_id = c.code
  22. <trim prefix="WHERE" prefixOverrides="and |or">
  23. <!-- <if test="materialId != null and materialId != ''">-->
  24. <!-- and a.material_id = #{materialId}-->
  25. <!-- </if>-->
  26. <if test="type != null and type != ''">
  27. and a.type = #{type}
  28. </if>
  29. <if test="startTime != null and startTime != ''">
  30. and a.arrival_time <![CDATA[>=]]> #{startTime}
  31. </if>
  32. <if test="endTime != null and endTime != ''">
  33. and a.arrival_time <![CDATA[<=]]> #{endTime}
  34. </if>
  35. <if test="orderCode != null and orderCode != ''">
  36. and a.order_code = #{orderCode}
  37. </if>
  38. </trim>
  39. order by a.id desc
  40. </select>
  41. <!-- 查询超时采购单 -->
  42. <select id="getPastReceiveGoods" resultType="com.tld.model.ReceiveGoods">
  43. select
  44. a.id,
  45. a.order_code,
  46. b.name as materialName,
  47. c.name as supplierName,
  48. a.purchase_num,
  49. a.arrival_num,
  50. a.type,
  51. a.qualified_num,
  52. a.disqualification_num,
  53. a.arrival_time
  54. from tld_receive_goods a
  55. left join tld_material b on a.material_id = b.tld_id
  56. left join tld_customer c on a.supplier_id = c.code
  57. where a.type = "0" and a.arrival_time <![CDATA[<]]> CURDATE()
  58. <if test="orderCode != null and orderCode != ''">
  59. and a.order_code = #{orderCode}
  60. </if>
  61. order by a.id desc
  62. </select>
  63. <!-- 查询采购父表是否有次采购单的数据 -->
  64. <select id="getReceiveGoodsf" resultType="int">
  65. select count(*) from tld_receive_goods_f where order_code = #{orderCode}
  66. </select>
  67. <!-- 新增采购单信息 -->
  68. <insert id="addReceiveGoods">
  69. insert into tld_receive_goods(order_code,material_id,purchase_num,arrival_num,type,qualified_num,disqualification_num,wbs,arrival_time,measurement_id,supplier_id,entry_number,warehousing_num)
  70. values(#{orderCode},#{materialId},#{purchaseNum},#{arrivalNum},#{type},#{qualifiedNum},#{disqualificationNum},#{wbs},#{arrivalTime},#{measurementId},#{supplierId},#{entryNumber},'0');
  71. </insert>
  72. <!-- 新增采购单信息 -->
  73. <insert id="addReceiveGoodsf">
  74. insert into tld_receive_goods_f(order_number,order_code,company_number,supplier_id,arrival_time,order_type,source_type,move_type)
  75. values(#{orderNumber},#{orderCode},#{companyNumber},#{supplierId},#{arrivalTime},#{orderType},#{sourceType},#{moveType})
  76. </insert>
  77. <!-- 修改采购单信息 -->
  78. <update id="updateReceiveGoods">
  79. update tld_receive_goods
  80. <set>
  81. <trim suffixOverrides=",">
  82. <if test="arrivalNum != null and arrivalNum != ''">
  83. arrival_num = #{arrivalNum},
  84. </if>
  85. <if test="qualifiedNum != null and qualifiedNum != ''">
  86. qualified_num = #{qualifiedNum},
  87. </if>
  88. <if test="disqualificationNum != null and disqualificationNum != ''">
  89. disqualification_num = #{disqualificationNum},
  90. </if>
  91. <if test="arrivalTime != null and arrivalTime != ''">
  92. arrival_time = #{arrivalTime},
  93. </if>
  94. <if test="type != null and type != ''">
  95. type = #{type},
  96. </if>
  97. </trim>
  98. </set>
  99. where order_code = #{orderCode};
  100. update tld_receive_goods_f
  101. <set>
  102. <trim suffixOverrides=",">
  103. <if test="supplierId != null and supplierId != ''">
  104. supplier_id = #{supplierId},
  105. </if>
  106. <if test="arrivalTime != null and arrivalTime != ''">
  107. arrival_time = #{arrivalTime},
  108. </if>
  109. <if test="orderType != null and orderType != ''">
  110. order_type = #{orderType},
  111. </if>
  112. <if test="sourceType != null and sourceType != ''">
  113. source_type = #{sourceType},
  114. </if>
  115. <if test="moveType != null and moveType != ''">
  116. move_type = #{moveType},
  117. </if>
  118. </trim>
  119. </set>
  120. where order_code = #{orderCode};
  121. </update>
  122. <!-- 采购单日志 -->
  123. <insert id="addReceiveGoodsLog" keyProperty="id" useGeneratedKeys="true">
  124. insert into tld_receive_goods_log(order_number, order_code, company_number, supplier_id, arrival_time, order_type, source_type, move_type, material_id, purchase_num, arrival_num, qualified_num, disqualification_num, wbs, measurement_id)
  125. values (#{orderNumber}, #{orderCode}, #{companyNumber}, #{supplierId}, #{arrivalTime}, #{orderType}, #{sourceType}, #{moveType}, #{materialId}, #{purchaseNum}, #{arrivalNum}, #{qualifiedNum}, #{disqualificationNum}, #{wbs}, #{measurementId})
  126. </insert>
  127. <!-- 新增采购到料大屏信息 -->
  128. <insert id="addPurchase">
  129. insert into tld_purchase(supplier_id,order_code,material_id,purchase_num,arrival_num,arrival_time,type)
  130. values
  131. <foreach collection="jsonData" index="index" item="item" separator=",">
  132. (#{item.supplierId},#{item.orderCode},#{item.materialId},#{item.purchaseNum},#{item.arrivalNum},#{item.arrivalTime},'0')
  133. </foreach>
  134. </insert>
  135. <!-- 修改采购到料状态 -->
  136. <update id="updatePurchaseType">
  137. update tld_purchase set type = '1' where order_code = #{orderCode}
  138. </update>
  139. <!-- 查询采购单 -->
  140. <select id="getPurchase" resultType="com.tld.model.ReceiveGoods">
  141. select
  142. a.id,
  143. a.supplier_id,
  144. a.order_code,
  145. a.material_id,
  146. a.purchase_num,
  147. a.arrival_num,
  148. a.arrival_time,
  149. a.type,
  150. b.name as materialName,
  151. b.code as wllbCode,
  152. c.name as supplierName
  153. from tld_purchase a
  154. left join tld_material b on a.material_id = b.tld_id
  155. left join tld_customer c on a.supplier_id = c.tld_id
  156. <trim prefix="WHERE" prefixOverrides="and |or">
  157. <if test="orderCode != null and orderCode != ''">
  158. and a.order_code = #{orderCode}
  159. </if>
  160. <if test="startTime != null and startTime != ''">
  161. and a.arrival_time <![CDATA[>=]]> #{startTime}
  162. </if>
  163. <if test="endTime != null and endTime != ''">
  164. and a.arrival_time <![CDATA[<=]]> #{endTime}
  165. </if>
  166. </trim>
  167. </select>
  168. <!-- 查询超时采购单 -->
  169. <select id="timeoutPurchase" resultType="com.tld.model.ReceiveGoods">
  170. select
  171. a.id,
  172. a.supplier_id,
  173. a.order_code,
  174. a.material_id,
  175. a.purchase_num,
  176. a.arrival_num,
  177. a.arrival_time,
  178. a.type,
  179. b.name as materialName,
  180. b.code as wllbCode,
  181. c.name as supplierName
  182. from tld_purchase a
  183. left join tld_material b on a.material_id = b.tld_id
  184. left join tld_customer c on a.supplier_id = c.tld_id
  185. where
  186. a.arrival_time <![CDATA[<]]> CURDATE() and type = '0'
  187. <if test="orderCode != null and orderCode != ''">
  188. and a.order_code = #{orderCode}
  189. </if>
  190. <if test="startTime != null and startTime != ''">
  191. and a.arrival_time <![CDATA[>=]]> #{startTime}
  192. </if>
  193. <if test="endTime != null and endTime != ''">
  194. and a.arrival_time <![CDATA[<=]]> #{endTime}
  195. </if>
  196. </select>
  197. </mapper>