| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921 |
- <?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.finance.mapper.fia.AssetMapper">
- <!-- **************************************** 数据库基础列映射 **************************************** -->
- <resultMap id="Pojo_ResultMap" type="com.dk.finance.model.pojo.fia.Asset">
- <id column="doc_id" property="docId"/>
- <result column="doc_no" property="docNo"/>
- <result column="kind_code" property="kindCode"/>
- <result column="status_invoice" property="statusInvoice"/>
- <result column="status_flow" property="statusFlow"/>
- <result column="org_id" property="orgId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="staff_id" property="staffId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="asset_name" property="assetName"/>
- <result column="asset_type_id" property="assetTypeId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="calc_method" property="calcMethod"/>
- <result column="summary" property="summary"/>
- <result column="sum_amt_asset" property="sumAmtAsset"/>
- <result column="sum_amt_net_worth" property="sumAmtNetWorth"/>
- <result column="sum_amt_net_salvage" property="sumAmtNetSalvage"/>
- <result column="total_calc_no" property="totalCalcNo"/>
- <result column="sum_amt_calc_month" property="sumAmtCalcMonth"/>
- <result column="acc_calc_begin" property="accCalcBegin" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="acc_calc_end" property="accCalcEnd" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="happen_calc_no" property="happenCalcNo"/>
- <result column="sum_amt_happen_calc" property="sumAmtHappenCalc"/>
- <result column="sum_amt_loss" property="sumAmtLoss"/>
- <result column="sum_amt_clear" property="sumAmtClear"/>
- <result column="asset_subject_id" property="assetSubjectId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="calc_subject_id" property="calcSubjectId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="tax_rate" property="taxRate"/>
- <result column="sum_amt_tax" property="sumAmtTax"/>
- <result column="sum_amt_should" property="sumAmtShould"/>
- <result column="mac_id" property="macId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="sum_amt_cash" property="sumAmtCash"/>
- <result column="sum_amt_total_cash" property="sumAmtTotalCash"/>
- <result column="sum_amt_charge" property="sumAmtCharge"/>
- <result column="obj_type" property="objType"/>
- <result column="obj_id" property="objId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="flg_init" property="flgInit"/>
- <result column="external_no" property="externalNo"/>
- <result column="external_system" property="externalSystem"/>
- <result column="print_times" property="printTimes"/>
- <result column="apv_submit_id" property="apvSubmitId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="apv_staff_ids" property="apvStaffIds" typeHandler="com.dk.common.infrastructure.handler.UuidListTypeHandler"/>
- <result column="apv_result_time" property="apvResultTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="annex_paths" property="annexPaths" typeHandler="com.dk.common.infrastructure.handler.JsonTypeHandler"/>
- <result column="other_annex_paths" property="otherAnnexPaths" typeHandler="com.dk.common.infrastructure.handler.JsonTypeHandler"/>
- <result column="remarks" property="remarks"/>
- <result column="acc_date" property="accDate" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="make_staff" property="makeStaff" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="make_time" property="makeTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="own_cp_id" property="ownCpId"/>
- <result column="ctr_cp_id" property="ctrCpId"/>
- <result column="op_create_time" property="opCreateTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="op_update_staff_id" property="opUpdateStaffId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="due_date" property="dueDate" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- </resultMap>
- <!-- **************************************** 查询映射结果 **************************************** -->
- <resultMap id="Response_ResultMap" type="com.dk.finance.model.response.fia.AssetResponse">
- <!-- **************************************** 当前表映射 **************************************** -->
- <id column="doc_id" property="docId"/>
- <result column="doc_no" property="docNo"/>
- <result column="kind_code" property="kindCode"/>
- <result column="status_invoice" property="statusInvoice"/>
- <result column="status_flow" property="statusFlow"/>
- <result column="org_id" property="orgId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="staff_id" property="staffId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="asset_name" property="assetName"/>
- <result column="asset_type_id" property="assetTypeId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="calc_method" property="calcMethod"/>
- <result column="summary" property="summary"/>
- <result column="sum_amt_asset" property="sumAmtAsset"/>
- <result column="sum_amt_net_worth" property="sumAmtNetWorth"/>
- <result column="sum_amt_net_salvage" property="sumAmtNetSalvage"/>
- <result column="total_calc_no" property="totalCalcNo"/>
- <result column="sum_amt_calc_month" property="sumAmtCalcMonth"/>
- <result column="acc_calc_begin" property="accCalcBegin" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="acc_calc_end" property="accCalcEnd" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="happen_calc_no" property="happenCalcNo"/>
- <result column="sum_amt_happen_calc" property="sumAmtHappenCalc"/>
- <result column="sum_amt_loss" property="sumAmtLoss"/>
- <result column="sum_amt_clear" property="sumAmtClear"/>
- <result column="asset_subject_id" property="assetSubjectId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="calc_subject_id" property="calcSubjectId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="tax_rate" property="taxRate"/>
- <result column="sum_amt_tax" property="sumAmtTax"/>
- <result column="sum_amt_total_cash" property="sumAmtTotalCash"/>
- <result column="sum_amt_should" property="sumAmtShould"/>
- <result column="mac_id" property="macId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="sum_amt_cash" property="sumAmtCash"/>
- <result column="sum_amt_charge" property="sumAmtCharge"/>
- <result column="obj_type" property="objType"/>
- <result column="obj_id" property="objId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="flg_init" property="flgInit"/>
- <result column="external_no" property="externalNo"/>
- <result column="external_system" property="externalSystem"/>
- <result column="print_times" property="printTimes"/>
- <result column="apv_submit_id" property="apvSubmitId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="apv_staff_ids" property="apvStaffIds" typeHandler="com.dk.common.infrastructure.handler.UuidListTypeHandler"/>
- <result column="apv_result_time" property="apvResultTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="annex_paths" property="annexPaths" typeHandler="com.dk.common.infrastructure.handler.JsonTypeHandler"/>
- <result column="other_annex_paths" property="otherAnnexPaths" typeHandler="com.dk.common.infrastructure.handler.JsonTypeHandler"/>
- <result column="remarks" property="remarks"/>
- <result column="acc_date" property="accDate" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="make_staff" property="makeStaff" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="make_time" property="makeTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="own_cp_id" property="ownCpId"/>
- <result column="ctr_cp_id" property="ctrCpId"/>
- <result column="op_create_time" property="opCreateTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <result column="op_update_staff_id" property="opUpdateStaffId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
- <result column="due_date" property="dueDate" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
- <!-- **************************************** 关联表映射 **************************************** -->
- <result column="op_update_staff_name" property="opUpdateStaffName"/>
- <result column="status_invoice_name" property="statusInvoiceName"/>
- <result column="status_flow_name" property="statusFlowName"/>
- <result column="org_name" property="orgName"/>
- <result column="make_staff_name" property="makeStaffName"/>
- <result column="staff_name" property="staffName"/>
- <result column="type_name" property="typeName"/>
- <result column="assetTaxRate" property="assetTaxRate"/>
- <result column="calc_method_name" property="calcMethodName"/>
- <result column="ass_sub_name" property="assSubName"/>
- <result column="loss_sub_name" property="lossSubName"/>
- <result column="calc_sub_name" property="calcSubName"/>
- <result column="clear_sub_name" property="clearSubName"/>
- <result column="un_happen_calc_no" property="unHappenCalcNo"/>
- <result column="mac_name" property="macName"/>
- <result column="pay_status" property="payStatus"/>
- <result column="un_sum_amt_total_cash" property="unSumAmtTotalCash"/>
- <result column="obj_name" property="objName"/>
- </resultMap>
- <!-- **************************************** 当前表列 **************************************** -->
- <sql id="Base_Columns">
- t.doc_id,
- t.doc_no,
- t.kind_code,
- t.status_invoice,
- t.status_flow,
- t.org_id,
- t.staff_id,
- t.asset_name,
- t.asset_type_id,
- t.calc_method,
- t.summary,
- t.sum_amt_asset,
- t.sum_amt_net_worth,
- t.sum_amt_net_salvage,
- t.total_calc_no,
- t.sum_amt_calc_month,
- t.acc_calc_begin,
- t.acc_calc_end,
- t.happen_calc_no,
- t.sum_amt_happen_calc,
- t.sum_amt_loss,
- t.sum_amt_clear,
- t.asset_subject_id,
- t.calc_subject_id,
- t.tax_rate,
- t.sum_amt_tax,
- t.sum_amt_should,
- t.mac_id,
- t.sum_amt_cash,
- t.sum_amt_charge,
- t.obj_type,
- t.obj_id,
- t.flg_init,
- t.external_no,
- t.external_system,
- t.print_times,
- t.apv_submit_id,
- t.apv_staff_ids,
- t.apv_result_time,
- t.annex_paths,
- t.other_annex_paths,
- t.remarks,
- t.acc_date,
- t.make_staff,
- t.make_time,
- t.flg_valid,
- t.own_cp_id,
- t.ctr_cp_id,
- t.op_create_time,
- t.op_update_time,
- t.op_update_staff_id,
- t.sum_amt_total_cash,
- t.sum_amt_asset - t.sum_amt_total_cash as un_sum_amt_total_cash,
- t.total_calc_no - happen_calc_no as un_happen_calc_no,
- case when t.sum_amt_should > t.sum_amt_total_cash and t.sum_amt_total_cash>0 then '部分付款'
- when t.sum_amt_total_cash = 0 then '未付款'
- when t.sum_amt_should = t.sum_amt_total_cash then '付款完成'
- end as pay_status,
- t.due_date,
- </sql>
- <!-- **************************************** 当前表查询条件 **************************************** -->
- <sql id="Base_Conditions">
- <if test="docNo != null and docNo != ''">
- AND t.doc_no LIKE concat('%',pgex.likequery(#{docNo}),'%')
- </if>
- <if test="kindCode != null and kindCode != ''">
- AND t.kind_code LIKE concat('%',pgex.likequery(#{kindCode}),'%')
- </if>
- <if test="statusInvoice != null and statusInvoice != ''">
- AND t.status_invoice LIKE concat('%',pgex.likequery(#{statusInvoice}),'%')
- </if>
- <if test="statusFlow != null and statusFlow != ''">
- AND t.status_flow LIKE concat('%',pgex.likequery(#{statusFlow}),'%')
- </if>
- <if test="orgId != null">
- AND t.org_id = #{orgId}::uuid
- </if>
- <if test="staffId != null">
- AND t.staff_id = #{staffId}::uuid
- </if>
- <if test="assetName != null and assetName != ''">
- AND t.asset_name LIKE concat('%',pgex.likequery(#{assetName}),'%')
- </if>
- <if test="assetTypeId != null">
- AND t.asset_type_id = #{assetTypeId}::uuid
- </if>
- <if test="calcMethod != null and calcMethod != ''">
- AND t.calc_method LIKE concat('%',pgex.likequery(#{calcMethod}),'%')
- </if>
- <if test="summary != null and summary != ''">
- AND t.summary LIKE concat('%',pgex.likequery(#{summary}),'%')
- </if>
- <if test="sumAmtAsset != null">
- AND t.sum_amt_asset = #{sumAmtAsset}
- </if>
- <if test="sumAmtNetWorth != null">
- AND t.sum_amt_net_worth = #{sumAmtNetWorth}
- </if>
- <if test="sumAmtNetSalvage != null">
- AND t.sum_amt_net_salvage = #{sumAmtNetSalvage}
- </if>
- <if test="totalCalcNo != null">
- AND t.total_calc_no = #{totalCalcNo}
- </if>
- <if test="sumAmtCalcMonth != null">
- AND t.sum_amt_calc_month = #{sumAmtCalcMonth}
- </if>
- <if test="happenCalcNo != null">
- AND t.happen_calc_no = #{happenCalcNo}
- </if>
- <if test="sumAmtHappenCalc != null">
- AND t.sum_amt_happen_calc = #{sumAmtHappenCalc}
- </if>
- <if test="sumAmtLoss != null">
- AND t.sum_amt_loss = #{sumAmtLoss}
- </if>
- <if test="sumAmtClear != null">
- AND t.sum_amt_clear = #{sumAmtClear}
- </if>
- <if test="assetSubjectId != null">
- AND t.asset_subject_id = #{assetSubjectId}::uuid
- </if>
- <if test="calcSubjectId != null">
- AND t.calc_subject_id = #{calcSubjectId}::uuid
- </if>
- <if test="taxRate != null">
- AND t.tax_rate = #{taxRate}
- </if>
- <if test="sumAmtTax != null">
- AND t.sum_amt_tax = #{sumAmtTax}
- </if>
- <if test="sumAmtShould != null">
- AND t.sum_amt_should = #{sumAmtShould}
- </if>
- <if test="macId != null">
- AND t.mac_id = #{macId}::uuid
- </if>
- <if test="sumAmtCash != null">
- AND t.sum_amt_cash = #{sumAmtCash}
- </if>
- <if test="sumAmtCharge != null">
- AND t.sum_amt_charge = #{sumAmtCharge}
- </if>
- <if test="objType != null">
- AND t.obj_type = #{objType}
- </if>
- <if test="objId != null">
- AND t.obj_id = #{objId}::uuid
- </if>
- <if test="flgInit != null">
- AND t.flg_init = #{flgInit}
- </if>
- <if test="externalNo != null and externalNo != ''">
- AND t.external_no LIKE concat('%',pgex.likequery(#{externalNo}),'%')
- </if>
- <if test="externalSystem != null and externalSystem != ''">
- AND t.external_system LIKE concat('%',pgex.likequery(#{externalSystem}),'%')
- </if>
- <if test="printTimes != null">
- AND t.print_times = #{printTimes}
- </if>
- <if test="apvSubmitId != null">
- AND t.apv_submit_id = #{apvSubmitId}::uuid
- </if>
- <if test="apvStaffIds != null">
- AND t.apv_staff_ids = #{apvStaffIds}
- </if>
- <if test="annexPaths != null">
- AND t.annex_paths = #{annexPaths}
- </if>
- <if test="otherAnnexPaths != null">
- AND t.other_annex_paths = #{otherAnnexPaths}
- </if>
- <if test="remarks != null and remarks != ''">
- AND t.remarks LIKE concat('%',pgex.likequery(#{remarks}),'%')
- </if>
- <if test="makeStaff != null">
- AND t.make_staff = #{makeStaff}::uuid
- </if>
- <if test="flgValid != null">
- AND t.flg_valid = #{flgValid}
- </if>
- <if test="ownCpId != null">
- AND t.own_cp_id = #{ownCpId}
- </if>
- <if test="ctrCpId != null">
- AND t.ctr_cp_id = #{ctrCpId}
- </if>
- <if test="opUpdateStaffId != null">
- AND t.op_update_staff_id = #{opUpdateStaffId}::uuid
- </if>
- <!-- **************************************** 自动生成其他查询条件 **************************************** -->
-
- <if test="accCalcBeginStart != null">
- AND t.acc_calc_begin >= #{accCalcBeginStart}
- </if>
- <if test="accCalcBeginEnd != null">
- AND t.acc_calc_begin <= #{accCalcBeginEnd}
- </if>
- <if test="accCalcEndStart != null">
- AND t.acc_calc_end >= #{accCalcEndStart}
- </if>
- <if test="accCalcEndEnd != null">
- AND t.acc_calc_end <= #{accCalcEndEnd}
- </if>
- <if test="apvResultTimeStart != null">
- AND t.apv_result_time >= #{apvResultTimeStart}::timestamp with time zone
- </if>
- <if test="apvResultTimeEnd != null">
- AND t.apv_result_time < #{apvResultTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="accDateStart != null">
- AND t.acc_date >= #{accDateStart}
- </if>
- <if test="accDateEnd != null">
- AND t.acc_date <= #{accDateEnd}
- </if>
- <if test="makeTimeStart != null">
- AND t.make_time >= #{makeTimeStart}::timestamp with time zone
- </if>
- <if test="makeTimeEnd != null">
- 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>
- <if test="ownCpIdList != null and ownCpIdList.size()>0">
- AND t.own_cp_id = any(#{ownCpIdList, typeHandler= BigIntListTypeHandler})
- </if>
- <if test="opCreateTimeStart != null">
- AND t.op_create_time >= #{opCreateTimeStart}::timestamp with time zone
- </if>
- <if test="opCreateTimeEnd != null">
- AND t.op_create_time < #{opCreateTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="opUpdateTimeStart != null">
- AND t.op_update_time >= #{opUpdateTimeStart}::timestamp with time zone
- </if>
- <if test="opUpdateTimeEnd != null">
- AND t.op_update_time < #{opUpdateTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="staffIdList != null and staffIdList.size()>0">
- AND t.staff_id = any(#{staffIdList, typeHandler= UUidListTypeHandler})
- </if>
- <if test="orgIdList != null and orgIdList.size()>0">
- AND t.org_id = any(#{orgIdList, typeHandler= UUidListTypeHandler})
- </if>
- <if test="statusInvoiceList!=null and statusInvoiceList.size()>0">
- AND t.status_invoice = any(#{statusInvoiceList, typeHandler= StringListTypeHandler})
- </if>
- <if test="sumAmtCashFlag!=null and sumAmtCashFlag != ''">
- AND t.sum_amt_cash != t.sum_amt_should
- </if>
- <if test="itemOrgIdList != null and itemOrgIdList.size()>0
- or calcSubjectList != null and calcSubjectList.size()>0">
- AND EXISTS(
- SELECT
- 1
- FROM
- dkscu_b.t_fia_asset_item AS item
- WHERE
- flg_valid
- AND item.doc_id = T.doc_id
- <if test="itemOrgIdList != null and itemOrgIdList.size()>0">
- AND item.org_id = any(#{itemOrgIdList, typeHandler= UUidListTypeHandler})
- </if>
- <if test="calcSubjectList != null and calcSubjectList.size()>0">
- AND item.calc_subject_id = any(#{calcSubjectList, typeHandler= UUidListTypeHandler})
- </if>
- )
- </if>
- <if test="payStatusList != null and payStatusList.size()>0">
- AND (
- (1= any(#{payStatusList, typeHandler= BigIntListTypeHandler}) and t.sum_amt_cash = 0)
- or (2= any(#{payStatusList, typeHandler= BigIntListTypeHandler}) and t.sum_amt_cash = t.sum_amt_should)
- or (3= any(#{payStatusList, typeHandler= BigIntListTypeHandler}) and t.sum_amt_cash != t.sum_amt_should and t.sum_amt_cash >0)
- )
- </if>
- <if test="assetStatusList!=null and assetStatusList.size()>0">
- AND t.status_flow = any(#{assetStatusList, typeHandler= StringListTypeHandler})
- </if>
- </sql>
- <!-- **************************************** 关联表列 **************************************** -->
- <sql id="Join_Columns">
- update_staff.staff_name AS op_update_staff_name,
- org.org_name,
- mStaff.staff_name AS make_staff_name,
- myex.f_get_name_i18n(dks.kind_name_i18n,#{i18n}) as status_invoice_name,
- myex.f_get_name_i18n(dkf.kind_name_i18n,#{i18n}) as status_flow_name,
- staff.staff_name,
- assType.type_name,
- assType.tax_rate as "assetTaxRate",
- myex.f_get_name_i18n(dkm.kind_name_i18n,#{i18n}) as calc_method_name,
- assSub.subject_name AS ass_sub_name,
- lossSub.subject_name AS loss_sub_name,
- calcSub.subject_name AS calc_sub_name,
- clearSub.subject_name AS clear_sub_name,
- ma.mac_name,
- obj.obj_name,
- </sql>
- <!-- **************************************** 关联表 **************************************** -->
- <sql id="Join_Tables">
- LEFT JOIN dkscu_b.t_mst_staff AS update_staff ON t.op_update_staff_id = update_staff.staff_id
- LEFT JOIN dkscu_bs.t_data_kind dks on t.status_invoice = dks.kind_code
- LEFT JOIN dkscu_bs.t_data_kind dkf on t.status_flow = dkf.kind_code
- LEFT JOIN dkscu_b.t_mst_organization org ON t.org_id = org.org_id
- LEFT JOIN dkscu_b.t_mst_staff mStaff ON t.make_staff = mStaff.staff_id
- LEFT JOIN dkscu_b.t_mst_staff staff ON t.staff_id = staff.staff_id
- LEFT JOIN dkscu_bs.t_fia_asset_type assType ON t.asset_type_id =assType.type_id
- LEFT JOIN dkscu_bs.t_data_kind dkm on t.calc_method = dkm.kind_code
- LEFT JOIN dkscu_b.t_fnc_subject AS assSub ON assSub.subject_id = t.asset_subject_id
- LEFT JOIN dkscu_b.t_fnc_subject AS lossSub ON lossSub.subject_id = t.loss_subject_id
- LEFT JOIN dkscu_b.t_fnc_subject AS calcSub ON calcSub.subject_id = t.calc_subject_id
- LEFT JOIN dkscu_b.t_fnc_subject AS clearSub ON clearSub.subject_id = t.clear_subject_id
- LEFT JOIN dkscu_b.t_mst_money_account AS ma ON T.mac_id = ma.mac_id
- LEFT JOIN dkscu_b.t_mst_obj as obj ON t.obj_id = obj.obj_id
- </sql>
- <!-- **************************************** 关联表查询条件 **************************************** -->
- <sql id="Join_Conditions">
- </sql>
- <!-- 查询表t_fia_asset,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="Response_ResultMap">
- SELECT
- <trim suffixOverrides=",">
- <include refid="Base_Columns"/>
- <include refid="Join_Columns"/>
- </trim>
- FROM dkscu_b.t_fia_asset t
- <include refid="Join_Tables"/>
- <where>
- <include refid="Base_Conditions"/>
- <include refid="Join_Conditions"/>
- </where>
- order by t.make_time desc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_fia_asset,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkscu_b.t_fia_asset t
- <include refid="Join_Tables"/>
- <where>
- <include refid="Base_Conditions"/>
- <include refid="Join_Conditions"/>
- </where>
- </select>
- <!-- 根据主键查询表t_fia_asset的一行数据 -->
- <select id="selectById" resultMap="Response_ResultMap">
- SELECT
- <trim suffixOverrides=",">
- <include refid="Base_Columns"/>
- <include refid="Join_Columns"/>
- </trim>
- FROM dkscu_b.t_fia_asset t
- <include refid="Join_Tables"/>
- WHERE t.doc_id = #{id}::uuid
- </select>
- <!-- 根据主键docId批量操作 -->
- <sql id="idList">
- WHERE t.doc_id in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}::uuid
- </foreach>
- </sql>
- <!-- 根据主键锁定表t_fia_asset的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="Pojo_ResultMap">
- SELECT
- <trim suffixOverrides=",">
- <include refid="Base_Columns"/>
- </trim>
- FROM dkscu_b.t_fia_asset t
- WHERE t.doc_id = #{id}::uuid
- for update
- </select>
- <!-- 根据主键锁定表t_fia_asset的多行数据 -->
- <select id="selectByIdsForUpdate" resultMap="Pojo_ResultMap">
- SELECT
- <trim suffixOverrides=",">
- <include refid="Base_Columns"/>
- </trim>
- FROM dkscu_b.t_fia_asset t
- <include refid="idList"/>
- for update
- </select>
- <!-- 批量新建 -->
- <insert id="insertBatch" useGeneratedKeys="true" keyProperty="docId">
- <include refid="insertBatchSql"/>
- </insert>
- <sql id="insertBatchSql">
- insert into dkscu_b.t_fia_asset
- (
- <trim suffixOverrides=",">
- doc_id,
- doc_no,
- kind_code,
- status_invoice,
- status_flow,
- org_id,
- staff_id,
- asset_name,
- asset_type_id,
- calc_method,
- summary,
- sum_amt_asset,
- sum_amt_net_worth,
- sum_amt_net_salvage,
- total_calc_no,
- sum_amt_calc_month,
- acc_calc_begin,
- acc_calc_end,
- happen_calc_no,
- sum_amt_happen_calc,
- sum_amt_loss,
- sum_amt_clear,
- asset_subject_id,
- calc_subject_id,
- tax_rate,
- sum_amt_tax,
- sum_amt_should,
- mac_id,
- sum_amt_cash,
- sum_amt_charge,
- obj_type,
- obj_id,
- flg_init,
- external_no,
- external_system,
- print_times,
- apv_submit_id,
- apv_staff_ids,
- apv_result_time,
- annex_paths,
- other_annex_paths,
- remarks,
- acc_date,
- make_staff,
- make_time,
- own_cp_id,
- ctr_cp_id,
- sum_amt_total_cash,
- due_date,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.docId}::uuid,
- #{item.docNo},
- #{item.kindCode},
- #{item.statusInvoice},
- #{item.statusFlow},
- #{item.orgId}::uuid,
- #{item.staffId}::uuid,
- #{item.assetName},
- #{item.assetTypeId}::uuid,
- #{item.calcMethod},
- #{item.summary},
- <choose>
- <when test="item.sumAmtAsset != null">
- #{item.sumAmtAsset},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtNetWorth != null">
- #{item.sumAmtNetWorth},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtNetSalvage != null">
- #{item.sumAmtNetSalvage},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.totalCalcNo != null">
- #{item.totalCalcNo},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtCalcMonth != null">
- #{item.sumAmtCalcMonth},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- #{item.accCalcBegin},
- #{item.accCalcEnd},
- <choose>
- <when test="item.happenCalcNo != null">
- #{item.happenCalcNo},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtHappenCalc != null">
- #{item.sumAmtHappenCalc},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtLoss != null">
- #{item.sumAmtLoss},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtClear != null">
- #{item.sumAmtClear},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- #{item.assetSubjectId}::uuid,
- #{item.calcSubjectId}::uuid,
- <choose>
- <when test="item.taxRate != null">
- #{item.taxRate},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtTax != null">
- #{item.sumAmtTax},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtShould != null">
- #{item.sumAmtShould},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- #{item.macId}::uuid,
- <choose>
- <when test="item.sumAmtCash != null">
- #{item.sumAmtCash},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.sumAmtCharge != null">
- #{item.sumAmtCharge},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- <choose>
- <when test="item.objType != null">
- #{item.objType},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- #{item.objId}::uuid,
- <choose>
- <when test="item.flgInit != null">
- #{item.flgInit},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- #{item.externalNo},
- #{item.externalSystem},
- <choose>
- <when test="item.printTimes != null">
- #{item.printTimes},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- #{item.apvSubmitId}::uuid,
- #{item.apvStaffIds,typeHandler=UuidListTypeHandler},
- #{item.apvResultTime},
- #{item.annexPaths,typeHandler=JsonTypeHandler},
- #{item.otherAnnexPaths,typeHandler=JsonTypeHandler},
- #{item.remarks},
- #{item.accDate},
- #{item.makeStaff}::uuid,
- <choose>
- <when test="item.makeTime != null">
- #{item.makeTime},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- #{item.ownCpId},
- #{item.ctrCpId},
- <choose>
- <when test="item.sumAmtTotalCash != null">
- #{item.sumAmtTotalCash},
- </when>
- <otherwise>
- DEFAULT,
- </otherwise>
- </choose>
- #{item.dueDate},
- </trim>
- )
- </foreach>
- </sql>
- <!-- 批量保存 - 有id则编辑无id则新建 -->
- <insert id="saveBatch" useGeneratedKeys="true" keyProperty="docId">
- <include refid="insertBatchSql"/>
- on conflict (doc_id) do update set
- <trim suffixOverrides=",">
- doc_no = excluded."doc_no",
- kind_code = excluded."kind_code",
- status_invoice = excluded."status_invoice",
- status_flow = excluded."status_flow",
- org_id = excluded."org_id",
- staff_id = excluded."staff_id",
- asset_name = excluded."asset_name",
- asset_type_id = excluded."asset_type_id",
- calc_method = excluded."calc_method",
- summary = excluded."summary",
- sum_amt_asset = excluded."sum_amt_asset",
- sum_amt_net_worth = excluded."sum_amt_net_worth",
- sum_amt_net_salvage = excluded."sum_amt_net_salvage",
- total_calc_no = excluded."total_calc_no",
- sum_amt_calc_month = excluded."sum_amt_calc_month",
- acc_calc_begin = excluded."acc_calc_begin",
- acc_calc_end = excluded."acc_calc_end",
- happen_calc_no = excluded."happen_calc_no",
- sum_amt_happen_calc = excluded."sum_amt_happen_calc",
- sum_amt_loss = excluded."sum_amt_loss",
- sum_amt_clear = excluded."sum_amt_clear",
- asset_subject_id = excluded."asset_subject_id",
- calc_subject_id = excluded."calc_subject_id",
- tax_rate = excluded."tax_rate",
- sum_amt_tax = excluded."sum_amt_tax",
- sum_amt_should = excluded."sum_amt_should",
- mac_id = excluded."mac_id",
- sum_amt_cash = excluded."sum_amt_cash",
- sum_amt_charge = excluded."sum_amt_charge",
- obj_type = excluded."obj_type",
- obj_id = excluded."obj_id",
- flg_init = excluded."flg_init",
- external_no = excluded."external_no",
- external_system = excluded."external_system",
- print_times = excluded."print_times",
- apv_submit_id = excluded."apv_submit_id",
- apv_staff_ids = excluded."apv_staff_ids",
- apv_result_time = excluded."apv_result_time",
- annex_paths = excluded."annex_paths",
- other_annex_paths = excluded."other_annex_paths",
- remarks = excluded."remarks",
- acc_date = excluded."acc_date",
- make_staff = excluded."make_staff",
- make_time = excluded."make_time",
- own_cp_id = excluded."own_cp_id",
- ctr_cp_id = excluded."ctr_cp_id",
- </trim>
- </insert>
- <!-- 校验名称是否重复 -->
- <select id="checkNameDuplicated" resultType="java.lang.Long">
- SELECT COUNT(doc_id)
- FROM dkscu_b.t_fia_asset
- WHERE
- own_cp_id = #{ownCpId}
- <!-- 通过判断id是否存在判断为新增操作还是修改操作 -->
- <if test="docId != null and docId != ''">
- AND doc_id != #{docId}::uuid
- </if>
- <if test="assetName != null and assetName != ''">
- AND asset_name = #{assetName}
- </if>
- </select>
- <!-- 查询资产类别 -->
- <select id="getAssetType" resultType="java.util.Map">
- SELECT
- fat.type_id ,
- fat.type_code
- FROM
- dkscu_bs.t_fia_asset_type as fat
- WHERE
- fat.type_name = #{typeName}
- </select>
- <!-- 查询经手人 -->
- <select id="getStaffByName" resultType="java.util.Map">
- SELECT
- staff_id,
- staff_name
- FROM
- dkscu_b.t_mst_staff staff
- WHERE
- flg_valid
- AND staff.own_cp_id = #{ownCpId}
- AND staff.staff_name = #{staffName}
- </select>
- <!-- 查询经手部门 -->
- <select id="getOrgByName" resultType="java.util.Map">
- SELECT
- org.org_id,
- org.org_name
- FROM
- dkscu_b.t_mst_organization org
- WHERE
- flg_valid
- AND org.org_name = #{orgName}
- AND org.own_cp_id = #{ownCpId}
- </select>
- <!-- 折旧方法 -->
- <select id="getCalcMethod" resultType="java.util.Map">
- SELECT
- kind_code
- FROM
- dkscu_bs.t_data_kind dk
- WHERE
- dk.flg_valid
- AND myex.f_get_name_i18n (dk.kind_name_i18n,#{i18n} ) = #{kindName}
- </select>
- <!-- 会计科目 -->
- <select id="getSubject" resultType="java.util.Map">
- SELECT
- sub.subject_id
- FROM
- dkscu_b.t_fnc_subject sub
- WHERE
- sub.flg_valid
- AND sub.subject_name =#{subjectName}
- AND sub.own_cp_id = #{ownCpId}
- </select>
- </mapper>
|