1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078 |
- <?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.WarehousingMapper">
- <sql id="field">
- order_code
- ,material_id,purchase_num,arrival_num,type,qualified_num,disqualification_num,wbs,arrival_time,measurement_id,supplier_id,entry_number,warehousing_num
- </sql>
- <!-- 查询物料库位 -->
- <select id="getMaterialClass" resultType="com.tld.model.MaterialClass">
- select a.id,
- a.storage_location_code,
- a.wllb_code
- from tld_material_class a
- join tld_material b on a.wllb_code = b.code
- where b.code = #{wllbCode}
- </select>
- <!-- 根据物料分类查询库位 -->
- <select id="getMaterialClassType" resultType="com.tld.model.MaterialClass">
- select b.id,
- b.storage_location_code
- from tld_material a
- join tld_storage_location b on b.storage_location_type like CONCAT('%', a.wllb_class, '%')
- where a.code = #{wllbCode}
- </select>
- <!-- 新增库位信息虚拟表 -->
- <insert id="addWarehousingVirtual">
- insert into tld_warehousing_virtual(unique_code, num, storage_location_code, wllb_code, supp_id, serial, type,
- produc_date, capacity, seq, user_id, storage_location_name, attribute,
- notice_id, warehouse_transfer_id, storage_location_code_ck,wbs, receive_goods_id, account_sleeve)
- values (#{uniqueCode}, #{num}, #{storageLocationCode}, #{wllbCode}, #{suppId}, #{serial}, #{type},
- #{producDate}, #{capacity}, #{seq}, #{userId}, #{storageLocationName}, #{attribute}, #{noticeId},
- #{warehouseTransferId}, #{storageLocationCodeCk},#{wbs},#{receiveGoodsId},#{accountSleeve})
- </insert>
- <!-- 查询总数量 -->
- <select id="getScanNum" resultType="java.util.Map">
- SELECT (ifnull(sum(a.num), 0) + ${num} + ifnull(sum(c.amount), 0)) as scanNum,
- ifnull(b.storage_location_capacity, 0) as storageLocationCapacity
- FROM tld_warehousing_virtual a
- right join tld_storage_location b on a.storage_location_code = b.storage_location_code
- left join tld_inventory c on b.storage_location_code = c.storage_location_code
- where b.storage_location_code = #{storageLocationCode}
- </select>
- <!-- 查询 -->
- <select id="recommend" resultType="com.tld.model.StorageLocation">
- SELECT id,
- storage_location_code,
- storage_location_name,
- warehouse_where,
- storage_location_type,
- storage_location_capacity,
- is_not_disable,
- create_time
- FROM tld_storage_location
- WHERE #{storageLocationCode} like CONCAT('%', CONCAT(storage_location_code, ','), '%')
- and warehouse_where != '5000'
- </select>
- <!-- 查询是否是混合物料 -->
- <select id="getIsNotSisable" resultType="String">
- select is_not_disable
- from tld_material
- where code = #{wllbCode}
- </select>
- <!-- 查询混合库位 -->
- <select id="getIsNotSisableLocation" resultType="com.tld.model.StorageLocation">
- select id,
- storage_location_code,
- storage_location_name,
- warehouse_where,
- storage_location_type,
- storage_location_capacity,
- is_not_disable,
- create_time
- from tld_storage_location
- where is_not_disable = #{isNotDisable}
- </select>
- <!-- 删除虚拟表 -->
- <delete id="delWarehousingVirtual">
- delete
- from tld_warehousing_virtual
- where id = #{id}
- </delete>
- <!-- 查询虚拟表数据进行入库 -->
- <select id="getVirtual" resultType="com.tld.model.WarehousingVirtual">
- select
- a.id,
- a.unique_code,
- a.num,
- a.storage_location_code,
- a.wllb_code,
- a.supp_id,
- a.serial,
- a.type,
- a.produc_date,
- a.capacity,
- a.seq,
- a.user_id,
- a.attribute,
- a.warehouse_transfer_id,
- a.storage_location_code_ck,
- a.storage_location_name,
- b.user_name,
- a.receive_goods_id,
- a.wbs,
- a.account_sleeve,
- a.warehouse_transfer_id
- from tld_warehousing_virtual a
- left join tld_user b on a.user_id = b.id
- where a.unique_code = #{uniqueCode} and a.type = #{type}
- <if test="warehouseTransferId != null and warehouseTransferId != ''">
- and a.warehouse_transfer_id = #{warehouseTransferId}
- </if>
- </select>
- <!-- 查询采购单信息 -->
- <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
- SELECT a.id,
- a.order_code,
- a.material_id,+
- a.purchase_num,
- a.arrival_num,
- a.type,
- a.qualified_num,
- a.disqualification_num,
- a.wbs,
- a.arrival_time,
- a.measurement_id,
- a.supplier_id,
- a.entry_number,
- a.warehousing_num,
- b.company_number,
- b.order_number,
- b.source_type,
- b.move_type,
- f.name as supplierName
- FROM tld_receive_goods a
- LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
- JOIN tld_material c on a.material_id = c.tld_id
- LEFT JOIN tld_customer f on a.supplier_id = f.code
- WHERE a.supplier_id = #{suppId}
- and IFNULL(a.warehousing_num, 0) <![CDATA[<]]> a.qualified_num
- and c.code = #{wllbCode}
- ORDER BY a.arrival_time DESC
- </select>
- <!-- 修改采购单入库数量 -->
- <update id="updateReceiveGood">
- update tld_receive_goods
- set warehousing_num = warehousing_num + #{warehousingNum}
- where id = #{id}
- </update>
- <!-- 查询物料类型 -->
- <select id="getWlClass" resultType="com.tld.model.WarehousingVirtual">
- select wllb_class, tld_id as materialId
- from tld_material
- where code = #{wllbCode}
- </select>
- <!-- 插入入库流水 -->
- <insert id="addStorage">
- insert into
- tld_storage(wllb_code,supplier_id,serial,produc_date,produc_batch,capacity,seq,type,user_id,department_id,storage_location_code,scrq,storage_code,wbs,order_code,account_sleeve,purchase_num,transmission_type)
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (#{item.wllbCode},#{item.suppId},#{item.serial},#{item.producDate},#{item.producDate},#{item.num},#{item.seq},#{item.type},#{item.userId},#{item.departmentId},#{item.storageLocationCode},now(),#{item.storageCode},#{item.wbs},#{item.warehouseTransferId},#{item.accountSleeve},#{item.purchaseNum},0)
- </foreach>
- </insert>
- <!-- 插入库存 -->
- <insert id="addInventory">
- insert into
- tld_inventory(storage_location_code,wllb_class,material_id,amount,totime,hold,amount_lock,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date,scrq,produc_batch,attribute)
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (#{item.storageLocationCode},#{item.wllbClass},#{item.materialId},#{item.num},now(),'0','0',#{item.accountSleeve},#{item.wbs},#{item.suppId},#{item.serial},#{item.wllbCode},#{item.producDate},
- now(),(curdate() + 0),#{item.attribute})
- </foreach>
- </insert>
- <!-- 删除临时表数据 -->
- <delete id="delVirtual">
- delete
- from tld_warehousing_virtual
- where unique_code = #{uniqueCode}
- </delete>
- <!-- 查询当天质检数量 -->
- <select id="getWarehousingCount" resultType="int">
- select count(*)
- from tld_return_gs_warehousing
- where scrq BETWEEN CONCAT(CURDATE(), ' 00:00:00') AND CONCAT(CURDATE(), ' 23:59:59');
- </select>
- <!-- 存入为gs穿的信息 -->
- <insert id="addReturnWarehousing">
- insert into tld_return_gs_warehousing(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)
- values (#{storageCode}, #{gsCk}, #{sourceType}, #{moveType}, #{entryNumber}, #{wbs}, #{materialId},
- #{warehousingNum}, #{id}, now(), #{orderNumber}, #{userName}, #{storageLocationCode});
- </insert>
- <!-- 入库回传 -->
- <select id="getPlugOutWarehousing" resultType="com.tld.model.ReturnWarehousing">
- select a.*,
- ifnull(a.wbs, '') as wbsId,
- ifnull(b.code, '') as wbsCode,
- ifnull(b.name, '') as wbsName
- from tld_return_gs_warehousing a
- left join tld_wbs b on a.wbs = b.tld_id
- where #{orderNumber} LIKE CONCAT('%', CONCAT(order_number, ','), '%')
- </select>
- <!-- 查询入库流水 -->
- <select id="warehousingFlowing" resultType="com.tld.model.Storage">
- select
- a.id,
- b.name as materialName,
- a.wllb_code,
- h.name as supplierName,
- a.serial,
- a.produc_date,
- a.produc_batch,
- a.capacity,
- a.seq,
- a.type,
- c.user_name as userName,
- e.name as departmentName,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.storage_code,
- a.wbs,
- c.real_name as realName,
- a.order_code as orderCode,
- a.account_sleeve,
- f.name as accountName,
- a.purchase_num,
- a.transmission_type
- from tld_storage 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_id = 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
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </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="storageLocationName != null and storageLocationName != ''">
- and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="orderCode != null and orderCode != ''">
- and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </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="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询虚拟入库 -->
- <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
- select id,
- unique_code,
- num,
- storage_location_code,
- wllb_code,
- supp_id,
- serial,
- type,
- produc_date,
- capacity,
- seq,
- user_id,
- storage_location_name,
- warehouse_transfer_id,
- wbs,
- receive_goods_id
- from tld_warehousing_virtual
- where unique_code = #{uniqueCode}
- and type = #{type} and warehouse_transfer_id = #{warehouseTransferId}
- order by id desc
- </select>
- <!-- 查询导出内容 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- a.wllb_code as wllbCode,
- h.name as supplierName,
- if(a.serial = '', null ,a.serial) as serial,
- if(a.produc_date = '', null ,a.produc_date) as producDate,
- if(a.produc_batch = '', null ,a.produc_batch) as producbatch,
- a.capacity,
- a.seq,
- a.type,
- c.user_name as userName,
- e.name as departmentName,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.storage_code,
- a.wbs,
- c.real_name as realName,
- a.order_code as orderCode,
- f.name as accountName,
- if(a.purchase_num = '', null, a.purchase_num) as purchaseNum
- from tld_storage 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_id = 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
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </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="storageLocationName != null and storageLocationName != ''">
- and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="orderCode != null and orderCode != ''">
- and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </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="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询是否扫描 -->
- <select id="getScanIsNot" resultType="java.util.Map">
- select
- (select count(*)
- from tld_inventory a
- join tld_storage_location b on a.storage_location_code = b.storage_location_code
- where a.supplier_id = #{suppId} and a.serial = #{unique} and a.wllb_code = #{wllbCode} and a.produc_date =
- #{producDate}
- <if test="warehouseWhere != null and warehouseWhere != ''">
- and b.warehouse_where = #{warehouseWhere}
- </if>) as inventoryCount,
- (select count(*) from tld_warehousing_virtual where supp_id = #{suppId} and serial = #{unique} and wllb_code =
- #{wllbCode} and produc_date = #{producDate}) as virtualCount
- from dual
- </select>
- <!-- 查询物料是否存在 -->
- <select id="getMateriaIsExist" resultType="com.tld.model.MaterialClass">
- select id,
- code,
- name,
- tld_id,
- specification_and_model,
- unit_of_measurement,
- ifnull(size, 0) as size,
- wllb_class,
- is_not_disable,
- is_recommend,
- part_type
- from tld_material
- where code = #{wllbCode}
- </select>
- <!-- 查询库存是否同物料同批次存在 -->
- <select id="getInventoryProduc" resultType="java.util.Map">
- SELECT produc_batch as producDate,wbs as wbs,account_sleeve as accountSleeve,wllb_code as wllbCode
- FROM tld_inventory a
- JOIN tld_material b ON a.material_id = b.tld_id
- WHERE a.storage_location_code = #{storageLocationCode}
- and hold = '0'
- </select>
- <!-- 查询报工单 -->
- <select id="getNotice" resultType="com.tld.model.Notice">
- select
- a.id,
- a.notice_id,
- a.entry_number,
- a.production_code,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- a.type,
- a.warehousing_num,
- b.company_number,
- c.name as materialName,
- c.wllb_class as wllbClass,
- c.code as wllbCode,
- e.name as companyName,
- b.notice_time as noticeTime,
- b.source_type as sourceType,
- b.move_type as moveType,
- b.notice_code as noticeCode
- from tld_notice a
- join tld_notice_f b on a.notice_id = b.notice_id
- join tld_material c on a.material_id = c.tld_id
- join tld_company e on b.company_number = e.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="noticeId != null and noticeId != ''">
- and a.notice_id like CONCAT(CONCAT('%', #{noticeId}), '%')
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and b.notice_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.notice_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="partType != null and partType != ''">
- and c.part_type = #{partType}
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and b.company_number = #{companyNumber}
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- <if test="sourceType != null and sourceType != ''">
- and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="noticeCode != null and noticeCode != ''">
- and b.notice_code like CONCAT(CONCAT('%', #{noticeCode}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询通知单是否入库 -->
- <select id="getNoticeId" resultType="com.tld.model.Notice">
- select a.id,
- a.notice_id,
- a.entry_number,
- a.production_code,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- a.type,
- a.warehousing_num,
- b.wllb_class,
- c.source_type,
- c.move_type,
- b.code as materialCode,
- c.notice_time as noticeTime,
- c.company_number
- from tld_notice a
- join tld_notice_f c on a.notice_id = c.notice_id
- left join tld_material b on a.material_id = b.tld_id
- where a.notice_id = #{noticeId} and a.material_id = #{materialId}
- </select>
- <!-- 半成品跟部分产成品入库存 -->
- <insert id="addInventoryNotice">
- insert into tld_inventory(storage_location_code, material_id, amount, hold, amount_lock, account_sleeve, wbs,
- produc_date, scrq, wllb_class, produc_batch, attribute, serial, supplier_id,
- wllb_code, totime)
- value (#{storageLocationCode},#{materialId},#{warehousingNum},'0','0',#{companyNumber},#{wbs},#{producBatch},now(),#{wllbClass},#{producBatch},#{attribute},#{serial},#{supplierId},#{wllbCode},now());
- </insert>
- <!-- 查询库存里是否存在半成品虚拟库位 -->
- <select id="getInventoryNotice" resultType="int">
- select count(*)
- from tld_inventory
- where storage_location_code = #{storageLocationCode}
- and material_id = #{materialId}
- and account_sleeve = #{companyNumber}
- and wbs = #{wbs}
- </select>
- <!-- 增加半成品/产成品虚拟库位数量 -->
- <update id="updateInventoryNotice">
- update tld_inventory
- set amount = amount + #{warehousingNum},
- totime = now()
- where storage_location_code = #{storageLocationCode}
- and material_id = #{materialId}
- and wbs = #{wbs};
- </update>
- <!-- 半成品出库库存查询 -->
- <select id="getHalfInventory" resultType="com.tld.model.Inventory">
- select storage_location_code, wllb_class, material_id, amount
- from tld_inventory
- where storage_location_code = #{storageLocationCode}
- and material_id = #{materialId}
- and account_sleeve = #{companyNumber}
- and wbs = #{wbs}
- and hold = '0'
- order by produc_batch
- </select>
- <!-- 删除库存信息 -->
- <delete id="delInventoryNotice">
- delete
- from tld_inventory
- where storage_location_code = #{storageLocationCode}
- and material_id = #{materialId}
- </delete>
- <!--删除其它入库信息-->
- <delete id="delOtherReceivingGoods">
- delete from tld_notices where id = #{id}
- </delete>
- <!--删除其它出库信息-->
- <delete id="delOtherShipments">
- delete from tld_enquiry where id = #{id}
- </delete>
- <!-- 删减库存 -->
- <update id="updateInventoryNoticeNum">
- update tld_inventory
- set amount = amount - #{warehousingNum}
- where storage_location_code = #{storageLocationCode}
- and material_id = #{materialId}
- </update>
- <!-- 新增半成品入库流水 -->
- <insert id="addProduct">
- insert into tld_half_product(wllb_code, produc_date, produc_batch, capacity, user_id, storage_location_code,
- scrq, storage_code, wbs, production_code,account_sleeve,transmission_type)
- value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{storageCode},#{wbs}, #{productionCode},#{accountSleeve},0)
- </insert>
- <!-- 查询半成品入库流水-->
- <select id="getProduct" resultType="com.tld.model.Notice">
- select
- a.id,
- a.wllb_code,
- a.produc_date,
- a.produc_batch,
- a.capacity as warehousingNum,
- a.user_id,
- c.user_name,
- a.storage_location_code,
- a.scrq,
- b.name as materialName,
- b.code as materialCode,
- a.storage_code,
- a.wbs,
- a.production_code,
- c.real_name as realName,
- a.production_code as productionCode,
- a.account_sleeve as companyNumber,
- e.name as accountName
- from tld_half_product 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_company e on a.account_sleeve = e.code
- <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="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="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </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="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and a.account_sleeve = #{companyNumber}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询半成品入库流水导出-->
- <select id="productExcel" resultType="java.util.LinkedHashMap">
- select
- b.name,
- a.wllb_code,
- a.produc_date,
- a.capacity,
- c.user_name,
- a.scrq,
- a.storage_code,
- a.wbs,
- c.real_name as realName,
- a.production_code as productionCode,
- e.name as accountName
- from tld_half_product 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_company e on a.account_sleeve = e.code
- <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="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="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </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="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </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="companyNumber != null and companyNumber != ''">
- and a.account_sleeve = #{companyNumber}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询要料单信息 -->
- <select id="getAskGoodsHalf" resultType="com.tld.model.AskGoods">
- select a.id,
- a.ask_goods_id,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- a.out_num,
- a.entry_number,
- b.source_type,
- b.move_type,
- c.code as wllbCode,
- a.type,
- b.department
- from tld_ask_goods a
- join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
- left join tld_material c on a.material_id = c.tld_id
- where a.ask_goods_id = #{askGoodsId}
- and a.material_id = #{materialId}
- </select>
- <!-- 修改要货单出库数量 -->
- <update id="updateAskGoodsHalf">
- update tld_ask_goods
- set out_num = ifnull(out_num, 0) + #{warehousingNum}
- <if test="type != null and type != ''">
- ,type = '1'
- </if>
- where id = #{id}
- </update>
- <!-- 新增半成品流水 -->
- <insert id="addRemovalHalfProduct">
- insert into tld_removal_half_product(wllb_code, num, user_id, scrq, ask_goods_id, department, storage_code, wbs, account_sleeve)
- value (#{wllbCode},#{num},#{userId},now(),#{askGoodsId},#{department},#{storageCode},#{wbs},#{companyNumber})
- </insert>
- <!-- 查询指定物料内容 -->
- <select id="getMaterial" resultType="com.tld.model.MaterialClass">
- select
- code as wllbCode,
- name as wllbName,
- tld_id,
- specification_and_model,
- unit_of_measurement,
- size,
- wllb_class,
- is_not_disable,
- is_recommend,
- part_type
- from tld_material
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and tld_id = #{materialId}
- </if>
- <if test="materialCode != null and materialCode != ''">
- and code = #{materialCode}
- </if>
- </trim>
- </select>
- <!-- 查询库存信息 -->
- <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
- select 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}
- </select>
- <!-- 产成品入库 -->
- <insert id="addHalf">
- insert into tld_half(wllb_code, produc_date, produc_batch, capacity, user_id, storage_location_code, scrq,
- serial, seq, attribute, storage_code, wbs, production_code,account_sleeve,transmission_type)
- value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{serial},#{seq},#{attribute},#{storageCode},#{wbs},#{productionCode},#{accountSleeve},0)
- </insert>
- <!-- 查询虚拟表数据进行入库 -->
- <select id="getVirtualNotice" resultType="com.tld.model.WarehousingVirtual">
- select a.id,
- a.unique_code,
- a.num,
- a.storage_location_code,
- a.wllb_code,
- a.supp_id,
- a.serial,
- a.type,
- a.produc_date,
- a.capacity,
- a.seq,
- a.user_id,
- a.attribute,
- a.storage_location_name,
- b.user_name,
- a.account_sleeve
- from tld_warehousing_virtual a
- left join tld_user b on a.user_id = b.id
- where a.unique_code = #{uniqueCode}
- and a.type = #{type}
- and a.notice_id = #{noticeId}
- </select>
- <!-- 产成品入库流水 -->
- <select id="getHalf" resultType="com.tld.model.Notice">
- select
- a.id,
- a.wllb_code,
- a.produc_date,
- a.produc_batch,
- a.capacity,
- a.user_id,
- a.storage_location_code,
- e.storage_location_name as storageLocationName,
- a.scrq,
- a.serial,
- a.seq,
- a.attribute,
- b.name as materialName,
- c.user_name as userName,
- b.code as materialCode,
- a.storage_code,
- a.wbs,
- c.real_name as realName,
- a.production_code as productionCod,
- a.account_sleeve as companyNumber,
- f.name as accountName
- from tld_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_storage_location e on a.storage_location_code = e.storage_location_code
- left join tld_company f on a.account_sleeve = f.code
- <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="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </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="attribute != null and attribute != ''">
- and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
- </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="storageLocationName != null and storageLocationName != ''">
- and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and a.account_sleeve = #{companyNumber}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 产成品导出 -->
- <select id="getHalfExcel" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- a.wllb_code,
- if(a.produc_batch = '' , null , a.produc_batch) as producBatch,
- a.capacity,
- c.user_name as userName,
- a.storage_location_code,
- a.scrq,
- a.serial,
- if(a.seq = '' , null , a.seq) as seq,
- if(a.attribute = '' , null , a.attribute) as attribute,
- a.storage_code,
- if(a.wbs = '' , null , a.wbs) as wbs,
- c.real_name as realName,
- a.production_code as productionCode,
- f.name as accountName
- from tld_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_company f on a.account_sleeve = f.code
- <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="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </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="attribute != null and attribute != ''">
- and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
- </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="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="companyNumber != null and companyNumber != ''">
- and a.account_sleeve = #{companyNumber}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询通知单虚拟库扫描数 -->
- <select id="getSumScanNumVal" resultType="int">
- SELECT ifnull(sum(a.num), 0)
- FROM tld_warehousing_virtual a
- left join tld_material b on a.wllb_code = b.code
- WHERE a.notice_id = #{noticeId} and b.tld_id = #{materialId}
- </select>
- <!-- 修改报工单入库数量 -->
- <update id="updateNotice">
- update tld_notice
- set warehousing_num = (warehousing_num + 0) + #{warehousingNum}
- <if test="type != null and type != ''">
- ,type = '1'
- </if>
- where notice_id = #{noticeId}
- and material_id = #{materialId}
- </update>
- <!-- 查询产成品是否扫描 -->
- <select id="getScanIsNotProduct" resultType="java.util.Map">
- select (select count(*)
- from tld_inventory
- where attribute = #{attribute}
- and serial = #{serial}
- and wllb_code = #{materialCode}
- and produc_date = #{producBatch}) as inventoryCount,
- (select count(*)
- from tld_warehousing_virtual
- where attribute = #{attribute}
- and serial = #{serial}
- and wllb_code = #{materialCode}
- and produc_date = #{producBatch}) as virtualCount
- from dual
- </select>
- <!-- 查询昨天没满的库位 -->
- <select id="getStorageLocationCode" resultType="String">
- SELECT ifnull(max(storage_location_code), "0")
- FROM tld_inventory
- WHERE attribute = #{attribute} and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE() and material_id = #{materialId} and account_sleeve = #{companyNumber}
- <if test="producBatch != null">
- and produc_batch = #{producBatch}
- </if>
- ORDER BY scrq desc LIMIT 1
- </select>
- <select id="getCountStorage" resultType="int">
- SELECT count(*)
- FROM tld_inventory
- where attribute = #{attribute}
- and storage_location_code = #{storageLocationCode}
- and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE()
- and material_id = #{materialId}
- <if test="producBatch != null">
- and produc_batch = #{producBatch}
- </if>
- ORDER BY scrq desc LIMIT 1
- </select>
- <!-- 增加流水入库编号 -->
- <update id="updateStorage">
- update tld_storage
- set storage_code = #{storageCode}
- where wllb_code = #{wllbCode}
- and supplier_id = #{suppId}
- and serial = #{serial}
- and produc_batch = #{producDate}
- </update>
- <!-- 查询公共设置 -->
- <select id="getNumUtil" resultType="int">
- select num
- from tld_util
- where type = #{type}
- </select>
- <!-- 其他入库 -->
- <update id="updateInventoryOther">
- update tld_inventory
- set amount = (amount + 0) + #{amount}
- where id = #{id}
- </update>
- <!-- 移库虚拟库入库 -->
- <update id="updateVitrualNum">
- update tld_inventory
- set amount = amount + #{num}
- where material_id = #{materialId}
- and storage_location_code = #{storageLocationCode}
- </update>
- <!-- 其他入库返回gs -->
- <insert id="addReturnWarehousingOther">
- insert into tld_return_gs_other_warehousing
- (storage_code, account_sleeve, storage_location_code, notice_id, notice_code,
- amount,wbs,wbs_code,wbs_name,notice_time,warehouse_where,source_type,move_type,entry_number,wms_item_id,material_id,wms_id)
- value
- (#{storageCode},#{companyNumber},#{storageLocationCode},#{noticeId},#{noticeCode},#{num},#{wbs},#{code},#{name},
- now(),#{warehouseWhere},#{sourceType},#{moveType},#{entryNumber},#{wmsItemId},#{materialId},#{wmsId})
- </insert>
- <!-- 其他入库 -->
- <insert id="addInventoryOther">
- insert into tld_inventory(storage_location_code, wllb_class, library_type, material_id, amount, totime,
- amount_lock, account_sleeve, wbs, supplier_id, serial, wllb_code, produc_date, scrq,
- produc_batch, attribute)
- value (#{storageLocationCode},#{wllbClass},#{libraryType},#{materialId},#{amount},now(),'0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producDate},#{attribute})
- </insert>
- <!-- 查询扫描数量 -->
- <select id="getSumWarehousingVirtual" resultType="java.util.Map">
- select
- (select ifnull(sum(num), 0) from tld_warehousing_virtual where receive_goods_id = #{receiveGoodsId}) as scanNum,
- (select (qualified_num + 0) - ifnull((warehousing_num + 0), 0) from tld_receive_goods where id = #{receiveGoodsId}) as num
- from dual
- </select>
- <!-- 查询扫描数量 -->
- <select id="getWarehouseTransferVirtual" resultType="java.util.Map">
- select
- (select ifnull(sum(num), 0) from tld_warehousing_virtual where warehouse_transfer_id = #{warehouseTransferId} and wllb_code = #{wllbCode}) as scanNum,
- (select (num + 0) - ifnull((out_num + 0), 0) from tld_warehouse_transfer where warehouse_transfer_id = #{warehouseTransferId} and material_id = #{materialId}) as num
- from dual
- </select>
- <!-- 流水增加传输状态 -->
- <update id="updateWarehousingType">
- update tld_storage set transmission_type = #{type} where storage_code = #{storageCode}
- </update>
- <!-- 查询其他入库 -->
- <select id="getNotices" resultType="com.tld.model.Notice">
- select
- b.notice_code,
- b.notice_id,
- b.company_number,
- b.source_type,
- b.move_type,
- a.entry_number,
- a.id as wmsItemId,
- b.id as wmsId,
- a.wbs,
- c.code,
- c.name,
- a.entry_number
- from tld_notices a
- join tld_notices_f b on a.notice_id = b.notice_id
- left join tld_wbs c on a.wbs = c.tld_id
- where a.notice_id = #{noticeId} and a.entry_number = #{entryNumber} and a.material_id = #{materialId}
- </select>
- <!--查询删除信息-->
- <select id="getOtherReceivingGoods" resultType="java.util.Map">
- select * from tld_notices where id = #{id}
- </select>
- <!--查询删除信息-->
- <select id="getOtherShipments" resultType="java.util.Map">
- select * from tld_enquiry where id = #{id}
- </select>
- <!-- 往单据上增加数量 -->
- <update id="updateNoticesWarehousingNum">
- update tld_notices set warehousing_num = #{amount} where notice_id = #{noticeId} and entry_number = #{entryNumber}
- </update>
- </mapper>
|