WarehousingMapper.xml 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  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. b.company_number
  810. from tld_ask_goods a
  811. join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
  812. left join tld_material c on a.material_id = c.tld_id
  813. where a.ask_goods_id = #{askGoodsId}
  814. and a.material_id = #{materialId} and a.entry_number = #{entryNumber}
  815. </select>
  816. <!-- 修改要货单出库数量 -->
  817. <update id="updateAskGoodsHalf">
  818. update tld_ask_goods
  819. set out_num = ifnull(out_num, 0) + #{warehousingNum}
  820. <if test="type != null and type != ''">
  821. ,type = '1'
  822. </if>
  823. where id = #{id}
  824. </update>
  825. <!-- 新增半成品流水 -->
  826. <insert id="addRemovalHalfProduct">
  827. insert into tld_removal_half_product(wllb_code, num, user_id, scrq, ask_goods_id, department, storage_code, wbs, account_sleeve)
  828. value (#{wllbCode},#{num},#{userId},now(),#{askGoodsId},#{department},#{storageCode},#{wbs},#{companyNumber})
  829. </insert>
  830. <!-- 查询指定物料内容 -->
  831. <select id="getMaterial" resultType="com.tld.model.MaterialClass">
  832. select
  833. code as wllbCode,
  834. name as wllbName,
  835. tld_id,
  836. specification_and_model,
  837. unit_of_measurement,
  838. size,
  839. wllb_class,
  840. is_not_disable,
  841. ifnull(is_recommend,'') as isRecommend,
  842. part_type
  843. from tld_material
  844. <trim prefix="WHERE" prefixOverrides="and |or">
  845. <if test="materialId != null and materialId != ''">
  846. and tld_id = #{materialId}
  847. </if>
  848. <if test="materialCode != null and materialCode != ''">
  849. and code = #{materialCode}
  850. </if>
  851. </trim>
  852. </select>
  853. <!-- 查询库存信息 -->
  854. <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
  855. select storage_location_code,
  856. wllb_class,
  857. library_type,
  858. material_id,
  859. amount,
  860. total,
  861. totime,
  862. hold,
  863. amount_lock,
  864. account_sleeve,
  865. wbs,
  866. supplier_id,
  867. serial,
  868. wllb_code,
  869. produc_date,
  870. scrq,
  871. produc_batch,
  872. attribute
  873. from tld_inventory
  874. where storage_location_code = #{storageLocationCode}
  875. </select>
  876. <!-- 产成品入库 -->
  877. <insert id="addHalf">
  878. insert into tld_half(wllb_code, produc_date, produc_batch, capacity, user_id, storage_location_code, scrq,
  879. serial, seq, attribute, storage_code, wbs, production_code,account_sleeve,transmission_type)
  880. value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{serial},#{seq},#{attribute},#{storageCode},#{wbs},#{productionCode},#{accountSleeve},0)
  881. </insert>
  882. <!-- 查询虚拟表数据进行入库 -->
  883. <select id="getVirtualNotice" resultType="com.tld.model.WarehousingVirtual">
  884. select a.id,
  885. a.unique_code,
  886. a.num,
  887. a.storage_location_code,
  888. a.wllb_code,
  889. a.supp_id,
  890. a.serial,
  891. a.type,
  892. a.produc_date,
  893. a.capacity,
  894. a.seq,
  895. a.user_id,
  896. a.attribute,
  897. a.storage_location_name,
  898. b.user_name,
  899. a.account_sleeve,
  900. a.entry_number
  901. from tld_warehousing_virtual a
  902. left join tld_user b on a.user_id = b.id
  903. where a.unique_code = #{uniqueCode}
  904. and a.type = #{type}
  905. and a.notice_id = #{noticeId}
  906. </select>
  907. <!-- 产成品入库流水 -->
  908. <select id="getHalf" resultType="com.tld.model.Notice">
  909. select
  910. a.id,
  911. a.wllb_code,
  912. a.produc_date,
  913. a.produc_batch,
  914. a.capacity,
  915. a.user_id,
  916. a.storage_location_code,
  917. e.storage_location_name as storageLocationName,
  918. a.scrq,
  919. a.serial,
  920. a.seq,
  921. a.attribute,
  922. b.name as materialName,
  923. c.user_name as userName,
  924. b.code as materialCode,
  925. a.storage_code,
  926. a.wbs,
  927. h.name as wbsName,
  928. c.real_name as realName,
  929. a.production_code as productionCode,
  930. a.account_sleeve as companyNumber,
  931. f.name as accountName
  932. from tld_half a
  933. left join tld_material b on a.wllb_code = b.code
  934. left join tld_user c on a.user_id = c.id
  935. left join tld_storage_location e on a.storage_location_code = e.storage_location_code
  936. left join tld_company f on a.account_sleeve = f.code
  937. left join tld_wbs h on a.wbs = h.tld_id
  938. <trim prefix="WHERE" prefixOverrides="and |or">
  939. <if test="startTime != null and startTime != ''">
  940. and a.scrq <![CDATA[>=]]> #{startTime}
  941. </if>
  942. <if test="endTime != null and endTime != ''">
  943. and a.scrq <![CDATA[<=]]> #{endTime}
  944. </if>
  945. <if test="materialName != null and materialName != ''">
  946. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  947. </if>
  948. <if test="wllbCode != null and wllbCode != ''">
  949. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  950. </if>
  951. <if test="userName != null and userName != ''">
  952. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  953. </if>
  954. <if test="realName != null and realName != ''">
  955. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  956. </if>
  957. <if test="attribute != null and attribute != ''">
  958. and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
  959. </if>
  960. <if test="storageCode != null and storageCode != ''">
  961. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  962. </if>
  963. <if test="wbs != null and wbs != ''">
  964. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  965. </if>
  966. <if test="storageLocationName != null and storageLocationName != ''">
  967. and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  968. </if>
  969. <if test="productionCode != null and productionCode != ''">
  970. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  971. </if>
  972. <if test="companyNumber != null and companyNumber != ''">
  973. and a.account_sleeve = #{companyNumber}
  974. </if>
  975. </trim>
  976. order by a.scrq desc
  977. </select>
  978. <!-- 产成品导出 -->
  979. <select id="getHalfExcel" resultType="java.util.LinkedHashMap">
  980. select
  981. b.name as materialName,
  982. a.wllb_code,
  983. if(a.produc_batch = '' , null , a.produc_batch) as producBatch,
  984. a.capacity,
  985. c.user_name as userName,
  986. a.storage_location_code,
  987. a.scrq,
  988. a.serial,
  989. if(a.attribute = '' , null , a.attribute) as attribute,
  990. a.storage_code,
  991. if(a.wbs = '' , null , a.wbs) as wbs,
  992. if(h.name = '' , null , h.name) as wbsName,
  993. c.real_name as realName,
  994. a.production_code as productionCode,
  995. f.name as accountName,
  996. a.account_sleeve as accountSleeve
  997. from tld_half a
  998. left join tld_material b on a.wllb_code = b.code
  999. left join tld_user c on a.user_id = c.id
  1000. left join tld_company f on a.account_sleeve = f.code
  1001. left join tld_wbs h on a.wbs = h.tld_id
  1002. <trim prefix="WHERE" prefixOverrides="and |or">
  1003. <if test="startTime != null and startTime != ''">
  1004. and a.scrq <![CDATA[>=]]> #{startTime}
  1005. </if>
  1006. <if test="endTime != null and endTime != ''">
  1007. and a.scrq <![CDATA[<=]]> #{endTime}
  1008. </if>
  1009. <if test="materialName != null and materialName != ''">
  1010. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  1011. </if>
  1012. <if test="wllbCode != null and wllbCode != ''">
  1013. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  1014. </if>
  1015. <if test="userName != null and userName != ''">
  1016. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  1017. </if>
  1018. <if test="realName != null and realName != ''">
  1019. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  1020. </if>
  1021. <if test="attribute != null and attribute != ''">
  1022. and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
  1023. </if>
  1024. <if test="storageCode != null and storageCode != ''">
  1025. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  1026. </if>
  1027. <if test="wbs != null and wbs != ''">
  1028. and h.name like CONCAT(CONCAT('%', #{wbs}), '%')
  1029. </if>
  1030. <if test="productionCode != null and productionCode != ''">
  1031. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  1032. </if>
  1033. <if test="storageLocationName != null and storageLocationName != ''">
  1034. and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  1035. </if>
  1036. <if test="companyNumber != null and companyNumber != ''">
  1037. and a.account_sleeve = #{companyNumber}
  1038. </if>
  1039. </trim>
  1040. order by a.scrq desc
  1041. </select>
  1042. <!-- 查询通知单虚拟库扫描数 -->
  1043. <select id="getSumScanNumVal" resultType="int">
  1044. SELECT ifnull(sum(a.num), 0)
  1045. FROM tld_warehousing_virtual a
  1046. left join tld_material b on a.wllb_code = b.code
  1047. WHERE a.notice_id = #{noticeId} and b.tld_id = #{materialId}
  1048. </select>
  1049. <!-- 修改报工单入库数量 -->
  1050. <update id="updateNotice">
  1051. update tld_notice
  1052. set warehousing_num = (warehousing_num + 0) + #{warehousingNum}
  1053. <if test="type != null and type != ''">
  1054. ,type = '1'
  1055. </if>
  1056. where notice_id = #{noticeId}
  1057. and material_id = #{materialId} and entry_number = #{entryNumber}
  1058. </update>
  1059. <!-- 查询产成品是否扫描 -->
  1060. <select id="getScanIsNotProduct" resultType="java.util.Map">
  1061. select (select count(*)
  1062. from tld_inventory
  1063. where attribute = #{attribute}
  1064. and serial = #{serial}
  1065. and wllb_code = #{materialCode}
  1066. and produc_date = #{producBatch}) as inventoryCount,
  1067. (select count(*)
  1068. from tld_warehousing_virtual
  1069. where attribute = #{attribute}
  1070. and serial = #{serial}
  1071. and wllb_code = #{materialCode}
  1072. and produc_date = #{producBatch}) as virtualCount
  1073. from dual
  1074. </select>
  1075. <!-- 查询昨天没满的库位 -->
  1076. <select id="getStorageLocationCode" resultType="String">
  1077. SELECT ifnull(max(storage_location_code), "0")
  1078. FROM tld_inventory
  1079. WHERE attribute = #{attribute} and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE() and material_id = #{materialId} and account_sleeve = #{companyNumber}
  1080. <if test="producBatch != null">
  1081. and produc_batch = #{producBatch}
  1082. </if>
  1083. ORDER BY scrq desc LIMIT 1
  1084. </select>
  1085. <select id="getCountStorage" resultType="int">
  1086. SELECT count(*)
  1087. FROM tld_inventory
  1088. where attribute = #{attribute}
  1089. and storage_location_code = #{storageLocationCode}
  1090. and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE()
  1091. and material_id = #{materialId}
  1092. <if test="producBatch != null">
  1093. and produc_batch = #{producBatch}
  1094. </if>
  1095. ORDER BY scrq desc LIMIT 1
  1096. </select>
  1097. <!-- 增加流水入库编号 -->
  1098. <update id="updateStorage">
  1099. update tld_storage
  1100. set storage_code = #{storageCode}
  1101. where wllb_code = #{wllbCode}
  1102. and supplier_id = #{suppId}
  1103. and serial = #{serial}
  1104. and produc_batch = #{producDate}
  1105. </update>
  1106. <!-- 查询公共设置 -->
  1107. <select id="getNumUtil" resultType="int">
  1108. select num
  1109. from tld_util
  1110. where type = #{type}
  1111. </select>
  1112. <!-- 其他入库 -->
  1113. <update id="updateInventoryOther">
  1114. update tld_inventory
  1115. set amount = (amount + 0) + #{amount}
  1116. where id = #{id}
  1117. </update>
  1118. <!-- 移库虚拟库入库 -->
  1119. <update id="updateVitrualNum">
  1120. update tld_inventory
  1121. set amount = amount + #{num}
  1122. where material_id = #{materialId}
  1123. and storage_location_code = #{storageLocationCode}
  1124. </update>
  1125. <!-- 其他入库返回gs -->
  1126. <insert id="addReturnWarehousingOther">
  1127. insert into tld_return_gs_other_warehousing
  1128. (storage_code, account_sleeve, storage_location_code, notice_id, notice_code,
  1129. amount,wbs,wbs_code,wbs_name,notice_time,warehouse_where,source_type,move_type,entry_number,wms_item_id,material_id,wms_id)
  1130. value
  1131. (#{storageCode},#{companyNumber},#{storageLocationCode},#{noticeId},#{noticeCode},#{num},#{wbs},#{code},#{name},
  1132. now(),#{warehouseWhere},#{sourceType},#{moveType},#{entryNumber},#{wmsItemId},#{materialId},#{wmsId})
  1133. </insert>
  1134. <!-- 其他入库 -->
  1135. <insert id="addInventoryOther">
  1136. insert into tld_inventory(storage_location_code, wllb_class, library_type, material_id, amount, totime,
  1137. amount_lock, account_sleeve, wbs, supplier_id, serial, wllb_code, produc_date, scrq,
  1138. produc_batch, attribute)
  1139. value (#{storageLocationCode},#{wllbClass},#{libraryType},#{materialId},#{amount},now(),'0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producDate},#{attribute})
  1140. </insert>
  1141. <!-- 查询扫描数量 -->
  1142. <select id="getSumWarehousingVirtual" resultType="java.util.Map">
  1143. select
  1144. (select ifnull(sum(num), 0) from tld_warehousing_virtual where receive_goods_id = #{receiveGoodsId}) as scanNum,
  1145. (select (qualified_num + 0) - ifnull((warehousing_num + 0), 0) from tld_receive_goods where id = #{receiveGoodsId}) as num
  1146. from dual
  1147. </select>
  1148. <!-- 查询扫描数量 -->
  1149. <select id="getWarehouseTransferVirtual" resultType="java.util.Map">
  1150. select
  1151. (select ifnull(sum(num), 0) from tld_warehousing_virtual where warehouse_transfer_id = #{warehouseTransferId} and wllb_code = #{wllbCode}) as scanNum,
  1152. (select (num + 0) - ifnull((out_num + 0), 0) from tld_warehouse_transfer where warehouse_transfer_id = #{warehouseTransferId} and material_id = #{materialId}) as num
  1153. from dual
  1154. </select>
  1155. <!-- 流水增加传输状态 -->
  1156. <update id="updateWarehousingType">
  1157. update tld_storage set transmission_type = #{type} where storage_code = #{storageCode}
  1158. </update>
  1159. <!-- 查询其他入库 -->
  1160. <select id="getNotices" resultType="com.tld.model.Notice">
  1161. select
  1162. b.notice_code,
  1163. b.notice_id,
  1164. b.company_number,
  1165. b.source_type,
  1166. b.move_type,
  1167. a.entry_number,
  1168. a.id as wmsItemId,
  1169. b.id as wmsId,
  1170. a.wbs,
  1171. c.code,
  1172. c.name,
  1173. a.entry_number
  1174. from tld_notices a
  1175. join tld_notices_f b on a.notice_id = b.notice_id
  1176. left join tld_wbs c on a.wbs = c.tld_id
  1177. where a.notice_id = #{noticeId} and a.entry_number = #{entryNumber} and a.material_id = #{materialId}
  1178. </select>
  1179. <!--查询删除信息-->
  1180. <select id="getOtherReceivingGoods" resultType="java.util.Map">
  1181. select * from tld_notices where id = #{id}
  1182. </select>
  1183. <!--查询删除信息-->
  1184. <select id="getOtherShipments" resultType="java.util.Map">
  1185. select * from tld_enquiry where id = #{id}
  1186. </select>
  1187. <!-- 往单据上增加数量 -->
  1188. <update id="updateNoticesWarehousingNum">
  1189. update tld_notices set warehousing_num = warehousing_num + #{amount} where notice_id = #{noticeId} and entry_number = #{entryNumber}
  1190. </update>
  1191. <!-- 查询库存是否存在此产成品 -->
  1192. <select id="getFinishedInfo" resultType="String">
  1193. select max(id) from tld_inventory where wllb_code = #{wllbCode} and wbs = #{wbs} and account_sleeve = #{accountSleeve} limit 1
  1194. </select>
  1195. <!-- 查询产成品入库虚拟表数量 -->
  1196. <select id="getnumSaoMiao" resultType="java.lang.String">
  1197. select ifnull(max(num), 0) from tld_warehousing_virtual where notice_id = #{noticeId} and entry_number = #{entryNumber}
  1198. </select>
  1199. </mapper>