123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?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.StorageLocationMapper">
- <sql id="field">
- id,storage_location_code,storage_location_name,warehouse_where,storage_location_type,is_not_disable,storage_location_capacity,create_time
- </sql>
- <!-- 查询库位信息 -->
- <select id="getStorage" resultType="com.tld.model.StorageLocation">
- select
- a.id,
- a.storage_location_code,
- a.storage_location_name,
- a.warehouse_where,
- a.storage_location_type,
- a.is_not_disable,
- a.storage_location_capacity,
- a.create_time,
- a.is_product,
- a.storage_location_type as materialName,
- c.name as wareHouseName,
- c.tld_id as tldId,
- a.modify_time as modifyTime,
- f.user_name as modifyUser
- from tld_storage_location a
- /*left join tld_material_type b on a.storage_location_type = b.tld_id*/
- left join tld_warehouse c on a.warehouse_where = c.tld_id
- left join tld_user f on a.modify_user = f.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code like CONCAT(CONCAT('%', #{storageLocationCode}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and a.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="storageLocationType != null and storageLocationType != ''">
- and a.storage_location_type like CONCAT(CONCAT('%', #{storageLocationType}), '%')
- </if>
- <if test="modifyUser != null and modifyUser != ''">
- and f.user_name like CONCAT(CONCAT('%', #{modifyUser}), '%')
- </if>
- <if test="isNotDisable != null and isNotDisable != ''">
- and a.is_not_disable = #{isNotDisable}
- </if>
- <if test="warehouseWhere != null and warehouseWhere != ''">
- and a.warehouse_where = #{warehouseWhere}
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- <if test="isProduct != null and isProduct != ''">
- and a.is_product = #{isProduct}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 新增库位信息 -->
- <insert id="addStorage">
- delete from tld_storage_location where storage_location_code = #{storageLocationCode};
- insert into tld_storage_location(storage_location_code,storage_location_name,warehouse_where,storage_location_type,is_not_disable,storage_location_capacity,create_time,is_product,modify_user,modify_time)
- values(#{storageLocationCode},#{storageLocationName},#{warehouseWhere},#{storageLocationType},#{isNotDisable},#{storageLocationCapacity},NOW(),#{isProduct},#{modifyUser},NOW())
- </insert>
- <!-- 删除库位信息 -->
- <delete id="delStorage">
- delete from tld_storage_location where id = #{id}
- </delete>
- <!-- 修改库位信息 -->
- <update id="updateStorage">
- update tld_storage_location
- <set>
- <trim suffixOverrides=",">
- <if test="storageLocationCode != null">
- storage_location_code = #{storageLocationCode},
- </if>
- <if test="storageLocationName != null">
- storage_location_name = #{storageLocationName},
- </if>
- <if test="warehouseWhere != null">
- warehouse_where = #{warehouseWhere},
- </if>
- <if test="storageLocationType != null">
- storage_location_type = #{storageLocationType},
- </if>
- <if test="storageLocationCapacity != null">
- storage_location_capacity = #{storageLocationCapacity},
- </if>
- <if test="isNotDisable != null">
- is_not_disable = #{isNotDisable},
- </if>
- <if test="isProduct != null">
- is_product = #{isProduct},
- </if>
- modify_user = #{modifyUser},modify_time=now(),
- </trim>
- </set>
- where id = #{id}
- </update>
- <!-- 导出数据查询 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- a.storage_location_code,
- a.storage_location_name,
- b.name,
- if(a.storage_location_type = '', null , a.storage_location_type) as storageLocationType,
- if(a.is_not_disable = '1', '是' , '否') as isNotDisable,
- if(a.is_product = '1', '是' , '否') as isProduct
- from tld_storage_location a
- left join tld_warehouse b on a.warehouse_where = b.tld_id
- left join tld_user f on a.modify_user = f.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="storageLocationCode != null and storageLocationCode != ''">
- and a.storage_location_code like CONCAT(CONCAT('%', #{storageLocationCode}), '%')
- </if>
- <if test="storageLocationName != null and storageLocationName != ''">
- and a.storage_location_name like CONCAT(CONCAT('%', #{storageLocationName}), '%')
- </if>
- <if test="storageLocationType != null and storageLocationType != ''">
- and a.storage_location_type like CONCAT(CONCAT('%', #{storageLocationType}), '%')
- </if>
- <if test="modifyUser != null and modifyUser != ''">
- and f.user_name like CONCAT(CONCAT('%', #{modifyUser}), '%')
- </if>
- <if test="isNotDisable != null and isNotDisable != ''">
- and a.is_not_disable = #{isNotDisable}
- </if>
- <if test="isProduct != null and isProduct != ''">
- and a.is_product = #{isProduct}
- </if>
- <if test="warehouseWhere != null and warehouseWhere != ''">
- and a.warehouse_where = #{warehouseWhere}
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 查询编号是否存在 -->
- <select id="getStorageCount" resultType="int">
- select count(*) from tld_storage_location where storage_location_code = #{storageLocationCode}
- </select>
- <!-- 仓库id -->
- <select id="getWarehouseWhere" resultType="String">
- select tld_id from tld_warehouse where name = #{value}
- </select>
- </mapper>
|