123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <?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.InventoryMapper">
- <!--录入盘点-->
- <insert id="addInventory">
- insert into tld_plate(storage_location_code, amount, total, wllb_code, scrq, material_id, plate_id,
- account_sleeve, supplier_id, serial, attribute, uuid)
- values (#{storageLocationCode}, #{amount}, #{total}, #{wllbCode}, now(), #{materialId}, #{plateId},
- #{accountSleeve}, #{supplierId}, #{serial}, #{attribute}, #{uuid})
- </insert>
- <!--添加盘点主表信息-->
- <insert id="addInventoryPlate">
- insert into tld_plate_f(user_id, scrq, uuid, title)
- values (#{modifyUser}, now(), #{uuid}, #{title})
- </insert>
- <!--添加盘点子表信息-->
- <insert id="addInventoryPlates">
- insert into tld_plate_z(material_id, wllb_code, name, amount, gs_amount, uuid, account_sleeve)
- values
- <foreach collection="inventory" index="index" item="item" separator=",">
- (#{item.materialId}, #{item.wllbCode}, #{item.name}, #{item.amount}, #{item.gsAmount}, #{item.uuid},#{item.accountSleeve})
- </foreach>
- </insert>
- <!--修改录入信息为主表id为空的添加主表uuid进行关联-->
- <update id="updateInventoryPlate">
- update tld_plate
- set plate_id = #{uuid}
- where scrq like CONCAT(CONCAT('%', #{scrq}), '%')
- and (plate_id is null or plate_id = '')
- </update>
- <!--删除重复录入的信息-->
- <delete id="delInventoryRepetition">
- delete
- from tld_plate
- where id = #{id}
- </delete>
- <!--导出盘点数据-->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- a.material_id,
- a.wllb_code,
- a.name,
- a.amount,
- a.gs_amount,
- c.plateAmount,
- b.name as accountName
- from tld_plate_z a
- left join tld_company b on a.account_sleeve = b.code
- left join (select sum(amount) as plateAmount,material_id,uuid from tld_plate GROUP BY material_id,uuid) c on a.material_id = c.material_id and a.uuid = c.uuid
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code = #{wllbCode}
- </if>
- <if test="uuid != null and uuid != ''">
- and a.uuid = #{uuid}
- </if>
- <if test="name != null and name != ''">
- and a.name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- </select>
- <!--查询录入盘点信息-->
- <select id="getInventory" resultType="com.tld.model.MakeInventory">
- select
- a.id,
- a.storage_location_code,
- a.amount,
- a.total,
- a.wllb_code,
- a.scrq,
- a.material_id,
- a.plate_id,
- a.account_sleeve,
- a.supplier_id,
- a.serial,
- a.attribute,
- a.uuid,
- b.name as name ,
- c.storage_location_name as storageLocationName
- from tld_plate a
- left join tld_material b on a.wllb_code = b.code
- left join tld_storage_location c on a.storage_location_code = c.storage_location_code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCodes != null and wllbCodes != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCodes}), '%')
- </if>
- <if test="name != null and name != ''">
- and b.name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and c.storageLocationName like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wllbCodes != null and wllbCodes != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCodes}), '%')
- </if>
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="amount != null and amount != ''">
- and a.amount = #{amount}
- </if>
- <if test="total != null and total != ''">
- and a.total = #{total}
- </if>
- <if test="storageLocationCodes != null and storageLocationCodes != ''">
- and a.storage_location_code like CONCAT(CONCAT('%', #{storageLocationCodes}), '%')
- </if>
- <if test="plateId != null and plateId != ''">
- and a.plate_id = #{plateId}
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="serial != null and serial != ''">
- and a.serial = #{serial}
- </if>
- <if test="attribute != null and attribute != ''">
- and a.attribute = #{attribute}
- </if>
- <if test="uuid != null and uuid != ''">
- and a.uuid = #{uuid}
- </if>
- <if test="scrq != null and scrq != ''">
- and a.scrq like CONCAT(CONCAT('%', #{scrq}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.sqrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.sqrq <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- <!--查询盘点主表信息-->
- <select id="getInventoryDataList" resultType="com.tld.model.MakeInventory">
- select
- a.id,
- a.user_id,
- a.scrq,
- a.uuid,
- a.title,
- b.user_name as userName
- from tld_plate_f a
- left join tld_user b on a.user_id = b.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="userId != null and userId != ''">
- and a.user_id = #{userId}
- </if>
- <if test="uuid != null and uuid != ''">
- and a.uuid = #{uuid}
- </if>
- <if test="scrq != null and scrq != ''">
- and a.scrq like CONCAT(CONCAT('%', #{scrq}), '%')
- </if>
- <if test="userName != null and userName != ''">
- and b.user_name like CONCAT(CONCAT('%', #{userName}), '%')
- </if>
- <if test="title != null and title != ''">
- and a.title like CONCAT(CONCAT('%', #{title}), '%')
- </if>
- <if test="plateId != null and plateId != ''">
- and a.id = #{plateId}
- </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="getInventoryRepetition" resultType="com.tld.model.MakeInventory">
- select
- id,
- storage_location_code,
- amount,
- total,
- wllb_code,
- scrq,
- material_id,
- plate_id,
- account_sleeve,
- supplier_id,
- serial,
- attribute,
- uuid
- from tld_plate
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and material_id = #{materialId}
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and account_sleeve = #{accountSleeve}
- </if>
- <if test="supplierId != null and supplierId != ''">
- and supplier_id = #{supplierId}
- </if>
- <if test="serial != null and serial != ''">
- and serial = #{serial}
- </if>
- <if test="attribute != null and attribute != ''">
- and attribute = #{attribute}
- </if>
- <if test="uuid != null and uuid != ''">
- and uuid = #{uuid}
- </if>
- </trim>
- </select>
- <!--查询本地库存.gs库存.录入库存 数量-->
- <select id="getInventoryPlate" resultType="com.tld.model.MakeInventory">
- SELECT a.storage_location_code,
- a.account_sleeve,
- a.wllb_code,
- a.supplier_id,
- a.produc_batch,
- a.material_id,
- b.NAME,
- a.amount,
- c.amount AS gsAmount
- FROM tld_inventory a
- LEFT JOIN tld_material b ON a.wllb_code = b.CODE
- INNER JOIN tld_inventory_gs c ON a.material_id = c.material_id
- </select>
- <!--查询是否重复-->
- <select id="getInventoryPlates" resultType="com.tld.model.MakeInventory">
- select *
- from tld_plate_z
- where uuid = #{uuid}
- </select>
- <!--查询盘点子表信息-->
- <select id="getInventoryPlatesList" resultType="com.tld.model.MakeInventory">
- select
- a.id,
- a.plate_id,
- a.material_id,
- a.wllb_code,
- a.amount,
- a.gs_amount,
- e.plateAmount,
- a.uuid,
- b.name as name,
- a.account_sleeve,
- c.name as accountName
- from tld_plate_z a
- left join tld_material b on a.wllb_code = b.code
- left join tld_company c on a.account_sleeve = c.code
- left join (select sum(amount) as plateAmount,material_id,uuid from tld_plate GROUP BY material_id,uuid) e on a.material_id = e.material_id and a.uuid = e.uuid
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="wllbCode != null and wllbCode != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCode}), '%')
- </if>
- <if test="uuid != null and uuid != ''">
- and a.uuid = #{uuid}
- </if>
- <if test="name != null and name != ''">
- and b.name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!--查询本地库存.gs库存.录入库存 数量-->
- <select id="getInventoryLocality" resultType="java.util.Map">
- SELECT a.wllb_code AS wllbCode,
- a.material_id AS materialId,
- b.amount AS gsAmount,
- SUM(a.amount) AS amount,
- if(b.material_id is null ,'',b.material_id) AS bId,
- c.NAME AS name,
- a.account_sleeve as accountSleeve,
- ${uuid} AS uuid
- FROM tld_inventory a
- LEFT JOIN tld_inventory_gs b ON a.material_id = b.material_id
- LEFT JOIN tld_material c ON a.wllb_code = c.CODE
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- </trim>
- GROUP BY a.material_id
- </select>
- <!--查询本地库存.gs库存.录入库存 数量 中 没有连接到的gs的数据-->
- <select id="getInventoryLocalityGs" resultType="java.util.Map">
- select
- c.code AS wllbCode,
- a.material_id AS materialId,
- a.amount AS gsAmount,
- 0 AS amount,
- c.NAME AS name,
- a.account_sleeve as accountSleeve
- from tld_inventory_gs a
- LEFT JOIN tld_material c ON a.material_id = c.tld_id
- where material_id not in
- <foreach collection="list" index="index" item="item" separator="," close=")" open="(">
- <if test="item.bId != null ">
- #{item.bId}
- </if>
- </foreach>
- </select>
- <!--盘点录入信息导出-->
- <select id="exportEntering" resultType="java.util.LinkedHashMap">
- select
- a.wllb_code,
- b.name as name ,
- c.storage_location_name as storageLocationName,
- a.total,
- a.amount
- from tld_plate a
- left join tld_material b on a.wllb_code = b.code
- left join tld_storage_location c on a.storage_location_code = c.storage_location_code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="wllbCodes != null and wllbCodes != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCodes}), '%')
- </if>
- <if test="name != null and name != ''">
- and b.name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and c.storageLocationName like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="wllbCodes != null and wllbCodes != ''">
- and a.wllb_code like CONCAT(CONCAT('%', #{wllbCodes}), '%')
- </if>
- <if test="materialId != null and materialId != ''">
- and a.material_id = #{materialId}
- </if>
- <if test="amount != null and amount != ''">
- and a.amount = #{amount}
- </if>
- <if test="total != null and total != ''">
- and a.total = #{total}
- </if>
- <if test="storageLocationCodes != null and storageLocationCodes != ''">
- and a.storage_location_code like CONCAT(CONCAT('%', #{storageLocationCodes}), '%')
- </if>
- <if test="plateId != null and plateId != ''">
- and a.plate_id = #{plateId}
- </if>
- <if test="accountSleeve != null and accountSleeve != ''">
- and a.account_sleeve = #{accountSleeve}
- </if>
- <if test="supplierId != null and supplierId != ''">
- and a.supplier_id = #{supplierId}
- </if>
- <if test="serial != null and serial != ''">
- and a.serial = #{serial}
- </if>
- <if test="attribute != null and attribute != ''">
- and a.attribute = #{attribute}
- </if>
- <if test="uuid != null and uuid != ''">
- and a.uuid = #{uuid}
- </if>
- <if test="scrq != null and scrq != ''">
- and a.scrq like CONCAT(CONCAT('%', #{scrq}), '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and a.sqrq <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.sqrq <![CDATA[<=]]> #{endTime}
- </if>
- </trim>
- order by a.scrq desc
- </select>
- </mapper>
|