123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <?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 * from tld_material_class where wllb_code = #{wllbCode}
- </select>
- <!-- 根据物料分类查询库位 -->
- <select id="getMaterialClassType" resultType="com.tld.model.MaterialClass">
- select
- a.id,
- a.storage_location_code
- from tld_material_class a
- join tld_material b on a.wllb_code = b.code
- join tld_inventory c on b.wllb_class = c.wllb_class
- where a.wllb_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)
- values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName})
- </insert>
- <!-- 查询总数量 -->
- <select id="getScanNum" resultType="java.util.Map">
- SELECT
- (ifnull(sum(a.num), 0) + ${num} + ifnull(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
- *
- FROM
- tld_storage_location
- WHERE
- #{storageLocationCode} like CONCAT('%', CONCAT(storage_location_code, ','), '%')
- </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 * from tld_storage_location where is_not_disable = #{isNotDisable}
- </select>
- <!-- 删除虚拟表 -->
- <delete id="delWarehousingVirtual">
- delete from tld_warehousing_virtual where serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and supp_id = #{suppId}
- </delete>
- <!-- 查询虚拟表数据进行入库 -->
- <select id="getVirtual" resultType="com.tld.model.WarehousingVirtual">
- select * from tld_warehousing_virtual where unique_code = #{uniqueCode}
- </select>
- <!-- 查询采购单信息 -->
- <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
- SELECT
- a.*,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
- LEFT JOIN tld_material c on a.material_id = c.tld_id and c.code = #{wllbCode}
- LEFT JOIN tld_customer f on a.supplier_id = f.tld_id
- WHERE
- a.supplier_id = #{suppId} and IFNULL(a.warehousing_num, 0 ) <![CDATA[<]]> a.qualified_num
- ORDER BY
- a.arrival_time DESC
- </select>
- <!-- 修改采购单入库数量 -->
- <update id="updateReceiveGood">
- update tld_receive_goods
- set
- warehousing_num = (
- select a.result from (select (warehousing_num + ${warehousingNum}) as result from tld_receive_goods where id = #{id}) a
- )
- 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)
- 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())
- </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)
- 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())
- </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)
- values(#{storageCode},#{gsCk},#{sourceType},#{moveType},#{entryNumber},#{wbs},#{materialId},#{warehousingNum},#{receiveGoodsId},now(),#{orderNumber});
- </insert>
- <!-- 入库回传 -->
- <select id="getPlugOutWarehousing" resultType="com.tld.model.ReturnWarehousing">
- select * from tld_return_gs_warehousing 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
- 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.tld_id
- 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
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code = #{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>
- </trim>
- </select>
- <!-- 查询虚拟入库 -->
- <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
- select * from tld_warehousing_virtual where unique_code = #{uniqueCode}
- </select>
- <!-- 查询导出内容 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- 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
- 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.tld_id
- 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
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code = #{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>
- </trim>
- </select>
- <!-- 查询是否扫描 -->
- <select id="getScanIsNot" resultType="java.util.Map">
- select
- (select count(*) from tld_inventory where supplier_id = #{suppId} and serial = #{unique} and wllb_code = #{wllbCode} and produc_date = #{producDate}) 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="int">
- select count(0) from tld_material where code = #{wllbCode}
- </select>
- <!-- 查询库存是否同物料同批次存在 -->
- <select id="getInventoryProduc" resultType="int">
- SELECT
- count(0)
- FROM
- tld_inventory a
- JOIN tld_material b ON a.material_id = b.tld_id
- WHERE a.produc_date = #{producDate} AND b.code = #{wllbCode} and a.storage_location_code = #{storageLocationCode}
- </select>
- </mapper>
|