QueryListMappeer.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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.QueryListMapper">
  5. <!-- 呆滞品查询 -->
  6. <select id="dullGoods" resultType="java.util.Map">
  7. SELECT
  8. a.id as id,
  9. a.material_id as materialId,
  10. a.amount as amount,
  11. a.scrq as scrq,
  12. a.storage_location_code as storageLocationCode,
  13. b.name as materialName,
  14. c.storage_location_name as storageLocationName,
  15. b.code as wllbCode
  16. FROM tld_inventory a
  17. JOIN tld_material b ON a.material_id = b.tld_id
  18. LEFT JOIN tld_storage_location c ON a.storage_location_code = c.storage_location_code
  19. WHERE datediff(now(), a.scrq) <![CDATA[>]]> 90
  20. <if test="storageLocationCode != null and storageLocationCode != ''">
  21. and a.storage_location_code = #{storageLocationCode}
  22. </if>
  23. <if test="wllbCode != null and wllbCode != ''">
  24. and b.code = #{wllbCode}
  25. </if>
  26. </select>
  27. <!-- 查询所有物料 -->
  28. <select id="getMaterial" resultType="java.util.Map">
  29. select
  30. tld_id as tldId,
  31. ifnull(min_num, 0) as minNum,
  32. ifnull(max_num, 0) as maxNum,
  33. name as name,
  34. code as code
  35. from tld_material
  36. <trim prefix="WHERE" prefixOverrides="and |or">
  37. <if test="wllbCode != null and wllbCode != ''">
  38. and code = #{wllbCode}
  39. </if>
  40. </trim>
  41. </select>
  42. <!-- 物料储量预警查询 -->
  43. <select id="reserveWarning" resultType="java.util.Map" parameterType="java.util.Map">
  44. SELECT
  45. ifnull(sum( a.amount ), "0" ) as amount,
  46. ${tldId} as materialId,
  47. ${minNum} as minNum,
  48. ${maxNum} as maxNum
  49. FROM tld_inventory a
  50. LEFT JOIN tld_material b ON a.material_id = b.tld_id
  51. WHERE material_id = #{tldId}
  52. </select>
  53. <!-- 查询库位信息 -->
  54. <select id="storageLocation" resultType="java.util.Map">
  55. SELECT
  56. a.storage_location_code as storageLocationCode,
  57. a.material_id as materialId,
  58. sum( a.amount ) AS sum,
  59. a.serial,
  60. a.produc_batch as producBatch,
  61. a.supplier_id as supplierId,
  62. b.storage_location_name as storageLocationName ,
  63. b.warehouse_where as warehouseWhere,
  64. b.storage_location_type as storageLocationType,
  65. b.storage_location_capacity as storageLocationCapacity,
  66. b.is_not_disable as isNotDisable,
  67. b.create_time as createTime,
  68. b.is_product as isProduct,
  69. c.name as name,
  70. c.code as code,
  71. e.name as supplierName,
  72. f.name as warehouseName
  73. FROM
  74. tld_inventory a
  75. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  76. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  77. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  78. LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
  79. <trim prefix="WHERE" prefixOverrides="and |or">
  80. <if test="storageLocationCode != null and storageLocationCode != ''">
  81. and a.storage_location_code = #{storageLocationCode}
  82. </if>
  83. <if test="materialId != null and materialId != ''">
  84. and a.material_id = #{materialId}
  85. </if>
  86. </trim>
  87. GROUP BY
  88. a.storage_location_code,
  89. a.material_id
  90. </select>
  91. <!-- 查询库位信息 -->
  92. <select id="getQueryInventory" resultType="java.util.Map">
  93. SELECT
  94. a.storage_location_code as storageLocationCode,
  95. a.material_id as materialId,
  96. a.amount AS sum,
  97. a.serial,
  98. a.produc_batch as producBatch,
  99. a.supplier_id as supplierId,
  100. b.storage_location_name as storageLocationName ,
  101. b.warehouse_where as warehouseWhere,
  102. b.storage_location_type as storageLocationType,
  103. b.storage_location_capacity as storageLocationCapacity,
  104. b.is_not_disable as isNotDisable,
  105. b.create_time as createTime,
  106. b.is_product as isProduct,
  107. c.name as name,
  108. c.code as code,
  109. e.name as supplierName
  110. FROM
  111. tld_inventory a
  112. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  113. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  114. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  115. <trim prefix="WHERE" prefixOverrides="and |or">
  116. <if test="storageLocationCode != null and storageLocationCode != ''">
  117. and a.storage_location_code = #{storageLocationCode}
  118. </if>
  119. <if test="materialId != null and materialId != ''">
  120. and a.material_id = #{materialId}
  121. </if>
  122. </trim>
  123. </select>
  124. <select id="getStorageLocation" resultType="java.util.LinkedHashMap">
  125. SELECT
  126. c.code as code,
  127. c.name as name,
  128. b.storage_location_name as storageLocationName ,
  129. sum( a.amount ) AS sum
  130. FROM
  131. tld_inventory a
  132. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  133. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  134. <trim prefix="WHERE" prefixOverrides="and |or">
  135. <if test="storageLocationCode != null and storageLocationCode != ''">
  136. and a.storage_location_code = #{storageLocationCode}
  137. </if>
  138. <if test="materialId != null and materialId != ''">
  139. and a.material_id = #{materialId}
  140. </if>
  141. </trim>
  142. GROUP BY
  143. a.storage_location_code,
  144. a.material_id
  145. </select>
  146. <!-- 查询接入信息 -->
  147. <select id="getAccess" resultType="com.tld.model.Access">
  148. select id,type,data,scrq,access_type from tld_access
  149. <trim prefix="WHERE" prefixOverrides="and |or">
  150. <if test="type != null and type != ''">
  151. and type = #{type}
  152. </if>
  153. <if test="accessType != null and accessType != ''">
  154. and access_type = #{accessType}
  155. </if>
  156. </trim>
  157. </select>
  158. <!-- 查询生产领料要货 -->
  159. <select id="getAskGoods" resultType="com.tld.model.AskGoods">
  160. SELECT
  161. a.id,
  162. a.ask_goods_id,
  163. a.material_id,
  164. IFNULL( a.out_num, 0 ) AS out_num,
  165. a.num,
  166. e.NAME AS materialName,
  167. e.CODE AS materialCode,
  168. b.ask_goods_code,
  169. b.company_number,
  170. b.sqrq
  171. FROM
  172. tld_ask_goods a
  173. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  174. LEFT JOIN tld_department c ON b.department = c.code
  175. JOIN tld_material e ON a.material_id = e.tld_id
  176. /* WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
  177. <trim prefix="WHERE" prefixOverrides="and |or">
  178. <if test="askGoodsId != null and askGoodsId != ''">
  179. and b.ask_goods_code = #{askGoodsId}
  180. </if>
  181. <if test="materialCode != null and materialCode != ''">
  182. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  183. </if>
  184. <if test="materialName != null and materialName != ''">
  185. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  186. </if>
  187. <if test="startTime != null and startTime != ''">
  188. and b.sqrq <![CDATA[>=]]> #{startTime}
  189. </if>
  190. <if test="endTime != null and endTime != ''">
  191. and b.sqrq <![CDATA[<=]]> #{endTime}
  192. </if>
  193. </trim>
  194. </select>
  195. <!-- 查询生产领料要货 -->
  196. <select id="getAskGoodsExcel" resultType="java.util.LinkedHashMap">
  197. SELECT
  198. a.ask_goods_id,
  199. a.material_id,
  200. a.num,
  201. IFNULL( a.out_num, 0 ) AS out_num,
  202. e.NAME AS materialName,
  203. e.CODE AS materialCode,
  204. b.ask_goods_code,
  205. b.company_number
  206. FROM
  207. tld_ask_goods a
  208. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  209. LEFT JOIN tld_department c ON b.department = c.code
  210. JOIN tld_material e ON a.material_id = e.tld_id
  211. WHERE e.part_type != '半成品' and e.part_type != '产成品'
  212. <if test="askGoodsId != null and askGoodsId != ''">
  213. and a.ask_goods_id = #{askGoodsId}
  214. </if>
  215. <if test="materialCode != null and materialCode != ''">
  216. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  217. </if>
  218. <if test="materialName != null and materialName != ''">
  219. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  220. </if>
  221. <if test="startTime != null and startTime != ''">
  222. and b.sqrq <![CDATA[>=]]> #{startTime}
  223. </if>
  224. <if test="endTime != null and endTime != ''">
  225. and b.sqrq <![CDATA[<=]]> #{endTime}
  226. </if>
  227. </select>
  228. <!-- 查询非生产领料单 -->
  229. <select id="getInvite" resultType="com.tld.model.AskGoods">
  230. SELECT
  231. a.id,
  232. a.ask_goods_id,
  233. a.material_id,
  234. IFNULL( a.out_num, 0 ) AS out_num,
  235. a.num,
  236. e.NAME AS materialName,
  237. e.CODE AS materialCode,
  238. b.ask_goods_code,
  239. b.company_number,
  240. b.sqrq
  241. FROM
  242. tld_invite a
  243. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  244. LEFT JOIN tld_department c ON b.department = c.code
  245. JOIN tld_material e ON a.material_id = e.tld_id
  246. /*WHERE*/
  247. /*e.part_type != '半成品' and e.part_type != '产成品'*/
  248. <trim prefix="WHERE" prefixOverrides="and |or">
  249. <if test="askGoodsId != null and askGoodsId != ''">
  250. and b.ask_goods_code = #{askGoodsId}
  251. </if>
  252. <if test="materialCode != null and materialCode != ''">
  253. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  254. </if>
  255. <if test="materialName != null and materialName != ''">
  256. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  257. </if>
  258. <if test="startTime != null and startTime != ''">
  259. and b.sqrq <![CDATA[>=]]> #{startTime}
  260. </if>
  261. <if test="endTime != null and endTime != ''">
  262. and b.sqrq <![CDATA[<=]]> #{endTime}
  263. </if>
  264. </trim>
  265. </select>
  266. <!-- 导出生产领料要货 -->
  267. <select id="getInviteExcel" resultType="java.util.LinkedHashMap">
  268. SELECT
  269. a.ask_goods_id,
  270. a.material_id,
  271. a.num,
  272. IFNULL( a.out_num, 0 ) AS out_num,
  273. e.NAME AS materialName,
  274. e.CODE AS materialCode,
  275. b.ask_goods_code,
  276. b.company_number
  277. FROM
  278. tld_invite a
  279. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  280. LEFT JOIN tld_department c ON b.department = c.code
  281. JOIN tld_material e ON a.material_id = e.tld_id
  282. WHERE e.part_type != '半成品' and e.part_type != '产成品'
  283. <if test="askGoodsId != null and askGoodsId != ''">
  284. and a.ask_goods_id = #{askGoodsId}
  285. </if>
  286. <if test="materialCode != null and materialCode != ''">
  287. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  288. </if>
  289. <if test="materialName != null and materialName != ''">
  290. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  291. </if>
  292. <if test="startTime != null and startTime != ''">
  293. and b.sqrq <![CDATA[>=]]> #{startTime}
  294. </if>
  295. <if test="endTime != null and endTime != ''">
  296. and b.sqrq <![CDATA[<=]]> #{endTime}
  297. </if>
  298. </select>
  299. <!-- 查询销售单 -->
  300. <select id="getDelivery" resultType="com.tld.model.Delivery">
  301. select
  302. a.id,
  303. a.delivery_id,
  304. a.material_id,
  305. a.wbs,
  306. a.gs_delivery_num,
  307. a.gs_cancel_num,
  308. ifnull(a.out_num, 0) as out_num,
  309. b.company_number,
  310. b.bills_time,
  311. c.name as materialName,
  312. c.code as materialCode
  313. from tld_delivery a
  314. join tld_delivery_f b on a.delivery_id = b.delivery_id
  315. join tld_material c on a.material_id = c.tld_id
  316. <trim prefix="WHERE" prefixOverrides="and |or">
  317. <if test="deliveryId != null and deliveryId != ''">
  318. and a.delivery_id = #{deliveryId}
  319. </if>
  320. <if test="materialCode != null and materialCode != ''">
  321. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  322. </if>
  323. <if test="materialName != null and materialName != ''">
  324. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  325. </if>
  326. <if test="startTime != null and startTime != ''">
  327. and a.bills_time <![CDATA[>=]]> #{startTime}
  328. </if>
  329. <if test="endTime != null and endTime != ''">
  330. and a.bills_time <![CDATA[<=]]> #{endTime}
  331. </if>
  332. </trim>
  333. </select>
  334. <!-- 导出销售单 -->
  335. <select id="getDeliveryExcel" resultType="java.util.LinkedHashMap">
  336. select
  337. a.delivery_id,
  338. a.material_id,
  339. a.wbs,
  340. a.gs_delivery_num,
  341. a.gs_cancel_num,
  342. a.out_num,
  343. b.company_number,
  344. b.bills_time,
  345. c.name as materialName,
  346. c.code as materialCode
  347. from tld_delivery a
  348. join tld_delivery_f b on a.delivery_id = b.delivery_id
  349. join tld_material c on a.material_id = c.tld_id
  350. <trim prefix="WHERE" prefixOverrides="and |or">
  351. <if test="deliveryId != null and deliveryId != ''">
  352. and a.delivery_id = #{deliveryId}
  353. </if>
  354. <if test="materialCode != null and materialCode != ''">
  355. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  356. </if>
  357. <if test="materialName != null and materialName != ''">
  358. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  359. </if>
  360. <if test="startTime != null and startTime != ''">
  361. and a.bills_time <![CDATA[>=]]> #{startTime}
  362. </if>
  363. <if test="endTime != null and endTime != ''">
  364. and a.bills_time <![CDATA[<=]]> #{endTime}
  365. </if>
  366. </trim>
  367. </select>
  368. <!-- 查询移库单 -->
  369. <select id="getWarehouseTransfer" resultType="com.tld.model.WarehouseTransfer">
  370. select
  371. a.id,
  372. a.warehouse_transfer_id,
  373. a.entry_number,
  374. a.supply_warehouse_id,
  375. a.material_id,
  376. a.wbs,
  377. a.num,
  378. a.out_num,
  379. a.type,
  380. b.warehouse_transfer_code,
  381. b.ask_goods_warehouse_id,
  382. b.document_time,
  383. b.warehouse_transfer_type,
  384. c.name as materialName,
  385. c.code as materialCode,
  386. f.name as askGoodsWarehouseName,
  387. e.name as supplyWarehouseName
  388. from tld_warehouse_transfer a
  389. join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
  390. join tld_material c on a.material_id = c.tld_id
  391. join tld_warehouse e on a.supply_warehouse_id = e.tld_id
  392. join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
  393. <trim prefix="WHERE" prefixOverrides="and |or">
  394. <if test="type != null and type != ''">
  395. and a.type = #{type}
  396. </if>
  397. <if test="materialCode != null and materialCode != ''">
  398. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  399. </if>
  400. <if test="materialName != null and materialName != ''">
  401. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  402. </if>
  403. <if test="warehouseTransferCode != null and warehouseTransferCode != ''">
  404. and b.warehouse_transfer_code like CONCAT(CONCAT('%', #{warehouseTransferCode}), '%')
  405. </if>
  406. <if test="startTime != null and startTime != ''">
  407. and a.document_time <![CDATA[>=]]> #{startTime}
  408. </if>
  409. <if test="endTime != null and endTime != ''">
  410. and a.document_time <![CDATA[<=]]> #{endTime}
  411. </if>
  412. </trim>
  413. </select>
  414. <!-- 移库单导出 -->
  415. <select id="getWarehouseTransferExcel" resultType="java.util.LinkedHashMap">
  416. select
  417. a.warehouse_transfer_id,
  418. b.warehouse_transfer_code,
  419. a.material_id,
  420. c.name as materialName,
  421. c.code as materialCode,
  422. a.wbs,
  423. a.num,
  424. a.out_num,
  425. b.ask_goods_warehouse_id,
  426. a.supply_warehouse_id,
  427. f.name as askGoodsWarehouseaName,
  428. e.name as supplyWarehouseName,
  429. b.document_time,
  430. case
  431. when a.type = '0' then
  432. '未移库'
  433. when a.type = '1' then
  434. '已移库'
  435. end as type
  436. from tld_warehouse_transfer a
  437. join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
  438. join tld_material c on a.material_id = c.tld_id
  439. join tld_warehouse e on a.supply_warehouse_id = e.tld_id
  440. join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
  441. <trim prefix="WHERE" prefixOverrides="and |or">
  442. <if test="type != null and type != ''">
  443. and a.type = #{type}
  444. </if>
  445. <if test="materialCode != null and materialCode != ''">
  446. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  447. </if>
  448. <if test="materialName != null and materialName != ''">
  449. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  450. </if>
  451. <if test="startTime != null and startTime != ''">
  452. and a.document_time <![CDATA[>=]]> #{startTime}
  453. </if>
  454. <if test="endTime != null and endTime != ''">
  455. and a.document_time <![CDATA[<=]]> #{endTime}
  456. </if>
  457. </trim>
  458. </select>
  459. <!-- 查询日志信息 -->
  460. <select id="getLogData" resultType="com.tld.model.LogData">
  461. SELECT
  462. a.id,
  463. a.user_id,
  464. a.scrq,
  465. a.DATA,
  466. a.type,
  467. a.document_type,
  468. b.user_name
  469. FROM
  470. tld_log_data a
  471. LEFT JOIN tld_user b ON a.user_id = b.id
  472. <trim prefix="WHERE" prefixOverrides="and |or">
  473. <if test="documentType != null and documentType != ''">
  474. and document_type = #{documentType}
  475. </if>
  476. <if test="data != null and data != ''">
  477. and data like CONCAT(CONCAT('%', #{data}), '%')
  478. </if>
  479. <if test="startTime != null and startTime != ''">
  480. and scrq <![CDATA[>=]]> #{startTime}
  481. </if>
  482. <if test="endTime != null and endTime != ''">
  483. and scrq <![CDATA[<=]]> #{endTime}
  484. </if>
  485. </trim>
  486. ORDER BY a.scrq DESC
  487. </select>
  488. </mapper>