123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <?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.DeliveryMapper">
- <!-- 查询销售交货单 -->
- <select id="getDelivery" resultType="com.tld.model.Delivery">
- select
- a.id,
- a.delivery_id,
- a.entry_number,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.gs_delivery_num,
- a.gs_cancel_num,
- a.out_num,
- b.company_number,
- b.bills_time,
- b.delivery_type,
- b.source_type,
- b.move_type,
- c.name as materialName,
- c.code as materialCode
- from tld_delivery a
- join tld_delivery_f b on a.delivery_id = b.delivery_id
- left join tld_material c on a.material_id = c.tld_id
- where (a.gs_delivery_num - a.gs_cancel_num) != a.out_num
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id = #{deliveryId}
- </if>
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- </select>
- <!-- 查询所有产成品库位 -->
- <select id="getStorageLocationCodeList" resultType="String">
- select
- CONCAT(CONCAT(GROUP_CONCAT(storage_location_code SEPARATOR ","),','), '111111,')
- from tld_storage_location where is_product = '1'
- </select>
- <!-- 查询指定库位跟物料的库存 -->
- <select id="getInventory" 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.wbs,
- a.serial,
- a.wllb_code,
- a.produc_date,
- a.scrq,
- a.produc_batch,
- a.attribute,
- b.storage_location_name as storageLocationName
- FROM tld_inventory a
- LEFT JOIN tld_storage_location b on a.storage_location_code = b.storage_location_code
- WHERE #{storageLocationCode} LIKE CONCAT( '%', CONCAT( a.storage_location_code, ',' ), '%' )
- AND a.material_id = #{delivery.materialId} AND a.hold = '0'
- <if test="delivery.attribute != null and delivery.attribute != ''">
- and a.attribute = #{delivery.attribute}
- </if>
- ORDER BY
- a.produc_batch
- </select>
- <!-- 查询指定库存内容 -->
- <select id="getInventoryHalf" resultType="com.tld.model.AskGoods">
- SELECT
- a.id,
- a.storage_location_code,
- a.wllb_class,
- a.library_type,
- a.material_id,
- a.amount,
- a.amount_lock,
- a.wbs,
- a.serial,
- a.wllb_code,
- a.produc_date,
- a.scrq,
- a.produc_batch,
- a.attribute,
- b.storage_location_name as storageLocationName
- FROM tld_inventory a
- JOIN tld_material b on a.material_id = b.tld_id
- WHERE a.attribute = #{attribute} and a.produc_batch = #{producDate} and a.serial = #{serial} and b.code = #{wllbCode}
- </select>
- <!-- 查询指定库存被占用数量 -->
- <select id="getVitrual" resultType="int">
- select
- ifnull(sum(a.num), 0)
- from tld_ask_goods_vitrual a
- join tld_material b on a.wllb_code = b.code
- where a.storage_location_code = #{storageLocationCode} and b.code = #{wllbCode} and a.attribute = #{attribute} and a.produc_date = #{producBatch}
- </select>
- <!-- 修改销售单出库数量 -->
- <update id="updateDelivery">
- update tld_delivery set ifnull(out_num, 0) = #{num} where delivery_id = #{deliveryId} and material_id = #{materialId}
- </update>
- <!-- 产成品出库流水 -->
- <insert id="addRemovalHalf">
- insert into tld_removal_half(wllb_code,num,user_id,scrq,delivery_id,company_number,customer_code,storage_code,wbs)
- value(#{materialCode},#{outNum},#{userId},now(),#{deliveryId},#{companyNumber},#{customerCode},#{storageCode},#{wbs})
- </insert>
- <!-- 查询销售单父级信息 -->
- <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
- from tld_delivery_f where delivery_id = #{deliveryId}
- </select>
- <!-- 查询产成品属性 -->
- <select id="getAttribute" resultType="com.tld.model.Inventory">
- SELECT
- DISTINCT attribute,
- storage_location_code,
- wllb_code,
- produc_batch
- FROM tld_inventory
- WHERE CONCAT(#{storageLocationCode},'111111,') LIKE CONCAT( '%', CONCAT( storage_location_code, ',' ), '%' )
- AND material_id = #{delivery.materialId} AND hold = '0'
- </select>
- <!-- 查询库存 -->
- <select id="getSumAmount" resultType="int">
- select sum(amount) from tld_inventory where storage_location_code = #{storageLocationCode}
- </select>
- <!-- 查询物料信息 -->
- <select id="getMaterialClass" resultType="com.tld.model.MaterialClass">
- select
- id,
- name,
- code,
- tld_id,
- specification_and_model,
- unit_of_measurement,
- size,
- wllb_class,
- is_not_disable,
- is_recommend,
- part_type
- from tld_material where tld_id = #{materialId}
- </select>
- </mapper>
|