|
|
@@ -34,7 +34,7 @@
|
|
|
</insert>
|
|
|
<!-- 查询生产领料单 -->
|
|
|
<select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
|
|
|
- select ask_goods_id,ask_goods_code from tld_ask_goods_f order by sqrq desc
|
|
|
+ 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">
|
|
|
@@ -52,12 +52,12 @@
|
|
|
</select>
|
|
|
<!-- 物料库位选择 -->
|
|
|
<select id="getMaterialCk" resultType="com.tld.model.Inventory">
|
|
|
- select * from tld_inventory where material_id = #{materialId}
|
|
|
+ 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)
|
|
|
- values(uniqueCode,supplierId,serial,wllbCode,producDate,askGoodsId,#{type})
|
|
|
+ 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">
|
|
|
@@ -76,7 +76,7 @@
|
|
|
<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 num from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as virtualNum
|
|
|
+ (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>
|
|
|
<!-- 查询指定送货单信息 -->
|
|
|
@@ -90,6 +90,151 @@
|
|
|
</select>
|
|
|
<!-- 查询已扫描总数 -->
|
|
|
<select id="getAskInfoNumVitrual" resultType="int">
|
|
|
- select sum(num) from tld_ask_goods_vitrual where wllb_code = #{materialCode} and ask_goods_id = #{askGoodsId}
|
|
|
+ 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>
|