| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609 |
- <?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
- 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
- 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
- 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
- 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="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 = amount - #{amount}
- 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
- 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)
- values (#{documentId}, #{removalCode}, #{sourceType}, #{moveType}, now(), #{deliveryType})
- </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>
- <!-- 查询当天出库数量 -->
- <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
- 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,
- 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
- <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 a.wbs 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
- 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
- <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 a.wbs 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,
- 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
- WHERE
- -- (a.num + 0) <![CDATA[>]]> (a.out_num + 0)
- 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,
- 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
- <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 a.wbs 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,
- 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
- <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 a.wbs 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,
- 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
- <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 a.wbs 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="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,
- a.wbs,
- 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
- <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 a.wbs 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>
- <select id="getJsonError" 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>
- <!-- 修改数据传输状态 -->
- <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>
- </mapper>
|