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, AND t.doc_no LIKE concat('%',pgex.likequery(#{docNo}),'%') AND t.kind_code LIKE concat('%',pgex.likequery(#{kindCode}),'%') AND t.status_invoice LIKE concat('%',pgex.likequery(#{statusInvoice}),'%') AND t.status_flow LIKE concat('%',pgex.likequery(#{statusFlow}),'%') AND t.org_id = #{orgId}::uuid AND t.staff_id = #{staffId}::uuid AND t.asset_name LIKE concat('%',pgex.likequery(#{assetName}),'%') AND t.asset_type_id = #{assetTypeId}::uuid AND t.calc_method LIKE concat('%',pgex.likequery(#{calcMethod}),'%') AND t.summary LIKE concat('%',pgex.likequery(#{summary}),'%') AND t.sum_amt_asset = #{sumAmtAsset} AND t.sum_amt_net_worth = #{sumAmtNetWorth} AND t.sum_amt_net_salvage = #{sumAmtNetSalvage} AND t.total_calc_no = #{totalCalcNo} AND t.sum_amt_calc_month = #{sumAmtCalcMonth} AND t.happen_calc_no = #{happenCalcNo} AND t.sum_amt_happen_calc = #{sumAmtHappenCalc} AND t.sum_amt_loss = #{sumAmtLoss} AND t.sum_amt_clear = #{sumAmtClear} AND t.asset_subject_id = #{assetSubjectId}::uuid AND t.calc_subject_id = #{calcSubjectId}::uuid AND t.tax_rate = #{taxRate} AND t.sum_amt_tax = #{sumAmtTax} AND t.sum_amt_should = #{sumAmtShould} AND t.mac_id = #{macId}::uuid AND t.sum_amt_cash = #{sumAmtCash} AND t.sum_amt_charge = #{sumAmtCharge} AND t.obj_type = #{objType} AND t.obj_id = #{objId}::uuid AND t.flg_init = #{flgInit} AND t.external_no LIKE concat('%',pgex.likequery(#{externalNo}),'%') AND t.external_system LIKE concat('%',pgex.likequery(#{externalSystem}),'%') AND t.print_times = #{printTimes} AND t.apv_submit_id = #{apvSubmitId}::uuid AND t.apv_staff_ids = #{apvStaffIds} AND t.annex_paths = #{annexPaths} AND t.other_annex_paths = #{otherAnnexPaths} AND t.remarks LIKE concat('%',pgex.likequery(#{remarks}),'%') AND t.make_staff = #{makeStaff}::uuid AND t.flg_valid = #{flgValid} AND t.own_cp_id = #{ownCpId} AND t.ctr_cp_id = #{ctrCpId} AND t.op_update_staff_id = #{opUpdateStaffId}::uuid AND t.acc_calc_begin >= #{accCalcBeginStart} AND t.acc_calc_begin <= #{accCalcBeginEnd} AND t.acc_calc_end >= #{accCalcEndStart} AND t.acc_calc_end <= #{accCalcEndEnd} AND t.apv_result_time >= #{apvResultTimeStart}::timestamp with time zone AND t.apv_result_time < #{apvResultTimeEnd}::timestamp with time zone + interval '1 day' AND t.acc_date >= #{accDateStart} AND t.acc_date <= #{accDateEnd} AND t.make_time >= #{makeTimeStart}::timestamp with time zone AND t.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day' AND t.flg_valid = any(#{flgValidList, typeHandler= BooleanListTypeHandler}) AND t.own_cp_id = any(#{ownCpIdList, typeHandler= BigIntListTypeHandler}) AND t.op_create_time >= #{opCreateTimeStart}::timestamp with time zone AND t.op_create_time < #{opCreateTimeEnd}::timestamp with time zone + interval '1 day' AND t.op_update_time >= #{opUpdateTimeStart}::timestamp with time zone AND t.op_update_time < #{opUpdateTimeEnd}::timestamp with time zone + interval '1 day' AND t.staff_id = any(#{staffIdList, typeHandler= UUidListTypeHandler}) AND t.org_id = any(#{orgIdList, typeHandler= UUidListTypeHandler}) AND t.status_invoice = any(#{statusInvoiceList, typeHandler= StringListTypeHandler}) AND t.sum_amt_cash != t.sum_amt_should AND EXISTS( SELECT 1 FROM dkscu_b.t_fia_asset_item AS item WHERE flg_valid AND item.doc_id = T.doc_id AND item.org_id = any(#{itemOrgIdList, typeHandler= UUidListTypeHandler}) AND item.calc_subject_id = any(#{calcSubjectList, typeHandler= UUidListTypeHandler}) ) 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) ) AND t.status_flow = any(#{assetStatusList, typeHandler= StringListTypeHandler}) 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, 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 WHERE t.doc_id in #{item}::uuid insert into dkscu_b.t_fia_asset ( 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, ) values ( #{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}, #{item.sumAmtAsset}, DEFAULT, #{item.sumAmtNetWorth}, DEFAULT, #{item.sumAmtNetSalvage}, DEFAULT, #{item.totalCalcNo}, DEFAULT, #{item.sumAmtCalcMonth}, DEFAULT, #{item.accCalcBegin}, #{item.accCalcEnd}, #{item.happenCalcNo}, DEFAULT, #{item.sumAmtHappenCalc}, DEFAULT, #{item.sumAmtLoss}, DEFAULT, #{item.sumAmtClear}, DEFAULT, #{item.assetSubjectId}::uuid, #{item.calcSubjectId}::uuid, #{item.taxRate}, DEFAULT, #{item.sumAmtTax}, DEFAULT, #{item.sumAmtShould}, DEFAULT, #{item.macId}::uuid, #{item.sumAmtCash}, DEFAULT, #{item.sumAmtCharge}, DEFAULT, #{item.objType}, DEFAULT, #{item.objId}::uuid, #{item.flgInit}, DEFAULT, #{item.externalNo}, #{item.externalSystem}, #{item.printTimes}, DEFAULT, #{item.apvSubmitId}::uuid, #{item.apvStaffIds,typeHandler=UuidListTypeHandler}, #{item.apvResultTime}, #{item.annexPaths,typeHandler=JsonTypeHandler}, #{item.otherAnnexPaths,typeHandler=JsonTypeHandler}, #{item.remarks}, #{item.accDate}, #{item.makeStaff}::uuid, #{item.makeTime}, DEFAULT, #{item.ownCpId}, #{item.ctrCpId}, #{item.sumAmtTotalCash}, DEFAULT, #{item.dueDate}, ) on conflict (doc_id) do update set 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",