| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.tld.mapper.AskGoodsMapper">
- <!-- 查询要货单id+物料id是否存在 -->
- <select id="getAskGoods" resultType="int">
- select count(*)
- from tld_ask_goods
- where ask_goods_id = #{askGoodsId}
- and material_id = #{materialId}
- </select>
- <!-- 修改要料申请单数量 -->
- <update id="updateAskGoodsNum">
- update tld_ask_goods
- set num =#{num}
- where ask_goods_id = #{askGoodsId}
- and material_id = #{materialId}
- </update>
- <!-- 新增要料申请单 -->
- <insert id="addAskGoods">
- insert into tld_ask_goods(ask_goods_id, entry_number, production_code, material_id, wbs, measurement_id, num,
- type, out_num)
- values (#{askGoodsId}, #{entryNumber}, #{productionCode}, #{materialId}, #{wbs}, #{measurementId}, #{num},
- #{type}, '0')
- </insert>
- <!-- 新增要料日志 -->
- <insert id="addAskGoodsLog">
- insert into tld_ask_goods_log(ask_goods_id, entry_number, production_code, material_id, wbs, measurement_id,
- num, out_num, ask_goods_code, company_number, sqrq, department_id, source_type,
- move_type, ask_goods_type,request_type_number,request_type_name,if_commodity)
- values (#{askGoodsId}, #{entryNumber}, #{productionCode}, #{materialId}, #{wbs}, #{measurementId}, #{num},
- #{outNum}, #{askGoodsCode}, #{companyNumber}, #{sqrq}, #{departmentId}, #{sourceType}, #{moveType},
- #{askGoodsType},#{requestTypeNumber},#{requestTypeName},#{ifCommodity})
- </insert>
- <!-- 查询次要货单是否存在 -->
- <select id="getAskGoodsf" resultType="int">
- select count(*)
- from tld_ask_goods_f
- where ask_goods_id = #{askGoodsId}
- and ask_goods_code = #{askGoodsCode}
- </select>
- <!-- 新增要料申请单父级 -->
- <insert id="addAskGoodsf">
- insert into tld_ask_goods_f(ask_goods_id, ask_goods_code, company_number, sqrq, department, source_type,
- move_type,request_type_number,request_type_name,if_commodity)
- values (#{askGoodsId}, #{askGoodsCode}, #{companyNumber}, #{sqrq}, #{departmentId}, #{sourceType}, #{moveType},#{requestTypeNumber},#{requestTypeName},#{ifCommodity})
- </insert>
- <!-- 查询生产领料单 -->
- <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
- SELECT a.ask_goods_id,
- a.material_id,
- IFNULL(a.out_num, 0) AS num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- b.ask_goods_code,
- b.company_number,
- c.name as departmentName,
- g.name as companyName,
- b.source_type,
- b.move_type,
- a.entry_number,
- a.production_code,
- a.wbs,
- w.name as wbsName
- FROM tld_ask_goods a
- JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
- LEFT JOIN tld_department c ON b.department = c.code
- JOIN tld_material e ON a.material_id = e.tld_id
- left join tld_company g on b.company_number = g.code
- left join tld_wbs w on a.wbs = w.tld_id
- WHERE (a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0)
- and e.part_type != '半成品' and e.part_type != '产成品'
- </select>
- <!-- 查询指定生产单的物料 -->
- <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
- SELECT a.ask_goods_id,
- a.material_id,
- a.num,
- IFNULL(a.out_num, 0) AS out_num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- e.part_type as partType,
- b.ask_goods_code,
- b.company_number,
- b.sqrq,
- c.name,
- c.code,
- c.id AS departmentId,
- a.production_code,
- a.wbs,
- a.entry_number,
- e.wllb_class,
- a.wbs,
- f.name as wbsCode
- FROM tld_ask_goods a
- JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
- LEFT JOIN tld_department c ON b.department = c.code
- JOIN tld_material e ON a.material_id = e.tld_id
- LEFT JOIN tld_wbs f ON a.wbs = f.tld_id
- WHERE ((a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
- and e.part_type != '半成品' and e.part_type != '产成品'
- and a.ask_goods_id = #{askGoodsId} and e.code in (select material_id from tld_user_material where user_id = #{userId})
- </select>
- <!-- 查询指定生产单的物料 -->
- <select id="getAskGoodsMaterialTest" resultType="com.tld.model.AskGoods">
- SELECT a.ask_goods_id,
- a.material_id,
- a.num,
- IFNULL(a.out_num, 0) AS out_num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- e.part_type as partType,
- b.ask_goods_code,
- b.company_number,
- b.sqrq,
- c.name,
- c.code,
- c.id AS departmentId,
- a.production_code,
- a.wbs,
- a.entry_number,
- e.wllb_class,
- b.sqrq
- FROM tld_invite a
- JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
- LEFT JOIN tld_department c ON b.department = c.code
- JOIN tld_material e ON a.material_id = e.tld_id
- WHERE (a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0) and b.sqrq > '2023-05-12'
- </select>
- <!-- 物料库位选择 -->
- <select id="getMaterialCk" resultType="com.tld.model.Inventory">
- select
- a.id,
- a.storage_location_code,
- a.wllb_class,
- a.library_type,
- a.material_id,
- (a.amount - ifnull(a.amount_lock, 0)) as amount,
- a.total,
- a.totime,
- a.hold,
- a.amount_lock,
- a.account_sleeve,
- a.wbs,
- a.supplier_id,
- a.serial,
- a.wllb_code,
- a.produc_date,
- a.scrq,
- b.storage_location_name as storageLocationName
- from tld_inventory a
- join tld_storage_location b on a.storage_location_code = b.storage_location_code
- join tld_warehouse c on b.warehouse_where = c.tld_id
- where a.material_id = #{materialId}
- and a.account_sleeve = #{companyNumber}
- and a.hold = '0'
- and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2')
- and a.wbs = #{wbs}
- order by a.produc_batch
- </select>
- <!-- 新增出库虚拟表 -->
- <insert id="addAskGoodsVitrual">
- insert into tld_ask_goods_vitrual(unique_code, supplier_id, serial, wllb_code, produc_date, ask_goods_id, type,
- storage_location_code, num, user_id, department, attribute, account_sleeve,
- storage_location_code_rk, wbs, entry_number)
- values (#{uniqueCode}, #{supplierId}, #{serial}, #{wllbCode}, #{producDate}, #{askGoodsId}, #{type},
- #{storageLocationCode}, #{num}, #{userId}, #{department}, #{attribute}, #{companyNumber},
- #{storageLocationCodeRk}, #{wbs}, #{entryNumber})
- </insert>
- <!-- 查询指定库存内容 -->
- <select id="getInventory" resultType="com.tld.model.Inventory">
- select id,
- storage_location_code,
- wllb_class,
- library_type,
- material_id,
- amount,
- total,
- totime,
- hold,
- amount_lock,
- account_sleeve,
- wbs,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- scrq
- from tld_inventory
- where supplier_id = #{supplierId}
- and serial = #{serial}
- and wllb_code = #{wllbCode}
- and produc_date = #{producDate}
- and account_sleeve = #{companyNumber}
- <if test="wbs != null">
- and wbs = #{wbs}
- </if>
- </select>
- <!-- 查询指定库存内容 -->
- <select id="getInventoryWarehousing" resultType="com.tld.model.Inventory">
- select id,
- storage_location_code,
- wllb_class,
- library_type,
- material_id,
- amount,
- total,
- totime,
- hold,
- amount_lock,
- account_sleeve,
- wbs,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- scrq
- from tld_inventory
- where storage_location_code = #{storageLocationCode}
- and wllb_code = #{wllbCode}
- and account_sleeve = #{companyNumber}
- and wbs = #{wbs}
- </select>
- <!-- 查询库存是否充足 -->
- <select id="getAsk" resultType="com.tld.model.AskGoods">
- SELECT ifnull(sum(a.num), 0) as num
- FROM tld_ask_goods_vitrual a
- join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
- where a.storage_location_code = #{storageLocationCode}
- and a.serial = #{serial} and wbs = #{wbs} and account_sleeve = #{accountSleeve}
- </select>
- <!-- 查询是否扫描 -->
- <select id="getScanIsNot" resultType="java.util.Map">
- select (select ifnull(max(amount), 0)
- from tld_inventory
- where supplier_id = #{supplierId}
- and serial = #{serial}
- and wllb_code = #{wllbCode}
- and produc_date = #{producDate}) as inventoryNum,
- (select ifnull(sum(num), 0)
- from tld_ask_goods_vitrual
- where supplier_id = #{supplierId}
- and serial = #{serial}
- and wllb_code = #{wllbCode}
- and produc_date = #{producDate}
- and type = #{type}) as virtualNum
- from dual
- </select>
- <!-- 查询指定送货单信息 -->
- <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
- SELECT a.id,
- a.ask_goods_id,
- a.entry_number,
- a.production_code,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- ifnull(a.out_num, 0) as out_num
- FROM tld_ask_goods a
- join tld_material b on a.material_id = b.tld_id
- where a.ask_goods_id = #{askGoodsId}
- and b.code = #{wllbCode} and a.entry_number = #{entryNumber}
- </select>
- <!-- 查询指定移庫單 -->
- <select id="getWareInfo" resultType="com.tld.model.AskGoods">
- SELECT a.id,
- a.warehouse_transfer_id as askGoodsId,
- a.entry_number,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- ifnull(a.out_num, 0) as out_num
- FROM tld_warehouse_transfer a
- join tld_material b on a.material_id = b.tld_id
- where a.warehouse_transfer_id = #{askGoodsId}
- and b.code = #{wllbCode}
- </select>
- <!-- 查询已扫描总数 -->
- <select id="getAskInfoNumVitrual" resultType="int">
- select ifnull(sum(num), 0)
- from tld_ask_goods_vitrual
- where wllb_code = #{wllbCode}
- and ask_goods_id = #{askGoodsId}
- and account_sleeve = #{accountSleeve}
- and wbs = #{wbs}
- and type = #{type}
- </select>
- <!-- 查询此库存在虚拟表里占用的数量 -->
- <select id="getInventoryAlready" resultType="int">
- select ifnull(sum(num), 0)
- from tld_ask_goods_vitrual
- where supplier_id = #{supplierId}
- and serial = #{serial}
- and wllb_code = #{wllbCode}
- and produc_date = #{producDate}
- and account_sleeve = #{accountSleeve}
- and wbs = #{wbs}
- and type = #{type}
- </select>
- <!-- 查询虚拟表指定pda跟状态的的数据 -->
- <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
- select id,
- unique_code,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- ask_goods_id,
- type,
- storage_location_code,
- num,
- user_id,
- department,
- account_sleeve,
- wbs,
- storage_location_code_rk,
- entry_number
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode}
- and type = #{type}
- and ask_goods_id = #{askGoodsId}
- </select>
- <!-- 删除库存 -->
- <delete id="deleteInventory">
- delete
- from tld_inventory
- where id = #{id}
- </delete>
- <!-- 修改库存数量 -->
- <update id="updateInventory">
- UPDATE tld_inventory
- SET amount = convert(amount - #{amount}, decimal(12,3))
- WHERE id = #{id}
- </update>
- <!-- 删除虚拟表出库记录 -->
- <delete id="deleteVirtual">
- delete
- from tld_ask_goods_vitrual
- where id = #{id}
- </delete>
- <!-- 插入出库流水 -->
- <insert id="addRemoval">
- insert into tld_removal(wllb_code, supplier_id, serial, num, type, user_id, storage_location_code, scrq,
- process, ask_goods_id, produc_date, department, storage_code, wbs, account_sleeve,transmission_type)
- values (#{wllbCode}, #{supplierId}, #{serial}, #{num}, #{type}, #{userId}, #{storageLocationCode}, now(),
- #{process}, #{askGoodsId}, #{producDate}, #{department}, #{storageCode}, #{wbs}, #{companyNumber},'0')
- </insert>
- <!-- 查询指定物料类型的id -->
- <select id="getMaterialId" resultType="String">
- select tld_id
- from tld_material
- where code = #{wllbCode}
- </select>
- <!-- 查询要料申请单内容 -->
- <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
- select id,
- ask_goods_id,
- entry_number,
- production_code,
- material_id,
- wbs,
- measurement_id,
- num,
- out_num
- from tld_ask_goods
- where ask_goods_id = #{askGoodsId}
- and material_id = #{materialId}
- <if test="entryNumber != null and entryNumber != ''">
- and entry_number = #{entryNumber}
- </if>
- </select>
- <!-- 新增返回gs数据字表信息 -->
- <insert id="addReturnGsRemoval">
- insert into tld_return_gs_removal_z(material_id, wbs, num, entry_number, document_id, document_points_id,
- storage_location_code)
- values (#{materialId}, #{wbs}, #{num}, #{entryNumber}, #{documentId}, #{documentPointsId},
- #{storageLocationCode})
- </insert>
- <!-- 查询要货单父级信息 -->
- <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
- select id,
- ask_goods_id,
- ask_goods_code,
- company_number,
- sqrq,
- department,
- source_type,
- move_type,
- request_type_name
- from tld_ask_goods_f
- where ask_goods_id = #{askGoodsId}
- </select>
- <!-- 新增返回gs数据父表信息 -->
- <insert id="addReturnGsRemovalF">
- insert into tld_return_gs_removal(document_id, removal_code, source_type, move_type, scrq, delivery_type, name, request_type_name)
- values (#{documentId}, #{removalCode}, #{sourceType}, #{moveType}, now(), #{deliveryType}, #{name}, #{requestTypeName})
- </insert>
- <!-- 添加 tld_access 记录-->
- <insert id="addAccess">
- insert into tld_access (type, data, scrq, access_type)
- values (#{names}, #{returnGsRemoval}, now(), #{accessType})
- </insert>
- <!--出库回传数据导入-->
- <insert id="importExcel">
- insert into tld_outgoing_return(ask_id,ask_code,entry_number,amount,amount_num,amount_number,move_type,
- material_id,inventory_organization,warehouse,wbs)
- values
- <foreach collection="list" item="item" index="index" separator=",">
- (#{item.askId},#{item.askCode},#{item.entryNumber},#{item.amount},#{item.amountNum},#{item.amountNumber},#{item.moveType},#{item.materialId},#{item.inventoryOrganization},#{item.warehouse}
- ,#{item.wbs})
- </foreach>
- </insert>
- <!--添加GS返回数据-->
- <insert id="addReturnWarehousing">
- 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)
- values(#{storageCode},#{sourceType},#{moveType},#{entryNumber},#{wbs},#{materialId},#{warehousingNum},#{receiveGoodsId},now(),#{orderNumber},#{storageLocationCode})
- </insert>
- <!--销售出库导入数据-->
- <insert id="marketImport">
- insert into tld_market_return(order_number,order_officer,supplier_name,material_code,material_name,num,arrival_time,
- arrival_type,company,remark,delivery_order)
- values
- <foreach collection="list" item="item" index="index" separator=",">
- (#{item.orderNumber},#{item.orderOfficer},#{item.supplierName},#{item.materialCode},#{item.materialName},#{item.num},#{item.arrivalTime},#{item.arrivalType},#{item.company},#{item.remark}
- ,#{item.deliveryOrder})
- </foreach>
- </insert>
- <!--销售出库导入数据导入物料code-->
- <insert id="marketImports">
- insert into tld_market_return(material_code)
- values
- <foreach collection="list" item="item" index="index" separator=",">
- (#{item.materialCode})
- </foreach>
- </insert>
- <!-- 退库新增库存 -->
- <insert id="addInventory">
- <selectKey resultType="java.lang.String" order="AFTER" keyProperty="id">
- select LAST_INSERT_ID()
- </selectKey>
- 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)
- value(#{storageLocationCode},#{wllbClass},#{materialId},#{amount},now(),'0','0','0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producBatch}, ' ')
- </insert>
- <!-- 查询当天出库数量 -->
- <select id="getReturnRemovalCount" resultType="int">
- select count(*)
- from tld_return_gs_removal
- where scrq BETWEEN CONCAT(CURDATE(), ' 00:00:00') AND CONCAT(CURDATE(), ' 23:59:59');
- </select>
- <!-- 查询回传数据 -->
- <select id="plugOutRemoval" resultType="java.util.Map">
- select id,
- document_id as askGoodsId,
- removal_code as removalCode,
- source_type as sourceType,
- move_type as moveType,
- scrq,
- request_type_name as requestTypeName
- from tld_return_gs_removal
- where document_id = #{removalCode}
- </select>
- <!-- 查询字表回传数据 -->
- <select id="getRemovalz" resultType="java.util.Map">
- SELECT a.material_id AS materialId,
- a.wbs,
- a.num,
- a.entry_number AS entryNumber,
- a.document_id AS askGoodsId,
- a.document_points_id AS askId,
- ifnull(a.wbs, '') as wbsId,
- ifnull(c.code, '') as wbsCode,
- ifnull(c.name, '') as wbsName
- FROM tld_return_gs_removal_z a
- join tld_storage_location b on a.storage_location_code = b.storage_location_code
- left join tld_wbs c on a.wbs = c.tld_id
- WHERE a.document_id = #{askGoodsId}
- and b.warehouse_where = #{warehouseWhere}
- </select>
- <!-- 查询出库流水 -->
- <select id="getRemoval" resultType="com.tld.model.AskGoods">
- select
- a.id,
- b.name as materialName,
- a.wllb_code,
- h.name as supplierName,
- a.serial,
- a.type,
- c.user_name as userName,
- e.name as department,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.num,
- a.storage_code,
- a.wbs,
- w.name as wbsName,
- a.ask_goods_id,
- c.real_name as realName,
- a.account_sleeve,
- f.name as accountName,
- p.ask_goods_code as askGoodsCode
- from tld_removal a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_department e on a.department = e.code
- left join tld_storage_location g on a.storage_location_code = g.storage_location_code
- left join tld_customer h on a.supplier_id = h.code
- left join tld_company f on a.account_sleeve = f.code
- left join tld_ask_goods_f p on a.ask_goods_id = p.ask_goods_id
- left join tld_wbs w on a.wbs = w.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="type != null and type != ''">
- and a.type like CONCAT(CONCAT('%', #{type}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="department != null and department != ''">
- and a.department = #{department}
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and p.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 导出 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- if(h.name = '',null,h.name) as supplierName,
- if(a.serial = '',null,a.serial) as serial,
- a.type,
- c.user_name as userName,
- e.name as department,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.num,
- p.ask_goods_code,
- c.real_name,
- f.name as accountName,
- if(a.wbs = '' , null , a.wbs ) as wbs,
- if(w.name = '' , null , w.name ) as wbsName
- from tld_removal a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_department e on a.department = e.code
- left join tld_storage_location g on a.storage_location_code = g.storage_location_code
- left join tld_customer h on a.supplier_id = h.code
- left join tld_company f on a.account_sleeve = f.code
- left join tld_ask_goods_f p on a.ask_goods_id = p.ask_goods_id
- left join tld_wbs w on a.wbs = w.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="type != null and type != ''">
- and a.type like CONCAT(CONCAT('%', #{type}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="department != null and department != ''">
- and a.department = #{department}
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and p.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询指定pda出库虚拟表 -->
- <select id="getAskGoodsVitrual" resultType="com.tld.model.AskGoods">
- select id,
- unique_code,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- ask_goods_id,
- type,
- storage_location_code,
- num,
- user_id,
- department,
- account_sleeve,
- wbs,
- attribute,
- entry_number
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode}
- and type = #{type}
- </select>
- <!-- 删除指定虚拟表数据 -->
- <delete id="delAskGoodsVitrual">
- delete
- from tld_ask_goods_vitrual
- where id = #{id}
- and type = #{type}
- </delete>
- <!-- 删除出库回传主表信息 -->
- <delete id="delPlugOutRemoval">
- delete
- from tld_return_gs_removal
- where document_id = #{removalCode}
- </delete>
- <!-- 删除出库回传子表信息 -->
- <delete id="delRemovalz">
- delete
- from tld_return_gs_removal_z
- where document_id = #{removalCode}
- </delete>
- <!-- 删除入库回传信息 -->
- <delete id="delPlugOutWarehousing">
- delete
- from tld_return_gs_warehousing
- where #{orderNumber} LIKE CONCAT('%', CONCAT(order_number, ','), '%')
- </delete>
- <!-- 修改出库数量 -->
- <update id="updateOutNum">
- update tld_ask_goods
- set out_num = ifnull(out_num, 0) + #{num}
- where material_id = #{materialId}
- and ask_goods_id = #{askGoodsId}
- <if test="entryNumber != null and entryNumber != ''">
- and entry_number = #{entryNumber}
- </if>
- </update>
- <!-- 查询指定pda 指定物料扫描总数 -->
- <select id="getScanNum" resultType="String">
- select if(sum(num) is null, 0, sum(num))
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode}
- and ask_goods_id = #{askGoodsId}
- and wllb_code = #{wllbCode}
- and entry_number = #{entryNumber}
- </select>
- <!-- 查询半成品出库数据 -->
- <select id="getGoodsHalf" resultType="com.tld.model.AskGoods">
- SELECT
- a.id,
- a.material_id,
- a.num,
- a.production_code,
- b.name as materialName,
- b.code as materialCode,
- a.out_num,
- a.ask_goods_id,
- c.company_number,
- e.name as department,
- a.type,
- a.wbs,
- f.name as wbsCode,
- f.name as wbsName,
- f.code as wbsCode,
- a.entry_number,
- g.name as companyName,
- c.source_type,
- c.move_type,
- c.sqrq,
- c.ask_goods_code
- FROM
- tld_ask_goods a
- join tld_material b on a.material_id = b.tld_id
- join tld_ask_goods_f c on a.ask_goods_id = c.ask_goods_id
- left join tld_department e on c.department = e.code
- left join tld_company g on c.company_number = g.code
- left join tld_wbs f on a.wbs = f.tld_id
- WHERE
- (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and
- b.part_type = #{partType}
- <if test="userId != null and userId != ''">
- and b.code in (select material_id from tld_user_material where user_id = #{userId})
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and c.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="startTime != null and startTime != ''">
- and c.sqrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and c.sqrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="materialCode != null and materialCode != ''">
- and b.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and c.department = #{departmentCode}
- </if>
- <if test="companyCode != null and companyCode != ''">
- and c.company_number = #{companyCode}
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="sourceType != null and sourceType != ''">
- and c.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and c.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- order by a.id desc
- </select>
- <!-- 查询半成品出库流水 -->
- <select id="getRemovalHalfProduct" resultType="com.tld.model.AskGoods">
- select
- a.id,
- a.wllb_code,
- a.num,
- a.user_id,
- a.scrq,
- a.ask_goods_id,
- c.name as department,
- b.name as materialName,
- e.user_name as userName,
- b.code as materialCode,
- a.storage_code,
- a.wbs,
- w.name as wbsName,
- e.real_name as realName,
- a.account_sleeve,
- f.name as accountName,
- p.ask_goods_code as askGoodsCode
- from tld_removal_half_product a
- left join tld_material b on a.wllb_code = b.code
- left join tld_department c on a.department = c.code
- left join tld_user e on a.user_id = e.id
- left join tld_company f on a.account_sleeve = f.code
- left join tld_ask_goods_f p on a.ask_goods_id = p.ask_goods_id
- left join tld_wbs w on a.wbs = w.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and a.department = #{departmentCode}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and e.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and e.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and p.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询半成品出库流水导出 -->
- <select id="getRemovalHalfProductExcel" resultType="java.util.LinkedHashMap">
- select
- if(p.ask_goods_code = '' , null , p.ask_goods_code ) as askGoodsCode,
- a.storage_code as storageCode,
- a.wllb_code as wllbCode,
- b.name as materialName,
- a.num,
- e.user_name as userName,
- if(c.name = '' , null , c.name ) as department,
- if(a.wbs = '' , null , a.wbs ) as wbs,
- if(w.name = '' , null , w.name ) as wbsName,
- a.scrq,
- e.real_name as realName,
- f.name as accountName
- from tld_removal_half_product a
- left join tld_material b on a.wllb_code = b.code
- left join tld_department c on a.department = c.code
- left join tld_user e on a.user_id = e.id
- left join tld_company f on a.account_sleeve = f.code
- left join tld_ask_goods_f p on a.ask_goods_id = p.ask_goods_id
- left join tld_wbs w on a.wbs = w.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="departmentCode != null and departmentCode != ''">
- and a.department = #{departmentCode}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and e.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and e.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id like CONCAT(CONCAT('%', #{askGoodsId}), '%')
- </if>
- <if test="askGoodsCode != null and askGoodsCode != ''">
- and p.ask_goods_code like CONCAT(CONCAT('%', #{askGoodsCode}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 产成品出库流水 -->
- <select id="getRemovalHalf" resultType="com.tld.model.AskGoods">
- select
- a.id,
- a.wllb_code,
- a.num,
- a.user_id,
- a.scrq,
- a.delivery_id,
- a.company_number,
- a.customer_code,
- b.name as materialName,
- c.user_name as userName,
- e.name as customerName,
- f.name as companyName,
- b.code as materialCode,
- a.serial,
- a.storage_code,
- a.wbs,
- w.name as wbsName,
- c.real_name as realName,
- p.delivery_code as deliveryCode
- from tld_removal_half a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_customer e on a.customer_code = e.code
- left join tld_company f on a.company_number = f.code
- left join tld_delivery_f p on a.delivery_id = p.delivery_id
- left join tld_wbs w on a.wbs = w.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
- </if>
- <if test="deliveryCode != null and deliveryCode != ''">
- and p.delivery_code like CONCAT(CONCAT('%', #{deliveryCode}), '%')
- </if>
- <if test="companyCode != null and companyCode != ''">
- and a.company_number = #{companyCode}
- </if>
- <if test="customerCode != null and customerCode != ''">
- and a.customer_code = #{customerCode}
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="num != null and num != ''">
- and a.num = #{num}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 产成品导出出库流水 -->
- <select id="getRemovalHalfExcel" resultType="java.util.LinkedHashMap">
- select
- p.delivery_code as deliveryCode,
- b.name as materialName,
- a.num,
- c.user_name as userName,
- a.scrq,
- f.name as companyName,
- e.name,
- a.storage_code,
- if(a.wbs = '' , null , a.wbs ) as wbs,
- if(w.name = '' , null , w.name ) as wbsName,
- c.real_name as realName
- from tld_removal_half a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- left join tld_customer e on a.customer_code = e.code
- left join tld_company f on a.company_number = f.code
- left join tld_delivery_f p on a.delivery_id = p.delivery_id
- left join tld_wbs w on a.wbs = w.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id like CONCAT(CONCAT('%', #{deliveryId}), '%')
- </if>
- <if test="deliveryCode != null and deliveryCode != ''">
- and p.delivery_code like CONCAT(CONCAT('%', #{deliveryCode}), '%')
- </if>
- <if test="companyCode != null and companyCode != ''">
- and a.company_number = #{companyCode}
- </if>
- <if test="customerCode != null and customerCode != ''">
- and a.customer_code = #{customerCode}
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and w.name like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询指定物料的库存 -->
- <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
- select
- id,
- storage_location_code,
- wllb_class,
- library_type,
- material_id,
- amount,
- total,
- totime,
- hold,
- amount_lock,
- account_sleeve,
- wbs,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- scrq,
- produc_batch,
- attribute
- from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and
- account_sleeve = #{accountSleeve} and amount <![CDATA[>=]]> (#{num} + 0)
- <if test="wbs != null">
- and wbs = #{wbs}
- </if>
- <if test="storageLocationCode != '' and storageLocationCode != null">
- and storage_location_code = #{storageLocationCode}
- </if>
- <if test="serial != '' and serial != null">
- and serial = #{serial}
- </if>
- <if test="attribute != '' and attribute != null">
- and attribute = #{attribute}
- </if>
- <if test="producDate != '' and producDate != null">
- and produc_date = #{producDate}
- </if>
- <if test="supplierId != '' and supplierId != null">
- and supplier_id = #{supplierId}
- </if>
- order by produc_batch
- </select>
- <!-- 其他入库查询库存是否存在 -->
- <select id="getInventoryInfoOther" resultType="com.tld.model.Inventory">
- select
- a.id,
- a.storage_location_code,
- a.wllb_class,
- a.library_type,
- a.material_id,
- a.amount,
- a.total,
- a.totime,
- a.hold,
- a.amount_lock,
- a.account_sleeve,
- a.wbs,
- a.supplier_id,
- a.serial,
- a.wllb_code,
- a.produc_date,
- a.scrq,
- a.produc_batch,
- a.attribute,
- b.name as accountName,
- c.storage_location_name as storageLocationName,
- c.warehouse_where as warehouseWhere
- from tld_inventory a
- left join tld_company b on a.account_sleeve = b.code
- left join tld_storage_location c on a.storage_location_code = c.storage_location_code
- where material_id = #{materialId}
- <if test="wbs != '' and wbs != null">
- and a.wbs = #{wbs}
- </if>
- <if test="serial != '' and serial != null">
- and a.serial = #{serial}
- </if>
- <if test="attribute != '' and attribute != null">
- and a.attribute = #{attribute}
- </if>
- <if test="producDate != '' and producDate != null">
- and a.produc_batch = #{producDate}
- </if>
- <if test="supplierId != '' and supplierId != null">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="storageLocationCode != '' and storageLocationCode != null">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="accountSleeve != '' and accountSleeve != null">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </select>
- <!-- 查询仓库 -->
- <select id="getWarehouseWhere" resultType="String">
- SELECT DISTINCT b.warehouse_where
- FROM tld_return_gs_removal_z a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- WHERE a.document_id = #{removalCode}
- </select>
- <!-- 查询半成品原始数据 -->
- <select id="getInventoryNotice" resultType="java.util.Map">
- select *
- from tld_notice
- where id = #{id}
- </select>
- <!-- 删除半成品/产成品入库通知原始信息 -->
- <delete id="delInventoryNotice">
- delete
- from tld_notice
- where id = #{id}
- </delete>
- <!-- 查询要料申请单 -->
- <select id="getDelAskGoods" resultType="java.util.Map">
- select *
- from tld_ask_goods
- where id = #{id}
- </select>
- <!-- 销售发货单接口文档 父表信息 -->
- <select id="getGsRemoval" resultType="java.util.Map">
- select id,
- document_id as askGoodsId,
- removal_code as removalCode,
- source_type as sourceType,
- move_type as moveType,
- scrq
- from tld_return_gs_removal
- where removal_code = #{removalCode}
- </select>
- <!--查询移库子表中的供货仓库仓库-->
- <select id="getSupplyWarehouseWhere" resultType="java.lang.String">
- SELECT supply_warehouse_id
- FROM tld_return_warehouse_transfer_z
- WHERE warehouse_transfer_id = #{removalCode}
- GROUP BY supply_warehouse_id
- </select>
- <!--查询移库父表信息-->
- <select id="getReturnWarehouseTransfer" resultType="java.util.Map">
- select id,
- warehouse_transfer_id as warehouseTransferId,
- warehouse_transfer_code as warehouseTransferCode,
- ask_goods_warehouse_id as askGoodsWarehouseId,
- warehouse_transfer_type as warehouseTransferType,
- scrq
- from tld_return_warehouse_transfer
- where warehouse_transfer_code = #{removalCode}
- </select>
- <!--查询出父表中的移库id根据code-->
- <select id="getSupplyWarehouseWheres" resultType="java.lang.String">
- select warehouse_transfer_id as warehouseTransferId
- from tld_return_warehouse_transfer
- where warehouse_transfer_code = #{removalCode}
- </select>
- <!--查询移库子表信息-->
- <select id="getReturnWarehouseTransferZ" resultType="java.util.Map">
- select a.id,
- a.warehouse_transfer_id as warehouseTransferId,
- a.entry_number as entryNumber,
- a.supply_warehouse_id as supplyWarehouseId,
- a.material_id as materialId,
- ifnull(a.wbs, '') as wbsId,
- a.out_num as outNum,
- ifnull(b.code, '') as wbsCode,
- ifnull(b.name, '') as wbsName
- from tld_return_warehouse_transfer_z a
- left join tld_wbs b on a.wbs = b.tld_id
- where a.warehouse_transfer_id = #{warehouseTransferId}
- and a.supply_warehouse_id = #{warehouseWhere}
- </select>
- <!-- 删除生产领料 -->
- <delete id="delAskGoods">
- delete
- from tld_ask_goods
- where id = #{id}
- </delete>
- <!--删除移库父表-->
- <delete id="delReturnWarehouseTransfer">
- delete
- from tld_return_warehouse_transfer
- where warehouse_transfer_code = #{removalCode}
- </delete>
- <!--删除移库子表-->
- <delete id="delReturnWarehouseTransferZ">
- delete
- from tld_return_warehouse_transfer_z
- where warehouse_transfer_id = #{warehouseTransferTd}
- </delete>
- <!--删除生产收货父表-->
- <delete id="delNoticeParent">
- delete
- from tld_notice_f
- where notice_id = #{orderNumber}
- </delete>
- <!--删除生产收货子表-->
- <delete id="delNoticeSubtabulation">
- delete
- from tld_notice
- where notice_id = #{orderNumber}
- </delete>
- <!--删除其它入库父表信息-->
- <delete id="delNoticesParent">
- delete
- from tld_return_gs_other_warehousing
- where storage_code = #{noticeId}
- </delete>
- <!--删除其它入库子表信息-->
- <delete id="delNoticesSubtabulation">
- delete
- from tld_notices
- where notice_id = #{noticeId}
- </delete>
- <!--删除虚拟表-->
- <delete id="delReturnGsWarehousing">
- delete
- from tld_return_gs_warehousing
- where order_number = #{orderNumber}
- </delete>
- <!-- 查询名牌物料CODE -->
- <select id="getMing" resultType="String">
- select wllb_code from tld_mingpai where code = #{code}
- </select>
- <!--查询入库单信息-->
- <select id="getReturnGsWarehousing" resultType="com.tld.model.ReturnWarehousing">
- select
- id,
- storage_code,
- gs_ck,
- source_type,
- move_type,
- entry_number,
- wbs,
- material_id,
- warehousing_num,
- receive_goods_id,
- scrq,
- order_number,
- user_name,
- storage_location_code
- from tld_return_gs_warehousing where storage_code = #{removalCode}
- </select>
- <!--根据库位查询仓库-->
- <select id="getStorageLocationWarehouseWhere" resultType="java.util.Map">
- SELECT
- a.id as id,
- a.storage_code as storageCde,
- a.gs_ck as accountSleeve,
- a.source_type as sourceType,
- a.move_type as moveType,
- a.entry_number as entryNumber,
- ifnull(a.wbs, '') as wbsId,
- a.material_id as materialId,
- a.warehousing_num as num,
- a.receive_goods_id as receiveGoodsId,
- a.scrq as scrq,
- a.order_number as orderNumber,
- a.user_name as userName,
- a.storage_location_code as storageLocationCode,
- b.warehouse_where as warehouseWhere
- FROM tld_return_gs_warehousing a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- WHERE a.storage_code = #{removalCode}
- group by b.warehouse_where
- </select>
- <!--查询父表信息-->
- <select id="getNoticeParent" resultType="java.util.Map">
- select
- id as id,
- notice_id as noticeId,
- notice_code as noticeCode,
- company_number as companyNumber,
- notice_time as noticeTime,
- source_type as sourceType,
- move_type as moveType
- from tld_notice_f where notice_id = #{orderNumber}
- </select>
- <!--查询子表信息-->
- <select id="getNoticeSubtabulation" resultType="java.util.Map">
- select
- a.id as id,
- a.notice_id as noticeId,
- a.entry_number as entryNumber,
- a.production_code as productionCode,
- a.material_id as materialId,
- ifnull(a.wbs, '') as wbsId,
- a.measurement_id as measurementId,
- a.num as num,
- a.type as type,
- a.warehousing_num as warehousingNum,
- ifnull(b.code, '') as wbsCode,
- ifnull(b.name, '') as wbsName
- from tld_notice a
- left join tld_wbs b on a.wbs = b.tld_id
- where a.notice_id = #{orderNumber}
- </select>
- <!--查询库存数量-->
- <select id="getAmount" resultType="java.lang.String">
- select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
- </select>
- <!--根据入库单编号查询入库单信息-->
- <select id="getReturnGsOtherWarehousing" resultType="com.tld.model.ReturnWarehousing">
- select
- distinct
- id,
- storage_code,
- account_sleeve,
- storage_location_code,
- wbs,
- amount,
- material_id,
- notice_id
- from tld_return_gs_other_warehousing where storage_code = #{removalCode}
- group by notice_id
- </select>
- <!--查询其他入库表信息-->
- <select id="getNoticesParent" resultType="java.util.Map">
- SELECT
- a.id as id,
- a.storage_code as storageCde,
- a.account_sleeve as accountSleeve,
- a.storage_location_code as storageLocationCode,
- a.notice_id as noticeId,
- a.notice_code as noticeCode,
- a.amount as amount,
- ifnull(a.wbs, '') as wbsId,
- ifnull(a.wbs_code, '') as wbsCode,
- ifnull(a.wbs_name, '') as wbsName,
- a.notice_time as noticeTime,
- a.source_type as sourceType,
- a.move_type as moveType,
- a.entry_number as entryNumber,
- a.wms_item_id as wmsItemId,
- a.material_id as materialId,
- a.wms_id as wmsId,
- b.warehouse_where as warehouseWhere
- FROM tld_return_gs_other_warehousing a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- WHERE a.storage_code = #{noticeId} and a.storage_location_code = #{storageLocationCode}
- </select>
- <!--查询其他入库子表信息-->
- <select id="getNoticesSubtabulation" resultType="java.util.Map">
- select
- a.id as id,
- a.notice_id as noticeId,
- a.entry_number as entryNumber,
- a.material_id as materialId,
- ifnull(a.wbs, '') as wbsId,
- a.measurement_id as measurementId,
- a.num as num,
- a.type as type,
- a.warehousing_num as warehousingNum,
- ifnull(b.code, '') as wbsCode,
- ifnull(b.name, '') as wbsName
- from tld_notices a
- left join tld_wbs b on a.wbs = b.tld_id
- join tld_storage_location c on a.storage_location_code = c.storage_location_code
- where a.notice_id = #{noticeId}
- </select>
- <!--查询仓库信息-->
- <select id="getCreateOtherInStockWarehouseWhere" resultType="java.util.Map">
- SELECT
- a.id as id,
- a.storage_code as storageCde,
- a.account_sleeve as accountSleeve,
- a.storage_location_code as storageLocationCode,
- a.notice_id as noticeId,
- a.notice_code as noticeCode,
- a.amount as amount,
- ifnull(a.wbs, '') as wbsId,
- ifnull(a.wbs_code, '') as wbsCode,
- ifnull(a.wbs_name, '') as wbsName,
- a.notice_time as noticeTime,
- a.source_type as sourceType,
- a.move_type as moveType,
- a.entry_number as entryNumber,
- a.wms_item_id as wmsItemId,
- a.material_id as materialId,
- a.wms_id as wmsId,
- b.warehouse_where as warehouseWhere
- FROM tld_return_gs_other_warehousing a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- WHERE a.storage_code = #{removalCode}
- group by b.warehouse_where
- </select>
- <!--查询其他发货补领料仓库-->
- <select id="getCreateOtherDeliveryMaterialsWarehouseWhere" resultType="java.util.Map">
- SELECT DISTINCT b.warehouse_where as warehouseWhere
- FROM tld_return_gs_removal_z a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- join tld_return_gs_removal c on a.document_id = c.document_id
- WHERE c.removal_code = #{removalCode}
- </select>
- <!--查询其他发货父表信息-->
- <select id="getCreateOtherDeliveryMaterialsParent" resultType="java.util.Map">
- select
- id as id,
- ask_goods_id as askGoodsId,
- ask_goods_code as askGoodsCode,
- company_number as companyNumber,
- sqrq as sqrq,
- department as department,
- request_type_number as requestTypeNumber,
- request_type_name as requestType_name,
- source_type as sourceType,
- move_type as moveType,
- if_commodity as ifCommodity,
- ifnull(product_code, '') as productCode,
- from tld_enquiry_f where ask_goods_id = #{documentId}
- </select>
- <!--其他发货父表信息-->
- <select id="getGsRemovals" resultType="java.util.Map">
- select id,
- document_id as askGoodsId,
- removal_code as removalCode,
- source_type as sourceType,
- move_type as moveType,
- scrq
- from tld_return_gs_removal
- where removal_code = #{removalCode}
- </select>
- <!--销售发货单接口查询仓库-->
- <select id="getWarehouseWheres" resultType="java.lang.String">
- SELECT DISTINCT b.warehouse_where as warehouseWhere
- FROM tld_return_gs_removal_z a
- JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
- join tld_return_gs_removal c on a.document_id = c.document_id
- WHERE c.removal_code = #{removalCode}
- </select>
- <select id="test03" resultType="java.util.Map">
- select order_number as orderNumber from tld_return_gs_warehousing where source_type <![CDATA[!=]]> 'W'
- </select>
- <!--生产收货接口文档/报工单 w-->
- <select id="test04" resultType="java.util.Map">
- select storage_code as storageCode from tld_return_gs_warehousing where source_type <![CDATA[=]]> 'W'
- </select>
- <select id="getOutgoingReturnList" resultType="com.tld.model.OutgoingReturn">
- 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
- </select>
- <!--查询storage_location_code库位编号-->
- <select id="getLocationCode" resultType="java.lang.String">
- select storage_location_code from tld_storage_location where warehouse_where = #{warehouse} limit 1
- </select>
- <!--查询单据id-->
- <select id="getOutgoingReturn" resultType="com.tld.model.ReturRemoval">
- select id,document_id,removal_code,source_type,move_type,scrq,delivery_type from tld_return_gs_removal
- </select>
- <!--查询父表信息-->
- <select id="getReturnInStorageF" resultType="com.tld.model.ReceiveGoods">
- select order_number,order_code,company_number,supplier_id,arrival_time,order_type,source_type,move_type from tld_receive_goods_f
- </select>
- <!--查询子表信息-->
- <select id="getReturnInStorageZ" resultType="com.tld.model.ReceiveGoods">
- 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}
- </select>
- <!--查询物料类型-->
- <select id="getMaterialPartType" resultType="java.lang.String">
- select part_type from tld_material where tld_id = #{materialId}
- </select>
- <!--出库错误信息回调-->
- <select id="getOutgoingReturnError" resultType="com.tld.model.Error">
- select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
- where transmission_type = '3'
- and type = '出库回传'
- </select>
- <!--查询销售出库导入数据-->
- <select id="getMarketList" resultType="com.tld.model.MarketReturn">
- 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
- </select>
- <!--查询销售单父子表信息-->
- <select id="getDeliveryF" resultType="com.tld.model.Delivery">
- select
- id,delivery_id,delivery_code,company_number,customer_code,bills_time,delivery_type,source_type,move_type,project_name,project_code
- from tld_delivery_f
- where company_number = '8130'
- and delivery_code = #{deliveryOrder}
- </select>
- <!--查询销售单父子表信息-->
- <select id="getDeliveryZ" resultType="com.tld.model.Delivery">
- select
- id,delivery_id,entry_number,material_id,wbs,measurement_id,gs_delivery_num,gs_cancel_num,out_num,status
- from tld_delivery
- where delivery_id = #{deliveryId}
- and material_id = #{materialId}
- and out_num <![CDATA[=]]> '0'
- </select>
- <!--查询符合条件的数据-->
- <select id="getStorage" resultType="java.util.LinkedHashMap">
- select
- IFNULL(a.wllb_code, '') AS wllbCode,
- IFNULL(a.supplier_id, '') AS supplier_id,
- IFNULL(a.serial, '') AS serial,
- IFNULL(a.produc_date, '') AS produc_date,
- IFNULL(a.produc_batch, '') AS produc_batch,
- IFNULL(a.capacity, '') AS capacity,
- IFNULL(a.process, '') AS process,
- IFNULL(a.seq, '') AS seq,
- IFNULL(a.type, '') AS type,
- IFNULL(a.user_id, '') AS user_id,
- a.department_id,
- IFNULL(a.wllb_code, '') AS wllbCode,
- a.storage_location_code,
- IFNULL(a.wllb_code, '') AS wllbCode,
- a.scrq,
- IFNULL(a.wllb_code, '') AS wllbCode,
- a.storage_code,
- IFNULL(a.wllb_code, '') AS wllbCode,
- a.wbs,
- IFNULL(a.wllb_code, '') AS wllbCode,
- IFNULL(a.order_code, '') AS orderCode,
- a.account_sleeve,
- IFNULL(a.wllb_code, '') AS wllbCode,
- IFNULL(a.purchase_num, '') AS purchaseNum,
- IFNULL(a.transmission_type, '') AS transmission_type
- from tld_storage a
- join tld_market_return b on a.wllb_code = b.material_code
- where account_sleeve = '8130'
- </select>
- <!--入库错误信息回调-->
- <select id="getStorageReturnError" resultType="com.tld.model.Error">
- select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
- where transmission_type = '1'
- and type = '入库回传'
- </select>
- <!--移库错误信息回调-->
- <select id="parkingReturnError" resultType="com.tld.model.Error">
- select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
- where transmission_type = '1'
- and type = '移库'
- </select>
- <!--移库跑数据-->
- <select id="shiftingParkingReturn" resultType="com.tld.model.WarehouseTransfer">
- select id,warehouse_transfer_id,warehouse_transfer_code,ask_goods_warehouse_id,warehouse_transfer_type,scrq from tld_return_warehouse_transfer
- </select>
- <!--查询非生产领料-->
- <select id="getAskGoodsMaterialNot" resultType="com.tld.model.AskGoods">
- SELECT a.ask_goods_id,
- a.material_id,
- a.num,
- IFNULL(a.out_num, 0) AS out_num,
- e.NAME AS materialName,
- e.CODE AS materialCode,
- e.part_type as partType,
- b.ask_goods_code,
- b.company_number,
- b.sqrq,
- c.name,
- c.code,
- c.id AS departmentId,
- a.production_code,
- a.wbs,
- a.entry_number,
- e.wllb_class
- FROM tld_invite a
- JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
- LEFT JOIN tld_department c ON b.department = c.code
- JOIN tld_material e ON a.material_id = e.tld_id
- WHERE (a.num + 0) <![CDATA[>]]> (
- IFNULL(a.out_num, 0) + 0)
- and e.part_type != '半成品' and e.part_type != '产成品'
- and a.ask_goods_id = #{askGoodsId} and e.code in (select material_id from tld_user_material where user_id = #{userId})
- </select>
- <!--其它入库错误信息回调-->
- <select id="otherWarehousingReturnError" resultType="com.tld.model.Error">
- select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
- where transmission_type = '1'
- and type = '其它入库'
- </select>
- <!--转JSON-->
- <select id="getJsonError" resultType="com.tld.model.Error">
- select id,url,error_info,data_val,scrq,type,transmission_type from tld_error_excel_parking
- where type = '出库回传'
- </select>
- <select id="getProductionReturnError" resultType="com.tld.model.Error">
- select id,url,error_info,data_val,scrq,type,transmission_type from tld_error
- where transmission_type = '3'
- and type = '生产收货'
- </select>
- <!-- 查询生产领料回调信息 -->
- <select id="getCallback" resultType="com.tld.model.ReturRemoval">
- select document_id,name from tld_return_gs_removal where source_type = "8" and move_type = "207"
- </select>
- <!--查询父表信息-->
- <select id="getMergeGsF" resultType="com.tld.model.ReturRemoval">
- select
- id,
- ask_goods_id,
- ask_goods_code,
- company_number,
- sqrq,
- department,
- source_type,
- move_type,
- request_type_number,
- request_type_name,
- if_commodity
- from tld_ask_goods_f
- </select>
- <!--查询子表信息-->
- <select id="getMergeGsZ" resultType="com.tld.model.ReturRemoval">
- select
- ask_goods_id,
- entry_number,
- production_code,
- material_id,
- wbs,
- measurement_id,
- num,
- out_num,
- type
- from tld_ask_goods where ask_goods_id = #{askGoodsId}
- </select>
- <!--移库获取单据物料code分录号数量-->
- <select id="getjsonErrorParking" resultType="com.tld.model.Error">
- select
- id,
- url,
- error_info,
- data_val,
- scrq,
- type,
- transmission_type,
- order_number,
- material_code,
- num,
- classify
- from tld_error_excel_parking
- </select>
- <!--查询物料code-->
- <select id="getMaterialCode" resultType="java.lang.String">
- select code from tld_material where tld_id = #{material}
- </select>
- <!--error错误信息全部跑调用错误回传-->
- <select id="getErrorParkingReturn" resultType="com.tld.model.Error">
- select
- id,
- url,
- error_info,
- data_val,
- scrq,
- type,
- transmission_type
- from tld_error
- where transmission_type = '1'
- </select>
- <!--查询入库返回GS表信息-->
- <select id="getCallPlugOutWarehousing" resultType="java.util.Map">
- select
- order_number as orderNumber ,
- user_name as UserName
- from tld_return_gs_warehousing
- where source_type <![CDATA[!=]]> 'W'
- </select>
- <!--查询用户信息-->
- <select id="getUserName" resultType="java.lang.String">
- select real_name from tld_user where user_name = #{userName}
- </select>
- <!-- 修改数据传输状态 -->
- <update id="updateRemoval">
- update tld_removal set transmission_type = "1" where storage_code = #{removalCode}
- <if test="material != null and material != ''">
- and wllb_code = #{material}
- </if>
- </update>
- <!-- 修改数据传输状态 -->
- <update id="updateRemovalHalfProduct">
- update tld_removal_half_product set transmission_type = "1" where storage_code = #{removalCode}
- </update>
- <!-- 修改数据传输状态 -->
- <update id="updateRemovalHalf">
- update tld_removal_half set transmission_type = "1" where storage_code = #{removalCode}
- </update>
- <!-- 往单据上增加数量 -->
- <update id="updateEnquiryOutNum">
- update tld_enquiry set out_num = (out_num + 0) + #{num} where ask_goods_id = #{askGoodsId} and entry_number = #{entryNumber}
- </update>
- <!--产成品出库流水修改连翻号-->
- <update id="UpdSerial">
- update tld_removal_half set serial = #{serial} where id = #{id}
- </update>
- <!--修改-->
- <update id="updJSONError">
- update tld_error_excel_parking set data_val = #{dataVal} where id = #{id}
- </update>
- <!--修改error-->
- <update id="updErrorParking">
- update tld_error_excel_parking set order_number = #{orderNumber} , material_code = #{materialCode} , num = #{num} , classify = #{classify}
- where id = #{id}
- </update>
- </mapper>
|