123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <?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.WarehouseTransferMapper">
- <!-- 查询移库单 -->
- <select id="getWarehouseTransfer" resultType="com.tld.model.WarehouseTransfer">
- select
- a.id,
- a.warehouse_transfer_id,
- a.entry_number,
- a.supply_warehouse_id,
- a.material_id,
- a.wbs,
- a.num,
- a.out_num,
- a.type,
- a.account_sleeve,
- b.warehouse_transfer_code,
- b.ask_goods_warehouse_id,
- b.document_time,
- b.warehouse_transfer_type,
- c.name as materialName,
- c.code as materialCode,
- c.part_type as partType,
- c.is_recommend as isRecommend,
- f.name as askGoodsWarehouseaName,
- e.name as supplyWarehouseName,
- ifnull(f.warehouse_type, 10) as askType,
- ifnull(e.warehouse_type, 10) as suppType
- from tld_warehouse_transfer a
- join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
- join tld_material c on a.material_id = c.tld_id
- join tld_warehouse e on a.supply_warehouse_id = e.tld_id
- join tld_warehouse f on b.ask_goods_warehouse_id = f.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="materialCode != null and materialCode != ''">
- and c.code like CONCAT(CONCAT('%', #{materialCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.document_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.document_time <![CDATA[<=]]> #{endTime}
- </if>
- and (a.num + 0) <![CDATA[>]]> (a.out_num + 0)
- </trim>
- </select>
- <!-- 物料库位选择 -->
- <select id="getMaterialCk" resultType="com.tld.model.Inventory">
- select
- 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
- where a.material_id = #{materialId} and a.hold = '0' and a.account_sleeve = #{accountSleeve} and a.wbs = #{wbs} and b.warehouse_where = #{warehouseWhere}
- order by a.produc_date
- </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}
- </select>
- <!-- 查询移库单内容 -->
- <select id="getWarehouseTransferDetailed" resultType="com.tld.model.WarehouseTransfer">
- select
- a.id,
- a.warehouse_transfer_id,
- a.entry_number,
- a.supply_warehouse_id,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- a.out_num,
- a.type,
- a.account_sleeve,
- b.ask_goods_warehouse_id
- from tld_warehouse_transfer a
- join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
- where a.warehouse_transfer_id = #{askGoodsId} and a.material_id = #{materialId}
- </select>
- <!-- 修改出库数量 -->
- <update id="updateOutNum">
- update tld_warehouse_transfer
- set out_num = ifnull(out_num, 0) + #{num},type = #{typeVal} where material_id = #{materialId} and warehouse_transfer_id = #{askGoodsId}
- </update>
- <!-- 查询当天移库单条数 -->
- <select id="getReturnWarehouseTransferCount" resultType="int">
- select count(*) from tld_return_warehouse_transfer where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
- </select>
- <!-- 新增返回gs移库信息 -->
- <insert id="addReturnGsWarehouseTransfer">
- insert into tld_return_warehouse_transfer_z(warehouse_transfer_id,entry_number,supply_warehouse_id,material_id,wbs,out_num)
- value(#{warehouseTransferId},#{entryNumber},#{supplyWarehouseId},#{materialId},#{wbs},#{outNum})
- </insert>
- <!-- 查询父表移库单申请 -->
- <select id="getWarehouseTransferDetailedF" resultType="com.tld.model.WarehouseTransfer">
- select
- warehouse_transfer_id,
- warehouse_transfer_code,
- ask_goods_warehouse_id,
- warehouse_transfer_type,
- document_time
- from tld_warehouse_transfer_f where warehouse_transfer_id = #{askGoodsId}
- </select>
- <!-- 查询移库单原始数据 -->
- <select id="getWarehouseTransfers" resultType="java.util.Map">
- select * from tld_warehouse_transfer where id = #{id}
- </select>
- <!-- 删除移库单原始数据 -->
- <delete id="delWarehouseTransfer">
- delete from tld_warehouse_transfer where id = #{id}
- </delete>
- <!-- 新增返回gs父表移库信息 -->
- <insert id="addReturnGsWarehouseTransferF">
- insert into tld_return_warehouse_transfer(warehouse_transfer_id,warehouse_transfer_code,ask_goods_warehouse_id,warehouse_transfer_type,scrq)
- value(#{warehouseTransferId},#{warehouseTransferCode},#{askGoodsWarehouseId},#{warehouseTransferType},now())
- </insert>
- <!-- 查询指定pda 指定物料扫描总数 -->
- <select id="getScanNum" resultType="integer">
- select if(sum(num) is null, 0, sum(num))
- from tld_warehousing_virtual
- where unique_code = #{uniqueCode} and warehouse_transfer_id = #{warehouseTransferId} and wllb_code = #{materialCode}
- </select>
- <!-- 查询指定pda 指定物料扫描总数 -->
- <select id="getScanNumWare" resultType="integer">
- select if(sum(num) is null, 0, sum(num))
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode} and ask_goods_id = #{warehouseTransferId} and wllb_code = #{materialCode}
- </select>
- <!-- 查询指定送货单信息 -->
- <select id="getAsknInfo" resultType="com.tld.model.WarehouseTransfer">
- SELECT
- a.id,
- a.warehouse_transfer_id,
- 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="getMaterialWarehouseTransfer" resultType="com.tld.model.Inventory">
- select
- 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}
- <if test="warehouseWhere != null and warehouseWhere != ''">
- and c.tld_id = #{warehouseWhere}
- </if>
- order by a.produc_batch
- </select>
- <!-- 查询是否存在虚拟库存 -->
- <select id="getInventoryVitrual" 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 = #{storageLocationCodeRk} and material_id = #{materialId}
- <if test="accountSleeve != null and accountSleeve != ''">
- and account_sleeve = #{accountSleeve}
- </if>
- <if test="wbs != null and wbs != ''">
- and wbs = #{wbs}
- </if>
- </select>
- <!-- 查询是否是借件库 -->
- <select id="getWarehouseTransferCodeType" resultType="String">
- SELECT
- ifnull(warehouse_type, "10") as warehouseType
- FROM
- tld_warehouse
- WHERE
- tld_id = #{askGoodsWarehouseId}
- </select>
- </mapper>
|