| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609 |
- <?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
- a.id,
- a.storage_location_code,
- a.wllb_code
- from tld_material_class a
- join tld_material b on a.wllb_code = b.tld_id
- where b.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,attribute,notice_id,warehouse_transfer_id)
- values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName},#{attribute},#{noticeId},#{warehouseTransferId})
- </insert>
- <!-- 查询总数量 -->
- <select id="getScanNum" resultType="java.util.Map">
- SELECT
- (ifnull(sum(a.num), 0) + ${num} + ifnull(sum(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
- id,
- storage_location_code,
- storage_location_name,
- warehouse_where,
- storage_location_type,
- storage_location_capacity,
- is_not_disable,
- create_time
- FROM
- tld_storage_location
- WHERE
- #{storageLocationCode} like CONCAT('%', CONCAT(storage_location_code, ','), '%') and warehouse_where != '5000'
- </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
- id,
- storage_location_code,
- storage_location_name,
- warehouse_where,
- storage_location_type,
- storage_location_capacity,
- is_not_disable,
- create_time
- 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
- a.id,
- a.unique_code,
- a.num,
- a.storage_location_code,
- a.wllb_code,
- a.supp_id,
- a.serial,
- a.type,
- a.produc_date,
- a.capacity,
- a.seq,
- a.user_id,
- a.attribute,
- a.storage_location_name,
- b.user_name
- from tld_warehousing_virtual a
- left join tld_user b on a.user_id = b.id
- where a.unique_code = #{uniqueCode} and a.type = #{type}
- </select>
- <!-- 查询采购单信息 -->
- <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
- SELECT
- a.id,
- a.order_code,
- a.material_id,
- a.purchase_num,
- a.arrival_num,
- a.type,
- a.qualified_num,
- a.disqualification_num,
- a.wbs,
- a.arrival_time,
- a.measurement_id,
- a.supplier_id,
- a.entry_number,
- a.warehousing_num,
- 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
- JOIN tld_material c on a.material_id = c.tld_id
- 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 and c.code = #{wllbCode}
- ORDER BY
- a.arrival_time DESC
- </select>
- <!-- 修改采购单入库数量 -->
- <update id="updateReceiveGood">
- update tld_receive_goods
- set
- warehousing_num = warehousing_num + #{warehousingNum}
- 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,produc_batch)
- 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(),#{item.producDate})
- </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,user_name,storage_location_code)
- values(#{storageCode},#{gsCk},#{sourceType},#{moveType},#{entryNumber},#{wbs},#{materialId},#{warehousingNum},#{id},now(),#{orderNumber},#{userName},#{storageLocationCode});
- </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>
- order by scrq desc
- </select>
- <!-- 查询虚拟入库 -->
- <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
- select
- id,
- unique_code,
- num,
- storage_location_code,
- wllb_code,
- supp_id,
- serial,
- type,
- produc_date,
- capacity,
- seq,
- user_id,
- storage_location_name
- 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>
- order by a.scrq desc
- </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="com.tld.model.MaterialClass">
- select
- id,
- code,
- name,
- tld_id,
- specification_and_model,
- unit_of_measurement,
- size,
- wllb_class,
- is_not_disable,
- is_recommend,
- part_type
- from tld_material where code = #{wllbCode}
- </select>
- <!-- 查询库存是否同物料同批次存在 -->
- <select id="getInventoryProduc" resultType="int">
- SELECT
- produc_date as producDate
- 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} and hold = '0'
- </select>
- <!-- 查询报工单 -->
- <select id="getNotice" resultType="com.tld.model.Notice">
- select
- a.id,
- a.notice_id,
- a.entry_number,
- a.production_code,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- a.type,
- a.warehousing_num,
- b.company_number,
- c.name as materialName,
- c.wllb_class as wllbClass,
- c.code as wllbCode
- from tld_notice a
- join tld_notice_f b on a.notice_id = b.notice_id
- join tld_material c on a.material_id = c.tld_id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="materialCode != null and materialCode != ''">
- and c.code = #{materialCode}
- </if>
- <if test="startTime != null and startTime != ''">
- and b.notice_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and b.notice_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="partType != null and partType != ''">
- and c.part_type = #{partType}
- </if>
- </trim>
- </select>
- <!-- 查询通知单是否入库 -->
- <select id="getNoticeId" resultType="com.tld.model.Notice">
- select
- a.id,
- a.notice_id,
- a.entry_number,
- a.production_code,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- a.type,
- a.warehousing_num,
- b.wllb_class,
- c.source_type,
- c.move_type,
- b.code as materialCode,
- c.notice_time as noticeTime
- from tld_notice a
- join tld_notice_f c on a.notice_id = c.notice_id
- left join tld_material b on a.material_id = b.tld_id
- where a.notice_id = #{noticeId} and a.material_id = #{materialId}
- </select>
- <!-- 半成品跟部分产成品入库存 -->
- <insert id="addInventoryNotice">
- insert into
- tld_inventory(storage_location_code,material_id,amount,hold,amount_lock,account_sleeve,wbs,produc_date,scrq,wllb_class,produc_batch,attribute)
- value(#{storageLocationCode},#{materialId},#{warehousingNum},'0','0',#{companyNumber},#{wbs},now(),now(),#{wllbClass},#{producBatch},#{attribute});
- update tld_notice set warehousing_num = #{warehousingNum},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
- </insert>
- <!-- 查询库存里是否存在半成品虚拟库位 -->
- <select id="getInventoryNotice" resultType="int">
- select count(0) from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
- </select>
- <!-- 增加半成品/产成品虚拟库位数量 -->
- <update id="updateInventoryNotice">
- update tld_inventory set amount = amount + #{warehousingNum} where storage_location_code = #{storageLocationCode};
- update tld_notice set warehousing_num = #{warehousingNum},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
- </update>
- <!-- 半成品出库库存查询 -->
- <select id="getHalfInventory" resultType="com.tld.model.Inventory">
- select storage_location_code,wllb_class,material_id,amount from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
- </select>
- <!-- 删除库存信息 -->
- <delete id="delInventoryNotice">
- delete from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
- </delete>
- <!-- 删减库存 -->
- <update id="updateInventoryNoticeNum">
- update tld_inventory set amount = amount - #{warehousingNum} where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
- </update>
- <!-- 新增半成品入库流水 -->
- <insert id="addProduct">
- insert into tld_half_product(wllb_code,produc_date,produc_batch,capacity,user_id,storage_location_code,scrq)
- value(#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now())
- </insert>
- <!-- 查询半成品入库流水-->
- <select id="getProduct" resultType="com.tld.model.Notice">
- select
- a.id,
- a.wllb_code,
- a.produc_date,
- a.produc_batch,
- a.capacity as warehousingNum,
- a.user_id,
- c.user_name,
- a.storage_location_code,
- a.scrq,
- b.name as materialName
- from tld_half_product a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- <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>
- order by a.scrq desc
- </select>
- <!-- 查询半成品入库流水-->
- <select id="productExcel" resultType="java.util.LinkedHashMap">
- select
- b.name,
- a.produc_date,
- a.capacity,
- c.user_name,
- a.scrq
- from tld_half_product a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- <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>
- order by a.scrq desc
- </select>
- <!-- 查询要料单信息 -->
- <select id="getAskGoodsHalf" resultType="com.tld.model.AskGoods">
- select
- a.id,
- a.ask_goods_id,
- a.material_id,
- a.wbs,
- a.measurement_id,
- a.num,
- a.out_num,
- a.entry_number,
- b.source_type,
- b.move_type,
- c.code as wllbCode,
- a.type,
- b.department
- from tld_ask_goods a
- join tld_ask_goods_f b on a.ask_goods_id = b. ask_goods_id
- left join tld_material c on a.material_id = c.tld_id
- where a.ask_goods_id = #{askGoodsId} and a.material_id = #{materialId}
- </select>
- <!-- 修改要货单出库数量 -->
- <update id="updateAskGoodsHalf">
- update tld_ask_goods set out_num = out_num + #{warehousingNum},type = '1' where id = #{id}
- </update>
- <!-- 新增半成品流水 -->
- <insert id="addRemovalHalfProduct">
- insert into tld_removal_half_product(wllb_code,num,user_id,scrq,ask_goods_id,department)
- value(#{wllbCode},#{num},#{userId},now(),#{askGoodsId},#{department})
- </insert>
- <!-- 查询指定物料内容 -->
- <select id="getMaterial" resultType="com.tld.model.MaterialClass">
- select
- code as wllbCode,
- name as wllbName,
- tld_id,
- specification_and_model,
- unit_of_measurement,
- size,
- wllb_class,
- is_not_disable,
- is_recommend,
- part_type
- from tld_material
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and tld_id = #{materialId}
- </if>
- <if test="materialCode != null and materialCode != ''">
- and code = #{materialCode}
- </if>
- </trim>
- </select>
- <!-- 查询库存信息 -->
- <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
- select
- 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,
- produc_batch,
- attribute
- from tld_inventory where storage_location_code = #{storageLocationCode}
- </select>
- <!-- 产成品入库 -->
- <insert id="addHalf">
- insert into tld_half(wllb_code,produc_date,produc_batch,capacity,user_id,storage_location_code,scrq,serial,seq,attribute)
- value(#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{serial},#{seq},#{attribute})
- </insert>
- <!-- 查询虚拟表数据进行入库 -->
- <select id="getVirtualNotice" resultType="com.tld.model.WarehousingVirtual">
- select
- a.id,
- a.unique_code,
- a.num,
- a.storage_location_code,
- a.wllb_code,
- a.supp_id,
- a.serial,
- a.type,
- a.produc_date,
- a.capacity,
- a.seq,
- a.user_id,
- a.attribute,
- a.storage_location_name,
- b.user_name
- from tld_warehousing_virtual a
- left join tld_user b on a.user_id = b.id
- where a.unique_code = #{uniqueCode} and a.type = #{type} and a.notice_id = #{noticeId}
- </select>
- <!-- 产成品入库流水 -->
- <select id="getHalf" resultType="com.tld.model.Notice">
- select
- a.id,
- a.wllb_code,
- a.produc_date,
- a.produc_batch,
- a.capacity,
- a.user_id,
- a.storage_location_code,
- a.scrq,
- a.serial,
- a.seq,
- a.attribute,
- b.name as materialName,
- c.user_name as userName
- from tld_half a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- <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>
- order by a.scrq desc
- </select>
- <!-- 产成品导出 -->
- <select id="getHalfExcel" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- a.produc_batch,
- a.capacity,
- c.user_name as userName
- a.storage_location_code,
- a.scrq,
- a.serial,
- a.seq,
- a.attribute
- from tld_half a
- left join tld_material b on a.wllb_code = b.code
- left join tld_user c on a.user_id = c.id
- <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>
- order by a.scrq desc
- </select>
- </mapper>
|