123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- <?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,
- b.delivery_code,
- a.entry_number,
- a.material_id,
- d.code as wbsCode,
- d.name as wbsName,
- a.wbs,
- a.measurement_id,
- a.gs_delivery_num,
- a.gs_cancel_num,
- a.out_num,
- b.company_number,
- b.bills_time,
- b.customer_code,
- b.delivery_type,
- b.source_type,
- b.move_type,
- b.project_name,
- c.name as materialName,
- c.code as materialCode,
- c.part_type as partType
- 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
- left join tld_wbs d on a.wbs = d.tld_id
- where (a.gs_delivery_num - a.gs_cancel_num) != a.out_num
- and a.status != '1' and c.code in (select material_id from tld_user_material where user_id = #{userId})
- <if test="deliveryId != null and deliveryId != ''">
- and a.delivery_id = #{deliveryId}
- </if>
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number = #{entryNumber}
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs = #{wbs}
- </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,
- 0 + (a.amount - a.amount_lock) 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,
- a.account_sleeve
- 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' AND a.wbs = #{delivery.wbs} and a.account_sleeve = #{delivery.companyNumber}
- <if test="delivery.attribute != null">
- and a.attribute = #{delivery.attribute}
- </if>
- ORDER BY
- a.produc_batch
- </select>
- <!-- 查询指定库存内容 -->
- <select id="getInventoryHalf" resultType="com.tld.model.Inventory">
- 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
- FROM tld_inventory a
- JOIN tld_material b on a.material_id = b.tld_id
- WHERE b.code = #{wllbCode} and a.account_sleeve = #{companyNumber} and a.wbs = #{wbs} and a.hold = '0'
- <if test="attribute != null and attribute != ''">
- and a.attribute = #{attribute}
- </if>
- <if test="serial != null and serial != ''">
- and a.serial = #{serial}
- </if>
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- </select>
- <!-- 暂时使用 后期删除-->
- <!-- 查询指定库存内容 -->
- <select id="getTemporarily" resultType="com.tld.model.Inventory">
- 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
- FROM tld_inventory a
- JOIN tld_material b on a.material_id = b.tld_id
- WHERE b.code = #{wllbCode} and a.account_sleeve = #{companyNumber} and a.wbs = #{wbs} and a.hold = '0'
- <if test="attribute != null and attribute != ''">
- and a.attribute = #{attribute}
- </if>
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- and (a.amount + 0) <![CDATA[>=]]> (#{num} + 0) limit 1
- </select>
- <!-- 暂时使用 后期删除-->
- <!-- 查询指定库存被占用数量 -->
- <select id="getVitrual" resultType="int">
- select
- count(*)
- 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} and serial = #{serial}
- </select>
- <!-- 修改销售单出库数量 -->
- <update id="updateDelivery">
- update tld_delivery set out_num = (out_num + 0) + #{num} where delivery_id = #{deliveryId} and material_id = #{materialId} and entry_number = #{entryNumber}
- </update>
- <!-- 产成品出库流水 -->
- <insert id="addRemovalHalf">
- insert into tld_removal_half(wllb_code,num,user_id,scrq,delivery_id,company_number,customer_code,storage_code,wbs,transmission_type,serial)
- value(#{materialCode},#{outNum},#{userId},now(),#{deliveryId},#{companyNumber},#{customerCode},#{storageCode},#{wbs},0,#{serial})
- </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}) 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>
- <!-- 查询虚拟表半成品扫描数量 -->
- <select id="getProductNumVitrual" resultType="int">
- select
- sum(num) as num
- 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.wbs = #{wbs}
- </select>
- <!-- 查询库存数量是否充足 -->
- <select id="getScanIsNot" resultType="java.util.Map">
- select
- (select ifnull(amount,0) from tld_inventory where id = #{id}) as amount,
- (select ifnull(sum(num),0) from tld_ask_goods_vitrual where wbs = #{wbs} and wllb_code = #{wllbCode} and storage_location_code = #{storageLocationCode} and produc_date = #{producDate} and account_sleeve = #{companyNumber}
- <if test="serial != null and serial !=''">
- and serial = #{serial}
- </if>
- <if test="attribute != null and attribute !=''">
- and attribute = #{attribute}
- </if>) as vitrualNum
- from dual
- </select>
- <!-- 查询销售交货单原始数据 -->
- <select id="getDeliverys" resultType="java.util.Map">
- select * from tld_delivery where id = #{id}
- </select>
- <!-- 删除销售交货单原始数据 -->
- <delete id="delDelivery">
- delete from tld_delivery where id = #{id}
- </delete>
- <!-- 物料库位选择 -->
- <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
- 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_date
- </select>
- <!-- 查询销售出库是否扫描 -->
- <select id="getDeliveryScan" resultType="int">
- select count(*) from tld_ask_goods_vitrual
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="serial != null and serial != ''">
- and serial = #{serial}
- </if>
- <if test="supplierId != null and supplierId != ''">
- and supplier_id = #{supplierId}
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and wllb_code = #{wllbCode}
- </if>
- <if test="producDate != null and producDate != ''">
- and produc_date = #{producDate}
- </if>
- </trim>
- </select>
- <!-- 查询指定销售单物料已扫数量 -->
- <select id="getScanSum" 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.ask_goods_id = #{deliveryId} and b.tld_id = #{materialId}
- </select>
- <!-- 新增半成品流水 -->
- <insert id="addRemovalHalfProduct">
- insert into tld_removal_half_product(wllb_code,num,user_id,scrq,ask_goods_id,storage_code,wbs,company_number,transmission_type)
- value(#{materialCode},#{outNum},#{userId},now(),#{deliveryId},#{storageCode},#{wbs},#{companyNumber},0)
- </insert>
- <!-- 查询销售订单 -->
- <select id="getDeliveryInfo" resultType="com.tld.model.Delivery">
- select out_num,gs_delivery_num from tld_delivery where delivery_id = #{askGoodsId} and entry_number = #{entryNumber}
- </select>
- <!-- 查询指定库存 -->
- <select id="getInventoryVal" resultType="com.tld.model.Inventory">
- select amount from tld_inventory where id = #{id}
- </select>
- <!-- 查询指定销售单扫描数量 -->
- <select id="getScanNumDelivery" resultType="String">
- select ifnull(sum(num), 0) as num from tld_ask_goods_vitrual where ask_goods_id = #{askGoodsId} and entry_number = #{entryNumber}
- </select>
- <!-- 虚拟表此物料占用数量 -->
- <select id="getAllScanNumDelivery" resultType="String">
- select ifnull(sum(num), 0) as num from tld_ask_goods_vitrual where wllb_code = #{wllbCode} and account_sleeve = #{accountSleeve} and wbs = #{wbs}
- <if test="producDate != null and producDate != ''">
- and produc_date = #{producDate}
- </if>
- <if test="serial != null and serial != ''">
- and serial = #{serial}
- </if>
- </select>
- <!-- 查询销售单绑定的软件类 -->
- <select id="getEquipmentSoftware" resultType="java.util.Map">
- select
- a.equipment_code as equipmentCode
- a.software_code as softwareCode,
- b.tld_id as materialId
- from tld_equipment_binding_software a
- join tld_material b on a.equipment_code = b.code
- where a.equipment_code = #{code}
- </select>
- </mapper>
|