WarehousingMapper.xml 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  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.WarehousingMapper">
  5. <sql id="field">
  6. order_code
  7. ,material_id,purchase_num,arrival_num,type,qualified_num,disqualification_num,wbs,arrival_time,measurement_id,supplier_id,entry_number,warehousing_num
  8. </sql>
  9. <!-- 查询物料库位 -->
  10. <select id="getMaterialClass" resultType="com.tld.model.MaterialClass">
  11. select a.id,
  12. a.storage_location_code,
  13. a.wllb_code
  14. from tld_material_class a
  15. join tld_material b on a.wllb_code = b.code
  16. where b.code = #{wllbCode}
  17. </select>
  18. <!-- 根据物料分类查询库位 -->
  19. <select id="getMaterialClassType" resultType="com.tld.model.MaterialClass">
  20. select b.id,
  21. b.storage_location_code
  22. from tld_material a
  23. join tld_storage_location b on b.storage_location_type like CONCAT('%', a.wllb_class, '%')
  24. where a.code = #{wllbCode}
  25. </select>
  26. <!-- 新增库位信息虚拟表 -->
  27. <insert id="addWarehousingVirtual">
  28. insert into tld_warehousing_virtual(unique_code, num, storage_location_code, wllb_code, supp_id, serial, type,
  29. produc_date, capacity, seq, user_id, storage_location_name, attribute,
  30. notice_id, warehouse_transfer_id, storage_location_code_ck,wbs, receive_goods_id, account_sleeve, entry_number)
  31. values (#{uniqueCode}, #{num}, #{storageLocationCode}, #{wllbCode}, #{suppId}, #{serial}, #{type},
  32. #{producDate}, #{capacity}, #{seq}, #{userId}, #{storageLocationName}, #{attribute}, #{noticeId},
  33. #{warehouseTransferId}, #{storageLocationCodeCk},#{wbs},#{receiveGoodsId},#{accountSleeve}, #{entryNumber})
  34. </insert>
  35. <!-- 查询总数量 -->
  36. <select id="getScanNum" resultType="java.util.Map">
  37. SELECT (ifnull(sum(a.num), 0) + ${num} + ifnull(sum(c.amount), 0)) as scanNum,
  38. ifnull(b.storage_location_capacity, 0) as storageLocationCapacity
  39. FROM tld_warehousing_virtual a
  40. right join tld_storage_location b on a.storage_location_code = b.storage_location_code
  41. left join tld_inventory c on b.storage_location_code = c.storage_location_code
  42. where b.storage_location_code = #{storageLocationCode}
  43. </select>
  44. <!-- 查询 -->
  45. <select id="recommend" resultType="com.tld.model.StorageLocation">
  46. SELECT id,
  47. storage_location_code,
  48. storage_location_name,
  49. warehouse_where,
  50. storage_location_type,
  51. storage_location_capacity,
  52. is_not_disable,
  53. create_time
  54. FROM tld_storage_location
  55. WHERE #{storageLocationCode} like CONCAT('%', CONCAT(storage_location_code, ','), '%')
  56. and warehouse_where != '5000'
  57. </select>
  58. <!-- 查询 -->
  59. <select id="getRecommendTwo" resultType="com.tld.model.StorageLocation">
  60. SELECT a.id,
  61. a.storage_location_code,
  62. a.storage_location_name,
  63. a.warehouse_where,
  64. a.storage_location_type,
  65. a.storage_location_capacity,
  66. a.is_not_disable,
  67. a.create_time
  68. FROM tld_storage_location a
  69. JOIN tld_warehouse b ON a.warehouse_where = b.tld_id
  70. where b.warehouse_type = #{type}
  71. </select>
  72. <!-- 查询是否是混合物料 -->
  73. <select id="getIsNotSisable" resultType="String">
  74. select
  75. ifnull(is_not_disable,'') as isNotDisable
  76. from tld_material
  77. where code = #{wllbCode}
  78. </select>
  79. <!-- 查询混合库位 -->
  80. <select id="getIsNotSisableLocation" resultType="com.tld.model.StorageLocation">
  81. select id,
  82. storage_location_code,
  83. storage_location_name,
  84. warehouse_where,
  85. storage_location_type,
  86. storage_location_capacity,
  87. is_not_disable,
  88. create_time
  89. from tld_storage_location
  90. where is_not_disable = #{isNotDisable}
  91. </select>
  92. <!-- 删除虚拟表 -->
  93. <delete id="delWarehousingVirtual">
  94. delete
  95. from tld_warehousing_virtual
  96. where id = #{id}
  97. </delete>
  98. <!-- 查询虚拟表数据进行入库 -->
  99. <select id="getVirtual" resultType="com.tld.model.WarehousingVirtual">
  100. select
  101. a.id,
  102. a.unique_code,
  103. a.num,
  104. a.storage_location_code,
  105. a.wllb_code,
  106. a.supp_id,
  107. a.serial,
  108. a.type,
  109. a.produc_date,
  110. a.capacity,
  111. a.seq,
  112. a.user_id,
  113. a.attribute,
  114. a.warehouse_transfer_id,
  115. a.storage_location_code_ck,
  116. a.storage_location_name,
  117. b.user_name,
  118. a.receive_goods_id,
  119. a.wbs,
  120. a.account_sleeve,
  121. a.warehouse_transfer_id,
  122. a.entry_number
  123. from tld_warehousing_virtual a
  124. left join tld_user b on a.user_id = b.id
  125. where a.unique_code = #{uniqueCode} and a.type = #{type}
  126. <if test="warehouseTransferId != null and warehouseTransferId != ''">
  127. and a.warehouse_transfer_id = #{warehouseTransferId}
  128. </if>
  129. </select>
  130. <!-- 查询采购单信息 -->
  131. <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
  132. SELECT a.id,
  133. a.order_code,
  134. a.material_id,+
  135. a.purchase_num,
  136. a.arrival_num,
  137. a.type,
  138. a.qualified_num,
  139. a.disqualification_num,
  140. a.wbs,
  141. a.arrival_time,
  142. a.measurement_id,
  143. a.supplier_id,
  144. a.entry_number,
  145. a.warehousing_num,
  146. b.company_number,
  147. b.order_number,
  148. b.source_type,
  149. b.move_type,
  150. f.name as supplierName
  151. FROM tld_receive_goods a
  152. LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
  153. JOIN tld_material c on a.material_id = c.tld_id
  154. LEFT JOIN tld_customer f on a.supplier_id = f.code
  155. WHERE a.supplier_id = #{suppId}
  156. and IFNULL(a.warehousing_num, 0) <![CDATA[<]]> a.qualified_num
  157. and c.code = #{wllbCode}
  158. ORDER BY a.arrival_time DESC
  159. </select>
  160. <!-- 修改采购单入库数量 -->
  161. <update id="updateReceiveGood">
  162. update tld_receive_goods
  163. set warehousing_num = warehousing_num + #{warehousingNum}
  164. where id = #{id}
  165. </update>
  166. <!-- 查询物料类型 -->
  167. <select id="getWlClass" resultType="com.tld.model.WarehousingVirtual">
  168. select wllb_class, tld_id as materialId
  169. from tld_material
  170. where code = #{wllbCode}
  171. </select>
  172. <!-- 插入入库流水 -->
  173. <insert id="addStorage">
  174. insert into
  175. tld_storage(wllb_code,supplier_id,serial,produc_date,produc_batch,capacity,seq,type,user_id,department_id,storage_location_code,scrq,storage_code,wbs,order_code,account_sleeve,purchase_num,transmission_type)
  176. values
  177. <foreach collection="list" index="index" item="item" separator=",">
  178. (#{item.wllbCode},#{item.suppId},#{item.serial},#{item.producDate},#{item.producDate},#{item.num},#{item.seq},#{item.type},#{item.userId},#{item.departmentId},#{item.storageLocationCode},now(),#{item.storageCode},#{item.wbs},#{item.warehouseTransferId},#{item.accountSleeve},#{item.purchaseNum},0)
  179. </foreach>
  180. </insert>
  181. <!-- 插入库存 -->
  182. <insert id="addInventory">
  183. insert into
  184. tld_inventory(storage_location_code,wllb_class,material_id,amount,totime,hold,amount_lock,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date,scrq,produc_batch,attribute)
  185. values
  186. <foreach collection="list" index="index" item="item" separator=",">
  187. (#{item.storageLocationCode},#{item.wllbClass},#{item.materialId},#{item.num},now(),'0','0',#{item.accountSleeve},#{item.wbs},#{item.suppId},#{item.serial},#{item.wllbCode},#{item.producDate},
  188. now(),(curdate() + 0),#{item.attribute})
  189. </foreach>
  190. </insert>
  191. <!-- 删除临时表数据 -->
  192. <delete id="delVirtual">
  193. delete
  194. from tld_warehousing_virtual
  195. where unique_code = #{uniqueCode}
  196. </delete>
  197. <!-- 查询当天质检数量 -->
  198. <select id="getWarehousingCount" resultType="int">
  199. select count(*)
  200. from tld_return_gs_warehousing
  201. where scrq BETWEEN CONCAT(CURDATE(), ' 00:00:00') AND CONCAT(CURDATE(), ' 23:59:59');
  202. </select>
  203. <!-- 存入为gs穿的信息 -->
  204. <insert id="addReturnWarehousing">
  205. insert into tld_return_gs_warehousing(storage_code, gs_ck, source_type, move_type, entry_number, wbs,
  206. material_id, warehousing_num, receive_goods_id, scrq, order_number,
  207. user_name, storage_location_code)
  208. values (#{storageCode}, #{gsCk}, #{sourceType}, #{moveType}, #{entryNumber}, #{wbs}, #{materialId},
  209. #{warehousingNum}, #{id}, now(), #{orderNumber}, #{userName}, #{storageLocationCode});
  210. </insert>
  211. <!-- 入库回传 -->
  212. <select id="getPlugOutWarehousing" resultType="com.tld.model.ReturnWarehousing">
  213. select a.*,
  214. ifnull(a.wbs, '') as wbsId,
  215. ifnull(b.code, '') as wbsCode,
  216. ifnull(b.name, '') as wbsName
  217. from tld_return_gs_warehousing a
  218. left join tld_wbs b on a.wbs = b.tld_id
  219. where #{orderNumber} LIKE CONCAT('%', CONCAT(order_number, ','), '%')
  220. </select>
  221. <!-- 查询入库流水 -->
  222. <select id="warehousingFlowing" resultType="com.tld.model.Storage">
  223. select
  224. a.id,
  225. b.name as materialName,
  226. a.wllb_code,
  227. h.name as supplierName,
  228. a.serial,
  229. a.produc_date,
  230. a.produc_batch,
  231. a.capacity,
  232. a.seq,
  233. a.type,
  234. c.user_name as userName,
  235. e.name as departmentName,
  236. g.storage_location_name as storageLocationName,
  237. a.scrq,
  238. a.storage_code,
  239. a.wbs,
  240. c.real_name as realName,
  241. a.order_code as orderCode,
  242. a.account_sleeve,
  243. f.name as accountName,
  244. a.purchase_num,
  245. a.transmission_type,
  246. v.name as wbsName
  247. from tld_storage a
  248. left join tld_material b on a.wllb_code = b.code
  249. left join tld_user c on a.user_id = c.id
  250. left join tld_department e on a.department_id = e.code
  251. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  252. left join tld_customer h on a.supplier_id = h.code
  253. left join tld_company f on a.account_sleeve = f.code
  254. left join tld_wbs v on a.wbs = v.tld_id
  255. <trim prefix="WHERE" prefixOverrides="and |or">
  256. <if test="storageCode != null and storageCode != ''">
  257. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  258. </if>
  259. <if test="wllbCode != null and wllbCode != ''">
  260. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  261. </if>
  262. <if test="materialName != null and materialName != ''">
  263. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  264. </if>
  265. <if test="userName != null and userName != ''">
  266. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  267. </if>
  268. <if test="realName != null and realName != ''">
  269. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  270. </if>
  271. <if test="storageLocationName != null and storageLocationName != ''">
  272. and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  273. </if>
  274. <if test="wbs != null and wbs != ''">
  275. and v.name like CONCAT(CONCAT('%', #{wbs}), '%')
  276. </if>
  277. <if test="orderCode != null and orderCode != ''">
  278. and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
  279. </if>
  280. <if test="supplierId != null and supplierId != ''">
  281. and a.supplier_id = #{supplierId}
  282. </if>
  283. <if test="startTime != null and startTime != ''">
  284. and a.scrq <![CDATA[>=]]> #{startTime}
  285. </if>
  286. <if test="endTime != null and endTime != ''">
  287. and a.scrq <![CDATA[<=]]> #{endTime}
  288. </if>
  289. <if test="accountSleeve != null and accountSleeve != ''">
  290. and a.account_sleeve = #{accountSleeve}
  291. </if>
  292. </trim>
  293. order by a.scrq desc
  294. </select>
  295. <!-- 查询虚拟入库 -->
  296. <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
  297. select id,
  298. unique_code,
  299. num,
  300. storage_location_code,
  301. wllb_code,
  302. supp_id,
  303. serial,
  304. type,
  305. produc_date,
  306. capacity,
  307. seq,
  308. user_id,
  309. storage_location_name,
  310. warehouse_transfer_id,
  311. wbs,
  312. receive_goods_id,
  313. notice_id,
  314. account_sleeve
  315. from tld_warehousing_virtual
  316. where unique_code = #{uniqueCode}
  317. and type = #{type} and warehouse_transfer_id = #{warehouseTransferId}
  318. order by id desc
  319. </select>
  320. <!-- 查询导出内容 -->
  321. <select id="export" resultType="java.util.LinkedHashMap">
  322. select
  323. b.name as materialName,
  324. a.wllb_code as wllbCode,
  325. h.name as supplierName,
  326. if(a.serial = '', null ,a.serial) as serial,
  327. a.capacity,
  328. a.type,
  329. c.user_name as userName,
  330. e.name as departmentName,
  331. g.storage_location_name as storageLocationName,
  332. a.scrq,
  333. a.storage_code,
  334. if(a.wbs = '', null, a.wbs) as wbs,
  335. if(e.name = '', null, e.name) as wbsName,
  336. c.real_name as realName,
  337. a.order_code as orderCode,
  338. f.name as accountName,
  339. a.account_sleeve as accountSleeve,
  340. if(a.purchase_num = '', null, a.purchase_num) as purchaseNum
  341. from tld_storage a
  342. left join tld_material b on a.wllb_code = b.code
  343. left join tld_user c on a.user_id = c.id
  344. left JOIN tld_wbs e ON a.wbs = e.tld_id
  345. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  346. left join tld_customer h on a.supplier_id = h.code
  347. left join tld_company f on a.account_sleeve = f.code
  348. <trim prefix="WHERE" prefixOverrides="and |or">
  349. <if test="storageCode != null and storageCode != ''">
  350. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  351. </if>
  352. <if test="wllbCode != null and wllbCode != ''">
  353. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  354. </if>
  355. <if test="materialName != null and materialName != ''">
  356. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  357. </if>
  358. <if test="userName != null and userName != ''">
  359. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  360. </if>
  361. <if test="realName != null and realName != ''">
  362. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  363. </if>
  364. <if test="storageLocationName != null and storageLocationName != ''">
  365. and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  366. </if>
  367. <if test="wbs != null and wbs != ''">
  368. and e.name like CONCAT(CONCAT('%', #{wbs}), '%')
  369. </if>
  370. <if test="orderCode != null and orderCode != ''">
  371. and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
  372. </if>
  373. <if test="supplierId != null and supplierId != ''">
  374. and a.supplier_id = #{supplierId}
  375. </if>
  376. <if test="startTime != null and startTime != ''">
  377. and a.scrq <![CDATA[>=]]> #{startTime}
  378. </if>
  379. <if test="endTime != null and endTime != ''">
  380. and a.scrq <![CDATA[<=]]> #{endTime}
  381. </if>
  382. <if test="accountSleeve != null and accountSleeve != ''">
  383. and a.account_sleeve = #{accountSleeve}
  384. </if>
  385. </trim>
  386. order by a.scrq desc
  387. </select>
  388. <!-- 查询是否扫描 -->
  389. <select id="getScanIsNot" resultType="java.util.Map">
  390. select
  391. (select count(*)
  392. from tld_inventory a
  393. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  394. where a.supplier_id = #{suppId} and a.serial = #{unique} and a.wllb_code = #{wllbCode} and a.produc_date =
  395. #{producDate}
  396. <if test="warehouseWhere != null and warehouseWhere != ''">
  397. and b.warehouse_where = #{warehouseWhere}
  398. </if>) as inventoryCount,
  399. (select count(*) from tld_warehousing_virtual where supp_id = #{suppId} and serial = #{unique} and wllb_code =
  400. #{wllbCode} and produc_date = #{producDate}) as virtualCount
  401. from dual
  402. </select>
  403. <!-- 查询物料是否存在 -->
  404. <select id="getMateriaIsExist" resultType="com.tld.model.MaterialClass">
  405. select id,
  406. code,
  407. name,
  408. tld_id,
  409. specification_and_model,
  410. unit_of_measurement,
  411. ifnull(size, 0) as size,
  412. wllb_class,
  413. is_not_disable,
  414. is_recommend,
  415. part_type
  416. from tld_material
  417. where code = #{wllbCode}
  418. </select>
  419. <!-- 查询库存是否同物料同批次存在 -->
  420. <select id="getInventoryProduc" resultType="java.util.Map">
  421. SELECT produc_batch as producDate,wbs as wbs,account_sleeve as accountSleeve,wllb_code as wllbCode
  422. FROM tld_inventory a
  423. JOIN tld_material b ON a.material_id = b.tld_id
  424. WHERE a.storage_location_code = #{storageLocationCode}
  425. and hold = '0'
  426. </select>
  427. <!-- 查询报工单 -->
  428. <select id="getNotice" resultType="com.tld.model.Notice">
  429. select
  430. a.id,
  431. a.notice_id,
  432. a.entry_number,
  433. a.production_code,
  434. a.material_id,
  435. a.wbs,
  436. f.name as wbsCode,
  437. a.measurement_id,
  438. a.num,
  439. a.type,
  440. a.warehousing_num,
  441. b.company_number,
  442. c.name as materialName,
  443. c.wllb_class as wllbClass,
  444. c.code as wllbCode,
  445. e.name as companyName,
  446. b.notice_time as noticeTime,
  447. b.source_type as sourceType,
  448. b.move_type as moveType,
  449. b.notice_code as noticeCode,
  450. f.name as wbsName
  451. from tld_notice a
  452. join tld_notice_f b on a.notice_id = b.notice_id
  453. join tld_material c on a.material_id = c.tld_id
  454. join tld_company e on b.company_number = e.code
  455. left join tld_wbs f on a.wbs = f.tld_id
  456. <trim prefix="WHERE" prefixOverrides="and |or">
  457. <if test="userId != null and userId != ''">
  458. and c.code in (select material_id from tld_user_material where user_id = #{userId})
  459. </if>
  460. <if test="type != null and type != ''">
  461. and a.type = #{type}
  462. </if>
  463. <if test="noticeId != null and noticeId != ''">
  464. and a.notice_id like CONCAT(CONCAT('%', #{noticeId}), '%')
  465. </if>
  466. <if test="entryNumber != null and entryNumber != ''">
  467. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  468. </if>
  469. <if test="wllbCode != null and wllbCode != ''">
  470. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  471. </if>
  472. <if test="materialName != null and materialName != ''">
  473. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  474. </if>
  475. <if test="startTime != null and startTime != ''">
  476. and b.notice_time <![CDATA[>=]]> #{startTime}
  477. </if>
  478. <if test="endTime != null and endTime != ''">
  479. and b.notice_time <![CDATA[<=]]> #{endTime}
  480. </if>
  481. <if test="partType != null and partType == '产成品'.toString()">
  482. and c.part_type = #{partType}
  483. </if>
  484. <if test="partType != null and partType == '半成品'.toString()">
  485. and (c.part_type ='半成品' or c.part_type ='原材料')
  486. </if>
  487. <if test="companyNumber != null and companyNumber != ''">
  488. and b.company_number = #{companyNumber}
  489. </if>
  490. <if test="productionCode != null and productionCode != ''">
  491. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  492. </if>
  493. <if test="wbs != null and wbs != ''">
  494. and f.name like CONCAT(CONCAT('%', #{wbs}), '%')
  495. </if>
  496. <if test="moveType != null and moveType != ''">
  497. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  498. </if>
  499. <if test="sourceType != null and sourceType != ''">
  500. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  501. </if>
  502. <if test="noticeCode != null and noticeCode != ''">
  503. and b.notice_code like CONCAT(CONCAT('%', #{noticeCode}), '%')
  504. </if>
  505. </trim>
  506. order by a.id desc
  507. </select>
  508. <!-- 导出报工单 -->
  509. <select id="exportNotice" resultType="java.util.LinkedHashMap">
  510. select
  511. a.production_code,
  512. b.notice_code as noticeCode,
  513. c.code as wllbCode,
  514. c.name as materialName,
  515. a.num,
  516. a.warehousing_num,
  517. b.notice_time as noticeTime,
  518. a.entry_number,
  519. e.name as companyName,
  520. b.company_number,
  521. if(a.wbs = "", null, a.wbs) as wbs,
  522. if(h.name = "", null, h.name) as wbsName,
  523. b.source_type as sourceType,
  524. b.move_type as moveType,
  525. (case a.type when "0" then "未入库" when "1" then "已入库" end) as type
  526. from tld_notice a
  527. join tld_notice_f b on a.notice_id = b.notice_id
  528. join tld_material c on a.material_id = c.tld_id
  529. join tld_company e on b.company_number = e.code
  530. left join tld_wbs h on a.wbs = h.tld_id
  531. <trim prefix="WHERE" prefixOverrides="and |or">
  532. <if test="type != null and type != ''">
  533. and a.type = #{type}
  534. </if>
  535. <if test="noticeId != null and noticeId != ''">
  536. and a.notice_id like CONCAT(CONCAT('%', #{noticeId}), '%')
  537. </if>
  538. <if test="entryNumber != null and entryNumber != ''">
  539. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  540. </if>
  541. <if test="wllbCode != null and wllbCode != ''">
  542. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  543. </if>
  544. <if test="materialName != null and materialName != ''">
  545. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  546. </if>
  547. <if test="startTime != null and startTime != ''">
  548. and b.notice_time <![CDATA[>=]]> #{startTime}
  549. </if>
  550. <if test="endTime != null and endTime != ''">
  551. and b.notice_time <![CDATA[<=]]> #{endTime}
  552. </if>
  553. <if test="partType != null and partType == '产成品'.toString()">
  554. and c.part_type = #{partType}
  555. </if>
  556. <if test="partType != null and partType == '半成品'.toString()">
  557. and (c.part_type ='半成品' or c.part_type ='原材料')
  558. </if>
  559. <if test="companyNumber != null and companyNumber != ''">
  560. and b.company_number = #{companyNumber}
  561. </if>
  562. <if test="productionCode != null and productionCode != ''">
  563. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  564. </if>
  565. <if test="wbs != null and wbs != ''">
  566. and g.wbsName like CONCAT(CONCAT('%', #{wbs}), '%')
  567. </if>
  568. <if test="moveType != null and moveType != ''">
  569. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  570. </if>
  571. <if test="sourceType != null and sourceType != ''">
  572. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  573. </if>
  574. <if test="noticeCode != null and noticeCode != ''">
  575. and b.notice_code like CONCAT(CONCAT('%', #{noticeCode}), '%')
  576. </if>
  577. </trim>
  578. order by a.id desc
  579. </select>
  580. <!-- 查询通知单是否入库 -->
  581. <select id="getNoticeId" resultType="com.tld.model.Notice">
  582. select a.id,
  583. a.notice_id,
  584. a.entry_number,
  585. a.production_code,
  586. a.material_id,
  587. a.wbs,
  588. a.measurement_id,
  589. a.num,
  590. a.type,
  591. a.warehousing_num,
  592. b.wllb_class,
  593. c.source_type,
  594. c.move_type,
  595. b.code as materialCode,
  596. c.notice_time as noticeTime,
  597. c.company_number
  598. from tld_notice a
  599. join tld_notice_f c on a.notice_id = c.notice_id
  600. left join tld_material b on a.material_id = b.tld_id
  601. where a.notice_id = #{noticeId} and a.material_id = #{materialId} and a.entry_number = #{entryNumber}
  602. </select>
  603. <!-- 半成品跟部分产成品入库存 -->
  604. <insert id="addInventoryNotice">
  605. insert into tld_inventory(storage_location_code, material_id, amount, hold, amount_lock, account_sleeve, wbs,
  606. produc_date, scrq, wllb_class, produc_batch, attribute, serial, supplier_id,
  607. wllb_code, totime)
  608. value (#{storageLocationCode},#{materialId},#{warehousingNum},'0','0',#{companyNumber},#{wbs},#{producBatch},now(),#{wllbClass},#{producBatch},#{attribute},#{serial},#{supplierId},#{wllbCode},now());
  609. </insert>
  610. <!-- 查询库存里是否存在半成品虚拟库位 -->
  611. <select id="getInventoryNotice" resultType="int">
  612. select count(*)
  613. from tld_inventory
  614. where storage_location_code = #{storageLocationCode}
  615. and material_id = #{materialId}
  616. and account_sleeve = #{companyNumber}
  617. and wbs = #{wbs}
  618. </select>
  619. <!-- 增加半成品/产成品虚拟库位数量 -->
  620. <update id="updateInventoryNotice">
  621. update tld_inventory
  622. set amount = amount + #{warehousingNum},
  623. totime = now()
  624. where storage_location_code = #{storageLocationCode}
  625. and material_id = #{materialId}
  626. and account_sleeve = #{companyNumber}
  627. and wbs = #{wbs};
  628. </update>
  629. <!-- 半成品出库库存查询 -->
  630. <select id="getHalfInventory" resultType="com.tld.model.Inventory">
  631. select storage_location_code, wllb_class, material_id, amount
  632. from tld_inventory
  633. where storage_location_code = #{storageLocationCode}
  634. and material_id = #{materialId}
  635. and account_sleeve = #{companyNumber}
  636. and wbs = #{wbs}
  637. and hold = '0'
  638. order by produc_batch
  639. </select>
  640. <!-- 删除库存信息 -->
  641. <delete id="delInventoryNotice">
  642. delete
  643. from tld_inventory
  644. where storage_location_code = #{storageLocationCode}
  645. and material_id = #{materialId} and wbs = #{wbs} and account_sleeve = #{companyNumber}
  646. </delete>
  647. <!--删除其它入库信息-->
  648. <delete id="delOtherReceivingGoods">
  649. delete from tld_notices where id = #{id}
  650. </delete>
  651. <!--删除其它出库信息-->
  652. <delete id="delOtherShipments">
  653. delete from tld_enquiry where id = #{id}
  654. </delete>
  655. <!-- 删减库存 -->
  656. <update id="updateInventoryNoticeNum">
  657. update tld_inventory
  658. set amount = amount - #{warehousingNum}
  659. where storage_location_code = #{storageLocationCode}
  660. and material_id = #{materialId} and wbs = #{wbs} and account_sleeve = #{companyNumber}
  661. </update>
  662. <!-- 新增半成品入库流水 -->
  663. <insert id="addProduct">
  664. insert into tld_half_product(wllb_code, produc_date, produc_batch, capacity, user_id, storage_location_code,
  665. scrq, storage_code, wbs, production_code,account_sleeve,transmission_type)
  666. value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{storageCode},#{wbs}, #{productionCode},#{accountSleeve},0)
  667. </insert>
  668. <!-- 查询半成品入库流水-->
  669. <select id="getProduct" resultType="com.tld.model.Notice">
  670. select
  671. a.id,
  672. a.wllb_code,
  673. a.produc_date,
  674. a.produc_batch,
  675. a.capacity as warehousingNum,
  676. a.user_id,
  677. c.user_name,
  678. a.storage_location_code,
  679. a.scrq,
  680. b.name as materialName,
  681. b.code as materialCode,
  682. a.storage_code,
  683. a.wbs,
  684. h.name as wbsName,
  685. a.production_code,
  686. c.real_name as realName,
  687. a.production_code as productionCode,
  688. a.account_sleeve as companyNumber,
  689. e.name as accountName
  690. from tld_half_product a
  691. left join tld_material b on a.wllb_code = b.code
  692. left join tld_user c on a.user_id = c.id
  693. left join tld_company e on a.account_sleeve = e.code
  694. left join tld_wbs h on a.wbs = h.tld_id
  695. <trim prefix="WHERE" prefixOverrides="and |or">
  696. <if test="startTime != null and startTime != ''">
  697. and a.scrq <![CDATA[>=]]> #{startTime}
  698. </if>
  699. <if test="endTime != null and endTime != ''">
  700. and a.scrq <![CDATA[<=]]> #{endTime}
  701. </if>
  702. <if test="wllbCode != null and wllbCode != ''">
  703. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  704. </if>
  705. <if test="materialName != null and materialName != ''">
  706. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  707. </if>
  708. <if test="storageLocationCode != null and storageLocationCode != ''">
  709. and a.storage_location_code = #{storageLocationCode}
  710. </if>
  711. <if test="userName != null and userName != ''">
  712. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  713. </if>
  714. <if test="realName != null and realName != ''">
  715. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  716. </if>
  717. <if test="productionCode != null and productionCode != ''">
  718. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  719. </if>
  720. <if test="storageCode != null and storageCode != ''">
  721. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  722. </if>
  723. <if test="productionCode != null and productionCode != ''">
  724. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  725. </if>
  726. <if test="wbs != null and wbs != ''">
  727. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  728. </if>
  729. <if test="companyNumber != null and companyNumber != ''">
  730. and a.account_sleeve = #{companyNumber}
  731. </if>
  732. </trim>
  733. order by a.scrq desc
  734. </select>
  735. <!-- 查询半成品入库流水导出-->
  736. <select id="productExcel" resultType="java.util.LinkedHashMap">
  737. select
  738. b.name,
  739. a.wllb_code,
  740. a.produc_date,
  741. a.capacity,
  742. c.user_name,
  743. a.scrq,
  744. a.storage_code,
  745. if(a.wbs = '' , null ,a.wbs) wbs,
  746. if(h.name = '' , null ,h.name) as wbsName,
  747. c.real_name as realName,
  748. if(a.production_code = '' , null ,a.production_code) as productionCode,
  749. e.name as accountName,
  750. a.account_sleeve as accountSleeve
  751. from tld_half_product a
  752. left join tld_material b on a.wllb_code = b.code
  753. left join tld_user c on a.user_id = c.id
  754. left join tld_company e on a.account_sleeve = e.code
  755. left join tld_wbs h on a.wbs = h.tld_id
  756. <trim prefix="WHERE" prefixOverrides="and |or">
  757. <if test="startTime != null and startTime != ''">
  758. and a.scrq <![CDATA[>=]]> #{startTime}
  759. </if>
  760. <if test="endTime != null and endTime != ''">
  761. and a.scrq <![CDATA[<=]]> #{endTime}
  762. </if>
  763. <if test="wllbCode != null and wllbCode != ''">
  764. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  765. </if>
  766. <if test="materialName != null and materialName != ''">
  767. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  768. </if>
  769. <if test="storageLocationCode != null and storageLocationCode != ''">
  770. and a.storage_location_code = #{storageLocationCode}
  771. </if>
  772. <if test="userName != null and userName != ''">
  773. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  774. </if>
  775. <if test="realName != null and realName != ''">
  776. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  777. </if>
  778. <if test="productionCode != null and productionCode != ''">
  779. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  780. </if>
  781. <if test="storageCode != null and storageCode != ''">
  782. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  783. </if>
  784. <if test="wbs != null and wbs != ''">
  785. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  786. </if>
  787. <if test="companyNumber != null and companyNumber != ''">
  788. and a.account_sleeve = #{companyNumber}
  789. </if>
  790. </trim>
  791. order by a.scrq desc
  792. </select>
  793. <!-- 查询要料单信息 -->
  794. <select id="getAskGoodsHalf" resultType="com.tld.model.AskGoods">
  795. select a.id,
  796. a.ask_goods_id,
  797. a.material_id,
  798. a.wbs,
  799. a.measurement_id,
  800. a.num,
  801. a.out_num,
  802. a.entry_number,
  803. b.source_type,
  804. b.move_type,
  805. c.code as wllbCode,
  806. a.type,
  807. b.department,
  808. b.request_type_name
  809. from tld_ask_goods a
  810. join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
  811. left join tld_material c on a.material_id = c.tld_id
  812. where a.ask_goods_id = #{askGoodsId}
  813. and a.material_id = #{materialId} and a.entry_number = #{entryNumber}
  814. </select>
  815. <!-- 修改要货单出库数量 -->
  816. <update id="updateAskGoodsHalf">
  817. update tld_ask_goods
  818. set out_num = ifnull(out_num, 0) + #{warehousingNum}
  819. <if test="type != null and type != ''">
  820. ,type = '1'
  821. </if>
  822. where id = #{id}
  823. </update>
  824. <!-- 新增半成品流水 -->
  825. <insert id="addRemovalHalfProduct">
  826. insert into tld_removal_half_product(wllb_code, num, user_id, scrq, ask_goods_id, department, storage_code, wbs, account_sleeve)
  827. value (#{wllbCode},#{num},#{userId},now(),#{askGoodsId},#{department},#{storageCode},#{wbs},#{companyNumber})
  828. </insert>
  829. <!-- 查询指定物料内容 -->
  830. <select id="getMaterial" resultType="com.tld.model.MaterialClass">
  831. select
  832. code as wllbCode,
  833. name as wllbName,
  834. tld_id,
  835. specification_and_model,
  836. unit_of_measurement,
  837. size,
  838. wllb_class,
  839. is_not_disable,
  840. ifnull(is_recommend,'') as isRecommend,
  841. part_type
  842. from tld_material
  843. <trim prefix="WHERE" prefixOverrides="and |or">
  844. <if test="materialId != null and materialId != ''">
  845. and tld_id = #{materialId}
  846. </if>
  847. <if test="materialCode != null and materialCode != ''">
  848. and code = #{materialCode}
  849. </if>
  850. </trim>
  851. </select>
  852. <!-- 查询库存信息 -->
  853. <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
  854. select storage_location_code,
  855. wllb_class,
  856. library_type,
  857. material_id,
  858. amount,
  859. total,
  860. totime,
  861. hold,
  862. amount_lock,
  863. account_sleeve,
  864. wbs,
  865. supplier_id,
  866. serial,
  867. wllb_code,
  868. produc_date,
  869. scrq,
  870. produc_batch,
  871. attribute
  872. from tld_inventory
  873. where storage_location_code = #{storageLocationCode}
  874. </select>
  875. <!-- 产成品入库 -->
  876. <insert id="addHalf">
  877. insert into tld_half(wllb_code, produc_date, produc_batch, capacity, user_id, storage_location_code, scrq,
  878. serial, seq, attribute, storage_code, wbs, production_code,account_sleeve,transmission_type)
  879. value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{serial},#{seq},#{attribute},#{storageCode},#{wbs},#{productionCode},#{accountSleeve},0)
  880. </insert>
  881. <!-- 查询虚拟表数据进行入库 -->
  882. <select id="getVirtualNotice" resultType="com.tld.model.WarehousingVirtual">
  883. select a.id,
  884. a.unique_code,
  885. a.num,
  886. a.storage_location_code,
  887. a.wllb_code,
  888. a.supp_id,
  889. a.serial,
  890. a.type,
  891. a.produc_date,
  892. a.capacity,
  893. a.seq,
  894. a.user_id,
  895. a.attribute,
  896. a.storage_location_name,
  897. b.user_name,
  898. a.account_sleeve,
  899. a.entry_number
  900. from tld_warehousing_virtual a
  901. left join tld_user b on a.user_id = b.id
  902. where a.unique_code = #{uniqueCode}
  903. and a.type = #{type}
  904. and a.notice_id = #{noticeId}
  905. </select>
  906. <!-- 产成品入库流水 -->
  907. <select id="getHalf" resultType="com.tld.model.Notice">
  908. select
  909. a.id,
  910. a.wllb_code,
  911. a.produc_date,
  912. a.produc_batch,
  913. a.capacity,
  914. a.user_id,
  915. a.storage_location_code,
  916. e.storage_location_name as storageLocationName,
  917. a.scrq,
  918. a.serial,
  919. a.seq,
  920. a.attribute,
  921. b.name as materialName,
  922. c.user_name as userName,
  923. b.code as materialCode,
  924. a.storage_code,
  925. a.wbs,
  926. h.name as wbsName,
  927. c.real_name as realName,
  928. a.production_code as productionCode,
  929. a.account_sleeve as companyNumber,
  930. f.name as accountName
  931. from tld_half a
  932. left join tld_material b on a.wllb_code = b.code
  933. left join tld_user c on a.user_id = c.id
  934. left join tld_storage_location e on a.storage_location_code = e.storage_location_code
  935. left join tld_company f on a.account_sleeve = f.code
  936. left join tld_wbs h on a.wbs = h.tld_id
  937. <trim prefix="WHERE" prefixOverrides="and |or">
  938. <if test="startTime != null and startTime != ''">
  939. and a.scrq <![CDATA[>=]]> #{startTime}
  940. </if>
  941. <if test="endTime != null and endTime != ''">
  942. and a.scrq <![CDATA[<=]]> #{endTime}
  943. </if>
  944. <if test="materialName != null and materialName != ''">
  945. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  946. </if>
  947. <if test="wllbCode != null and wllbCode != ''">
  948. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  949. </if>
  950. <if test="userName != null and userName != ''">
  951. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  952. </if>
  953. <if test="realName != null and realName != ''">
  954. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  955. </if>
  956. <if test="attribute != null and attribute != ''">
  957. and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
  958. </if>
  959. <if test="storageCode != null and storageCode != ''">
  960. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  961. </if>
  962. <if test="wbs != null and wbs != ''">
  963. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  964. </if>
  965. <if test="storageLocationName != null and storageLocationName != ''">
  966. and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  967. </if>
  968. <if test="productionCode != null and productionCode != ''">
  969. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  970. </if>
  971. <if test="companyNumber != null and companyNumber != ''">
  972. and a.account_sleeve = #{companyNumber}
  973. </if>
  974. </trim>
  975. order by a.scrq desc
  976. </select>
  977. <!-- 产成品导出 -->
  978. <select id="getHalfExcel" resultType="java.util.LinkedHashMap">
  979. select
  980. b.name as materialName,
  981. a.wllb_code,
  982. if(a.produc_batch = '' , null , a.produc_batch) as producBatch,
  983. a.capacity,
  984. c.user_name as userName,
  985. a.storage_location_code,
  986. a.scrq,
  987. a.serial,
  988. if(a.attribute = '' , null , a.attribute) as attribute,
  989. a.storage_code,
  990. if(a.wbs = '' , null , a.wbs) as wbs,
  991. if(h.name = '' , null , h.name) as wbsName,
  992. c.real_name as realName,
  993. a.production_code as productionCode,
  994. f.name as accountName,
  995. a.account_sleeve as accountSleeve
  996. from tld_half a
  997. left join tld_material b on a.wllb_code = b.code
  998. left join tld_user c on a.user_id = c.id
  999. left join tld_company f on a.account_sleeve = f.code
  1000. left join tld_wbs h on a.wbs = h.tld_id
  1001. <trim prefix="WHERE" prefixOverrides="and |or">
  1002. <if test="startTime != null and startTime != ''">
  1003. and a.scrq <![CDATA[>=]]> #{startTime}
  1004. </if>
  1005. <if test="endTime != null and endTime != ''">
  1006. and a.scrq <![CDATA[<=]]> #{endTime}
  1007. </if>
  1008. <if test="materialName != null and materialName != ''">
  1009. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  1010. </if>
  1011. <if test="wllbCode != null and wllbCode != ''">
  1012. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  1013. </if>
  1014. <if test="userName != null and userName != ''">
  1015. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  1016. </if>
  1017. <if test="realName != null and realName != ''">
  1018. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  1019. </if>
  1020. <if test="attribute != null and attribute != ''">
  1021. and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
  1022. </if>
  1023. <if test="storageCode != null and storageCode != ''">
  1024. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  1025. </if>
  1026. <if test="wbs != null and wbs != ''">
  1027. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  1028. </if>
  1029. <if test="productionCode != null and productionCode != ''">
  1030. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  1031. </if>
  1032. <if test="storageLocationName != null and storageLocationName != ''">
  1033. and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  1034. </if>
  1035. <if test="companyNumber != null and companyNumber != ''">
  1036. and a.account_sleeve = #{companyNumber}
  1037. </if>
  1038. </trim>
  1039. order by a.scrq desc
  1040. </select>
  1041. <!-- 查询通知单虚拟库扫描数 -->
  1042. <select id="getSumScanNumVal" resultType="int">
  1043. SELECT ifnull(sum(a.num), 0)
  1044. FROM tld_warehousing_virtual a
  1045. left join tld_material b on a.wllb_code = b.code
  1046. WHERE a.notice_id = #{noticeId} and b.tld_id = #{materialId}
  1047. </select>
  1048. <!-- 修改报工单入库数量 -->
  1049. <update id="updateNotice">
  1050. update tld_notice
  1051. set warehousing_num = (warehousing_num + 0) + #{warehousingNum}
  1052. <if test="type != null and type != ''">
  1053. ,type = '1'
  1054. </if>
  1055. where notice_id = #{noticeId}
  1056. and material_id = #{materialId} and entry_number = #{entryNumber}
  1057. </update>
  1058. <!-- 查询产成品是否扫描 -->
  1059. <select id="getScanIsNotProduct" resultType="java.util.Map">
  1060. select (select count(*)
  1061. from tld_inventory
  1062. where attribute = #{attribute}
  1063. and serial = #{serial}
  1064. and wllb_code = #{materialCode}
  1065. and produc_date = #{producBatch}) as inventoryCount,
  1066. (select count(*)
  1067. from tld_warehousing_virtual
  1068. where attribute = #{attribute}
  1069. and serial = #{serial}
  1070. and wllb_code = #{materialCode}
  1071. and produc_date = #{producBatch}) as virtualCount
  1072. from dual
  1073. </select>
  1074. <!-- 查询昨天没满的库位 -->
  1075. <select id="getStorageLocationCode" resultType="String">
  1076. SELECT ifnull(max(storage_location_code), "0")
  1077. FROM tld_inventory
  1078. WHERE attribute = #{attribute} and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE() and material_id = #{materialId} and account_sleeve = #{companyNumber}
  1079. <if test="producBatch != null">
  1080. and produc_batch = #{producBatch}
  1081. </if>
  1082. ORDER BY scrq desc LIMIT 1
  1083. </select>
  1084. <select id="getCountStorage" resultType="int">
  1085. SELECT count(*)
  1086. FROM tld_inventory
  1087. where attribute = #{attribute}
  1088. and storage_location_code = #{storageLocationCode}
  1089. and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE()
  1090. and material_id = #{materialId}
  1091. <if test="producBatch != null">
  1092. and produc_batch = #{producBatch}
  1093. </if>
  1094. ORDER BY scrq desc LIMIT 1
  1095. </select>
  1096. <!-- 增加流水入库编号 -->
  1097. <update id="updateStorage">
  1098. update tld_storage
  1099. set storage_code = #{storageCode}
  1100. where wllb_code = #{wllbCode}
  1101. and supplier_id = #{suppId}
  1102. and serial = #{serial}
  1103. and produc_batch = #{producDate}
  1104. </update>
  1105. <!-- 查询公共设置 -->
  1106. <select id="getNumUtil" resultType="int">
  1107. select num
  1108. from tld_util
  1109. where type = #{type}
  1110. </select>
  1111. <!-- 其他入库 -->
  1112. <update id="updateInventoryOther">
  1113. update tld_inventory
  1114. set amount = (amount + 0) + #{amount}
  1115. where id = #{id}
  1116. </update>
  1117. <!-- 移库虚拟库入库 -->
  1118. <update id="updateVitrualNum">
  1119. update tld_inventory
  1120. set amount = amount + #{num}
  1121. where material_id = #{materialId}
  1122. and storage_location_code = #{storageLocationCode}
  1123. </update>
  1124. <!-- 其他入库返回gs -->
  1125. <insert id="addReturnWarehousingOther">
  1126. insert into tld_return_gs_other_warehousing
  1127. (storage_code, account_sleeve, storage_location_code, notice_id, notice_code,
  1128. amount,wbs,wbs_code,wbs_name,notice_time,warehouse_where,source_type,move_type,entry_number,wms_item_id,material_id,wms_id)
  1129. value
  1130. (#{storageCode},#{companyNumber},#{storageLocationCode},#{noticeId},#{noticeCode},#{num},#{wbs},#{code},#{name},
  1131. now(),#{warehouseWhere},#{sourceType},#{moveType},#{entryNumber},#{wmsItemId},#{materialId},#{wmsId})
  1132. </insert>
  1133. <!-- 其他入库 -->
  1134. <insert id="addInventoryOther">
  1135. insert into tld_inventory(storage_location_code, wllb_class, library_type, material_id, amount, totime,
  1136. amount_lock, account_sleeve, wbs, supplier_id, serial, wllb_code, produc_date, scrq,
  1137. produc_batch, attribute)
  1138. value (#{storageLocationCode},#{wllbClass},#{libraryType},#{materialId},#{amount},now(),'0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producDate},#{attribute})
  1139. </insert>
  1140. <!-- 查询扫描数量 -->
  1141. <select id="getSumWarehousingVirtual" resultType="java.util.Map">
  1142. select
  1143. (select ifnull(sum(num), 0) from tld_warehousing_virtual where receive_goods_id = #{receiveGoodsId}) as scanNum,
  1144. (select (qualified_num + 0) - ifnull((warehousing_num + 0), 0) from tld_receive_goods where id = #{receiveGoodsId}) as num
  1145. from dual
  1146. </select>
  1147. <!-- 查询扫描数量 -->
  1148. <select id="getWarehouseTransferVirtual" resultType="java.util.Map">
  1149. select
  1150. (select ifnull(sum(num), 0) from tld_warehousing_virtual where warehouse_transfer_id = #{warehouseTransferId} and wllb_code = #{wllbCode}) as scanNum,
  1151. (select (num + 0) - ifnull((out_num + 0), 0) from tld_warehouse_transfer where warehouse_transfer_id = #{warehouseTransferId} and material_id = #{materialId}) as num
  1152. from dual
  1153. </select>
  1154. <!-- 流水增加传输状态 -->
  1155. <update id="updateWarehousingType">
  1156. update tld_storage set transmission_type = #{type} where storage_code = #{storageCode}
  1157. </update>
  1158. <!-- 查询其他入库 -->
  1159. <select id="getNotices" resultType="com.tld.model.Notice">
  1160. select
  1161. b.notice_code,
  1162. b.notice_id,
  1163. b.company_number,
  1164. b.source_type,
  1165. b.move_type,
  1166. a.entry_number,
  1167. a.id as wmsItemId,
  1168. b.id as wmsId,
  1169. a.wbs,
  1170. c.code,
  1171. c.name,
  1172. a.entry_number
  1173. from tld_notices a
  1174. join tld_notices_f b on a.notice_id = b.notice_id
  1175. left join tld_wbs c on a.wbs = c.tld_id
  1176. where a.notice_id = #{noticeId} and a.entry_number = #{entryNumber} and a.material_id = #{materialId}
  1177. </select>
  1178. <!--查询删除信息-->
  1179. <select id="getOtherReceivingGoods" resultType="java.util.Map">
  1180. select * from tld_notices where id = #{id}
  1181. </select>
  1182. <!--查询删除信息-->
  1183. <select id="getOtherShipments" resultType="java.util.Map">
  1184. select * from tld_enquiry where id = #{id}
  1185. </select>
  1186. <!-- 往单据上增加数量 -->
  1187. <update id="updateNoticesWarehousingNum">
  1188. update tld_notices set warehousing_num = warehousing_num + #{amount} where notice_id = #{noticeId} and entry_number = #{entryNumber}
  1189. </update>
  1190. <!-- 查询库存是否存在此产成品 -->
  1191. <select id="getFinishedInfo" resultType="String">
  1192. select id from tld_inventory where wllb_code = #{wllbCode} and wbs = #{wbs} and account_sleeve = #{accountSleeve} limit 1
  1193. </select>
  1194. <!-- 查询产成品入库虚拟表数量 -->
  1195. <select id="getnumSaoMiao" resultType="java.lang.String">
  1196. select ifnull(max(num), 0) from tld_warehousing_virtual where notice_id = #{noticeId} and entry_number = #{entryNumber}
  1197. </select>
  1198. </mapper>