AskGoodsMapper.xml 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  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.AskGoodsMapper">
  5. <!-- 查询要货单id+物料id是否存在 -->
  6. <select id="getAskGoods" resultType="int">
  7. select count(*)
  8. from tld_ask_goods
  9. where ask_goods_id = #{askGoodsId}
  10. and material_id = #{materialId}
  11. </select>
  12. <!-- 修改要料申请单数量 -->
  13. <update id="updateAskGoodsNum">
  14. update tld_ask_goods
  15. set num =#{num}
  16. where ask_goods_id = #{askGoodsId}
  17. and material_id = #{materialId}
  18. </update>
  19. <!-- 新增要料申请单 -->
  20. <insert id="addAskGoods">
  21. insert into tld_ask_goods(ask_goods_id, entry_number, production_code, material_id, wbs, measurement_id, num,
  22. type, out_num)
  23. values (#{askGoodsId}, #{entryNumber}, #{productionCode}, #{materialId}, #{wbs}, #{measurementId}, #{num},
  24. #{type}, '0')
  25. </insert>
  26. <!-- 新增要料日志 -->
  27. <insert id="addAskGoodsLog">
  28. insert into tld_ask_goods_log(ask_goods_id, entry_number, production_code, material_id, wbs, measurement_id,
  29. num, out_num, ask_goods_code, company_number, sqrq, department_id, source_type,
  30. move_type, ask_goods_type,request_type_number,request_type_name,if_commodity)
  31. values (#{askGoodsId}, #{entryNumber}, #{productionCode}, #{materialId}, #{wbs}, #{measurementId}, #{num},
  32. #{outNum}, #{askGoodsCode}, #{companyNumber}, #{sqrq}, #{departmentId}, #{sourceType}, #{moveType},
  33. #{askGoodsType},#{requestTypeNumber},#{requestTypeName},#{ifCommodity})
  34. </insert>
  35. <!-- 查询次要货单是否存在 -->
  36. <select id="getAskGoodsf" resultType="int">
  37. select count(*)
  38. from tld_ask_goods_f
  39. where ask_goods_id = #{askGoodsId}
  40. and ask_goods_code = #{askGoodsCode}
  41. </select>
  42. <!-- 新增要料申请单父级 -->
  43. <insert id="addAskGoodsf">
  44. insert into tld_ask_goods_f(ask_goods_id, ask_goods_code, company_number, sqrq, department, source_type,
  45. move_type,request_type_number,request_type_name,if_commodity)
  46. values (#{askGoodsId}, #{askGoodsCode}, #{companyNumber}, #{sqrq}, #{departmentId}, #{sourceType}, #{moveType},#{requestTypeNumber},#{requestTypeName},#{ifCommodity})
  47. </insert>
  48. <!-- 查询生产领料单 -->
  49. <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
  50. SELECT a.ask_goods_id,
  51. a.material_id,
  52. IFNULL(a.out_num, 0) AS num,
  53. e.NAME AS materialName,
  54. e.CODE AS materialCode,
  55. b.ask_goods_code,
  56. b.company_number,
  57. c.name as departmentName,
  58. g.name as companyName,
  59. b.source_type,
  60. b.move_type,
  61. a.entry_number,
  62. a.production_code,
  63. a.wbs
  64. FROM tld_ask_goods a
  65. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  66. LEFT JOIN tld_department c ON b.department = c.code
  67. JOIN tld_material e ON a.material_id = e.tld_id
  68. left join tld_company g on b.company_number = g.code
  69. WHERE (a.num + 0) <![CDATA[>]]> (
  70. IFNULL(a.out_num, 0) + 0)
  71. and e.part_type != '半成品' and e.part_type != '产成品'
  72. </select>
  73. <!-- 查询指定生产单的物料 -->
  74. <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
  75. SELECT a.ask_goods_id,
  76. a.material_id,
  77. a.num,
  78. IFNULL(a.out_num, 0) AS out_num,
  79. e.NAME AS materialName,
  80. e.CODE AS materialCode,
  81. b.ask_goods_code,
  82. b.company_number,
  83. c.name,
  84. c.code,
  85. c.id AS departmentId,
  86. a.production_code,
  87. a.wbs
  88. FROM tld_ask_goods a
  89. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  90. LEFT JOIN tld_department c ON b.department = c.code
  91. JOIN tld_material e ON a.material_id = e.tld_id
  92. WHERE (a.num + 0) <![CDATA[>]]> (
  93. IFNULL(a.out_num, 0) + 0)
  94. and e.part_type != '半成品' and e.part_type != '产成品'
  95. </select>
  96. <!-- 物料库位选择 -->
  97. <select id="getMaterialCk" resultType="com.tld.model.Inventory">
  98. select a.storage_location_code,
  99. a.wllb_class,
  100. a.library_type,
  101. a.material_id,
  102. (a.amount - ifnull(a.amount_lock, 0)) as amount,
  103. a.total,
  104. a.totime,
  105. a.hold,
  106. a.amount_lock,
  107. a.account_sleeve,
  108. a.wbs,
  109. a.supplier_id,
  110. a.serial,
  111. a.wllb_code,
  112. a.produc_date,
  113. a.scrq,
  114. b.storage_location_name as storageLocationName
  115. from tld_inventory a
  116. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  117. join tld_warehouse c on b.warehouse_where = c.tld_id
  118. where a.material_id = #{materialId}
  119. and a.account_sleeve = #{companyNumber}
  120. and a.hold = '0'
  121. and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2')
  122. order by a.produc_date
  123. </select>
  124. <!-- 新增出库虚拟表 -->
  125. <insert id="addAskGoodsVitrual">
  126. insert into tld_ask_goods_vitrual(unique_code, supplier_id, serial, wllb_code, produc_date, ask_goods_id, type,
  127. storage_location_code, num, user_id, department, attribute, account_sleeve,
  128. storage_location_code_rk, wbs)
  129. values (#{uniqueCode}, #{supplierId}, #{serial}, #{wllbCode}, #{producDate}, #{askGoodsId}, #{type},
  130. #{storageLocationCode}, #{num}, #{userId}, #{department}, #{attribute}, #{companyNumber},
  131. #{storageLocationCodeRk}, #{wbs})
  132. </insert>
  133. <!-- 查询指定库存内容 -->
  134. <select id="getInventory" resultType="com.tld.model.Inventory">
  135. select id,
  136. storage_location_code,
  137. wllb_class,
  138. library_type,
  139. material_id,
  140. amount,
  141. total,
  142. totime,
  143. hold,
  144. amount_lock,
  145. account_sleeve,
  146. wbs,
  147. supplier_id,
  148. serial,
  149. wllb_code,
  150. produc_date,
  151. scrq
  152. from tld_inventory
  153. where supplier_id = #{supplierId}
  154. and serial = #{serial}
  155. and wllb_code = #{wllbCode}
  156. and produc_date = #{producDate}
  157. and account_sleeve = #{companyNumber}
  158. <if test="wbs != null">
  159. and wbs = #{wbs}
  160. </if>
  161. </select>
  162. <!-- 查询指定库存内容 -->
  163. <select id="getInventoryWarehousing" resultType="com.tld.model.Inventory">
  164. select id,
  165. storage_location_code,
  166. wllb_class,
  167. library_type,
  168. material_id,
  169. amount,
  170. total,
  171. totime,
  172. hold,
  173. amount_lock,
  174. account_sleeve,
  175. wbs,
  176. supplier_id,
  177. serial,
  178. wllb_code,
  179. produc_date,
  180. scrq
  181. from tld_inventory
  182. where storage_location_code = #{storageLocationCode}
  183. and wllb_code = #{wllbCode}
  184. and account_sleeve = #{companyNumber}
  185. and wbs = #{wbs}
  186. </select>
  187. <!-- 查询库存是否充足 -->
  188. <select id="getAsk" resultType="com.tld.model.AskGoods">
  189. SELECT ifnull(sum(a.num), 0) as num
  190. FROM tld_ask_goods_vitrual a
  191. join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
  192. where a.storage_location_code = #{storageLocationCode}
  193. and a.serial = #{serial}
  194. </select>
  195. <!-- 查询是否扫描 -->
  196. <select id="getScanIsNot" resultType="java.util.Map">
  197. select (select ifnull(amount, 0)
  198. from tld_inventory
  199. where supplier_id = #{supplierId}
  200. and serial = #{serial}
  201. and wllb_code = #{wllbCode}
  202. and produc_date = #{producDate}) as inventoryNum,
  203. (select ifnull(sum(num), 0)
  204. from tld_ask_goods_vitrual
  205. where supplier_id = #{supplierId}
  206. and serial = #{serial}
  207. and wllb_code = #{wllbCode}
  208. and produc_date = #{producDate}
  209. and type = #{type}) as virtualNum
  210. from dual
  211. </select>
  212. <!-- 查询指定送货单信息 -->
  213. <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
  214. SELECT a.id,
  215. a.ask_goods_id,
  216. a.entry_number,
  217. a.production_code,
  218. a.material_id,
  219. a.wbs,
  220. a.measurement_id,
  221. a.num,
  222. ifnull(a.out_num, 0) as out_num
  223. FROM tld_ask_goods a
  224. join tld_material b on a.material_id = b.tld_id
  225. where a.ask_goods_id = #{askGoodsId}
  226. and b.code = #{wllbCode}
  227. </select>
  228. <!-- 查询指定移庫單 -->
  229. <select id="getWareInfo" resultType="com.tld.model.AskGoods">
  230. SELECT a.id,
  231. a.warehouse_transfer_id as askGoodsId,
  232. a.entry_number,
  233. a.material_id,
  234. a.wbs,
  235. a.measurement_id,
  236. a.num,
  237. ifnull(a.out_num, 0) as out_num
  238. FROM tld_warehouse_transfer a
  239. join tld_material b on a.material_id = b.tld_id
  240. where a.warehouse_transfer_id = #{askGoodsId}
  241. and b.code = #{wllbCode}
  242. </select>
  243. <!-- 查询已扫描总数 -->
  244. <select id="getAskInfoNumVitrual" resultType="int">
  245. select ifnull(sum(num), 0)
  246. from tld_ask_goods_vitrual
  247. where wllb_code = #{wllbCode}
  248. and ask_goods_id = #{askGoodsId}
  249. and type = #{type}
  250. </select>
  251. <!-- 查询此库存在虚拟表里占用的数量 -->
  252. <select id="getInventoryAlready" resultType="int">
  253. select ifnull(sum(num), 0)
  254. from tld_ask_goods_vitrual
  255. where supplier_id = #{supplierId}
  256. and serial = #{serial}
  257. and wllb_code = #{wllbCode}
  258. and produc_date = #{producDate}
  259. and type = #{type}
  260. </select>
  261. <!-- 查询虚拟表指定pda跟状态的的数据 -->
  262. <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
  263. select id,
  264. unique_code,
  265. supplier_id,
  266. serial,
  267. wllb_code,
  268. produc_date,
  269. ask_goods_id,
  270. type,
  271. storage_location_code,
  272. num,
  273. user_id,
  274. department,
  275. account_sleeve,
  276. wbs,
  277. storage_location_code_rk
  278. from tld_ask_goods_vitrual
  279. where unique_code = #{uniqueCode}
  280. and type = #{type}
  281. and ask_goods_id = #{askGoodsId}
  282. </select>
  283. <!-- 删除库存 -->
  284. <delete id="deleteInventory">
  285. delete
  286. from tld_inventory
  287. where id = #{id}
  288. </delete>
  289. <!-- 修改库存数量 -->
  290. <update id="updateInventory">
  291. UPDATE tld_inventory
  292. SET amount = amount - #{amount}
  293. WHERE id = #{id}
  294. </update>
  295. <!-- 删除虚拟表出库记录 -->
  296. <delete id="deleteVirtual">
  297. delete
  298. from tld_ask_goods_vitrual
  299. where id = #{id}
  300. </delete>
  301. <!-- 插入出库流水 -->
  302. <insert id="addRemoval">
  303. insert into tld_removal(wllb_code, supplier_id, serial, num, type, user_id, storage_location_code, scrq,
  304. process, ask_goods_id, produc_date, department, storage_code, wbs, account_sleeve,transmission_type)
  305. values (#{wllbCode}, #{supplierId}, #{serial}, #{num}, #{type}, #{userId}, #{storageLocationCode}, now(),
  306. #{process}, #{askGoodsId}, #{producDate}, #{department}, #{storageCode}, #{wbs}, #{companyNumber},'0')
  307. </insert>
  308. <!-- 查询指定物料类型的id -->
  309. <select id="getMaterialId" resultType="String">
  310. select tld_id
  311. from tld_material
  312. where code = #{wllbCode}
  313. </select>
  314. <!-- 查询要料申请单内容 -->
  315. <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
  316. select id,
  317. ask_goods_id,
  318. entry_number,
  319. production_code,
  320. material_id,
  321. wbs,
  322. measurement_id,
  323. num,
  324. out_num
  325. from tld_ask_goods
  326. where ask_goods_id = #{askGoodsId}
  327. and material_id = #{materialId}
  328. </select>
  329. <!-- 新增返回gs数据字表信息 -->
  330. <insert id="addReturnGsRemoval">
  331. insert into tld_return_gs_removal_z(material_id, wbs, num, entry_number, document_id, document_points_id,
  332. storage_location_code)
  333. values (#{materialId}, #{wbs}, #{num}, #{entryNumber}, #{documentId}, #{documentPointsId},
  334. #{storageLocationCode})
  335. </insert>
  336. <!-- 查询要货单父级信息 -->
  337. <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
  338. select id,
  339. ask_goods_id,
  340. ask_goods_code,
  341. company_number,
  342. sqrq,
  343. department,
  344. source_type,
  345. move_type
  346. from tld_ask_goods_f
  347. where ask_goods_id = #{askGoodsId}
  348. </select>
  349. <!-- 新增返回gs数据父表信息 -->
  350. <insert id="addReturnGsRemovalF">
  351. insert into tld_return_gs_removal(document_id, removal_code, source_type, move_type, scrq, delivery_type)
  352. values (#{documentId}, #{removalCode}, #{sourceType}, #{moveType}, now(), #{deliveryType})
  353. </insert>
  354. <!-- 添加 tld_access 记录-->
  355. <insert id="addAccess">
  356. insert into tld_access (type, data, scrq, access_type)
  357. values (#{names}, #{returnGsRemoval}, now(), #{accessType})
  358. </insert>
  359. <!-- 查询当天出库数量 -->
  360. <select id="getReturnRemovalCount" resultType="int">
  361. select count(*)
  362. from tld_return_gs_removal
  363. where scrq BETWEEN CONCAT(CURDATE(), ' 00:00:00') AND CONCAT(CURDATE(), ' 23:59:59');
  364. </select>
  365. <!-- 查询回传数据 -->
  366. <select id="plugOutRemoval" resultType="java.util.Map">
  367. select id,
  368. document_id as askGoodsId,
  369. removal_code as removalCode,
  370. source_type as sourceType,
  371. move_type as moveType,
  372. scrq
  373. from tld_return_gs_removal
  374. where document_id = #{removalCode}
  375. </select>
  376. <!-- 查询字表回传数据 -->
  377. <select id="getRemovalz" resultType="java.util.Map">
  378. SELECT a.material_id AS materialId,
  379. a.wbs,
  380. a.num,
  381. a.entry_number AS entryNumber,
  382. a.document_id AS askGoodsId,
  383. a.document_points_id AS askId,
  384. ifnull(a.wbs, '') as wbsId,
  385. ifnull(c.code, '') as wbsCode,
  386. ifnull(c.name, '') as wbsName
  387. FROM tld_return_gs_removal_z a
  388. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  389. left join tld_wbs c on a.wbs = c.tld_id
  390. WHERE a.document_id = #{askGoodsId}
  391. and b.warehouse_where = #{warehouseWhere}
  392. </select>
  393. <!-- 查询出库流水 -->
  394. <select id="getRemoval" resultType="com.tld.model.AskGoods">
  395. select
  396. a.id,
  397. b.name as materialName,
  398. a.wllb_code,
  399. h.name as supplierName,
  400. a.serial,
  401. a.type,
  402. c.user_name as userName,
  403. e.name as department,
  404. g.storage_location_name as storageLocationName,
  405. a.scrq,
  406. a.num,
  407. a.storage_code,
  408. a.wbs,
  409. a.ask_goods_id,
  410. c.real_name as realName,
  411. a.account_sleeve,
  412. f.name as accountName
  413. from tld_removal a
  414. left join tld_material b on a.wllb_code = b.code
  415. left join tld_user c on a.user_id = c.id
  416. left join tld_department e on a.department = e.code
  417. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  418. left join tld_customer h on a.supplier_id = h.code
  419. left join tld_company f on a.account_sleeve = f.code
  420. <trim prefix="WHERE" prefixOverrides="and |or">
  421. <if test="startTime != null and startTime != ''">
  422. and a.scrq <![CDATA[>=]]> #{startTime}
  423. </if>
  424. <if test="endTime != null and endTime != ''">
  425. and a.scrq <![CDATA[<=]]> #{endTime}
  426. </if>
  427. <if test="type != null and type != ''">
  428. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  429. </if>
  430. <if test="supplierId != null and supplierId != ''">
  431. and a.supplier_id = #{supplierId}
  432. </if>
  433. <if test="department != null and department != ''">
  434. and a.department = #{department}
  435. </if>
  436. <if test="storageCode != null and storageCode != ''">
  437. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  438. </if>
  439. <if test="storageLocationName != null and storageLocationName != ''">
  440. and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  441. </if>
  442. <if test="wllbCode != null and wllbCode != ''">
  443. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  444. </if>
  445. <if test="materialName != null and materialName != ''">
  446. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  447. </if>
  448. <if test="userName != null and userName != ''">
  449. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  450. </if>
  451. <if test="realName != null and realName != ''">
  452. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  453. </if>
  454. <if test="askGoodsId != null and askGoodsId != ''">
  455. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  456. </if>
  457. <if test="accountSleeve != null and accountSleeve != ''">
  458. and a.account_sleeve = #{accountSleeve}
  459. </if>
  460. </trim>
  461. order by a.id desc
  462. </select>
  463. <!-- 导出 -->
  464. <select id="export" resultType="java.util.LinkedHashMap">
  465. select
  466. b.name as materialName,
  467. if(h.name = '',null,h.name) as supplierName,
  468. if(a.serial = '',null,a.serial) as serial,
  469. a.type,
  470. c.user_name as userName,
  471. e.name as department,
  472. g.storage_location_name as storageLocationName,
  473. a.scrq,
  474. a.num,
  475. a.ask_goods_id,
  476. c.real_name,
  477. a.account_sleeve,
  478. f.name as accountName
  479. from tld_removal a
  480. left join tld_material b on a.wllb_code = b.code
  481. left join tld_user c on a.user_id = c.id
  482. left join tld_department e on a.department = e.code
  483. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  484. left join tld_customer h on a.supplier_id = h.code
  485. left join tld_company f on a.account_sleeve = f.code
  486. <trim prefix="WHERE" prefixOverrides="and |or">
  487. <if test="startTime != null and startTime != ''">
  488. and a.scrq <![CDATA[>=]]> #{startTime}
  489. </if>
  490. <if test="endTime != null and endTime != ''">
  491. and a.scrq <![CDATA[<=]]> #{endTime}
  492. </if>
  493. <if test="type != null and type != ''">
  494. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  495. </if>
  496. <if test="supplierId != null and supplierId != ''">
  497. and a.supplier_id = #{supplierId}
  498. </if>
  499. <if test="department != null and department != ''">
  500. and a.department = #{department}
  501. </if>
  502. <if test="storageCode != null and storageCode != ''">
  503. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  504. </if>
  505. <if test="storageLocationName != null and storageLocationName != ''">
  506. and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  507. </if>
  508. <if test="wllbCode != null and wllbCode != ''">
  509. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  510. </if>
  511. <if test="materialName != null and materialName != ''">
  512. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  513. </if>
  514. <if test="userName != null and userName != ''">
  515. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  516. </if>
  517. <if test="realName != null and realName != ''">
  518. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  519. </if>
  520. <if test="askGoodsId != null and askGoodsId != ''">
  521. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  522. </if>
  523. <if test="accountSleeve != null and accountSleeve != ''">
  524. and a.account_sleeve = #{accountSleeve}
  525. </if>
  526. </trim>
  527. order by a.id desc
  528. </select>
  529. <!-- 查询指定pda出库虚拟表 -->
  530. <select id="getAskGoodsVitrual" resultType="com.tld.model.AskGoods">
  531. select id,
  532. unique_code,
  533. supplier_id,
  534. serial,
  535. wllb_code,
  536. produc_date,
  537. ask_goods_id,
  538. type,
  539. storage_location_code,
  540. num,
  541. user_id,
  542. department,
  543. account_sleeve,
  544. wbs,
  545. attribute
  546. from tld_ask_goods_vitrual
  547. where unique_code = #{uniqueCode}
  548. and type = #{type}
  549. </select>
  550. <!-- 删除指定虚拟表数据 -->
  551. <delete id="delAskGoodsVitrual">
  552. delete
  553. from tld_ask_goods_vitrual
  554. where id = #{id}
  555. and type = #{type}
  556. </delete>
  557. <!-- 删除出库回传主表信息 -->
  558. <delete id="delPlugOutRemoval">
  559. delete
  560. from tld_return_gs_removal
  561. where document_id = #{removalCode}
  562. </delete>
  563. <!-- 删除出库回传子表信息 -->
  564. <delete id="delRemovalz">
  565. delete
  566. from tld_return_gs_removal_z
  567. where document_id = #{removalCode}
  568. </delete>
  569. <!-- 删除入库回传信息 -->
  570. <delete id="delPlugOutWarehousing">
  571. delete
  572. from tld_return_gs_warehousing
  573. where order_number = #{orderNumber}
  574. </delete>
  575. <!-- 修改出库数量 -->
  576. <update id="updateOutNum">
  577. update tld_ask_goods
  578. set out_num = ifnull(out_num, 0) + #{num}
  579. where material_id = #{materialId}
  580. and ask_goods_id = #{askGoodsId}
  581. </update>
  582. <!-- 查询指定pda 指定物料扫描总数 -->
  583. <select id="getScanNum" resultType="String">
  584. select if(sum(num) is null, 0, num)
  585. from tld_ask_goods_vitrual
  586. where unique_code = #{uniqueCode}
  587. and ask_goods_id = #{askGoodsId}
  588. and wllb_code = #{wllbCode}
  589. </select>
  590. <!-- 查询半成品出库数据 -->
  591. <select id="getGoodsHalf" resultType="com.tld.model.AskGoods">
  592. SELECT
  593. a.id,
  594. a.material_id,
  595. a.num,
  596. a.production_code,
  597. b.name as materialName,
  598. b.code as materialCode,
  599. a.out_num,
  600. a.ask_goods_id,
  601. c.company_number,
  602. e.name as department,
  603. a.type,
  604. a.wbs,
  605. a.entry_number,
  606. g.name as companyName,
  607. c.source_type,
  608. c.move_type,
  609. c.sqrq
  610. FROM
  611. tld_ask_goods a
  612. join tld_material b on a.material_id = b.tld_id
  613. join tld_ask_goods_f c on a.ask_goods_id = c.ask_goods_id
  614. left join tld_department e on c.department = e.code
  615. left join tld_company g on b.company_number = g.code
  616. WHERE
  617. -- (a.num + 0) <![CDATA[>]]> (a.out_num + 0)
  618. b.part_type = #{partType}
  619. <if test="productionCode != null and productionCode != ''">
  620. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  621. </if>
  622. <if test="askGoodsId != null and askGoodsId != ''">
  623. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  624. </if>
  625. <if test="id != null and id != ''">
  626. and a.id = #{id}
  627. </if>
  628. <if test="type != null and type != ''">
  629. and a.type = #{type}
  630. </if>
  631. <if test="startTime != null and startTime != ''">
  632. and c.sqrq <![CDATA[>=]]> #{startTime}
  633. </if>
  634. <if test="endTime != null and endTime != ''">
  635. and c.sqrq <![CDATA[<=]]> #{endTime}
  636. </if>
  637. <if test="materialName != null and materialName != ''">
  638. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  639. </if>
  640. <if test="materialCode != null and materialCode != ''">
  641. and b.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  642. </if>
  643. <if test="departmentCode != null and departmentCode != ''">
  644. and c.department = #{departmentCode}
  645. </if>
  646. <if test="companyCode != null and companyCode != ''">
  647. and c.company_number = #{companyCode}
  648. </if>
  649. <if test="entryNumber != null and entryNumber != ''">
  650. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  651. </if>
  652. <if test="sourceType != null and sourceType != ''">
  653. and c.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  654. </if>
  655. <if test="moveType != null and moveType != ''">
  656. and c.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  657. </if>
  658. order by a.id desc
  659. </select>
  660. <!-- 查询半成品出库流水 -->
  661. <select id="getRemovalHalfProduct" resultType="com.tld.model.AskGoods">
  662. select
  663. a.id,
  664. a.wllb_code,
  665. a.num,
  666. a.user_id,
  667. a.scrq,
  668. a.ask_goods_id,
  669. c.name as department,
  670. b.name as materialName,
  671. e.user_name as userName,
  672. b.code as materialCode,
  673. a.storage_code,
  674. a.wbs,
  675. e.real_name as realName,
  676. a.account_sleeve,
  677. f.name as accountName
  678. from tld_removal_half_product a
  679. left join tld_material b on a.wllb_code = b.code
  680. left join tld_department c on a.department = c.code
  681. left join tld_user e on a.user_id = e.id
  682. left join tld_company f on a.account_sleeve = f.code
  683. <trim prefix="WHERE" prefixOverrides="and |or">
  684. <if test="wllbCode != null and wllbCode != ''">
  685. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  686. </if>
  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="departmentCode != null and departmentCode != ''">
  694. and a.department = #{departmentCode}
  695. </if>
  696. <if test="materialName != null and materialName != ''">
  697. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  698. </if>
  699. <if test="userName != null and userName != ''">
  700. and e.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  701. </if>
  702. <if test="realName != null and realName != ''">
  703. and e.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  704. </if>
  705. <if test="askGoodsId != null and askGoodsId != ''">
  706. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  707. </if>
  708. <if test="storageCode != null and storageCode != ''">
  709. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  710. </if>
  711. <if test="wbs != null and wbs != ''">
  712. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  713. </if>
  714. <if test="accountSleeve != null and accountSleeve != ''">
  715. and a.account_sleeve = #{accountSleeve}
  716. </if>
  717. </trim>
  718. order by a.scrq desc
  719. </select>
  720. <!-- 查询半成品出库流水导出 -->
  721. <select id="getRemovalHalfProductExcel" resultType="java.util.LinkedHashMap">
  722. select
  723. if(a.ask_goods_id = '' , null , a.ask_goods_id ) as askGoodsId,
  724. a.storage_code as storageCode,
  725. a.wllb_code as wllbCode,
  726. b.name as materialName,
  727. a.num,
  728. e.user_name as userName,
  729. c.name as department,
  730. a.wbs,
  731. a.scrq,
  732. e.real_name as realName,
  733. f.name as accountName
  734. from tld_removal_half_product a
  735. left join tld_material b on a.wllb_code = b.code
  736. left join tld_department c on a.department = c.code
  737. left join tld_user e on a.user_id = e.id
  738. left join tld_company f on a.account_sleeve = f.code
  739. <trim prefix="WHERE" prefixOverrides="and |or">
  740. <if test="wllbCode != null and wllbCode != ''">
  741. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  742. </if>
  743. <if test="startTime != null and startTime != ''">
  744. and a.scrq <![CDATA[>=]]> #{startTime}
  745. </if>
  746. <if test="endTime != null and endTime != ''">
  747. and a.scrq <![CDATA[<=]]> #{endTime}
  748. </if>
  749. <if test="departmentCode != null and departmentCode != ''">
  750. and a.department = #{departmentCode}
  751. </if>
  752. <if test="materialName != null and materialName != ''">
  753. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  754. </if>
  755. <if test="userName != null and userName != ''">
  756. and e.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  757. </if>
  758. <if test="realName != null and realName != ''">
  759. and e.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  760. </if>
  761. <if test="askGoodsId != null and askGoodsId != ''">
  762. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  763. </if>
  764. <if test="storageCode != null and storageCode != ''">
  765. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  766. </if>
  767. <if test="wbs != null and wbs != ''">
  768. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  769. </if>
  770. <if test="accountSleeve != null and accountSleeve != ''">
  771. and a.account_sleeve = #{accountSleeve}
  772. </if>
  773. </trim>
  774. order by a.scrq desc
  775. </select>
  776. <!-- 产成品出库流水 -->
  777. <select id="getRemovalHalf" resultType="com.tld.model.AskGoods">
  778. select
  779. a.id,
  780. a.wllb_code,
  781. a.num,
  782. a.user_id,
  783. a.scrq,
  784. a.delivery_id,
  785. a.company_number,
  786. a.customer_code,
  787. b.name as materialName,
  788. c.user_name as userName,
  789. e.name as customerName,
  790. f.name as companyName,
  791. b.code as materialCode,
  792. a.storage_code,
  793. a.wbs,
  794. c.real_name as realName
  795. from tld_removal_half a
  796. left join tld_material b on a.wllb_code = b.code
  797. left join tld_user c on a.user_id = c.id
  798. left join tld_customer e on a.customer_code = e.code
  799. left join tld_company f on a.company_number = f.code
  800. <trim prefix="WHERE" prefixOverrides="and |or">
  801. <if test="wllbCode != null and wllbCode != ''">
  802. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  803. </if>
  804. <if test="materialName != null and materialName != ''">
  805. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  806. </if>
  807. <if test="userName != null and userName != ''">
  808. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  809. </if>
  810. <if test="realName != null and realName != ''">
  811. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  812. </if>
  813. <if test="deliveryId != null and deliveryId != ''">
  814. and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
  815. </if>
  816. <if test="companyCode != null and companyCode != ''">
  817. and a.company_number = #{companyCode}
  818. </if>
  819. <if test="customerCode != null and customerCode != ''">
  820. and a.customer_code = #{customerCode}
  821. </if>
  822. <if test="storageCode != null and storageCode != ''">
  823. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  824. </if>
  825. <if test="wbs != null and wbs != ''">
  826. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  827. </if>
  828. <if test="startTime != null and startTime != ''">
  829. and a.scrq <![CDATA[>=]]> #{startTime}
  830. </if>
  831. <if test="endTime != null and endTime != ''">
  832. and a.scrq <![CDATA[<=]]> #{endTime}
  833. </if>
  834. </trim>
  835. order by a.scrq desc
  836. </select>
  837. <!-- 产成品导出出库流水 -->
  838. <select id="getRemovalHalfExcel" resultType="java.util.LinkedHashMap">
  839. select
  840. b.name as materialName,
  841. a.num,
  842. c.user_name as userName,
  843. a.scrq,
  844. f.name as companyName,
  845. e.name,
  846. a.storage_code,
  847. a.wbs,
  848. c.real_name as realName
  849. from tld_removal_half a
  850. left join tld_material b on a.wllb_code = b.code
  851. left join tld_user c on a.user_id = c.id
  852. left join tld_customer e on a.customer_code = e.code
  853. left join tld_company f on a.company_number = f.tld_id
  854. <trim prefix="WHERE" prefixOverrides="and |or">
  855. <if test="wllbCode != null and wllbCode != ''">
  856. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  857. </if>
  858. <if test="materialName != null and materialName != ''">
  859. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  860. </if>
  861. <if test="userName != null and userName != ''">
  862. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  863. </if>
  864. <if test="realName != null and realName != ''">
  865. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  866. </if>
  867. <if test="deliveryId != null and deliveryId != ''">
  868. and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
  869. </if>
  870. <if test="companyCode != null and companyCode != ''">
  871. and a.company_number = #{companyCode}
  872. </if>
  873. <if test="customerCode != null and customerCode != ''">
  874. and a.customer_code = #{customerCode}
  875. </if>
  876. <if test="storageCode != null and storageCode != ''">
  877. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  878. </if>
  879. <if test="wbs != null and wbs != ''">
  880. and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
  881. </if>
  882. <if test="startTime != null and startTime != ''">
  883. and a.scrq <![CDATA[>=]]> #{startTime}
  884. </if>
  885. <if test="endTime != null and endTime != ''">
  886. and a.scrq <![CDATA[<=]]> #{endTime}
  887. </if>
  888. </trim>
  889. order by a.scrq desc
  890. </select>
  891. <!-- 查询指定物料的库存 -->
  892. <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
  893. select
  894. id,
  895. storage_location_code,
  896. wllb_class,
  897. library_type,
  898. material_id,
  899. amount,
  900. total,
  901. totime,
  902. hold,
  903. amount_lock,
  904. account_sleeve,
  905. wbs,
  906. supplier_id,
  907. serial,
  908. wllb_code,
  909. produc_date,
  910. scrq,
  911. produc_batch,
  912. attribute
  913. from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and
  914. account_sleeve = #{accountSleeve} and amount <![CDATA[>=]]> #{num}
  915. <if test="wbs != null">
  916. and wbs = #{wbs}
  917. </if>
  918. <if test="storageLocationCode != '' and storageLocationCode != null">
  919. and storage_location_code = #{storageLocationCode}
  920. </if>
  921. <if test="serial != '' and serial != null">
  922. and serial = #{serial}
  923. </if>
  924. <if test="attribute != '' and attribute != null">
  925. and attribute = #{attribute}
  926. </if>
  927. <if test="producDate != '' and producDate != null">
  928. and produc_batch = #{producDate}
  929. </if>
  930. <if test="supplierId != '' and supplierId != null">
  931. and supplier_id = #{supplierId}
  932. </if>
  933. </select>
  934. <!-- 其他入库查询库存是否存在 -->
  935. <select id="getInventoryInfoOther" resultType="com.tld.model.Inventory">
  936. select
  937. a.id,
  938. a.storage_location_code,
  939. a.wllb_class,
  940. a.library_type,
  941. a.material_id,
  942. a.amount,
  943. a.total,
  944. a.totime,
  945. a.hold,
  946. a.amount_lock,
  947. a.account_sleeve,
  948. a.wbs,
  949. a.supplier_id,
  950. a.serial,
  951. a.wllb_code,
  952. a.produc_date,
  953. a.scrq,
  954. a.produc_batch,
  955. a.attribute,
  956. b.name as accountName,
  957. c.storage_location_name as storageLocationName,
  958. c.warehouse_where as warehouseWhere
  959. from tld_inventory a
  960. left join tld_company b on a.account_sleeve = b.code
  961. left join tld_storage_location c on a.storage_location_code = c.storage_location_code
  962. where material_id = #{materialId}
  963. <if test="wbs != '' and wbs != null">
  964. and a.wbs = #{wbs}
  965. </if>
  966. <if test="serial != '' and serial != null">
  967. and a.serial = #{serial}
  968. </if>
  969. <if test="attribute != '' and attribute != null">
  970. and a.attribute = #{attribute}
  971. </if>
  972. <if test="producDate != '' and producDate != null">
  973. and a.produc_batch = #{producDate}
  974. </if>
  975. <if test="supplierId != '' and supplierId != null">
  976. and a.supplier_id = #{supplierId}
  977. </if>
  978. <if test="storageLocationCode != '' and storageLocationCode != null">
  979. and a.storage_location_code = #{storageLocationCode}
  980. </if>
  981. <if test="accountSleeve != '' and accountSleeve != null">
  982. and a.account_sleeve = #{accountSleeve}
  983. </if>
  984. </select>
  985. <!-- 查询仓库 -->
  986. <select id="getWarehouseWhere" resultType="String">
  987. SELECT DISTINCT b.warehouse_where
  988. FROM tld_return_gs_removal_z a
  989. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  990. WHERE a.document_id = #{removalCode}
  991. </select>
  992. <!-- 查询半成品原始数据 -->
  993. <select id="getInventoryNotice" resultType="java.util.Map">
  994. select *
  995. from tld_notice
  996. where id = #{id}
  997. </select>
  998. <!-- 删除半成品/产成品入库通知原始信息 -->
  999. <delete id="delInventoryNotice">
  1000. delete
  1001. from tld_notice
  1002. where id = #{id}
  1003. </delete>
  1004. <!-- 查询要料申请单 -->
  1005. <select id="getDelAskGoods" resultType="java.util.Map">
  1006. select *
  1007. from tld_ask_goods
  1008. where id = #{id}
  1009. </select>
  1010. <!-- 销售发货单接口文档 父表信息 -->
  1011. <select id="getGsRemoval" resultType="java.util.Map">
  1012. select id,
  1013. document_id as askGoodsId,
  1014. removal_code as removalCode,
  1015. source_type as sourceType,
  1016. move_type as moveType,
  1017. scrq
  1018. from tld_return_gs_removal
  1019. where document_id = #{removalCode}
  1020. </select>
  1021. <!--查询移库子表中的供货仓库仓库-->
  1022. <select id="getSupplyWarehouseWhere" resultType="java.lang.String">
  1023. SELECT supply_warehouse_id
  1024. FROM tld_return_warehouse_transfer_z
  1025. WHERE warehouse_transfer_id = #{removalCode}
  1026. GROUP BY supply_warehouse_id
  1027. </select>
  1028. <!--查询移库父表信息-->
  1029. <select id="getReturnWarehouseTransfer" resultType="java.util.Map">
  1030. select id,
  1031. warehouse_transfer_id as warehouseTransferId,
  1032. warehouse_transfer_code as warehouseTransferCode,
  1033. ask_goods_warehouse_id as askGoodsWarehouseId,
  1034. warehouse_transfer_type as warehouseTransferType,
  1035. scrq
  1036. from tld_return_warehouse_transfer
  1037. where warehouse_transfer_code = #{removalCode}
  1038. </select>
  1039. <!--查询出父表中的移库id根据code-->
  1040. <select id="getSupplyWarehouseWheres" resultType="java.lang.String">
  1041. select warehouse_transfer_id as warehouseTransferId
  1042. from tld_return_warehouse_transfer
  1043. where warehouse_transfer_code = #{removalCode}
  1044. </select>
  1045. <!--查询移库子表信息-->
  1046. <select id="getReturnWarehouseTransferZ" resultType="java.util.Map">
  1047. select a.id,
  1048. a.warehouse_transfer_id as warehouseTransferId,
  1049. a.entry_number as entryNumber,
  1050. a.supply_warehouse_id as supplyWarehouseId,
  1051. a.material_id as materialId,
  1052. ifnull(a.wbs, '') as wbsId,
  1053. a.out_num as outNum,
  1054. ifnull(b.code, '') as wbsCode,
  1055. ifnull(b.name, '') as wbsName
  1056. from tld_return_warehouse_transfer_z a
  1057. left join tld_wbs b on a.wbs = b.tld_id
  1058. where a.warehouse_transfer_id = #{warehouseTransferId}
  1059. and a.supply_warehouse_id = #{warehouseWhere}
  1060. </select>
  1061. <!-- 删除生产领料 -->
  1062. <delete id="delAskGoods">
  1063. delete
  1064. from tld_ask_goods
  1065. where id = #{id}
  1066. </delete>
  1067. <!--删除移库父表-->
  1068. <delete id="delReturnWarehouseTransfer">
  1069. delete
  1070. from tld_return_warehouse_transfer
  1071. where warehouse_transfer_code = #{removalCode}
  1072. </delete>
  1073. <!--删除移库子表-->
  1074. <delete id="delReturnWarehouseTransferZ">
  1075. delete
  1076. from tld_return_warehouse_transfer_z
  1077. where warehouse_transfer_id = #{warehouseTransferTd}
  1078. </delete>
  1079. <!--删除移库父表-->
  1080. <delete id="delNoticeParent">
  1081. delete
  1082. from tld_notice_f
  1083. where notice_id = #{orderNumber}
  1084. </delete>
  1085. <!--删除移库子表-->
  1086. <delete id="delNoticeSubtabulation">
  1087. delete
  1088. from tld_notice
  1089. where notice_id = #{orderNumber}
  1090. </delete>
  1091. <!--删除其它入库父表信息-->
  1092. <delete id="delNoticesParent">
  1093. delete
  1094. from tld_notices_f
  1095. where notice_id = #{noticeId}
  1096. </delete>
  1097. <!--删除其它入库子表信息-->
  1098. <delete id="delNoticesSubtabulation">
  1099. delete
  1100. from tld_notices
  1101. where notice_id = #{noticeId}
  1102. </delete>
  1103. <!-- 查询名牌物料CODE -->
  1104. <select id="getMing" resultType="String">
  1105. select wllb_code from tld_mingpai where code = #{code}
  1106. </select>
  1107. <!--查询入库单信息-->
  1108. <select id="getReturnGsWarehousing" resultType="com.tld.model.ReturnWarehousing">
  1109. select
  1110. id,
  1111. storage_code,
  1112. gs_ck,
  1113. source_type,
  1114. move_type,
  1115. entry_number,
  1116. wbs,
  1117. material_id,
  1118. warehousing_num,
  1119. receive_goods_id,
  1120. scrq,
  1121. order_number,
  1122. user_name,
  1123. storage_location_code
  1124. from tld_return_gs_warehousing where storage_code = #{removalCode}
  1125. </select>
  1126. <!--根据库位查询仓库-->
  1127. <select id="getStorageLocationWarehouseWhere" resultType="java.lang.String">
  1128. select warehouse_where as warehouseWhere from tld_storage_location where storage_location_code = #{storageLocationCode}
  1129. </select>
  1130. <!--查询父表信息-->
  1131. <select id="getNoticeParent" resultType="java.util.Map">
  1132. select
  1133. id as id,
  1134. notice_id as noticeId,
  1135. notice_code as noticeCode,
  1136. company_number as companyNumber,
  1137. notice_time as noticeTime,
  1138. source_type as sourceType,
  1139. move_type as moveType
  1140. from tld_notice_f where notice_id = #{orderNumber}
  1141. </select>
  1142. <!--查询子表信息-->
  1143. <select id="getNoticeSubtabulation" resultType="java.util.Map">
  1144. select
  1145. a.id as id,
  1146. a.notice_id as noticeId,
  1147. a.entry_number as entryNumber,
  1148. a.production_code as productionCode,
  1149. a.material_id as materialId,
  1150. ifnull(a.wbs, '') as wbsId,
  1151. a.measurement_id as measurementId,
  1152. a.num as num,
  1153. a.type as type,
  1154. a.warehousing_num as warehousingNum,
  1155. ifnull(b.code, '') as wbsCode,
  1156. ifnull(b.name, '') as wbsName
  1157. from tld_notice a
  1158. left join tld_wbs b on a.wbs = b.tld_id
  1159. where a.notice_id = #{orderNumber}
  1160. </select>
  1161. <!--查询库存数量-->
  1162. <select id="getAmount" resultType="java.lang.String">
  1163. select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
  1164. </select>
  1165. <!--根据入库单编号查询入库单信息-->
  1166. <select id="getReturnGsOtherWarehousing" resultType="com.tld.model.ReturnWarehousing">
  1167. select
  1168. distinct
  1169. id,
  1170. storage_code,
  1171. account_sleeve,
  1172. storage_location_code,
  1173. wbs,
  1174. amount,
  1175. material_id,
  1176. notice_id
  1177. from tld_return_gs_other_warehousing where storage_code = #{removalCode}
  1178. group by notice_id
  1179. </select>
  1180. <!--查询其他入库表信息-->
  1181. <select id="getNoticesParent" resultType="java.util.Map">
  1182. SELECT
  1183. a.id as id,
  1184. a.storage_code as storageCde,
  1185. a.account_sleeve as accountSleeve,
  1186. a.storage_location_code as storageLocationCode,
  1187. a.notice_id as noticeId,
  1188. a.notice_code as noticeCode,
  1189. a.amount as amount,
  1190. ifnull(a.wbs, '') as wbsId,
  1191. ifnull(a.wbs_code, '') as wbsCode,
  1192. ifnull(a.wbs_name, '') as wbsName,
  1193. a.notice_time as noticeTime,
  1194. a.source_type as sourceType,
  1195. a.move_type as moveType,
  1196. a.entry_number as entryNumber,
  1197. a.wms_item_id as wmsItemId,
  1198. a.material_id as materialId,
  1199. a.wms_id as wmsId,
  1200. b.warehouse_where as warehouseWhere
  1201. FROM tld_return_gs_other_warehousing a
  1202. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1203. WHERE a.storage_code = #{noticeId} and a.storage_location_code = #{storageLocationCode}
  1204. </select>
  1205. <!--查询其他入库子表信息-->
  1206. <select id="getNoticesSubtabulation" resultType="java.util.Map">
  1207. select
  1208. a.id as id,
  1209. a.notice_id as noticeId,
  1210. a.entry_number as entryNumber,
  1211. a.material_id as materialId,
  1212. ifnull(a.wbs, '') as wbsId,
  1213. a.measurement_id as measurementId,
  1214. a.num as num,
  1215. a.type as type,
  1216. a.warehousing_num as warehousingNum,
  1217. ifnull(b.code, '') as wbsCode,
  1218. ifnull(b.name, '') as wbsName
  1219. from tld_notices a
  1220. left join tld_wbs b on a.wbs = b.tld_id
  1221. join tld_storage_location c on a.storage_location_code = c.storage_location_code
  1222. where a.notice_id = #{noticeId}
  1223. </select>
  1224. <!--查询仓库信息-->
  1225. <select id="getCreateOtherInStockWarehouseWhere" resultType="java.util.Map">
  1226. SELECT
  1227. a.id as id,
  1228. a.storage_code as storageCde,
  1229. a.account_sleeve as accountSleeve,
  1230. a.storage_location_code as storageLocationCode,
  1231. a.notice_id as noticeId,
  1232. a.notice_code as noticeCode,
  1233. a.amount as amount,
  1234. ifnull(a.wbs, '') as wbsId,
  1235. ifnull(a.wbs_code, '') as wbsCode,
  1236. ifnull(a.wbs_name, '') as wbsName,
  1237. a.notice_time as noticeTime,
  1238. a.source_type as sourceType,
  1239. a.move_type as moveType,
  1240. a.entry_number as entryNumber,
  1241. a.wms_item_id as wmsItemId,
  1242. a.material_id as materialId,
  1243. a.wms_id as wmsId,
  1244. b.warehouse_where as warehouseWhere
  1245. FROM tld_return_gs_other_warehousing a
  1246. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1247. WHERE a.storage_code = #{removalCode}
  1248. group by b.warehouse_where
  1249. </select>
  1250. <!-- 修改数据传输状态 -->
  1251. <update id="updateRemoval">
  1252. update tld_removal set transmission_type = "1" where storage_code = #{removalCode}
  1253. </update>
  1254. <!-- 修改数据传输状态 -->
  1255. <update id="updateRemovalHalfProduct">
  1256. update tld_removal_half_product set transmission_type = "1" where storage_code = #{removalCode}
  1257. </update>
  1258. <!-- 修改数据传输状态 -->
  1259. <update id="updateRemovalHalf">
  1260. update tld_removal_half set transmission_type = "1" where storage_code = #{removalCode}
  1261. </update>
  1262. </mapper>