ReceiveGoodsMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. b.code as wllbCode,
  19. -- a.wbs,
  20. g.code as wbs,
  21. e.company_number as companyNumber,
  22. e.supplier_id as supplierId,
  23. p.name as compName
  24. from tld_receive_goods a
  25. left join tld_material b on a.material_id = b.tld_id
  26. left join tld_customer c on a.supplier_id = c.code
  27. left join tld_receive_goods_f e on a.order_code = e.order_code
  28. left join tld_company p on e.company_number = p.code
  29. left join tld_wbs g on a.wbs = g.tld_id
  30. <trim prefix="WHERE" prefixOverrides="and |or">
  31. <if test="materialId != null and materialId != ''">
  32. and a.material_id like CONCAT(CONCAT('%',#{materialId},'%'))
  33. </if>
  34. <if test="materialCode != null and materialCode != ''">
  35. and b.code like CONCAT(CONCAT('%',#{materialCode},'%'))
  36. </if>
  37. <if test="supplierId != null and supplierId != ''">
  38. and a.supplier_id = #{supplierId}
  39. </if>
  40. <if test="companyNumber != null and companyNumber != ''">
  41. and e.company_number = #{companyNumber}
  42. </if>
  43. <if test="materialName != null and materialName != ''">
  44. and b.name like CONCAT(CONCAT('%',#{materialName},'%'))
  45. </if>
  46. <if test="type != null and type != ''">
  47. and a.type = #{type}
  48. </if>
  49. <if test="startTime != null and startTime != ''">
  50. and a.arrival_time <![CDATA[>=]]> #{startTime}
  51. </if>
  52. <if test="endTime != null and endTime != ''">
  53. and a.arrival_time <![CDATA[<=]]> #{endTime}
  54. </if>
  55. <if test="orderCode != null and orderCode != ''">
  56. and a.order_code like CONCAT(CONCAT('%',#{orderCode},'%'))
  57. </if>
  58. <if test="wbs != null and wbs != ''">
  59. and a.wbs like CONCAT(CONCAT('%',#{wbs},'%'))
  60. </if>
  61. </trim>
  62. order by a.id desc
  63. </select>
  64. <!-- 查询超时采购单 -->
  65. <select id="getPastReceiveGoods" resultType="com.tld.model.ReceiveGoods">
  66. select
  67. a.id,
  68. a.order_code,
  69. b.name as materialName,
  70. c.name as supplierName,
  71. a.purchase_num,
  72. a.arrival_num,
  73. a.type,
  74. a.qualified_num,
  75. a.disqualification_num,
  76. a.arrival_time
  77. from tld_receive_goods a
  78. left join tld_material b on a.material_id = b.tld_id
  79. left join tld_customer c on a.supplier_id = c.code
  80. where a.type = "0" and a.arrival_time <![CDATA[<]]> CURDATE()
  81. <if test="orderCode != null and orderCode != ''">
  82. and a.order_code = #{orderCode}
  83. </if>
  84. order by a.id desc
  85. </select>
  86. <!-- 查询采购父表是否有次采购单的数据 -->
  87. <select id="getReceiveGoodsf" resultType="int">
  88. select count(*)
  89. from tld_receive_goods_f
  90. where order_code = #{orderCode}
  91. </select>
  92. <!-- 新增采购单信息 -->
  93. <insert id="addReceiveGoods">
  94. insert into tld_receive_goods(order_code, material_id, purchase_num, arrival_num, type, qualified_num,
  95. disqualification_num, wbs, arrival_time, measurement_id, supplier_id,
  96. entry_number, warehousing_num)
  97. values (#{orderCode}, #{materialId}, #{purchaseNum}, #{arrivalNum}, #{type}, 0+CAST(#{qualifiedNum} as char),
  98. #{disqualificationNum}, #{wbs}, #{arrivalTime}, #{measurementId}, #{supplierId}, #{entryNumber}, '0');
  99. </insert>
  100. <!-- 新增采购单信息 -->
  101. <insert id="addReceiveGoodsf">
  102. insert into tld_receive_goods_f(order_number, order_code, company_number, supplier_id, arrival_time, order_type,
  103. source_type, move_type)
  104. values (#{orderNumber}, #{orderCode}, #{companyNumber}, #{supplierId}, #{arrivalTime}, #{orderType},
  105. #{sourceType}, #{moveType})
  106. </insert>
  107. <!-- 修改采购单信息 -->
  108. <update id="updateReceiveGoods">
  109. update tld_receive_goods
  110. <set>
  111. <trim suffixOverrides=",">
  112. <if test="arrivalNum != null">
  113. arrival_num = #{arrivalNum},
  114. </if>
  115. <if test="qualifiedNum != null">
  116. qualified_num = #{qualifiedNum},
  117. </if>
  118. <if test="disqualificationNum != null">
  119. disqualification_num = #{disqualificationNum},
  120. </if>
  121. <if test="arrivalTime != null">
  122. arrival_time = #{arrivalTime},
  123. </if>
  124. <if test="type != null">
  125. type = #{type},
  126. </if>
  127. </trim>
  128. </set>
  129. where order_code = #{orderCode};
  130. update tld_receive_goods_f
  131. <set>
  132. <trim suffixOverrides=",">
  133. <if test="supplierId != null and supplierId != ''">
  134. supplier_id = #{supplierId},
  135. </if>
  136. <if test="arrivalTime != null and arrivalTime != ''">
  137. arrival_time = #{arrivalTime},
  138. </if>
  139. <if test="orderType != null and orderType != ''">
  140. order_type = #{orderType},
  141. </if>
  142. <if test="sourceType != null and sourceType != ''">
  143. source_type = #{sourceType},
  144. </if>
  145. <if test="moveType != null and moveType != ''">
  146. move_type = #{moveType},
  147. </if>
  148. </trim>
  149. </set>
  150. where order_code = #{orderCode};
  151. </update>
  152. <!-- 采购单日志 -->
  153. <insert id="addReceiveGoodsLog" keyProperty="id" useGeneratedKeys="true">
  154. insert into tld_receive_goods_log(order_number, order_code, company_number, supplier_id, arrival_time,
  155. order_type, source_type, move_type, material_id, purchase_num, arrival_num,
  156. qualified_num, disqualification_num, wbs, measurement_id)
  157. values (#{orderNumber}, #{orderCode}, #{companyNumber}, #{supplierId}, #{arrivalTime}, #{orderType},
  158. #{sourceType}, #{moveType}, #{materialId}, #{purchaseNum}, #{arrivalNum}, 0+CAST(#{qualifiedNum} as char),
  159. #{disqualificationNum}, #{wbs}, #{measurementId})
  160. </insert>
  161. <!-- 新增采购到料大屏信息 -->
  162. <insert id="addPurchase">
  163. insert into tld_purchase(supplier_id,order_code,material_id,purchase_num,arrival_num,arrival_time,type)
  164. values
  165. <foreach collection="jsonData" index="index" item="item" separator=",">
  166. (#{item.supplierId},#{item.orderCode},#{item.materialId},#{item.purchaseNum},#{item.arrivalNum},#{item.DateTime},'0')
  167. </foreach>
  168. </insert>
  169. <!-- 修改采购到料状态 -->
  170. <update id="updatePurchaseType">
  171. update tld_purchase
  172. set type = '1'
  173. where order_code = #{orderCode}
  174. </update>
  175. <!-- 查询采购单 -->
  176. <select id="getPurchase" resultType="com.tld.model.ReceiveGoods">
  177. select
  178. a.id,
  179. a.supplier_id,
  180. a.order_code,
  181. a.material_id,
  182. a.purchase_num,
  183. a.arrival_num,
  184. a.arrival_time,
  185. a.type,
  186. b.name as materialName,
  187. b.code as wllbCode,
  188. c.name as supplierName
  189. from tld_purchase a
  190. left join tld_material b on a.material_id = b.tld_id
  191. left join tld_customer c on a.supplier_id = c.code
  192. <trim prefix="WHERE" prefixOverrides="and |or">
  193. <if test="orderCode != null and orderCode != ''">
  194. and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
  195. </if>
  196. <if test="supplierId != null and supplierId != ''">
  197. and a.supplier_id = #{supplierId}
  198. </if>
  199. <if test="materialName != null and materialName != ''">
  200. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  201. </if>
  202. <if test="wllbCode != null and wllbCode != ''">
  203. and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  204. </if>
  205. <if test="startTime != null and startTime != ''">
  206. and a.arrival_time <![CDATA[>=]]> #{startTime}
  207. </if>
  208. <if test="endTime != null and endTime != ''">
  209. and a.arrival_time <![CDATA[<=]]> #{endTime}
  210. </if>
  211. </trim>
  212. order by a.id desc
  213. </select>
  214. <!-- 查询超时采购单 -->
  215. <select id="timeoutPurchase" resultType="com.tld.model.ReceiveGoods">
  216. select
  217. a.id,
  218. a.supplier_id,
  219. a.order_code,
  220. a.material_id,
  221. a.purchase_num,
  222. a.arrival_num,
  223. a.arrival_time,
  224. a.type,
  225. b.name as materialName,
  226. b.code as wllbCode,
  227. c.name as supplierName
  228. from tld_purchase a
  229. left join tld_material b on a.material_id = b.tld_id
  230. left join tld_customer c on a.supplier_id = c.code
  231. where
  232. a.arrival_time <![CDATA[<]]> CURDATE() and a.type = '0'
  233. <if test="orderCode != null and orderCode != ''">
  234. and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
  235. </if>
  236. <if test="startTime != null and startTime != ''">
  237. and a.arrival_time <![CDATA[>=]]> #{startTime}
  238. </if>
  239. <if test="endTime != null and endTime != ''">
  240. and a.arrival_time <![CDATA[<=]]> #{endTime}
  241. </if>
  242. <if test="supplierId != null and supplierId != ''">
  243. and a.supplier_id = #{supplierId}
  244. </if>
  245. <if test="materialName != null and materialName != ''">
  246. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  247. </if>
  248. <if test="wllbCode != null and wllbCode != ''">
  249. and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  250. </if>
  251. order by a.id desc
  252. </select>
  253. <!-- 查询 原始记录 -->
  254. <select id="getDelReceiveGoods" resultType="java.util.Map">
  255. select *
  256. from tld_receive_goods
  257. where id = #{id}
  258. </select>
  259. <!--采购单导出-->
  260. <select id="purchaseExport" resultType="java.util.LinkedHashMap">
  261. select
  262. a.supplier_id,
  263. b.code as wllbCode,
  264. b.name as materialName,
  265. c.name as supplierName,
  266. a.arrival_num,
  267. a.arrival_time
  268. from tld_purchase a
  269. left join tld_material b on a.material_id = b.tld_id
  270. left join tld_customer c on a.supplier_id = c.code
  271. <trim prefix="WHERE" prefixOverrides="and |or">
  272. <if test="orderCode != null and orderCode != ''">
  273. and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
  274. </if>
  275. <if test="supplierId != null and supplierId != ''">
  276. and a.supplier_id = #{supplierId}
  277. </if>
  278. <if test="materialName != null and materialName != ''">
  279. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  280. </if>
  281. <if test="wllbCode != null and wllbCode != ''">
  282. and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  283. </if>
  284. <if test="startTime != null and startTime != ''">
  285. and a.arrival_time <![CDATA[>=]]> #{startTime}
  286. </if>
  287. <if test="endTime != null and endTime != ''">
  288. and a.arrival_time <![CDATA[<=]]> #{endTime}
  289. </if>
  290. </trim>
  291. order by a.id desc
  292. </select>
  293. <!--超时采购单导出-->
  294. <select id="overtimePurchaseExport" resultType="java.util.LinkedHashMap">
  295. select
  296. a.supplier_id,
  297. b.code as wllbCode,
  298. b.name as materialName,
  299. c.name as supplierName,
  300. a.arrival_num,
  301. a.arrival_time
  302. from tld_purchase a
  303. left join tld_material b on a.material_id = b.tld_id
  304. left join tld_customer c on a.supplier_id = c.code
  305. where
  306. a.arrival_time <![CDATA[<]]> CURDATE() and a.type = '0'
  307. <if test="orderCode != null and orderCode != ''">
  308. and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
  309. </if>
  310. <if test="startTime != null and startTime != ''">
  311. and a.arrival_time <![CDATA[>=]]> #{startTime}
  312. </if>
  313. <if test="endTime != null and endTime != ''">
  314. and a.arrival_time <![CDATA[<=]]> #{endTime}
  315. </if>
  316. <if test="supplierId != null and supplierId != ''">
  317. and a.supplier_id = #{supplierId}
  318. </if>
  319. <if test="materialName != null and materialName != ''">
  320. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  321. </if>
  322. <if test="wllbCode != null and wllbCode != ''">
  323. and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  324. </if>
  325. order by a.id desc
  326. </select>
  327. <!--查询采购单1导出-->
  328. <select id="purchasesExport" resultType="java.util.LinkedHashMap">
  329. select
  330. a.order_code,
  331. b.name as materialName,
  332. b.code as wllbCode,
  333. a.wbs,
  334. c.name as supplierName,
  335. a.purchase_num,
  336. a.arrival_num,
  337. a.qualified_num,
  338. a.disqualification_num
  339. from tld_receive_goods a
  340. left join tld_material b on a.material_id = b.tld_id
  341. left join tld_customer c on a.supplier_id = c.code
  342. left join tld_receive_goods_f e on a.order_code = e.order_code
  343. left join tld_company p on e.company_number = p.code
  344. <trim prefix="WHERE" prefixOverrides="and |or">
  345. <if test="materialId != null and materialId != ''">
  346. and a.material_id like CONCAT(CONCAT('%',#{materialId},'%'))
  347. </if>
  348. <if test="supplierId != null and supplierId != ''">
  349. and a.supplier_id = #{supplierId}
  350. </if>
  351. <if test="companyNumber != null and companyNumber != ''">
  352. and e.company_number = #{companyNumber}
  353. </if>
  354. <if test="materialName != null and materialName != ''">
  355. and b.name like CONCAT(CONCAT('%',#{materialName},'%'))
  356. </if>
  357. <if test="type != null and type != ''">
  358. and a.type = #{type}
  359. </if>
  360. <if test="startTime != null and startTime != ''">
  361. and a.arrival_time <![CDATA[>=]]> #{startTime}
  362. </if>
  363. <if test="endTime != null and endTime != ''">
  364. and a.arrival_time <![CDATA[<=]]> #{endTime}
  365. </if>
  366. <if test="orderCode != null and orderCode != ''">
  367. and a.order_code like CONCAT(CONCAT('%',#{orderCode},'%'))
  368. </if>
  369. <if test="wbs != null and wbs != ''">
  370. and a.wbs like CONCAT(CONCAT('%',#{wbs},'%'))
  371. </if>
  372. </trim>
  373. order by a.id desc
  374. </select>
  375. <!-- 删除原始记录 -->
  376. <delete id="delReceiveGoods">
  377. delete
  378. from tld_receive_goods
  379. where id = #{id}
  380. </delete>
  381. <!-- 查询入库单内容 -->
  382. <select id="getPdaReceiveGoods" resultType="com.tld.model.ReceiveGoods">
  383. select
  384. a.id,
  385. a.order_code,
  386. b.name as materialName,
  387. c.name as supplierName,
  388. a.warehousing_num,
  389. a.purchase_num,
  390. a.arrival_num,
  391. a.type,
  392. a.qualified_num,
  393. a.disqualification_num,
  394. a.arrival_time,
  395. b.code as wllbCode,
  396. a.wbs,
  397. e.company_number as companyNumber,
  398. e.supplier_id as supplierId,
  399. p.name as compName
  400. from tld_receive_goods a
  401. left join tld_material b on a.material_id = b.tld_id
  402. left join tld_customer c on a.supplier_id = c.code
  403. left join tld_receive_goods_f e on a.order_code = e.order_code
  404. left join tld_company p on e.company_number = p.code
  405. where (warehousing_num + 0) <![CDATA[<]]> (qualified_num + 0)
  406. <if test="materialId != null and materialId != ''">
  407. and a.material_id like CONCAT(CONCAT('%',#{materialId},'%'))
  408. </if>
  409. <if test="supplierId != null and supplierId != ''">
  410. and a.supplier_id = #{supplierId}
  411. </if>
  412. <if test="companyNumber != null and companyNumber != ''">
  413. and e.company_number = #{companyNumber}
  414. </if>
  415. <if test="materialName != null and materialName != ''">
  416. and b.name like CONCAT(CONCAT('%',#{materialName},'%'))
  417. </if>
  418. <if test="type != null and type != ''">
  419. and a.type = #{type}
  420. </if>
  421. <if test="startTime != null and startTime != ''">
  422. and a.arrival_time <![CDATA[>=]]> #{startTime}
  423. </if>
  424. <if test="endTime != null and endTime != ''">
  425. and a.arrival_time <![CDATA[<=]]> #{endTime}
  426. </if>
  427. <if test="orderCode != null and orderCode != ''">
  428. and a.order_code like CONCAT(CONCAT('%',#{orderCode},'%'))
  429. </if>
  430. <if test="wbs != null and wbs != ''">
  431. and a.wbs like CONCAT(CONCAT('%',#{wbs},'%'))
  432. </if>
  433. order by a.id desc
  434. </select>
  435. <!-- 查询采购单内容 -->
  436. <select id="getReceiveGoodsCode" resultType="com.tld.model.ReceiveGoods">
  437. SELECT a.id,
  438. a.order_code,
  439. a.material_id,
  440. a.purchase_num,
  441. a.arrival_num,
  442. a.type,
  443. a.qualified_num,
  444. a.disqualification_num,
  445. a.wbs,
  446. a.arrival_time,
  447. a.measurement_id,
  448. a.supplier_id,
  449. a.entry_number,
  450. a.warehousing_num,
  451. b.company_number,
  452. b.order_number,
  453. b.source_type,
  454. b.move_type,
  455. f.name as supplierName
  456. FROM tld_receive_goods a
  457. LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
  458. JOIN tld_material c on a.material_id = c.tld_id
  459. LEFT JOIN tld_customer f on a.supplier_id = f.code
  460. WHERE a.id = #{receiveGoodsId}
  461. </select>
  462. </mapper>