WarehousingMapper.xml 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  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. from tld_storage a
  247. left join tld_material b on a.wllb_code = b.code
  248. left join tld_user c on a.user_id = c.id
  249. left join tld_department e on a.department_id = e.code
  250. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  251. left join tld_customer h on a.supplier_id = h.code
  252. left join tld_company f on a.account_sleeve = f.code
  253. <trim prefix="WHERE" prefixOverrides="and |or">
  254. <if test="storageCode != null and storageCode != ''">
  255. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  256. </if>
  257. <if test="wllbCode != null and wllbCode != ''">
  258. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  259. </if>
  260. <if test="materialName != null and materialName != ''">
  261. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  262. </if>
  263. <if test="userName != null and userName != ''">
  264. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  265. </if>
  266. <if test="realName != null and realName != ''">
  267. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  268. </if>
  269. <if test="storageLocationName != null and storageLocationName != ''">
  270. and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  271. </if>
  272. <if test="wbs != null and wbs != ''">
  273. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  274. </if>
  275. <if test="orderCode != null and orderCode != ''">
  276. and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
  277. </if>
  278. <if test="supplierId != null and supplierId != ''">
  279. and a.supplier_id = #{supplierId}
  280. </if>
  281. <if test="startTime != null and startTime != ''">
  282. and a.scrq <![CDATA[>=]]> #{startTime}
  283. </if>
  284. <if test="endTime != null and endTime != ''">
  285. and a.scrq <![CDATA[<=]]> #{endTime}
  286. </if>
  287. <if test="accountSleeve != null and accountSleeve != ''">
  288. and a.account_sleeve = #{accountSleeve}
  289. </if>
  290. </trim>
  291. order by a.scrq desc
  292. </select>
  293. <!-- 查询虚拟入库 -->
  294. <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
  295. select id,
  296. unique_code,
  297. num,
  298. storage_location_code,
  299. wllb_code,
  300. supp_id,
  301. serial,
  302. type,
  303. produc_date,
  304. capacity,
  305. seq,
  306. user_id,
  307. storage_location_name,
  308. warehouse_transfer_id,
  309. wbs,
  310. receive_goods_id,
  311. notice_id,
  312. account_sleeve
  313. from tld_warehousing_virtual
  314. where unique_code = #{uniqueCode}
  315. and type = #{type} and warehouse_transfer_id = #{warehouseTransferId}
  316. order by id desc
  317. </select>
  318. <!-- 查询导出内容 -->
  319. <select id="export" resultType="java.util.LinkedHashMap">
  320. select
  321. b.name as materialName,
  322. a.wllb_code as wllbCode,
  323. h.name as supplierName,
  324. if(a.serial = '', null ,a.serial) as serial,
  325. a.capacity,
  326. a.type,
  327. c.user_name as userName,
  328. e.name as departmentName,
  329. g.storage_location_name as storageLocationName,
  330. a.scrq,
  331. a.storage_code,
  332. e.code as wbs,
  333. c.real_name as realName,
  334. a.order_code as orderCode,
  335. f.name as accountName,
  336. a.account_sleeve as accountSleeve,
  337. if(a.purchase_num = '', null, a.purchase_num) as purchaseNum
  338. from tld_storage a
  339. left join tld_material b on a.wllb_code = b.code
  340. left join tld_user c on a.user_id = c.id
  341. left JOIN tld_wbs e ON a.wbs = e.code
  342. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  343. left join tld_customer h on a.supplier_id = h.code
  344. left join tld_company f on a.account_sleeve = f.code
  345. <trim prefix="WHERE" prefixOverrides="and |or">
  346. <if test="storageCode != null and storageCode != ''">
  347. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  348. </if>
  349. <if test="wllbCode != null and wllbCode != ''">
  350. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  351. </if>
  352. <if test="materialName != null and materialName != ''">
  353. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  354. </if>
  355. <if test="userName != null and userName != ''">
  356. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  357. </if>
  358. <if test="realName != null and realName != ''">
  359. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  360. </if>
  361. <if test="storageLocationName != null and storageLocationName != ''">
  362. and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  363. </if>
  364. <if test="wbs != null and wbs != ''">
  365. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  366. </if>
  367. <if test="orderCode != null and orderCode != ''">
  368. and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
  369. </if>
  370. <if test="supplierId != null and supplierId != ''">
  371. and a.supplier_id = #{supplierId}
  372. </if>
  373. <if test="startTime != null and startTime != ''">
  374. and a.scrq <![CDATA[>=]]> #{startTime}
  375. </if>
  376. <if test="endTime != null and endTime != ''">
  377. and a.scrq <![CDATA[<=]]> #{endTime}
  378. </if>
  379. <if test="accountSleeve != null and accountSleeve != ''">
  380. and a.account_sleeve = #{accountSleeve}
  381. </if>
  382. </trim>
  383. order by a.scrq desc
  384. </select>
  385. <!-- 查询是否扫描 -->
  386. <select id="getScanIsNot" resultType="java.util.Map">
  387. select
  388. (select count(*)
  389. from tld_inventory a
  390. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  391. where a.supplier_id = #{suppId} and a.serial = #{unique} and a.wllb_code = #{wllbCode} and a.produc_date =
  392. #{producDate}
  393. <if test="warehouseWhere != null and warehouseWhere != ''">
  394. and b.warehouse_where = #{warehouseWhere}
  395. </if>) as inventoryCount,
  396. (select count(*) from tld_warehousing_virtual where supp_id = #{suppId} and serial = #{unique} and wllb_code =
  397. #{wllbCode} and produc_date = #{producDate}) as virtualCount
  398. from dual
  399. </select>
  400. <!-- 查询物料是否存在 -->
  401. <select id="getMateriaIsExist" resultType="com.tld.model.MaterialClass">
  402. select id,
  403. code,
  404. name,
  405. tld_id,
  406. specification_and_model,
  407. unit_of_measurement,
  408. ifnull(size, 0) as size,
  409. wllb_class,
  410. is_not_disable,
  411. is_recommend,
  412. part_type
  413. from tld_material
  414. where code = #{wllbCode}
  415. </select>
  416. <!-- 查询库存是否同物料同批次存在 -->
  417. <select id="getInventoryProduc" resultType="java.util.Map">
  418. SELECT produc_batch as producDate,wbs as wbs,account_sleeve as accountSleeve,wllb_code as wllbCode
  419. FROM tld_inventory a
  420. JOIN tld_material b ON a.material_id = b.tld_id
  421. WHERE a.storage_location_code = #{storageLocationCode}
  422. and hold = '0'
  423. </select>
  424. <!-- 查询报工单 -->
  425. <select id="getNotice" resultType="com.tld.model.Notice">
  426. select
  427. a.id,
  428. a.notice_id,
  429. a.entry_number,
  430. a.production_code,
  431. a.material_id,
  432. a.wbs,
  433. f.code as wbsCode,
  434. a.measurement_id,
  435. a.num,
  436. a.type,
  437. a.warehousing_num,
  438. b.company_number,
  439. c.name as materialName,
  440. c.wllb_class as wllbClass,
  441. c.code as wllbCode,
  442. e.name as companyName,
  443. b.notice_time as noticeTime,
  444. b.source_type as sourceType,
  445. b.move_type as moveType,
  446. b.notice_code as noticeCode
  447. from tld_notice a
  448. join tld_notice_f b on a.notice_id = b.notice_id
  449. join tld_material c on a.material_id = c.tld_id
  450. join tld_company e on b.company_number = e.code
  451. left join tld_wbs f on a.wbs = f.tld_id
  452. <trim prefix="WHERE" prefixOverrides="and |or">
  453. <if test="userId != null and userId != ''">
  454. and c.code in (select material_id from tld_user_material where user_id = #{userId})
  455. </if>
  456. <if test="type != null and type != ''">
  457. and a.type = #{type}
  458. </if>
  459. <if test="noticeId != null and noticeId != ''">
  460. and a.notice_id like CONCAT(CONCAT('%', #{noticeId}), '%')
  461. </if>
  462. <if test="entryNumber != null and entryNumber != ''">
  463. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  464. </if>
  465. <if test="wllbCode != null and wllbCode != ''">
  466. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  467. </if>
  468. <if test="materialName != null and materialName != ''">
  469. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  470. </if>
  471. <if test="startTime != null and startTime != ''">
  472. and b.notice_time <![CDATA[>=]]> #{startTime}
  473. </if>
  474. <if test="endTime != null and endTime != ''">
  475. and b.notice_time <![CDATA[<=]]> #{endTime}
  476. </if>
  477. <if test="partType != null and partType == '产成品'.toString()">
  478. and c.part_type = #{partType}
  479. </if>
  480. <if test="partType != null and partType == '半成品'.toString()">
  481. and (c.part_type ='半成品' or c.part_type ='原材料')
  482. </if>
  483. <if test="companyNumber != null and companyNumber != ''">
  484. and b.company_number = #{companyNumber}
  485. </if>
  486. <if test="productionCode != null and productionCode != ''">
  487. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  488. </if>
  489. <if test="wbs != null and wbs != ''">
  490. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  491. </if>
  492. <if test="moveType != null and moveType != ''">
  493. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  494. </if>
  495. <if test="sourceType != null and sourceType != ''">
  496. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  497. </if>
  498. <if test="noticeCode != null and noticeCode != ''">
  499. and b.notice_code like CONCAT(CONCAT('%', #{noticeCode}), '%')
  500. </if>
  501. </trim>
  502. order by a.id desc
  503. </select>
  504. <!-- 导出报工单 -->
  505. <select id="exportNotice" resultType="java.util.LinkedHashMap">
  506. select
  507. a.production_code,
  508. b.notice_code as noticeCode,
  509. c.code as wllbCode,
  510. c.name as materialName,
  511. a.num,
  512. a.warehousing_num,
  513. b.notice_time as noticeTime,
  514. a.entry_number,
  515. e.name as companyName,
  516. b.company_number,
  517. if(a.wbs = "", null, a.wbs) as wbs,
  518. b.source_type as sourceType,
  519. b.move_type as moveType,
  520. (case a.type when "0" then "未入库" when "1" then "已入库" end) as type
  521. from tld_notice a
  522. join tld_notice_f b on a.notice_id = b.notice_id
  523. join tld_material c on a.material_id = c.tld_id
  524. join tld_company e on b.company_number = e.code
  525. <trim prefix="WHERE" prefixOverrides="and |or">
  526. <if test="type != null and type != ''">
  527. and a.type = #{type}
  528. </if>
  529. <if test="noticeId != null and noticeId != ''">
  530. and a.notice_id like CONCAT(CONCAT('%', #{noticeId}), '%')
  531. </if>
  532. <if test="entryNumber != null and entryNumber != ''">
  533. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  534. </if>
  535. <if test="wllbCode != null and wllbCode != ''">
  536. and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  537. </if>
  538. <if test="materialName != null and materialName != ''">
  539. and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
  540. </if>
  541. <if test="startTime != null and startTime != ''">
  542. and b.notice_time <![CDATA[>=]]> #{startTime}
  543. </if>
  544. <if test="endTime != null and endTime != ''">
  545. and b.notice_time <![CDATA[<=]]> #{endTime}
  546. </if>
  547. <if test="partType != null and partType == '产成品'.toString()">
  548. and c.part_type = #{partType}
  549. </if>
  550. <if test="partType != null and partType == '半成品'.toString()">
  551. and (c.part_type ='半成品' or c.part_type ='原材料')
  552. </if>
  553. <if test="companyNumber != null and companyNumber != ''">
  554. and b.company_number = #{companyNumber}
  555. </if>
  556. <if test="productionCode != null and productionCode != ''">
  557. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  558. </if>
  559. <if test="wbs != null and wbs != ''">
  560. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  561. </if>
  562. <if test="moveType != null and moveType != ''">
  563. and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  564. </if>
  565. <if test="sourceType != null and sourceType != ''">
  566. and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  567. </if>
  568. <if test="noticeCode != null and noticeCode != ''">
  569. and b.notice_code like CONCAT(CONCAT('%', #{noticeCode}), '%')
  570. </if>
  571. </trim>
  572. order by a.id desc
  573. </select>
  574. <!-- 查询通知单是否入库 -->
  575. <select id="getNoticeId" resultType="com.tld.model.Notice">
  576. select a.id,
  577. a.notice_id,
  578. a.entry_number,
  579. a.production_code,
  580. a.material_id,
  581. a.wbs,
  582. a.measurement_id,
  583. a.num,
  584. a.type,
  585. a.warehousing_num,
  586. b.wllb_class,
  587. c.source_type,
  588. c.move_type,
  589. b.code as materialCode,
  590. c.notice_time as noticeTime,
  591. c.company_number
  592. from tld_notice a
  593. join tld_notice_f c on a.notice_id = c.notice_id
  594. left join tld_material b on a.material_id = b.tld_id
  595. where a.notice_id = #{noticeId} and a.material_id = #{materialId} and a.entry_number = #{entryNumber}
  596. </select>
  597. <!-- 半成品跟部分产成品入库存 -->
  598. <insert id="addInventoryNotice">
  599. insert into tld_inventory(storage_location_code, material_id, amount, hold, amount_lock, account_sleeve, wbs,
  600. produc_date, scrq, wllb_class, produc_batch, attribute, serial, supplier_id,
  601. wllb_code, totime)
  602. value (#{storageLocationCode},#{materialId},#{warehousingNum},'0','0',#{companyNumber},#{wbs},#{producBatch},now(),#{wllbClass},#{producBatch},#{attribute},#{serial},#{supplierId},#{wllbCode},now());
  603. </insert>
  604. <!-- 查询库存里是否存在半成品虚拟库位 -->
  605. <select id="getInventoryNotice" resultType="int">
  606. select count(*)
  607. from tld_inventory
  608. where storage_location_code = #{storageLocationCode}
  609. and material_id = #{materialId}
  610. and account_sleeve = #{companyNumber}
  611. and wbs = #{wbs}
  612. </select>
  613. <!-- 增加半成品/产成品虚拟库位数量 -->
  614. <update id="updateInventoryNotice">
  615. update tld_inventory
  616. set amount = amount + #{warehousingNum},
  617. totime = now()
  618. where storage_location_code = #{storageLocationCode}
  619. and material_id = #{materialId}
  620. and wbs = #{wbs};
  621. </update>
  622. <!-- 半成品出库库存查询 -->
  623. <select id="getHalfInventory" resultType="com.tld.model.Inventory">
  624. select storage_location_code, wllb_class, material_id, amount
  625. from tld_inventory
  626. where storage_location_code = #{storageLocationCode}
  627. and material_id = #{materialId}
  628. and account_sleeve = #{companyNumber}
  629. and wbs = #{wbs}
  630. and hold = '0'
  631. order by produc_batch
  632. </select>
  633. <!-- 删除库存信息 -->
  634. <delete id="delInventoryNotice">
  635. delete
  636. from tld_inventory
  637. where storage_location_code = #{storageLocationCode}
  638. and material_id = #{materialId}
  639. </delete>
  640. <!--删除其它入库信息-->
  641. <delete id="delOtherReceivingGoods">
  642. delete from tld_notices where id = #{id}
  643. </delete>
  644. <!--删除其它出库信息-->
  645. <delete id="delOtherShipments">
  646. delete from tld_enquiry where id = #{id}
  647. </delete>
  648. <!-- 删减库存 -->
  649. <update id="updateInventoryNoticeNum">
  650. update tld_inventory
  651. set amount = amount - #{warehousingNum}
  652. where storage_location_code = #{storageLocationCode}
  653. and material_id = #{materialId}
  654. </update>
  655. <!-- 新增半成品入库流水 -->
  656. <insert id="addProduct">
  657. insert into tld_half_product(wllb_code, produc_date, produc_batch, capacity, user_id, storage_location_code,
  658. scrq, storage_code, wbs, production_code,account_sleeve,transmission_type)
  659. value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{storageCode},#{wbs}, #{productionCode},#{accountSleeve},0)
  660. </insert>
  661. <!-- 查询半成品入库流水-->
  662. <select id="getProduct" resultType="com.tld.model.Notice">
  663. select
  664. a.id,
  665. a.wllb_code,
  666. a.produc_date,
  667. a.produc_batch,
  668. a.capacity as warehousingNum,
  669. a.user_id,
  670. c.user_name,
  671. a.storage_location_code,
  672. a.scrq,
  673. b.name as materialName,
  674. b.code as materialCode,
  675. a.storage_code,
  676. a.wbs,
  677. a.production_code,
  678. c.real_name as realName,
  679. a.production_code as productionCode,
  680. a.account_sleeve as companyNumber,
  681. e.name as accountName
  682. from tld_half_product a
  683. left join tld_material b on a.wllb_code = b.code
  684. left join tld_user c on a.user_id = c.id
  685. left join tld_company e on a.account_sleeve = e.code
  686. <trim prefix="WHERE" prefixOverrides="and |or">
  687. <if test="startTime != null and startTime != ''">
  688. and a.scrq <![CDATA[>=]]> #{startTime}
  689. </if>
  690. <if test="endTime != null and endTime != ''">
  691. and a.scrq <![CDATA[<=]]> #{endTime}
  692. </if>
  693. <if test="wllbCode != null and wllbCode != ''">
  694. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  695. </if>
  696. <if test="materialName != null and materialName != ''">
  697. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  698. </if>
  699. <if test="storageLocationCode != null and storageLocationCode != ''">
  700. and a.storage_location_code = #{storageLocationCode}
  701. </if>
  702. <if test="userName != null and userName != ''">
  703. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  704. </if>
  705. <if test="realName != null and realName != ''">
  706. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  707. </if>
  708. <if test="productionCode != null and productionCode != ''">
  709. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  710. </if>
  711. <if test="storageCode != null and storageCode != ''">
  712. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  713. </if>
  714. <if test="productionCode != null and productionCode != ''">
  715. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  716. </if>
  717. <if test="wbs != null and wbs != ''">
  718. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  719. </if>
  720. <if test="companyNumber != null and companyNumber != ''">
  721. and a.account_sleeve = #{companyNumber}
  722. </if>
  723. </trim>
  724. order by a.scrq desc
  725. </select>
  726. <!-- 查询半成品入库流水导出-->
  727. <select id="productExcel" resultType="java.util.LinkedHashMap">
  728. select
  729. b.name,
  730. a.wllb_code,
  731. a.produc_date,
  732. a.capacity,
  733. c.user_name,
  734. a.scrq,
  735. a.storage_code,
  736. if(a.wbs = '' , null ,a.wbs) wbs,
  737. c.real_name as realName,
  738. if(a.production_code = '' , null ,a.production_code) as productionCode,
  739. e.name as accountName,
  740. a.account_sleeve as accountSleeve
  741. from tld_half_product a
  742. left join tld_material b on a.wllb_code = b.code
  743. left join tld_user c on a.user_id = c.id
  744. left join tld_company e on a.account_sleeve = e.code
  745. <trim prefix="WHERE" prefixOverrides="and |or">
  746. <if test="startTime != null and startTime != ''">
  747. and a.scrq <![CDATA[>=]]> #{startTime}
  748. </if>
  749. <if test="endTime != null and endTime != ''">
  750. and a.scrq <![CDATA[<=]]> #{endTime}
  751. </if>
  752. <if test="wllbCode != null and wllbCode != ''">
  753. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  754. </if>
  755. <if test="materialName != null and materialName != ''">
  756. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  757. </if>
  758. <if test="storageLocationCode != null and storageLocationCode != ''">
  759. and a.storage_location_code = #{storageLocationCode}
  760. </if>
  761. <if test="userName != null and userName != ''">
  762. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  763. </if>
  764. <if test="realName != null and realName != ''">
  765. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  766. </if>
  767. <if test="productionCode != null and productionCode != ''">
  768. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  769. </if>
  770. <if test="storageCode != null and storageCode != ''">
  771. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  772. </if>
  773. <if test="wbs != null and wbs != ''">
  774. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  775. </if>
  776. <if test="companyNumber != null and companyNumber != ''">
  777. and a.account_sleeve = #{companyNumber}
  778. </if>
  779. </trim>
  780. order by a.scrq desc
  781. </select>
  782. <!-- 查询要料单信息 -->
  783. <select id="getAskGoodsHalf" resultType="com.tld.model.AskGoods">
  784. select a.id,
  785. a.ask_goods_id,
  786. a.material_id,
  787. a.wbs,
  788. a.measurement_id,
  789. a.num,
  790. a.out_num,
  791. a.entry_number,
  792. b.source_type,
  793. b.move_type,
  794. c.code as wllbCode,
  795. a.type,
  796. b.department
  797. from tld_ask_goods a
  798. join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
  799. left join tld_material c on a.material_id = c.tld_id
  800. where a.ask_goods_id = #{askGoodsId}
  801. and a.material_id = #{materialId} and a.entry_number = #{entryNumber}
  802. </select>
  803. <!-- 修改要货单出库数量 -->
  804. <update id="updateAskGoodsHalf">
  805. update tld_ask_goods
  806. set out_num = ifnull(out_num, 0) + #{warehousingNum}
  807. <if test="type != null and type != ''">
  808. ,type = '1'
  809. </if>
  810. where id = #{id}
  811. </update>
  812. <!-- 新增半成品流水 -->
  813. <insert id="addRemovalHalfProduct">
  814. insert into tld_removal_half_product(wllb_code, num, user_id, scrq, ask_goods_id, department, storage_code, wbs, account_sleeve)
  815. value (#{wllbCode},#{num},#{userId},now(),#{askGoodsId},#{department},#{storageCode},#{wbs},#{companyNumber})
  816. </insert>
  817. <!-- 查询指定物料内容 -->
  818. <select id="getMaterial" resultType="com.tld.model.MaterialClass">
  819. select
  820. code as wllbCode,
  821. name as wllbName,
  822. tld_id,
  823. specification_and_model,
  824. unit_of_measurement,
  825. size,
  826. wllb_class,
  827. is_not_disable,
  828. ifnull(is_recommend,'') as isRecommend,
  829. part_type
  830. from tld_material
  831. <trim prefix="WHERE" prefixOverrides="and |or">
  832. <if test="materialId != null and materialId != ''">
  833. and tld_id = #{materialId}
  834. </if>
  835. <if test="materialCode != null and materialCode != ''">
  836. and code = #{materialCode}
  837. </if>
  838. </trim>
  839. </select>
  840. <!-- 查询库存信息 -->
  841. <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
  842. select storage_location_code,
  843. wllb_class,
  844. library_type,
  845. material_id,
  846. amount,
  847. total,
  848. totime,
  849. hold,
  850. amount_lock,
  851. account_sleeve,
  852. wbs,
  853. supplier_id,
  854. serial,
  855. wllb_code,
  856. produc_date,
  857. scrq,
  858. produc_batch,
  859. attribute
  860. from tld_inventory
  861. where storage_location_code = #{storageLocationCode}
  862. </select>
  863. <!-- 产成品入库 -->
  864. <insert id="addHalf">
  865. insert into tld_half(wllb_code, produc_date, produc_batch, capacity, user_id, storage_location_code, scrq,
  866. serial, seq, attribute, storage_code, wbs, production_code,account_sleeve,transmission_type)
  867. value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{serial},#{seq},#{attribute},#{storageCode},#{wbs},#{productionCode},#{accountSleeve},0)
  868. </insert>
  869. <!-- 查询虚拟表数据进行入库 -->
  870. <select id="getVirtualNotice" resultType="com.tld.model.WarehousingVirtual">
  871. select a.id,
  872. a.unique_code,
  873. a.num,
  874. a.storage_location_code,
  875. a.wllb_code,
  876. a.supp_id,
  877. a.serial,
  878. a.type,
  879. a.produc_date,
  880. a.capacity,
  881. a.seq,
  882. a.user_id,
  883. a.attribute,
  884. a.storage_location_name,
  885. b.user_name,
  886. a.account_sleeve
  887. from tld_warehousing_virtual a
  888. left join tld_user b on a.user_id = b.id
  889. where a.unique_code = #{uniqueCode}
  890. and a.type = #{type}
  891. and a.notice_id = #{noticeId}
  892. </select>
  893. <!-- 产成品入库流水 -->
  894. <select id="getHalf" resultType="com.tld.model.Notice">
  895. select
  896. a.id,
  897. a.wllb_code,
  898. a.produc_date,
  899. a.produc_batch,
  900. a.capacity,
  901. a.user_id,
  902. a.storage_location_code,
  903. e.storage_location_name as storageLocationName,
  904. a.scrq,
  905. a.serial,
  906. a.seq,
  907. a.attribute,
  908. b.name as materialName,
  909. c.user_name as userName,
  910. b.code as materialCode,
  911. a.storage_code,
  912. a.wbs,
  913. c.real_name as realName,
  914. a.production_code as productionCode,
  915. a.account_sleeve as companyNumber,
  916. f.name as accountName
  917. from tld_half a
  918. left join tld_material b on a.wllb_code = b.code
  919. left join tld_user c on a.user_id = c.id
  920. left join tld_storage_location e on a.storage_location_code = e.storage_location_code
  921. left join tld_company f on a.account_sleeve = f.code
  922. <trim prefix="WHERE" prefixOverrides="and |or">
  923. <if test="startTime != null and startTime != ''">
  924. and a.scrq <![CDATA[>=]]> #{startTime}
  925. </if>
  926. <if test="endTime != null and endTime != ''">
  927. and a.scrq <![CDATA[<=]]> #{endTime}
  928. </if>
  929. <if test="materialName != null and materialName != ''">
  930. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  931. </if>
  932. <if test="wllbCode != null and wllbCode != ''">
  933. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  934. </if>
  935. <if test="userName != null and userName != ''">
  936. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  937. </if>
  938. <if test="realName != null and realName != ''">
  939. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  940. </if>
  941. <if test="attribute != null and attribute != ''">
  942. and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
  943. </if>
  944. <if test="storageCode != null and storageCode != ''">
  945. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  946. </if>
  947. <if test="wbs != null and wbs != ''">
  948. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  949. </if>
  950. <if test="storageLocationName != null and storageLocationName != ''">
  951. and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  952. </if>
  953. <if test="productionCode != null and productionCode != ''">
  954. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  955. </if>
  956. <if test="companyNumber != null and companyNumber != ''">
  957. and a.account_sleeve = #{companyNumber}
  958. </if>
  959. </trim>
  960. order by a.scrq desc
  961. </select>
  962. <!-- 产成品导出 -->
  963. <select id="getHalfExcel" resultType="java.util.LinkedHashMap">
  964. select
  965. b.name as materialName,
  966. a.wllb_code,
  967. if(a.produc_batch = '' , null , a.produc_batch) as producBatch,
  968. a.capacity,
  969. c.user_name as userName,
  970. a.storage_location_code,
  971. a.scrq,
  972. a.serial,
  973. if(a.attribute = '' , null , a.attribute) as attribute,
  974. a.storage_code,
  975. if(a.wbs = '' , null , a.wbs) as wbs,
  976. c.real_name as realName,
  977. a.production_code as productionCode,
  978. f.name as accountName,
  979. a.account_sleeve as accountSleeve
  980. from tld_half a
  981. left join tld_material b on a.wllb_code = b.code
  982. left join tld_user c on a.user_id = c.id
  983. left join tld_company f on a.account_sleeve = f.code
  984. <trim prefix="WHERE" prefixOverrides="and |or">
  985. <if test="startTime != null and startTime != ''">
  986. and a.scrq <![CDATA[>=]]> #{startTime}
  987. </if>
  988. <if test="endTime != null and endTime != ''">
  989. and a.scrq <![CDATA[<=]]> #{endTime}
  990. </if>
  991. <if test="materialName != null and materialName != ''">
  992. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  993. </if>
  994. <if test="wllbCode != null and wllbCode != ''">
  995. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  996. </if>
  997. <if test="userName != null and userName != ''">
  998. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  999. </if>
  1000. <if test="realName != null and realName != ''">
  1001. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  1002. </if>
  1003. <if test="attribute != null and attribute != ''">
  1004. and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
  1005. </if>
  1006. <if test="storageCode != null and storageCode != ''">
  1007. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  1008. </if>
  1009. <if test="wbs != null and wbs != ''">
  1010. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  1011. </if>
  1012. <if test="productionCode != null and productionCode != ''">
  1013. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  1014. </if>
  1015. <if test="storageLocationName != null and storageLocationName != ''">
  1016. and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  1017. </if>
  1018. <if test="companyNumber != null and companyNumber != ''">
  1019. and a.account_sleeve = #{companyNumber}
  1020. </if>
  1021. </trim>
  1022. order by a.scrq desc
  1023. </select>
  1024. <!-- 查询通知单虚拟库扫描数 -->
  1025. <select id="getSumScanNumVal" resultType="int">
  1026. SELECT ifnull(sum(a.num), 0)
  1027. FROM tld_warehousing_virtual a
  1028. left join tld_material b on a.wllb_code = b.code
  1029. WHERE a.notice_id = #{noticeId} and b.tld_id = #{materialId}
  1030. </select>
  1031. <!-- 修改报工单入库数量 -->
  1032. <update id="updateNotice">
  1033. update tld_notice
  1034. set warehousing_num = (warehousing_num + 0) + #{warehousingNum}
  1035. <if test="type != null and type != ''">
  1036. ,type = '1'
  1037. </if>
  1038. where notice_id = #{noticeId}
  1039. and material_id = #{materialId} and entry_number = #{entryNumber}
  1040. </update>
  1041. <!-- 查询产成品是否扫描 -->
  1042. <select id="getScanIsNotProduct" resultType="java.util.Map">
  1043. select (select count(*)
  1044. from tld_inventory
  1045. where attribute = #{attribute}
  1046. and serial = #{serial}
  1047. and wllb_code = #{materialCode}
  1048. and produc_date = #{producBatch}) as inventoryCount,
  1049. (select count(*)
  1050. from tld_warehousing_virtual
  1051. where attribute = #{attribute}
  1052. and serial = #{serial}
  1053. and wllb_code = #{materialCode}
  1054. and produc_date = #{producBatch}) as virtualCount
  1055. from dual
  1056. </select>
  1057. <!-- 查询昨天没满的库位 -->
  1058. <select id="getStorageLocationCode" resultType="String">
  1059. SELECT ifnull(max(storage_location_code), "0")
  1060. FROM tld_inventory
  1061. WHERE attribute = #{attribute} and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE() and material_id = #{materialId} and account_sleeve = #{companyNumber}
  1062. <if test="producBatch != null">
  1063. and produc_batch = #{producBatch}
  1064. </if>
  1065. ORDER BY scrq desc LIMIT 1
  1066. </select>
  1067. <select id="getCountStorage" resultType="int">
  1068. SELECT count(*)
  1069. FROM tld_inventory
  1070. where attribute = #{attribute}
  1071. and storage_location_code = #{storageLocationCode}
  1072. and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE()
  1073. and material_id = #{materialId}
  1074. <if test="producBatch != null">
  1075. and produc_batch = #{producBatch}
  1076. </if>
  1077. ORDER BY scrq desc LIMIT 1
  1078. </select>
  1079. <!-- 增加流水入库编号 -->
  1080. <update id="updateStorage">
  1081. update tld_storage
  1082. set storage_code = #{storageCode}
  1083. where wllb_code = #{wllbCode}
  1084. and supplier_id = #{suppId}
  1085. and serial = #{serial}
  1086. and produc_batch = #{producDate}
  1087. </update>
  1088. <!-- 查询公共设置 -->
  1089. <select id="getNumUtil" resultType="int">
  1090. select num
  1091. from tld_util
  1092. where type = #{type}
  1093. </select>
  1094. <!-- 其他入库 -->
  1095. <update id="updateInventoryOther">
  1096. update tld_inventory
  1097. set amount = (amount + 0) + #{amount}
  1098. where id = #{id}
  1099. </update>
  1100. <!-- 移库虚拟库入库 -->
  1101. <update id="updateVitrualNum">
  1102. update tld_inventory
  1103. set amount = amount + #{num}
  1104. where material_id = #{materialId}
  1105. and storage_location_code = #{storageLocationCode}
  1106. </update>
  1107. <!-- 其他入库返回gs -->
  1108. <insert id="addReturnWarehousingOther">
  1109. insert into tld_return_gs_other_warehousing
  1110. (storage_code, account_sleeve, storage_location_code, notice_id, notice_code,
  1111. amount,wbs,wbs_code,wbs_name,notice_time,warehouse_where,source_type,move_type,entry_number,wms_item_id,material_id,wms_id)
  1112. value
  1113. (#{storageCode},#{companyNumber},#{storageLocationCode},#{noticeId},#{noticeCode},#{num},#{wbs},#{code},#{name},
  1114. now(),#{warehouseWhere},#{sourceType},#{moveType},#{entryNumber},#{wmsItemId},#{materialId},#{wmsId})
  1115. </insert>
  1116. <!-- 其他入库 -->
  1117. <insert id="addInventoryOther">
  1118. insert into tld_inventory(storage_location_code, wllb_class, library_type, material_id, amount, totime,
  1119. amount_lock, account_sleeve, wbs, supplier_id, serial, wllb_code, produc_date, scrq,
  1120. produc_batch, attribute)
  1121. value (#{storageLocationCode},#{wllbClass},#{libraryType},#{materialId},#{amount},now(),'0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producDate},#{attribute})
  1122. </insert>
  1123. <!-- 查询扫描数量 -->
  1124. <select id="getSumWarehousingVirtual" resultType="java.util.Map">
  1125. select
  1126. (select ifnull(sum(num), 0) from tld_warehousing_virtual where receive_goods_id = #{receiveGoodsId}) as scanNum,
  1127. (select (qualified_num + 0) - ifnull((warehousing_num + 0), 0) from tld_receive_goods where id = #{receiveGoodsId}) as num
  1128. from dual
  1129. </select>
  1130. <!-- 查询扫描数量 -->
  1131. <select id="getWarehouseTransferVirtual" resultType="java.util.Map">
  1132. select
  1133. (select ifnull(sum(num), 0) from tld_warehousing_virtual where warehouse_transfer_id = #{warehouseTransferId} and wllb_code = #{wllbCode}) as scanNum,
  1134. (select (num + 0) - ifnull((out_num + 0), 0) from tld_warehouse_transfer where warehouse_transfer_id = #{warehouseTransferId} and material_id = #{materialId}) as num
  1135. from dual
  1136. </select>
  1137. <!-- 流水增加传输状态 -->
  1138. <update id="updateWarehousingType">
  1139. update tld_storage set transmission_type = #{type} where storage_code = #{storageCode}
  1140. </update>
  1141. <!-- 查询其他入库 -->
  1142. <select id="getNotices" resultType="com.tld.model.Notice">
  1143. select
  1144. b.notice_code,
  1145. b.notice_id,
  1146. b.company_number,
  1147. b.source_type,
  1148. b.move_type,
  1149. a.entry_number,
  1150. a.id as wmsItemId,
  1151. b.id as wmsId,
  1152. a.wbs,
  1153. c.code,
  1154. c.name,
  1155. a.entry_number
  1156. from tld_notices a
  1157. join tld_notices_f b on a.notice_id = b.notice_id
  1158. left join tld_wbs c on a.wbs = c.tld_id
  1159. where a.notice_id = #{noticeId} and a.entry_number = #{entryNumber} and a.material_id = #{materialId}
  1160. </select>
  1161. <!--查询删除信息-->
  1162. <select id="getOtherReceivingGoods" resultType="java.util.Map">
  1163. select * from tld_notices where id = #{id}
  1164. </select>
  1165. <!--查询删除信息-->
  1166. <select id="getOtherShipments" resultType="java.util.Map">
  1167. select * from tld_enquiry where id = #{id}
  1168. </select>
  1169. <!-- 往单据上增加数量 -->
  1170. <update id="updateNoticesWarehousingNum">
  1171. update tld_notices set warehousing_num = warehousing_num + #{amount} where notice_id = #{noticeId} and entry_number = #{entryNumber}
  1172. </update>
  1173. <!-- 查询库存是否存在此产成品 -->
  1174. <select id="getFinishedInfo" resultType="String">
  1175. select id from tld_inventory where wllb_code = #{wllbCode} and wbs = #{wbs} and account_sleeve = #{accountSleeve} limit 1
  1176. </select>
  1177. <!-- 查询产成品入库虚拟表数量 -->
  1178. <select id="getnumSaoMiao" resultType="java.lang.String">
  1179. select ifnull(max(num), 0) from tld_warehousing_virtual where notice_id = #{noticeId} and entry_number = #{entryNumber}
  1180. </select>
  1181. </mapper>