QueryListMappeer.xml 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633
  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. <!--添加errorExcel-->
  6. <insert id="addErrorExcel">
  7. insert into tld_error_excel(url,error_info,data_val,scrq,type,transmission_type,order_number,material_code,num,classify)
  8. values (#{url},#{errorInfo},#{dataVal},#{scrq},#{type},#{transmissionType},#{orderNumber},#{materialCode},#{num},#{classify})
  9. </insert>
  10. <!-- 呆滞品查询 -->
  11. <select id="dullGoods" resultType="java.util.Map">
  12. SELECT
  13. a.id as id,
  14. a.material_id as materialId,
  15. a.amount as amount,
  16. a.scrq as scrq,
  17. a.storage_location_code as storageLocationCode,
  18. b.name as materialName,
  19. c.storage_location_name as storageLocationName,
  20. b.code as wllbCode,
  21. a.wbs as wbs,
  22. h.name as wbsName,
  23. e.name as ustomerName,
  24. a.account_sleeve as accountSleeve,
  25. f.name as companyName
  26. FROM tld_inventory a
  27. JOIN tld_material b ON a.material_id = b.tld_id
  28. LEFT JOIN tld_storage_location c ON a.storage_location_code = c.storage_location_code
  29. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  30. LEFT JOIN tld_company f ON a.account_sleeve = f.code
  31. left join tld_wbs h on a.wbs = h.tld_id
  32. WHERE datediff(now(), a.scrq) <![CDATA[>]]> 90
  33. <if test="storageLocationCode != null and storageLocationCode != ''">
  34. and a.storage_location_code = #{storageLocationCode}
  35. </if>
  36. <if test="materialName != null and materialName != ''">
  37. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  38. </if>
  39. <if test="wllbCode != null and wllbCode != ''">
  40. and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  41. </if>
  42. <if test="wbs != null and wbs != ''">
  43. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  44. </if>
  45. <if test="storageLocationName != null and storageLocationName != ''">
  46. and c.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  47. </if>
  48. <if test="ustomerCode != null and ustomerCode != ''">
  49. and a.supplier_id = #{ustomerCode}
  50. </if>
  51. <if test="companyCode != null and companyCode != ''">
  52. and a.account_sleeve = #{companyCode}
  53. </if>
  54. </select>
  55. <!-- 查询所有物料 -->
  56. <select id="getMaterial" resultType="java.util.Map">
  57. select
  58. tld_id as tldId,
  59. ifnull(min_num, 0) as minNum,
  60. ifnull(max_num, 0) as maxNum,
  61. name as name,
  62. code as code
  63. from tld_material
  64. <trim prefix="WHERE" prefixOverrides="and |or">
  65. <if test="wllbCode != null and wllbCode != ''">
  66. and code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  67. </if>
  68. <if test="materialName != null and materialName != ''">
  69. and name like CONCAT(CONCAT('%', #{materialName}), '%')
  70. </if>
  71. </trim>
  72. </select>
  73. <!-- 物料储量预警查询 -->
  74. <select id="reserveWarning" resultType="java.util.Map" parameterType="java.util.Map">
  75. SELECT ifnull(sum(a.amount), "0") as amount,
  76. ${tldId} as materialId,
  77. ${minNum} as minNum,
  78. ${maxNum} as maxNum
  79. FROM tld_inventory a
  80. LEFT JOIN tld_material b ON a.material_id = b.tld_id
  81. WHERE material_id = #{tldId}
  82. </select>
  83. <!-- 查询库位信息 -->
  84. <select id="storageLocation" resultType="java.util.Map">
  85. SELECT
  86. a.id,
  87. YEAR(CURDATE()) AS year,
  88. MONTH(CURDATE()) AS month,
  89. f.code as warehouseCode,
  90. f.name as warehouseName,
  91. b.storage_location_name as storageLocationName,
  92. c.code as code,
  93. c.name as name,
  94. m.name as unitOfMeasurement,
  95. sum( a.amount ) AS sum,
  96. a.wbs as wbs,
  97. h.name as wbsName,
  98. c.max_num as maxNum,
  99. DATEDIFF(now(), scrq) as day,
  100. c.part_type as partType,
  101. c.wllb_class as wllbClass,
  102. p.code as companyCode,
  103. p.name as companyName,
  104. a.account_sleeve as accountSleeve,
  105. a.supplier_id as supplierId,
  106. e.name as supplierName,
  107. a.storage_location_code as storageLocationCode
  108. FROM
  109. tld_inventory a
  110. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  111. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  112. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  113. LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
  114. LEFT JOIN tld_company p on a.account_sleeve = p.code
  115. LEFT JOIN tld_measurement m on c.unit_of_measurement = m.tld_id
  116. left join tld_wbs h on a.wbs = h.tld_id
  117. <trim prefix="WHERE" prefixOverrides="and |or">
  118. <if test="storageLocationCode != null and storageLocationCode != ''">
  119. and a.storage_location_code = #{storageLocationCode}
  120. </if>
  121. <if test="materialId != null and materialId != ''">
  122. and a.material_id = #{materialId}
  123. </if>
  124. <if test="wllbCode != null and wllbCode != ''">
  125. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  126. </if>
  127. <if test="materialName != null and materialName != ''">
  128. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  129. </if>
  130. <if test="storageLocationName != null and storageLocationName != ''">
  131. and b.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  132. </if>
  133. <if test="companyName != null and companyName != ''">
  134. and p.name like CONCAT(CONCAT('%', #{companyName}), '%')
  135. </if>
  136. <if test="companyCode != null and companyCode != ''">
  137. and p.code = #{companyCode}
  138. </if>
  139. <if test="supplierId != null and supplierId != ''">
  140. and a.supplier_id like CONCAT(CONCAT('%', #{supplierId}), '%')
  141. </if>
  142. <if test="wbs != null and wbs != ''">
  143. and a.wbs = #{wbs}
  144. </if>
  145. <if test="wbsName != null and wbsName != ''">
  146. and h.name like CONCAT(CONCAT('%', #{wbsName}), '%')
  147. </if>
  148. <if test="warehouseId != null and warehouseId != ''">
  149. and f.tld_id = #{warehouseId}
  150. </if>
  151. <if test="partType != null and partType != ''">
  152. and c.part_type = #{partType}
  153. </if>
  154. <if test="wllbClass != null and wllbClass != ''">
  155. and c.wllb_class = #{wllbClass}
  156. </if>
  157. <if test="unitOfMeasurement != null and unitOfMeasurement != ''">
  158. and c.unit_of_measurement = #{unitOfMeasurement}
  159. </if>
  160. </trim>
  161. GROUP BY
  162. ${groupBy}
  163. </select>
  164. <!-- 查询库位信息 -->
  165. <select id="getQueryInventory" resultType="java.util.Map">
  166. SELECT
  167. a.id,
  168. a.storage_location_code as storageLocationCode,
  169. a.material_id as materialId,
  170. a.amount AS sum,
  171. a.serial,
  172. a.produc_batch as producBatch,
  173. a.produc_date as producDate,
  174. a.supplier_id as supplierId,
  175. b.storage_location_name as storageLocationName ,
  176. b.warehouse_where as warehouseWhere,
  177. b.storage_location_type as storageLocationType,
  178. b.storage_location_capacity as storageLocationCapacity,
  179. b.is_not_disable as isNotDisable,
  180. b.create_time as createTime,
  181. b.is_product as isProduct,
  182. c.name as name,
  183. c.code as code,
  184. e.name as supplierName,
  185. a.wbs,
  186. a.account_sleeve,
  187. h.name as wbsName
  188. FROM
  189. tld_inventory a
  190. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  191. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  192. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  193. LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
  194. LEFT JOIN tld_company p on a.account_sleeve = p.code
  195. LEFT JOIN tld_measurement m on c.unit_of_measurement = m.tld_id
  196. left join tld_wbs h on a.wbs = h.tld_id
  197. <trim prefix="WHERE" prefixOverrides="and |or">
  198. <if test="storageLocationCode != null and storageLocationCode != ''">
  199. and a.storage_location_code = #{storageLocationCode}
  200. </if>
  201. <if test="materialId != null and materialId != ''">
  202. and a.material_id = #{materialId}
  203. </if>
  204. <if test="wllbCode != null and wllbCode != ''">
  205. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  206. </if>
  207. <if test="materialName != null and materialName != ''">
  208. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  209. </if>
  210. <if test="storageLocationName != null and storageLocationName != ''">
  211. and b.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  212. </if>
  213. <if test="companyName != null and companyName != ''">
  214. and p.name like CONCAT(CONCAT('%', #{companyName}), '%')
  215. </if>
  216. <if test="companyCode != null and companyCode != ''">
  217. and p.code = #{companyCode}
  218. </if>
  219. <if test="supplierId != null and supplierId != ''">
  220. and a.supplier_id like CONCAT(CONCAT('%', #{supplierId}), '%')
  221. </if>
  222. <if test="wbs != null and wbs != ''">
  223. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  224. </if>
  225. <if test="warehouseId != null and warehouseId != ''">
  226. and f.tld_id = #{warehouseId}
  227. </if>
  228. <if test="partType != null and partType != ''">
  229. and c.part_type = #{partType}
  230. </if>
  231. <if test="wllbClass != null and wllbClass != ''">
  232. and c.wllb_class = #{wllbClass}
  233. </if>
  234. <if test="unitOfMeasurement != null and unitOfMeasurement != ''">
  235. and c.unit_of_measurement = #{unitOfMeasurement}
  236. </if>
  237. </trim>
  238. order by c.code
  239. </select>
  240. <!--导出-->
  241. <select id="getStorageLocation" resultType="java.util.LinkedHashMap">
  242. SELECT
  243. YEAR(CURDATE()) AS year,
  244. MONTH(CURDATE()) AS month,
  245. f.code as warehouseCode,
  246. f.name as warehouseName,
  247. b.storage_location_name as storageLocationName,
  248. c.code as code,
  249. c.name as name,
  250. ifnull(c.unit_of_measurement, "暂无单位") as unit_of_measurement,
  251. sum( a.amount ) AS sum,
  252. if(a.wbs = " ", null, a.wbs) as wbs,
  253. if(h.name = " ", null, h.name) as wbsName,
  254. ifnull(c.max_num, 0) as max_num,
  255. DATEDIFF(now(),scrq) as day,
  256. ifnull(c.part_type, "暂无分类") as part_type,
  257. ifnull(c.wllb_class, "暂无分类") as wllb_class,
  258. p.code as companyCode,
  259. p.name as companyName
  260. FROM tld_inventory a
  261. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  262. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  263. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  264. LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
  265. LEFT JOIN tld_company p on a.account_sleeve = p.code
  266. left join tld_wbs h on a.wbs = h.tld_id
  267. <trim prefix="WHERE" prefixOverrides="and |or">
  268. <if test="storageLocationCode != null and storageLocationCode != ''">
  269. and a.storage_location_code = #{storageLocationCode}
  270. </if>
  271. <if test="materialId != null and materialId != ''">
  272. and a.material_id = #{materialId}
  273. </if>
  274. <if test="wllbCode != null and wllbCode != ''">
  275. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  276. </if>
  277. <if test="materialName != null and materialName != ''">
  278. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  279. </if>
  280. <if test="storageLocationName != null and storageLocationName != ''">
  281. and b.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  282. </if>
  283. <if test="companyName != null and companyName != ''">
  284. and p.name like CONCAT(CONCAT('%', #{companyName}), '%')
  285. </if>
  286. <if test="supplierId != null and supplierId != ''">
  287. and a.supplier_id like CONCAT(CONCAT('%', #{supplierId}), '%')
  288. </if>
  289. <if test="wbs != null and wbs != ''">
  290. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  291. </if>
  292. <if test="wbsName != null and wbsName != ''">
  293. and h.name like CONCAT(CONCAT('%', #{wbsName}), '%')
  294. </if>
  295. <if test="warehouseId != null and warehouseId != ''">
  296. and f.tld_id = #{warehouseId}
  297. </if>
  298. </trim>
  299. GROUP BY
  300. /*a.storage_location_code,
  301. a.material_id,
  302. a.wbs,
  303. a.account_sleeve*/
  304. ${groupBy}
  305. </select>
  306. <!-- 查询接入信息 -->
  307. <select id="getAccess" resultType="com.tld.model.Access">
  308. select id,type,data,scrq,access_type from tld_access
  309. <trim prefix="WHERE" prefixOverrides="and |or">
  310. <if test="type != null and type != ''">
  311. and type = #{type}
  312. </if>
  313. <if test="accessType != null and accessType != ''">
  314. and access_type = #{accessType}
  315. </if>
  316. <if test="data != null and data != ''">
  317. and data like CONCAT(CONCAT('%', #{data}), '%')
  318. </if>
  319. <if test="startTime != null and startTime != ''">
  320. and scrq <![CDATA[>=]]> #{startTime}
  321. </if>
  322. <if test="endTime != null and endTime != ''">
  323. and scrq <![CDATA[<=]]> #{endTime}
  324. </if>
  325. </trim>
  326. order by id desc
  327. </select>
  328. <!-- 查询生产领料要货 -->
  329. <select id="getAskGoods" resultType="com.tld.model.AskGoods">
  330. SELECT
  331. a.id,
  332. a.ask_goods_id,
  333. a.material_id,
  334. IFNULL( a.out_num, 0 ) AS out_num,
  335. a.num,
  336. e.NAME AS materialName,
  337. e.CODE AS materialCode,
  338. b.ask_goods_code,
  339. b.company_number,
  340. b.sqrq,
  341. c.name as departmentName,
  342. g.name as companyName,
  343. b.source_type,
  344. b.move_type,
  345. a.entry_number,
  346. a.production_code,
  347. a.wbs,
  348. w.name as wbsName
  349. FROM
  350. tld_ask_goods a
  351. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  352. LEFT JOIN tld_department c ON b.department = c.code and b.company_number = c.account_sleeve
  353. JOIN tld_material e ON a.material_id = e.tld_id
  354. left join tld_company g on b.company_number = g.code
  355. left join tld_wbs w on a.wbs = w.tld_id
  356. /* WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
  357. <trim prefix="WHERE" prefixOverrides="and |or">
  358. <if test="materialCode != null and materialCode != ''">
  359. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  360. </if>
  361. <if test="materialName != null and materialName != ''">
  362. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  363. </if>
  364. <if test="startTime != null and startTime != ''">
  365. and b.sqrq <![CDATA[>=]]> #{startTime}
  366. </if>
  367. <if test="endTime != null and endTime != ''">
  368. and b.sqrq <![CDATA[<=]]> #{endTime}
  369. </if>
  370. <if test="departmentCode != null and departmentCode != ''">
  371. and b.department = #{departmentCode}
  372. </if>
  373. <if test="companyCode != null and companyCode != ''">
  374. and b.company_number = #{companyCode}
  375. </if>
  376. <if test="sourceType != null and sourceType != ''">
  377. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  378. </if>
  379. <if test="moveType != null and moveType != ''">
  380. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  381. </if>
  382. <if test="entryNumber != null and entryNumber != ''">
  383. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  384. </if>
  385. <if test="wbs != null and wbs != ''">
  386. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  387. </if>
  388. <if test="askGoodsCode != null and askGoodsCode != ''">
  389. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  390. </if>
  391. <if test="productionCode != null and productionCode != ''">
  392. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  393. </if>
  394. </trim>
  395. order by a.id desc
  396. </select>
  397. <!-- 查询生产领料要货 -->
  398. <select id="getAskGoodsExcel" resultType="java.util.LinkedHashMap">
  399. SELECT
  400. a.production_code,
  401. a.num,
  402. IFNULL( a.out_num, 0 ) AS out_num,
  403. e.NAME AS materialName,
  404. e.CODE AS materialCode,
  405. b.ask_goods_code,
  406. if(a.wbs = '' , null , a.wbs ) as wbs,
  407. if(w.name = '' , null , w.name ) as wbsName,
  408. b.company_number,
  409. g.name as companyName
  410. FROM
  411. tld_ask_goods a
  412. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  413. LEFT JOIN tld_department c ON b.department = c.code and b.company_number = c.account_sleeve
  414. JOIN tld_material e ON a.material_id = e.tld_id
  415. left join tld_company g on b.company_number = g.code
  416. left join tld_wbs w on a.wbs = w.tld_id
  417. /*WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
  418. <trim prefix="WHERE" prefixOverrides="and |or">
  419. <if test="materialCode != null and materialCode != ''">
  420. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  421. </if>
  422. <if test="materialName != null and materialName != ''">
  423. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  424. </if>
  425. <if test="startTime != null and startTime != ''">
  426. and b.sqrq <![CDATA[>=]]> #{startTime}
  427. </if>
  428. <if test="endTime != null and endTime != ''">
  429. and b.sqrq <![CDATA[<=]]> #{endTime}
  430. </if>
  431. <if test="departmentCode != null and departmentCode != ''">
  432. and b.department = #{departmentCode}
  433. </if>
  434. <if test="companyCode != null and companyCode != ''">
  435. and b.company_number = #{companyCode}
  436. </if>
  437. <if test="sourceType != null and sourceType != ''">
  438. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  439. </if>
  440. <if test="moveType != null and moveType != ''">
  441. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  442. </if>
  443. <if test="entryNumber != null and entryNumber != ''">
  444. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  445. </if>
  446. <if test="wbs != null and wbs != ''">
  447. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  448. </if>
  449. <if test="askGoodsCode != null and askGoodsCode != ''">
  450. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  451. </if>
  452. <if test="productionCode != null and productionCode != ''">
  453. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  454. </if>
  455. </trim>
  456. order by a.id desc
  457. </select>
  458. <!-- 查询非生产领料单 -->
  459. <select id="getInvite" resultType="com.tld.model.AskGoods">
  460. SELECT
  461. a.id,
  462. a.ask_goods_id,
  463. a.material_id,
  464. IFNULL( a.out_num, 0 ) AS out_num,
  465. a.num,
  466. e.NAME AS materialName,
  467. e.CODE AS materialCode,
  468. b.ask_goods_code,
  469. b.company_number,
  470. b.sqrq,
  471. c.name as departmentName,
  472. g.name as companyName,
  473. b.source_type ,
  474. b.move_type ,
  475. a.entry_number,
  476. a.production_code,
  477. a.wbs,
  478. w.name as wbsName
  479. FROM
  480. tld_invite a
  481. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  482. LEFT JOIN tld_department c ON b.department = c.code and b.company_number = c.account_sleeve
  483. JOIN tld_material e ON a.material_id = e.tld_id
  484. left join tld_company g on b.company_number = g.code
  485. left join tld_wbs w on a.wbs = w.tld_id
  486. /*WHERE*/
  487. /*e.part_type != '半成品' and e.part_type != '产成品'*/
  488. <trim prefix="WHERE" prefixOverrides="and |or">
  489. <if test="materialCode != null and materialCode != ''">
  490. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  491. </if>
  492. <if test="materialName != null and materialName != ''">
  493. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  494. </if>
  495. <if test="startTime != null and startTime != ''">
  496. and b.sqrq <![CDATA[>=]]> #{startTime}
  497. </if>
  498. <if test="endTime != null and endTime != ''">
  499. and b.sqrq <![CDATA[<=]]> #{endTime}
  500. </if>
  501. <if test="departmentCode != null and departmentCode != ''">
  502. and b.department = #{departmentCode}
  503. </if>
  504. <if test="companyCode != null and companyCode != ''">
  505. and b.company_number = #{companyCode}
  506. </if>
  507. <if test="sourceType != null and sourceType != ''">
  508. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  509. </if>
  510. <if test="moveType != null and moveType != ''">
  511. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  512. </if>
  513. <if test="entryNumber != null and entryNumber != ''">
  514. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  515. </if>
  516. <if test="wbs != null and wbs != ''">
  517. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  518. </if>
  519. <if test="askGoodsCode != null and askGoodsCode != ''">
  520. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  521. </if>
  522. <if test="productionCode != null and productionCode != ''">
  523. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  524. </if>
  525. </trim>
  526. order by a.id desc
  527. </select>
  528. <!-- 导出生产领料要货 -->
  529. <select id="getInviteExcel" resultType="java.util.LinkedHashMap">
  530. SELECT
  531. a.ask_goods_id,
  532. a.material_id,
  533. a.num,
  534. IFNULL( a.out_num, 0 ) AS out_num,
  535. e.NAME AS materialName,
  536. e.CODE AS materialCode,
  537. b.ask_goods_code,
  538. if(a.wbs = '' , null , a.wbs ) as wbs,
  539. if(w.name = '' , null , w.name ) as wbsName,
  540. b.company_number,
  541. g.name as companyName
  542. FROM
  543. tld_invite a
  544. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  545. LEFT JOIN tld_department c ON b.department = c.code and b.company_number = c.account_sleeve
  546. JOIN tld_material e ON a.material_id = e.tld_id
  547. left join tld_company g on b.company_number = g.code
  548. left join tld_wbs w on a.wbs = w.tld_id
  549. /*WHERE e.part_type != '半成品' and e.part_type != '产成品'*/
  550. <trim prefix="WHERE" prefixOverrides="and |or">
  551. <if test="materialCode != null and materialCode != ''">
  552. and e.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  553. </if>
  554. <if test="materialName != null and materialName != ''">
  555. and e.name like CONCAT(CONCAT('%', #{materialName}), '%')
  556. </if>
  557. <if test="startTime != null and startTime != ''">
  558. and b.sqrq <![CDATA[>=]]> #{startTime}
  559. </if>
  560. <if test="endTime != null and endTime != ''">
  561. and b.sqrq <![CDATA[<=]]> #{endTime}
  562. </if>
  563. <if test="departmentCode != null and departmentCode != ''">
  564. and b.department = #{departmentCode}
  565. </if>
  566. <if test="companyCode != null and companyCode != ''">
  567. and b.company_number = #{companyCode}
  568. </if>
  569. <if test="sourceType != null and sourceType != ''">
  570. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  571. </if>
  572. <if test="moveType != null and moveType != ''">
  573. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  574. </if>
  575. <if test="entryNumber != null and entryNumber != ''">
  576. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  577. </if>
  578. <if test="wbs != null and wbs != ''">
  579. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  580. </if>
  581. <if test="askGoodsCode != null and askGoodsCode != ''">
  582. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  583. </if>
  584. <if test="productionCode != null and productionCode != ''">
  585. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  586. </if>
  587. </trim>
  588. order by a.id desc
  589. </select>
  590. <!-- 查询销售单 -->
  591. <select id="getDelivery" resultType="com.tld.model.Delivery">
  592. select
  593. a.id,
  594. a.delivery_id,
  595. a.material_id,
  596. a.wbs,
  597. w.name as wbsName,
  598. a.gs_delivery_num,
  599. a.gs_cancel_num,
  600. ifnull(a.out_num, 0) as out_num,
  601. b.company_number,
  602. b.bills_time,
  603. c.name as materialName,
  604. c.code as materialCode,
  605. g.name as customerName,
  606. b.delivery_code as deliveryCode,
  607. v.name as companyName,
  608. b.delivery_type,
  609. b.source_type,
  610. b.move_type,
  611. b.delivery_code,
  612. a.entry_number
  613. from tld_delivery a
  614. join tld_delivery_f b on a.delivery_id = b.delivery_id
  615. join tld_material c on a.material_id = c.tld_id
  616. left join tld_customer g on b.customer_code = g.code
  617. left join tld_company v on b.company_number = v.code
  618. left join tld_wbs w on a.wbs = w.tld_id
  619. <trim prefix="WHERE" prefixOverrides="and |or">
  620. <if test="deliveryId != null and deliveryId != ''">
  621. and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
  622. </if>
  623. <if test="deliveryCode != null and deliveryCode != ''">
  624. and b.delivery_code like CONCAT(CONCAT('%', #{deliveryCode}), '%')
  625. </if>
  626. <if test="materialCode != null and materialCode != ''">
  627. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  628. </if>
  629. <if test="materialName != null and materialName != ''">
  630. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  631. </if>
  632. <if test="startTime != null and startTime != ''">
  633. and b.bills_time <![CDATA[>=]]> #{startTime}
  634. </if>
  635. <if test="endTime != null and endTime != ''">
  636. and b.bills_time <![CDATA[<=]]> #{endTime}
  637. </if>
  638. <if test="wbs != null and wbs != ''">
  639. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  640. </if>
  641. <if test="companyNumber != null and companyNumber != ''">
  642. and b.company_number = #{companyNumber}
  643. </if>
  644. <if test="customerCode != null and customerCode != ''">
  645. and b.customer_code = #{customerCode}
  646. </if>
  647. <if test="entryNumber != null and entryNumber != ''">
  648. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  649. </if>
  650. <if test="deliveryType != null and deliveryType != ''">
  651. and b.delivery_type like CONCAT(CONCAT('%', #{deliveryType}), '%')
  652. </if>
  653. <if test="sourceType != null and sourceType != ''">
  654. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  655. </if>
  656. <if test="moveType != null and moveType != ''">
  657. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  658. </if>
  659. <if test="status != null and status != ''">
  660. and a.status like CONCAT(CONCAT('%', #{status}), '%')
  661. </if>
  662. <if test="gsDeliveryNum != null and gsDeliveryNum != ''">
  663. and a.gs_delivery_num = #{gsDeliveryNum}
  664. </if>
  665. </trim>
  666. order by a.id desc
  667. </select>
  668. <!-- 导出销售单 -->
  669. <select id="getDeliveryExcel" resultType="java.util.LinkedHashMap">
  670. select
  671. b.delivery_code,
  672. a.material_id,
  673. if(a.wbs = '', null, a.wbs) as wbs,
  674. if(w.name = '' , null , w.name ) as wbsName,
  675. a.gs_delivery_num,
  676. a.gs_cancel_num,
  677. a.out_num,
  678. v.name as companyName,
  679. b.bills_time,
  680. c.name as materialName,
  681. c.code as materialCode,
  682. g.name as customerName,
  683. b.source_type,
  684. b.move_type,
  685. b.delivery_type,
  686. a.entry_number
  687. from tld_delivery a
  688. join tld_delivery_f b on a.delivery_id = b.delivery_id
  689. join tld_material c on a.material_id = c.tld_id
  690. left join tld_customer g on b.customer_code = g.code
  691. left join tld_company v on b.company_number = v.code
  692. left join tld_wbs w on a.wbs = w.tld_id
  693. <trim prefix="WHERE" prefixOverrides="and |or">
  694. <if test="deliveryId != null and deliveryId != ''">
  695. and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
  696. </if>
  697. <if test="deliveryCode != null and deliveryCode != ''">
  698. and b.delivery_code like CONCAT(CONCAT('%', #{deliveryCode}), '%')
  699. </if>
  700. <if test="materialCode != null and materialCode != ''">
  701. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  702. </if>
  703. <if test="materialName != null and materialName != ''">
  704. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  705. </if>
  706. <if test="startTime != null and startTime != ''">
  707. and b.bills_time <![CDATA[>=]]> #{startTime}
  708. </if>
  709. <if test="endTime != null and endTime != ''">
  710. and b.bills_time <![CDATA[<=]]> #{endTime}
  711. </if>
  712. <if test="wbs != null and wbs != ''">
  713. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  714. </if>
  715. <if test="companyNumber != null and companyNumber != ''">
  716. and b.company_number = #{companyNumber}
  717. </if>
  718. <if test="customerCode != null and customerCode != ''">
  719. and b.customer_code = #{customerCode}
  720. </if>
  721. <if test="entryNumber != null and entryNumber != ''">
  722. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  723. </if>
  724. <if test="deliveryType != null and deliveryType != ''">
  725. and b.delivery_type like CONCAT(CONCAT('%', #{deliveryType}), '%')
  726. </if>
  727. <if test="sourceType != null and sourceType != ''">
  728. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  729. </if>
  730. <if test="moveType != null and moveType != ''">
  731. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  732. </if>
  733. </trim>
  734. </select>
  735. <!-- 查询移库单 -->
  736. <select id="getWarehouseTransfer" resultType="com.tld.model.WarehouseTransfer">
  737. select
  738. a.id,
  739. a.warehouse_transfer_id,
  740. a.entry_number,
  741. a.supply_warehouse_id,
  742. a.material_id,
  743. a.wbs,
  744. h.name as wbsName,
  745. a.num,
  746. a.out_num,
  747. a.type,
  748. b.warehouse_transfer_code,
  749. b.ask_goods_warehouse_id,
  750. b.document_time,
  751. b.warehouse_transfer_type,
  752. c.name as materialName,
  753. c.code as materialCode,
  754. f.name as askGoodsWarehouseName,
  755. e.name as supplyWarehouseName,
  756. a.account_sleeve as accountSleeve,
  757. k.name as companyName
  758. from tld_warehouse_transfer a
  759. join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
  760. join tld_material c on a.material_id = c.tld_id
  761. join tld_warehouse e on a.supply_warehouse_id = e.tld_id
  762. join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
  763. join tld_company k on a.account_sleeve = k.code
  764. left join tld_wbs h on a.wbs = h.tld_id
  765. <trim prefix="WHERE" prefixOverrides="and |or">
  766. <if test="type != null and type != ''">
  767. and a.type = #{type}
  768. </if>
  769. <if test="materialCode != null and materialCode != ''">
  770. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  771. </if>
  772. <if test="materialName != null and materialName != ''">
  773. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  774. </if>
  775. <if test="warehouseTransferCode != null and warehouseTransferCode != ''">
  776. and b.warehouse_transfer_code like CONCAT(CONCAT('%',#{warehouseTransferCode}),'%')
  777. </if>
  778. <if test="startTime != null and startTime != ''">
  779. and b.document_time <![CDATA[>=]]> #{startTime}
  780. </if>
  781. <if test="endTime != null and endTime != ''">
  782. and b.document_time <![CDATA[<=]]> #{endTime}
  783. </if>
  784. <if test="askGoodsWarehouseId != null and askGoodsWarehouseId != ''">
  785. and b.ask_goods_warehouse_id = #{askGoodsWarehouseId}
  786. </if>
  787. <if test="supplyWarehouseId != null and supplyWarehouseId != ''">
  788. and a.supply_warehouse_id = #{supplyWarehouseId}
  789. </if>
  790. <if test="warehouseTransferType != null and warehouseTransferType != ''">
  791. and b.warehouse_transfer_type like CONCAT(CONCAT('%', #{warehouseTransferType}), '%')
  792. </if>
  793. <if test="companyCode != null and companyCode != ''">
  794. and a.account_sleeve = #{companyCode}
  795. </if>
  796. <if test="entryNumber != null and entryNumber != ''">
  797. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  798. </if>
  799. <if test="wbs != null and wbs != ''">
  800. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  801. </if>
  802. </trim>
  803. order by a.id desc
  804. </select>
  805. <!-- 移库单导出 -->
  806. <select id="getWarehouseTransferExcel" resultType="java.util.LinkedHashMap">
  807. select
  808. a.warehouse_transfer_id,
  809. b.warehouse_transfer_code,
  810. c.name as materialName,
  811. c.code as materialCode,
  812. if(a.wbs = '', null, a.wbs) as wbs,
  813. if( h.name = '', null, h.name) as wbsName,
  814. a.num,
  815. a.out_num,
  816. f.name as askGoodsWarehouseaName,
  817. e.name as supplyWarehouseName,
  818. b.document_time
  819. from tld_warehouse_transfer a
  820. join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
  821. join tld_material c on a.material_id = c.tld_id
  822. join tld_warehouse e on a.supply_warehouse_id = e.tld_id
  823. join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
  824. join tld_company k on a.account_sleeve = k.code
  825. left join tld_wbs h on a.wbs = h.tld_id
  826. <trim prefix="WHERE" prefixOverrides="and |or">
  827. <if test="type != null and type != ''">
  828. and a.type = #{type}
  829. </if>
  830. <if test="materialCode != null and materialCode != ''">
  831. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  832. </if>
  833. <if test="materialName != null and materialName != ''">
  834. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  835. </if>
  836. <if test="warehouseTransferCode != null and warehouseTransferCode != ''">
  837. and b.warehouse_transfer_code like CONCAT(CONCAT('%',#{warehouseTransferCode}),'%')
  838. </if>
  839. <if test="startTime != null and startTime != ''">
  840. and b.document_time <![CDATA[>=]]> #{startTime}
  841. </if>
  842. <if test="endTime != null and endTime != ''">
  843. and b.document_time <![CDATA[<=]]> #{endTime}
  844. </if>
  845. <if test="askGoodsWarehouseId != null and askGoodsWarehouseId != ''">
  846. and b.ask_goods_warehouse_id = #{askGoodsWarehouseId}
  847. </if>
  848. <if test="supplyWarehouseId != null and supplyWarehouseId != ''">
  849. and a.supply_warehouse_id = #{supplyWarehouseId}
  850. </if>
  851. <if test="warehouseTransferType != null and warehouseTransferType != ''">
  852. and b.warehouse_transfer_type like CONCAT(CONCAT('%', #{warehouseTransferType}), '%')
  853. </if>
  854. <if test="companyCode != null and companyCode != ''">
  855. and a.account_sleeve = #{companyCode}
  856. </if>
  857. <if test="entryNumber != null and entryNumber != ''">
  858. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  859. </if>
  860. <if test="wbs != null and wbs != ''">
  861. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  862. </if>
  863. </trim>
  864. order by a.id desc
  865. </select>
  866. <!-- 查询日志信息 -->
  867. <select id="getLogData" resultType="com.tld.model.LogData">
  868. SELECT
  869. a.id,
  870. a.user_id,
  871. a.scrq,
  872. a.DATA,
  873. a.type,
  874. a.document_type,
  875. b.user_name
  876. FROM
  877. tld_log_data a
  878. LEFT JOIN tld_user b ON a.user_id = b.id
  879. <trim prefix="WHERE" prefixOverrides="and |or">
  880. <if test="documentType != null and documentType != ''">
  881. and a.document_type = #{documentType}
  882. </if>
  883. <if test="data != null and data != ''">
  884. and a.data like CONCAT(CONCAT('%', #{data}), '%')
  885. </if>
  886. <if test="startTime != null and startTime != ''">
  887. and a.scrq <![CDATA[>=]]> #{startTime}
  888. </if>
  889. <if test="endTime != null and endTime != ''">
  890. and a.scrq <![CDATA[<=]]> #{endTime}
  891. </if>
  892. <if test="userName != null and userName != ''">
  893. and b.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  894. </if>
  895. </trim>
  896. ORDER BY a.scrq DESC
  897. </select>
  898. <!--呆滞品导出-->
  899. <select id="dullGoodsExport" resultType="java.util.LinkedHashMap">
  900. SELECT
  901. b.code as wllbCode,
  902. b.name as materialName,
  903. c.storage_location_name as storageLocationName,
  904. f.name as companyName,
  905. e.name as ustomerName,
  906. if(a.wbs = '', null,a.wbs) as wbs,
  907. if(h.name = '', null, h.name) as wbsName,
  908. a.amount as amount,
  909. a.scrq as scrq
  910. FROM tld_inventory a
  911. JOIN tld_material b ON a.material_id = b.tld_id
  912. LEFT JOIN tld_storage_location c ON a.storage_location_code = c.storage_location_code
  913. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  914. LEFT JOIN tld_company f ON a.account_sleeve = f.code
  915. left join tld_wbs h on a.wbs = h.tld_id
  916. WHERE datediff(now(), a.scrq) <![CDATA[>]]> 90
  917. <if test="storageLocationCode != null and storageLocationCode != ''">
  918. and a.storage_location_code = #{storageLocationCode}
  919. </if>
  920. <if test="materialName != null and materialName != ''">
  921. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  922. </if>
  923. <if test="wllbCode != null and wllbCode != ''">
  924. and b.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  925. </if>
  926. <if test="wbs != null and wbs != ''">
  927. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  928. </if>
  929. <if test="storageLocationName != null and storageLocationName != ''">
  930. and c.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  931. </if>
  932. <if test="ustomerCode != null and ustomerCode != ''">
  933. and a.supplier_id = #{ustomerCode}
  934. </if>
  935. <if test="companyCode != null and companyCode != ''">
  936. and a.account_sleeve = #{companyCode}
  937. </if>
  938. </select>
  939. <!--查询物料储量预警查询-->
  940. <select id="reserveWarnings" resultType="java.util.Map">
  941. SELECT
  942. a.NAME as materialName,
  943. a.CODE as wllbCode,
  944. ifnull(b.sum,0) AS amount,
  945. ifnull(a.max_num,'0') AS maxNum,
  946. ifnull(a.min_num,'0') AS minNum
  947. FROM
  948. tld_material a
  949. LEFT JOIN ( SELECT SUM( amount ) AS sum, material_id FROM tld_inventory GROUP BY material_id ) b ON a.tld_id =
  950. b.material_id
  951. WHERE
  952. (
  953. IF(a.max_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[>]]> a.max_num)
  954. OR
  955. IF(a.min_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[<]]> a.min_num)
  956. )
  957. <if test="materialName != null and materialName != ''">
  958. and a.name like CONCAT(CONCAT('%', #{materialName}), '%')
  959. </if>
  960. <if test="wllbCode != null and wllbCode != ''">
  961. and a.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  962. </if>
  963. </select>
  964. <!--查询物料储量预警查询导出-->
  965. <select id="reserveWarningsExport" resultType="java.util.LinkedHashMap">
  966. SELECT
  967. a.CODE as wllbCode,
  968. a.NAME as materialName,
  969. ifnull(b.sum,0) AS amount,
  970. ifnull(a.max_num,'0') AS maxNum,
  971. ifnull(a.min_num,'0') AS minNum
  972. FROM
  973. tld_material a
  974. LEFT JOIN ( SELECT SUM( amount ) AS sum, material_id FROM tld_inventory GROUP BY material_id ) b ON a.tld_id =
  975. b.material_id
  976. WHERE
  977. (
  978. IF(a.max_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[>]]> a.max_num)
  979. OR
  980. IF(a.min_num IS NULL,FALSE,IF( b.sum IS NULL, 0, b.sum + 0 ) <![CDATA[<]]> a.min_num)
  981. )
  982. <if test="materialName != null and materialName != ''">
  983. and a.name like CONCAT(CONCAT('%', #{materialName}), '%')
  984. </if>
  985. <if test="wllbCode != null and wllbCode != ''">
  986. and a.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  987. </if>
  988. </select>
  989. <!--接入接出/接口信息导出-->
  990. <select id="onOffExcel" resultType="java.util.LinkedHashMap">
  991. select type,data,
  992. case access_type
  993. when '0' then '接入'
  994. when '1' then '接出'
  995. end as access_type,
  996. scrq
  997. from tld_access
  998. <trim prefix="WHERE" prefixOverrides="and |or">
  999. <if test="type != null and type != ''">
  1000. and type = #{type}
  1001. </if>
  1002. <if test="accessType != null and accessType != ''">
  1003. and access_type = #{accessType}
  1004. </if>
  1005. <if test="data != null and data != ''">
  1006. and data like CONCAT(CONCAT('%', #{data}), '%')
  1007. </if>
  1008. <if test="startTime != null and startTime != ''">
  1009. and scrq <![CDATA[>=]]> #{startTime}
  1010. </if>
  1011. <if test="endTime != null and endTime != ''">
  1012. and scrq <![CDATA[<=]]> #{endTime}
  1013. </if>
  1014. </trim>
  1015. order by id desc
  1016. </select>
  1017. <!--查询删除/修改日志信息导出-->
  1018. <select id="getLogDataExcel" resultType="java.util.LinkedHashMap">
  1019. SELECT
  1020. b.user_name,
  1021. a.document_type,
  1022. a.DATA,
  1023. a.scrq
  1024. FROM
  1025. tld_log_data a
  1026. LEFT JOIN tld_user b ON a.user_id = b.id
  1027. <trim prefix="WHERE" prefixOverrides="and |or">
  1028. <if test="documentType != null and documentType != ''">
  1029. and a.document_type = #{documentType}
  1030. </if>
  1031. <if test="data != null and data != ''">
  1032. and a.data like CONCAT(CONCAT('%', #{data}), '%')
  1033. </if>
  1034. <if test="startTime != null and startTime != ''">
  1035. and a.scrq <![CDATA[>=]]> #{startTime}
  1036. </if>
  1037. <if test="endTime != null and endTime != ''">
  1038. and a.scrq <![CDATA[<=]]> #{endTime}
  1039. </if>
  1040. <if test="userName != null and userName != ''">
  1041. and b.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  1042. </if>
  1043. </trim>
  1044. ORDER BY a.scrq DESC
  1045. </select>
  1046. <!--查询库存数量-->
  1047. <select id="getAmount" resultType="java.lang.String">
  1048. select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
  1049. </select>
  1050. <!--查询库存数量-->
  1051. <select id="getAmounts" resultType="java.lang.String">
  1052. select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
  1053. </select>
  1054. <!--查询其它入库信息-->
  1055. <select id="getOtherReceivingGoods" resultType="com.tld.model.Notice">
  1056. select
  1057. a.id,
  1058. a.notice_id,
  1059. a.entry_number,
  1060. a.material_id,
  1061. a.wbs,
  1062. g.name as wbsName,
  1063. a.measurement_id,
  1064. a.num,
  1065. a.entry_number,
  1066. a.warehousing_num,
  1067. b.notice_code,
  1068. b.company_number,
  1069. b.notice_time,
  1070. b.source_type,
  1071. b.move_type,
  1072. b.notification_type_number,
  1073. b.notification_type_name,
  1074. c.name as materialName,
  1075. c.code as materialCode,
  1076. c.part_type,
  1077. k.name as companyName,
  1078. g.name as wbsCode
  1079. from tld_notices a
  1080. join tld_notices_f b on a.notice_id = b.notice_id
  1081. join tld_material c on a.material_id = c.tld_id
  1082. join tld_company k on b.company_number = k.code
  1083. left join tld_wbs g on a.wbs = g.tld_id
  1084. <trim prefix="WHERE" prefixOverrides="and |or">
  1085. <if test="type == '0'.toString() ">
  1086. IFNULL(a.warehousing_num, 0) <![CDATA[<]]> (a.num + 0)
  1087. </if>
  1088. <if test="type == '1'.toString() ">
  1089. IFNULL(a.warehousing_num, 0) <![CDATA[=]]> (a.num + 0)
  1090. </if>
  1091. <if test="materialCode != null and materialCode != ''">
  1092. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  1093. </if>
  1094. <if test="materialName != null and materialName != ''">
  1095. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  1096. </if>
  1097. <if test="noticeCode != null and noticeCode != ''">
  1098. and b.notice_code like CONCAT(CONCAT('%', #{noticeCode}), '%')
  1099. </if>
  1100. <if test="materialId != null and materialId != ''">
  1101. and c.tld_id like CONCAT(CONCAT('%', #{materialId}), '%')
  1102. </if>
  1103. <if test="partType != null and partType != ''">
  1104. and c.part_type = #{partType}
  1105. </if>
  1106. <if test="startTime != null and startTime != ''">
  1107. and b.notice_time <![CDATA[>=]]> #{startTime}
  1108. </if>
  1109. <if test="endTime != null and endTime != ''">
  1110. and b.notice_time <![CDATA[<=]]> #{endTime}
  1111. </if>
  1112. <if test="companyNumber != null and companyNumber != ''">
  1113. and b.company_number = #{companyNumber}
  1114. </if>
  1115. <if test="wbs != null and wbs != ''">
  1116. and g.name like CONCAT(CONCAT('%', #{wbs}), '%')
  1117. </if>
  1118. </trim>
  1119. order by a.id desc
  1120. </select>
  1121. <!-- 移库修改状态 -->
  1122. <update id="updateType">
  1123. update tld_storage set transmission_type = #{type} where storage_code = #{wmsCode}
  1124. <if test="code != null and code != ''">
  1125. and wllb_code = #{code}
  1126. </if>;
  1127. update tld_removal set transmission_type = #{type} where storage_code = #{wmsCode}
  1128. <if test="code != null and code != ''">
  1129. and wllb_code = #{code}
  1130. </if>;
  1131. update tld_removal_half_product set transmission_type = #{type} where storage_code = #{wmsCode}
  1132. <if test="code != null and code != ''">
  1133. and wllb_code = #{code}
  1134. </if>;
  1135. update tld_removal_half set transmission_type = #{type} where storage_code = #{wmsCode}
  1136. <if test="code != null and code != ''">
  1137. and wllb_code = #{code}
  1138. </if>;
  1139. update tld_half set transmission_type = #{type} where storage_code = #{wmsCode}
  1140. <if test="code != null and code != ''">
  1141. and wllb_code = #{code}
  1142. </if>;
  1143. update tld_half_product set transmission_type = #{type} where storage_code = #{wmsCode}
  1144. <if test="code != null and code != ''">
  1145. and wllb_code = #{code}
  1146. </if>;
  1147. </update>
  1148. <!--查询其它出库信息-->
  1149. <select id="getOtherShipments" resultType="com.tld.model.AskGoods">
  1150. select
  1151. a.id,
  1152. a.ask_goods_id,
  1153. a.material_id,
  1154. a.wbs,
  1155. g.name as wbsName,
  1156. a.measurement_id,
  1157. a.num,
  1158. a.out_num,
  1159. a.entry_number,
  1160. b.ask_goods_code,
  1161. b.company_number,
  1162. b.sqrq,
  1163. p.name as department,
  1164. b.source_type,
  1165. b.move_type,
  1166. b.request_type_number,
  1167. b.request_type_name,
  1168. b.if_commodity,
  1169. b.id as documentPointsId,
  1170. c.name as materialName,
  1171. c.code as materialCode,
  1172. c.part_type,
  1173. k.name as companyName,
  1174. g.name as wbsCode
  1175. from tld_enquiry a
  1176. join tld_enquiry_f b on a.ask_goods_id = b.ask_goods_id
  1177. join tld_material c on a.material_id = c.tld_id
  1178. join tld_company k on b.company_number = k.code
  1179. join tld_department p on b.department = p.code and b.company_number = p.account_sleeve
  1180. left join tld_wbs g on a.wbs = g.tld_id
  1181. <trim prefix="WHERE" prefixOverrides="and |or">
  1182. <if test="type == '0'.toString() ">
  1183. IFNULL(a.out_num, 0) <![CDATA[<]]> (a.num + 0)
  1184. </if>
  1185. <if test="type == '1'.toString() ">
  1186. IFNULL(a.out_num, 0) <![CDATA[=]]> (a.num + 0)
  1187. </if>
  1188. <if test="materialCode != null and materialCode != ''">
  1189. and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  1190. </if>
  1191. <if test="materialName != null and materialName != ''">
  1192. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  1193. </if>
  1194. <if test="askGoodsCode != null and askGoodsCode != ''">
  1195. and b.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  1196. </if>
  1197. <if test="departmentCode != null and departmentCode != ''">
  1198. and b.department = #{departmentCode}
  1199. </if>
  1200. <if test="materialId != null and materialId != ''">
  1201. and c.tld_id like CONCAT(CONCAT('%', #{materialId}), '%')
  1202. </if>
  1203. <if test="partType != null and partType != ''">
  1204. and c.part_type = #{partType}
  1205. </if>
  1206. <if test="startTime != null and startTime != ''">
  1207. and b.sqrq <![CDATA[>=]]> #{startTime}
  1208. </if>
  1209. <if test="endTime != null and endTime != ''">
  1210. and b.sqrq <![CDATA[<=]]> #{endTime}
  1211. </if>
  1212. <if test="companyNumber != null and companyNumber != ''">
  1213. and b.company_number = #{companyNumber}
  1214. </if>
  1215. <if test="wbs != null and wbs != ''">
  1216. and g.name like CONCAT(CONCAT('%', #{wbs}), '%')
  1217. </if>
  1218. </trim>
  1219. order by a.id desc
  1220. </select>
  1221. <!--采购大屏信息-->
  1222. <select id="getProcurementScreen" resultType="com.tld.model.ReceiveGoods">
  1223. select
  1224. a.id,
  1225. a.supplier_id,
  1226. a.order_code,
  1227. a.material_id,
  1228. a.purchase_num,
  1229. a.arrival_num,
  1230. a.arrival_time,
  1231. a.type,
  1232. b.name as materialName,
  1233. b.code as wllbCode,
  1234. b.wllb_class as wllbClass,
  1235. c.name as supplierName
  1236. from tld_purchase a
  1237. left join tld_material b on a.material_id = b.tld_id
  1238. left join tld_customer c on a.supplier_id = c.tld_id
  1239. where DATE(a.arrival_time) <![CDATA[=]]> DATE(NOW())
  1240. and a.type = '0'
  1241. </select>
  1242. <!--采购大屏总数量-->
  1243. <select id="getTotalQuantity" resultType="java.lang.Integer">
  1244. select sum(arrival_num) from tld_purchase where DATE(arrival_time) <![CDATA[=]]> DATE(NOW())
  1245. </select>
  1246. <!-- 已收货数量-->
  1247. <select id="getQuantityArrived" resultType="java.lang.Integer">
  1248. select sum(arrival_num) from tld_purchase where DATE(arrival_time) <![CDATA[=]]> DATE(NOW()) and type = '1'
  1249. </select>
  1250. <!--未收货数量-->
  1251. <select id="getUnarrivedQuantity" resultType="java.lang.Integer">
  1252. select sum(arrival_num) from tld_purchase where DATE(arrival_time) <![CDATA[=]]> DATE(NOW()) and type = '0'
  1253. </select>
  1254. <!-- 超时未送达数量 -->
  1255. <select id="getTimeoutQuantity" resultType="java.lang.Integer">
  1256. select sum(arrival_num) from tld_purchase
  1257. where arrival_time <![CDATA[<]]> NOW()
  1258. and type = '0'
  1259. </select>
  1260. <!--查询采购单入库数量-->
  1261. <select id="getPurchaseSum" resultType="java.lang.Integer">
  1262. select IFNULL(sum(warehousing_num),0) as amount from tld_receive_goods a
  1263. left join tld_receive_goods_f b on a.order_code = b.order_code
  1264. left join tld_material c on a.material_id = c.tld_id
  1265. where c.part_type = #{nameType}
  1266. and DATE_FORMAT( b.arrival_time, '%Y-%m-%d' ) = #{format}
  1267. </select>
  1268. <!--查询其他入库数量-->
  1269. <select id="getSomeoneSum" resultType="java.lang.Integer">
  1270. select IFNULL(sum(warehousing_num),0) as amount from tld_notices a
  1271. left join tld_notices_f b on a.notice_id = b.notice_id
  1272. left join tld_material c on a.material_id = c.tld_id
  1273. where c.part_type = #{nameType}
  1274. and DATE_FORMAT( b.notice_time, '%Y-%m-%d' ) = #{format}
  1275. </select>
  1276. <!--生成领料出库数量-->
  1277. <select id="getAskGoodsSum" resultType="java.lang.Integer">
  1278. select IFNULL(sum(out_num),0) as amount from tld_ask_goods a
  1279. left join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
  1280. left join tld_material c on a.material_id = c.tld_id
  1281. where c.part_type = #{nameType}
  1282. and DATE_FORMAT( b.sqrq, '%Y-%m-%d' ) = #{format}
  1283. </select>
  1284. <!--非生产领料出库数量-->
  1285. <select id="getInviteSum" resultType="java.lang.Integer">
  1286. select IFNULL(sum(out_num),0) as amount from tld_invite a
  1287. left join tld_invite_f b on a.ask_goods_id = b.ask_goods_id
  1288. left join tld_material c on a.material_id = c.tld_id
  1289. where c.part_type = #{nameType}
  1290. and DATE_FORMAT( b.sqrq, '%Y-%m-%d' ) = #{format}
  1291. </select>
  1292. <!--其他出库数量-->
  1293. <select id="getEnquirySum" resultType="java.lang.Integer">
  1294. select IFNULL(sum(out_num),0) as amount from tld_enquiry a
  1295. left join tld_enquiry_f b on a.ask_goods_id = b.ask_goods_id
  1296. left join tld_material c on a.material_id = c.tld_id
  1297. where c.part_type = #{nameType}
  1298. and DATE_FORMAT( b.sqrq, '%Y-%m-%d' ) = #{format}
  1299. </select>
  1300. <!--报工单入库数量-->
  1301. <select id="getNoticeSum" resultType="java.lang.Integer">
  1302. select IFNULL(sum(warehousing_num),0) as amount from tld_notice a
  1303. left join tld_notice_f b on a.notice_id = b.notice_id
  1304. left join tld_material c on a.material_id = c.tld_id
  1305. where c.part_type = #{nameType}
  1306. and DATE_FORMAT( b.notice_time, '%Y-%m-%d' ) = #{format}
  1307. </select>
  1308. <!--销售单出库数量-->
  1309. <select id="getDeliverySum" resultType="java.lang.Integer">
  1310. select IFNULL(sum(out_num),0) as amount from tld_delivery a
  1311. left join tld_delivery_f b on a.delivery_id = b.delivery_id
  1312. left join tld_material c on a.material_id = c.tld_id
  1313. where c.part_type = #{nameType}
  1314. and DATE_FORMAT( b.bills_time, '%Y-%m-%d' ) = #{format}
  1315. </select>
  1316. <!--查询pda所有任务-->
  1317. <select id="getPdaTask" resultType="java.util.Map">
  1318. SELECT
  1319. a.id,
  1320. a.scrq,
  1321. a.modify_time AS modifyTime,
  1322. b.code,
  1323. b.name,
  1324. b.part_type AS partType,
  1325. c.user_name AS userName,
  1326. c.real_name AS realName,
  1327. d.user_name AS modifyUserName,
  1328. d.real_name AS modifyRealName,
  1329. d.modify_time AS modifyTime
  1330. FROM tld_user_material a
  1331. LEFT JOIN tld_material b ON a.material_id = b.CODE
  1332. LEFT JOIN tld_user c ON a.user_id = c.id
  1333. LEFT JOIN tld_user d ON a.modify_user = d.id
  1334. <trim prefix="WHERE" prefixOverrides="and |or">
  1335. <if test="userId != null and userId != ''">
  1336. and a.user_id = #{userId}
  1337. </if>
  1338. </trim>
  1339. ORDER BY a.id DESC
  1340. </select>
  1341. <!-- 查询质检单任务数量 -->
  1342. <select id="getShangjia" resultType="int">
  1343. select count(*) from tld_receive_goods where (warehousing_num + 0) <![CDATA[<]]> (qualified_num + 0)
  1344. </select>
  1345. <!-- 查询生产领料任务数量 -->
  1346. <select id="getJihua" resultType="int">
  1347. SELECT
  1348. count(*)
  1349. FROM
  1350. tld_ask_goods a
  1351. JOIN tld_material b on a.material_id = b.tld_id
  1352. WHERE
  1353. ((a.num + 0) <![CDATA[>]]> (IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
  1354. and b.code in (select material_id from tld_user_material where user_id = #{userId})
  1355. and b.part_type != '半成品' and b.part_type != '产成品'
  1356. </select>
  1357. <!-- 查询非生产领料任务数量 -->
  1358. <select id="getYaoqing" resultType="int">
  1359. SELECT
  1360. count(*)
  1361. FROM
  1362. tld_invite a
  1363. JOIN tld_material b on a.material_id = b.tld_id
  1364. WHERE
  1365. ((a.num + 0) <![CDATA[>]]> (
  1366. IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and b.code in (select material_id from tld_user_material where user_id = #{userId})
  1367. and b.part_type != '半成品' and b.part_type != '产成品'
  1368. </select>
  1369. <!-- 查询半成品入库任务数量 -->
  1370. <select id="getBanChenPin" resultType="int">
  1371. SELECT
  1372. count(*)
  1373. FROM
  1374. tld_notice a
  1375. join tld_material b on a.material_id = b.tld_id
  1376. where b.part_type = "半成品" and a.type = "0" and b.code in (select material_id from tld_user_material where user_id = #{userId})
  1377. </select>
  1378. <!-- 查询产成品入库任务数量 -->
  1379. <select id="getChanChenPin" resultType="int">
  1380. SELECT
  1381. count(*)
  1382. FROM
  1383. tld_notice a
  1384. JOIN tld_material b on a.material_id = b.tld_id
  1385. where b.part_type = "产成品" and (warehousing_num + 0) <![CDATA[<]]> (
  1386. a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
  1387. </select>
  1388. <!-- 销售发货任务数量 -->
  1389. <select id="getXiaoShou" resultType="int">
  1390. SELECT
  1391. count(*)
  1392. FROM
  1393. tld_delivery a
  1394. JOIN tld_material b ON a.material_id = b.tld_id
  1395. where ( a.gs_delivery_num - a.gs_cancel_num ) <![CDATA[>]]> a.out_num and b.code in (select material_id from tld_user_material where user_id = #{userId}) and a.status = "0"
  1396. </select>
  1397. <!-- 查询其他入库任务数量 -->
  1398. <select id="getQiTaRu" resultType="int">
  1399. SELECT
  1400. count(*)
  1401. FROM
  1402. tld_notices a
  1403. JOIN tld_material b ON a.material_id = b.tld_id
  1404. where (a.warehousing_num + 0) <![CDATA[<]]> (
  1405. a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
  1406. </select>
  1407. <!-- 查询其他出库任务数量 -->
  1408. <select id="getQiTaChu" resultType="int">
  1409. SELECT
  1410. count(*)
  1411. FROM
  1412. tld_enquiry a
  1413. JOIN tld_material b ON a.material_id = b.tld_id
  1414. where (a.out_num + 0) <![CDATA[<]]> (
  1415. a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
  1416. </select>
  1417. <!-- 查询移库任务数量 -->
  1418. <select id="getYiKu" resultType="int">
  1419. SELECT
  1420. count(*)
  1421. FROM
  1422. tld_warehouse_transfer a
  1423. JOIN tld_material b ON a.material_id = b.tld_id
  1424. where (a.out_num + 0) <![CDATA[<]]> (
  1425. a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
  1426. </select>
  1427. <!-- 查询发货追溯任务数量 -->
  1428. <select id="getZhuiSu" resultType="int">
  1429. SELECT
  1430. count(*)
  1431. FROM
  1432. tld_trace_back
  1433. where (out_num + 0) <![CDATA[<]]> (
  1434. num + 0) and material_code in (select material_id from tld_user_material where user_id = #{userId})
  1435. </select>
  1436. <!-- 查询半成品出 -->
  1437. <select id="getBanChenPinChu" resultType="int">
  1438. SELECT
  1439. count(*)
  1440. FROM
  1441. tld_ask_goods a
  1442. JOIN tld_material b on a.material_id = b.tld_id
  1443. WHERE
  1444. ((a.num + 0) <![CDATA[>]]> (IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
  1445. and b.code in (select material_id from tld_user_material where user_id = #{userId})
  1446. and b.part_type = '半成品'
  1447. </select>
  1448. <select id="storageLocationNum" resultType="java.util.Map">
  1449. SELECT
  1450. a.id,
  1451. YEAR(CURDATE()) AS year,
  1452. MONTH(CURDATE()) AS month,
  1453. f.code as warehouseCode,
  1454. f.name as warehouseName,
  1455. b.storage_location_name as storageLocationName,
  1456. c.code as code,
  1457. c.name as name,
  1458. m.name as unitOfMeasurement,
  1459. a.amount AS sum,
  1460. a.wbs as wbs,
  1461. c.max_num as maxNum,
  1462. DATEDIFF(now(), scrq) as day,
  1463. c.part_type as partType,
  1464. c.wllb_class as wllbClass,
  1465. p.code as companyCode,
  1466. p.name as companyName,
  1467. a.account_sleeve as accountSleeve,
  1468. a.supplier_id as supplierId,
  1469. e.name as supplierName,
  1470. ifnull(a.storage_location_code, "1") as storageLocationCode
  1471. FROM
  1472. tld_inventory a
  1473. LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1474. LEFT JOIN tld_material c ON a.material_id = c.tld_id
  1475. LEFT JOIN tld_customer e ON a.supplier_id = e.code
  1476. LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
  1477. LEFT JOIN tld_company p on a.account_sleeve = p.code
  1478. LEFT JOIN tld_measurement m on c.unit_of_measurement = m.tld_id
  1479. <trim prefix="WHERE" prefixOverrides="and |or">
  1480. <if test="storageLocationCode != null and storageLocationCode != ''">
  1481. and a.storage_location_code = #{storageLocationCode}
  1482. </if>
  1483. <if test="materialId != null and materialId != ''">
  1484. and a.material_id = #{materialId}
  1485. </if>
  1486. <if test="wllbCode != null and wllbCode != ''">
  1487. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  1488. </if>
  1489. <if test="materialName != null and materialName != ''">
  1490. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  1491. </if>
  1492. <if test="storageLocationName != null and storageLocationName != ''">
  1493. and b.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  1494. </if>
  1495. <if test="companyName != null and companyName != ''">
  1496. and p.name like CONCAT(CONCAT('%', #{companyName}), '%')
  1497. </if>
  1498. <if test="companyCode != null and companyCode != ''">
  1499. and p.code = #{companyCode}
  1500. </if>
  1501. <if test="supplierId != null and supplierId != ''">
  1502. and a.supplier_id like CONCAT(CONCAT('%', #{supplierId}), '%')
  1503. </if>
  1504. <if test="wbs != null and wbs != ''">
  1505. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  1506. </if>
  1507. <if test="warehouseId != null and warehouseId != ''">
  1508. and f.tld_id = #{warehouseId}
  1509. </if>
  1510. <if test="partType != null and partType != ''">
  1511. and c.part_type = #{partType}
  1512. </if>
  1513. <if test="wllbClass != null and wllbClass != ''">
  1514. and c.wllb_class = #{wllbClass}
  1515. </if>
  1516. <if test="unitOfMeasurement != null and unitOfMeasurement != ''">
  1517. and c.unit_of_measurement = #{unitOfMeasurement}
  1518. </if>
  1519. and (a.amount + 0) <![CDATA[>]]> (#{amount} + 0)
  1520. </trim>
  1521. </select>
  1522. <select id="getTestTwo" resultType="java.util.Map">
  1523. select DISTINCT ask_goods_id from tld_ask_goods_vitrual where unique_code = "1111" and type = "计划出库"
  1524. </select>
  1525. <!--查询领料日期计划出库-->
  1526. <select id="getPlannedDelivery" resultType="java.lang.String">
  1527. select
  1528. b.sqrq
  1529. from tld_ask_goods a
  1530. join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
  1531. join tld_material e on a.material_id = e.tld_id
  1532. where e.code in ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
  1533. and ((a.num + 0) <![CDATA[>]]> (
  1534. IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and e.part_type != '半成品' and e.part_type != '产成品'
  1535. group by b.sqrq
  1536. order by b.sqrq desc
  1537. </select>
  1538. <!--查询领料日期邀请出库-->
  1539. <select id="getInviteDelivery" resultType="java.lang.String">
  1540. select
  1541. b.sqrq
  1542. from tld_invite a
  1543. join tld_invite_f b on a.ask_goods_id = b.ask_goods_id
  1544. join tld_material e on a.material_id = e.tld_id
  1545. where e.code in ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
  1546. and ((a.num + 0) <![CDATA[>]]> (
  1547. IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
  1548. and e.part_type != '半成品' and e.part_type != '产成品'
  1549. group by b.sqrq
  1550. order by b.sqrq desc
  1551. </select>
  1552. <!--查询部门-->
  1553. <select id="getPlannedDepartment" resultType="java.util.Map">
  1554. select
  1555. c.name,
  1556. c.code
  1557. from tld_ask_goods a
  1558. join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
  1559. join tld_department c on b.department = c.code and b.company_number = c.account_sleeve
  1560. join tld_material e on a.material_id = e.tld_id
  1561. where e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
  1562. and ((a.num + 0) <![CDATA[>]]> (
  1563. IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and e.part_type != '半成品' and e.part_type != '产成品'
  1564. and b.sqrq = #{sqrq}
  1565. group by c.name,c.code
  1566. </select>
  1567. <!--查询部门-->
  1568. <select id="getInviteDepartment" resultType="java.util.Map">
  1569. select
  1570. c.name,
  1571. c.code
  1572. from tld_invite a
  1573. join tld_invite_f b on a.ask_goods_id = b.ask_goods_id
  1574. join tld_department c on b.department = c.code and b.company_number = c.account_sleeve
  1575. join tld_material e on a.material_id = e.tld_id
  1576. where e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
  1577. and ((a.num + 0) <![CDATA[>]]> (
  1578. IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
  1579. and e.part_type != '半成品' and e.part_type != '产成品'
  1580. and b.sqrq = #{sqrq}
  1581. group by c.name,c.code
  1582. </select>
  1583. <!-- 查询指定参数的要货单 -->
  1584. <select id="getAskGoodsInfo" resultType="com.tld.model.AskGoods">
  1585. SELECT DISTINCT b.ask_goods_id as id,b.ask_goods_code as code
  1586. FROM tld_ask_goods a
  1587. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  1588. JOIN tld_material e ON a.material_id = e.tld_id
  1589. WHERE
  1590. b.sqrq = #{sqrq} AND b.department = #{department}
  1591. AND e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
  1592. AND e.part_type != '半成品' AND e.part_type != '产成品' AND ((a.num + 0) <![CDATA[>]]> (
  1593. IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
  1594. </select>
  1595. <!-- 查询指定参数的要货单 -->
  1596. <select id="getInviteInfo" resultType="com.tld.model.AskGoods">
  1597. SELECT DISTINCT b.ask_goods_id as id,b.ask_goods_code as code
  1598. FROM tld_invite a
  1599. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  1600. JOIN tld_material e ON a.material_id = e.tld_id
  1601. WHERE
  1602. b.sqrq = #{sqrq} AND b.department = #{department}
  1603. AND e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
  1604. AND e.part_type != '半成品' AND e.part_type != '产成品' AND ((a.num + 0) <![CDATA[>]]> (
  1605. IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
  1606. </select>
  1607. <!--查询错误日志添加到Excel表-->
  1608. <select id="getErrorList" resultType="com.tld.model.Error">
  1609. select
  1610. id,
  1611. url,
  1612. error_info,
  1613. data_val,
  1614. scrq,
  1615. type,
  1616. transmission_type
  1617. from tld_error where type = '出库回传' and transmission_type = '1' and error_info = '异常:“是否允许负库存”附近有语法错误。'
  1618. </select>
  1619. <!--207生产领料-->
  1620. <select id="getOrderNumber" resultType="java.lang.String">
  1621. select ask_goods_code from tld_ask_goods_f where ask_goods_id = #{giReqBillID}
  1622. </select>
  1623. <!--Z05非生产领料-->
  1624. <select id="getOrderNumberNot" resultType="java.lang.String">
  1625. select ask_goods_code from tld_invite_f where ask_goods_id = #{giReqBillID}
  1626. </select>
  1627. <!--查询物料code-->
  1628. <select id="getMaterialCode" resultType="java.lang.String">
  1629. select code from tld_material where tld_id = #{material}
  1630. </select>
  1631. </mapper>