AskGoodsMapper.xml 56 KB

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