| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- <?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.AskGoodsMapper">
- <!-- 查询要货单id+物料id是否存在 -->
- <select id="getAskGoods" resultType="int">
- select count(*) from tld_ask_goods where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
- </select>
- <!-- 修改要料申请单数量 -->
- <update id="updateAskGoodsNum">
- update tld_ask_goods
- set
- num = (select num from tld_ask_goods where ask_goods_id = #{askGoodsId} and material_id = #{materialId})
- where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
- </update>
- <!-- 新增要料申请单 -->
- <insert id="addAskGoods">
- insert into tld_ask_goods(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,out_num)
- values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{outNum})
- </insert>
- <!-- 新增要料日志 -->
- <insert id="addAskGoodsLog">
- insert into tld_ask_goods(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,out_num,ask_goods_code,company_number,sqrq,department_id,source_type,move_type)
- values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{outNum},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType})
- </insert>
- <!-- 查询次要货单是否存在 -->
- <select id="getAskGoodsf" resultType="int">
- select count(*) from tld_ask_goods_f where ask_goods_id = #{askGoodsId} and ask_goods_code = #{askGoodsCode}
- </select>
- <!-- 新增要料申请单父级 -->
- <insert id="addAskGoodsNumf">
- insert into tld_ask_goods_f(ask_goods_id,ask_goods_code,company_number,sqrq,department,source_type,move_type)
- values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{department},#{sourceType},#{moveType})
- </insert>
- <!-- 查询生产领料单 -->
- <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
- select ask_goods_id,ask_goods_code,department from tld_ask_goods_f order by sqrq desc
- </select>
- <!-- 查询指定生产单的物料 -->
- <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
- SELECT
- a.id,
- a.material_id,
- a.num,
- b.name as materialName,
- b.code as materialCode
- FROM
- tld_ask_goods a
- left join tld_material b on a.material_id = b.tld_id
- WHERE
- a.ask_goods_id = #{askGoodsId} and a.num <![CDATA[>]]> a.out_num
- </select>
- <!-- 物料库位选择 -->
- <select id="getMaterialCk" resultType="com.tld.model.Inventory">
- select * from tld_inventory where material_id = #{materialId} order by scrq
- </select>
- <!-- 新增出库虚拟表 -->
- <insert id="addAskGoodsVitrual">
- insert into tld_ask_goods_vitrual(unique_code,supplier_id,serial,wllb_code,produc_date,ask_goods_id,type,storage_location_code,num,user_id,department)
- values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department})
- </insert>
- <!-- 查询指定库存内容 -->
- <select id="getInventory" resultType="com.tld.model.Inventory">
- select * from tld_inventory where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}
- </select>
- <!-- 查询库存是否充足 -->
- <select id="getAsk" resultType="com.tld.model.AskGoods">
- SELECT
- a.*
- 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}
- </select>
- <!-- 查询是否扫描 -->
- <select id="getScanIsNot" resultType="java.util.Map">
- select
- (select amount from tld_inventory where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
- (select sum(num) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}) as virtualNum
- from dual
- </select>
- <!-- 查询指定送货单信息 -->
- <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
- SELECT
- a.*
- FROM
- tld_ask_goods a
- join tld_material b on a.material_id = b.tld_id
- where a.ask_goods_id = #{askGoodsId} and b.code = #{materialCode}
- </select>
- <!-- 查询已扫描总数 -->
- <select id="getAskInfoNumVitrual" resultType="int">
- select sum(num) from tld_ask_goods_vitrual where wllb_code = #{materialCode} and ask_goods_id = #{askGoodsId} and type = #{type}
- </select>
- <!-- 查询此库存在虚拟表里占用的数量 -->
- <select id="getInventoryAlready" resultType="int">
- select sum(num) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}
- </select>
- <!-- 查询虚拟表指定pda跟状态的的数据 -->
- <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
- select * from tld_ask_goods_vitrual where unique_code = #{uniqueCode} and type = #{type} and ask_goods_id = #{askGoodsId}
- </select>
- <!-- 删除库存 -->
- <delete id="deleteInventory">
- delete from tld_inventory where id = #{id}
- </delete>
- <!-- 修改库存数量 -->
- <update id="updateInventory">
- UPDATE tld_inventory
- SET amount = ( SELECT a.amount FROM (select (amount - ${amount}) as amount from tld_inventory WHERE id = #{id}) as a )
- WHERE
- id = #{id}
- </update>
- <!-- 删除虚拟表出库记录 -->
- <delete id="deleteVirtual">
- delete from tld_ask_goods_vitrual where id = #{id}
- </delete>
- <!-- 插入出库流水 -->
- <insert id="addRemoval">
- insert into tld_removal(wllb_code,supplier_id,serial,num,type,user_id,storage_location_code,scrq,process,ask_goods_id,produc_date,department)
- values(#{materialCode},#{supplierId},#{serial},#{num},#{type},#{userId},#{storageLocationCode},now(),#{process},#{askGoodsId},#{producDate},#{department})
- </insert>
- <!-- 查询指定物料类型的id -->
- <select id="getMaterialId" resultType="String">
- select tld_id from tld_material where code = #{wllbCode}
- </select>
- <!-- 查询要料申请单内容 -->
- <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
- select *
- from tld_ask_goods
- where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
- </select>
- <!-- 新增返回gs数据字表信息 -->
- <insert id="addReturnGsRemoval">
- insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,ask_goods_id,ask_id,storage_location_code)
- values(#{materialId},#{wbs},#{num},#{entryNumber},#{askGoodsId},#{askId},#{storageLocationCode})
- </insert>
- <!-- 查询要货单父级信息 -->
- <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
- select * from tld_ask_goods_f where ask_goods_id = #{askGoodsId}
- </select>
- <!-- 新增返回gs数据父表信息 -->
- <insert id="addReturnGsRemovalF">
- insert into tld_ask_goods_f(ask_goods_id,removal_code,source_type,move_type,scrq)
- values(#{askGoodsId},#{removalCode},#{sourceType},#{movetype},now())
- </insert>
- <!-- 查询当天出库数量 -->
- <select id="getReturnRemovalCount" resultType="int">
- select count(*) from tld_return_gs_removal where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
- </select>
- <!-- 查询回传数据 -->
- <select id="plugOutRemoval" resultType="java.util.Map">
- select
- id,
- ask_goods_id as askGoodsId,
- removal_code as removalCode,
- source_type as sourceType,
- move_type as moveType
- from tld_return_gs_removal where removal_code = #{removalCode}
- </select>
- <!-- 查询字表回传数据 -->
- <select id="getRemovalz" resultType="java.util.Map">
- select
- material_id as materialId,
- wbs,
- num,
- entry_number as entryNumber,
- ask_goods_id as askGoodsId,
- ask_id as askId
- from tld_return_gs_removal_z where ask_goods_id = #{askGoodsId}
- </select>
- <!-- 查询出库流水 -->
- <select id="getRemoval" resultType="com.tld.model.AskGoods">
- select
- a.id,
- b.name as materialName,
- a.wllb_code,
- h.name as supplierName,
- a.serial,
- a.type,
- c.user_name as userName,
- e.name as departmentName,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.num
- from tld_removal 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 = 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>
- <if test="type != null and type != ''">
- and a.type like CONCAT(CONCAT('%', #{type}), '%')
- </if>
- </trim>
- </select>
- <!-- 导出 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- h.name as supplierName,
- a.serial,
- a.type,
- c.user_name as userName,
- e.name as departmentName,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.num
- from tld_removal 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 = 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>
- <if test="type != null and type != ''">
- and a.type like CONCAT(CONCAT('%', #{type}), '%')
- </if>
- </trim>
- </select>
- </mapper>
|