WarehouseMapperEx.xml 7.2 KB
Newer Older
苗卫卫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
<?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.boco.nbd.wios.manage.mapper.extdb.WarehouseMapperEx">

    <select id="getWarehouseLevenByNameCount" resultType="integer">
        SELECT
            count( 1 )
        FROM
            t_warehouse_leven
        WHERE
            `status` = 1
            <if test="parentId != null and parentId != ''">
                AND parent_id = #{parentId}
            </if>
            <if test="id != null and id != ''">
                and id != #{id}
            </if>
            AND NAME = #{name}
    </select>

    <select id="getWarehouseLevenParentLastId" parameterType="integer" resultType="integer">
        SELECT
            IFNULL( max( id ), 0 ) + 1
        FROM
            t_warehouse_leven
    </select>

    <select id="getWarehouseLevenParentSeq" parameterType="integer" resultType="integer">
        SELECT
            IFNULL( max( seq ), 0 ) + 1
        FROM
            t_warehouse_leven
        WHERE
            parent_id = #{parentId}
            and status = 1
    </select>

    <select id="qryWarehouseLevenById" resultType="map">
        select
            id,
            name,
            parent_id parentId
        from
            t_warehouse_leven
        where
            status = 1
            and id = #{parentId}
        limit 1
    </select>


    <insert id="insertWarehouseLeven" parameterType="com.boco.nbd.wios.manage.entity.bo.WarehouseLeven">
        INSERT INTO t_warehouse_leven(id,appkey,name,parent_id,seq,path_code,path_name,status,create_time,create_account,modify_time,modify_account,msg)
        values (
            #{id},#{appkey},#{name},#{parentId},#{seq},#{pathCode},#{pathName},#{status},#{createTime},#{createAccount},#{modifyTime},#{modifyAccount},#{msg}
        )
         ON DUPLICATE KEY UPDATE parent_id = values(parent_id),seq = values(seq),name = values(name),path_code = values(path_code),path_name=values(path_name),msg=values(msg)
    </insert>


    <insert id="insertWarehouse" parameterType="com.boco.nbd.wios.manage.entity.bo.Warehouse">
62 63 64
        insert  into t_warehouse(id,appkey,warehouse_leven_id,name,area,service_provider,warehouse_attribution,msg,status,create_time,create_account,modify_account,modify_time,is_enabled,superior_warehouse_id,receive_people,receive_phone,receive_address)
        values (#{id},#{appkey},#{warehouseLevenId},#{name},#{area},#{serviceProvider},#{warehouseAttribution},#{msg},#{status},#{createTime},#{createAccount},#{modifyAccount},#{modifyTime},#{isEnabled},#{superiorWarehouseId},#{receivePeople},#{receivePhone},#{receiveAddress})
        ON DUPLICATE KEY UPDATE  warehouse_leven_id = values(warehouse_leven_id),name = values(name),area=values(area),service_provider = values(service_provider),warehouse_attribution = values(warehouse_attribution),msg = values(msg),is_enabled = values(is_enabled),superior_warehouse_id = values(superior_warehouse_id),receive_people = values(receive_people),receive_phone = values(receive_phone),receive_address = values(receive_address)
苗卫卫 committed
65 66 67 68 69
    </insert>


    <select id="qryWarehouseList" parameterType="string" resultType="com.boco.nbd.wios.manage.entity.bo.WarehouseEx">
        select
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
        tw.id,
        tw.appkey,
        tw.warehouse_leven_id,
        tw.name,
        tw.area,
        tw.service_provider,
        tw.warehouse_attribution,
        tw.msg,
        tw.status,
        tw.is_enabled,
        tw.create_time,
        tw.create_account,
        tw.modify_account,
        tw.modify_time,
        tw.superior_warehouse_id,
        tw.receive_people,
        tw.receive_phone,
        tw.receive_address,
        twl.parent_id parentId,
        twl.path_code pathCode,
90 91 92 93 94 95 96 97 98 99 100 101 102 103
        twl.path_name pathName,
        case
            when tw.warehouse_attribution = 1 then 'CAMS仓库'
            when tw.warehouse_attribution = 2 then '安装服务商仓库'
        end warehouseAttributionName,
        case
            when tw.warehouse_leven_id = 0 then '总仓'
            when tw.warehouse_leven_id = 1 then '仓库'
            when tw.warehouse_leven_id = 2 then '网点'
        end warehouseLevenName,
        case
            when tw.is_enabled = 0 then '已禁用'
            when tw.is_enabled = 1 then '已启用'
        end isEnabledName
苗卫卫 committed
104 105 106 107
        from
        t_warehouse tw
        LEFT JOIN t_warehouse_leven twl on tw.warehouse_leven_id = twl.id
        where
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
        tw.status = 1
        and tw.appkey = #{appkey}
        <if test="id != null and id != ''">
            and tw.id = #{id}
        </if>
        <if test="isEnable != null">
            and tw.is_enabled = #{isEnable}
        </if>
        <if test="serviceProviders != null and serviceProviders.size() > 0">
            and tw.service_provider in
            <foreach collection="serviceProviders" item="item" index="index"
                     open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="area != null and area != ''">
            and tw.area = #{area}
        </if>
        <if test="warehouseAttribution != null and warehouseAttribution != ''">
            and tw.warehouse_attribution = #{warehouseAttribution}
        </if>
129 130 131
        <if test="createAccount != null and createAccount != ''">
            and tw.create_account = #{createAccount}
        </if>
132 133 134 135 136 137
        <if test="name != null and name != ''">
            and tw.name like CONCAT('%',#{name},'%')
        </if>
        <if test="warehouseLevenId != null and warehouseLevenId != '' ">
            and tw.warehouse_leven_id = #{warehouseLevenId}
        </if>
138 139 140
        <if test="superiorWarehouseId != null and superiorWarehouseId != '' ">
            and tw.superior_warehouse_id = #{superiorWarehouseId}
        </if>
141
        order by tw.create_time desc
苗卫卫 committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
    </select>

    <select id="qryWarehouseLeven" resultType="com.boco.nbd.wios.manage.entity.bo.WarehouseLeven">
        SELECT
            twl.id,
            twl.name,
            twl.parent_id,
            twl.seq,
            twl.msg,
            twl.path_name,
            twl.path_code
        FROM
            t_warehouse_leven twl
            LEFT JOIN t_warehouse tw on tw.warehouse_leven_id = twl.id
        WHERE
            twl.`status` = 1
            and twl.appkey = #{appkey}
            <if test="serviceProvider != null and serviceProvider != '' and serviceProvider != 'null'">
                and tw.service_provider = #{serviceProvider}
            </if>
            <if test="parentId != null">
                and twl.parent_id = #{parentId}
            </if>
            <if test="id != null">
                and twl.id = #{id}
            </if>
            <if test="name != null and name != ''">
                and twl.name  like CONCAT('%',#{name},'%')
            </if>
        GROUP BY twl.id
    </select>


    <update id="updateWarehouseisEnabled">
        update
            t_warehouse
        set
            is_enabled = #{isEnabled}
        where id = #{id}
    </update>

183 184 185 186
    <select id="wareHouseBySuperiorWarehouseId" parameterType="string" resultType="com.boco.nbd.wios.manage.entity.bo.WarehouseEx">
        select id,name from t_warehouse where id = #{superiorWarehouseId}
    </select>

苗卫卫 committed
187
</mapper>