AskGoodsMapper.xml 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737
  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. w.name as wbsName
  65. FROM tld_ask_goods a
  66. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  67. LEFT JOIN tld_department c ON b.department = c.code
  68. JOIN tld_material e ON a.material_id = e.tld_id
  69. left join tld_company g on b.company_number = g.code
  70. left join tld_wbs w on a.wbs = w.tld_id
  71. WHERE (a.num + 0) <![CDATA[>]]> (
  72. IFNULL(a.out_num, 0) + 0)
  73. and e.part_type != '半成品' and e.part_type != '产成品'
  74. </select>
  75. <!-- 查询指定生产单的物料 -->
  76. <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
  77. SELECT a.ask_goods_id,
  78. a.material_id,
  79. a.num,
  80. IFNULL(a.out_num, 0) AS out_num,
  81. e.NAME AS materialName,
  82. e.CODE AS materialCode,
  83. e.part_type as partType,
  84. b.ask_goods_code,
  85. b.company_number,
  86. b.sqrq,
  87. c.name,
  88. c.code,
  89. c.id AS departmentId,
  90. a.production_code,
  91. a.wbs,
  92. a.entry_number,
  93. e.wllb_class,
  94. a.wbs,
  95. f.name as wbsCode
  96. FROM tld_ask_goods a
  97. JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
  98. LEFT JOIN tld_department c ON b.department = c.code
  99. JOIN tld_material e ON a.material_id = e.tld_id
  100. LEFT JOIN tld_wbs f ON a.wbs = f.tld_id
  101. WHERE ((a.num + 0) <![CDATA[>]]> (
  102. IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
  103. and e.part_type != '半成品' and e.part_type != '产成品'
  104. and a.ask_goods_id = #{askGoodsId} and e.code in (select material_id from tld_user_material where user_id = #{userId})
  105. </select>
  106. <!-- 查询指定生产单的物料 -->
  107. <select id="getAskGoodsMaterialTest" resultType="com.tld.model.AskGoods">
  108. SELECT a.ask_goods_id,
  109. a.material_id,
  110. a.num,
  111. IFNULL(a.out_num, 0) AS out_num,
  112. e.NAME AS materialName,
  113. e.CODE AS materialCode,
  114. e.part_type as partType,
  115. b.ask_goods_code,
  116. b.company_number,
  117. b.sqrq,
  118. c.name,
  119. c.code,
  120. c.id AS departmentId,
  121. a.production_code,
  122. a.wbs,
  123. a.entry_number,
  124. e.wllb_class,
  125. b.sqrq
  126. FROM tld_invite a
  127. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  128. LEFT JOIN tld_department c ON b.department = c.code
  129. JOIN tld_material e ON a.material_id = e.tld_id
  130. WHERE (a.num + 0) <![CDATA[>]]> (
  131. IFNULL(a.out_num, 0) + 0) and b.sqrq > '2023-05-12'
  132. </select>
  133. <!-- 物料库位选择 -->
  134. <select id="getMaterialCk" resultType="com.tld.model.Inventory">
  135. select
  136. a.id,
  137. a.storage_location_code,
  138. a.wllb_class,
  139. a.library_type,
  140. a.material_id,
  141. (a.amount - ifnull(a.amount_lock, 0)) as amount,
  142. a.total,
  143. a.totime,
  144. a.hold,
  145. a.amount_lock,
  146. a.account_sleeve,
  147. a.wbs,
  148. a.supplier_id,
  149. a.serial,
  150. a.wllb_code,
  151. a.produc_date,
  152. a.scrq,
  153. b.storage_location_name as storageLocationName
  154. from tld_inventory a
  155. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  156. join tld_warehouse c on b.warehouse_where = c.tld_id
  157. where a.material_id = #{materialId}
  158. and a.account_sleeve = #{companyNumber}
  159. and a.hold = '0'
  160. and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2')
  161. and a.wbs = #{wbs}
  162. order by a.produc_batch
  163. </select>
  164. <!-- 新增出库虚拟表 -->
  165. <insert id="addAskGoodsVitrual">
  166. insert into tld_ask_goods_vitrual(unique_code, supplier_id, serial, wllb_code, produc_date, ask_goods_id, type,
  167. storage_location_code, num, user_id, department, attribute, account_sleeve,
  168. storage_location_code_rk, wbs, entry_number)
  169. values (#{uniqueCode}, #{supplierId}, #{serial}, #{wllbCode}, #{producDate}, #{askGoodsId}, #{type},
  170. #{storageLocationCode}, #{num}, #{userId}, #{department}, #{attribute}, #{companyNumber},
  171. #{storageLocationCodeRk}, #{wbs}, #{entryNumber})
  172. </insert>
  173. <!-- 查询指定库存内容 -->
  174. <select id="getInventory" resultType="com.tld.model.Inventory">
  175. select id,
  176. storage_location_code,
  177. wllb_class,
  178. library_type,
  179. material_id,
  180. amount,
  181. total,
  182. totime,
  183. hold,
  184. amount_lock,
  185. account_sleeve,
  186. wbs,
  187. supplier_id,
  188. serial,
  189. wllb_code,
  190. produc_date,
  191. scrq
  192. from tld_inventory
  193. where supplier_id = #{supplierId}
  194. and serial = #{serial}
  195. and wllb_code = #{wllbCode}
  196. and produc_date = #{producDate}
  197. and account_sleeve = #{companyNumber}
  198. <if test="wbs != null">
  199. and wbs = #{wbs}
  200. </if>
  201. </select>
  202. <!-- 查询指定库存内容 -->
  203. <select id="getInventoryWarehousing" resultType="com.tld.model.Inventory">
  204. select id,
  205. storage_location_code,
  206. wllb_class,
  207. library_type,
  208. material_id,
  209. amount,
  210. total,
  211. totime,
  212. hold,
  213. amount_lock,
  214. account_sleeve,
  215. wbs,
  216. supplier_id,
  217. serial,
  218. wllb_code,
  219. produc_date,
  220. scrq
  221. from tld_inventory
  222. where storage_location_code = #{storageLocationCode}
  223. and wllb_code = #{wllbCode}
  224. and account_sleeve = #{companyNumber}
  225. and wbs = #{wbs}
  226. </select>
  227. <!-- 查询库存是否充足 -->
  228. <select id="getAsk" resultType="com.tld.model.AskGoods">
  229. SELECT ifnull(sum(a.num), 0) as num
  230. FROM tld_ask_goods_vitrual a
  231. join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
  232. where a.storage_location_code = #{storageLocationCode}
  233. and a.serial = #{serial} and wbs = #{wbs} and account_sleeve = #{accountSleeve}
  234. </select>
  235. <!-- 查询是否扫描 -->
  236. <select id="getScanIsNot" resultType="java.util.Map">
  237. select (select ifnull(max(amount), 0)
  238. from tld_inventory
  239. where supplier_id = #{supplierId}
  240. and serial = #{serial}
  241. and wllb_code = #{wllbCode}
  242. and produc_date = #{producDate}) as inventoryNum,
  243. (select ifnull(sum(num), 0)
  244. from tld_ask_goods_vitrual
  245. where supplier_id = #{supplierId}
  246. and serial = #{serial}
  247. and wllb_code = #{wllbCode}
  248. and produc_date = #{producDate}
  249. and type = #{type}) as virtualNum
  250. from dual
  251. </select>
  252. <!-- 查询指定送货单信息 -->
  253. <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
  254. SELECT a.id,
  255. a.ask_goods_id,
  256. a.entry_number,
  257. a.production_code,
  258. a.material_id,
  259. a.wbs,
  260. a.measurement_id,
  261. a.num,
  262. ifnull(a.out_num, 0) as out_num
  263. FROM tld_ask_goods a
  264. join tld_material b on a.material_id = b.tld_id
  265. where a.ask_goods_id = #{askGoodsId}
  266. and b.code = #{wllbCode} and a.entry_number = #{entryNumber}
  267. </select>
  268. <!-- 查询指定移庫單 -->
  269. <select id="getWareInfo" resultType="com.tld.model.AskGoods">
  270. SELECT a.id,
  271. a.warehouse_transfer_id as askGoodsId,
  272. a.entry_number,
  273. a.material_id,
  274. a.wbs,
  275. a.measurement_id,
  276. a.num,
  277. ifnull(a.out_num, 0) as out_num
  278. FROM tld_warehouse_transfer a
  279. join tld_material b on a.material_id = b.tld_id
  280. where a.warehouse_transfer_id = #{askGoodsId}
  281. and b.code = #{wllbCode}
  282. </select>
  283. <!-- 查询已扫描总数 -->
  284. <select id="getAskInfoNumVitrual" resultType="int">
  285. select ifnull(sum(num), 0)
  286. from tld_ask_goods_vitrual
  287. where wllb_code = #{wllbCode}
  288. and ask_goods_id = #{askGoodsId}
  289. and account_sleeve = #{accountSleeve}
  290. and wbs = #{wbs}
  291. and type = #{type}
  292. </select>
  293. <!-- 查询此库存在虚拟表里占用的数量 -->
  294. <select id="getInventoryAlready" resultType="int">
  295. select ifnull(sum(num), 0)
  296. from tld_ask_goods_vitrual
  297. where supplier_id = #{supplierId}
  298. and serial = #{serial}
  299. and wllb_code = #{wllbCode}
  300. and produc_date = #{producDate}
  301. and account_sleeve = #{accountSleeve}
  302. and wbs = #{wbs}
  303. and type = #{type}
  304. </select>
  305. <!-- 查询虚拟表指定pda跟状态的的数据 -->
  306. <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
  307. select id,
  308. unique_code,
  309. supplier_id,
  310. serial,
  311. wllb_code,
  312. produc_date,
  313. ask_goods_id,
  314. type,
  315. storage_location_code,
  316. num,
  317. user_id,
  318. department,
  319. account_sleeve,
  320. wbs,
  321. storage_location_code_rk,
  322. entry_number
  323. from tld_ask_goods_vitrual
  324. where unique_code = #{uniqueCode}
  325. and type = #{type}
  326. and ask_goods_id = #{askGoodsId}
  327. </select>
  328. <!-- 删除库存 -->
  329. <delete id="deleteInventory">
  330. delete
  331. from tld_inventory
  332. where id = #{id}
  333. </delete>
  334. <!-- 修改库存数量 -->
  335. <update id="updateInventory">
  336. UPDATE tld_inventory
  337. SET amount = convert(amount - #{amount}, decimal(12,3))
  338. WHERE id = #{id}
  339. </update>
  340. <!-- 删除虚拟表出库记录 -->
  341. <delete id="deleteVirtual">
  342. delete
  343. from tld_ask_goods_vitrual
  344. where id = #{id}
  345. </delete>
  346. <!-- 插入出库流水 -->
  347. <insert id="addRemoval">
  348. insert into tld_removal(wllb_code, supplier_id, serial, num, type, user_id, storage_location_code, scrq,
  349. process, ask_goods_id, produc_date, department, storage_code, wbs, account_sleeve,transmission_type)
  350. values (#{wllbCode}, #{supplierId}, #{serial}, #{num}, #{type}, #{userId}, #{storageLocationCode}, now(),
  351. #{process}, #{askGoodsId}, #{producDate}, #{department}, #{storageCode}, #{wbs}, #{companyNumber},'0')
  352. </insert>
  353. <!-- 查询指定物料类型的id -->
  354. <select id="getMaterialId" resultType="String">
  355. select tld_id
  356. from tld_material
  357. where code = #{wllbCode}
  358. </select>
  359. <!-- 查询要料申请单内容 -->
  360. <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
  361. select id,
  362. ask_goods_id,
  363. entry_number,
  364. production_code,
  365. material_id,
  366. wbs,
  367. measurement_id,
  368. num,
  369. out_num
  370. from tld_ask_goods
  371. where ask_goods_id = #{askGoodsId}
  372. and material_id = #{materialId}
  373. <if test="entryNumber != null and entryNumber != ''">
  374. and entry_number = #{entryNumber}
  375. </if>
  376. </select>
  377. <!-- 新增返回gs数据字表信息 -->
  378. <insert id="addReturnGsRemoval">
  379. insert into tld_return_gs_removal_z(material_id, wbs, num, entry_number, document_id, document_points_id,
  380. storage_location_code)
  381. values (#{materialId}, #{wbs}, #{num}, #{entryNumber}, #{documentId}, #{documentPointsId},
  382. #{storageLocationCode})
  383. </insert>
  384. <!-- 查询要货单父级信息 -->
  385. <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
  386. select id,
  387. ask_goods_id,
  388. ask_goods_code,
  389. company_number,
  390. sqrq,
  391. department,
  392. source_type,
  393. move_type,
  394. request_type_name
  395. from tld_ask_goods_f
  396. where ask_goods_id = #{askGoodsId}
  397. </select>
  398. <!-- 新增返回gs数据父表信息 -->
  399. <insert id="addReturnGsRemovalF">
  400. insert into tld_return_gs_removal(document_id, removal_code, source_type, move_type, scrq, delivery_type, name, request_type_name)
  401. values (#{documentId}, #{removalCode}, #{sourceType}, #{moveType}, now(), #{deliveryType}, #{name}, #{requestTypeName})
  402. </insert>
  403. <!-- 添加 tld_access 记录-->
  404. <insert id="addAccess">
  405. insert into tld_access (type, data, scrq, access_type)
  406. values (#{names}, #{returnGsRemoval}, now(), #{accessType})
  407. </insert>
  408. <!--出库回传数据导入-->
  409. <insert id="importExcel">
  410. insert into tld_outgoing_return(ask_id,ask_code,entry_number,amount,amount_num,amount_number,move_type,
  411. material_id,inventory_organization,warehouse,wbs)
  412. values
  413. <foreach collection="list" item="item" index="index" separator=",">
  414. (#{item.askId},#{item.askCode},#{item.entryNumber},#{item.amount},#{item.amountNum},#{item.amountNumber},#{item.moveType},#{item.materialId},#{item.inventoryOrganization},#{item.warehouse}
  415. ,#{item.wbs})
  416. </foreach>
  417. </insert>
  418. <!--添加GS返回数据-->
  419. <insert id="addReturnWarehousing">
  420. insert into tld_return_gs_warehousing(storage_code,source_type,move_type,entry_number,wbs,material_id,warehousing_num,receive_goods_id,scrq,order_number,storage_location_code)
  421. values(#{storageCode},#{sourceType},#{moveType},#{entryNumber},#{wbs},#{materialId},#{warehousingNum},#{receiveGoodsId},now(),#{orderNumber},#{storageLocationCode})
  422. </insert>
  423. <!--销售出库导入数据-->
  424. <insert id="marketImport">
  425. insert into tld_market_return(order_number,order_officer,supplier_name,material_code,material_name,num,arrival_time,
  426. arrival_type,company,remark,delivery_order)
  427. values
  428. <foreach collection="list" item="item" index="index" separator=",">
  429. (#{item.orderNumber},#{item.orderOfficer},#{item.supplierName},#{item.materialCode},#{item.materialName},#{item.num},#{item.arrivalTime},#{item.arrivalType},#{item.company},#{item.remark}
  430. ,#{item.deliveryOrder})
  431. </foreach>
  432. </insert>
  433. <!--销售出库导入数据导入物料code-->
  434. <insert id="marketImports">
  435. insert into tld_market_return(material_code)
  436. values
  437. <foreach collection="list" item="item" index="index" separator=",">
  438. (#{item.materialCode})
  439. </foreach>
  440. </insert>
  441. <!-- 退库新增库存 -->
  442. <insert id="addInventory">
  443. <selectKey resultType="java.lang.String" order="AFTER" keyProperty="id">
  444. select LAST_INSERT_ID()
  445. </selectKey>
  446. insert into tld_inventory(storage_location_code,wllb_class,material_id,amount,totime,hold,amount_lock,total,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date,scrq,produc_batch,attribute)
  447. value(#{storageLocationCode},#{wllbClass},#{materialId},#{amount},now(),'0','0','0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producBatch}, ' ')
  448. </insert>
  449. <!-- 查询当天出库数量 -->
  450. <select id="getReturnRemovalCount" resultType="int">
  451. select count(*)
  452. from tld_return_gs_removal
  453. where scrq BETWEEN CONCAT(CURDATE(), ' 00:00:00') AND CONCAT(CURDATE(), ' 23:59:59');
  454. </select>
  455. <!-- 查询回传数据 -->
  456. <select id="plugOutRemoval" resultType="java.util.Map">
  457. select id,
  458. document_id as askGoodsId,
  459. removal_code as removalCode,
  460. source_type as sourceType,
  461. move_type as moveType,
  462. scrq,
  463. request_type_name as requestTypeName
  464. from tld_return_gs_removal
  465. where document_id = #{removalCode}
  466. </select>
  467. <!-- 查询字表回传数据 -->
  468. <select id="getRemovalz" resultType="java.util.Map">
  469. SELECT a.material_id AS materialId,
  470. a.wbs,
  471. a.num,
  472. a.entry_number AS entryNumber,
  473. a.document_id AS askGoodsId,
  474. a.document_points_id AS askId,
  475. ifnull(a.wbs, '') as wbsId,
  476. ifnull(c.code, '') as wbsCode,
  477. ifnull(c.name, '') as wbsName
  478. FROM tld_return_gs_removal_z a
  479. join tld_storage_location b on a.storage_location_code = b.storage_location_code
  480. left join tld_wbs c on a.wbs = c.tld_id
  481. WHERE a.document_id = #{askGoodsId}
  482. and b.warehouse_where = #{warehouseWhere}
  483. </select>
  484. <!-- 查询出库流水 -->
  485. <select id="getRemoval" resultType="com.tld.model.AskGoods">
  486. select
  487. a.id,
  488. b.name as materialName,
  489. a.wllb_code,
  490. h.name as supplierName,
  491. a.serial,
  492. a.type,
  493. c.user_name as userName,
  494. e.name as department,
  495. g.storage_location_name as storageLocationName,
  496. a.scrq,
  497. a.num,
  498. a.storage_code,
  499. a.wbs,
  500. w.name as wbsName,
  501. a.ask_goods_id,
  502. c.real_name as realName,
  503. a.account_sleeve,
  504. f.name as accountName,
  505. p.ask_goods_code as askGoodsCode
  506. from tld_removal a
  507. left join tld_material b on a.wllb_code = b.code
  508. left join tld_user c on a.user_id = c.id
  509. left join tld_department e on a.department = e.code
  510. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  511. left join tld_customer h on a.supplier_id = h.code
  512. left join tld_company f on a.account_sleeve = f.code
  513. left join tld_ask_goods_f p on a.ask_goods_id = p.ask_goods_id
  514. left join tld_wbs w on a.wbs = w.tld_id
  515. <trim prefix="WHERE" prefixOverrides="and |or">
  516. <if test="startTime != null and startTime != ''">
  517. and a.scrq <![CDATA[>=]]> #{startTime}
  518. </if>
  519. <if test="endTime != null and endTime != ''">
  520. and a.scrq <![CDATA[<=]]> #{endTime}
  521. </if>
  522. <if test="type != null and type != ''">
  523. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  524. </if>
  525. <if test="supplierId != null and supplierId != ''">
  526. and a.supplier_id = #{supplierId}
  527. </if>
  528. <if test="department != null and department != ''">
  529. and a.department = #{department}
  530. </if>
  531. <if test="storageCode != null and storageCode != ''">
  532. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  533. </if>
  534. <if test="storageLocationName != null and storageLocationName != ''">
  535. and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  536. </if>
  537. <if test="wllbCode != null and wllbCode != ''">
  538. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  539. </if>
  540. <if test="materialName != null and materialName != ''">
  541. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  542. </if>
  543. <if test="userName != null and userName != ''">
  544. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  545. </if>
  546. <if test="realName != null and realName != ''">
  547. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  548. </if>
  549. <if test="askGoodsId != null and askGoodsId != ''">
  550. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  551. </if>
  552. <if test="askGoodsCode != null and askGoodsCode != ''">
  553. and p.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  554. </if>
  555. <if test="wbs != null and wbs != ''">
  556. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  557. </if>
  558. <if test="accountSleeve != null and accountSleeve != ''">
  559. and a.account_sleeve = #{accountSleeve}
  560. </if>
  561. </trim>
  562. order by a.id desc
  563. </select>
  564. <!-- 导出 -->
  565. <select id="export" resultType="java.util.LinkedHashMap">
  566. select
  567. b.name as materialName,
  568. if(h.name = '',null,h.name) as supplierName,
  569. if(a.serial = '',null,a.serial) as serial,
  570. a.type,
  571. c.user_name as userName,
  572. e.name as department,
  573. g.storage_location_name as storageLocationName,
  574. a.scrq,
  575. a.num,
  576. p.ask_goods_code,
  577. c.real_name,
  578. f.name as accountName,
  579. if(a.wbs = '' , null , a.wbs ) as wbs,
  580. if(w.name = '' , null , w.name ) as wbsName
  581. from tld_removal a
  582. left join tld_material b on a.wllb_code = b.code
  583. left join tld_user c on a.user_id = c.id
  584. left join tld_department e on a.department = e.code
  585. left join tld_storage_location g on a.storage_location_code = g.storage_location_code
  586. left join tld_customer h on a.supplier_id = h.code
  587. left join tld_company f on a.account_sleeve = f.code
  588. left join tld_ask_goods_f p on a.ask_goods_id = p.ask_goods_id
  589. left join tld_wbs w on a.wbs = w.tld_id
  590. <trim prefix="WHERE" prefixOverrides="and |or">
  591. <if test="startTime != null and startTime != ''">
  592. and a.scrq <![CDATA[>=]]> #{startTime}
  593. </if>
  594. <if test="endTime != null and endTime != ''">
  595. and a.scrq <![CDATA[<=]]> #{endTime}
  596. </if>
  597. <if test="type != null and type != ''">
  598. and a.type like CONCAT(CONCAT('%', #{type}), '%')
  599. </if>
  600. <if test="supplierId != null and supplierId != ''">
  601. and a.supplier_id = #{supplierId}
  602. </if>
  603. <if test="department != null and department != ''">
  604. and a.department = #{department}
  605. </if>
  606. <if test="storageCode != null and storageCode != ''">
  607. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  608. </if>
  609. <if test="storageLocationName != null and storageLocationName != ''">
  610. and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
  611. </if>
  612. <if test="wllbCode != null and wllbCode != ''">
  613. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  614. </if>
  615. <if test="materialName != null and materialName != ''">
  616. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  617. </if>
  618. <if test="userName != null and userName != ''">
  619. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  620. </if>
  621. <if test="realName != null and realName != ''">
  622. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  623. </if>
  624. <if test="askGoodsId != null and askGoodsId != ''">
  625. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  626. </if>
  627. <if test="askGoodsCode != null and askGoodsCode != ''">
  628. and p.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  629. </if>
  630. <if test="wbs != null and wbs != ''">
  631. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  632. </if>
  633. <if test="accountSleeve != null and accountSleeve != ''">
  634. and a.account_sleeve = #{accountSleeve}
  635. </if>
  636. </trim>
  637. order by a.id desc
  638. </select>
  639. <!-- 查询指定pda出库虚拟表 -->
  640. <select id="getAskGoodsVitrual" resultType="com.tld.model.AskGoods">
  641. select id,
  642. unique_code,
  643. supplier_id,
  644. serial,
  645. wllb_code,
  646. produc_date,
  647. ask_goods_id,
  648. type,
  649. storage_location_code,
  650. num,
  651. user_id,
  652. department,
  653. account_sleeve,
  654. wbs,
  655. attribute,
  656. entry_number
  657. from tld_ask_goods_vitrual
  658. where unique_code = #{uniqueCode}
  659. and type = #{type}
  660. </select>
  661. <!-- 删除指定虚拟表数据 -->
  662. <delete id="delAskGoodsVitrual">
  663. delete
  664. from tld_ask_goods_vitrual
  665. where id = #{id}
  666. and type = #{type}
  667. </delete>
  668. <!-- 删除出库回传主表信息 -->
  669. <delete id="delPlugOutRemoval">
  670. delete
  671. from tld_return_gs_removal
  672. where document_id = #{removalCode}
  673. </delete>
  674. <!-- 删除出库回传子表信息 -->
  675. <delete id="delRemovalz">
  676. delete
  677. from tld_return_gs_removal_z
  678. where document_id = #{removalCode}
  679. </delete>
  680. <!-- 删除入库回传信息 -->
  681. <delete id="delPlugOutWarehousing">
  682. delete
  683. from tld_return_gs_warehousing
  684. where #{orderNumber} LIKE CONCAT('%', CONCAT(order_number, ','), '%')
  685. </delete>
  686. <!-- 修改出库数量 -->
  687. <update id="updateOutNum">
  688. update tld_ask_goods
  689. set out_num = ifnull(out_num, 0) + #{num}
  690. where material_id = #{materialId}
  691. and ask_goods_id = #{askGoodsId}
  692. <if test="entryNumber != null and entryNumber != ''">
  693. and entry_number = #{entryNumber}
  694. </if>
  695. </update>
  696. <!-- 查询指定pda 指定物料扫描总数 -->
  697. <select id="getScanNum" resultType="String">
  698. select if(sum(num) is null, 0, sum(num))
  699. from tld_ask_goods_vitrual
  700. where unique_code = #{uniqueCode}
  701. and ask_goods_id = #{askGoodsId}
  702. and wllb_code = #{wllbCode}
  703. and entry_number = #{entryNumber}
  704. </select>
  705. <!-- 查询半成品出库数据 -->
  706. <select id="getGoodsHalf" resultType="com.tld.model.AskGoods">
  707. SELECT
  708. a.id,
  709. a.material_id,
  710. a.num,
  711. a.production_code,
  712. b.name as materialName,
  713. b.code as materialCode,
  714. a.out_num,
  715. a.ask_goods_id,
  716. c.company_number,
  717. e.name as department,
  718. a.type,
  719. a.wbs,
  720. f.name as wbsCode,
  721. f.name as wbsName,
  722. f.code as wbsCode,
  723. a.entry_number,
  724. g.name as companyName,
  725. c.source_type,
  726. c.move_type,
  727. c.sqrq,
  728. c.ask_goods_code
  729. FROM
  730. tld_ask_goods a
  731. join tld_material b on a.material_id = b.tld_id
  732. join tld_ask_goods_f c on a.ask_goods_id = c.ask_goods_id
  733. left join tld_department e on c.department = e.code
  734. left join tld_company g on c.company_number = g.code
  735. left join tld_wbs f on a.wbs = f.tld_id
  736. WHERE
  737. (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and
  738. b.part_type = #{partType}
  739. <if test="userId != null and userId != ''">
  740. and b.code in (select material_id from tld_user_material where user_id = #{userId})
  741. </if>
  742. <if test="productionCode != null and productionCode != ''">
  743. and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
  744. </if>
  745. <if test="askGoodsId != null and askGoodsId != ''">
  746. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  747. </if>
  748. <if test="askGoodsCode != null and askGoodsCode != ''">
  749. and c.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  750. </if>
  751. <if test="id != null and id != ''">
  752. and a.id = #{id}
  753. </if>
  754. <if test="type != null and type != ''">
  755. and a.type = #{type}
  756. </if>
  757. <if test="startTime != null and startTime != ''">
  758. and c.sqrq <![CDATA[>=]]> #{startTime}
  759. </if>
  760. <if test="endTime != null and endTime != ''">
  761. and c.sqrq <![CDATA[<=]]> #{endTime}
  762. </if>
  763. <if test="materialName != null and materialName != ''">
  764. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  765. </if>
  766. <if test="materialCode != null and materialCode != ''">
  767. and b.code like CONCAT(CONCAT('%', #{materialCode}), '%')
  768. </if>
  769. <if test="departmentCode != null and departmentCode != ''">
  770. and c.department = #{departmentCode}
  771. </if>
  772. <if test="companyCode != null and companyCode != ''">
  773. and c.company_number = #{companyCode}
  774. </if>
  775. <if test="entryNumber != null and entryNumber != ''">
  776. and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
  777. </if>
  778. <if test="sourceType != null and sourceType != ''">
  779. and c.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
  780. </if>
  781. <if test="moveType != null and moveType != ''">
  782. and c.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
  783. </if>
  784. order by a.id desc
  785. </select>
  786. <!-- 查询半成品出库流水 -->
  787. <select id="getRemovalHalfProduct" resultType="com.tld.model.AskGoods">
  788. select
  789. a.id,
  790. a.wllb_code,
  791. a.num,
  792. a.user_id,
  793. a.scrq,
  794. a.ask_goods_id,
  795. c.name as department,
  796. b.name as materialName,
  797. e.user_name as userName,
  798. b.code as materialCode,
  799. a.storage_code,
  800. a.wbs,
  801. w.name as wbsName,
  802. e.real_name as realName,
  803. a.account_sleeve,
  804. f.name as accountName,
  805. p.ask_goods_code as askGoodsCode
  806. from tld_removal_half_product a
  807. left join tld_material b on a.wllb_code = b.code
  808. left join tld_department c on a.department = c.code
  809. left join tld_user e on a.user_id = e.id
  810. left join tld_company f on a.account_sleeve = f.code
  811. left join tld_ask_goods_f p on a.ask_goods_id = p.ask_goods_id
  812. left join tld_wbs w on a.wbs = w.tld_id
  813. <trim prefix="WHERE" prefixOverrides="and |or">
  814. <if test="wllbCode != null and wllbCode != ''">
  815. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  816. </if>
  817. <if test="startTime != null and startTime != ''">
  818. and a.scrq <![CDATA[>=]]> #{startTime}
  819. </if>
  820. <if test="endTime != null and endTime != ''">
  821. and a.scrq <![CDATA[<=]]> #{endTime}
  822. </if>
  823. <if test="departmentCode != null and departmentCode != ''">
  824. and a.department = #{departmentCode}
  825. </if>
  826. <if test="materialName != null and materialName != ''">
  827. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  828. </if>
  829. <if test="userName != null and userName != ''">
  830. and e.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  831. </if>
  832. <if test="realName != null and realName != ''">
  833. and e.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  834. </if>
  835. <if test="askGoodsId != null and askGoodsId != ''">
  836. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  837. </if>
  838. <if test="askGoodsCode != null and askGoodsCode != ''">
  839. and p.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  840. </if>
  841. <if test="storageCode != null and storageCode != ''">
  842. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  843. </if>
  844. <if test="wbs != null and wbs != ''">
  845. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  846. </if>
  847. <if test="accountSleeve != null and accountSleeve != ''">
  848. and a.account_sleeve = #{accountSleeve}
  849. </if>
  850. </trim>
  851. order by a.scrq desc
  852. </select>
  853. <!-- 查询半成品出库流水导出 -->
  854. <select id="getRemovalHalfProductExcel" resultType="java.util.LinkedHashMap">
  855. select
  856. if(p.ask_goods_code = '' , null , p.ask_goods_code ) as askGoodsCode,
  857. a.storage_code as storageCode,
  858. a.wllb_code as wllbCode,
  859. b.name as materialName,
  860. a.num,
  861. e.user_name as userName,
  862. if(c.name = '' , null , c.name ) as department,
  863. if(a.wbs = '' , null , a.wbs ) as wbs,
  864. if(w.name = '' , null , w.name ) as wbsName,
  865. a.scrq,
  866. e.real_name as realName,
  867. f.name as accountName
  868. from tld_removal_half_product a
  869. left join tld_material b on a.wllb_code = b.code
  870. left join tld_department c on a.department = c.code
  871. left join tld_user e on a.user_id = e.id
  872. left join tld_company f on a.account_sleeve = f.code
  873. left join tld_ask_goods_f p on a.ask_goods_id = p.ask_goods_id
  874. left join tld_wbs w on a.wbs = w.tld_id
  875. <trim prefix="WHERE" prefixOverrides="and |or">
  876. <if test="wllbCode != null and wllbCode != ''">
  877. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  878. </if>
  879. <if test="startTime != null and startTime != ''">
  880. and a.scrq <![CDATA[>=]]> #{startTime}
  881. </if>
  882. <if test="endTime != null and endTime != ''">
  883. and a.scrq <![CDATA[<=]]> #{endTime}
  884. </if>
  885. <if test="departmentCode != null and departmentCode != ''">
  886. and a.department = #{departmentCode}
  887. </if>
  888. <if test="materialName != null and materialName != ''">
  889. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  890. </if>
  891. <if test="userName != null and userName != ''">
  892. and e.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  893. </if>
  894. <if test="realName != null and realName != ''">
  895. and e.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  896. </if>
  897. <if test="askGoodsId != null and askGoodsId != ''">
  898. and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
  899. </if>
  900. <if test="askGoodsCode != null and askGoodsCode != ''">
  901. and p.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
  902. </if>
  903. <if test="storageCode != null and storageCode != ''">
  904. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  905. </if>
  906. <if test="wbs != null and wbs != ''">
  907. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  908. </if>
  909. <if test="accountSleeve != null and accountSleeve != ''">
  910. and a.account_sleeve = #{accountSleeve}
  911. </if>
  912. </trim>
  913. order by a.scrq desc
  914. </select>
  915. <!-- 产成品出库流水 -->
  916. <select id="getRemovalHalf" resultType="com.tld.model.AskGoods">
  917. select
  918. a.id,
  919. a.wllb_code,
  920. a.num,
  921. a.user_id,
  922. a.scrq,
  923. a.delivery_id,
  924. a.company_number,
  925. a.customer_code,
  926. b.name as materialName,
  927. c.user_name as userName,
  928. e.name as customerName,
  929. f.name as companyName,
  930. b.code as materialCode,
  931. a.serial,
  932. a.storage_code,
  933. a.wbs,
  934. w.name as wbsName,
  935. c.real_name as realName,
  936. p.delivery_code as deliveryCode
  937. from tld_removal_half a
  938. left join tld_material b on a.wllb_code = b.code
  939. left join tld_user c on a.user_id = c.id
  940. left join tld_customer e on a.customer_code = e.code
  941. left join tld_company f on a.company_number = f.code
  942. left join tld_delivery_f p on a.delivery_id = p.delivery_id
  943. left join tld_wbs w on a.wbs = w.tld_id
  944. <trim prefix="WHERE" prefixOverrides="and |or">
  945. <if test="wllbCode != null and wllbCode != ''">
  946. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  947. </if>
  948. <if test="materialName != null and materialName != ''">
  949. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  950. </if>
  951. <if test="userName != null and userName != ''">
  952. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  953. </if>
  954. <if test="realName != null and realName != ''">
  955. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  956. </if>
  957. <if test="deliveryId != null and deliveryId != ''">
  958. and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
  959. </if>
  960. <if test="deliveryCode != null and deliveryCode != ''">
  961. and p.delivery_code like CONCAT(CONCAT('%', #{deliveryCode}), '%')
  962. </if>
  963. <if test="companyCode != null and companyCode != ''">
  964. and a.company_number = #{companyCode}
  965. </if>
  966. <if test="customerCode != null and customerCode != ''">
  967. and a.customer_code = #{customerCode}
  968. </if>
  969. <if test="storageCode != null and storageCode != ''">
  970. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  971. </if>
  972. <if test="wbs != null and wbs != ''">
  973. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  974. </if>
  975. <if test="startTime != null and startTime != ''">
  976. and a.scrq <![CDATA[>=]]> #{startTime}
  977. </if>
  978. <if test="endTime != null and endTime != ''">
  979. and a.scrq <![CDATA[<=]]> #{endTime}
  980. </if>
  981. <if test="num != null and num != ''">
  982. and a.num = #{num}
  983. </if>
  984. </trim>
  985. order by a.scrq desc
  986. </select>
  987. <!-- 产成品导出出库流水 -->
  988. <select id="getRemovalHalfExcel" resultType="java.util.LinkedHashMap">
  989. select
  990. p.delivery_code as deliveryCode,
  991. b.name as materialName,
  992. a.num,
  993. c.user_name as userName,
  994. a.scrq,
  995. f.name as companyName,
  996. e.name,
  997. a.storage_code,
  998. if(a.wbs = '' , null , a.wbs ) as wbs,
  999. if(w.name = '' , null , w.name ) as wbsName,
  1000. c.real_name as realName
  1001. from tld_removal_half a
  1002. left join tld_material b on a.wllb_code = b.code
  1003. left join tld_user c on a.user_id = c.id
  1004. left join tld_customer e on a.customer_code = e.code
  1005. left join tld_company f on a.company_number = f.code
  1006. left join tld_delivery_f p on a.delivery_id = p.delivery_id
  1007. left join tld_wbs w on a.wbs = w.tld_id
  1008. <trim prefix="WHERE" prefixOverrides="and |or">
  1009. <if test="wllbCode != null and wllbCode != ''">
  1010. and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
  1011. </if>
  1012. <if test="materialName != null and materialName != ''">
  1013. and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
  1014. </if>
  1015. <if test="userName != null and userName != ''">
  1016. and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
  1017. </if>
  1018. <if test="realName != null and realName != ''">
  1019. and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
  1020. </if>
  1021. <if test="deliveryId != null and deliveryId != ''">
  1022. and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
  1023. </if>
  1024. <if test="deliveryCode != null and deliveryCode != ''">
  1025. and p.delivery_code like CONCAT(CONCAT('%', #{deliveryCode}), '%')
  1026. </if>
  1027. <if test="companyCode != null and companyCode != ''">
  1028. and a.company_number = #{companyCode}
  1029. </if>
  1030. <if test="customerCode != null and customerCode != ''">
  1031. and a.customer_code = #{customerCode}
  1032. </if>
  1033. <if test="storageCode != null and storageCode != ''">
  1034. and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
  1035. </if>
  1036. <if test="wbs != null and wbs != ''">
  1037. and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
  1038. </if>
  1039. <if test="startTime != null and startTime != ''">
  1040. and a.scrq <![CDATA[>=]]> #{startTime}
  1041. </if>
  1042. <if test="endTime != null and endTime != ''">
  1043. and a.scrq <![CDATA[<=]]> #{endTime}
  1044. </if>
  1045. </trim>
  1046. order by a.scrq desc
  1047. </select>
  1048. <!-- 查询指定物料的库存 -->
  1049. <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
  1050. select
  1051. id,
  1052. storage_location_code,
  1053. wllb_class,
  1054. library_type,
  1055. material_id,
  1056. amount,
  1057. total,
  1058. totime,
  1059. hold,
  1060. amount_lock,
  1061. account_sleeve,
  1062. wbs,
  1063. supplier_id,
  1064. serial,
  1065. wllb_code,
  1066. produc_date,
  1067. scrq,
  1068. produc_batch,
  1069. attribute
  1070. from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and
  1071. account_sleeve = #{accountSleeve} and amount <![CDATA[>=]]> (#{num} + 0)
  1072. <if test="wbs != null">
  1073. and wbs = #{wbs}
  1074. </if>
  1075. <if test="storageLocationCode != '' and storageLocationCode != null">
  1076. and storage_location_code = #{storageLocationCode}
  1077. </if>
  1078. <if test="serial != '' and serial != null">
  1079. and serial = #{serial}
  1080. </if>
  1081. <if test="attribute != '' and attribute != null">
  1082. and attribute = #{attribute}
  1083. </if>
  1084. <if test="producDate != '' and producDate != null">
  1085. and produc_date = #{producDate}
  1086. </if>
  1087. <if test="supplierId != '' and supplierId != null">
  1088. and supplier_id = #{supplierId}
  1089. </if>
  1090. order by produc_batch
  1091. </select>
  1092. <!-- 其他入库查询库存是否存在 -->
  1093. <select id="getInventoryInfoOther" resultType="com.tld.model.Inventory">
  1094. select
  1095. a.id,
  1096. a.storage_location_code,
  1097. a.wllb_class,
  1098. a.library_type,
  1099. a.material_id,
  1100. a.amount,
  1101. a.total,
  1102. a.totime,
  1103. a.hold,
  1104. a.amount_lock,
  1105. a.account_sleeve,
  1106. a.wbs,
  1107. a.supplier_id,
  1108. a.serial,
  1109. a.wllb_code,
  1110. a.produc_date,
  1111. a.scrq,
  1112. a.produc_batch,
  1113. a.attribute,
  1114. b.name as accountName,
  1115. c.storage_location_name as storageLocationName,
  1116. c.warehouse_where as warehouseWhere
  1117. from tld_inventory a
  1118. left join tld_company b on a.account_sleeve = b.code
  1119. left join tld_storage_location c on a.storage_location_code = c.storage_location_code
  1120. where material_id = #{materialId}
  1121. <if test="wbs != '' and wbs != null">
  1122. and a.wbs = #{wbs}
  1123. </if>
  1124. <if test="serial != '' and serial != null">
  1125. and a.serial = #{serial}
  1126. </if>
  1127. <if test="attribute != '' and attribute != null">
  1128. and a.attribute = #{attribute}
  1129. </if>
  1130. <if test="producDate != '' and producDate != null">
  1131. and a.produc_batch = #{producDate}
  1132. </if>
  1133. <if test="supplierId != '' and supplierId != null">
  1134. and a.supplier_id = #{supplierId}
  1135. </if>
  1136. <if test="storageLocationCode != '' and storageLocationCode != null">
  1137. and a.storage_location_code = #{storageLocationCode}
  1138. </if>
  1139. <if test="accountSleeve != '' and accountSleeve != null">
  1140. and a.account_sleeve = #{accountSleeve}
  1141. </if>
  1142. </select>
  1143. <!-- 查询仓库 -->
  1144. <select id="getWarehouseWhere" resultType="String">
  1145. SELECT DISTINCT b.warehouse_where
  1146. FROM tld_return_gs_removal_z a
  1147. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1148. WHERE a.document_id = #{removalCode}
  1149. </select>
  1150. <!-- 查询半成品原始数据 -->
  1151. <select id="getInventoryNotice" resultType="java.util.Map">
  1152. select *
  1153. from tld_notice
  1154. where id = #{id}
  1155. </select>
  1156. <!-- 删除半成品/产成品入库通知原始信息 -->
  1157. <delete id="delInventoryNotice">
  1158. delete
  1159. from tld_notice
  1160. where id = #{id}
  1161. </delete>
  1162. <!-- 查询要料申请单 -->
  1163. <select id="getDelAskGoods" resultType="java.util.Map">
  1164. select *
  1165. from tld_ask_goods
  1166. where id = #{id}
  1167. </select>
  1168. <!-- 销售发货单接口文档 父表信息 -->
  1169. <select id="getGsRemoval" resultType="java.util.Map">
  1170. select id,
  1171. document_id as askGoodsId,
  1172. removal_code as removalCode,
  1173. source_type as sourceType,
  1174. move_type as moveType,
  1175. scrq
  1176. from tld_return_gs_removal
  1177. where removal_code = #{removalCode}
  1178. </select>
  1179. <!--查询移库子表中的供货仓库仓库-->
  1180. <select id="getSupplyWarehouseWhere" resultType="java.lang.String">
  1181. SELECT supply_warehouse_id
  1182. FROM tld_return_warehouse_transfer_z
  1183. WHERE warehouse_transfer_id = #{removalCode}
  1184. GROUP BY supply_warehouse_id
  1185. </select>
  1186. <!--查询移库父表信息-->
  1187. <select id="getReturnWarehouseTransfer" resultType="java.util.Map">
  1188. select id,
  1189. warehouse_transfer_id as warehouseTransferId,
  1190. warehouse_transfer_code as warehouseTransferCode,
  1191. ask_goods_warehouse_id as askGoodsWarehouseId,
  1192. warehouse_transfer_type as warehouseTransferType,
  1193. scrq
  1194. from tld_return_warehouse_transfer
  1195. where warehouse_transfer_code = #{removalCode}
  1196. </select>
  1197. <!--查询出父表中的移库id根据code-->
  1198. <select id="getSupplyWarehouseWheres" resultType="java.lang.String">
  1199. select warehouse_transfer_id as warehouseTransferId
  1200. from tld_return_warehouse_transfer
  1201. where warehouse_transfer_code = #{removalCode}
  1202. </select>
  1203. <!--查询移库子表信息-->
  1204. <select id="getReturnWarehouseTransferZ" resultType="java.util.Map">
  1205. select a.id,
  1206. a.warehouse_transfer_id as warehouseTransferId,
  1207. a.entry_number as entryNumber,
  1208. a.supply_warehouse_id as supplyWarehouseId,
  1209. a.material_id as materialId,
  1210. ifnull(a.wbs, '') as wbsId,
  1211. a.out_num as outNum,
  1212. ifnull(b.code, '') as wbsCode,
  1213. ifnull(b.name, '') as wbsName
  1214. from tld_return_warehouse_transfer_z a
  1215. left join tld_wbs b on a.wbs = b.tld_id
  1216. where a.warehouse_transfer_id = #{warehouseTransferId}
  1217. and a.supply_warehouse_id = #{warehouseWhere}
  1218. </select>
  1219. <!-- 删除生产领料 -->
  1220. <delete id="delAskGoods">
  1221. delete
  1222. from tld_ask_goods
  1223. where id = #{id}
  1224. </delete>
  1225. <!--删除移库父表-->
  1226. <delete id="delReturnWarehouseTransfer">
  1227. delete
  1228. from tld_return_warehouse_transfer
  1229. where warehouse_transfer_code = #{removalCode}
  1230. </delete>
  1231. <!--删除移库子表-->
  1232. <delete id="delReturnWarehouseTransferZ">
  1233. delete
  1234. from tld_return_warehouse_transfer_z
  1235. where warehouse_transfer_id = #{warehouseTransferTd}
  1236. </delete>
  1237. <!--删除生产收货父表-->
  1238. <delete id="delNoticeParent">
  1239. delete
  1240. from tld_notice_f
  1241. where notice_id = #{orderNumber}
  1242. </delete>
  1243. <!--删除生产收货子表-->
  1244. <delete id="delNoticeSubtabulation">
  1245. delete
  1246. from tld_notice
  1247. where notice_id = #{orderNumber}
  1248. </delete>
  1249. <!--删除其它入库父表信息-->
  1250. <delete id="delNoticesParent">
  1251. delete
  1252. from tld_return_gs_other_warehousing
  1253. where storage_code = #{noticeId}
  1254. </delete>
  1255. <!--删除其它入库子表信息-->
  1256. <delete id="delNoticesSubtabulation">
  1257. delete
  1258. from tld_notices
  1259. where notice_id = #{noticeId}
  1260. </delete>
  1261. <!--删除虚拟表-->
  1262. <delete id="delReturnGsWarehousing">
  1263. delete
  1264. from tld_return_gs_warehousing
  1265. where order_number = #{orderNumber}
  1266. </delete>
  1267. <!-- 查询名牌物料CODE -->
  1268. <select id="getMing" resultType="String">
  1269. select wllb_code from tld_mingpai where code = #{code}
  1270. </select>
  1271. <!--查询入库单信息-->
  1272. <select id="getReturnGsWarehousing" resultType="com.tld.model.ReturnWarehousing">
  1273. select
  1274. id,
  1275. storage_code,
  1276. gs_ck,
  1277. source_type,
  1278. move_type,
  1279. entry_number,
  1280. wbs,
  1281. material_id,
  1282. warehousing_num,
  1283. receive_goods_id,
  1284. scrq,
  1285. order_number,
  1286. user_name,
  1287. storage_location_code
  1288. from tld_return_gs_warehousing where storage_code = #{removalCode}
  1289. </select>
  1290. <!--根据库位查询仓库-->
  1291. <select id="getStorageLocationWarehouseWhere" resultType="java.util.Map">
  1292. SELECT
  1293. a.id as id,
  1294. a.storage_code as storageCde,
  1295. a.gs_ck as accountSleeve,
  1296. a.source_type as sourceType,
  1297. a.move_type as moveType,
  1298. a.entry_number as entryNumber,
  1299. ifnull(a.wbs, '') as wbsId,
  1300. a.material_id as materialId,
  1301. a.warehousing_num as num,
  1302. a.receive_goods_id as receiveGoodsId,
  1303. a.scrq as scrq,
  1304. a.order_number as orderNumber,
  1305. a.user_name as userName,
  1306. a.storage_location_code as storageLocationCode,
  1307. b.warehouse_where as warehouseWhere
  1308. FROM tld_return_gs_warehousing a
  1309. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1310. WHERE a.storage_code = #{removalCode}
  1311. group by b.warehouse_where
  1312. </select>
  1313. <!--查询父表信息-->
  1314. <select id="getNoticeParent" resultType="java.util.Map">
  1315. select
  1316. id as id,
  1317. notice_id as noticeId,
  1318. notice_code as noticeCode,
  1319. company_number as companyNumber,
  1320. notice_time as noticeTime,
  1321. source_type as sourceType,
  1322. move_type as moveType
  1323. from tld_notice_f where notice_id = #{orderNumber}
  1324. </select>
  1325. <!--查询子表信息-->
  1326. <select id="getNoticeSubtabulation" resultType="java.util.Map">
  1327. select
  1328. a.id as id,
  1329. a.notice_id as noticeId,
  1330. a.entry_number as entryNumber,
  1331. a.production_code as productionCode,
  1332. a.material_id as materialId,
  1333. ifnull(a.wbs, '') as wbsId,
  1334. a.measurement_id as measurementId,
  1335. a.num as num,
  1336. a.type as type,
  1337. a.warehousing_num as warehousingNum,
  1338. ifnull(b.code, '') as wbsCode,
  1339. ifnull(b.name, '') as wbsName
  1340. from tld_notice a
  1341. left join tld_wbs b on a.wbs = b.tld_id
  1342. where a.notice_id = #{orderNumber}
  1343. </select>
  1344. <!--查询库存数量-->
  1345. <select id="getAmount" resultType="java.lang.String">
  1346. select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
  1347. </select>
  1348. <!--根据入库单编号查询入库单信息-->
  1349. <select id="getReturnGsOtherWarehousing" resultType="com.tld.model.ReturnWarehousing">
  1350. select
  1351. distinct
  1352. id,
  1353. storage_code,
  1354. account_sleeve,
  1355. storage_location_code,
  1356. wbs,
  1357. amount,
  1358. material_id,
  1359. notice_id
  1360. from tld_return_gs_other_warehousing where storage_code = #{removalCode}
  1361. group by notice_id
  1362. </select>
  1363. <!--查询其他入库表信息-->
  1364. <select id="getNoticesParent" resultType="java.util.Map">
  1365. SELECT
  1366. a.id as id,
  1367. a.storage_code as storageCde,
  1368. a.account_sleeve as accountSleeve,
  1369. a.storage_location_code as storageLocationCode,
  1370. a.notice_id as noticeId,
  1371. a.notice_code as noticeCode,
  1372. a.amount as amount,
  1373. ifnull(a.wbs, '') as wbsId,
  1374. ifnull(a.wbs_code, '') as wbsCode,
  1375. ifnull(a.wbs_name, '') as wbsName,
  1376. a.notice_time as noticeTime,
  1377. a.source_type as sourceType,
  1378. a.move_type as moveType,
  1379. a.entry_number as entryNumber,
  1380. a.wms_item_id as wmsItemId,
  1381. a.material_id as materialId,
  1382. a.wms_id as wmsId,
  1383. b.warehouse_where as warehouseWhere
  1384. FROM tld_return_gs_other_warehousing a
  1385. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1386. WHERE a.storage_code = #{noticeId} and a.storage_location_code = #{storageLocationCode}
  1387. </select>
  1388. <!--查询其他入库子表信息-->
  1389. <select id="getNoticesSubtabulation" resultType="java.util.Map">
  1390. select
  1391. a.id as id,
  1392. a.notice_id as noticeId,
  1393. a.entry_number as entryNumber,
  1394. a.material_id as materialId,
  1395. ifnull(a.wbs, '') as wbsId,
  1396. a.measurement_id as measurementId,
  1397. a.num as num,
  1398. a.type as type,
  1399. a.warehousing_num as warehousingNum,
  1400. ifnull(b.code, '') as wbsCode,
  1401. ifnull(b.name, '') as wbsName
  1402. from tld_notices a
  1403. left join tld_wbs b on a.wbs = b.tld_id
  1404. join tld_storage_location c on a.storage_location_code = c.storage_location_code
  1405. where a.notice_id = #{noticeId}
  1406. </select>
  1407. <!--查询仓库信息-->
  1408. <select id="getCreateOtherInStockWarehouseWhere" resultType="java.util.Map">
  1409. SELECT
  1410. a.id as id,
  1411. a.storage_code as storageCde,
  1412. a.account_sleeve as accountSleeve,
  1413. a.storage_location_code as storageLocationCode,
  1414. a.notice_id as noticeId,
  1415. a.notice_code as noticeCode,
  1416. a.amount as amount,
  1417. ifnull(a.wbs, '') as wbsId,
  1418. ifnull(a.wbs_code, '') as wbsCode,
  1419. ifnull(a.wbs_name, '') as wbsName,
  1420. a.notice_time as noticeTime,
  1421. a.source_type as sourceType,
  1422. a.move_type as moveType,
  1423. a.entry_number as entryNumber,
  1424. a.wms_item_id as wmsItemId,
  1425. a.material_id as materialId,
  1426. a.wms_id as wmsId,
  1427. b.warehouse_where as warehouseWhere
  1428. FROM tld_return_gs_other_warehousing a
  1429. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1430. WHERE a.storage_code = #{removalCode}
  1431. group by b.warehouse_where
  1432. </select>
  1433. <!--查询其他发货补领料仓库-->
  1434. <select id="getCreateOtherDeliveryMaterialsWarehouseWhere" resultType="java.util.Map">
  1435. SELECT DISTINCT b.warehouse_where as warehouseWhere
  1436. FROM tld_return_gs_removal_z a
  1437. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1438. join tld_return_gs_removal c on a.document_id = c.document_id
  1439. WHERE c.removal_code = #{removalCode}
  1440. </select>
  1441. <!--查询其他发货父表信息-->
  1442. <select id="getCreateOtherDeliveryMaterialsParent" resultType="java.util.Map">
  1443. select
  1444. id as id,
  1445. ask_goods_id as askGoodsId,
  1446. ask_goods_code as askGoodsCode,
  1447. company_number as companyNumber,
  1448. sqrq as sqrq,
  1449. department as department,
  1450. request_type_number as requestTypeNumber,
  1451. request_type_name as requestType_name,
  1452. source_type as sourceType,
  1453. move_type as moveType,
  1454. if_commodity as ifCommodity,
  1455. ifnull(product_code, '') as productCode,
  1456. from tld_enquiry_f where ask_goods_id = #{documentId}
  1457. </select>
  1458. <!--其他发货父表信息-->
  1459. <select id="getGsRemovals" resultType="java.util.Map">
  1460. select id,
  1461. document_id as askGoodsId,
  1462. removal_code as removalCode,
  1463. source_type as sourceType,
  1464. move_type as moveType,
  1465. scrq
  1466. from tld_return_gs_removal
  1467. where removal_code = #{removalCode}
  1468. </select>
  1469. <!--销售发货单接口查询仓库-->
  1470. <select id="getWarehouseWheres" resultType="java.lang.String">
  1471. SELECT DISTINCT b.warehouse_where as warehouseWhere
  1472. FROM tld_return_gs_removal_z a
  1473. JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
  1474. join tld_return_gs_removal c on a.document_id = c.document_id
  1475. WHERE c.removal_code = #{removalCode}
  1476. </select>
  1477. <select id="test03" resultType="java.util.Map">
  1478. select order_number as orderNumber from tld_return_gs_warehousing where source_type <![CDATA[!=]]> 'W'
  1479. </select>
  1480. <!--生产收货接口文档/报工单 w-->
  1481. <select id="test04" resultType="java.util.Map">
  1482. select storage_code as storageCode from tld_return_gs_warehousing where source_type <![CDATA[=]]> 'W'
  1483. </select>
  1484. <select id="getOutgoingReturnList" resultType="com.tld.model.OutgoingReturn">
  1485. select id,ask_id,ask_code,entry_number,amount,amount_num,amount_number,move_type,material_id,inventory_organization,warehouse,wbs from tld_outgoing_return
  1486. </select>
  1487. <!--查询storage_location_code库位编号-->
  1488. <select id="getLocationCode" resultType="java.lang.String">
  1489. select storage_location_code from tld_storage_location where warehouse_where = #{warehouse} limit 1
  1490. </select>
  1491. <!--查询单据id-->
  1492. <select id="getOutgoingReturn" resultType="com.tld.model.ReturRemoval">
  1493. select id,document_id,removal_code,source_type,move_type,scrq,delivery_type from tld_return_gs_removal
  1494. </select>
  1495. <!--查询父表信息-->
  1496. <select id="getReturnInStorageF" resultType="com.tld.model.ReceiveGoods">
  1497. select order_number,order_code,company_number,supplier_id,arrival_time,order_type,source_type,move_type from tld_receive_goods_f
  1498. </select>
  1499. <!--查询子表信息-->
  1500. <select id="getReturnInStorageZ" resultType="com.tld.model.ReceiveGoods">
  1501. select order_code,material_id,purchase_num,arrival_num,type,qualified_num,disqualification_num,wbs,arrival_time,measurement_id,supplier_id,entry_number,warehousing_num from tld_receive_goods where order_code = #{orderCode}
  1502. </select>
  1503. <!--查询物料类型-->
  1504. <select id="getMaterialPartType" resultType="java.lang.String">
  1505. select part_type from tld_material where tld_id = #{materialId}
  1506. </select>
  1507. <!--出库错误信息回调-->
  1508. <select id="getOutgoingReturnError" resultType="com.tld.model.Error">
  1509. select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
  1510. where transmission_type = '3'
  1511. and type = '出库回传'
  1512. </select>
  1513. <!--查询销售出库导入数据-->
  1514. <select id="getMarketList" resultType="com.tld.model.MarketReturn">
  1515. select id,order_number,order_officer,supplier_name,material_code,material_name,num,arrival_time,arrival_type,company,remark,delivery_order,delivery_or_not from tld_market_return
  1516. </select>
  1517. <!--查询销售单父子表信息-->
  1518. <select id="getDeliveryF" resultType="com.tld.model.Delivery">
  1519. select
  1520. id,delivery_id,delivery_code,company_number,customer_code,bills_time,delivery_type,source_type,move_type,project_name,project_code
  1521. from tld_delivery_f
  1522. where company_number = '8130'
  1523. and delivery_code = #{deliveryOrder}
  1524. </select>
  1525. <!--查询销售单父子表信息-->
  1526. <select id="getDeliveryZ" resultType="com.tld.model.Delivery">
  1527. select
  1528. id,delivery_id,entry_number,material_id,wbs,measurement_id,gs_delivery_num,gs_cancel_num,out_num,status
  1529. from tld_delivery
  1530. where delivery_id = #{deliveryId}
  1531. and material_id = #{materialId}
  1532. and out_num <![CDATA[=]]> '0'
  1533. </select>
  1534. <!--查询符合条件的数据-->
  1535. <select id="getStorage" resultType="java.util.LinkedHashMap">
  1536. select
  1537. IFNULL(a.wllb_code, '') AS wllbCode,
  1538. IFNULL(a.supplier_id, '') AS supplier_id,
  1539. IFNULL(a.serial, '') AS serial,
  1540. IFNULL(a.produc_date, '') AS produc_date,
  1541. IFNULL(a.produc_batch, '') AS produc_batch,
  1542. IFNULL(a.capacity, '') AS capacity,
  1543. IFNULL(a.process, '') AS process,
  1544. IFNULL(a.seq, '') AS seq,
  1545. IFNULL(a.type, '') AS type,
  1546. IFNULL(a.user_id, '') AS user_id,
  1547. a.department_id,
  1548. IFNULL(a.wllb_code, '') AS wllbCode,
  1549. a.storage_location_code,
  1550. IFNULL(a.wllb_code, '') AS wllbCode,
  1551. a.scrq,
  1552. IFNULL(a.wllb_code, '') AS wllbCode,
  1553. a.storage_code,
  1554. IFNULL(a.wllb_code, '') AS wllbCode,
  1555. a.wbs,
  1556. IFNULL(a.wllb_code, '') AS wllbCode,
  1557. IFNULL(a.order_code, '') AS orderCode,
  1558. a.account_sleeve,
  1559. IFNULL(a.wllb_code, '') AS wllbCode,
  1560. IFNULL(a.purchase_num, '') AS purchaseNum,
  1561. IFNULL(a.transmission_type, '') AS transmission_type
  1562. from tld_storage a
  1563. join tld_market_return b on a.wllb_code = b.material_code
  1564. where account_sleeve = '8130'
  1565. </select>
  1566. <!--入库错误信息回调-->
  1567. <select id="getStorageReturnError" resultType="com.tld.model.Error">
  1568. select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
  1569. where transmission_type = '1'
  1570. and type = '入库回传'
  1571. </select>
  1572. <!--移库错误信息回调-->
  1573. <select id="parkingReturnError" resultType="com.tld.model.Error">
  1574. select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
  1575. where transmission_type = '1'
  1576. and type = '移库'
  1577. </select>
  1578. <!--移库跑数据-->
  1579. <select id="shiftingParkingReturn" resultType="com.tld.model.WarehouseTransfer">
  1580. select id,warehouse_transfer_id,warehouse_transfer_code,ask_goods_warehouse_id,warehouse_transfer_type,scrq from tld_return_warehouse_transfer
  1581. </select>
  1582. <!--查询非生产领料-->
  1583. <select id="getAskGoodsMaterialNot" resultType="com.tld.model.AskGoods">
  1584. SELECT a.ask_goods_id,
  1585. a.material_id,
  1586. a.num,
  1587. IFNULL(a.out_num, 0) AS out_num,
  1588. e.NAME AS materialName,
  1589. e.CODE AS materialCode,
  1590. e.part_type as partType,
  1591. b.ask_goods_code,
  1592. b.company_number,
  1593. b.sqrq,
  1594. c.name,
  1595. c.code,
  1596. c.id AS departmentId,
  1597. a.production_code,
  1598. a.wbs,
  1599. a.entry_number,
  1600. e.wllb_class
  1601. FROM tld_invite a
  1602. JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
  1603. LEFT JOIN tld_department c ON b.department = c.code
  1604. JOIN tld_material e ON a.material_id = e.tld_id
  1605. WHERE (a.num + 0) <![CDATA[>]]> (
  1606. IFNULL(a.out_num, 0) + 0)
  1607. and e.part_type != '半成品' and e.part_type != '产成品'
  1608. and a.ask_goods_id = #{askGoodsId} and e.code in (select material_id from tld_user_material where user_id = #{userId})
  1609. </select>
  1610. <!--其它入库错误信息回调-->
  1611. <select id="otherWarehousingReturnError" resultType="com.tld.model.Error">
  1612. select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
  1613. where transmission_type = '1'
  1614. and type = '其它入库'
  1615. </select>
  1616. <!--转JSON-->
  1617. <select id="getJsonError" resultType="com.tld.model.Error">
  1618. select id,url,error_info,data_val,scrq,type,transmission_type from tld_error_excel_parking
  1619. where type = '出库回传'
  1620. </select>
  1621. <select id="getProductionReturnError" resultType="com.tld.model.Error">
  1622. select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
  1623. where transmission_type = '3'
  1624. and type = '生产收货'
  1625. </select>
  1626. <!-- 查询生产领料回调信息 -->
  1627. <select id="getCallback" resultType="com.tld.model.ReturRemoval">
  1628. select document_id,name from tld_return_gs_removal where source_type = "8" and move_type = "207"
  1629. </select>
  1630. <!--查询父表信息-->
  1631. <select id="getMergeGsF" resultType="com.tld.model.ReturRemoval">
  1632. select
  1633. id,
  1634. ask_goods_id,
  1635. ask_goods_code,
  1636. company_number,
  1637. sqrq,
  1638. department,
  1639. source_type,
  1640. move_type,
  1641. request_type_number,
  1642. request_type_name,
  1643. if_commodity
  1644. from tld_ask_goods_f
  1645. </select>
  1646. <!--查询子表信息-->
  1647. <select id="getMergeGsZ" resultType="com.tld.model.ReturRemoval">
  1648. select
  1649. ask_goods_id,
  1650. entry_number,
  1651. production_code,
  1652. material_id,
  1653. wbs,
  1654. measurement_id,
  1655. num,
  1656. out_num,
  1657. type
  1658. from tld_ask_goods where ask_goods_id = #{askGoodsId}
  1659. </select>
  1660. <!--移库获取单据物料code分录号数量-->
  1661. <select id="getjsonErrorParking" resultType="com.tld.model.Error">
  1662. select
  1663. id,
  1664. url,
  1665. error_info,
  1666. data_val,
  1667. scrq,
  1668. type,
  1669. transmission_type,
  1670. order_number,
  1671. material_code,
  1672. num,
  1673. classify
  1674. from tld_error_excel_parking
  1675. </select>
  1676. <!--查询物料code-->
  1677. <select id="getMaterialCode" resultType="java.lang.String">
  1678. select code from tld_material where tld_id = #{material}
  1679. </select>
  1680. <!--error错误信息全部跑调用错误回传-->
  1681. <select id="getErrorParkingReturn" resultType="com.tld.model.Error">
  1682. select
  1683. id,
  1684. url,
  1685. error_info,
  1686. data_val,
  1687. scrq,
  1688. type,
  1689. transmission_type
  1690. from tld_error
  1691. where transmission_type = '1'
  1692. </select>
  1693. <!--查询入库返回GS表信息-->
  1694. <select id="getCallPlugOutWarehousing" resultType="java.util.Map">
  1695. select
  1696. order_number as orderNumber ,
  1697. user_name as UserName
  1698. from tld_return_gs_warehousing
  1699. where source_type <![CDATA[!=]]> 'W'
  1700. </select>
  1701. <!--查询用户信息-->
  1702. <select id="getUserName" resultType="java.lang.String">
  1703. select real_name from tld_user where user_name = #{userName}
  1704. </select>
  1705. <!-- 修改数据传输状态 -->
  1706. <update id="updateRemoval">
  1707. update tld_removal set transmission_type = "1" where storage_code = #{removalCode}
  1708. <if test="material != null and material != ''">
  1709. and wllb_code = #{material}
  1710. </if>
  1711. </update>
  1712. <!-- 修改数据传输状态 -->
  1713. <update id="updateRemovalHalfProduct">
  1714. update tld_removal_half_product set transmission_type = "1" where storage_code = #{removalCode}
  1715. </update>
  1716. <!-- 修改数据传输状态 -->
  1717. <update id="updateRemovalHalf">
  1718. update tld_removal_half set transmission_type = "1" where storage_code = #{removalCode}
  1719. </update>
  1720. <!-- 往单据上增加数量 -->
  1721. <update id="updateEnquiryOutNum">
  1722. update tld_enquiry set out_num = (out_num + 0) + #{num} where ask_goods_id = #{askGoodsId} and entry_number = #{entryNumber}
  1723. </update>
  1724. <!--产成品出库流水修改连翻号-->
  1725. <update id="UpdSerial">
  1726. update tld_removal_half set serial = #{serial} where id = #{id}
  1727. </update>
  1728. <!--修改-->
  1729. <update id="updJSONError">
  1730. update tld_error_excel_parking set data_val = #{dataVal} where id = #{id}
  1731. </update>
  1732. <!--修改error-->
  1733. <update id="updErrorParking">
  1734. update tld_error_excel_parking set order_number = #{orderNumber} , material_code = #{materialCode} , num = #{num} , classify = #{classify}
  1735. where id = #{id}
  1736. </update>
  1737. </mapper>