123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988 |
- <?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.code
- where b.code = #{wllbCode}
- </select>
- <!-- 根据物料分类查询库位 -->
- <select id="getMaterialClassType" resultType="com.tld.model.MaterialClass">
- select b.id,
- b.storage_location_code
- from tld_material a
- join tld_storage_location b on b.storage_location_type like CONCAT('%', a.wllb_class, '%')
- where a.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, storage_location_code_ck,wbs, receive_goods_id, account_sleeve)
- values (#{uniqueCode}, #{num}, #{storageLocationCode}, #{wllbCode}, #{suppId}, #{serial}, #{type},
- #{producDate}, #{capacity}, #{seq}, #{userId}, #{storageLocationName}, #{attribute}, #{noticeId},
- #{warehouseTransferId}, #{storageLocationCodeCk},#{wbs},#{receiveGoodsId},#{accountSleeve})
- </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 id = #{id}
- </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.warehouse_transfer_id,
- a.storage_location_code_ck,
- a.storage_location_name,
- b.user_name,
- a.receive_goods_id,
- a.wbs,
- a.account_sleeve,
- a.warehouse_transfer_id
- 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}
- <if test="warehouseTransferId != null and warehouseTransferId != ''">
- and a.warehouse_transfer_id = #{warehouseTransferId}
- </if>
- </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.code
- 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,storage_code,wbs,order_code)
- 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(),#{item.storageCode},#{item.wbs},#{item.warehouseTransferId})
- </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,attribute)
- 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},#{item.attribute})
- </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 a.*,
- ifnull(a.wbs, '') as wbsId,
- ifnull(b.code, '') as wbsCode,
- ifnull(b.name, '') as wbsName
- from tld_return_gs_warehousing a
- left join tld_wbs b on a.wbs = b.tld_id
- 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,
- a.storage_code,
- a.wbs,
- c.real_name as realName,
- a.order_code as orderCode
- 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.code
- 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="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="orderCode != null and orderCode != ''">
- and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </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,
- warehouse_transfer_id,
- wbs,
- receive_goods_id
- from tld_warehousing_virtual
- where unique_code = #{uniqueCode}
- and type = #{type} and warehouse_transfer_id = #{warehouseTransferId}
- order by id desc
- </select>
- <!-- 查询导出内容 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- a.wllb_code as wllbCode,
- h.name as supplierName,
- if(a.serial = '', null ,a.serial) as serial,
- if(a.produc_date = '', null ,a.produc_date) as producDate,
- if(a.produc_batch = '', null ,a.produc_batch) as producbatch,
- a.capacity,
- a.seq,
- a.type,
- c.user_name as userName,
- e.name as departmentName,
- g.storage_location_name as storageLocationName,
- a.scrq,
- a.storage_code,
- a.wbs,
- c.real_name as realName,
- a.order_code as orderCode
- 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.code
- 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="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and g.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="orderCode != null and orderCode != ''">
- and a.order_code like CONCAT(CONCAT('%', #{orderCode}), '%')
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </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 a
- join tld_storage_location b on a.storage_location_code = b.storage_location_code
- where a.supplier_id = #{suppId} and a.serial = #{unique} and a.wllb_code = #{wllbCode} and a.produc_date =
- #{producDate}
- <if test="warehouseWhere != null and warehouseWhere != ''">
- and b.warehouse_where = #{warehouseWhere}
- </if>) 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,
- ifnull(size, 0) as 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,
- e.name as companyName,
- b.notice_time as noticeTime,
- b.source_type as sourceType,
- b.move_type as moveType,
- b.notice_code as noticeCode
- 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
- join tld_company e on b.company_number = e.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="noticeId != null and noticeId != ''">
- and a.notice_id like CONCAT(CONCAT('%', #{noticeId}), '%')
- </if>
- <if test="entryNumber != null and entryNumber != ''">
- and a.entry_number like CONCAT(CONCAT('%', #{entryNumber}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and c.code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and c.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </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>
- <if test="companyNumber != null and companyNumber != ''">
- and b.company_number = #{companyNumber}
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="moveType != null and moveType != ''">
- and b.move_type like CONCAT(CONCAT('%', #{moveType}), '%')
- </if>
- <if test="sourceType != null and sourceType != ''">
- and b.source_type like CONCAT(CONCAT('%', #{sourceType}), '%')
- </if>
- <if test="noticeCode != null and noticeCode != ''">
- and b.notice_code like CONCAT(CONCAT('%', #{noticeCode}), '%')
- </if>
- </trim>
- order by a.id desc
- </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,
- c.company_number
- 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, serial, supplier_id,
- wllb_code, totime)
- value (#{storageLocationCode},#{materialId},#{warehousingNum},'0','0',#{companyNumber},#{wbs},#{producBatch},now(),#{wllbClass},#{producBatch},#{attribute},#{serial},#{supplierId},#{wllbCode},now());
- </insert>
- <!-- 查询库存里是否存在半成品虚拟库位 -->
- <select id="getInventoryNotice" resultType="int">
- select count(*)
- from tld_inventory
- where storage_location_code = #{storageLocationCode}
- and material_id = #{materialId}
- and account_sleeve = #{companyNumber}
- and wbs = #{wbs}
- </select>
- <!-- 增加半成品/产成品虚拟库位数量 -->
- <update id="updateInventoryNotice">
- update tld_inventory
- set amount = amount + #{warehousingNum},
- totime = now()
- where storage_location_code = #{storageLocationCode}
- and material_id = #{materialId}
- and wbs = #{wbs};
- </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}
- and account_sleeve = #{companyNumber}
- and wbs = #{wbs}
- and hold = '0'
- order by produc_batch
- </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, storage_code, wbs, production_code)
- value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{storageCode},#{wbs}, #{productionCode})
- </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,
- b.code as materialCode,
- a.storage_code,
- a.wbs,
- a.production_code,
- c.real_name as realName,
- a.production_code as productionCode
- 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="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询半成品入库流水导出-->
- <select id="productExcel" resultType="java.util.LinkedHashMap">
- select
- b.name,
- a.wllb_code,
- a.produc_date,
- a.capacity,
- c.user_name,
- a.scrq,
- a.storage_code,
- a.wbs,
- c.real_name as realName,
- a.production_code as productionCode
- 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="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code = #{storageLocationCode}
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </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 = ifnull(out_num, 0) + #{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, storage_code, wbs, company_number)
- value (#{wllbCode},#{num},#{userId},now(),#{askGoodsId},#{department},#{storageCode},#{wbs},#{companyNumber})
- </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, storage_code, wbs, production_code)
- value (#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{serial},#{seq},#{attribute},#{storageCode},#{wbs},#{productionCode})
- </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,
- e.storage_location_name as storageLocationName,
- a.scrq,
- a.serial,
- a.seq,
- a.attribute,
- b.name as materialName,
- c.user_name as userName,
- b.code as materialCode,
- a.storage_code,
- a.wbs,
- c.real_name as realName,
- a.production_code as productionCode
- 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
- left join tld_storage_location e on a.storage_location_code = e.storage_location_code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <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="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="attribute != null and attribute != ''">
- and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 产成品导出 -->
- <select id="getHalfExcel" resultType="java.util.LinkedHashMap">
- select
- b.name as materialName,
- a.wllb_code,
- if(a.produc_batch = '' , null , a.produc_batch) as producBatch,
- a.capacity,
- c.user_name as userName,
- a.storage_location_code,
- a.scrq,
- a.serial,
- if(a.seq = '' , null , a.seq) as seq,
- if(a.attribute = '' , null , a.attribute) as attribute,
- a.storage_code,
- if(a.wbs = '' , null , a.wbs) as wbs,
- c.real_name as realName,
- a.production_code as productionCode
- 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="startTime != null and startTime != ''">
- and a.scrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrq <![CDATA[<=]]> #{endTime}
- </if>
- <if test="materialName != null and materialName != ''">
- and b.name like CONCAT(CONCAT('%', #{materialName}), '%')
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and c.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="realName != null and realName != ''">
- and c.real_name like CONCAT(CONCAT('%', #{realName}), '%')
- </if>
- <if test="attribute != null and attribute != ''">
- and a.attribute like CONCAT(CONCAT('%', #{attribute}), '%')
- </if>
- <if test="storageCode != null and storageCode != ''">
- and a.storage_code like CONCAT(CONCAT('%', #{storageCode}), '%')
- </if>
- <if test="wbs != null and wbs != ''">
- and a.wbs like CONCAT(CONCAT('%', #{wbs}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and e.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="productionCode != null and productionCode != ''">
- and a.production_code like CONCAT(CONCAT('%', #{productionCode}), '%')
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!-- 查询通知单虚拟库扫描数 -->
- <select id="getSumScanNumVal" resultType="int">
- SELECT ifnull(sum(a.num), 0)
- FROM tld_warehousing_virtual a
- left join tld_material b on a.wllb_code = b.code
- WHERE a.notice_id = #{noticeId} and b.tld_id = #{materialId}
- </select>
- <!-- 修改报工单入库数量 -->
- <update id="updateNotice">
- update tld_notice
- set warehousing_num = (warehousing_num + 0) + #{warehousingNum}
- <if test="type != null and type != ''">
- ,type = '1'
- </if>
- where notice_id = #{noticeId}
- and material_id = #{materialId}
- </update>
- <!-- 查询产成品是否扫描 -->
- <select id="getScanIsNotProduct" resultType="java.util.Map">
- select (select count(*)
- from tld_inventory
- where attribute = #{attribute}
- and serial = #{serial}
- and wllb_code = #{materialCode}
- and produc_date = #{producBatch}) as inventoryCount,
- (select count(*)
- from tld_warehousing_virtual
- where attribute = #{attribute}
- and serial = #{serial}
- and wllb_code = #{materialCode}
- and produc_date = #{producBatch}) as virtualCount
- from dual
- </select>
- <!-- 查询昨天没满的库位 -->
- <select id="getStorageLocationCode" resultType="String">
- SELECT ifnull(max(storage_location_code), "0")
- FROM tld_inventory
- WHERE attribute = #{attribute} and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE() and material_id = #{materialId} and account_sleeve = #{companyNumber}
- <if test="producBatch != null">
- and produc_batch = #{producBatch}
- </if>
- ORDER BY scrq desc LIMIT 1
- </select>
- <select id="getCountStorage" resultType="int">
- SELECT count(*)
- FROM tld_inventory
- where attribute = #{attribute}
- and storage_location_code = #{storageLocationCode}
- and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE()
- and material_id = #{materialId}
- <if test="producBatch != null">
- and produc_batch = #{producBatch}
- </if>
- ORDER BY scrq desc LIMIT 1
- </select>
- <!-- 增加流水入库编号 -->
- <update id="updateStorage">
- update tld_storage
- set storage_code = #{storageCode}
- where wllb_code = #{wllbCode}
- and supplier_id = #{suppId}
- and serial = #{serial}
- and produc_batch = #{producDate}
- </update>
- <!-- 查询公共设置 -->
- <select id="getNumUtil" resultType="int">
- select num
- from tld_util
- where type = #{type}
- </select>
- <!-- 其他入库 -->
- <update id="updateInventoryOther">
- update tld_inventory
- set amount = (amount + 0) + #{amount}
- where id = #{id}
- </update>
- <!-- 移库虚拟库入库 -->
- <update id="updateVitrualNum">
- update tld_inventory
- set amount = amount + #{num}
- where material_id = #{materialId}
- and storage_location_code = #{storageLocationCode}
- </update>
- <!-- 其他入库返回gs -->
- <insert id="addReturnWarehousingOther">
- insert into tld_return_gs_other_warehousing(storage_code, account_sleeve, storage_location_code, wbs, amount,
- material_id)
- value (#{storageCode},#{accountSleeve},#{storageLocationCode},#{wbs},#{num},#{materialId})
- </insert>
- <!-- 其他入库 -->
- <insert id="addInventoryOther">
- insert into tld_inventory(storage_location_code, wllb_class, library_type, material_id, amount, totime,
- amount_lock, account_sleeve, wbs, supplier_id, serial, wllb_code, produc_date, scrq,
- produc_batch, attribute)
- value (#{storageLocationCode},#{wllbClass},#{libraryType},#{materialId},#{amount},now(),'0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producDate},#{attribute})
- </insert>
- <!-- 查询扫描数量 -->
- <select id="getSumWarehousingVirtual" resultType="java.util.Map">
- select
- (select ifnull(sum(num), 0) from tld_warehousing_virtual where receive_goods_id = #{receiveGoodsId}) as scanNum,
- (select (qualified_num + 0) - ifnull((warehousing_num + 0), 0) from tld_receive_goods where id = #{receiveGoodsId}) as num
- from dual
- </select>
- </mapper>
|