| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- <?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.dk.mdm.mapper.ivt.OutboundMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- out_id, out_no, out_type, from_id, from_no, org_id, staff_id, cus_id, sup_id, out_status, outing_qty, outing_amt, out_qty, out_amt, return_qty, return_amt, out_date, remarks, annex_paths, make_staff, make_time, receivable_id, payable_id, flg_valid, cp_id
- </sql>
- <sql id="Base_Column_List_Response">
- tpo.out_id, tpo.out_no, tpo.out_type, tpo.from_id, tpo.from_no, tpo.org_id, tpo.staff_id,
- tpo.cus_id, tpo.sup_id, tpo.out_status, tpo.outing_qty, tpo.outing_amt, tpo.out_qty, tpo.out_amt,
- tpo.return_qty, tpo.return_amt, tpo.out_date, tpo.remarks, tpo.annex_paths, tpo.make_staff,
- tpo.make_time, tpo.receivable_id, tpo.payable_id, tpo.flg_valid, tpo.cp_id
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.ivt.Outbound">
- <id column="out_id" property="outId"/>
- <result column="out_no" property="outNo"/>
- <result column="out_type" property="outType"/>
- <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
- <result column="from_no" property="fromNo"/>
- <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
- <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
- <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
- <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
- <result column="out_status" property="outStatus"/>
- <result column="outing_qty" property="outingQty"/>
- <result column="outing_amt" property="outingAmt"/>
- <result column="out_qty" property="outQty"/>
- <result column="out_amt" property="outAmt"/>
- <result column="return_qty" property="returnQty"/>
- <result column="return_amt" property="returnAmt"/>
- <result column="out_date" property="outDate" typeHandler="TimestampTypeHandler"/>
- <result column="remarks" property="remarks"/>
- <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
- <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
- <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
- <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
- <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_app_code" property="opAppCode"/>
- <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
- <result column="op_db_user" property="opDbUser"/>
- </resultMap>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.ivt.OutboundResponse">
- <id column="out_id" property="outId"/>
- <result column="out_no" property="outNo"/>
- <result column="out_type" property="outType"/>
- <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
- <result column="from_no" property="fromNo"/>
- <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
- <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
- <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
- <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
- <result column="out_status" property="outStatus"/>
- <result column="outing_qty" property="outingQty"/>
- <result column="outing_amt" property="outingAmt"/>
- <result column="out_qty" property="outQty"/>
- <result column="out_amt" property="outAmt"/>
- <result column="return_qty" property="returnQty"/>
- <result column="return_amt" property="returnAmt"/>
- <result column="out_date" property="outDate" typeHandler="TimestampTypeHandler"/>
- <result column="remarks" property="remarks"/>
- <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
- <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
- <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
- <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
- <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <result column="org_name" property="orgName"/>
- <result column="staff_name" property="staffName"/>
- <result column="cus_code" property="cusCode"/>
- <result column="cus_name" property="cusName"/>
- <result column="cus_phone" property="cusPhone"/>
- <result column="contact_phone" property="contactPhone"/>
- <result column="contact_name" property="contactName"/>
- <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
- <result column="address_name" property="addressName"/>
- <result column="address_no" property="addressNo"/>
- <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
- <result column="address_full" property="addressFull"/>
- <result column="channel_name" property="channelName"/>
- <result column="cus_from_name" property="cusFromName"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="outNo != null and outNo != ''">
- AND t.out_no LIKE concat('%',my_ex.likequery(#{outNo}),'%')
- </if>
- <if test="outType != null and outType != ''">
- AND t.out_type = #{outType}
- </if>
- <if test="fromId != null and fromId != ''">
- AND t.from_id = #{fromId}
- </if>
- <if test="fromNo != null and fromNo != ''">
- AND t.from_no = #{fromNo}
- </if>
- <if test="orgId != null and orgId != ''">
- AND t.org_id = #{orgId}
- </if>
- <if test="staffId != null and staffId != ''">
- AND t.staff_id = #{staffId}
- </if>
- <if test="cusId != null and cusId != ''">
- AND t.cus_id = #{cusId}
- </if>
- <if test="supId != null and supId != ''">
- AND t.sup_id = #{supId}
- </if>
- <if test="outStatus != null and outStatus != ''">
- AND t.out_status = #{outStatus}
- </if>
- <if test="outingQty != null">
- AND t.outing_qty = #{outingQty}
- </if>
- <if test="outingAmt != null">
- AND t.outing_amt = #{outingAmt}
- </if>
- <if test="outQty != null">
- AND t.out_qty = #{outQty}
- </if>
- <if test="outAmt != null">
- AND t.out_amt = #{outAmt}
- </if>
- <if test="returnQty != null">
- AND t.return_qty = #{returnQty}
- </if>
- <if test="returnAmt != null">
- AND t.return_amt = #{returnAmt}
- </if>
- <if test="remarks != null and remarks != ''">
- AND t.remarks = #{remarks}
- </if>
- <if test="annexPaths != null and annexPaths != ''">
- AND t.annex_paths = #{annexPaths}
- </if>
- <if test="makeStaff != null and makeStaff != ''">
- AND t.make_staff = #{makeStaff}
- </if>
- <if test="receivableId != null and receivableId != ''">
- AND t.receivable_id = #{receivableId}
- </if>
- <if test="payableId != null and payableId != ''">
- AND t.payable_id = #{payableId}
- </if>
- <if test="cpId != null">
- AND t.cp_id = #{cpId}
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND t.from_no LIKE concat('%',my_ex.likequery(#{orderNo}),'%')
- </if>
- <if test="cusPhone != null and cusPhone != ''">
- AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
- </if>
- <if test="cusName != null and cusName != ''">
- AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
- </if>
- <if test="orgIdList != null and orgIdList.size() > 0">
- AND t.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="staffIdList != null and staffIdList.size() > 0">
- AND t.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="outStatusList != null and outStatusList.size() > 0">
- AND t.out_status =any(#{outStatusList, typeHandler=StringListTypeHandler})
- </if>
- <if test="outDateStart != null and outDateEnd != null">
- AND t.out_date >= #{outDateStart}::timestamp with time zone
- AND t.out_date < #{outDateEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="makeTimeStart != null and makeTimeEnd != null">
- AND t.make_time >= #{makeTimeStart}::timestamp with time zone
- AND t.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="flgValidList != null and flgValidList.size()>0">
- AND t.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
- </if>
- </where>
- </sql>
- <sql id="idsForeach">
- <!-- 根据主键outId批量操作 -->
- WHERE out_id in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </sql>
- <!-- 查询表dkic_b.t_psi_outbound,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMapResponse">
- SELECT t.out_id,
- t.out_no,
- t.out_type,
- t.from_id,
- t.from_no,
- t.from_no as "orderNo",
- t.org_id,
- tmo.org_name as "orgName",
- t.staff_id,
- tms.staff_name as "staffName",
- t.cus_id,
- tmc.cus_code as "cusCode",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- tmc.contact_phone as "contactPhone",
- tmc.address_full as "addressFull",
- tmdd.data_value as "cusFromName",
- t.sup_id,
- tmp.sup_name AS "supplierName",
- t.out_status,
- sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "outStatusName",
- sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "outTypeName",
- t.outing_qty,
- t.outing_amt,
- t.out_qty,
- t.out_amt,
- t.return_qty,
- t.return_amt,
- t.out_date,
- t.remarks,
- t.annex_paths,
- t.make_staff,
- makestaff.staff_name as "makeStaffName",
- t.make_time,
- t.receivable_id,
- t.payable_id,
- t.cp_id,
- t.flg_valid
- FROM dkic_b.t_psi_outbound as t
- left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
- Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.sup_id
- left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
- left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
- left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
- left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
- left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
- LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = t.out_type
- <include refid="Condition"/>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表dkic_b.t_psi_outbound,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_psi_outbound as t
- left join dkic_b.t_mst_customer tmc on t.cus_id = tmc.cus_id
- <include refid="Condition"/>
- </select>
- <!-- 根据主键查询表dkic_b.t_psi_outbound的一行数据 -->
- <select id="selectById" resultMap="BaseResultMapResponse">
- SELECT t.out_id,
- t.out_no,
- t.out_type,
- t.from_id,
- t.from_no,
- t.from_no as "orderNo",
- t.org_id,
- tmo.org_name as "orgName",
- t.staff_id,
- tms.staff_name as "staffName",
- t.cus_id,
- tmc.cus_code as "cusCode",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- tmc.contact_phone as "contactPhone",
- tmc.address_full as "addressFull",
- tmdd.data_value as "cusFromName",
- tpo1.address_area,
- tpo1.address_name,
- tpo1.address_no,
- tpo1.address_gcj02,
- tpo1.address_full,
- tpo1.contact_name,
- tpo1.contact_phone,
- tpo1.sales_channel,
- tmsc.channel_name as "channelName",
- t.sup_id,
- t.out_status,
- sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "outStatusName",
- t.outing_qty,
- t.outing_amt,
- t.out_qty,
- t.out_amt,
- t.return_qty,
- t.return_amt,
- t.out_date,
- t.remarks,
- t.annex_paths,
- t.make_staff,
- makestaff.staff_name as "makeStaffName",
- t.make_time,
- t.receivable_id,
- t.payable_id,
- t.cp_id,
- t.flg_valid
- FROM dkic_b.t_psi_outbound as t
- left join dkic_b.t_psi_order as tpo1 on tpo1.order_id = t.from_id
- left join dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tpo1.sales_channel
- left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
- left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
- left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
- left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
- left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
- left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
- WHERE t.out_id = #{id}::uuid
- </select>
- <!-- 根据主键锁定表dkic_b.t_psi_outbound的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_b.t_psi_outbound
- WHERE out_id = #{id}::uuid
- for update
- </select>
- <!-- 根据主键锁定表dkic_b.t_psi_outbound的多行数据 -->
- <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_b.t_psi_outbound
- <include refid="idsForeach"/>
- for update
- </select>
- <insert id="insertBatch">
- insert into dkic_b.t_psi_outbound
- (
- <trim suffixOverrides=",">
- out_no,
- out_type,
- from_id,
- from_no,
- org_id,
- staff_id,
- order_id,
- order_no,
- into_return_id,
- into_return_no,
- cus_id,
- sup_id,
- out_status,
- outing_qty,
- outing_amt,
- out_qty,
- out_amt,
- return_qty,
- return_amt,
- out_date,
- remarks,
- annex_paths,
- make_staff,
- make_time,
- receivable_id,
- payable_id,
- cp_id,
- op_app_code,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.outNo},
- #{item.outType},
- #{item.fromId}::uuid,
- #{item.fromNo},
- #{item.orgId}::uuid,
- #{item.staffId}::uuid,
- #{item.cusId}::uuid,
- #{item.supId}::uuid,
- #{item.outStatus},
- #{item.outingQty},
- #{item.outingAmt},
- #{item.outQty},
- #{item.outAmt},
- #{item.returnQty},
- #{item.returnAmt},
- #{item.outDate},
- #{item.remarks},
- #{item.annexPaths},
- #{item.makeStaff}::uuid,
- #{item.makeTime},
- #{item.receivableId}::uuid,
- #{item.payableId}::uuid,
- #{item.cpId},
- #{item.opAppCode},
- </trim>
- )
- </foreach>
- </insert>
- <!-- 根据id查询带出销售退货单数据(销售退货出库办理用)-->
- <select id="selectMessageByOtherQuery" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tmo.org_name
- ,tms.staff_name
- ,tmc.cus_code
- ,tmc.cus_name
- ,tmc.cus_phone
- ,tmc.contact_phone
- ,tmc.contact_name
- ,tmc.address_area
- ,tmc.address_name
- ,tmc.address_no
- ,tmc.address_gcj02
- ,tmc.address_full
- ,tmsc.channel_name
- ,tmsc.channel_name
- ,tmsc.channel_name
- ,tmd.data_value as cus_from_name
- FROM dkic_b.t_psi_outbound tpo
- Left join dkic_b.t_mst_org tmo on tmo.org_id = tpo.org_id
- Left join dkic_b.t_mst_staff tms on tms.staff_id = tpo.staff_id
- left join dkic_b.t_mst_customer tmc on tpo.cus_id = tmc.cus_id
- left join dkic_b.t_mst_sale_channel tmsc on tmc.channel_id = tmsc.channel_id
- left join dkic_b.t_mst_dictionary_data tmd on tmc.cus_from = tmd.data_id
- <where>
- <if test="outId != null and outId != ''">
- AND tpo.out_id = #{outId}::uuid
- </if>
- <if test="outStatus != null and outStatus != ''">
- AND tpo.out_status = #{outStatus}
- </if>
- </where>
- </select>
- </mapper>
|