123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873 |
- <?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="fCname" column="f_cname"/>
- <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"/>
- <result property="supervise" column="supervise"/>
- <result property="fProperties" column="f_properties"/>
- <result property="fType" column="f_type"/>
- <result property="fGoodsType" column="f_goods_type"/>
- <result property="fCoverArea" column="f_cover_area"/>
- </resultMap>
- <sql id="selectTWarehouseVo">
- select f_id,
- parent_id,
- ancestors,
- order_num,
- f_no,
- f_is_bonded,
- f_name,
- f_cname,
- 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,
- supervise,
- f_properties,
- f_type,
- f_goods_type,
- f_cover_area
- 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="fCname != null and fCname != ''">and f_cname like concat('%', #{fCname}, '%')</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>
- <if test="supervise != null and supervise != ''">and supervise = #{supervise}</if>
- <if test="fProperties != null and fProperties != ''">and f_properties like concat('%', #{fProperties}, '%')</if>
- <if test="fType != null and fType != ''">and f_type like concat('%', #{fType}, '%')</if>
- <if test="fGoodsType != null and fGoodsType != ''">and f_goods_type like concat('%', #{fGoodsType}, '%')</if>
- <if test="fCoverArea != null and fCoverArea != ''">and f_cover_area like concat('%', #{fCoverArea}, '%')</if>
- </where>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- order by parent_id, order_num, convert(f_name using gbk)
- </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_cname, 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.supervise, ware.f_status,
- ware.f_properties, ware.f_type, ware.f_goods_type, ware.f_cover_area,
- (
- SELECT
- CASE WHEN count( * ) > 0 THEN 1 ELSE 0 END
- FROM
- t_warehouse tw
- WHERE
- tw.parent_id = ware.f_id AND tw.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="fCname != null and fCname != ''">and ware.f_cname like concat('%', #{fCname}, '%')</if>
- <if test="fStatus != null and fStatus != ''">and ware.f_status = #{fStatus}</if>
- <if test="supervise != null and supervise != ''">and ware.supervise = #{supervise}</if>
- <if test="fProperties != null and fProperties != ''">and f_properties like concat('%', #{fProperties}, '%')</if>
- <if test="fType != null and fType != ''">and f_type like concat('%', #{fType}, '%')</if>
- <if test="fGoodsType != null and fGoodsType != ''">and f_goods_type like concat('%', #{fGoodsType}, '%')</if>
- <if test="fCoverArea != null and fCoverArea != ''">and f_cover_area like concat('%', #{fCoverArea}, '%')</if>
- <if test="fAddr != null and fAddr != ''">and f_addr like concat('%', #{fAddr}, '%')</if>
- </where>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- order by ware.parent_id, ware.order_num, convert(ware.f_name using gbk)
- </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="fCname != null and fCname != ''">f_cname,</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>
- <if test="supervise != null">supervise,</if>
- <if test="fProperties != null">f_properties,</if>
- <if test="fType != null">f_type,</if>
- <if test="fGoodsType != null">f_goods_type,</if>
- <if test="fCoverArea != null">f_cover_area,</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="fCname != null and fCname != ''">#{fCname},</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>
- <if test="supervise != null">#{supervise},</if>
- <if test="fProperties != null">#{fProperties},</if>
- <if test="fType != null">#{fType},</if>
- <if test="fGoodsType != null">#{fGoodsType},</if>
- <if test="fCoverArea != null">#{fCoverArea},</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="fCname != null and fCname != ''">f_cname = #{fCname},</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>
- <if test="supervise != null">supervise = #{supervise},</if>
- <if test="fProperties != null">f_properties = #{fProperties},</if>
- <if test="fType != null">f_type = #{fType},</if>
- <if test="fGoodsType != null">f_goods_type = #{fGoodsType},</if>
- <if test="fCoverArea != null">f_cover_area = #{fCoverArea},</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>
- <select id="biWarehouseList" resultType="map">
- select
- f_id as warehouseId,
- f_name as warehouseName
- from t_warehouse
- where parent_id = 100
- <if test="external != null and external != ''">
- and f_id in (
- select distinct f_warehouseid
- from t_customer_contact t1 left join t_whgenleg t2 on t1.f_pid = t2.f_corpid
- where f_tel = #{external})
- </if>
- order by convert(f_name using gbk)
- </select>
- <select id="getWarehouseByNo" parameterType="String" resultMap="TWarehouseResult">
- <include refid="selectTWarehouseVo"/>
- <where>
- f_id = #{fNo} and del_flag = '0' limit 1
- </where>
- </select>
- <select id="queryGoodsAccountByPageV1" resultType="map">
- SELECT
- TW.f_id AS warehouseCode,
- TW.f_name AS warehouseName,
- TC.uscc AS ownerSocialIdentifier,
- TC.f_id AS ownerCode,
- TC.f_name AS ownerName,
- TG.f_name AS goodsName,
- TG.f_packagespecs AS specifications,
- '' AS producing,
- TWG.f_marks AS materialQuality,
- '' AS LEVEL,
- SUM(TWG.f_qtyD) AS totalQuantity,
- SUM(TWG.f_qtyblc) AS availableQuantity,
- '袋' AS quantityUnit,
- IFNULL( ROUND( SUM(TWG.f_netweightD) / 1000, 2 ), 0 ) AS totalNetWeight,
- IFNULL( ROUND( SUM(TWG.f_netweightblc) / 1000, 2 ), 0 ) AS availableWeight,
- '吨' AS weightUnit,
- CONCAT_WS('-',IFNULL( TG.f_name, '' ),CONCAT_WS( IFNULL( TG.f_packagespecs, '' ), '/袋' ),IFNULL( TWG.f_marks, '' )) AS spu
- FROM t_warehouse TW
- LEFT JOIN t_whgenleg TWG ON TWG.f_warehouseid = TW.f_id
- LEFT JOIN t_corps TC ON TC.f_id = TWG.f_corpid
- LEFT JOIN t_goods TG ON TG.f_id = TWG.f_goodsid
- <where>
- TW.del_flag = '0'
- and TWG.f_qtyblc > 0
- <if test="warehouseCode != null and warehouseCode != ''"> and TW.f_id = #{warehouseCode}</if>
- <if test="ownerName != null and ownerName != ''"> and TC.f_name like concat('%', #{ownerName}, '%')</if>
- <if test="goodsName != null and goodsName != ''"> and TG.f_name like concat('%', #{goodsName}, '%')</if>
- <if test="specifications != null and specifications != ''"> and TG.f_packagespecs like concat('%', #{specifications}, '%')</if>
- <if test="materialQuality != null and materialQuality != ''"> and TWG.f_marks like concat('%', #{materialQuality}, '%')</if>
- <if test="ownerSocialIdentifier != null and ownerSocialIdentifier != ''"> and TC.uscc = #{ownerSocialIdentifier}</if>
- <if test="ownerCode != null and ownerCode != ''"> and TC.f_id = #{ownerCode}</if>
- </where>
- GROUP BY
- TW.f_id,TC.f_no,TG.f_name,TG.f_packagespecs,TWG.f_marks
- </select>
- <select id="queryGoodsAccountDetailByPageV1" resultType="map">
- SELECT
- DISTINCT
- TWG.f_id AS id,
- TW.f_id AS warehouseCode,
- TW.f_name AS warehouseName,
- ware.f_name AS areaName,
- ware.f_id AS areaCode,
- ware.f_name AS slotName,
- ware.f_id AS slotCode,
- TWG.f_originalbillno AS receiptDoc,
- TWG.f_mblno AS billOfLading,
- TC.f_id AS ownerCode,
- TC.f_name AS ownerName,
- TC.uscc AS ownerSocialIdentifier,
- TG.f_name AS goodsName,
- TG.f_packagespecs AS specifications,
- '' AS producing,
- TWG.f_marks AS materialQuality,
- '' AS LEVEL,
- TWG.f_qtyD AS totalQuantity,
- TWG.f_qtyblc AS availableQuantity,
- '袋' AS quantityUnit,
- IFNULL( ROUND( TWG.f_netweightD / 1000, 2 ), 0 ) AS totalNetWeight,
- IFNULL( ROUND( TWG.f_netweightblc / 1000, 2 ), 0 ) AS availableWeight,
- '吨' AS weightUnit,
- TWG.f_originalbilldate AS storesTime,
- '' AS productionTime,
- TWB.f_truckno AS plateNumber,
- '' AS batchNo,
- '' AS warehouseReceiptNo
- FROM
- t_whgenleg TWG
- LEFT JOIN t_warehouse TW ON TWG.f_warehouseid = TW.f_id
- LEFT JOIN t_warehouse ware ON ware.f_id = TWG.f_warehouse_locationid
- LEFT JOIN t_corps TC ON TC.f_id = TWG.f_corpid
- LEFT JOIN t_goods TG ON TG.f_id = TWG.f_goodsid
- LEFT JOIN t_warehousebills TWB ON TWG.f_originalbillno = TWB.f_billno
- <where>
- TW.del_flag = '0'
- and TWG.f_qtyblc > 0
- <if test="warehouseCode != null and warehouseCode != ''"> and TWG.f_warehouseid = #{warehouseCode}</if>
- <if test="ownerName != null and ownerName != ''"> and TC.f_name like concat('%', #{ownerName}, '%')</if>
- <if test="ownerCode != null and ownerCode != ''"> and TC.f_id = #{ownerCode}</if>
- <if test="ownerSocialIdentifier != null and ownerSocialIdentifier != ''"> and TC.uscc = #{ownerSocialIdentifier}</if>
- <if test="goodsName != null and goodsName != ''"> and TG.f_name like concat('%', #{goodsName}, '%')</if>
- <if test="specifications != null and specifications != ''"> and TG.f_packagespecs like concat('%', #{specifications}, '%')</if>
- <if test="materialQuality != null and materialQuality != ''"> and TWG.f_marks like concat('%', #{materialQuality}, '%')</if>
- <if test="receiptDoc != null and receiptDoc != ''"> and TWG.f_originalbillno like concat('%', #{receiptDoc}, '%')</if>
- <if test="billOfLading != null and billOfLading != ''"> and TWG.f_mblno like concat('%', #{billOfLading}, '%')</if>
- <if test="areaName != null and areaName != ''"> and ware.f_name like concat('%', #{areaName}, '%')</if>
- <if test="areaCode != null and areaCode != ''"> and ware.f_id = #{areaCode}</if>
- <if test="slotName != null and slotName != ''"> and ware.f_name like concat('%', #{slotName}, '%')</if>
- <if test="slotCode != null and slotCode != ''"> and ware.f_id = #{slotCode}</if>
- </where>
- </select>
- <select id="getWareHouseInfo" parameterType="String" resultMap="TWarehouseResult">
- <include refid="selectTWarehouseVo"/>
- <where>
- f_id = #{wareHouseId} and del_flag = '0' limit 1
- </where>
- </select>
- <select id="getStorageInfo" resultType="map">
- SELECT
- cast(IFNULL( ROUND( TW.f_totalgross / 1000, 2 ), 0 ) as DECIMAL(20,2)) AS capacity,
- IFNULL( ROUND( TWB.f_netweight / 1000, 2 ), 0 ) AS storage,
- TTL.value AS throughput,
- count(distinct(TWB.f_corpid)) AS customers
- FROM
- t_warehouse TW
- LEFT JOIN t_warehousebills TWB ON TW.f_id = TWB.f_warehouseid
- LEFT JOIN (
- SELECT
- f_warehouseid,
- ROUND( SUM(f_grossweight) / 1000, 2 ) as value
- FROM t_warehousebills
- where
- del_flag = '0'
- and f_billtype in ('SJCK')
- GROUP BY
- f_id
- ) TTL ON TTL.f_warehouseid = TW.f_id
- <where>
- TW.del_flag = '0'
- AND TW.f_id = #{wareHouseId}
- </where>
- GROUP BY
- TW.f_id
- </select>
- <select id="getTimeStorageInfo" resultType="map">
- SELECT
- f_bsdate as time,
- ROUND( SUM(f_grossweight) / 1000, 2 ) as value
- FROM t_warehousebills
- <where>
- del_flag = '0'
- AND f_warehouseid = #{wareHouseId}
- <if test="startTime != null and startTime != ''">
- and f_bsdate >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and f_bsdate <= #{endTime}
- </if>
- <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
- and f_bsdate>=date(now()) and f_bsdate < DATE_ADD(date(now()),INTERVAL 1 DAY)
- </if>
- </where>
- </select>
- <select id="getTimeThroughputInfo" resultType="map">
- SELECT
- f_bsdate as time,
- ROUND( SUM(f_grossweight) / 1000, 2 ) as value
- FROM t_warehousebills
- <where>
- del_flag = '0'
- AND f_warehouseid = #{wareHouseId}
- and f_billtype in ('SJRK','SJCK')
- <if test="startTime != null and startTime != ''">
- and f_bsdate >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and f_bsdate <= #{endTime}
- </if>
- <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
- and f_bsdate>=date(now()) and f_bsdate < DATE_ADD(date(now()),INTERVAL 1 DAY)
- </if>
- </where>
- </select>
- <select id="getCargoInfo" resultType="map">
- SELECT
- ROUND( SUM(f_grossweight) / 1000, 2 ) as FGrossweight
- FROM t_warehousebills
- <where>
- f_warehouseid = #{wareHouseId}
- <if test="isPledge != null and isPledge != ''">
- and is_pledge = #{isPledge}
- </if>
- <if test="startTime != null and startTime != ''">
- and f_bsdate >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and f_bsdate <= #{endTime}
- </if>
- <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
- and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) <= date(f_bsdate)
- </if>
- </where>
- </select>
- <select id="getGoodsList" resultType="map">
- SELECT
- SDD.dict_label AS goodsType,
- ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as count,
- round(
- SUM(TW.f_grossweight) * 100 /(
- SELECT
- SUM(f_grossweight) as total
- FROM
- t_warehousebills
- ),
- 2
- ) as rate
- FROM
- t_warehousebills TW
- LEFT JOIN sys_dict_data SDD ON SDD.dict_type = 'data_trademodes' AND SDD.dict_value = TW.f_trademodeid
- <where>
- TW.f_warehouseid = #{wareHouseId}
- <if test="startTime != null and startTime != ''">
- and TW.f_bsdate >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and TW.f_bsdate <= #{endTime}
- </if>
- <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
- and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) <= date(TW.f_bsdate)
- </if>
- </where>
- GROUP BY
- SDD.dict_label
- </select>
- <select id="getCargoInfoTrend" resultType="map">
- SELECT
- f_bsdate as time,
- ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as value
- FROM
- t_warehousebills TW
- LEFT JOIN sys_dict_data SDD ON SDD.dict_type = 'data_trademodes' AND SDD.dict_value = TW.f_trademodeid
- <where>
- TW.del_flag = '0'
- AND TW.f_warehouseid = #{wareHouseId}
- AND SDD.dict_value = #{FTradeModeId}
- <if test="startTime != null and startTime != ''">
- and TW.f_bsdate >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and TW.f_bsdate <= #{endTime}
- </if>
- <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
- and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) <= date(TW.f_bsdate)
- </if>
- </where>
- GROUP BY
- SDD.dict_label
- </select>
- <select id="getStorageTop" resultType="map">
- SELECT
- TG.f_name AS goodsName,
- ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as normalCnt,
- '' AS receiptCnt
- FROM
- t_warehousebillsitems TW
- LEFT JOIN t_goods TG ON TG.f_id = TW.f_goodsid
- <where>
- TW.del_flag = '0'
- AND TW.f_warehouselocid = #{wareHouseId}
- <if test="countType != null and countType != '' and countType == 2">
- and TW.f_billtype in ('SJRK','SJCK')
- </if>
- </where>
- GROUP BY TW.f_goodsid
- ORDER BY IFNULL( ROUND( SUM(TW.f_grossweight) / 1000, 2 ), 0 ) DESC
- LIMIT #{topCnt}
- </select>
- <select id="getGoodsTop" resultType="map">
- SELECT
- TC.f_name AS ownerName,
- ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as count
- FROM
- t_warehousebills TW
- LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
- <where>
- TW.del_flag = '0'
- AND TW.f_warehouseid = #{wareHouseId}
- <if test="countType != null and countType != '' and countType == 2">
- and TW.f_billtype in ('SJRK','SJCK')
- </if>
- </where>
- GROUP BY TW.f_corpid
- ORDER BY IFNULL( ROUND( SUM(TW.f_grossweight) / 1000, 2 ), 0 ) DESC
- LIMIT #{topCnt}
- </select>
- <select id="getTransferTransaction" resultType="map">
- SELECT
- f_bsdate as time,
- ROUND( SUM(f_grossweight) / 1000, 2 ) as value
- FROM
- t_warehousebills
- <where>
- del_flag = '0'
- AND f_warehouseid = #{wareHouseId}
- <if test="startTime != null and startTime != ''">
- and f_bsdate >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and f_bsdate <= #{endTime}
- </if>
- <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
- and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) <= date(f_bsdate)
- </if>
- </where>
- </select>
- <select id="getWorkInfo" resultType="map">
- SELECT
- IFNULL( ROUND( SUM( TW.f_grossweight ) / 1000, 2 ),0) AS Fgrossweight,
- COUNT(f_id) AS count
- FROM
- t_warehousebills TW
- <where>
- TW.del_flag = '0'
- AND TW.f_warehouseid = #{wareHouseId}
- <if test="countType != null and countType != '' and countType == 'SJRK'">
- and TW.f_billtype = #{countType}
- </if>
- </where>
- </select>
- <select id="getWorkTrend" resultType="map">
- SELECT
- f_bsdate as time,
- ROUND( SUM( TW.f_grossweight ) / 1000, 2 ) AS value
- FROM
- t_warehousebills TW
- <where>
- TW.del_flag = '0'
- AND TW.f_warehouseid = #{wareHouseId}
- <if test="countType != null and countType != ''">
- and TW.f_billtype = #{countType}
- </if>
- <if test="startTime != null and startTime != ''">
- and TW.f_bsdate >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and TW.f_bsdate <= #{endTime}
- </if>
- <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
- and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) <= date(TW.f_bsdate)
- </if>
- </where>
- </select>
- <select id="inventoryQueries" resultType="com.ruoyi.warehouseBusiness.response.InventoryQueryResponse">
- SELECT
- TWH.f_no AS warehouseSerialNumber,
- TW.f_mblno AS blNo,
- TW.f_originalbilldate AS originalWarehousingDate,
- TW.f_originalbilldate AS rentBeginDate,
- TC.f_name AS sourceOwnerName,
- TC.uscc AS sourceOwnerSocialIdentifier,
- TC.f_name AS currentOwnerName,
- TC.uscc AS currentOwnerSocialIdentifier,
- TWH.f_addr AS warehouseAddress,
- TG.f_name AS cargoName,
- TW.f_marks AS cargoModel,
- TW.f_marks AS cargoSpec,
- IFNULL( ROUND( SUM( TW.f_netweightblc ) / 1000, 2 ), 0 ) AS netWeight,
- IFNULL( ROUND( SUM( TW.f_grossweightblc ) / 1000, 2 ), 0 ) AS grossWeight,
- SUM( TW.f_qtyblc ) AS cargoQuantity
- -- '' AS storageRate,
- -- TW.f_marks AS mark,
- -- SUM( TW.f_qtyblc ) AS number,
- -- (CASE
- -- TWBI.f_business_type
- -- WHEN '3' THEN
- -- TWBI.f_marks ELSE ''
- -- END) AS manufacturer,
- -- '' AS trademark,
- -- '' AS grade,
- -- TG.f_packagespecs AS packing,
- -- '' AS country,
- -- '' AS process,
- -- TWBI.f_warehouse_information AS location
- FROM t_whgenleg TW
- LEFT JOIN t_goods TG ON TG.f_id = TW.f_goodsid
- LEFT JOIN t_warehouse TWH ON TW.f_warehouseid = TWH.f_id
- LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
- <!--LEFT JOIN (
- SELECT DISTINCT
- TWB.f_ifpledge,
- TWB.f_mblno,
- bi.f_business_type,
- bi.f_marks,
- bi.f_warehouse_information,
- bi.f_warehouselocid
- FROM
- t_warehousebills TWB
- LEFT JOIN t_warehousebillsitems bi ON bi.f_pid = TWB.f_id
- WHERE
- TWB.del_flag = '0'
- <if test="numbersList != null and numbersList != ''">
- and TWB.f_mblno IN
- <foreach item="number" collection="numbersList" open="(" separator="," close=")">
- #{number}
- </foreach>
- </if>
- ) TWBI ON TWBI.f_mblno = TW.f_mblno
- AND TWBI.f_warehouselocid = TW.f_warehouseid-->
- <where>
- TW.del_flag = '0'
- and TW.f_netweightblc != 0
- /* AND (TWBI.f_ifpledge != 0 or TWBI.f_ifpledge IS NULL)*/
- <if test="ownerName != null and ownerName != ''">
- and TC.f_name = #{ownerName}
- </if>
- <if test="identifier != null and identifier != ''">
- and TC.uscc = #{identifier}
- </if>
- <if test="numbersList != null and numbersList != ''">
- and TWH.f_no in
- <foreach item="number" collection="numbersList" open="(" separator="," close=")">
- #{number}
- </foreach>
- </if>
- </where>
- GROUP BY
- TW.f_originalbillno
- </select>
- <update id="receiptRegister">
- update t_warehousebills TW
- LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
- SET TW.f_ifpledge = '0'
- <where>
- TW.del_flag = '0'
- <if test="ownerName != null and ownerName != ''">
- and TC.f_name = #{ownerName}
- </if>
- <if test="identifier != null and identifier != ''">
- and TC.uscc = #{identifier}
- </if>
- <if test="numbers != null and numbers != ''">
- and TW.f_mblno = #{numbers}
- </if>
- </where>
- </update>
- <update id="receiptCancel">
- update t_warehousebills TW
- LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
- SET TW.f_ifpledge = '1'
- <where>
- TW.del_flag = '0'
- <if test="ownerName != null and ownerName != ''">
- and TC.f_name = #{ownerName}
- </if>
- <if test="identifier != null and identifier != ''">
- and TC.uscc = #{identifier}
- </if>
- <if test="numbers != null and numbers != ''">
- and TW.f_mblno = #{numbers}
- </if>
- </where>
- </update>
- <select id="selectByPidANDName" resultMap="TWarehouseResult">
- <include refid="selectTWarehouseVo"/>
- <where>
- parent_id = #{fWarehouseid} and del_flag = '0' and f_name =#{stringCellValue}
- </where>
- </select>
- <select id="getStorageTopS" resultType="java.util.Map">
- SELECT
- TG.f_name AS goodsName,
- ROUND( SUM(TW.f_grossweightblc) / 1000, 2 ) as normalCnt,
- '' AS receiptCnt
- FROM
- t_whgenleg TW
- LEFT JOIN t_goods TG ON TG.f_id = TW.f_goodsid
- <where>
- TW.del_flag = '0'
- AND TW.f_warehouseid = #{wareHouseId}
- </where>
- GROUP BY TW.f_goodsid
- ORDER BY IFNULL( ROUND( SUM(TW.f_grossweightblc) / 1000, 2 ), 0 ) DESC
- LIMIT #{topCnt}
- </select>
- </mapper>
|