QueryListMappeer.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  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. a.wbs as wbs,
  17. e.name as ustomerName,
  18. f.name as companyName
  19. FROM tld_inventory a
  20. JOIN tld_material b ON a.material_id = b.tld_id
  21. LEFT JOIN tld_storage_location c ON a.storage_location_code = c.storage_location_code
  22. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  23. LEFT JOIN tld_company f ON a.account_sleeve = f.code
  24. WHERE datediff(now(), a.scrq) <![CDATA[>]]> 90
  25. <if test="storageLocationCode != null and storageLocationCode != ''">
  26. and a.storage_location_code = #{storageLocationCode}
  27. </if>
  28. <if test="materialName != null and materialName != ''">
  29. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  30. </if>
  31. <if test="wllbCode != null and wllbCode != ''">
  32. and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  33. </if>
  34. <if test="wbs != null and wbs != ''">
  35. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  36. </if>
  37. <if test="storageLocationName != null and storageLocationName != ''">
  38. and c.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  39. </if>
  40. <if test="ustomerCode != null and ustomerCode != ''">
  41. and a.supplier_id = #{ustomerCode}
  42. </if>
  43. <if test="companyCode != null and companyCode != ''">
  44. and a.account_sleeve = #{companyCode}
  45. </if>
  46. </select>
  47. <!-- 查询所有物料 -->
  48. <select id="getMaterial" resultType="java.util.Map">
  49. select
  50. tld_id as tldId,
  51. ifnull(min_num, 0) as minNum,
  52. ifnull(max_num, 0) as maxNum,
  53. name as name,
  54. code as code
  55. from tld_material
  56. <trim prefix="WHERE" prefixOverrides="and |or">
  57. <if test="wllbCode != null and wllbCode != ''">
  58. and code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  59. </if>
  60. <if test="materialName != null and materialName != ''">
  61. and name like CONCAT(CONCAT('%', #{materialName}), '%')
  62. </if>
  63. </trim>
  64. </select>
  65. <!-- 物料储量预警查询 -->
  66. <select id="reserveWarning" resultType="java.util.Map" parameterType="java.util.Map">
  67. SELECT ifnull(sum(a.amount), "0") as amount,
  68. ${tldId} as materialId,
  69. ${minNum} as minNum,
  70. ${maxNum} as maxNum
  71. FROM tld_inventory a
  72. LEFT JOIN tld_material b ON a.material_id = b.tld_id
  73. WHERE material_id = #{tldId}
  74. </select>
  75. <!-- 查询库位信息 -->
  76. <select id="storageLocation" resultType="java.util.Map">
  77. SELECT
  78. a.id,
  79. a.storage_location_code as storageLocationCode,
  80. a.material_id as materialId,
  81. sum( a.amount ) AS sum,
  82. a.serial,
  83. a.wbs as wbs,
  84. a.produc_batch as producBatch,
  85. a.supplier_id as supplierId,
  86. b.storage_location_name as storageLocationName ,
  87. b.warehouse_where as warehouseWhere,
  88. b.storage_location_type as storageLocationType,
  89. b.storage_location_capacity as storageLocationCapacity,
  90. b.is_not_disable as isNotDisable,
  91. b.create_time as createTime,
  92. b.is_product as isProduct,
  93. c.name as name,
  94. c.code as code,
  95. e.name as supplierName,
  96. f.name as warehouseName,
  97. p.name as companyName,
  98. a.account_sleeve as accountSleeve
  99. FROM
  100. tld_inventory a
  101. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  102. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  103. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  104. LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
  105. LEFT JOIN tld_company p on a.account_sleeve = p.code
  106. <trim prefix="WHERE" prefixOverrides="and |or">
  107. <if test="storageLocationCode != null and storageLocationCode != ''">
  108. and a.storage_location_code = #{storageLocationCode}
  109. </if>
  110. <if test="materialId != null and materialId != ''">
  111. and a.material_id = #{materialId}
  112. </if>
  113. <if test="wllbCode != null and wllbCode != ''">
  114. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  115. </if>
  116. <if test="materialName != null and materialName != ''">
  117. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  118. </if>
  119. <if test="storageLocationName != null and storageLocationName != ''">
  120. and b.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  121. </if>
  122. <if test="companyName != null and companyName != ''">
  123. and p.name like CONCAT(CONCAT('%', #{companyName}), '%')
  124. </if>
  125. <if test="companyCode != null and companyCode != ''">
  126. and p.code = #{companyCode}
  127. </if>
  128. <if test="supplierId != null and supplierId != ''">
  129. and a.supplier_id like CONCAT(CONCAT('%', #{supplierId}), '%')
  130. </if>
  131. <if test="wbs != null and wbs != ''">
  132. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  133. </if>
  134. <if test="warehouseId != null and warehouseId != ''">
  135. and f.tld_id = #{warehouseId}
  136. </if>
  137. </trim>
  138. GROUP BY
  139. a.storage_location_code,
  140. a.material_id,
  141. a.wbs,
  142. a.account_sleeve
  143. </select>
  144. <!-- 查询库位信息 -->
  145. <select id="getQueryInventory" resultType="java.util.Map">
  146. SELECT
  147. a.storage_location_code as storageLocationCode,
  148. a.material_id as materialId,
  149. a.amount AS sum,
  150. a.serial,
  151. a.produc_batch as producBatch,
  152. a.supplier_id as supplierId,
  153. b.storage_location_name as storageLocationName ,
  154. b.warehouse_where as warehouseWhere,
  155. b.storage_location_type as storageLocationType,
  156. b.storage_location_capacity as storageLocationCapacity,
  157. b.is_not_disable as isNotDisable,
  158. b.create_time as createTime,
  159. b.is_product as isProduct,
  160. c.name as name,
  161. c.code as code,
  162. e.name as supplierName,
  163. a.wbs,
  164. a.account_sleeve
  165. FROM tld_inventory a
  166. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  167. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  168. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  169. <trim prefix="WHERE" prefixOverrides="and |or">
  170. <if test="storageLocationCode != null and storageLocationCode != ''">
  171. and a.storage_location_code = #{storageLocationCode}
  172. </if>
  173. <if test="materialId != null and materialId != ''">
  174. and a.material_id = #{materialId}
  175. </if>
  176. </trim>
  177. </select>
  178. <!--导出-->
  179. <select id="getStorageLocation" resultType="java.util.LinkedHashMap">
  180. SELECT
  181. YEAR(CURDATE()) AS year,
  182. MONTH(CURDATE()) AS month,
  183. f.code as warehouseCode,
  184. f.name as warehouseName,
  185. b.storage_location_name as storageLocationName,
  186. c.code as code,
  187. c.name as name,
  188. ifnull(c.unit_of_measurement, "暂无单位") as unit_of_measurement,
  189. sum( a.amount ) AS sum,
  190. if(a.wbs = "", " ", a.wbs) as wbs,
  191. ifnull(c.max_num, 0) as max_num,
  192. DATEDIFF(now(),scrq) as day,
  193. ifnull(c.part_type, "暂无分类") as part_type,
  194. ifnull(c.wllb_class, "暂无分类") as wllb_class,
  195. p.code as companyCode,
  196. p.name as companyName
  197. FROM tld_inventory a
  198. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  199. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  200. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  201. LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
  202. LEFT JOIN tld_company p on a.account_sleeve = p.code
  203. <trim prefix="WHERE" prefixOverrides="and |or">
  204. <if test="storageLocationCode != null and storageLocationCode != ''">
  205. and a.storage_location_code = #{storageLocationCode}
  206. </if>
  207. <if test="materialId != null and materialId != ''">
  208. and a.material_id = #{materialId}
  209. </if>
  210. <if test="wllbCode != null and wllbCode != ''">
  211. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  212. </if>
  213. <if test="materialName != null and materialName != ''">
  214. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  215. </if>
  216. <if test="storageLocationName != null and storageLocationName != ''">
  217. and b.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  218. </if>
  219. <if test="companyName != null and companyName != ''">
  220. and p.name like CONCAT(CONCAT('%', #{companyName}), '%')
  221. </if>
  222. <if test="supplierId != null and supplierId != ''">
  223. and a.supplier_id like CONCAT(CONCAT('%', #{supplierId}), '%')
  224. </if>
  225. <if test="wbs != null and wbs != ''">
  226. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  227. </if>
  228. <if test="warehouseId != null and warehouseId != ''">
  229. and f.tld_id = #{warehouseId}
  230. </if>
  231. </trim>
  232. GROUP BY
  233. a.storage_location_code,
  234. a.material_id,
  235. a.wbs,
  236. a.account_sleeve
  237. </select>
  238. <!-- 查询接入信息 -->
  239. <select id="getAccess" resultType="com.tld.model.Access">
  240. select id,type,data,scrq,access_type from tld_access
  241. <trim prefix="WHERE" prefixOverrides="and |or">
  242. <if test="type != null and type != ''">
  243. and type = #{type}
  244. </if>
  245. <if test="accessType != null and accessType != ''">
  246. and access_type = #{accessType}
  247. </if>
  248. <if test="data != null and data != ''">
  249. and data like CONCAT(CONCAT('%', #{data}), '%')
  250. </if>
  251. <if test="startTime != null and startTime != ''">
  252. and scrq <![CDATA[>=]]> #{startTime}
  253. </if>
  254. <if test="endTime != null and endTime != ''">
  255. and scrq <![CDATA[<=]]> #{endTime}
  256. </if>
  257. </trim>
  258. order by id desc
  259. </select>
  260. <!-- 查询生产领料要货 -->
  261. <select id="getAskGoods" resultType="com.tld.model.AskGoods">
  262. SELECT
  263. a.id,
  264. a.ask_goods_id,
  265. a.material_id,
  266. IFNULL( a.out_num, 0 ) AS out_num,
  267. a.num,
  268. e.NAME AS materialName,
  269. e.CODE AS materialCode,
  270. b.ask_goods_code,
  271. b.company_number,
  272. b.sqrq,
  273. c.name as departmentName,
  274. g.name as companyName,
  275. b.source_type,
  276. b.move_type,
  277. a.entry_number,
  278. a.production_code,
  279. a.wbs
  280. FROM
  281. tld_ask_goods a
  282. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  283. LEFT JOIN tld_department c ON b.department = c.code
  284. JOIN tld_material e ON a.material_id = e.tld_id
  285. left join tld_company g on b.company_number = g.code
  286. /* WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
  287. <trim prefix="WHERE" prefixOverrides="and |or">
  288. <if test="materialCode != null and materialCode != ''">
  289. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  290. </if>
  291. <if test="materialName != null and materialName != ''">
  292. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  293. </if>
  294. <if test="startTime != null and startTime != ''">
  295. and b.sqrq <![CDATA[>=]]> #{startTime}
  296. </if>
  297. <if test="endTime != null and endTime != ''">
  298. and b.sqrq <![CDATA[<=]]> #{endTime}
  299. </if>
  300. <if test="departmentCode != null and departmentCode != ''">
  301. and b.department = #{departmentCode}
  302. </if>
  303. <if test="companyCode != null and companyCode != ''">
  304. and b.company_number = #{companyCode}
  305. </if>
  306. <if test="sourceType != null and sourceType != ''">
  307. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  308. </if>
  309. <if test="moveType != null and moveType != ''">
  310. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  311. </if>
  312. <if test="entryNumber != null and entryNumber != ''">
  313. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  314. </if>
  315. <if test="wbs != null and wbs != ''">
  316. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  317. </if>
  318. <if test="askGoodsCode != null and askGoodsCode != ''">
  319. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  320. </if>
  321. <if test="productionCode != null and productionCode != ''">
  322. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  323. </if>
  324. </trim>
  325. order by a.id desc
  326. </select>
  327. <!-- 查询生产领料要货 -->
  328. <select id="getAskGoodsExcel" resultType="java.util.LinkedHashMap">
  329. SELECT
  330. a.ask_goods_id,
  331. a.material_id,
  332. a.num,
  333. IFNULL( a.out_num, 0 ) AS out_num,
  334. e.NAME AS materialName,
  335. e.CODE AS materialCode,
  336. b.ask_goods_code,
  337. b.company_number
  338. FROM
  339. tld_ask_goods a
  340. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  341. LEFT JOIN tld_department c ON b.department = c.code
  342. JOIN tld_material e ON a.material_id = e.tld_id
  343. /*WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
  344. <trim prefix="WHERE" prefixOverrides="and |or">
  345. <if test="materialCode != null and materialCode != ''">
  346. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  347. </if>
  348. <if test="materialName != null and materialName != ''">
  349. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  350. </if>
  351. <if test="startTime != null and startTime != ''">
  352. and b.sqrq <![CDATA[>=]]> #{startTime}
  353. </if>
  354. <if test="endTime != null and endTime != ''">
  355. and b.sqrq <![CDATA[<=]]> #{endTime}
  356. </if>
  357. <if test="departmentCode != null and departmentCode != ''">
  358. and b.department = #{departmentCode}
  359. </if>
  360. <if test="companyCode != null and companyCode != ''">
  361. and b.company_number = #{companyCode}
  362. </if>
  363. <if test="sourceType != null and sourceType != ''">
  364. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  365. </if>
  366. <if test="moveType != null and moveType != ''">
  367. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  368. </if>
  369. <if test="entryNumber != null and entryNumber != ''">
  370. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  371. </if>
  372. <if test="wbs != null and wbs != ''">
  373. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  374. </if>
  375. <if test="askGoodsCode != null and askGoodsCode != ''">
  376. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  377. </if>
  378. <if test="productionCode != null and productionCode != ''">
  379. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  380. </if>
  381. </trim>
  382. order by a.id desc
  383. </select>
  384. <!-- 查询非生产领料单 -->
  385. <select id="getInvite" resultType="com.tld.model.AskGoods">
  386. SELECT
  387. a.id,
  388. a.ask_goods_id,
  389. a.material_id,
  390. IFNULL( a.out_num, 0 ) AS out_num,
  391. a.num,
  392. e.NAME AS materialName,
  393. e.CODE AS materialCode,
  394. b.ask_goods_code,
  395. b.company_number,
  396. b.sqrq,
  397. c.name as departmentName,
  398. g.name as companyName,
  399. b.source_type ,
  400. b.move_type ,
  401. a.entry_number,
  402. a.production_code,
  403. a.wbs
  404. FROM
  405. tld_invite a
  406. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  407. LEFT JOIN tld_department c ON b.department = c.code
  408. JOIN tld_material e ON a.material_id = e.tld_id
  409. left join tld_company g on b.company_number = g.code
  410. /*WHERE*/
  411. /*e.part_type != '半成品' and e.part_type != '产成品'*/
  412. <trim prefix="WHERE" prefixOverrides="and |or">
  413. <if test="materialCode != null and materialCode != ''">
  414. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  415. </if>
  416. <if test="materialName != null and materialName != ''">
  417. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  418. </if>
  419. <if test="startTime != null and startTime != ''">
  420. and b.sqrq <![CDATA[>=]]> #{startTime}
  421. </if>
  422. <if test="endTime != null and endTime != ''">
  423. and b.sqrq <![CDATA[<=]]> #{endTime}
  424. </if>
  425. <if test="departmentCode != null and departmentCode != ''">
  426. and b.department = #{departmentCode}
  427. </if>
  428. <if test="companyCode != null and companyCode != ''">
  429. and b.company_number = #{companyCode}
  430. </if>
  431. <if test="sourceType != null and sourceType != ''">
  432. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  433. </if>
  434. <if test="moveType != null and moveType != ''">
  435. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  436. </if>
  437. <if test="entryNumber != null and entryNumber != ''">
  438. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  439. </if>
  440. <if test="wbs != null and wbs != ''">
  441. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  442. </if>
  443. <if test="askGoodsCode != null and askGoodsCode != ''">
  444. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  445. </if>
  446. <if test="productionCode != null and productionCode != ''">
  447. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  448. </if>
  449. </trim>
  450. order by a.id desc
  451. </select>
  452. <!-- 导出生产领料要货 -->
  453. <select id="getInviteExcel" resultType="java.util.LinkedHashMap">
  454. SELECT
  455. a.ask_goods_id,
  456. a.material_id,
  457. a.num,
  458. IFNULL( a.out_num, 0 ) AS out_num,
  459. e.NAME AS materialName,
  460. e.CODE AS materialCode,
  461. b.ask_goods_code,
  462. b.company_number
  463. FROM
  464. tld_invite a
  465. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  466. LEFT JOIN tld_department c ON b.department = c.code
  467. JOIN tld_material e ON a.material_id = e.tld_id
  468. /*WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
  469. <trim prefix="WHERE" prefixOverrides="and |or">
  470. <if test="materialCode != null and materialCode != ''">
  471. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  472. </if>
  473. <if test="materialName != null and materialName != ''">
  474. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  475. </if>
  476. <if test="startTime != null and startTime != ''">
  477. and b.sqrq <![CDATA[>=]]> #{startTime}
  478. </if>
  479. <if test="endTime != null and endTime != ''">
  480. and b.sqrq <![CDATA[<=]]> #{endTime}
  481. </if>
  482. <if test="departmentCode != null and departmentCode != ''">
  483. and b.department = #{departmentCode}
  484. </if>
  485. <if test="companyCode != null and companyCode != ''">
  486. and b.company_number = #{companyCode}
  487. </if>
  488. <if test="sourceType != null and sourceType != ''">
  489. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  490. </if>
  491. <if test="moveType != null and moveType != ''">
  492. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  493. </if>
  494. <if test="entryNumber != null and entryNumber != ''">
  495. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  496. </if>
  497. <if test="wbs != null and wbs != ''">
  498. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  499. </if>
  500. <if test="askGoodsCode != null and askGoodsCode != ''">
  501. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  502. </if>
  503. <if test="productionCode != null and productionCode != ''">
  504. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  505. </if>
  506. </trim>
  507. order by a.id desc
  508. </select>
  509. <!-- 查询销售单 -->
  510. <select id="getDelivery" resultType="com.tld.model.Delivery">
  511. select
  512. a.id,
  513. a.delivery_id,
  514. a.material_id,
  515. a.wbs,
  516. a.gs_delivery_num,
  517. a.gs_cancel_num,
  518. ifnull(a.out_num, 0) as out_num,
  519. b.company_number,
  520. b.bills_time,
  521. c.name as materialName,
  522. c.code as materialCode,
  523. g.name as customerName,
  524. b.delivery_code as deliveryCode,
  525. v.name as companyName,
  526. b.delivery_type,
  527. b.source_type,
  528. b.move_type,
  529. a.entry_number
  530. from tld_delivery a
  531. join tld_delivery_f b on a.delivery_id = b.delivery_id
  532. join tld_material c on a.material_id = c.tld_id
  533. left join tld_customer g on b.customer_code = g.code
  534. left join tld_company v on b.company_number = v.code
  535. <trim prefix="WHERE" prefixOverrides="and |or">
  536. <if test="deliveryId != null and deliveryId != ''">
  537. and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
  538. </if>
  539. <if test="materialCode != null and materialCode != ''">
  540. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  541. </if>
  542. <if test="materialName != null and materialName != ''">
  543. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  544. </if>
  545. <if test="startTime != null and startTime != ''">
  546. and b.bills_time <![CDATA[>=]]> #{startTime}
  547. </if>
  548. <if test="endTime != null and endTime != ''">
  549. and b.bills_time <![CDATA[<=]]> #{endTime}
  550. </if>
  551. <if test="wbs != null and wbs != ''">
  552. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  553. </if>
  554. <if test="companyNumber != null and companyNumber != ''">
  555. and b.company_number = #{companyNumber}
  556. </if>
  557. <if test="customerCode != null and customerCode != ''">
  558. and b.customer_code = #{customerCode}
  559. </if>
  560. <if test="entryNumber != null and entryNumber != ''">
  561. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  562. </if>
  563. <if test="deliveryType != null and deliveryType != ''">
  564. and b.delivery_type like CONCAT(CONCAT('%', #{deliveryType}), '%')
  565. </if>
  566. <if test="sourceType != null and sourceType != ''">
  567. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  568. </if>
  569. <if test="moveType != null and moveType != ''">
  570. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  571. </if>
  572. </trim>
  573. order by a.id desc
  574. </select>
  575. <!-- 导出销售单 -->
  576. <select id="getDeliveryExcel" resultType="java.util.LinkedHashMap">
  577. select
  578. a.delivery_id,
  579. a.material_id,
  580. a.wbs,
  581. a.gs_delivery_num,
  582. a.gs_cancel_num,
  583. a.out_num,
  584. v.name as companyName,
  585. b.bills_time,
  586. c.name as materialName,
  587. c.code as materialCode,
  588. g.name as customerName,
  589. b.source_type,
  590. b.move_type,
  591. b.delivery_type,
  592. a.entry_number
  593. from tld_delivery a
  594. join tld_delivery_f b on a.delivery_id = b.delivery_id
  595. join tld_material c on a.material_id = c.tld_id
  596. left join tld_customer g on b.customer_code = g.code
  597. left join tld_company v on b.company_number = v.code
  598. <trim prefix="WHERE" prefixOverrides="and |or">
  599. <if test="deliveryId != null and deliveryId != ''">
  600. and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
  601. </if>
  602. <if test="materialCode != null and materialCode != ''">
  603. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  604. </if>
  605. <if test="materialName != null and materialName != ''">
  606. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  607. </if>
  608. <if test="startTime != null and startTime != ''">
  609. and b.bills_time <![CDATA[>=]]> #{startTime}
  610. </if>
  611. <if test="endTime != null and endTime != ''">
  612. and b.bills_time <![CDATA[<=]]> #{endTime}
  613. </if>
  614. <if test="wbs != null and wbs != ''">
  615. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  616. </if>
  617. <if test="companyNumber != null and companyNumber != ''">
  618. and b.company_number = #{companyNumber}
  619. </if>
  620. <if test="customerCode != null and customerCode != ''">
  621. and b.customer_code = #{customerCode}
  622. </if>
  623. <if test="entryNumber != null and entryNumber != ''">
  624. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  625. </if>
  626. <if test="deliveryType != null and deliveryType != ''">
  627. and b.delivery_type like CONCAT(CONCAT('%', #{deliveryType}), '%')
  628. </if>
  629. <if test="sourceType != null and sourceType != ''">
  630. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  631. </if>
  632. <if test="moveType != null and moveType != ''">
  633. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  634. </if>
  635. </trim>
  636. </select>
  637. <!-- 查询移库单 -->
  638. <select id="getWarehouseTransfer" resultType="com.tld.model.WarehouseTransfer">
  639. select
  640. a.id,
  641. a.warehouse_transfer_id,
  642. a.entry_number,
  643. a.supply_warehouse_id,
  644. a.material_id,
  645. a.wbs,
  646. a.num,
  647. a.out_num,
  648. a.type,
  649. b.warehouse_transfer_code,
  650. b.ask_goods_warehouse_id,
  651. b.document_time,
  652. b.warehouse_transfer_type,
  653. c.name as materialName,
  654. c.code as materialCode,
  655. f.name as askGoodsWarehouseName,
  656. e.name as supplyWarehouseName,
  657. k.name as companyName
  658. from tld_warehouse_transfer a
  659. join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
  660. join tld_material c on a.material_id = c.tld_id
  661. join tld_warehouse e on a.supply_warehouse_id = e.tld_id
  662. join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
  663. join tld_company k on a.account_sleeve = k.code
  664. <trim prefix="WHERE" prefixOverrides="and |or">
  665. <if test="type != null and type != ''">
  666. and a.type = #{type}
  667. </if>
  668. <if test="materialCode != null and materialCode != ''">
  669. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  670. </if>
  671. <if test="materialName != null and materialName != ''">
  672. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  673. </if>
  674. <if test="warehouseTransferCode != null and warehouseTransferCode != ''">
  675. and b.warehouse_transfer_code like CONCAT(CONCAT('%',#{warehouseTransferCode}),'%')
  676. </if>
  677. <if test="startTime != null and startTime != ''">
  678. and b.document_time <![CDATA[>=]]> #{startTime}
  679. </if>
  680. <if test="endTime != null and endTime != ''">
  681. and b.document_time <![CDATA[<=]]> #{endTime}
  682. </if>
  683. <if test="askGoodsWarehouseId != null and askGoodsWarehouseId != ''">
  684. and b.ask_goods_warehouse_id = #{askGoodsWarehouseId}
  685. </if>
  686. <if test="supplyWarehouseId != null and supplyWarehouseId != ''">
  687. and a.supply_warehouse_id = #{supplyWarehouseId}
  688. </if>
  689. <if test="warehouseTransferType != null and warehouseTransferType != ''">
  690. and b.warehouse_transfer_type like CONCAT(CONCAT('%', #{warehouseTransferType}), '%')
  691. </if>
  692. <if test="companyCode != null and companyCode != ''">
  693. and a.account_sleeve = #{companyCode}
  694. </if>
  695. <if test="entryNumber != null and entryNumber != ''">
  696. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  697. </if>
  698. <if test="wbs != null and wbs != ''">
  699. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  700. </if>
  701. </trim>
  702. order by a.id desc
  703. </select>
  704. <!-- 移库单导出 -->
  705. <select id="getWarehouseTransferExcel" resultType="java.util.LinkedHashMap">
  706. select
  707. a.warehouse_transfer_id,
  708. b.warehouse_transfer_code,
  709. c.name as materialName,
  710. c.code as materialCode,
  711. a.wbs,
  712. a.num,
  713. a.out_num,
  714. f.name as askGoodsWarehouseaName,
  715. e.name as supplyWarehouseName,
  716. b.document_time
  717. from tld_warehouse_transfer a
  718. join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
  719. join tld_material c on a.material_id = c.tld_id
  720. join tld_warehouse e on a.supply_warehouse_id = e.tld_id
  721. join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
  722. <trim prefix="WHERE" prefixOverrides="and |or">
  723. <if test="type != null and type != ''">
  724. and a.type = #{type}
  725. </if>
  726. <if test="materialCode != null and materialCode != ''">
  727. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  728. </if>
  729. <if test="materialName != null and materialName != ''">
  730. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  731. </if>
  732. <if test="warehouseTransferCode != null and warehouseTransferCode != ''">
  733. and b.warehouse_transfer_code like CONCAT(CONCAT('%',#{warehouseTransferCode}),'%')
  734. </if>
  735. <if test="startTime != null and startTime != ''">
  736. and b.document_time <![CDATA[>=]]> #{startTime}
  737. </if>
  738. <if test="endTime != null and endTime != ''">
  739. and b.document_time <![CDATA[<=]]> #{endTime}
  740. </if>
  741. <if test="askGoodsWarehouseId != null and askGoodsWarehouseId != ''">
  742. and b.ask_goods_warehouse_id = #{askGoodsWarehouseId}
  743. </if>
  744. <if test="supplyWarehouseId != null and supplyWarehouseId != ''">
  745. and a.supply_warehouse_id = #{supplyWarehouseId}
  746. </if>
  747. <if test="warehouseTransferType != null and warehouseTransferType != ''">
  748. and b.warehouse_transfer_type like CONCAT(CONCAT('%', #{warehouseTransferType}), '%')
  749. </if>
  750. <if test="companyCode != null and companyCode != ''">
  751. and a.account_sleeve = #{companyCode}
  752. </if>
  753. <if test="entryNumber != null and entryNumber != ''">
  754. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  755. </if>
  756. <if test="wbs != null and wbs != ''">
  757. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  758. </if>
  759. </trim>
  760. order by a.id desc
  761. </select>
  762. <!-- 查询日志信息 -->
  763. <select id="getLogData" resultType="com.tld.model.LogData">
  764. SELECT
  765. a.id,
  766. a.user_id,
  767. a.scrq,
  768. a.DATA,
  769. a.type,
  770. a.document_type,
  771. b.user_name
  772. FROM
  773. tld_log_data a
  774. LEFT JOIN tld_user b ON a.user_id = b.id
  775. <trim prefix="WHERE" prefixOverrides="and |or">
  776. <if test="documentType != null and documentType != ''">
  777. and a.document_type = #{documentType}
  778. </if>
  779. <if test="data != null and data != ''">
  780. and a.data like CONCAT(CONCAT('%', #{data}), '%')
  781. </if>
  782. <if test="startTime != null and startTime != ''">
  783. and a.scrq <![CDATA[>=]]> #{startTime}
  784. </if>
  785. <if test="endTime != null and endTime != ''">
  786. and a.scrq <![CDATA[<=]]> #{endTime}
  787. </if>
  788. <if test="userName != null and userName != ''">
  789. and b.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  790. </if>
  791. </trim>
  792. ORDER BY a.scrq DESC
  793. </select>
  794. <!--呆滞品导出-->
  795. <select id="dullGoodsExport" resultType="java.util.LinkedHashMap">
  796. SELECT
  797. b.code as wllbCode,
  798. b.name as materialName,
  799. c.storage_location_name as storageLocationName,
  800. f.name as companyName,
  801. e.name as ustomerName,
  802. a.wbs as wbs,
  803. a.amount as amount,
  804. a.scrq as scrq
  805. FROM tld_inventory a
  806. JOIN tld_material b ON a.material_id = b.tld_id
  807. LEFT JOIN tld_storage_location c ON a.storage_location_code = c.storage_location_code
  808. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  809. LEFT JOIN tld_company f ON a.account_sleeve = f.code
  810. WHERE datediff(now(), a.scrq) <![CDATA[>]]> 90
  811. <if test="storageLocationCode != null and storageLocationCode != ''">
  812. and a.storage_location_code = #{storageLocationCode}
  813. </if>
  814. <if test="materialName != null and materialName != ''">
  815. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  816. </if>
  817. <if test="wllbCode != null and wllbCode != ''">
  818. and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  819. </if>
  820. <if test="wbs != null and wbs != ''">
  821. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  822. </if>
  823. <if test="storageLocationName != null and storageLocationName != ''">
  824. and c.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  825. </if>
  826. <if test="ustomerCode != null and ustomerCode != ''">
  827. and a.supplier_id = #{ustomerCode}
  828. </if>
  829. <if test="companyCode != null and companyCode != ''">
  830. and a.account_sleeve = #{companyCode}
  831. </if>
  832. </select>
  833. <!--查询物料储量预警查询-->
  834. <select id="reserveWarnings" resultType="java.util.Map">
  835. SELECT
  836. a.NAME as materialName,
  837. a.CODE as wllbCode,
  838. ifnull(b.sum,0) AS amount,
  839. ifnull(a.max_num,'0') AS maxNum,
  840. ifnull(a.min_num,'0') AS minNum
  841. FROM
  842. tld_material a
  843. LEFT JOIN ( SELECT SUM( amount ) AS sum, material_id FROM tld_inventory GROUP BY material_id ) b ON a.tld_id =
  844. b.material_id
  845. WHERE
  846. (
  847. IF(a.max_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[>]]> a.max_num)
  848. OR
  849. IF(a.min_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[<]]> a.min_num)
  850. )
  851. <if test="materialName != null and materialName != ''">
  852. and a.name like CONCAT(CONCAT('%', #{materialName}), '%')
  853. </if>
  854. <if test="wllbCode != null and wllbCode != ''">
  855. and a.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  856. </if>
  857. </select>
  858. <!--查询物料储量预警查询导出-->
  859. <select id="reserveWarningsExport" resultType="java.util.LinkedHashMap">
  860. SELECT
  861. a.CODE as wllbCode,
  862. a.NAME as materialName,
  863. ifnull(b.sum,0) AS amount,
  864. ifnull(a.max_num,'0') AS maxNum,
  865. ifnull(a.min_num,'0') AS minNum
  866. FROM
  867. tld_material a
  868. LEFT JOIN ( SELECT SUM( amount ) AS sum, material_id FROM tld_inventory GROUP BY material_id ) b ON a.tld_id =
  869. b.material_id
  870. WHERE
  871. (
  872. IF(a.max_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[>]]> a.max_num)
  873. OR
  874. IF(a.min_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[<]]> a.min_num)
  875. )
  876. <if test="materialName != null and materialName != ''">
  877. and a.name like CONCAT(CONCAT('%', #{materialName}), '%')
  878. </if>
  879. <if test="wllbCode != null and wllbCode != ''">
  880. and a.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  881. </if>
  882. </select>
  883. <!--接入接出/接口信息导出-->
  884. <select id="onOffExcel" resultType="java.util.LinkedHashMap">
  885. select type,data,
  886. case access_type
  887. when '0' then '接入'
  888. when '1' then '接出'
  889. end as access_type,
  890. scrq
  891. from tld_access
  892. <trim prefix="WHERE" prefixOverrides="and |or">
  893. <if test="type != null and type != ''">
  894. and type = #{type}
  895. </if>
  896. <if test="accessType != null and accessType != ''">
  897. and access_type = #{accessType}
  898. </if>
  899. <if test="data != null and data != ''">
  900. and data like CONCAT(CONCAT('%', #{data}), '%')
  901. </if>
  902. <if test="startTime != null and startTime != ''">
  903. and scrq <![CDATA[>=]]> #{startTime}
  904. </if>
  905. <if test="endTime != null and endTime != ''">
  906. and scrq <![CDATA[<=]]> #{endTime}
  907. </if>
  908. </trim>
  909. order by id desc
  910. </select>
  911. <!--查询删除/修改日志信息导出-->
  912. <select id="getLogDataExcel" resultType="java.util.LinkedHashMap">
  913. SELECT
  914. b.user_name,
  915. a.document_type,
  916. a.DATA,
  917. a.scrq
  918. FROM
  919. tld_log_data a
  920. LEFT JOIN tld_user b ON a.user_id = b.id
  921. <trim prefix="WHERE" prefixOverrides="and |or">
  922. <if test="documentType != null and documentType != ''">
  923. and a.document_type = #{documentType}
  924. </if>
  925. <if test="data != null and data != ''">
  926. and a.data like CONCAT(CONCAT('%', #{data}), '%')
  927. </if>
  928. <if test="startTime != null and startTime != ''">
  929. and a.scrq <![CDATA[>=]]> #{startTime}
  930. </if>
  931. <if test="endTime != null and endTime != ''">
  932. and a.scrq <![CDATA[<=]]> #{endTime}
  933. </if>
  934. <if test="userName != null and userName != ''">
  935. and b.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  936. </if>
  937. </trim>
  938. ORDER BY a.scrq DESC
  939. </select>
  940. </mapper>