この記事では、主にエンティティデータを保存する方法を紹介します。特定のコンテンツは次のとおりです。
1。XMLサンプル
<?xml version = "1.0" encoding = "gbk"?> <! - 1..1-> <cisreports batno = "query batch number" initname = "query name name" suborgan = "branch name" queryuserid = "query operator login name" querycount = "query =" requery = "recimetime HH24:mm:ss "> <! - 次のクエリアプリケーションのクエリ結果1..n-> <cisreport ReportID =" Report number "buildendtime =" Report生成時間、フォーマットyyyy-mm-dd HH24:mm:ss "queryraindid =" query rease = "subreportttepes" querreportttepe for seque for for for for for for efie subreport IDs are separated by commas" treatmentResult="Compact fee count times of fee subreport, corresponding to subReportTypes, is a set of values greater than or equal to 0, separated by commas" subReportTypesShortCaption="Query fee subreport Chinese name" refID="Query ID, is the reference ID in the query application condition" hasSystemError="Is there a system error, true:エラーがあります、偽:エラーなし "isfrozen ="顧客が凍結しているかどうか、真:凍結、false:fals "> <! - 1 queryconditions> <! - 1..n-> <item> <アイテム> <アイテム> <アイテム> <アイテム> <アイテム> <アイテム> <アイテム>英語名</name> <キャプション>クエリ条件< <! - 2Identity Authentication1..1-> <PoliceCheckInfo SubreportType = "10602" Subreporttypecost = "96040" TreateResult = "Subreport Query Status、1:Find、2:Found、3:他の理由で見つかりません" "errorcode =" Treatult = 3はerroresult = "erresult =" errersult = "erresult ="このプロパティは存在しません "errormessage ="エラー説明情報Treatresult = 3、Treatresult!= 3の場合、このプロパティの値は空です "> <item> <name> queryee> name> <documentno> Queryeeの名前</documentno> <! - 1、一貫性のある2、inconsent ultersent> </item> </policecheckinfo> <! - 3人の携帯電話番号検証1..1-> <mobilecheckinfo subreporttype = "13612" subreporttypecost = "96040" treateResult = "subreport queryステータス、1:発見、2:他の理由= 3: Treatresult!= 3の場合、属性は存在しません。」 errormessage = "エラー説明情報Treatresult = 3、Treatresult!= 3の場合、この属性の値は空です"> <!--- Treatresultは2と3です。結果、次の結果:一貫性、一貫性がなく、一貫性がない</documentNocheckResult> <PhoneCheckResult>携帯電話番号検証結果:一貫性があり、チェック不可能</PhonecheckResult> <AreaInfo>番号属性</areaInfo> <オペレーター>オペレーター1:中国のモバイル3:中国Unisom </opertor> 4人の個人抗fraudのリスク1..1-> <> <personinatispoofingdescinfo subreporttype = "14225" subreporttypecost = "96040" treateResult = "subreport queryステータス、1:発見、2:見つかった、3: Treatsult!= 3、属性は存在しません= "エラー説明terirtresult!= 3、この属性の値は空です。次の例のように、それは空である可能性があり、それらの0またはnがある場合があり、特定の結果に応じて返すことができます。 1.アンチフラードリスクスコアは100ポイント、リスクレベルは高く、拒否することをお勧めします。 2。Telecom携帯電話番号131 **** 1542は1か月未満で使用されています。 3.ウールパーティーのリストをヒットします。 4.ヒット詐欺のリスクのリスト。 5。リスクの高い人員のリスト。 6. 7つの期限切れの信用記録があります。 7. 40の個人リスクの要約情報があります。 8。過去2年間で、私の個人情報は23回照会されました。 - > <PersonAntisPoofingDesc>個人的な反フラッドレビュー情報</personAntisPoofingDesc> </personAntisPoofingDesc> <! - 5パーソナルアンチフレーズリスクスコア情報1..1-> <PersoniSPOOFINGINFO subReporttype = "14224" subreporttypecost = "" 96040 "" 96040 "" 96040 "ステータス、1:2:チェックされていない、3:他の理由をチェックしない「TreaterRorcode = "Treatresult = 3の場合、詳細についてはデータ辞書を参照してください!= 3を参照してください。 errormessage = "エラー説明treatresult = 3の場合、Treatresult!= 3の場合、このプロパティの値は空です"> <!-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 6携帯電話番号ステータス情報errormessage = "エラー説明情報Treatresult = 3、Treatresult!= 3の場合、この属性の値は空です"> <! - TREATRETRESULTが2または3の場合、次のノード - > <アイテム> <オペレーター>オペレーター1:中国の通信2:中国携帯電話3:中国UNICOM </OPERINFO> <ERAIGINFO> <ERAINFO>ステータス1:通常の使用2:シャットダウン3:有効化されていない4:キャンセル5-other 6:PRONESTATUS> PHONESTATUS> <TimeLength>インターネット上の携帯電話番号:インターネット上の時間、1か月、1〜6か月、7-12か月、7-12か月、7-12か月</タイムレングス>ウールパーティーのリストをヒットする1..1-> <econnoisserurinfo subreporttype = "14228" subreporttypecost = "96040" treateResult = "サブレポートクエリステータス、1:Find、2:not not found、3:他の理由で見つかっていない"エラーコード= Treatresult!= 3の場合、属性は存在しません "errormessage ="エラー説明treatresult = 3、treatresult!= 3の場合、この属性の値は空です "> <!------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- subReportType="14229" subreporttypecost = "96040" TreatentResult = "サブレポートクエリステータス、1:Find、2:見つかりません、3:他の理由で見つかりません" "TreaterRorcode =" TreaterRorcode = 3エラーコード、データ辞書を参照してください。このプロパティは空です」 subreporttypecost = "96040" TreatentResult = "サブレポートクエリステータス、1:find、2:checked、3:他の理由で見つかりません" "treaterrorcode =" treaterrorcode = 3、data dictionaryを参照してください。この属性は空です "> <! - 世俗的なトールラストが2または3の場合、次のノードはありません - > <sheckResult>ハイリスクリストを押すかどうか1:はい、2:no </checkResult> </personRiskAssess> <! subreporttypecost = "96040" treationResult = "サブレポートクエリステータス、1:find、2:not not not not not not not not not not other not other code" treaterrorcode = "treatresult = 3、詳細についてはデータ辞書を参照してください。 Treatresult!= 3、属性は存在しません。 "errormessage ="エラー説明情報Treatresult = 3、Treatresult!= 3の場合、この属性の値は空です "> <! - 次のノードが2または3の場合、次のノードはありません - > <!ローンの基本情報</overdueamount> <overduedays>延滞日間隔、値範囲:1日(包括的)またはそれ以上</dueduedays> <overduecount>過度の日数間インターバル数</overduecount> </stat> <! - 0..1- <アイテム> <アイテム> < <overdueamount>延期されたプリンシパル、ユニット:ローンの基本情報の通貨に基づく</overdueamount> <overduedays>延滞日間隔、値の範囲:1〜6日、延滞、延滞、30〜59日、延滞、60〜89日間の過度、過度に過度に過度に延長(期限間隔TreaterRorcode = "TreaterResult = 3の場合、詳細についてはデータ辞書を参照してください。 Treatresult!= 3の場合、属性は存在しません。 "errormessage =" treatresult = 3、エラー説明情報Treatresult!= 3、この属性の値は空です "> <!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- <cqggcount>雇用発表に関する情報の数</cqggcount> <wdyqcount>延滞オンラインローンに関する情報の数</wdyqcount> </stat> <! - 概要情報終了 - > <! - 概要情報0..1-> <! - 概要情報0..1-> <als> < <item> recordid>レコード番号</recordid> <bt>タイトル</bt> <ajlx>ケースタイプ</ajlx> <sjnf>レビュー年、形式:yyyy </sjnf> <dsrlx>タイプのパーティー</dsrlx> </item> </als> <司法執行情報の情報<! - 司法違反の信託違反情報の要約情報 - > <sws> <! - 税務管理法執行情報の要約情報コンテンツ1..n-> <itemid>レコード番号</recordid> <bt>タイトル</bt> <ggrq>発表日、フォーマットyyyy-mm-dd </ggrq> </item> </sws> <! 1..n-> <item> <ecordid>レコード番号</recordid> <bt>タイトル</bt> <fbrq>リリース日、フォーマットyyyy-mm-dd </fbrq> </item> </cqs> <! - オーバーデュー情報サマリー情報オンラインローン0..1-> <wdue情報番号</recordId> <bt>タイトル</bt> <fbrq>リリース日、フォーマットyyyy-mm-dd </fbrq> </item> </wdyqs> </summary> </personriskinfo> <! - 12人の過去2年間の歴史的クエリレコード1..1-> subreporttypecost = "96040" TreationResult = "サブレポートクエリステータス、1:チェック、2:他の理由で見つかりません=" TREATRESULT = 3、TREATRESTRES!= 3、emrorResult = 3、TERERESULT = 3、TERERESTERING = 3、 "ErrorSult = 3、空の "> <!--- Treaterteartresultが2と3の場合、以下のノードはありません - > <! - 0..1-> <アイテム> <! - 1..n-> <itemmember> unitypmember> </unitmember> <最後の1か月>過去1か月のクエリレコード数</last1mth> </last3nth <last3nth </last3nth </</emon </last3nty>過去6か月間のクエリレコード</last6nth> <last12mth>過去12か月間のクエリレコード数</last12mth> <last18mth>過去18か月のクエリレコード数</last18nth> <最後の24か月>過去24か月間のクエリレコード数</last24nth>過去1か月のクエリレコード</last1month> <last3month>過去3か月間のクエリレコードの総数</last3month> <last6nth>過去6か月のクエリレコードの総数</last6nth> last12mth>過去12か月間のクエリレコードの総数</last12mth> </last18mont>月</last18month> <last24month>過去24か月の各ユニットタイプのクエリレコードの総数</last24month> </count> </historysimplequeryinfo> </cisreport> </cisreports> </cisreports>
2。テーブル構造設計
1。バッチ番号:各テーブルは、最も外側のバッチ番号に関連付けられています。
2。メインテーブル:つまり、各レイヤーのすべてのフィールドは1つのテーブルに保存されます。
3、物理的なデザイン
Cisreportroot、Cisreportchild、ReportElementの3つの層に分かれています
パブリッククラスのcisreportrootは、serializable {private string docid;プライベート文字列batno; //クエリバッチ番号@jsonfield(serialize = false)private string xmlid; Private Cisreportchild Cisreportchild;/*** 2017/7/21。 *ノードプロパティとチャイルドノードをレポート*/パブリッククラスCisReportChildは、basepojo {/***レポート生成の終了時間**/プライベート文字列buildendtimeを拡張します。 / ***falseがあるというシステムエラーがありますか?つまり、**/ private string hassystemerrorがないことを意味します。 / ***顧客が凍結されているかどうか**/ private文字列isfrozen;プライベートレポートエレメントレポートエレメント。 Public Class ReportElementはBasepojo {private String Phone; Private PoliceCheckinfo PoliceCheckinfo; // ID認証プライベートMobileCheckinfo MobileCheckinfo; //人の携帯電話番号検証Private PersonistisPoofingDescinfo PersonistisPoofingDescinfo; mobilestatusinfo mobilestatusinfo; //携帯電話番号ステータス情報プライベートeconnoisserurinfo econnoisserurinfo; //はウールパーティーリストにヒットします。 Micronearlylyeysoverdueinfo; //オンラインローン過度の情報情報private anriskinfo personriskinfo; //リスク情報private privatesimplequeryinfo historysimplequeryinfo; //過去2年間の個人履歴クエリレコード4、コード
<1>単一のトランザクション、バッチにはプライマリキーは必要ありません
データは単一のトランザクションまたはバッチのマップに保存でき、データはSQLのマップキーを介して取得できます。
のように:
private void savepersonriskinfo(string batno、personriskinfo personriskinfo)スロー{map <string、object> map = new hashmap <>(); map.put( "batno"、batno); //シングルハンドマップ.put( "item"、personriskinfo); pymapper.savepersonriskinfo(マップ); if(!listutil.isempty(personriskinfo.getallist())){// batch map.put( "list"、personriskinfo.getallist()); pymapper.savealinfolist(map); }SQL:
<! - 個人リスクレコード - > //シングル<挿入id = "savepersonriskinfo" parametertype = "java.util.map"> table_person_risk_info(batno、totlecount、alcount、zxcount、sxcount、swcount、cqggount、wyqcount、wyqcount)value( #{item.totlecount、jdbctype = numeric}、 #{item.alcount、jdbctype = numeric}、#{item.zxcount、jdbctype = numeric}、#{item.sxcount、jdbctype = numeric}、#{{ item.swcount、jdbctype = numeric}、#{item.cqggcount、jdbctype = numeric}、#{item.wdyqcount、jdbctype = numeric}) </insert> <! - duedueの詳細な記録 - > // batch <挿入id = "savememicronearlyyearsoverdueinfolist" parametertype = "java.util.map">挿入table_mntyoi(batno、dueamount、dueamount、duedays、duedays、overduount)< #{batno、jdbctype = varchar}、#{item.overdueamount、jdbctype = varchar}、#{item.overduedays、jdbctype = varchar}、{item.overduecount、jdbctype = numeric} dual foreead < pyquerybean)スロー例外{pyquerybean.setqueryfrompy(query_from_py); // pyサービスcisreportroot cisreportroot = querycisreportfrompysterver(pyquerybean); cisreportroot.getCisReportChild()。getReportElement()。setPhone(pyquerybean.getPhone()); //cacheservice.save(cisreportroot); //(1)データSavecisReport(cisreportroot)を保存します。 cisreportrootを返します。 }(1)データを保存します
@transactional(rollbackfor = exception.class)@override public cisreportroot savecisreport(cisreportroot cisreportroot)スロー{try {reportelement reportelement = cisreportroot.getcisreportchild()。getReportelement(); personriskinfo personriskinfo = reportelement.getPersonRiskInfo(); //(2)メインテーブル、XMLのすべてのノード情報を保存(個人リスク情報を除く)、単一のデータpymapper.savecisreport(cisreportroot)を保存します。 if(success.equals(cisreportroot.getCisreportChild()。getReportElement()。getPersonRiskInfo()。getTretResult())){savepersonriskinfo(cisreportroot.getbatno()、personriskinfo); } if(cisreportroot.getCisReportChild()。getReportElement()。gethistorysimplequeryinfo()。getTretResult()。 //(3)バッチデータMap.putを保存( "Batno"、cisreportroot.getBatno()); if(!listutil.isempty(cisreportroot.getcisreportchild()。getReportelement()。gethistorysimplequeryinfo()。getItemlist())){map.put( "list"、 cisreportroot.getCisReportChild()。getReportElement()。gethistorysimplequeryinfo()。getItemlist()); pymapper.savehistorysimplequeryinfolist(Map); } if(!listutil.isempty(cisreportroot.getCisReportChild()。getReportElement()。getMicRonylyyEarySoverDueInfo()。getList())){map.put( "list" "、 cisreportroot.getCisReportChild()。getReportElement()。getMicRonearlylyeyearsoverdueinfo()。getList()); pymapper.savememicronearlylyeyearsoverdueinfolist(map); }} cisreportrootを返します。 } catch(Exception e){logger.error( "savecisreport@pyserviceimpl_exception"、e); eを投げる; }}(2)メインテーブルを保存します
<insert id = "savecisreport" parametertype = "java.util.map"> table_cisreport(batno、buildendtime、isfrozen、insertingに挿入MCI_NAMECHECKRESULT、MCI_AREAINFO、MCI_DOCUMENTNOCHECKRESULT、MCI_OPERATOR、MCI_PHONECHECKRESULT、PCI_DOCUMENTNO、PCI_NAME、PCI_RESULT、PASDI_DESC、PASI_HITTYPES、PASI_RISKLEBEBLE、PASI_RISSCORE、PASI_RISCCORE、PASI_RISCEXCOE、 MS_AREAINFO、MS_CANCELTIME、MS_OPERATOR、MS_PHONESTATUS、MS_TIMELENGTH、ECONNOISSERUR、FRAUDRISK、PRA_CHECKRESULT、MNTYOI_OVERDUECOUNT、MNTYOI_OVERDUECOUNT hs_last1month、hs_last3month、hs_last6month、hs_last12month、hs_last18month、hs_last24month、電話、xmlid)値(#{batno、jdbctype = varchar}、to_date HH24:mi:ss ')、#{cisreportchild.isfrozen、jdbctype = varchar}、#{cisreportchild.reportelement.mobilecheckinfo.namecheckresult、jdbctype = varchar}、 #{cisreportchild.reportelement.mobilecheckinfo.areainfo、jdbctype = varchar}、#{cisreportchild.reportelement.mobilecheckinfo.documentnocheckresult、jdbctype = varchar}、 #{cisreportchild.reportelement.mobilecheckinfo.operator、jdbctype = numeric}、#{cisreportchild.reportelement.mobilecheckinfo.phonecheckresult、jdbctype = varchar}、 #{cisreportchild.reportelement.policecheckinfo.documentno、jdbctype = varchar}、#{cisreportchild.reportelement.policecheckinfo.result、jdbctype = numeric}、 #{cisreportchild.reportelement.personantispoofingdescinfo.personantispoofingdesc、jdbctype = varchar}、#{cisreportchild.reportelement.personantispoofinginfo.hittypes #{cisreportchild.reportelement.personantispoofinginfo.risklevel、jdbctype = varchar}、#{cisreportchild.reportelement.personantispoofinginfo.riskscore、jdbctype = varchar}、 #{cisreportchild.reportelement.personantispoofinginfo.suggest、jdbctype = varchar}、#{cisreportchild.reportelement.mobilestatusinfo.areainfo、jdbctype = varchar}、 #{cisreportchild.reportelement.mobilestatusinfo.canceltime、jdbctype = varchar}、#{cisreportchild.reportelement.mobilestatusinfo.operator、jdbctype = numeric}、 #{cisreportchild.reportelement.mobilestatusinfo.phonestatus、jdbctype = numeric}、#{cisreportchild.reportelement.mobilestatatusinfo.timelength、jdbctype = varchar}、 #{cisreportchild.Reportelement.econnoisserurinfo.state、jdbctype = numeric}、#{cisreportchild.reportelement.fraudriskinfo.state、jdbctype = numeric}、 #{cisreportchild.reportelement.personriskassess.checkresult、jdbctype = numeric}、#{cisreportchild.reportelement.micronearlyyearsoversoversoverdueinfo.overdueamount、jdbctype = varchar}、 #{cisreportchild.reportelement.micronearlylyyearsoverdueinfo.overduecount、jdbctype = numeric}、#{cisreportchild.reportelement.micronearthreeyearsoverdueinfo.overdays #{cisreportchild.reportelement.historysimplequeryinfo.totalcount.last1month、jdbctype = numeric}、{cisreportchild.reportelement.historysimplequeryinfo.totalcount.last3month #{cisreportchild.reportelement.historysimplequeryinfo.totalcount.last6month、jdbctype = numeric}、{cisreportchild.reportelement.historysimplequeryinfo.totalcount.last12month #{cisreportchild.reportelement.historysimplequeryinfo.totalcount.last18month、jdbctype = numeric}、#{cisreportchild.reportelement.historysimplequeryinfo.totalcount.last24month、jdbctype} #{cisreportChild.ReportElement.Phone、jdbctype = varchar}、#{xmlid、jdbctype = varchar})(3)バッチデータを保存します(プライマリキーは自動的に生成されません)
<! - 過去2年間の個人的な歴史的クエリレコード - > <ID = "SaveHistorySimplequeryInfolist" parametertype = "Java.util.map"> table_history_simple_query(batno、unt_member、last1thsth、last3month、last18month、last18month、 " item = "item" separator = "union all">(select#{batno、jdbctype = varchar}、#{item.unitmember、jdbctype = varchar}、#{item.last1month、jdbctype = numeric}、#{item.last3nth、jdbctype = numeric} #{item.last6month、jdbctype = numeric}、#{item.last12month、jdbctype = numeric}、#{item.last18month、jdbctype = numeric}、#{item.last24month、jdbctype = numeric} from dual < <2>単一のストローク、バッチを主キーに挿入する必要があります
シングルストロークには主キーが含まれています
DataServiceTeTailResult DataServiceTeTailResult = tdservice.getDataServiceTeTailResult(TDREPORTROOT); int n = tddataservicemapper.insertdataserviceteTailResult(dataservicedetailresult); <! - 情報検証インターフェイス - > <! - dataService-> <insert dataService = "insertDataserviceTeailResult" parameterType = "dataServiceDetailResult"> <selectkey keyproperty = "id" resulttype = "bigdecimal" order = "before"> select seq_ics_td_dataservice.nextmey ICS_TD_DATASERVICE(ID、RECORDID、REACE_DESC、REASON_CODE、成功)値(#{id、jdbctype = decimal}、#{reaveondesc、jdbctype = varchar}、 #{success、jdbctype = decimal})</insert>バッチセーブにはプライマリキーが含まれています
if(!listutil.isempty(interfaceslist)){map.put( "recordid"、id); map.put( "list"、interfaceslist); tddataservicemapper.addbatchinterfaces(Map); }SQL:
<! - バッチ保存インターフェイス - > <ID = "addBatchInterfaces" parametertype = "java.util.list"> <! - コメントはmysql挿入方法です。挿入できますが、データをロールバックすることはできません。以下はOracle挿入方法です。パラメータ型:java.util.listまたはjava.util.mapに注意してください<foreach collection = "foreach" item = "index =" separator = ""> ICS_TD_INTERFACES(ID、RECORDID、タイプ)値(Bloancrdtdata #{RecordID、jdbctype = decimal}、#{item.type、jdbctype = varchar}); </foreach>コミット; end; - > inserting Insing ICS_TD_INTERFACES(ID、RECORDID、TYPE)SELECT SEQ_ICS_TD_INTERFACES.NEXTVAL ID、A。 </foreach>)a </insert>要約します
上記は、エディターによる単一のバッチに物理データを保存する方法です。私はそれが誰にでも役立つことを願っています。ご質問がある場合は、メッセージを残してください。編集者は、すべての人に時間内に返信します。 wulin.comのウェブサイトへのご支援ありがとうございます!