| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209 |
- <?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.InboundMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- into_id ,into_no, into_type, from_id, from_no, org_id, staff_id, cus_id, sup_id,
- into_status, sys.f_remove_zero(intoing_qty) as intoing_qty, intoing_amt, sys.f_remove_zero(into_qty) as into_qty
- , into_amt, sys.f_remove_zero(return_qty) as return_qty,
- return_amt, into_date, remarks, annex_paths, make_staff, make_time,
- receivable_id, flg_valid, cp_id, op_create_time, op_create_user_id,
- op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user,wh_id,
- into_reason,flg_auto_handle,inbound_processing_flag
- </sql>
- <!-- response通用查询列 -->
- <sql id="Base_Column_List_Response">
- tpi.into_id, tpi.into_no, tpi.into_type, tpi.from_id, tpi.from_no, tpi.org_id, tpi.staff_id,
- tpi.cus_id, tpi.sup_id, tpi.into_status, sys.f_remove_zero(tpi.intoing_qty) as intoing_qty, tpi.intoing_amt,
- sys.f_remove_zero(tpi.into_qty) as into_qty,
- tpi.into_amt, sys.f_remove_zero(tpi.return_qty) as return_qty, tpi.return_amt, tpi.into_date, tpi.remarks, tpi.annex_paths,
- tpi.make_staff, tpi.make_time, tpi.receivable_id, tpi.flg_valid, tpi.cp_id,
- tpi.wh_id,tpi.into_reason,tpi.flg_auto_handle,tpi.inbound_processing_flag
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.ivt.Inbound">
- <id column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
- <result column="into_no" property="intoNo"/>
- <result column="into_type" property="intoType"/>
- <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="into_status" property="intoStatus"/>
- <result column="intoing_qty" property="intoingQty"/>
- <result column="intoing_amt" property="intoingAmt"/>
- <result column="into_qty" property="intoQty"/>
- <result column="into_amt" property="intoAmt"/>
- <result column="return_qty" property="returnQty"/>
- <result column="return_amt" property="returnAmt"/>
- <result column="into_date" property="intoDate" 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="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"/>
- <result column="into_reason" property="intoReason" typeHandler="UuidTypeHandler"/>
- <result column="wh_id" property="whId"/>
- <result column="flg_auto_handle" property="flgAutoHandle"/>
- <result column="inbound_processing_flag" property="inboundProcessingFlag"/>
- </resultMap>
- <!-- response查询映射结果 -->
- <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.ivt.InboundResponse">
- <id column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
- <result column="into_no" property="intoNo"/>
- <result column="into_type" property="intoType"/>
- <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="into_status" property="intoStatus"/>
- <result column="intoing_qty" property="intoingQty"/>
- <result column="intoing_amt" property="intoingAmt"/>
- <result column="into_qty" property="intoQty"/>
- <result column="into_amt" property="intoAmt"/>
- <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
- <result column="return_qty" property="returnQty"/>
- <result column="return_amt" property="returnAmt"/>
- <result column="into_date" property="intoDate" 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="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <result column="into_reason" property="intoReason" typeHandler="UuidTypeHandler"/>
- <result column="into_reason_name" property="intoReasonName" />
- <!-- <result column="orgName" 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" />
- <result column="return_address" property="returnAddress" />
- <result column="flg_auto_handle" property="flgAutoHandle"/>
- <result column="inbound_processing_flag" property="inboundProcessingFlag"/>
- <result column="pickup_date" property="pickupDate" typeHandler="TimestampTypeHandler"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
- </resultMap>
- <!-- response明细通用查询列 -->
- <sql id="Base_Column_List_Item_Response">
- tpi.into_id
- , tpi.into_no, tpi.into_type, tpi.from_id, tpi.from_no, tpi.org_id, tpi.staff_id, tpi.cus_id, tpi.sup_id,
- tpi.into_status, sys.f_remove_zero(tpi.intoing_qty) as intoing_qty, tpi.intoing_amt,
- sys.f_remove_zero(tpi.into_qty) as into_qty, tpi.into_amt, sys.f_remove_zero(tpi.return_qty) as return_qty, tpi.return_amt, tpi.into_date,
- tpi.remarks, tpi.annex_paths, tpi.make_staff, tpi.make_time,
- tpi.receivable_id, tpi.flg_valid, tpi.cp_id
- </sql>
- <!-- response明细关联明细映射-->
- <resultMap id="BaseResultMapItemResponse" type="com.dk.mdm.model.response.ivt.InboundResponse">
- <id column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
- <result column="into_no" property="intoNo"/>
- <result column="into_type" property="intoType"/>
- <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="into_status" property="intoStatus"/>
- <result column="intoing_qty" property="intoingQty"/>
- <result column="intoing_amt" property="intoingAmt"/>
- <result column="into_qty" property="intoQty"/>
- <result column="into_amt" property="intoAmt"/>
- <result column="return_qty" property="returnQty"/>
- <result column="return_amt" property="returnAmt"/>
- <result column="into_date" property="intoDate" 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="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <collection property="inboundItemList" resultMap="inboundItemListMap" columnPrefix="list_"/>
- </resultMap>
- <!-- 关联映射-->
- <resultMap id="inboundItemListMap" type="java.util.Map">
- <result column="item_id" property="itemId" typeHandler="UuidTypeHandler"/>
- <result column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
- <result column="into_no" property="intoNo" typeHandler="UuidTypeHandler"/>
- <result column="into_type" property="intoType"/>
- <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
- <result column="from_item_id" property="fromItemId" typeHandler="UuidTypeHandler"/>
- <result column="item_index" property="itemIndex"/>
- <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
- <result column="item_qty" property="itemQty"/>
- <result column="price_into" property="priceInto"/>
- <result column="item_amt" property="itemAmt"/>
- <result column="non_std_code" property="nonStdCode"/>
- <result column="into_status" property="intoStatus"/>
- <result column="intoing_qty" property="intoingQty"/>
- <result column="intoing_amt" property="intoingAmt"/>
- <result column="into_qty" property="intoQty"/>
- <result column="into_amt" property="intoAmt"/>
- <result column="return_qty" property="returnQty"/>
- <result column="return_amt" property="returnAmt"/>
- <result column="remarks" property="remarks"/>
- <result column="inv_id" property="invId" typeHandler="UuidTypeHandler"/>
- <result column="cost_price" property="costPrice"/>
- <result column="cost_amt" property="costAmt"/>
- <result column="out_qty" property="outQty"/>
- <result column="inv_qty" property="invQty"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <result column="sku_code" property="skuCode"/>
- <result column="sku_name" property="skuName"/>
- <result column="sku_model" property="skuModel"/>
- <result column="short_name" property="shortName"/>
- <result column="price_purchase" property="pricePurchase"/>
- <result column="reject_qty" property="rejectQty"/>
- <result column="sku_images" property="skuImages" typeHandler="JsonTypeHandler"/>
- <result column="usable_qty" property="usableQty"/>
- <result column="inv_qty" property="invQty"/>
- <result column="outing_qty" property="outingQty"/>
- <result column="price_std" property="priceStd"/>
- <result column="into_item_id" property="intoItemId"/>
- <result column="inv_id" property="invId"/>
- <result column="wh_id" property="whId"/>
- <result column="inv_qty" property="invQty"/>
- <result column="usable_qty" property="usableQty"/>
- <result column="wh_name" property="whName"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="intoNo != null and intoNo != ''">
- AND tpi.into_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
- </if>
- <if test="intoType != null and intoType != ''">
- AND tpi.into_type LIKE concat('%',my_ex.likequery(#{intoType}),'%')
- </if>
- <if test="intoTypes != null and intoTypes.size()>0">
- AND tpi.into_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
- </if>
- <if test="intoReasonList != null and intoReasonList.size()>0">
- AND tpi.into_reason =any(#{intoReasonList,typeHandler=UuidListTypeHandler})
- </if>
- <if test="searchText !=null and searchText != ''">
- AND (
- tpi.into_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tpi.from_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- )
- </if>
- <if test="fromId != null and fromId != ''">
- AND tpi.from_id = #{fromId}::uuid
- </if>
- <if test="fromNo != null and fromNo != ''">
- AND tpi.from_no LIKE concat('%',my_ex.likequery(#{fromNo}),'%')
- </if>
- <if test="orgId != null and orgId != ''">
- AND tpi.org_id = #{orgId}::uuid
- </if>
- <if test="orgName != null and orgName != ''">
- AND tmo.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- <if test="supName != null and supName != ''">
- AND tmp.sup_name LIKE concat('%',my_ex.likequery(#{supName}),'%')
- </if>
- <if test="staffName != null and staffName != ''">
- AND tms.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
- </if>
- <if test="whName != null and whName != ''">
- AND tmw.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
- </if>
- <if test="staffId != null and staffId != ''">
- AND tpi.staff_id = #{staffId}::uuid
- </if>
- <if test="cusId != null and cusId != ''">
- AND tpi.cus_id = #{cusId}::uuid
- </if>
- <if test="supId != null and supId != ''">
- AND tpi.sup_id = #{supId}::uuid
- </if>
- <if test="makeStaff != null and makeStaff != ''">
- AND tpi.make_staff = #{makeStaff}
- </if>
- <if test="makeTime != null">
- AND tpi.make_time = #{makeTime}
- </if>
- <if test="receivableId != null and receivableId != ''">
- AND tpi.receivable_id = #{receivableId}
- </if>
- <if test="flgValid != null">
- AND tpi.flg_valid = #{flgValid}
- </if>
- <if test="cpId != null">
- AND tpi.cp_id = #{cpId}
- </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 tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="staffIdList != null and staffIdList.size() > 0">
- AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="intoDateStart != null and intoDateEnd != null">
- AND tpi.into_date >= #{intoDateStart}::timestamp with time zone
- AND tpi.into_date < #{intoDateEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="makeTimeStart != null and makeTimeEnd != null">
- AND tpi.make_time >= #{makeTimeStart}::timestamp with time zone
- AND tpi.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="intoStatusList != null and intoStatusList.size()>0">
- AND tpi.into_status =
- any(#{intoStatusList, typeHandler= StringListTypeHandler})
- </if>
- <if test="intoStatus != null and intoStatus != ''">
- AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
- </if>
- <if test="skuModel != null and skuModel!='' ">
- and exists (select 1 from dkic_b.t_psi_inbound_item tpii
- left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
- where
- tpi.into_id = tpii.into_id
- and tpii.flg_valid
- AND position(#{skuModel} in tmgs.sku_model) > 0
- )
- </if>
- <if test="skuCode != null and skuCode!='' ">
- and exists (select 1 from dkic_b.t_psi_inbound_item tpii
- left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
- where
- tpi.into_id = tpii.into_id
- and tpii.flg_valid
- AND position(#{skuCode} in tmgs.sku_code) > 0
- )
- </if>
- <if test="skuName != null and skuName!='' ">
- and exists (select 1 from dkic_b.t_psi_inbound_item tpii
- left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
- where
- tpi.into_id = tpii.into_id
- and tpii.flg_valid
- AND position(#{skuName} in tmgs.sku_name) > 0
- )
- </if>
- </where>
- </sql>
- <sql id="ConditionIsSup">
- <where>
- <if test="intoNo != null and intoNo != ''">
- AND tpi.into_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
- </if>
- <if test="intoType != null and intoType != ''">
- AND tpi.into_type LIKE concat('%',my_ex.likequery(#{intoType}),'%')
- </if>
- <if test="intoTypes != null and intoTypes.size()>0">
- AND tpi.into_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
- </if>
- <if test="intoReasonList != null and intoReasonList.size()>0">
- AND tpi.into_reason =any(#{intoReasonList,typeHandler=UuidListTypeHandler})
- </if>
- <if test="fromId != null and fromId != ''">
- AND tpi.from_id = #{fromId}::uuid
- </if>
- <if test="fromNo != null and fromNo != ''">
- AND tpi.from_no LIKE concat('%',my_ex.likequery(#{fromNo}),'%')
- </if>
- <if test="orgId != null and orgId != ''">
- AND tpi.org_id = #{orgId}::uuid
- </if>
- <if test="orgName != null and orgName != ''">
- AND tmo.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- <if test="supName != null and supName != ''">
- AND tmp.sup_name LIKE concat('%',my_ex.likequery(#{supName}),'%')
- </if>
- <if test="staffName != null and staffName != ''">
- AND tms.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
- </if>
- <if test="whName != null and whName != ''">
- AND tmw.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
- </if>
- <if test="staffId != null and staffId != ''">
- AND tpi.staff_id = #{staffId}::uuid
- </if>
- <if test="cusId != null and cusId != ''">
- AND tpi.cus_id = #{cusId}::uuid
- </if>
- <if test="supId != null and supId != ''">
- AND tpi.sup_id = #{supId}::uuid
- </if>
- <if test="makeStaff != null and makeStaff != ''">
- AND tpi.make_staff = #{makeStaff}
- </if>
- <if test="makeTime != null">
- AND tpi.make_time = #{makeTime}
- </if>
- <if test="receivableId != null and receivableId != ''">
- AND tpi.receivable_id = #{receivableId}
- </if>
- <if test="flgValid != null">
- AND tpi.flg_valid = #{flgValid}
- </if>
- <if test="cpId != null">
- AND tpi.cp_id = #{cpId}
- </if>
- <if test="searchText !=null and searchText != ''">
- AND ( tpi.into_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or (exists (select 1 from dkic_b.t_psi_inbound_item tpii
- left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
- where
- tpi.into_id = tpii.into_id
- and tpii.flg_valid
- AND position(#{searchText} in tmgs.sku_model) > 0
- ))
- )
- </if>
- </where>
- </sql>
- <sql id="idsForeach">
- <!-- 根据主键intoId批量操作 -->
- WHERE into_id in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </sql>
- <!-- 查询表t_psi_inbound,(条件查询+分页)列表 tpi.sum_quantity, tpi.sum_amount,-->
- <select id="selectByCond" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tmo.org_name AS "orgName",
- tmp.sup_name AS "supplierName",
- tms.staff_name AS "staffName",
- tms.staff_name AS "makeStaffName",
- tmw.wh_name as "whName",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- makestaff.staff_name as "makeStaffName",
- sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "intoTypeName",
- sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "intoStatusName",
- tmd.data_value as into_reason_name,
- tmp.return_address,
- case when tpi.receivable_id is null then false
- when tmai.amt_handle = 0 then false
- else true end as "paymentFlag"
- FROM dkic_b.t_psi_inbound tpi
- <include refid="Join_Table"/>
- <include refid="Condition"/>
- order by tpi.make_time desc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_psi_inbound,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_psi_inbound tpi
- <include refid="Join_Table"/>
- <include refid="Condition"/>
- </select>
- <sql id="Join_Table">
- Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
- Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
- Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
- Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpi.make_staff
- LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
- LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
- Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
- left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
- left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
- left join dkic_b.t_mac_account_item tmai on tmai.item_id = tpi.receivable_id
- </sql>
- <!-- 根据主键查询表t_psi_inbound的一行数据 -->
- <select id="selectById" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tmo.org_name as "orgName"
- ,tms.staff_name as "staffName"
- ,tms1.staff_name as "makeStaffName"
- ,tmc.cus_name as "cusName"
- ,tmc.cus_phone as "cusPhone"
- ,tmc.cus_from as "cusFrom"
- ,tmp.sup_name as "supplierName"
- ,tmw.wh_name as "whName"
- ,tmd.data_value as into_reason_name
- ,case when tpi.receivable_id is null then false
- when tmai.amt_handle = 0 then false
- else true end as "paymentFlag"
- ,tpp.pickup_date
- FROM dkic_b.t_psi_inbound tpi
- Left join dkic_b.t_psi_purchase tpp on tpp.pur_id = tpi.from_id
- Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
- Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
- left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
- Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
- Left join dkic_b.t_mst_staff tms1 on tms1.staff_id = tpi.make_staff
- Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
- left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
- left join dkic_b.t_mac_account_item tmai on tmai.item_id = tpi.receivable_id
- WHERE tpi.into_id = #{id}::uuid
- </select>
- <!-- 根据主键锁定表t_psi_inbound的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_b.t_psi_inbound
- WHERE into_id = #{id}::uuid
- for update
- </select>
- <!-- 根据主键锁定表t_psi_inbound的多行数据 -->
- <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_b.t_psi_inbound
- <include refid="idsForeach"/>
- for update
- </select>
- <insert id="insertBatch">
- insert into dkic_b.t_psi_inbound
- (
- <trim suffixOverrides=",">
- into_no,
- into_type,
- from_id,
- from_no,
- org_id,
- staff_id,
- cus_id,
- sup_id,
- into_status,
- intoing_qty,
- intoing_amt,
- into_qty,
- into_amt,
- return_qty,
- return_amt,
- into_date,
- remarks,
- annex_paths,
- make_staff,
- make_time,
- receivable_id,
- cp_id,
- op_app_code,
- wh_id,
- entry_reason,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.intoNo},
- #{item.intoType},
- #{item.fromId}::uuid,
- #{item.fromNo},
- #{item.orgId}::uuid,
- #{item.staffId}::uuid,
- #{item.cusId}::uuid,
- #{item.supId}::uuid,
- #{item.intoStatus},
- #{item.intoingQty},
- #{item.intoingAmt},
- #{item.intoQty},
- #{item.intoAmt},
- #{item.returnQty},
- #{item.returnAmt},
- #{item.intoDate},
- #{item.remarks},
- #{item.annexPaths},
- #{item.makeStaff}::uuid,
- #{item.makeTime},
- #{item.receivableId}::uuid,
- #{item.cpId},
- #{item.opAppCode},
- #{item.whId},
- #{item.intoReason}::uuid,
- </trim>
- )
- </foreach>
- </insert>
- <sql id="Base_Column_List_Item_Response_Join">
- tpii
- .
- item_id
- AS list_item_id,
- tpii.item_id AS list_into_item_Id,
- tpii.into_id AS list_into_id,
- tpi.into_no AS list_into_no,
- tpii.into_type AS list_into_type,
- tpii.from_id AS list_from_id,
- tpii.from_item_id AS list_from_item_id,
- tpii.item_index AS list_item_index,
- tpii.sku_id AS list_sku_id,
- tpii.price_into AS list_price_into,
- tpii.non_std_code AS list_non_std_code,
- tpii.into_status AS list_into_status,
- sys.f_remove_zero(tpii.intoing_qty) AS list_intoing_qty,
- tpii.intoing_amt AS list_intoing_amt,
- sys.f_remove_zero(tpii.into_qty) AS list_into_qty,
- tpii.into_amt AS list_into_amt,
- sys.f_remove_zero(tpii.return_qty) AS list_return_qty,
- tpii.return_amt AS list_return_amt,
- tpii.remarks AS list_remarks,
- tpii.inv_id AS list_inv_id,
- tpii.cost_price AS list_cost_price,
- tpii.cost_amt AS list_cost_amt,
- sys.f_remove_zero(tpii.out_qty) AS list_out_qty,
- sys.f_remove_zero(tpii.inv_qty) AS list_inv_qty,
- tpii.flg_valid AS list_flg_valids,
- tpii.cp_id AS list_cp_id,
- tmgs.sku_code AS list_sku_code,
- tmgs.sku_name AS list_sku_name,
- tmgs.sku_model AS list_sku_model,
- tmgb.short_name AS list_short_name,
- tmgs.price_purchase AS list_price_purchase,
- tmgs.sku_images AS list_sku_images,
- sys.f_remove_zero( tpii.into_qty - tpii.return_qty) AS list_reject_qty,
- -- tpit.usable_qty AS list_usable_qty,
- -- tpit.inv_qty AS list_inv_qty,
- -- tpit.outing_qty AS list_outing_qty
- -- ,
- tmgs.price_standard AS list_price_std,
- i.inv_id as list_inv_id,
- i.wh_id as list_wh_id,
- i.inv_qty as list_inv_qty,
- i.usable_qty as list_usable_qty,
- i.wh_name as list_wh_name
- </sql>
- <!-- 查询表t_psi_inbound,(条件查询+分页)列表 -->
- <select id="selectInboundAndItem" resultMap="BaseResultMapItemResponse">
- SELECT
- <include refid="Base_Column_List_Item_Response"/>,
- <include refid="Base_Column_List_Item_Response_Join"/>
- FROM dkic_b.t_psi_inbound tpi
- left join dkic_b.t_psi_inbound_item tpii on tpi.into_id = tpii.into_id and ( tpii.into_qty - tpii.return_qty) > 0
- left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpii.wh_id
- inner join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
- left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
- left join(SELECT T.*
- FROM (select tpi.inv_id,
- tpi.wh_id,
- tpi.inv_qty,
- tpi.usable_qty,
- tpi.sku_id,
- tpi.non_std_code,
- tpi.cp_id,
- tmw.wh_name,
- rank()
- over (partition by tpi.cp_id,tpi.sku_id,tpi.non_std_code order by tpi.inv_id) as RK
- from dkic_b.t_psi_inventory as tpi
- left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id) T
- WHERE T.RK = 1) as i
- on i.sku_id = tpii.sku_id and i.non_std_code = tpii.non_std_code and i.cp_id = tpii.cp_id
- <include refid="ConditionIsSup"/>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_psi_inbound,(条件查询)个数 -->
- <select id="selectInboundAndItemCountByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_psi_inbound tpi
- left join dkic_b.t_psi_inbound_item tpii on tpi.into_id = tpii.into_id
- left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpii.wh_id
- inner join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
- <include refid="ConditionIsSup"/>
- </select>
- <update id="updateAmount" parameterType="com.dk.mdm.model.pojo.ivt.InboundItem">
- update dkic_b.t_psi_inbound
- <set>
- <if test="returnQty!= null">
- return_qty= #{returnQty},
- </if>
- <if test="returnAmt!= null">
- return_amt = #{returnAmt},
- </if>
- </set>
- where into_id = #{intoId}::uuid
- </update>
- <!-- 根据id查询带出销售退货单数据(采购退货入库办理用)-->
- <select id="selectMessageByOtherQuery" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tmo.org_name as "orgName"
- ,tms.staff_name as "staffName"
- ,tmc.cus_code
- ,tmc.cus_name as "cusName"
- ,tmc.cus_phone as "cusPhone"
- ,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_inbound tpi
- Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
- Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
- left join dkic_b.t_mst_customer tmc on tpi.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="intoId != null and intoId != ''">
- AND tpi.into_id = #{intoId}::uuid
- </if>
- <if test="intoStatus != null and intoStatus != ''">
- AND tpi.into_status = #{intoStatus}
- </if>
- <if test="fromId != null and fromId != ''">
- AND tpi.from_id = #{fromId}::uuid
- </if>
- </where>
- </select>
- <!-- 入库办理显示字段 -->
- <sql id="Base_Column_List_Response_Into">
- tpi.into_id,
- tpi.into_no,
- tpi.into_type,
- tpi.from_id,
- tpi.from_no,
- tpi.org_id,
- tpi.staff_id,
- tpi.cus_id,
- tpi.sup_id,
- tpi.into_status,
- sys.f_remove_zero(tpi.intoing_qty) as intoing_qty,
- tpi.intoing_amt,
- sys.f_remove_zero(tpi.into_qty) as into_qty,
- tpi.into_amt,
- sys.f_remove_zero(tpi.return_qty) as return_qty,
- tpi.return_amt,
- tpi.into_date,
- tpi.remarks,
- tpi.annex_paths,
- tpi.make_staff,
- tpi.make_time,
- tpi.wh_id,
- tpi.into_reason,
- tpi.flg_valid,
- tpi.flg_auto_handle,
- tpi.op_update_time
- </sql>
- <sql id="Base_Column_List_Response_Out">
- tpo.out_id as into_id,
- tpo.out_no as into_no,
- tpo.out_type as into_type,
- tpo.from_id,
- tpo.from_no,
- tpo.org_id,
- tpo.staff_id,
- tpo.cus_id,
- tpo.sup_id,
- tpo.out_status,
- sys.f_remove_zero(tpo.outing_qty) as intoing_qty,
- tpo.outing_amt as intoing_amt,
- sys.f_remove_zero(tpo.out_qty) as into_qty,
- tpo.out_amt as into_amt,
- sys.f_remove_zero(tpo.return_qty) as return_qty,
- tpo.return_amt,
- tpo.out_date as into_date,
- tpo.remarks,
- tpo.annex_paths,
- tpo.make_staff,
- tpo.make_time,
- null as wh_id,
- tpo.out_reason as into_reason,
- tpo.flg_valid,
- tpo.flg_auto_handle,
- tpo.op_update_time
- </sql>
- <!-- 条件查询 web端入库办理用,-->
- <select id="selectInbound" resultMap="BaseResultMapResponse">
- select * from (
- SELECT
- <include refid="Base_Column_List_Response_Into"/>,
- tmo.org_name AS "orgName",
- tmp.sup_name AS "supplierName",
- tms.staff_name AS "staffName",
- tms.staff_name AS "makeStaffName",
- tmw.wh_name as "whName",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- tmc.address_full,
- makestaff.staff_name as "makeStaffName",
- sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "intoTypeName",
- sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "intoStatusName",
- tmd.data_value as into_reason_name
- FROM dkic_b.t_psi_inbound tpi
- <include refid="Select_Inbound_Join_Table_Into"/>
- <where>
- AND tpi.cp_id = #{cpId}
- AND tpi.into_type != '入库类型-外协入库'
- <if test="intoTypes != null and intoTypes.size()>0">
- AND tpi.into_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
- </if>
- <if test="intoTypes == null || intoTypes.size()==0">
- AND (tpi.into_type = '入库类型-其他入库'
- or tpi.into_type = '入库类型-采购入库' or tpi.into_type = '入库类型-期初入库')
- </if>
- <if test=" intoStatus != null and intoStatus != '' ">
- AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
- </if>
- <if test="makeTimeStart != null and makeTimeEnd != null">
- AND tpi.make_time >= #{makeTimeStart}::timestamp with time zone
- AND tpi.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="intoNo != null and intoNo != ''">
- AND tpi.into_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
- </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="whName != null and whName != ''">
- AND tmw.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
- </if>
- <if test="supId != null and supId != ''">
- AND tpi.sup_id = #{supId}::uuid
- </if>
- <if test="orgIdList != null and orgIdList.size() > 0">
- AND tpi.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="staffIdList != null and staffIdList.size() > 0">
- AND tpi.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="flgValidList != null and flgValidList.size()>0">
- AND tpi.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
- </if>
- <if test="searchText !=null and searchText != ''">
- AND (
- tpi.into_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- )
- </if>
- </where>
- union all
- select
- <include refid="Base_Column_List_Response_Out"/>,
- tmo.org_name AS "orgName",
- tmp.sup_name AS "supplierName",
- tms.staff_name AS "staffName",
- tms.staff_name AS "makeStaffName",
- null as "whName",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- tmc.address_full,
- makestaff.staff_name as "makeStaffName",
- sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "intoTypeName",
- sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "intoStatusName",
- tmd.data_value as into_reason_name
- from dkic_b.t_psi_outbound tpo
- <include refid="Select_Inbound_Join_Table_Out"/>
- <where>
- AND tpo.cp_id = #{cpId}
- <if test="intoTypes != null and intoTypes.size()>0">
- AND tpo.out_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
- </if>
- <if test="intoTypes == null || intoTypes.size()==0">
- AND tpo.out_type = '出库类型-销退回库'
- </if>
- <if test="outStatus != null and outStatus != '' ">
- AND tpo.out_status LIKE concat('%',my_ex.likequery(#{outStatus}),'%')
- </if>
- <if test="makeTimeStart != null and makeTimeEnd != null">
- AND tpo.make_time >= #{makeTimeStart}::timestamp with time zone
- AND tpo.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="intoNo != null and intoNo != ''">
- AND tpo.out_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
- </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="supId != null and supId != ''">
- AND tpo.sup_id = #{supId}::uuid
- </if>
- <if test="orgIdList != null and orgIdList.size() > 0">
- AND tpo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="staffIdList != null and staffIdList.size() > 0">
- AND tpo.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="flgValidList != null and flgValidList.size()>0">
- AND tpo.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
- </if>
- <if test="searchText !=null and searchText != ''">
- AND (
- tpo.out_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- )
- </if>
- </where>
- ) tt order by tt.op_update_time desc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 条件查询 web端入库办理用个数 -->
- <select id="selectInboundCond" resultType="Long">
- SELECT
- count(1) from (
- SELECT
- <include refid="Base_Column_List_Response_Into"/>,
- tmo.org_name AS "orgName",
- tmp.sup_name AS "supplierName",
- tms.staff_name AS "staffName",
- tms.staff_name AS "makeStaffName",
- tmw.wh_name as "whName",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- makestaff.staff_name as "makeStaffName",
- sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "intoTypeName",
- sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "intoStatusName",
- tmd.data_value as into_reason_name
- FROM dkic_b.t_psi_inbound tpi
- <include refid="Select_Inbound_Join_Table_Into"/>
- <where>
- AND tpi.cp_id = #{cpId}
- <if test="intoTypes != null and intoTypes.size()>0">
- AND tpi.into_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
- </if>
- <if test="intoTypes == null || intoTypes.size()==0">
- AND (tpi.into_type = '入库类型-其他入库'
- or tpi.into_type = '入库类型-采购入库'or tpi.into_type = '入库类型-期初入库')
- </if>
- <if test=" intoStatus != null and intoStatus != '' ">
- AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
- </if>
- <if test="makeTimeStart != null and makeTimeEnd != null">
- AND tpi.make_time >= #{makeTimeStart}::timestamp with time zone
- AND tpi.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="intoNo != null and intoNo != ''">
- AND tpi.into_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
- </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="supId != null and supId != ''">
- AND tpi.sup_id = #{supId}::uuid
- </if>
- <if test="orgIdList != null and orgIdList.size() > 0">
- AND tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="staffIdList != null and staffIdList.size() > 0">
- AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="flgValidList != null and flgValidList.size()>0">
- AND tpi.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
- </if>
- </where>
- union all
- select
- <include refid="Base_Column_List_Response_Out"/>,
- tmo.org_name AS "orgName",
- tmp.sup_name AS "supplierName",
- tms.staff_name AS "staffName",
- tms.staff_name AS "makeStaffName",
- null as "whName",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- makestaff.staff_name as "makeStaffName",
- sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "intoTypeName",
- sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "intoStatusName",
- tmd.data_value as into_reason_name
- from dkic_b.t_psi_outbound tpo
- <include refid="Select_Inbound_Join_Table_Out"/>
- <where>
- AND tpo.cp_id = #{cpId}
- <if test="intoTypes != null and intoTypes.size()>0">
- AND tpo.out_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
- </if>
- <if test="intoTypes == null || intoTypes.size()==0">
- AND tpo.out_type = '出库类型-销退回库'
- </if>
- <if test="outStatus != null and outStatus != '' ">
- AND tpo.out_status LIKE concat('%',my_ex.likequery(#{outStatus}),'%')
- </if>
- <if test="makeTimeStart != null and makeTimeEnd != null">
- AND tpo.make_time >= #{makeTimeStart}::timestamp with time zone
- AND tpo.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="intoNo != null and intoNo != ''">
- AND tpo.out_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
- </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="supId != null and supId != ''">
- AND tpo.sup_id = #{supId}::uuid
- </if>
- <if test="orgIdList != null and orgIdList.size() > 0">
- AND tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="staffIdList != null and staffIdList.size() > 0">
- AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="flgValidList != null and flgValidList.size()>0">
- AND tpo.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
- </if>
- </where>
- ) tt
- </select>
- <!--入库办理显示入库关联表-->
- <sql id="Select_Inbound_Join_Table_Into">
- Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
- Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
- Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
- Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpi.make_staff
- LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
- LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
- Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
- left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
- left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
- </sql>
- <!--入库办理显示出库关联表-->
- <sql id="Select_Inbound_Join_Table_Out">
- Left join dkic_b.t_mst_org tmo on tmo.org_id = tpo.org_id
- Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpo.sup_id
- Left join dkic_b.t_mst_staff tms on tms.staff_id = tpo.staff_id
- Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpo.make_staff
- LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpo.out_status
- LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpo.out_type
- left join dkic_b.t_mst_customer tmc on tpo.cus_id = tmc.cus_id
- left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpo.out_reason
- </sql>
- <update id="updateIntoStatus" parameterType="com.dk.mdm.model.pojo.ivt.InboundItem">
- update dkic_b.t_psi_inbound
- <set>
- <if test="intoStatus!= null">
- into_status= #{intoStatus},
- </if>
- </set>
- where into_id = #{intoId}::uuid
- </update>
- <!-- 采购退货用-->
- <resultMap id="BaseResultMapInboundReturnResponse" type="com.dk.mdm.model.response.ivt.InboundResponse">
- <id column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
- <result column="into_no" property="intoNo"/>
- <result column="into_type" property="intoType"/>
- <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="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
- <result column="into_status" property="intoStatus"/>
- <result column="intoing_qty" property="intoingQty"/>
- <result column="intoing_amt" property="intoingAmt"/>
- <result column="into_qty" property="intoQty"/>
- <result column="into_amt" property="intoAmt"/>
- <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
- <result column="return_qty" property="returnQty"/>
- <result column="return_amt" property="returnAmt"/>
- <result column="into_date" property="intoDate" 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="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <result column="sup_name" property="supName"/>
- <result column="into_reason" property="intoReason" typeHandler="UuidTypeHandler"/>
- <result column="into_reason_name" property="intoReasonName" />
- <result column="org_name" property="orgName" />
- <result column="staff_name" property="staffName" />
- <result column="contact_phone" property="contactPhone" />
- <result column="contact_name" property="contactName" />
- <result column="channel_name" property="channelName" />
- <result column="cus_from_name" property="cusFromName" />
- <result column="return_address" property="returnAddress" />
- <result column="purSumAmount" property="purSumAmount" />
- <result column="purReturnAmt" property="purReturnAmt" />
- </resultMap>
- <sql id="Join_Table_Return">
- Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
- Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
- Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
- Left join dkic_b.t_mst_staff tms1 on tms1.staff_id = tpi.make_staff
- LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
- LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
- Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
- left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
- left join dkic_b.t_mac_account_item tmai on tmai.item_id = tpi.receivable_id
- </sql>
- <!-- 采购退货用-->
- <select id="selectByInboundReturnCond" resultMap="BaseResultMapInboundReturnResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tmo.org_name
- ,tmp.sup_name
- ,tms.staff_name
- ,tmw.wh_name
- ,tms1.staff_name as make_staff_name
- ,sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS into_type_name
- ,sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS into_status_name
- ,tmd.data_value as into_reason_name
- ,tmp.return_address
- ,tmp.contact_name
- ,tmp.contact_phone
- ,case when tpi.receivable_id is null then false
- when tmai.amt_handle = 0 then false
- else true end as "paymentFlag"
- FROM dkic_b.t_psi_inbound tpi
- <include refid="Join_Table_Return"/>
- <include refid="Condition"/>
- ORDER BY tpi.op_create_time DESC
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--采购退货用 查询表t_psi_inbound,(条件查询)个数 -->
- <select id="countByInboundReturnCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_psi_inbound tpi
- <include refid="Join_Table_Return"/>
- <include refid="Condition"/>
- </select>
- <!-- 查看来源单据,总单加明细 采购退货用-->
- <select id="selectInboundReturnById" resultMap="BaseResultMapInboundReturnResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tmo.org_name
- ,tms.staff_name as staff_name
- ,tms1.staff_name as make_staff_name
- ,tmp.sup_name
- ,tmw.wh_name
- ,tmd.data_value as into_reason_name
- ,tmp.return_address
- ,tmp.contact_name
- ,tmp.contact_phone
- ,case when tpi.receivable_id is null then false
- when tmai.amt_handle = 0 then false
- else true end as "paymentFlag"
- ,tpp.sum_amount AS "purSumAmount"
- ,tpp.return_amt AS "purReturnAmt"
- FROM dkic_b.t_psi_inbound tpi
- Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
- Left join dkic_b.t_psi_purchase tpp on tpp.pur_id = tpi.from_id
- Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
- Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
- Left join dkic_b.t_mst_staff tms1 on tms1.staff_id = tpi.make_staff
- Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
- left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
- left join dkic_b.t_mac_account_item tmai on tmai.item_id = tpi.receivable_id
- WHERE tpi.into_id = #{id}::uuid AND tpi.flg_valid = true
- </select>
- <!-- 根据来源id查询 -->
- <select id="selectByFromId" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- FROM dkic_b.t_psi_inbound tpi
- WHERE tpi.from_id = #{fromId}::uuid
- and tpi.flg_valid
- </select>
- <!--根据来源id删除单据-->
- <update id="deleteByFromId" >
- update dkic_b.t_psi_inbound
- <set>
- flg_valid = false
- </set>
- WHERE from_id = #{fromId}::uuid
- </update>
- </mapper>
|