123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <?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.ruoyi.basicData.mapper.TWarehouseMapper">
- <resultMap type="TWarehouse" id="TWarehouseResult">
- <result property="fId" column="f_id"/>
- <result property="parentId" column="parent_id"/>
- <result property="ancestors" column="ancestors"/>
- <result property="orderNum" column="order_num"/>
- <result property="fNo" column="f_no"/>
- <result property="fIsBonded" column="f_is_bonded"/>
- <result property="fName" column="f_name"/>
- <result property="fAddr" column="f_addr"/>
- <result property="fTotalgross" column="f_totalgross"/>
- <result property="fContacts" column="f_contacts"/>
- <result property="fTel" column="f_tel"/>
- <result property="fCharg" column="f_charg"/>
- <result property="fStatus" column="f_status"/>
- <result property="delFlag" column="del_flag"/>
- <result property="createBy" column="create_by"/>
- <result property="createTime" column="create_time"/>
- <result property="updateBy" column="update_by"/>
- <result property="updateTime" column="update_time"/>
- <result property="remark" column="remark"/>
- <result property="fLocation" column="f_location"/>
- <result property="hasChildren" column="has_children"/>
- <result property="fWarehouseInformation" column="f_warehouse_information"/>
- </resultMap>
- <sql id="selectTWarehouseVo">
- select f_id,
- parent_id,
- ancestors,
- order_num,
- f_no,
- f_is_bonded,
- f_name,
- f_addr,
- f_totalgross,
- f_contacts,
- f_tel,
- f_charg,
- f_status,
- del_flag,
- create_by,
- create_time,
- update_by,
- update_time,
- remark,
- f_location,
- f_warehouse_information
- from t_warehouse
- </sql>
- <select id="selectTWarehouseList" parameterType="TWarehouse" resultMap="TWarehouseResult">
- <include refid="selectTWarehouseVo"/>
- <where>
- <if test="parentId != null and parentId != ''">and parent_id = #{parentId}</if>
- <if test="fIsBonded != null and fIsBonded != ''">and f_is_bonded = #{fIsBonded}</if>
- <if test="ancestors != null and ancestors != ''">and ancestors like concat('%', #{ancestors}, '%')</if>
- <if test="fNo != null and fNo != ''">and f_no like concat('%', #{fNo}, '%')</if>
- <if test="fName != null and fName != ''">and f_name like concat('%', #{fName}, '%')</if>
- <if test="fAddr != null and fAddr != ''">and f_addr like concat('%', #{fAddr}, '%')</if>
- <if test="fTotalgross != null ">and f_totalgross like concat('%', #{fTotalgross}, '%')</if>
- <if test="fContacts != null and fContacts != ''">and f_contacts = #{fContacts}</if>
- <if test="fTel != null and fTel != ''">and f_tel = #{fTel}</if>
- <if test="fCharg != null ">and f_charg = #{fCharg}</if>
- <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
- </where>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- order by parent_id, order_num
- </select>
- <select id="lazyList" parameterType="TWarehouse" resultMap="TWarehouseResult">
- select
- ware.f_id, ware.parent_id, ware.ancestors, ware.order_num,ware.f_no, ware.f_name,ware.f_totalgross, ware.f_location,
- ware.f_addr,ware.f_contacts,ware.f_tel,ware.f_charg,ware.f_is_bonded,ware.remark,ware.f_status,
- (
- SELECT
- CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END
- FROM
- t_warehouse
- WHERE
- parent_id = ware.f_id AND del_flag = '0'
- ) AS "has_children"
- from t_warehouse ware
- <where>
- <if test="parentId != null">and ware.parent_id = #{parentId}</if>
- <if test="fNo != null and fNo != ''">and ware.f_no like concat('%', #{fNo}, '%')</if>
- <if test="fName != null and fName != ''">and ware.f_name like concat('%', #{fName}, '%')</if>
- <if test="fStatus != null and fStatus != ''">and ware.f_status = #{fStatus}</if>
- </where>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- order by ware.parent_id, ware.order_num
- </select>
- <select id="selectTWarehouseLists" parameterType="TWarehouse" resultMap="TWarehouseResult">
- <include refid="selectTWarehouseVo"/>
- <where>
- parent_id = 100
- </where>
- </select>
- <select id="appGetWarehouseList" resultType="map">
- SELECT
- f_id AS fId,
- f_name AS fName
- FROM t_warehouse
- WHERE parent_id = 100
- <if test="corpId != null and corpId != ''">
- AND f_id IN (SELECT DISTINCT f_warehouseid FROM t_whgenleg WHERE f_corpid = #{corpId})
- </if>
- </select>
- <select id="selectTWarehouseById" parameterType="Long" resultMap="TWarehouseResult">
- <include refid="selectTWarehouseVo"/>
- where f_id = #{fId}
- </select>
- <insert id="insertTWarehouse" parameterType="TWarehouse" useGeneratedKeys="true" keyProperty="fId">
- insert into t_warehouse
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="parentId != null and parentId != 0">parent_id,</if>
- <if test="ancestors != null and ancestors != ''">ancestors,</if>
- <if test="orderNum != null and orderNum != ''">order_num,</if>
- <if test="fNo != null and fNo != ''">f_no,</if>
- <if test="fIsBonded != null and fIsBonded != ''">f_is_bonded,</if>
- <if test="fName != null and fName != ''">f_name,</if>
- <if test="fAddr != null and fAddr != ''">f_addr,</if>
- <if test="fTotalgross != null">f_totalgross,</if>
- <if test="fContacts != null">f_contacts,</if>
- <if test="fTel != null">f_tel,</if>
- <if test="fCharg != null">f_charg,</if>
- <if test="fStatus != null">f_status,</if>
- <if test="delFlag != null">del_flag,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- <if test="fLocation != null">f_location,</if>
- <if test="fWarehouseInformation != null">f_warehouse_information,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="parentId != null and parentId != 0">#{parentId},</if>
- <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
- <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
- <if test="fNo != null and fNo != ''">#{fNo},</if>
- <if test="fIsBonded != null and fIsBonded != ''">#{fIsBonded},</if>
- <if test="fName != null and fName != ''">#{fName},</if>
- <if test="fAddr != null and fAddr != ''">#{fAddr},</if>
- <if test="fTotalgross != null">#{fTotalgross},</if>
- <if test="fContacts != null">#{fContacts},</if>
- <if test="fTel != null">#{fTel},</if>
- <if test="fCharg != null">#{fCharg},</if>
- <if test="fStatus != null">#{fStatus},</if>
- <if test="delFlag != null">#{delFlag},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- <if test="fLocation != null">#{fLocation},</if>
- <if test="fWarehouseInformation != null">#{fWarehouseInformation},</if>
- </trim>
- </insert>
- <update id="updateTWarehouse" parameterType="TWarehouse">
- update t_warehouse
- <trim prefix="SET" suffixOverrides=",">
- <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
- <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
- <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
- <if test="fNo != null and fNo != ''">f_no = #{fNo},</if>
- <if test="fIsBonded != null and fIsBonded != ''">f_is_bonded = #{fIsBonded},</if>
- <if test="fName != null and fName != ''">f_name = #{fName},</if>
- <if test="fAddr != null and fAddr != ''">f_addr = #{fAddr},</if>
- <if test="fTotalgross != null">f_totalgross = #{fTotalgross},</if>
- <if test="fContacts != null">f_contacts = #{fContacts},</if>
- <if test="fTel != null">f_tel = #{fTel},</if>
- <if test="fCharg != null">f_charg = #{fCharg},</if>
- <if test="fStatus != null">f_status = #{fStatus},</if>
- <if test="delFlag != null">del_flag = #{delFlag},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="fLocation != null">f_location = #{fLocation},</if>
- <if test="fWarehouseInformation != null">f_warehouse_information = #{fWarehouseInformation},</if>
- </trim>
- where f_id = #{fId}
- </update>
- <delete id="deleteTWarehouseById" parameterType="Long">
- delete
- from t_warehouse
- where f_id = #{fId}
- </delete>
- <delete id="deleteTWarehouseByIds" parameterType="String">
- delete from t_warehouse where f_id in
- <foreach item="fId" collection="array" open="(" separator="," close=")">
- #{fId}
- </foreach>
- </delete>
- <select id="checkFNoUnique" parameterType="String" resultMap="TWarehouseResult">
- select f_id, f_no
- from t_warehouse
- where f_no = #{fNo}
- limit 1
- </select>
- <select id="checkUFNnameUnique" parameterType="String" resultMap="TWarehouseResult">
- select f_id, f_name
- from t_warehouse
- where f_name = #{fAame}
- limit 1
- </select>
- <select id="checkUFAaddrUnique" parameterType="String" resultMap="TWarehouseResult">
- select f_id, f_addr
- from t_warehouse
- where f_addr = #{fAddr}
- limit 1
- </select>
- <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
- select count(*)
- from t_warehouse
- where f_status = 0
- and del_flag = '0'
- and find_in_set(#{fId}, ancestors)
- </select>
- <select id="selectChildrenDeptById" parameterType="Long" resultMap="TWarehouseResult">
- select *
- from t_warehouse
- where find_in_set(#{fId}, ancestors)
- </select>
- <select id="selectTWarehousById" resultMap="TWarehouseResult">
- select f_id
- from t_warehouse
- where parent_id = #{fId}
- limit 1
- </select>
- <update id="updateDeptChildren" parameterType="java.util.List">
- update t_warehouse set ancestors =
- <foreach collection="depts" item="item" index="index"
- separator=" " open="case f_id" close="end">
- when #{item.fId} then #{item.ancestors}
- </foreach>
- where f_id in
- <foreach collection="depts" item="item" index="index"
- separator="," open="(" close=")">
- #{item.fId}
- </foreach>
- </update>
- <update id="updateDeptStatus" parameterType="TWarehouse">
- update t_warehouse
- <set>
- <if test="fStatus != null and fStatus != ''">f_status = #{fStatus},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- update_time = sysdate()
- </set>
- where f_id in (${ancestors})
- </update>
- <update id="updatefTotalgross">
- update t_warehouse
- <set>
- <if test="fTotalgross != null and fTotalgross != ''">f_totalgross = #{fTotalgross},</if>
- update_time = sysdate()
- </set>
- where f_id = #{fId}
- </update>
- <select id="selectTWarehouseFTotalgross" resultType="java.math.BigDecimal">
- SELECT sum(f_totalgross) AS fTotalgross
- FROM t_warehouse
- WHERE ancestors LIKE concat('%', #{fId}, '%')
- </select>
- <select id="checkDeptNameUnique" resultMap="TWarehouseResult">
- <include refid="selectTWarehouseVo"/>
- where f_name=#{fName} and parent_id = #{parentId} limit 1
- </select>
- <select id="hasChildByfId" parameterType="Long" resultType="int">
- select count(1)
- from t_warehouse
- where del_flag = '0'
- and parent_id = #{fId}
- limit 1
- </select>
- <select id="checkDeptExistarehouse" parameterType="Long" resultType="int">
- select count(1)
- from t_warehousebills
- where f_warehouseid = #{fId}
- and del_flag = '0'
- </select>
- <select id="checkDeptExistWarehouseItems" parameterType="Long" resultType="int">
- select count(1)
- from t_warehousebillsitems
- where f_warehouselocid = #{fId}
- and del_flag = '0'
- </select>
- <select id="selectByIds" resultMap="TWarehouseResult">
- <include refid="selectTWarehouseVo"/>
- where f_id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- </mapper>
|