123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- <?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_log(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,ask_goods_type)
- values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{outNum},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType},#{askGoodsType})
- </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="addAskGoodsf">
- insert into tld_ask_goods_f(ask_goods_id,ask_goods_code,company_number,sqrq,department,source_type,move_type,ask_goods_apply_type)
- values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{department},#{sourceType},#{moveType},#{askGoodsApplyType})
- </insert>
- <!-- 查询生产领料单 -->
- <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
- select
- a.ask_goods_id,
- a.ask_goods_code,
- b.name as departmentName
- from tld_ask_goods_f a
- left join tld_department b on a.department = b.tld_id
- order by a.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,
- a.out_num
- 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 + 0) <![CDATA[>]]> (a.out_num + 0) and b.part_type != '半成品' and b.part_type != '产成品'
- </select>
- <!-- 物料库位选择 -->
- <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
- left join tld_storage_location b on a.storage_location_code = b.storage_location_code
- where a.material_id = #{materialId} and a.hold = '0' order by a.produc_date
- </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,attribute)
- values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department},#{attribute})
- </insert>
- <!-- 查询指定库存内容 -->
- <select id="getInventory" resultType="com.tld.model.Inventory">
- select
- id,
- storage_location_code,
- wllb_class,
- library_type,
- material_id,
- amount,
- total,
- totime,
- hold,
- amount_lock,
- account_sleeve,
- wbs,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- scrq
- from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}
- </select>
- <!-- 查询库存是否充足 -->
- <select id="getAsk" resultType="com.tld.model.AskGoods">
- SELECT
- ifnull(sum(a.num),0) as num
- 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 ifnull(amount,0) from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
- (select ifnull(sum(num),0) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{serial} 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.id,
- a.ask_goods_id,
- a.entry_number,
- a.production_code,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- a.out_num
- 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 = #{wllbCode}
- </select>
- <!-- 查询已扫描总数 -->
- <select id="getAskInfoNumVitrual" resultType="int">
- select ifnull(sum(num), 0) from tld_ask_goods_vitrual where wllb_code = #{wllbCode} and ask_goods_id = #{askGoodsId} and type = #{type}
- </select>
- <!-- 查询此库存在虚拟表里占用的数量 -->
- <select id="getInventoryAlready" resultType="int">
- select ifnull(sum(num), 0) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}
- </select>
- <!-- 查询虚拟表指定pda跟状态的的数据 -->
- <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
- select
- id,
- unique_code,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- ask_goods_id,
- type,
- storage_location_code,
- num,
- user_id,
- department
- 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 = amount - #{amount}
- 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(#{wllbCode},#{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
- id,
- ask_goods_id,
- entry_number,
- production_code,
- material_id,
- wbs,
- measurement_id,
- num,
- out_num
- 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,document_id,ask_id,storage_location_code)
- values(#{materialId},#{wbs},#{num},#{entryNumber},#{documentId},#{documentPointsId},#{storageLocationCode})
- </insert>
- <!-- 查询要货单父级信息 -->
- <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
- select
- id,
- ask_goods_id,
- ask_goods_code,
- company_number,
- sqrq,
- department,
- source_type,
- move_type
- from tld_ask_goods_f where ask_goods_id = #{askGoodsId}
- </select>
- <!-- 新增返回gs数据父表信息 -->
- <insert id="addReturnGsRemovalF">
- insert into tld_return_gs_removal(ask_goods_id,removal_code,source_type,move_type,scrq,delivery_type)
- values(#{documentId},#{removalCode},#{sourceType},#{moveType},now(),#{deliveryType})
- </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,
- document_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,
- document_id as askGoodsId,
- document_points_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,
- a.department,
- 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>
- order by a.id desc
- </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,
- a.department,
- 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>
- order by a.id desc
- </select>
- <!-- 查询指定pda出库虚拟表 -->
- <select id="getAskGoodsVitrual" resultType="com.tld.model.AskGoods">
- select
- id,
- unique_code,
- supplier_id,
- serial,
- wllb_code,
- produc_date,
- ask_goods_id,
- type,
- storage_location_code,
- num,
- user_id,
- department
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode} and type = #{type}
- </select>
- <!-- 删除指定虚拟表数据 -->
- <delete id="delAskGoodsVitrual">
- delete from tld_ask_goods_vitrual where id = #{id} and type = #{type}
- </delete>
- <!-- 修改出库数量 -->
- <update id="updateOutNum">
- update tld_ask_goods
- set out_num = out_num + #{num} where material_id = #{materialId} and ask_goods_id = #{askGoodsId}
- </update>
- <!-- 查询指定pda 指定物料扫描总数 -->
- <select id="getScanNum" resultType="String">
- select if(AVG(num) is null, 0, num)
- from tld_ask_goods_vitrual
- where unique_code = #{uniqueCode} and ask_goods_id = #{askGoodsId}
- </select>
- <!-- 查询半成品出库数据 -->
- <select id="getGoodsHalf" resultType="com.tld.model.AskGoods">
- SELECT
- a.id,
- a.material_id,
- a.num,
- a.production_code,
- b.name as materialName,
- b.code as materialCode,
- a.out_num,
- a.ask_goods_id,
- e.name as department,
- a.type
- FROM
- tld_ask_goods a
- join tld_material b on a.material_id = b.tld_id
- join tld_ask_goods_f c on a.ask_goods_id = c.ask_goods_id
- left join tld_department e on c.department = e.tld_id
- WHERE
- (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and b.part_type = #{partType}
- <if test="productionCode != null and productionCode != ''">
- and a.production_code = #{productionCode}
- </if>
- <if test="askGoodsId != null and askGoodsId != ''">
- and a.ask_goods_id = #{askGoodsId}
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- </select>
- <!-- 查询半成品出库流水 -->
- <select id="getRemovalHalfProduct" resultType="com.tld.model.AskGoods">
- select
- a.id,
- a.wllb_code,
- a.num,
- a.user_id,
- a.scrq,
- a.ask_goods_id,
- c.name as department,
- b.name as materialName,
- e.user_name as userName
- from tld_removal_half_product a
- left join tld_material b on a.wllb_code = b.code
- left join tld_department c on a.department = c.tld_id
- left join tld_user e on a.user_id = e.id
- <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>
- order by a.scrq desc
- </select>
- <!-- 查询半成品出库流水导出 -->
- <select id="getRemovalHalfProductExcel" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- a.num,
- e.user_name as userName,
- a.scrq,
- a.ask_goods_id,
- c.name as department
- from tld_removal_half_product a
- left join tld_material b on a.wllb_code = b.code
- left join tld_department c on a.department = c.tld_id
- left join tld_user e on a.user_id = e.id
- <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>
- order by a.scrq desc
- </select>
- <!-- 产成品出库流水 -->
- <select id="getRemovalHalf" resultType="com.tld.model.AskGoods">
- select
- a.id,
- a.wllb_code,
- a.num,
- a.user_id,
- a.scrq,
- a.delivery_id,
- a.company_number,
- a.customer_code,
- b.name as materialName,
- c.user_name as userName,
- e.name as customerName
- from tld_removal_half 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_customer e on a.customer_code = e.code
- <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>
- order by a.scrq desc
- </select>
- <!-- 产成品导出出库流水 -->
- <select id="getRemovalHalfExcel" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- a.num,
- c.user_name as userName
- a.scrq,
- a.company_number,
- e.name
- from tld_removal_half 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_customer e on a.customer_code = e.code
- <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>
- order by a.scrq desc
- </select>
- </mapper>
|