xmlParser.py 297 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828
  1. #!/usr/bin/env Python
  2. # coding=utf-8
  3. import json
  4. from xml.dom import minidom
  5. import consts;
  6. import constsBase
  7. import pandas as pd
  8. import numpy as np;
  9. import time
  10. import log
  11. logger = log.logger
  12. import utils
  13. import loanIndexParser as lip;
  14. import payRcdIndexParser as prp;
  15. import creditCardIndexParser as cip
  16. import queryInfoIndexParser as qip
  17. import requests
  18. import dfParser
  19. import sys
  20. import traceback
  21. import timeit
  22. from mailUtil import MailUtil
  23. from dbController import DbController
  24. #身份信息
  25. identityInfoIndex = '身份信息'
  26. identityInfoDf = pd.DataFrame(columns=consts.identityInfoHeader,index=[identityInfoIndex])
  27. #配偶信息
  28. mateInfoIndex = '配偶信息'
  29. mateInfoDf = pd.DataFrame(columns=consts.mateInfoHeader,index=[mateInfoIndex])
  30. #居住信息
  31. liveInfoIndex = '居住信息'
  32. liveInfoDf = pd.DataFrame(columns=consts.liveInfoHeader,index=[liveInfoIndex])
  33. #职业信息
  34. occupationInfoIndex = '职业信息'
  35. occupationInfoDf = pd.DataFrame(columns=consts.occupationInfoHeader,index=[occupationInfoIndex])
  36. #信贷交易信息提示
  37. loanTradeInfoIndex = '信贷交易信息提示'
  38. briefInfoDf_loanTradeInfo = pd.DataFrame(columns=consts.briefInfoHeader_loanTradeInfo,index=[loanTradeInfoIndex])
  39. #被追偿信息汇总及呆账信息汇总
  40. recoveryInfoSumIndex = '信贷交易违约信息概要'
  41. briefInfoDf_recoveryInfoSum = pd.DataFrame(columns=consts.briefInfoHeader_recoveryInfo,index=[recoveryInfoSumIndex])
  42. #呆账信息汇总
  43. badDebtsInfoIndex = '呆账信息汇总'
  44. briefInfoDf_badDebtsInfoSum = pd.DataFrame(columns=consts.briefInfoHeader_badDebtsInfoSum,index=[badDebtsInfoIndex])
  45. #逾期(透支)信息汇总
  46. overdueInfoSumIndex='逾期(透支)信息汇总'
  47. briefInfoDf_overdueInfoSum = pd.DataFrame(columns=consts.briefInfoHeader_overdueInfoSum,index=[overdueInfoSumIndex])
  48. #信贷交易授信及负债信息概要
  49. loanTradeCreditInfoIndex='信贷交易授信及负债信息概要'
  50. briefInfoDf_loanTradeCreditInfo = pd.DataFrame(columns=consts.briefInfoHeader_loanTradeCreditInfo,index=[loanTradeCreditInfoIndex]).fillna(0.0)
  51. #公共信息概要
  52. publicInfoBriefIndex = '公共信息概要'
  53. publicInfoBriefDf = pd.DataFrame(columns=consts.publicInfoBriefHeader,index=[publicInfoBriefIndex])
  54. #查询记录汇总
  55. queryRecordSumIndex = '查询记录汇总'
  56. queryRecordSumDf = pd.DataFrame(columns=consts.queryRecordSumHeader,index=[queryRecordSumIndex])
  57. #信贷交易明细-被追偿信息
  58. recoveryInfoIndex='被追偿信息'
  59. creditTradeDetailDf_recoveryInfo = pd.DataFrame(columns=consts.creditTradeDetailHeader_recoveryInfo,index=[recoveryInfoIndex])
  60. #信贷交易明细-特殊交易
  61. specialTradeIndex='特殊交易'
  62. creditTradeDetailHeader_specialTrade = pd.DataFrame(columns=consts.creditTradeDetailHeader_specialTrade,index=[specialTradeIndex])
  63. #信贷交易明细
  64. #非循环贷账户
  65. loanInfoIndex='非循环贷账户'
  66. creditTradeDetailDf_loanAccountInfo = pd.DataFrame(columns=consts.creditTradeDetailHeader_loanAccountInfo,index=[loanInfoIndex])
  67. #循环额度下分账户
  68. cycleCreditAccountInfoIndex='循环额度下分账户'
  69. creditTradeDetailDf_cycleCreditAccountInfo = pd.DataFrame(columns=consts.creditTradeDetailHeader_cycleCreditAccountInfo,index=[cycleCreditAccountInfoIndex])
  70. #循环贷账户
  71. cycleLoanAccountInfoIndex='循环贷账户'
  72. creditTradeDetailDf_cycleLoanAccountInfo = pd.DataFrame(columns=consts.creditTradeDetailHeader_cycleLoanAccountInfo,index=[cycleLoanAccountInfoIndex])
  73. #贷款信息
  74. loanAccountInfoIndex='贷款信息'
  75. loanAccountInfoDf = pd.DataFrame(columns=consts.loanAccountInfoHeader,index=[loanAccountInfoIndex])
  76. #贷记卡信息
  77. creditCardAccountInfoIndex = '贷记卡账户'
  78. creditCardAccountInfoDf = pd.DataFrame(columns=consts.creditCardAccountInfoHeader,index=[creditCardAccountInfoIndex])
  79. #准贷记卡
  80. creditCardAccountInfoIndexZ = '准贷记卡账户'
  81. creditCardAccountInfoDfZ = pd.DataFrame(columns=consts.creditCardAccountInfoHeaderZ,index=[creditCardAccountInfoIndexZ])
  82. useRateIndex = '使用率'
  83. useRateDf = pd.DataFrame(columns=consts.creditTradeDetailHeader_useRate,index=[useRateIndex])
  84. openAccountIndex = '开户数'
  85. openAccountDf = pd.DataFrame(columns=consts.creditTradeDetailHeader_openAccount,index=[openAccountIndex])
  86. payRcdStatusIndex = '24期还款状态'
  87. payRcdStatusDf = pd.DataFrame(columns=consts.creditTradeDetailHeader_payRcdStatus,index=[payRcdStatusIndex])
  88. #查询记录明细指标
  89. queryRecordDetailIndex = '信贷审批查询记录明细'
  90. queryRecordDetailDf = pd.DataFrame(columns=consts.queryRecordDetailHeader,index=[queryRecordDetailIndex])
  91. #住房公积金
  92. housingFundRcdIndex = '住房公积金参缴记录'
  93. housingFundRcdDf = pd.DataFrame(columns=consts.housingFundRcdHeader,index=[housingFundRcdIndex])
  94. #汇算-其他
  95. otherIndex = '慧算账新增'
  96. otherDf = pd.DataFrame(columns=consts.otherHeader,index=[otherIndex])
  97. sanshouIndex = '恒昌新增'
  98. sanshouDf = pd.DataFrame(columns=consts.sanShouHeader,index=[sanshouIndex])
  99. #0916
  100. juziIndex = '桔子新增'
  101. juziDf = pd.DataFrame(columns=consts.juziHeader,index=[juziIndex])
  102. #基础信息字段补充,从欠税记录到查询记录(已补完),中间略去本人声明和异注声明
  103. #基础身份信息
  104. baseIdentityInfo = "基础身份信息"
  105. baseIdentityInfoDf = pd.DataFrame(columns=constsBase.identityInfo,index=[baseIdentityInfo])
  106. #基础配偶信息
  107. baseMateInfo = "基础配偶信息"
  108. baseMateInfoDf = pd.DataFrame(columns=constsBase.mateInfo,index=[baseMateInfo])
  109. #基础居住信息
  110. baseLiveInfo = "基础居住信息"
  111. baseLiveInfoDf = pd.DataFrame(columns=constsBase.liveInfo,index=[baseLiveInfo])
  112. #基础职业信息
  113. baseOccupationInfo = "基础职业信息"
  114. baseOccupationInfoDf = pd.DataFrame(columns=constsBase.occupationInfo,index=[baseOccupationInfo])
  115. #个人信用报告"数字解读"
  116. personalCreditInfo = "个人信用报告'数字解读'"
  117. personalCreditInfoDf = pd.DataFrame(columns=constsBase.personalCreditInfo,index=[personalCreditInfo])
  118. #信贷交易信息提示
  119. briefInfoHeaderLoanTradeInfo = "信贷交易信息提示"
  120. briefInfoHeaderLoanTradeInfoDf = pd.DataFrame(columns=constsBase.briefInfoHeaderLoanTradeInfo,index=[briefInfoHeaderLoanTradeInfo])
  121. #被追偿信息汇总
  122. recoveryInfoSumIndexY = '信贷交易违约信息概要'
  123. briefInfoDf_recoveryInfoSumY = pd.DataFrame(columns=constsBase.briefInfoHeader_recoveryInfoY,index=[recoveryInfoSumIndexY])
  124. #呆账信息汇总
  125. badDebtsInfoIndexY = '呆账信息汇总'
  126. briefInfoDf_badDebtsInfoSumY = pd.DataFrame(columns=constsBase.briefInfoHeader_badDebtsInfoSumY,index=[badDebtsInfoIndexY])
  127. #逾期(透支)信息汇总
  128. overdueInfoSumIndexY='逾期(透支)信息汇总'
  129. briefInfoDf_overdueInfoSumY = pd.DataFrame(columns=constsBase.briefInfoHeader_overdueInfoSumY,index=[overdueInfoSumIndexY])
  130. #信贷交易授信及负债信息概要
  131. creditTransactionCredit = "信贷交易授信及负债信息概要"
  132. creditTransactionCreditDf = pd.DataFrame(columns=constsBase.creditTransactionCredit,index=[creditTransactionCredit])
  133. #非信贷交易信息概要
  134. nonCreditTransactions = "非信贷交易信息概要"
  135. nonCreditTransactionsDf = pd.DataFrame(columns=constsBase.nonCreditTransactions,index=[nonCreditTransactions])
  136. #公共信息概要
  137. publicInformation = "公共信息概要"
  138. publicInformationDf = pd.DataFrame(columns=constsBase.publicInformation,index=[publicInformation])
  139. #查询记录概要
  140. queryRecord = "查询记录概要"
  141. queryRecordDf = pd.DataFrame(columns=constsBase.queryRecord,index=[queryRecord])
  142. # #被追偿信息已拆分
  143. # recoveryInformation = "被追偿信息"
  144. # recoveryInformationDf = pd.DataFrame(columns=constsBase.recoveryInformation,index=[recoveryInformation])
  145. # 被追偿账户基本信息
  146. recoveryBaseInfo = "被追偿账户基本信息"
  147. recoveryBaseInfoDf = pd.DataFrame(columns=constsBase.recoveryBaseInfo,index=[recoveryBaseInfo])
  148. #被追偿账户最新表现信息
  149. recoveryLatest = "被追偿账户基本信息"
  150. recoveryLatestDf = pd.DataFrame(columns=constsBase.recoveryLatest,index=[recoveryLatest])
  151. #被追偿账户特殊交易信息
  152. recoverySpecial = "被追偿账户基本信息"
  153. recoverySpecialDf = pd.DataFrame(columns=constsBase.recoverySpecial,index=[recoverySpecial])
  154. #被追偿账户标注及声明信息
  155. recoveryMark = "被追偿账户基本信息"
  156. recoveryMarkDf = pd.DataFrame(columns=constsBase.recoveryMark,index=[recoveryMark])
  157. # #非循环贷账户已拆分
  158. # nonRevolvingLoan = "非循环贷账户"
  159. # nonRevolvingLoanDf = pd.DataFrame(columns=constsBase.nonRevolvingLoan,index=[nonRevolvingLoan])
  160. # 非循环贷账户基本信息
  161. noLoopLoanBase = "非循环贷账户基本信息"
  162. noLoopLoanBaseDf = pd.DataFrame(columns=constsBase.noLoopLoanBase,index=[noLoopLoanBase])
  163. # 非循环贷账户最近一次月度表现信息
  164. noLoopLoanLastMonth = "非循环贷账户最近一次月度表现信息"
  165. noLoopLoanLastMonthDf = pd.DataFrame(columns=constsBase.noLoopLoanLastMonth,index=[noLoopLoanLastMonth])
  166. # 非循环贷账户最新表现信息
  167. noLoopLoanLatest = "非循环贷账户最新表现信息"
  168. noLoopLoanLatestDf = pd.DataFrame(columns=constsBase.noLoopLoanLatest,index=[noLoopLoanLatest])
  169. # 非循环贷账户最近 5 年内的历史表现信息
  170. noLoopLoan5Year = "非循环贷账户最近 5 年内的历史表现信息"
  171. noLoopLoan5YearDf = pd.DataFrame(columns=constsBase.noLoopLoan5Year,index=[noLoopLoan5Year])
  172. # 非循环贷账户特殊交易信息
  173. noLoopLoanSpecial = "非循环贷账户特殊交易信息"
  174. noLoopLoanSpecialDf = pd.DataFrame(columns=constsBase.noLoopLoanSpecial,index=[noLoopLoanSpecial])
  175. # 非循环贷账户标注及声明日期
  176. noLoopLoanMark = "非循环贷账户标注及声明日期"
  177. noLoopLoanMarkDf = pd.DataFrame(columns=constsBase.noLoopLoanMark,index=[noLoopLoanMark])
  178. # #循环额度下分账户已拆分
  179. # revolvingLoneSubAccount = "循环额度下分账户"
  180. # revolvingLoneSubAccountDf = pd.DataFrame(columns=constsBase.revolvingLoneSubAccount,index=[revolvingLoneSubAccount])
  181. # 循环额度下分账户基本信息
  182. LoopSubAccountBase = "循环额度下分账户基本信息"
  183. LoopSubAccountBaseDf = pd.DataFrame(columns=constsBase.LoopSubAccountBase,index=[LoopSubAccountBase])
  184. # 循环额度下分账户最近一次月度表现信息
  185. LoopSubAccountLastMonth = "循环额度下分账户最近一次月度表现信息"
  186. LoopSubAccountLastMonthDf = pd.DataFrame(columns=constsBase.LoopSubAccountLastMonth,index=[LoopSubAccountLastMonth])
  187. # 循环额度下分账户最近 5 年内的历史表现信息
  188. LoopSubAccount5Year = "循环额度下分账户最近 5 年内的历史表现信息"
  189. LoopSubAccount5YearDf = pd.DataFrame(columns=constsBase.LoopSubAccount5Year,index=[LoopSubAccount5Year])
  190. # 循环额度下分帐户特殊交易信息
  191. LoopSubAccountSpecial = "循环额度下分帐户特殊交易信息"
  192. LoopSubAccountSpecialDf = pd.DataFrame(columns=constsBase.LoopSubAccountSpecial,index=[LoopSubAccountSpecial])
  193. # 循环额度下分帐户标注及声明日期
  194. LoopSubAccountMark = "循环额度下分帐户标注及声明日期"
  195. LoopSubAccountMarkDf = pd.DataFrame(columns=constsBase.LoopSubAccountMark,index=[LoopSubAccountMark])
  196. # #循环贷账户已拆分
  197. # revolvingLone = "循环贷账户"
  198. # revolvingLoneDf = pd.DataFrame(columns=constsBase.revolvingLone,index=[revolvingLone])
  199. # 循环贷账户基本信息
  200. LoopLoanBase = "循环贷账户基本信息"
  201. LoopLoanBaseDf = pd.DataFrame(columns=constsBase.LoopLoanBase,index=[LoopLoanBase])
  202. # 循环贷账户最近一次月度表现信息
  203. LoopLoanLastMonth = "循环贷账户最近一次月度表现信息"
  204. LoopLoanLastMonthDf = pd.DataFrame(columns=constsBase.LoopLoanLastMonth,index=[LoopLoanLastMonth])
  205. # 循环贷账户最新表现信息
  206. LoopLoanLatest = "循环贷账户最新表现信息"
  207. LoopLoanLatestDf = pd.DataFrame(columns=constsBase.LoopLoanLatest,index=[LoopLoanLatest])
  208. # 循环贷账户最近 5 年内的历史表现信息
  209. LoopLoan5Year = "循环贷账户最近 5 年内的历史表现信息"
  210. LoopLoan5YearDf = pd.DataFrame(columns=constsBase.LoopLoan5Year,index=[LoopLoan5Year])
  211. # 循环贷账户特殊交易信息
  212. LoopLoanSpecial = "循环贷账户特殊交易信息"
  213. LoopLoanSpecialDf = pd.DataFrame(columns=constsBase.LoopLoanSpecial,index=[LoopLoanSpecial])
  214. # 循环贷账户标注及声明日期
  215. LoopLoanMark= "循环贷账户标注及声明日期"
  216. LoopLoanMarkDf = pd.DataFrame(columns=constsBase.LoopLoanMark,index=[LoopLoanMark])
  217. # #贷记卡账户已拆分
  218. # creditCard = "贷记卡账户"
  219. # creditCardDf = pd.DataFrame(columns=constsBase.creditCard,index=[creditCard])
  220. # 贷记卡账户基本信息
  221. creditCardBase = "贷记卡账户基本信息"
  222. creditCardBaseDf = pd.DataFrame(columns=constsBase.creditCardBase,index=[creditCardBase])
  223. # 贷记卡账户最近一次月度表现信息
  224. creditCardLastMonth = "贷记卡账户最近一次月度表现信息"
  225. creditCardLastMonthDf = pd.DataFrame(columns=constsBase.creditCardLastMonth,index=[creditCardLastMonth])
  226. # 贷记卡账户最新表现信息
  227. creditCardLatest = "贷记卡账户最新表现信息"
  228. creditCardLatestDf = pd.DataFrame(columns=constsBase.creditCardLatest,index=[creditCardLatest])
  229. # 贷记卡账户大额专项分期信息
  230. creditCardBig = "贷记卡账户大额专项分期信息"
  231. creditCardBigDf = pd.DataFrame(columns=constsBase.creditCardBig,index=[creditCardBig])
  232. # 贷记卡账户最近 5 年内的历史表现信息
  233. creditCard5Year = "贷记卡账户最近 5 年内的历史表现信息"
  234. creditCard5YearDf = pd.DataFrame(columns=constsBase.creditCard5Year,index=[creditCard5Year])
  235. # 贷记卡账户特殊事件信息
  236. creditCardSpecial = "贷记卡账户特殊事件信息"
  237. creditCardSpecialDf = pd.DataFrame(columns=constsBase.creditCardSpecial,index=[creditCardSpecial])
  238. # 贷记卡账户特殊交易说明
  239. creditCardSpecialMent = "贷记卡账户特殊交易说明"
  240. creditCardSpecialMentDf = pd.DataFrame(columns=constsBase.creditCardSpecialMent,index=[creditCardSpecialMent])
  241. # 贷记卡账户标注及声明日期
  242. creditCardMark = "贷记卡账户标注及声明日期"
  243. creditCardMarkDf = pd.DataFrame(columns=constsBase.creditCardMark,index=[creditCardMark])
  244. # #准贷记卡账户已拆分
  245. # quasiCreditCard = "准贷记卡账户"
  246. # quasiCreditCardDf = pd.DataFrame(columns=constsBase.quasiCreditCard,index=[quasiCreditCard])
  247. # 准贷记卡账户基本信息
  248. quasiCreditCardBase = "准贷记卡账户基本信息"
  249. quasiCreditCardBaseDf = pd.DataFrame(columns=constsBase.quasiCreditCardBase,index=[quasiCreditCardBase])
  250. # 准贷记卡账户最近一次月度表现信息
  251. quasiCreditCardLastMonth = "准贷记卡账户最近一次月度表现信息"
  252. quasiCreditCardLastMonthDf = pd.DataFrame(columns=constsBase.quasiCreditCardLastMonth,index=[quasiCreditCardLastMonth])
  253. # 准贷记卡账户最新表现信息
  254. quasiCreditCardLatest = "准贷记卡账户最新表现信息"
  255. quasiCreditCardLatestDf = pd.DataFrame(columns=constsBase.quasiCreditCardLatest,index=[quasiCreditCardLatest])
  256. # 准贷记卡账户最近 5 年内的历史表现信息
  257. quasiCreditCard5Year = "准贷记卡账户最近 5 年内的历史表现信息"
  258. quasiCreditCard5YearDf = pd.DataFrame(columns=constsBase.quasiCreditCard5Year,index=[quasiCreditCard5Year])
  259. # 准贷记卡账户特殊交易信息
  260. quasiCreditCardSpecial = "准贷记卡账户特殊交易信息"
  261. quasiCreditCardSpecialDf = pd.DataFrame(columns=constsBase.quasiCreditCardSpecial,index=[quasiCreditCardSpecial])
  262. # 准贷记卡账户标注及声明日期
  263. quasiCreditCardMark = "准贷记卡账户标注及声明日期"
  264. quasiCreditCardMarkDf = pd.DataFrame(columns=constsBase.quasiCreditCardMark,index=[quasiCreditCardMark])
  265. #相关还款责任信息
  266. relevantRepaymentLiability = "相关还款责任信息"
  267. relevantRepaymentLiabilityDf = pd.DataFrame(columns=constsBase.relevantRepaymentLiability,index=[relevantRepaymentLiability])
  268. #授信协议信息
  269. creditAgreement = "授信协议信息"
  270. creditAgreementDf = pd.DataFrame(columns=constsBase.creditAgreement,index=[creditAgreement])
  271. #后付费记录(未开发)
  272. postPaidRecord = "后付费记录"
  273. postPaidRecordDf = pd.DataFrame(columns=constsBase.postPaidRecord,index=[postPaidRecord])
  274. #欠税记录
  275. taxArrearsIndex = '欠税记录'
  276. taxArrearsDf = pd.DataFrame(columns=constsBase.taxArrears,index=[taxArrearsIndex])
  277. #民事判决记录
  278. civilJudgmentIndex = '民事判决记录'
  279. civilJudgmentDf = pd.DataFrame(columns=constsBase.civilJudgment,index=[civilJudgmentIndex])
  280. #强制执行记录
  281. enforceIndex = '强制执行记录'
  282. enforceDf = pd.DataFrame(columns=constsBase.enforce,index=[enforceIndex])
  283. #行政处罚记录
  284. administrativePunishmentIndex = '行政处罚记录'
  285. administrativePunishmentDf = pd.DataFrame(columns=constsBase.administrativePunishment,index=[administrativePunishmentIndex])
  286. #住房公积金参缴记录
  287. housingProvidentFundParticipationIndex = '住房公积金参缴记录'
  288. housingProvidentFundParticipationIndexDf = pd.DataFrame(columns=constsBase.housingProvidentFundParticipation,index=[housingProvidentFundParticipationIndex])
  289. #低保救助记录
  290. subsistenceAllowanceAssistanceIndex = '低保救助记录'
  291. subsistenceAllowanceAssistanceDf = pd.DataFrame(columns=constsBase.subsistenceAllowanceAssistance,index=[subsistenceAllowanceAssistanceIndex])
  292. #执业资格记录
  293. practiceQualificationIndex = '执业资格记录'
  294. practiceQualificationDf = pd.DataFrame(columns=constsBase.practiceQualification,index=[practiceQualificationIndex])
  295. #行政奖励记录
  296. administrativeIncentiveIndex = '行政奖励记录'
  297. administrativeIncentiveDf = pd.DataFrame(columns=constsBase.administrativeIncentive,index=[administrativeIncentiveIndex])
  298. #本人声明
  299. personalDeclaration = "本人声明"
  300. personalDeclarationDf = pd.DataFrame(columns=constsBase.personalDeclaration,index=[personalDeclaration])
  301. #异议标注
  302. objectionMarking = "异议标注"
  303. objectionMarkingDf = pd.DataFrame(columns=constsBase.objectionMarking,index=[objectionMarking])
  304. #查询记录
  305. queryRecordIndexY = '查询记录'
  306. queryRecordDfY = pd.DataFrame(columns=constsBase.queryRecordY,index=[queryRecordIndexY])
  307. #待执行的sql语句
  308. sqlMap = []
  309. class XmlParser(object):
  310. def getNodeData(self,node, key):
  311. data = ""
  312. try:
  313. if len(node.getElementsByTagName(key)) > 0:
  314. nodeValue = node.getElementsByTagName(key)[0].childNodes
  315. if len(nodeValue)>0:
  316. data = nodeValue[0].data
  317. except Exception:
  318. logger.error("getNodeData error")
  319. info = sys.exc_info()
  320. logger.error(info[0])
  321. logger.error(info[1])
  322. logger.error(traceback.extract_tb(info[2], 1))
  323. return data;
  324. def parse(self, xmlData):
  325. result = "{"
  326. try:
  327. docXml = minidom.parseString(xmlData)
  328. # print("xmlData" + xmlData)
  329. # print("docXml" +docXml)
  330. queryInfo = self.parseQueryInfo(docXml)
  331. reportTime = queryInfo["reportTime"];
  332. start = timeit.default_timer();
  333. logger.info(queryInfo["queryInfoCardId"] + "基本信息解析开始")
  334. self.parseIdentity(reportTime,docXml)
  335. self.parseLiveInfo(docXml)
  336. self.parseOccupationInfoDf(reportTime,docXml)
  337. self.parseLoanTradeInfo(docXml)
  338. self.parseRecoveryInfoSum(docXml)
  339. self.parseBadDebtsInfoSumDf(docXml)
  340. self.parseOverdueInfoSum(docXml)
  341. self.parseLoanAccountInfoSum(docXml)
  342. self.parseCycleCreditAccountInfoSum(docXml);
  343. self.parseCyleLoanAccountInfoSum(docXml);
  344. self.parseCreditCardInfoSum(docXml)
  345. self.parseCreditCardInfoSumZ(docXml)
  346. self.parseRepaymentSum(docXml)
  347. self.parsePublicInfoBrief(docXml)
  348. self.parseQueryRecordSum(docXml)
  349. self.parseQueryInfoDetail(reportTime,docXml)
  350. self.parseHousingFundRcd(reportTime,docXml)
  351. # yuan
  352. # self.parseBaseIdentity(reportTime, docXml)
  353. # self.parseBaseLiveInfo( docXml)
  354. # self.parseBaseOccupationInfoDf(docXml)
  355. # self.personalCreditInfo(docXml)
  356. # self.parseBriefInfoHeaderLoanTradeInfo(docXml)
  357. # self.parseCreditTransactionDefaultY(docXml)
  358. # self.parseBadDebtsInfoSumDfY(docXml)
  359. # self.parseOverdueInfoSumY(docXml)
  360. # self.parseLoanAccountInfoSumY(docXml)
  361. # self.parseCycleCreditAccountInfoSumY(docXml)
  362. # self.parseCyleLoanAccountInfoSumY(docXml)
  363. # self.parseCreditCardInfoSumY(docXml)
  364. # self.parseCreditCardInfoSumZY(docXml)
  365. # self.parsePublicInfoBriefY(docXml)
  366. # self.parseQueryRecordSumY(docXml)
  367. # self.parseRecoveryInfo(docXml)
  368. # # self.parseNoLoopLoan(docXml)
  369. # self.parseLoopSubAccount(docXml)
  370. # self.parseLoopLoan(docXml)
  371. # self.parseCreditCard(docXml)
  372. # self.parseQuasiquasiCreditCard(docXml)
  373. # self.parseRelevantRepaymentLiability(docXml)
  374. # self.parseCreditAgreement(docXml)
  375. # self.parseTaxArrears(docXml, reportTime)
  376. # self.parseCivilJudgment(docXml)
  377. # self.parseEnforce(docXml)
  378. # self.parseAdministrativePunishment(docXml, reportTime)
  379. # self.parseHousingProvidentFundParticipation(docXml)
  380. # self.parseSubsistenceAllowanceAssistance(docXml)
  381. # self.parsePracticeQualification(docXml)
  382. # self.parseAdministrativeIncentive(docXml, reportTime)
  383. # self.parseQueryRecordY(docXml)
  384. s = timeit.default_timer() - start
  385. logger.info(str(s) + " 秒")
  386. logger.info(queryInfo["queryInfoCardId"] + "基本信息解析完成")
  387. loanAccountDfs = []
  388. start = timeit.default_timer();
  389. logger.info(queryInfo["queryInfoCardId"]+"贷款解析开始")
  390. # 非循环
  391. noloopcreditaccountbols = self.mergeLoanDf(reportTime, docXml, "NOLOOPCREDITACCOUNTBOLS")
  392. # 循环额度
  393. loopquotaaccountbols = self.mergeLoanDf(reportTime, docXml, "LOOPQUOTAACCOUNTBOLS")
  394. # 循环贷账户
  395. loopcreditaccountbols = self.mergeLoanDf(reportTime, docXml, "LOOPCREDITACCOUNTBOLS")
  396. loanAccountDfs = noloopcreditaccountbols + loopquotaaccountbols + loopcreditaccountbols
  397. # print(len(loanAccountDfs))
  398. s = timeit.default_timer() - start
  399. logger.info(str(s) + " 秒")
  400. logger.info(queryInfo["queryInfoCardId"] + "贷款解析完成")
  401. start = timeit.default_timer();
  402. logger.info(queryInfo["queryInfoCardId"] + "信用卡解析开始")
  403. creditCardAccountDfs = self.mergeCreditCardDf(reportTime, docXml)
  404. # print(len(creditCardAccountDfs))
  405. creditCardAccountDfsZ = self.mergeCreditCardDfZ(reportTime, docXml)
  406. # print(len(creditCardAccountDfsZ))
  407. # 合并贷款
  408. loanMergeDf = pd.DataFrame(columns=dfParser.dfHeaderLoan)
  409. loanPayRecordMergeDf = pd.DataFrame(columns=dfParser.dfHeaderLoanPayRecord)
  410. loanSpecialTradeMergeDf = pd.DataFrame(columns=dfParser.dfHeaderLoanSpecialTrade) # 特殊交易
  411. loanMergeDfDs = []
  412. loanPayRecordMergeDfDs = []
  413. # for loanDfObj in loanAccountDfs:
  414. # loanMergeDf = pd.concat([loanMergeDf, loanDfObj["loanDf"]], axis=0, ignore_index=True);
  415. # loanPayRecordMergeDf = pd.concat([loanPayRecordMergeDf, loanDfObj["loanPayRecordDf"]], axis=0,ignore_index=True);
  416. # loanSpecialTradeMergeDf = pd.concat([loanSpecialTradeMergeDf, loanDfObj["specialTradeDf"]], axis=0,ignore_index=True);
  417. for loanDfObj in loanAccountDfs:
  418. loanMergeDfDs.append(loanDfObj["loanDf"])
  419. if loanDfObj["loanPayRecordDf"]!=None:
  420. loanPayRecordMergeDfDs.extend(loanDfObj["loanPayRecordDf"])
  421. loanSpecialTradeMergeDf = pd.concat([loanSpecialTradeMergeDf, loanDfObj["specialTradeDf"]], axis=0,ignore_index=True);
  422. if len(loanMergeDfDs)>0:
  423. loanMergeDf = pd.DataFrame(loanMergeDfDs)
  424. if len(loanPayRecordMergeDfDs)>0:
  425. loanPayRecordMergeDf = pd.DataFrame(loanPayRecordMergeDfDs)
  426. # 合并贷记卡
  427. creditCardMergeDf = pd.DataFrame(columns=dfParser.dfHeaderCreditCard)
  428. creditCardPayRecordMergeDf = pd.DataFrame(columns=dfParser.dfHeaderCreditCardPayRecord)
  429. for creditCardDfObj in creditCardAccountDfs:
  430. creditCardMergeDf = pd.concat([creditCardMergeDf, creditCardDfObj["creditCardDf"]], axis=0,ignore_index=True);
  431. creditCardPayRecordMergeDf = pd.concat([creditCardPayRecordMergeDf, creditCardDfObj["creditCardPayRecordDf"]], axis=0, ignore_index=True);
  432. # 准贷记卡合并df
  433. creditCardMergeDfZ = pd.DataFrame(columns=dfParser.dfHeaderCreditCardZ)
  434. creditCardPayRecordMergeDfZ = pd.DataFrame(columns=dfParser.dfHeaderCreditCardPayRecordZ)
  435. for creditCardDfObj in creditCardAccountDfsZ:
  436. creditCardMergeDfZ = pd.concat([creditCardMergeDfZ, creditCardDfObj["creditCardDfZ"]], axis=0,ignore_index=True);
  437. creditCardPayRecordMergeDfZ = pd.concat([creditCardPayRecordMergeDfZ, creditCardDfObj["creditCardPayRecordDfZ"]], axis=0,ignore_index=True);
  438. s = timeit.default_timer() - start
  439. logger.info(str(s) + " 秒")
  440. logger.info(queryInfo["queryInfoCardId"] + "信用卡解析完成")
  441. result += utils.toJson(identityInfoDf) + ","
  442. result += utils.toJson(mateInfoDf) + ","
  443. result += utils.toJson(liveInfoDf) + ","
  444. result += utils.toJson(occupationInfoDf) + ","
  445. result += "briefInfoDf_loanTradeInfo" + "," # 占位符
  446. result += "briefInfoDf_recoveryInfoSum" + "," # 占位符
  447. result += "briefInfoDf_overdueInfoSum" + ","
  448. result += utils.toJson(briefInfoDf_badDebtsInfoSum) + ","
  449. result += utils.toJson(briefInfoDf_loanTradeCreditInfo) + ","
  450. result += utils.toJson(publicInfoBriefDf) + ","
  451. result += utils.toJson(queryRecordSumDf) + ","
  452. # 合并被追偿信息DF
  453. recoveryInfoMergeDf = self.mergeRecoveryInfoDf(reportTime, docXml)
  454. self.parseRecoveryInfoMergeDf(recoveryInfoMergeDf)
  455. result = result.replace("briefInfoDf_recoveryInfoSum", utils.toJson(briefInfoDf_recoveryInfoSum)) # 替换汇总中的指标
  456. result += utils.toJson(creditTradeDetailDf_recoveryInfo) + "," # 设置占位符,由于存在概要的指标在明细中计算
  457. # 特殊交易
  458. self.parseSpecialTrade(loanSpecialTradeMergeDf)
  459. result += utils.toJson(creditTradeDetailHeader_specialTrade) + ","
  460. # 信贷交易明细-解析非循环贷账户
  461. self.parseLoanAccountInfo(loanMergeDf);
  462. result += utils.toJson(creditTradeDetailDf_loanAccountInfo) + ","
  463. # 循环额度分账户
  464. self.parseCycleCreditAccountInfo(loanMergeDf);
  465. result += utils.toJson(creditTradeDetailDf_cycleCreditAccountInfo) + ","
  466. # 循环贷
  467. self.parseCycleLoanAccountInfo(loanMergeDf);
  468. result += utils.toJson(creditTradeDetailDf_cycleLoanAccountInfo) + ","
  469. # 解析贷款账户指标
  470. start = timeit.default_timer();
  471. self.parseLoanMergeDf(loanMergeDf,reportTime);
  472. s = timeit.default_timer() - start
  473. logger.info("解析贷款账户指标 " + str(s) + " 秒")
  474. # 解析还款记录相关指标
  475. start = timeit.default_timer();
  476. self.parseLoanMergeAndPayRecordDf(loanMergeDf, loanPayRecordMergeDf,reportTime);
  477. s = timeit.default_timer() - start
  478. logger.info("解析还款记录相关指标 " + str(s) + " 秒")
  479. result += utils.toJson(loanAccountInfoDf) + ","
  480. # 解析贷记卡账户指标
  481. self.parseCreditCardMergeDf(creditCardMergeDf,reportTime);
  482. self.parseCreditCardMergeAndPayRecordDf(creditCardMergeDf, creditCardPayRecordMergeDf,reportTime)
  483. # 解析准贷记卡相关指标
  484. self.parseCreditCardMergeDfZ(creditCardMergeDfZ, creditCardPayRecordMergeDfZ);
  485. result += utils.toJson(creditCardAccountInfoDf) + ","
  486. result += utils.toJson(creditCardAccountInfoDfZ) + ","
  487. # 使用率
  488. self.parseUseRate()
  489. result += utils.toJson(useRateDf) + ","
  490. # 开户数
  491. self.parseOpenAccount(loanMergeDf, creditCardMergeDf, creditCardMergeDfZ, recoveryInfoMergeDf, loanPayRecordMergeDf,creditCardPayRecordMergeDf, creditCardPayRecordMergeDfZ,reportTime)
  492. result += utils.toJson(openAccountDf) + ","
  493. # 24期还款状态
  494. start = timeit.default_timer();
  495. self.parsePayRcdStatus(loanMergeDf, creditCardMergeDf, creditCardMergeDfZ, loanPayRecordMergeDf,creditCardPayRecordMergeDf, creditCardPayRecordMergeDfZ,reportTime)
  496. s = timeit.default_timer() - start
  497. logger.info("24期还款状态 " + str(s) + " 秒")
  498. result += utils.toJson(payRcdStatusDf) + ","
  499. # 由于逾期汇总的指标再还款状态之后需要替换占位 TODO
  500. result = result.replace("briefInfoDf_overdueInfoSum", utils.toJson(briefInfoDf_overdueInfoSum))
  501. # 0525 由于在开户数后,统计信贷信息概要的指标,替换占位符
  502. result = result.replace("briefInfoDf_loanTradeInfo", utils.toJson(briefInfoDf_loanTradeInfo))
  503. # 公积金
  504. result += utils.toJson(housingFundRcdDf) + ","
  505. result += utils.toJson(queryRecordDetailDf) + ","
  506. #取消汇算帐
  507. result += utils.toJson(otherDf) + ","
  508. #三寿新增
  509. result += utils.toJson(sanshouDf) + ","
  510. self.calcFirstBusMonth(reportTime)
  511. self.getLastOverdueMonthJz(loanMergeDf,creditCardMergeDf,loanPayRecordMergeDf,creditCardPayRecordMergeDf,reportTime)
  512. result += utils.toJson(juziDf)
  513. # # yuan
  514. # result += utils.toJson(baseIdentityInfoDf) + ","
  515. # result += utils.toJson(baseMateInfoDf) + ","
  516. # result += utils.toJson(baseLiveInfoDf) + ","
  517. # result += utils.toJson(baseOccupationInfoDf) + ","
  518. # result += utils.toJson(personalCreditInfoDf) + ","
  519. # result += utils.toJson(briefInfoHeaderLoanTradeInfoDf) + ","
  520. # result += utils.toJson(briefInfoDf_recoveryInfoSumY) + ","
  521. # result += utils.toJson(briefInfoDf_badDebtsInfoSumY) + ","
  522. # result += utils.toJson(briefInfoDf_overdueInfoSumY) + ","
  523. # result += utils.toJson(creditTransactionCreditDf) + ","
  524. # result += utils.toJson(nonCreditTransactionsDf) + ","
  525. # result += utils.toJson(publicInformationDf) + ","
  526. # result += utils.toJson(queryRecordDf) + ","
  527. # result += utils.toJson(recoveryBaseInfoDf) + ","
  528. # result += utils.toJson(recoveryLatestDf) + ","
  529. # result += utils.toJson(recoverySpecialDf) + ","
  530. # result += utils.toJson(recoveryMarkDf) + ","
  531. # result += utils.toJson(noLoopLoanBaseDf) + ","
  532. # result += utils.toJson(noLoopLoanLastMonthDf) + ","
  533. # result += utils.toJson(noLoopLoanLatestDf) + ","
  534. # result += utils.toJson(noLoopLoan5YearDf) + ","
  535. # result += utils.toJson(noLoopLoanSpecialDf) + ","
  536. # result += utils.toJson(LoopSubAccountBaseDf) + ","
  537. # result += utils.toJson(LoopSubAccountLastMonthDf) + ","
  538. # result += utils.toJson(LoopSubAccount5YearDf) + ","
  539. # result += utils.toJson(LoopSubAccountSpecialDf) + ","
  540. # result += utils.toJson(LoopLoanBaseDf) + ","
  541. # result += utils.toJson(LoopLoanLastMonthDf) + ","
  542. # result += utils.toJson(LoopLoanLatestDf) + ","
  543. # result += utils.toJson(LoopLoan5YearDf) + ","
  544. # result += utils.toJson(LoopLoanSpecialDf) + ","
  545. # result += utils.toJson(creditCardBaseDf) + ","
  546. #
  547. # result += utils.toJson(creditCardLastMonthDf) + ","
  548. # result += utils.toJson(creditCardLatestDf) + ","
  549. # result += utils.toJson(creditCardBigDf) + ","
  550. # result += utils.toJson(creditCard5YearDf) + ","
  551. # result += utils.toJson(creditCardSpecialDf) + ","
  552. # result += utils.toJson(creditCardSpecialMentDf) + ","
  553. # result += utils.toJson(quasiCreditCardBaseDf) + ","
  554. # result += utils.toJson(quasiCreditCardLastMonthDf) + ","
  555. # result += utils.toJson(quasiCreditCardLatestDf) + ","
  556. # result += utils.toJson(quasiCreditCard5YearDf) + ","
  557. # result += utils.toJson(quasiCreditCardSpecialDf) + ","
  558. # result += utils.toJson(relevantRepaymentLiabilityDf) + ","
  559. # result += utils.toJson(creditAgreementDf) + ","
  560. # result += utils.toJson(postPaidRecordDf) + ","
  561. # result += utils.toJson(taxArrearsDf) + ","
  562. # result += utils.toJson(civilJudgmentDf) + ","
  563. # #
  564. # result += utils.toJson(enforceDf) + ","
  565. # result += utils.toJson(administrativePunishmentDf) + ","
  566. # result += utils.toJson(housingProvidentFundParticipationIndexDf) + ","
  567. # result += utils.toJson(subsistenceAllowanceAssistanceDf) + ","
  568. # result += utils.toJson(practiceQualificationDf) + ","
  569. # result += utils.toJson(administrativeIncentiveDf) + ","
  570. #
  571. # result += utils.toJson(personalDeclarationDf) + ","
  572. # result += utils.toJson(objectionMarkingDf) + ","
  573. # result += utils.toJson(queryRecordDfY)
  574. result += "}"
  575. except Exception:
  576. info = sys.exc_info()
  577. # logger.error(str(Exception))
  578. logger.error(queryInfo["queryInfoCardId"]+" error")
  579. logger.error(info[0])
  580. logger.error(info[1])
  581. logger.error(traceback.extract_tb(info[2], 1))
  582. # logger.error( 'str(Exception):\t', str(Exception))
  583. # logger.error('str(e):\t\t', str(e))
  584. # logger.error('repr(e):\t', repr(e))
  585. # logger.error('e.message:\t', e.message)
  586. logger.error(traceback.print_exc())
  587. logger.error(traceback.format_exc())
  588. mailUtil = MailUtil();
  589. webhook = 'https://oapi.dingtalk.com/robot/send?access_token=64d8b2c7fed4949e9433b807c7c5559939f1517af8f77c1dacb4de19c6910b56'
  590. mailUtil.dingtalk("号码:"+queryInfo["queryInfoCardId"]+" 解析错误 "+traceback.format_exc(),webhook)
  591. return result,sqlMap;
  592. # 解析被查询信息指标
  593. def parseQueryInfo(self,docXml):
  594. headbo = docXml.documentElement.getElementsByTagName("HEADBO")[0]
  595. reportTime= self.getNodeData(headbo,"RPTTIME")
  596. queryInfo = {};
  597. queryInfoCardId = self.getNodeData(headbo,"CRENUMBER")
  598. queryInfo["reportTime"] = reportTime.replace("T"," ")
  599. queryInfo["queryInfoCardId"] = queryInfoCardId; # 被查询者证件号码
  600. otherDf.loc[otherIndex, '报告查询日期'] = queryInfo["reportTime"];
  601. sanshouDf.loc[sanshouIndex,"身份证号前两位"]=queryInfoCardId[0:2]
  602. # print(queryInfo)
  603. RPTNO = self.getNodeData(headbo, "RPTNO")
  604. self.RPTNO = RPTNO
  605. self.saveNode(headbo)
  606. return queryInfo;
  607. #xml节点入库
  608. def saveNode(self,node):
  609. try:
  610. RPTNO = self.RPTNO
  611. if node.nodeName == "HEADBO":
  612. sql = "insert into "+node.nodeName+"("
  613. # 保存根节点
  614. childNodes = node.childNodes;
  615. for child in childNodes:
  616. sql += child.nodeName+","
  617. sql=sql[:-1]
  618. sql += ")"
  619. sql+="values("
  620. for child in childNodes:
  621. if len(child.childNodes) == 1:
  622. sql +="'"+ child.childNodes[0].data + "',"
  623. else:
  624. sql += "'" + "" + "',"
  625. if sql.endswith(","):
  626. sql = sql[:-1]
  627. sql += ")"
  628. else:#保存其它节点
  629. sql = "insert into " + node.nodeName + "(RPTNO,"
  630. # 保存根节点
  631. childNodes = node.childNodes;
  632. for child in childNodes:
  633. if child.nodeName=='RINFOLS':
  634. continue
  635. sql += child.nodeName + ","
  636. sql = sql[:-1]
  637. sql += ")"
  638. sql += "values("+"'"+RPTNO+"',"
  639. for child in childNodes:
  640. if child.nodeName=='RINFOLS':
  641. continue
  642. if len(child.childNodes) == 1:
  643. sql += "'" + child.childNodes[0].data + "',"
  644. else:
  645. sql += "'" + "" + "',"
  646. if sql.endswith(","):
  647. sql = sql[:-1]
  648. sql += ")"
  649. sqlMap.append(sql)
  650. except:
  651. logger.error(traceback.print_exc())
  652. logger.error(traceback.format_exc())
  653. def saveNodeWithType(self,node,TYPE):
  654. try:
  655. RPTNO = self.RPTNO
  656. sql = "insert into " + node.nodeName + "(TYPE,RPTNO,"
  657. # 保存根节点
  658. childNodes = node.childNodes;
  659. for child in childNodes:
  660. if child.nodeName=='RINFOLS':
  661. continue
  662. sql += child.nodeName + ","
  663. sql = sql[:-1]
  664. sql += ")"
  665. sql += "values("+"'"+TYPE+"','"+RPTNO+"',"
  666. for child in childNodes:
  667. if child.nodeName=='RINFOLS':
  668. continue
  669. if len(child.childNodes) == 1:
  670. sql += "'" + child.childNodes[0].data + "',"
  671. else:
  672. sql += "'" + "" + "',"
  673. if sql.endswith(","):
  674. sql = sql[:-1]
  675. sql += ")"
  676. sqlMap.append(sql)
  677. except:
  678. logger.error(traceback.print_exc())
  679. logger.error(traceback.format_exc())
  680. def parseIdentity(self,reportTime,docXml):
  681. tmpNode =docXml.documentElement.getElementsByTagName("BASEINFO")
  682. if len(tmpNode)>0:
  683. baseInfo = docXml.documentElement.getElementsByTagName("BASEINFO")[0]
  684. print(str(baseInfo))
  685. self.saveNode(baseInfo)
  686. tmpNode = docXml.documentElement.getElementsByTagName("MARRIAGEINFOSG")
  687. identityInfoDf.loc[identityInfoIndex, '性别'] = self.getNodeData(baseInfo,"SEXDESC")
  688. identityInfoDf.loc[identityInfoIndex, '出生日期'] = self.getNodeData(baseInfo,"BIRTHDAY")
  689. identityInfoDf.loc[identityInfoIndex, '国籍'] = self.getNodeData(baseInfo,"NATIONDESC")
  690. identityInfoDf.loc[identityInfoIndex, '户籍地址'] = self.getNodeData(baseInfo,"ADDRESS")
  691. if len(tmpNode)>0:
  692. marriageinfosg = docXml.documentElement.getElementsByTagName("MARRIAGEINFOSG")[0]
  693. self.parseMate(marriageinfosg)
  694. identityInfoDf.loc[identityInfoIndex, '婚姻状况'] = self.getNodeData(marriageinfosg,"MARSTATUDESC")
  695. identityInfoDf.loc[identityInfoIndex, '学历'] = self.getNodeData(baseInfo,"DEGREEDESC")
  696. identityInfoDf.loc[identityInfoIndex, '学位'] = self.getNodeData(baseInfo,"DEGREEDESC")
  697. identityInfoDf.loc[identityInfoIndex, '通讯地址'] = self.getNodeData(baseInfo,"COMMUADDRESS")
  698. identityInfoDf.loc[identityInfoIndex, '就业状况'] = self.getNodeData(baseInfo,"WORKSTATUSDESC")
  699. mobiles = docXml.documentElement.getElementsByTagName("TELEPHONEINFOSGLS")
  700. if len(mobiles)>0:
  701. telephoneinfosgls = docXml.documentElement.getElementsByTagName("TELEPHONEINFOSGLS")[0]
  702. telephoneinfosg = telephoneinfosgls.getElementsByTagName("TELEPHONEINFOSG");
  703. identityInfoDf.loc[identityInfoIndex, '历史手机号码数'] = len(telephoneinfosg)
  704. identityInfoDf.loc[identityInfoIndex, '近3个月手机号码数'] = self.getLastMonthMobileCount(telephoneinfosg, 3, reportTime)
  705. identityInfoDf.loc[identityInfoIndex, '近6个月手机号码数'] = self.getLastMonthMobileCount(telephoneinfosg, 6, reportTime)
  706. identityInfoDf.loc[identityInfoIndex, '近12个月手机号码数'] = self.getLastMonthMobileCount(telephoneinfosg, 12, reportTime)
  707. identityInfoDf.loc[identityInfoIndex, '近24个月手机号码数'] = self.getLastMonthMobileCount(telephoneinfosg, 24, reportTime)
  708. # print(identityInfoDf.to_json(orient="index",force_ascii=False))
  709. def getLastMonthMobileCount(self,telephoneinfosg, month, reportTime):
  710. df = pd.DataFrame()
  711. for i in range(0,len(telephoneinfosg)):
  712. self.saveNode(telephoneinfosg[i])
  713. telephone = self.getNodeData(telephoneinfosg[i],"TELEPHONE")
  714. updatedateinfo= self.getNodeData(telephoneinfosg[i],"UPDATEDATEINFO")
  715. df.loc[i,0] = telephone
  716. df.loc[i,1] = updatedateinfo
  717. # 当前日期
  718. last1MonthDateStr = reportTime
  719. # 最近一个月
  720. lastMonthDate = np.datetime64(last1MonthDateStr, "D") - np.timedelta64(30 * month, 'D')
  721. lastMonthMobileDf = df[df[1] >= str(lastMonthDate)]
  722. return lastMonthMobileDf.shape[0];
  723. #解析配偶信息
  724. def parseMate(self,marriageinfosg):
  725. self.saveNode(marriageinfosg)
  726. mateInfoDf.loc[mateInfoIndex, '姓名'] = self.getNodeData(marriageinfosg,"SPUOSENAME")
  727. mateInfoDf.loc[mateInfoIndex, '证件号码'] = self.getNodeData(marriageinfosg,"CERTNUM")
  728. mateInfoDf.loc[mateInfoIndex, '工作单位'] = self.getNodeData(marriageinfosg,"COMPANY")
  729. mateInfoDf.loc[mateInfoIndex, '联系电话'] = self.getNodeData(marriageinfosg,"TELNUM")
  730. # print(mateInfoDf.to_json(orient="index", force_ascii=False))
  731. # 解析居住信息
  732. def parseLiveInfo(self,docXml):
  733. # residenceinfosgls = docXml.documentElement.getElementsByTagName("RESIDENCEINFOSGLS")
  734. residenceinfosg = docXml.documentElement.getElementsByTagName("RESIDENCEINFOSG");
  735. df = pd.DataFrame()
  736. for i in range(0, len(residenceinfosg)):
  737. self.saveNode(residenceinfosg[i])
  738. resistatusdesc = self.getNodeData(residenceinfosg[i], "RESISTATUSDESC")
  739. address = self.getNodeData(residenceinfosg[i], "ADDRESS")
  740. telnum = self.getNodeData(residenceinfosg[i], "TELNUM")
  741. updatedateinfo = self.getNodeData(residenceinfosg[i], "UPDATEDATEINFO")
  742. df.loc[i, 0] = resistatusdesc
  743. df.loc[i, 1] = address
  744. df.loc[i, 2] = telnum
  745. df.loc[i, 3] = updatedateinfo
  746. if len(residenceinfosg)>0:
  747. liveInfoDf.loc[liveInfoIndex, '居住地址'] = self.getNodeData(residenceinfosg[0],"ADDRESS")
  748. liveInfoDf.loc[liveInfoIndex, '住宅电话'] = self.getNodeData(residenceinfosg[0],"TELNUM")
  749. liveInfoDf.loc[liveInfoIndex, '历史居住地址个数'] = len(residenceinfosg);
  750. curDate = np.datetime64(time.strftime("%Y-%m-%d"));
  751. last3year = str(curDate)[0:4]
  752. last3yearDate = str(int(last3year) - 3) + str(curDate)[4:10]
  753. lastLiveDf = df[df[3] >= last3yearDate];
  754. liveInfoDf.loc[liveInfoIndex, '最近3年内居住地址个数'] = lastLiveDf.index.size ;
  755. houseIndex = df[df[0] == '自置'].index.size > 0
  756. if (houseIndex):
  757. houseStr = '是'
  758. else:
  759. houseStr = '否'
  760. liveInfoDf.loc[liveInfoIndex, '当前居住状况-是否具有自有住房'] = houseStr;
  761. liveInfoDf.loc[liveInfoIndex, '居住状况'] = self.getNodeData(residenceinfosg[0],"RESISTATUSDESC")
  762. liveInfoDf.loc[liveInfoIndex, '信息更新日期'] = self.getNodeData(residenceinfosg[0],"UPDATEDATEINFO")
  763. # print(liveInfoDf.to_json(orient="index", force_ascii=False))
  764. # 解析职业信息
  765. def parseOccupationInfoDf(self,reportTime,docXml):
  766. vocationinfosg = docXml.documentElement.getElementsByTagName("VOCATIONINFOSG");
  767. df = pd.DataFrame()
  768. if len(vocationinfosg)>0:
  769. for i in range(0, len(vocationinfosg)):
  770. # df.loc[i, 0] = self.getNodeData(vocationinfosg[i], "WORDSTATUSDESC")
  771. self.saveNode(vocationinfosg[i])
  772. df.loc[i, 0] = self.getNodeData(vocationinfosg[i], "CPNTYPEDESC")
  773. df.loc[i, 1] = self.getNodeData(vocationinfosg[i], "TRADEDESC")
  774. df.loc[i, 2] = self.getNodeData(vocationinfosg[i], "VOCATIONDESC")
  775. df.loc[i, 3] = self.getNodeData(vocationinfosg[i], "VOCATIONTITLEDESC")
  776. df.loc[i, 4] = self.getNodeData(vocationinfosg[i], "COMPANY")
  777. df.loc[i, 5] = self.getNodeData(vocationinfosg[i], "CPNADDRESS")
  778. df.loc[i, 6] = self.getNodeData(vocationinfosg[i], "CPNTELNUM")
  779. df.loc[i, 7] = self.getNodeData(vocationinfosg[i], "BEGINYEAR")
  780. df.loc[i, 8] = self.getNodeData(vocationinfosg[i], "INFOUPDATEDATE")
  781. occupationInfoDf.loc[occupationInfoIndex, '工作单位'] = self.getNodeData(vocationinfosg[0], "COMPANY")
  782. last3yearDate = utils.getLastMonthDate(reportTime, 12 * 3)
  783. last3yearOccDf = df[df[8] >= last3yearDate]
  784. occupationInfoDf.loc[occupationInfoIndex, '最近3年内工作单位数'] = last3yearOccDf.index.size;
  785. occupationInfoDf.loc[occupationInfoIndex, '单位电话'] = self.getNodeData(vocationinfosg[0], "CPNTELNUM")
  786. try:
  787. minDateIndex = np.argmin(df[7]);
  788. maxDateIndex = np.argmax(df[7]);
  789. rowYearMin = df.loc[minDateIndex, :].dropna()
  790. rowYearMax = df.loc[maxDateIndex, :].dropna()
  791. if rowYearMin[7] != "":
  792. occupationInfoDf.loc[occupationInfoIndex, '最早进入本单位年份距报告日期时长'] = int(
  793. str(np.datetime64(reportTime, "Y"))) - int(rowYearMin[7])
  794. if rowYearMax[7] != "":
  795. occupationInfoDf.loc[occupationInfoIndex, '最新进入本单位年份距报告日期时长'] = int(
  796. str(np.datetime64(reportTime, "Y"))) - int(rowYearMax[7])
  797. except:
  798. logger.error("最早进入本单位年份距报告日期时长解析异常")
  799. occupationInfoDf.loc[occupationInfoIndex, '单位性质'] = self.getNodeData(vocationinfosg[0], "CPNTYPEDESC")
  800. occupationInfoDf.loc[occupationInfoIndex, '单位地址'] = self.getNodeData(vocationinfosg[0], "CPNADDRESS")
  801. occupationInfoDf.loc[occupationInfoIndex, '职业'] = self.getNodeData(vocationinfosg[0], "VOCATIONDESC")
  802. occupationInfoDf.loc[occupationInfoIndex, '行业'] = self.getNodeData(vocationinfosg[0], "TRADEDESC")
  803. occupationInfoDf.loc[occupationInfoIndex, '职务'] = self.getNodeData(vocationinfosg[0], "TITLEDESC")
  804. occupationInfoDf.loc[occupationInfoIndex, '职称'] = self.getNodeData(vocationinfosg[0], "VOCATIONTITLEDESC")
  805. occupationInfoDf.loc[occupationInfoIndex, '进入本单位年份'] =self.getNodeData(vocationinfosg[0], "BEGINYEAR")
  806. occupationInfoDf.loc[occupationInfoIndex, '信息更新日期'] = self.getNodeData(vocationinfosg[0], "INFOUPDATEDATE")
  807. occupationInfoDf.loc[occupationInfoIndex, '历史工作单位数'] = len(vocationinfosg)
  808. # print(occupationInfoDf.to_json(orient="index", force_ascii=False))
  809. # 信贷交易明细汇总
  810. def parseLoanTradeInfo(self,docXml):
  811. credittipsinfo = docXml.documentElement.getElementsByTagName("CREDITTIPSINFO");
  812. if len(credittipsinfo)>0:
  813. briefInfoDf_loanTradeInfo.loc[loanTradeInfoIndex, '个人住房贷款账户数'] = utils.toInt(self.getNodeData(credittipsinfo[0],"ACCOUNTNUM"))
  814. self.saveNode(credittipsinfo[0])
  815. briefInfoDf_loanTradeInfo.loc[loanTradeInfoIndex, '个人商用房贷款(包括商住两用)账户数'] = utils.toInt(self.getNodeData(credittipsinfo[1],"ACCOUNTNUM"))
  816. self.saveNode(credittipsinfo[1])
  817. briefInfoDf_loanTradeInfo.loc[loanTradeInfoIndex, '其他类贷款账户数'] = utils.toInt(self.getNodeData(credittipsinfo[2],"ACCOUNTNUM"))
  818. self.saveNode(credittipsinfo[2])
  819. briefInfoDf_loanTradeInfo.loc[loanTradeInfoIndex, '贷记卡账户数'] = utils.toInt(self.getNodeData(credittipsinfo[3],"ACCOUNTNUM"))
  820. self.saveNode(credittipsinfo[3])
  821. briefInfoDf_loanTradeInfo.loc[loanTradeInfoIndex, '准贷记卡账户数'] = utils.toInt(self.getNodeData(credittipsinfo[4],"ACCOUNTNUM"))
  822. self.saveNode(credittipsinfo[4])
  823. #汇算
  824. moths = [self.getNodeData(credittipsinfo[0], "FIRSTBUSMONTH"),
  825. self.getNodeData(credittipsinfo[1], "FIRSTBUSMONTH"),self.getNodeData(credittipsinfo[2], "FIRSTBUSMONTH")]
  826. moths=utils.get_real_arr(moths)
  827. if len(moths)>0:
  828. otherDf.loc[otherIndex, '首笔贷款发放月份'] = min(moths)
  829. otherDf.loc[otherIndex, '首张贷记卡发卡月份'] = self.getNodeData(credittipsinfo[3], "FIRSTBUSMONTH")
  830. # print(briefInfoDf_loanTradeInfo.to_json(orient="index", force_ascii=False))
  831. #贷款首次交易或者第一张贷记卡开卡日期距今月份数
  832. #juzi
  833. def calcFirstBusMonth(self,reportTime):
  834. try:
  835. firstLoanMonth = str(otherDf.loc[otherIndex, '首笔贷款发放月份'])
  836. firstCreditMonth = str(otherDf.loc[otherIndex, '首张贷记卡发卡月份'])
  837. dateStr = ""
  838. if str(firstLoanMonth) == "nan":
  839. firstLoanMonth = ""
  840. if firstCreditMonth == "nan":
  841. firstCreditMonth = ""
  842. if firstLoanMonth == "" and firstCreditMonth !="":
  843. dateStr = firstCreditMonth
  844. elif firstCreditMonth == "" and firstLoanMonth !="":
  845. dateStr = firstLoanMonth
  846. elif firstCreditMonth == "" and firstLoanMonth =="":
  847. dateStr = ""
  848. else:
  849. dateStr = min(firstCreditMonth,firstLoanMonth)
  850. if dateStr !="":
  851. juziDf.loc[juziIndex, '贷款首次交易或者第一张贷记卡开卡日期距今月份数'] = utils.difMonthReportTime(dateStr,reportTime)
  852. except:
  853. logger.error(traceback.print_exc())
  854. logger.error(traceback.format_exc())
  855. mailUtil = MailUtil();
  856. webhook = 'https://oapi.dingtalk.com/robot/send?access_token=64d8b2c7fed4949e9433b807c7c5559939f1517af8f77c1dacb4de19c6910b56'
  857. mailUtil.dingtalk("号码:" + " 解析错误 " + traceback.format_exc(), webhook)
  858. # 最近一次逾期距今月份数 juzi
  859. def getLastOverdueMonthJz(self, loanMergeDf, creditCardMergeDf, loanPayRecordMergeDf, creditCardPayRecordMergeDf,
  860. reportTime):
  861. try:
  862. result = None;
  863. if np.sum(loanMergeDf['当前逾期期数']) > 0 or np.sum(creditCardMergeDf['当前逾期期数']) > 0:
  864. result = 0
  865. else:
  866. payRcdDf = loanPayRecordMergeDf.sort_values(by=["账户编号", "还款日期"], ascending=(True, False))
  867. # payRcdDf = payRcdDf.groupby(['账户编号']).head(60)
  868. payRcdDf = utils.replacePayRcdStatusOverdue(payRcdDf) # 替换逾期
  869. payRcdDf = payRcdDf[payRcdDf['还款状态'] > 0]
  870. payRcdDf = utils.replacePayRcdStatusOverdue(payRcdDf) # 替换逾期
  871. loanOverdueDate = np.max(payRcdDf['还款日期'])
  872. payRcdDfCredit = creditCardPayRecordMergeDf.sort_values(by=["账户编号", "还款日期"], ascending=(True, False))
  873. payRcdDfCredit = utils.replacePayRcdStatusOverdue(payRcdDfCredit) # 替换逾期
  874. # payRcdDfCredit = payRcdDfCredit.groupby(['账户编号']).head(60)
  875. payRcdDfCredit = payRcdDfCredit[payRcdDfCredit['还款状态'] > 0]
  876. if not payRcdDf.empty or not payRcdDfCredit.empty:
  877. creditOverdueDate = np.max(payRcdDfCredit['还款日期'])
  878. # reportTime = str(np.datetime64(reportTime, "M")) + "-02"
  879. reportTime = utils.get_last_month_first_day_v2(reportTime)
  880. overdueDate = None
  881. if str(loanOverdueDate) != "nan" and str(creditOverdueDate) != "nan":
  882. overdueDate = max([loanOverdueDate, creditOverdueDate])
  883. elif str(loanOverdueDate) == "nan" and str(creditOverdueDate) != "nan":
  884. overdueDate = creditOverdueDate
  885. elif str(loanOverdueDate) != "nan" and str(creditOverdueDate) == "nan":
  886. overdueDate = loanOverdueDate
  887. if overdueDate != None:
  888. result = utils.difMonthReportTime(overdueDate, reportTime)
  889. juziDf.loc[juziIndex, "用户贷记卡或者贷款最近逾期距今月份数"] = result
  890. except:
  891. logger.error(traceback.print_exc())
  892. logger.error(traceback.format_exc())
  893. mailUtil = MailUtil();
  894. webhook = 'https://oapi.dingtalk.com/robot/send?access_token=64d8b2c7fed4949e9433b807c7c5559939f1517af8f77c1dacb4de19c6910b56'
  895. mailUtil.dingtalk("号码:" + " 解析错误 " + traceback.format_exc(), webhook)
  896. def encodeJuzi(self,value):
  897. result = ""
  898. if value == None:
  899. result = 'A'
  900. elif value >=1 and value <3:
  901. result = 'B'
  902. elif value >=3 and value <5:
  903. result = 'C'
  904. elif value >= 3 and value < 5:
  905. result = 'C'
  906. elif value >= 5 and value < 7:
  907. result = 'D'
  908. elif value >= 7 and value < 10:
  909. result = 'E'
  910. elif value >= 10 and value < 12:
  911. result = 'F'
  912. elif value >= 12 and value < 15:
  913. result = 'G'
  914. elif value >= 15 and value < 17:
  915. result = 'H'
  916. elif value >= 17 and value < 20:
  917. result = 'I'
  918. elif value >= 20 and value < 24:
  919. result = 'J'
  920. elif value >= 24 and value < 30:
  921. result = 'K'
  922. elif value >= 30 and value < 36:
  923. result = 'L'
  924. elif value >= 36 and value < 48:
  925. result = 'M'
  926. elif value >= 48:
  927. result = 'N'
  928. return result
  929. # 解析被追偿信息汇总
  930. def parseRecoveryInfoSum(self,docXml):
  931. recoveredinfosumsmry = docXml.documentElement.getElementsByTagName("RECOVEREDINFOSUMSMRY");
  932. recorinfosumsg = docXml.documentElement.getElementsByTagName("RECORINFOSUMSG")
  933. if len(recoveredinfosumsmry)>0:
  934. if len(recorinfosumsg)>0:
  935. self.saveNode(recorinfosumsg[0])
  936. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '资产处置业务账户数'] = utils.toInt(self.getNodeData(recorinfosumsg[0],"ACCOUNTNUM"))
  937. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '资产处置业务余额'] = utils.replaceAmt(self.getNodeData(recorinfosumsg[0],"BALANCE"))
  938. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '垫款业务账户数'] = utils.toInt(self.getNodeData(recorinfosumsg[1],"ACCOUNTNUM"))
  939. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '垫款业务余额'] = utils.replaceAmt(self.getNodeData(recorinfosumsg[1],"BALANCE"))
  940. self.saveNode(recorinfosumsg[1])
  941. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '合计总账户数'] = utils.toInt(self.getNodeData(recoveredinfosumsmry[0],"ACCOUNTNUMSUM"))
  942. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '合计总余额'] = utils.replaceAmt(self.getNodeData(recoveredinfosumsmry[0],"BALANCESUM"))
  943. self.saveNode(recoveredinfosumsmry[0])
  944. # print(briefInfoDf_recoveryInfoSum.to_json(orient="index", force_ascii=False))
  945. # 解析呆账信息汇总
  946. def parseBadDebtsInfoSumDf(self,docXml):
  947. baddebtssmry = docXml.documentElement.getElementsByTagName("BADDEBTSSMRY");
  948. if len(baddebtssmry)>0:
  949. briefInfoDf_badDebtsInfoSum.loc[badDebtsInfoIndex, '账户数'] = utils.toInt(self.getNodeData(baddebtssmry[0],"ACCOUNTNUM"))
  950. briefInfoDf_badDebtsInfoSum.loc[badDebtsInfoIndex, '余额'] = utils.replaceAmt(self.getNodeData(baddebtssmry[0],"BALANCE"));
  951. self.saveNode(baddebtssmry[0])
  952. # print(briefInfoDf_badDebtsInfoSum.to_json(orient="index", force_ascii=False))
  953. #透支及逾期信息汇总
  954. def parseOverdueInfoSum(self,docXml):
  955. overdraftsumsg = docXml.documentElement.getElementsByTagName("OVERDRAFTSUMSG");
  956. df = pd.DataFrame()
  957. if len(overdraftsumsg)>0:
  958. for i in range(0, len(overdraftsumsg)):
  959. df.loc[i, 0] = self.getNodeData(overdraftsumsg[i], "ACCTYPEDESC")
  960. df.loc[i, 1] = self.getNodeData(overdraftsumsg[i], "ACCSUM")
  961. df.loc[i, 2] = self.getNodeData(overdraftsumsg[i], "MONTHSUM")
  962. df.loc[i, 3] = self.getNodeData(overdraftsumsg[i], "OVERDRAFTMAX")
  963. df.loc[i, 4] = self.getNodeData(overdraftsumsg[i], "OVERMONTH")
  964. self.saveNode(overdraftsumsg[i])
  965. if len(overdraftsumsg)>0:
  966. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '非循环贷帐户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[0],"ACCSUM"));
  967. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '非循环贷帐户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[0],"MONTHSUM"));
  968. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '非循环贷帐户单月最高逾期总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[0],"OVERDRAFTMAX"));
  969. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '非循环贷帐户最长逾期月数'] = utils.toInt(self.getNodeData(overdraftsumsg[0],"OVERMONTH"));
  970. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '循环额度下分账户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[1],"ACCSUM"));
  971. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '循环额度下分账户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[1],"MONTHSUM"));
  972. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '循环额度下分账户单月最高逾期总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[1],"OVERDRAFTMAX"));
  973. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '循环额度下分账户最长逾期月数'] = utils.toInt(self.getNodeData(overdraftsumsg[1],"OVERMONTH"));
  974. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '循环贷账户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[2],"ACCSUM"));
  975. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '循环贷账户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[2],"MONTHSUM"));
  976. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '循环贷账户单月最高逾期总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[2],"OVERDRAFTMAX"));
  977. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '循环贷账户最长逾期月数'] = utils.toInt(self.getNodeData(overdraftsumsg[2],"OVERMONTH"));
  978. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '贷记卡账户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[3],"ACCSUM"));
  979. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '贷记卡账户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[3],"MONTHSUM"));
  980. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '贷记卡账户单月逾期总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[3],"OVERDRAFTMAX"));
  981. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '贷记卡账户最长逾期月数'] = utils.toInt(self.getNodeData(overdraftsumsg[3],"OVERMONTH"));
  982. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '准贷记卡账户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[4],"ACCSUM"));
  983. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '准贷记卡账户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[4],"MONTHSUM"));
  984. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '准贷记卡账户单月透支总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[4],"OVERDRAFTMAX"));
  985. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '准贷记卡账户最长透支月数'] = utils.toInt(self.getNodeData(overdraftsumsg[4],"OVERMONTH"));
  986. overdueInfoAccountDf = df[df[1] != ''];
  987. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '该用户所有逾期账户最长逾期/透支月数最大值'] = np.max(overdueInfoAccountDf[4].astype('int'))
  988. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '该用户所有逾期账户数加总'] = np.sum(overdueInfoAccountDf[1].astype('int')) # TODO
  989. # briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '该用户过去5年出现逾期的所有账户数目']=None# TODO
  990. # print(briefInfoDf_overdueInfoSum.to_json(orient="index", force_ascii=False))
  991. # 非循环贷账户信息汇总
  992. def parseLoanAccountInfoSum(self,docXml):
  993. noncyclicalsmry = docXml.documentElement.getElementsByTagName("NONCYCLICALSMRY");
  994. if len(noncyclicalsmry)>0:
  995. # loanAccountInfoSumDf = doFilterCalc(loanAccountInfoSumDf); # 替换为0
  996. #TODO 需要检查是否都有值
  997. # loanAccountInfoSumDf = loanAccountInfoSumDf.reset_index(drop=True)
  998. # row0 = loanAccountInfoSumDf.loc[0, :]
  999. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户管理机构数'] = int(self.getNodeData(noncyclicalsmry[0],"MANAGEORGNUM"))
  1000. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户账户数'] = int(self.getNodeData(noncyclicalsmry[0],"ACCSUM"))
  1001. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户授信总额'] = utils.replaceAmt(self.getNodeData(noncyclicalsmry[0],"CREDITSUM"))
  1002. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户余额'] = utils.replaceAmt(self.getNodeData(noncyclicalsmry[0],"BALANCE"))
  1003. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户6月平均应还款'] = utils.replaceAmt(self.getNodeData(noncyclicalsmry[0],"LATELY6MON"))
  1004. self.saveNode(noncyclicalsmry[0])
  1005. # print(briefInfoDf_loanTradeCreditInfo.to_json(orient="index", force_ascii=False))
  1006. # 循环额度下分账户
  1007. def parseCycleCreditAccountInfoSum(self,docXml):
  1008. cybranchaccsmry = docXml.documentElement.getElementsByTagName("CYBRANCHACCSMRY");
  1009. if len(cybranchaccsmry) > 0:
  1010. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户管理机构数'] = int(self.getNodeData(cybranchaccsmry[0],"MANAGEORGNUM"))
  1011. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户账户数'] = int(self.getNodeData(cybranchaccsmry[0],"ACCSUM"))
  1012. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户授信总额'] = utils.replaceAmt(self.getNodeData(cybranchaccsmry[0],"CREDITSUM"))
  1013. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户余额'] = utils.replaceAmt(self.getNodeData(cybranchaccsmry[0],"BALANCE"))
  1014. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户6月平均应还款'] = utils.replaceAmt(self.getNodeData(cybranchaccsmry[0],"LATELY6MON"))
  1015. self.saveNode(cybranchaccsmry[0])
  1016. # print(briefInfoDf_loanTradeCreditInfo.to_json(orient="index", force_ascii=False))
  1017. # 循环贷账户信息
  1018. def parseCyleLoanAccountInfoSum(self,docXml):
  1019. cyclicalloansmry = docXml.documentElement.getElementsByTagName("CYCLICALLOANSMRY");
  1020. if len(cyclicalloansmry) > 0:
  1021. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环贷账户管理机构数'] = int(self.getNodeData(cyclicalloansmry[0],"MANAGEORGNUM"))
  1022. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环贷账户账户数'] = int(self.getNodeData(cyclicalloansmry[0],"ACCSUM"))
  1023. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环贷账户授信总额'] = utils.replaceAmt(self.getNodeData(cyclicalloansmry[0],"CREDITSUM"))
  1024. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环贷账户余额'] = utils.replaceAmt(self.getNodeData(cyclicalloansmry[0],"BALANCE"))
  1025. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环贷账户6月平均应还款'] = utils.replaceAmt(self.getNodeData(cyclicalloansmry[0],"LATELY6MON"))
  1026. self.saveNode(cyclicalloansmry[0])
  1027. # 解析贷记卡信息汇总,包含准贷记卡
  1028. def parseCreditCardInfoSum(self,docXml):
  1029. debitcardaccsmry = docXml.documentElement.getElementsByTagName("DEBITCARDACCSMRY");
  1030. if len(debitcardaccsmry) > 0:
  1031. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡发卡机构数'] = int(self.getNodeData(debitcardaccsmry[0],"CARDISSUERNUM"))
  1032. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡账户数'] =int(self.getNodeData(debitcardaccsmry[0],"ACCSUM"))
  1033. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡授信总额'] = utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"CREDITSUM"))
  1034. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡单家机构最高授信额'] = utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"CRAMOUNTMAX"))
  1035. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡单家机构最低授信额'] =utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"CRAMOUNTMIN"))
  1036. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡已用额度'] = utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"ALREADYUSED"))
  1037. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡最近6个月平均使用额度'] = utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"LATELY6MONUSE"))
  1038. self.saveNode(debitcardaccsmry[0])
  1039. # 解析贷记卡信息汇总,包含准贷记卡
  1040. def parseCreditCardInfoSumZ(self,docXml):
  1041. zdebitcardaccsmry = docXml.documentElement.getElementsByTagName("ZDEBITCARDACCSMRY");
  1042. if len(zdebitcardaccsmry) > 0:
  1043. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡发卡机构数'] = int(self.getNodeData(zdebitcardaccsmry[0],"CARDISSUERNUM"))
  1044. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡账户数'] =int(self.getNodeData(zdebitcardaccsmry[0],"ACCSUM"))
  1045. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡授信总额'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"CREDITSUM"))
  1046. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡单家机构最高授信额'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"CRAMOUNTMAX"))
  1047. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡单家机构最低授信额'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"CRAMOUNTMIN"))
  1048. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡已用额度'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"OVERDRAFT"))
  1049. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡最近6个月平均使用额度'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"LATELY6MONDRAFT"))
  1050. self.saveNode(zdebitcardaccsmry[0])
  1051. # 相关还款责任
  1052. def parseRepaymentSum(self,docXml):
  1053. repaymentinfosmry = docXml.documentElement.getElementsByTagName("REPAYMENTINFOSMRY");
  1054. for item in repaymentinfosmry:
  1055. self.saveNode(item)
  1056. if len(repaymentinfosmry)>0:
  1057. perAccountNum = 0; # 个人账户数
  1058. orgAccountNum = 0; # 企业账户数
  1059. totalAccountNum = 0; # 总账户数
  1060. guaranteeAccountNum = 0; # 相关还款责任总账户数-担保责任
  1061. otherAccountNum = 0; # 相关还款责任总账户数-其他
  1062. perGuaranteeAmt = 0 # 个人担保金额及其他
  1063. orgGuaranteeAmt = 0 # 企业担保金额及其他
  1064. totalGuaranteeAmt = 0; # 总担保金额
  1065. guaranteeAmt = 0; # 相关还款责任总担保金额
  1066. otherPaymentAmt = 0; # 其他还款责任金额
  1067. perGuaranteeBalance = 0 # 个人担保余额及其他
  1068. orgGuaranteeBalance = 0 # 企业担保余额及其他
  1069. totalGuaranteeBalance = 0; # 总担保余额
  1070. guaranteeBalance = 0; # 相关还款责任总担保余额
  1071. otherPaymentBalance = 0; # 其他还款责任余额
  1072. perGuaranteeNum = self.getNodeData(repaymentinfosmry[0],"ACCSUM")
  1073. perGuaranteeAmtStr = self.getNodeData(repaymentinfosmry[0], "RELPAYRESPSUM")
  1074. perGuaranteeBalanceStr = self.getNodeData(repaymentinfosmry[0], "BALANCE")
  1075. perOtherNum = self.getNodeData(repaymentinfosmry[1], "ACCSUM")
  1076. perOtherAmt = self.getNodeData(repaymentinfosmry[1], "RELPAYRESPSUM")
  1077. perOtherBalance = self.getNodeData(repaymentinfosmry[1], "BALANCE")
  1078. enGuaranteeNum = ""
  1079. enGuaranteeAmt = ""
  1080. enGuaranBalance = ""
  1081. enOtherNum = ""
  1082. enOtherAmt = ""
  1083. enOtherBalance= ""
  1084. if len(repaymentinfosmry)>=3:
  1085. enGuaranteeNum = self.getNodeData(repaymentinfosmry[2], "ACCSUM")
  1086. enGuaranteeAmt = self.getNodeData(repaymentinfosmry[2], "RELPAYRESPSUM")
  1087. enGuaranBalance = self.getNodeData(repaymentinfosmry[2], "BALANCE")
  1088. if len(repaymentinfosmry) >= 4:
  1089. enOtherNum = self.getNodeData(repaymentinfosmry[3], "ACCSUM")
  1090. enOtherAmt = self.getNodeData(repaymentinfosmry[3], "RELPAYRESPSUM")
  1091. enOtherBalance = self.getNodeData(repaymentinfosmry[3], "BALANCE")
  1092. # 计算总账户数
  1093. if perGuaranteeNum != "":
  1094. perAccountNum = perAccountNum + utils.toInt(perGuaranteeNum)
  1095. guaranteeAccountNum = guaranteeAccountNum + utils.toInt(perGuaranteeNum) # 个人担保责任账户数
  1096. if perOtherNum != "":
  1097. perAccountNum = perAccountNum + utils.toInt(perOtherNum) # 其他
  1098. otherAccountNum = otherAccountNum + utils.toInt(perOtherNum) # 其他
  1099. if enGuaranteeNum != None:
  1100. if enGuaranteeNum != "":
  1101. orgAccountNum = orgAccountNum + utils.toInt(enGuaranteeNum)
  1102. guaranteeAccountNum = guaranteeAccountNum + utils.toInt(enGuaranteeNum) # 企业担保责任账户数
  1103. if enOtherNum != "":
  1104. orgAccountNum = orgAccountNum + utils.toInt(enOtherNum) # 其他
  1105. otherAccountNum = otherAccountNum + utils.toInt(enOtherNum) # 其他
  1106. totalAccountNum = perAccountNum + orgAccountNum
  1107. # 计算担保金额
  1108. if perGuaranteeAmtStr != "":
  1109. perGuaranteeAmt = perGuaranteeAmt + utils.replaceAmt(perGuaranteeAmtStr) # 担保
  1110. guaranteeAmt = guaranteeAmt + utils.replaceAmt(perGuaranteeAmtStr) # 担保
  1111. if perOtherAmt != "":
  1112. perGuaranteeAmt = perGuaranteeAmt + utils.replaceAmt(perOtherAmt) # 其他
  1113. otherPaymentAmt = otherPaymentAmt + utils.replaceAmt(perOtherAmt) # 其他
  1114. if enGuaranteeAmt != None:
  1115. if enGuaranteeAmt != "":
  1116. orgGuaranteeAmt = orgGuaranteeAmt + utils.replaceAmt(enGuaranteeAmt) # 担保
  1117. guaranteeAmt = guaranteeAmt + utils.replaceAmt(enGuaranteeAmt) # 担保
  1118. if enOtherAmt != "":
  1119. orgGuaranteeAmt = orgGuaranteeAmt + utils.replaceAmt(enOtherAmt) # 其他
  1120. otherPaymentAmt = otherPaymentAmt + utils.replaceAmt(enOtherAmt) # 其他
  1121. totalGuaranteeAmt = perGuaranteeAmt + orgGuaranteeAmt
  1122. # 计算余额
  1123. if perGuaranteeBalanceStr != "":
  1124. perGuaranteeBalance = perGuaranteeBalance + utils.replaceAmt(perGuaranteeBalanceStr)
  1125. guaranteeBalance = guaranteeBalance + utils.replaceAmt(perGuaranteeBalanceStr) # 个人担保余额
  1126. if perOtherBalance != "":
  1127. perGuaranteeBalance = perGuaranteeBalance + utils.replaceAmt(perOtherBalance) # 其他
  1128. otherPaymentBalance = otherPaymentBalance + utils.replaceAmt(perOtherBalance) # 其他
  1129. if enGuaranBalance != None:
  1130. if enGuaranBalance != "":
  1131. orgGuaranteeBalance = orgGuaranteeBalance + utils.replaceAmt(enGuaranBalance)
  1132. guaranteeBalance = guaranteeBalance + utils.replaceAmt(enGuaranBalance) # 企业担保余额
  1133. if enOtherBalance != "":
  1134. orgGuaranteeBalance = orgGuaranteeBalance + utils.replaceAmt(enOtherBalance)
  1135. otherPaymentBalance = otherPaymentBalance + utils.replaceAmt(enOtherBalance) # 其他
  1136. totalGuaranteeBalance = perGuaranteeBalance + orgGuaranteeBalance
  1137. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总账户数(担保+其他+个人+企业)'] = totalAccountNum
  1138. briefInfoDf_loanTradeCreditInfo.loc[
  1139. loanTradeCreditInfoIndex, '相关还款责任总担保金额+总还款责任金额(个人+企业)'] = totalGuaranteeAmt
  1140. briefInfoDf_loanTradeCreditInfo.loc[
  1141. loanTradeCreditInfoIndex, '相关还款责任账户总担保余额+总其他余额(个人+企业)'] = totalGuaranteeBalance
  1142. if totalGuaranteeAmt != 0:
  1143. briefInfoDf_loanTradeCreditInfo.loc[
  1144. loanTradeCreditInfoIndex, '相关还款责任账户总担保余额+总其他余额(个人+企业)/相关还款责任账户总担保金额+总其他金额(个人+企业)'] = \
  1145. round(totalGuaranteeBalance / totalGuaranteeAmt, 2)
  1146. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任担保总账户数-个人'] = perAccountNum
  1147. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保金额-个人'] = perGuaranteeAmt
  1148. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保余额-个人'] = perGuaranteeBalance
  1149. if perGuaranteeBalance != 0:
  1150. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保余额-个人/相关还款责任总担保金额-个人'] = round(
  1151. perGuaranteeBalance / perGuaranteeBalance, 2)
  1152. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总账户数-企业'] = orgAccountNum
  1153. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保金额-企业'] = orgGuaranteeAmt
  1154. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保余额-企业'] = orgGuaranteeBalance
  1155. if orgGuaranteeAmt != 0:
  1156. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保余额-企业/相关还款责任总担保金额-企业'] = round(
  1157. orgGuaranteeBalance / orgGuaranteeAmt, 2)
  1158. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总账户数-担保责任'] = guaranteeAccountNum
  1159. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保金额-担保责任'] = guaranteeAmt
  1160. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任账户总担保余额-担保责任'] = guaranteeBalance
  1161. if guaranteeAmt != 0:
  1162. briefInfoDf_loanTradeCreditInfo.loc[
  1163. loanTradeCreditInfoIndex, '相关还款责任总担保余额-担保责任/相关还款责任总担保金额-担保责任'] = round(
  1164. guaranteeBalance / guaranteeAmt, 2)
  1165. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总账户数-其他'] = otherAccountNum
  1166. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保金额-其他'] = otherPaymentAmt
  1167. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任总担保余额-其他'] = otherPaymentBalance
  1168. if otherPaymentAmt != 0:
  1169. briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '相关还款责任账户总担保余额-其他/相关还款责任账户总担保金额-其他'] = round(otherPaymentBalance / otherPaymentAmt, 2)
  1170. # print(briefInfoDf_loanTradeCreditInfo.to_json(orient="index", force_ascii=False))
  1171. #解析公共信息汇总
  1172. def parsePublicInfoBrief(self,docXml):
  1173. comminfosmry = docXml.documentElement.getElementsByTagName("COMMINFOSMRY")
  1174. for item in comminfosmry:
  1175. self.saveNode(item)
  1176. if len(comminfosmry)>0:
  1177. publicInfoBriefDf.loc[publicInfoBriefIndex, '欠税信息-记录数'] = utils.toInt(self.getNodeData(comminfosmry[0],"RECORDNUM"))
  1178. publicInfoBriefDf.loc[publicInfoBriefIndex, '欠税信息-涉及金额'] = utils.replaceAmt(self.getNodeData(comminfosmry[0],"INVOLVEMONEY"))
  1179. publicInfoBriefDf.loc[publicInfoBriefIndex, '民事判决信息-记录数'] = utils.toInt(self.getNodeData(comminfosmry[1],"RECORDNUM"))
  1180. publicInfoBriefDf.loc[publicInfoBriefIndex, '民事判决信息-涉及金额'] = utils.replaceAmt(self.getNodeData(comminfosmry[1],"INVOLVEMONEY"))
  1181. publicInfoBriefDf.loc[publicInfoBriefIndex, '强制执行信息-记录数'] = utils.toInt(self.getNodeData(comminfosmry[2],"RECORDNUM"))
  1182. publicInfoBriefDf.loc[publicInfoBriefIndex, '强制执行信息-涉及金额'] = utils.replaceAmt(self.getNodeData(comminfosmry[2],"INVOLVEMONEY"))
  1183. publicInfoBriefDf.loc[publicInfoBriefIndex, '行政处罚信息-记录数'] = utils.toInt(self.getNodeData(comminfosmry[3],"RECORDNUM"))
  1184. publicInfoBriefDf.loc[publicInfoBriefIndex, '行政处罚信息-涉及金额'] = utils.replaceAmt(self.getNodeData(comminfosmry[3],"INVOLVEMONEY"))
  1185. # 解析查询信息汇总
  1186. def parseQueryRecordSum(self,docXml):
  1187. queryrecordsumsg = docXml.documentElement.getElementsByTagName("QUERYRECORDSUMSG")
  1188. if len(queryrecordsumsg) > 0:
  1189. self.saveNode(queryrecordsumsg[0])
  1190. queryRecordSumDf.loc[queryRecordSumIndex, '近1月内的查询机构数-贷款审批'] = int(self.getNodeData(queryrecordsumsg[0],"LAST1ORGSP"))
  1191. queryRecordSumDf.loc[queryRecordSumIndex, '近1月内的查询机构数-信用卡审批'] = int(self.getNodeData(queryrecordsumsg[0],"LAST1CREDITSP"))
  1192. queryRecordSumDf.loc[queryRecordSumIndex, '近1月内的查询次数-贷款审批'] = int(self.getNodeData(queryrecordsumsg[0],"NUMSP"))
  1193. queryRecordSumDf.loc[queryRecordSumIndex, '近1月内的查询次数-信用卡审批'] = int(self.getNodeData(queryrecordsumsg[0],"NUMCREDITSP"))
  1194. queryRecordSumDf.loc[queryRecordSumIndex, '近1月内的查询次数-本人查询'] = int(self.getNodeData(queryrecordsumsg[0],"LAST1NUMSELF"))
  1195. queryRecordSumDf.loc[queryRecordSumIndex, '近2年内的查询次数-贷后管理'] = int(self.getNodeData(queryrecordsumsg[0],"L2YNUMDH"))
  1196. queryRecordSumDf.loc[queryRecordSumIndex, '近2年内的查询次数-担保资格审查'] = int(self.getNodeData(queryrecordsumsg[0],"L2YNUMDBZG"))
  1197. # print(queryRecordSumDf.to_json(orient="index", force_ascii=False))
  1198. # 解析查询记录明细
  1199. def parseQueryInfoDetail(self,reportTime,docXml):
  1200. queryRecordsg = docXml.documentElement.getElementsByTagName("QUERYRECORDSG");
  1201. if len(queryRecordsg)>0:
  1202. df = pd.DataFrame()
  1203. for i in range(0, len(queryRecordsg)):
  1204. self.saveNode(queryRecordsg[i])
  1205. df.loc[i, 1] = self.getNodeData(queryRecordsg[i], "QUERYDATE")
  1206. df.loc[i, 2] = self.getNodeData(queryRecordsg[i], "QUERYORG")
  1207. queryReson = self.getNodeData(queryRecordsg[i], "QUERYREASONDESC")
  1208. df.loc[i, 3] = queryReson
  1209. queryRecordDetailDf.loc[queryRecordDetailIndex, '近1月查询次数'] =qip.getLastMonthQueryTimes(df, 1, "",reportTime)
  1210. queryRecordDetailDf.loc[queryRecordDetailIndex, '近3月查询次数'] =qip.getLastMonthQueryTimes(df, 3, "",reportTime)
  1211. queryRecordDetailDf.loc[queryRecordDetailIndex, '近6月查询次数'] =qip.getLastMonthQueryTimes(df, 6, "",reportTime)
  1212. queryRecordDetailDf.loc[queryRecordDetailIndex, '近12月查询次数'] =qip.getLastMonthQueryTimes(df, 12, "",reportTime)
  1213. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近1个月查询机构数'] =qip.getLastMonthQueryOrgTimes(df, 1, "", reportTime)
  1214. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近3个月查询机构数'] =qip.getLastMonthQueryOrgTimes(df, 3, "", reportTime)
  1215. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近6个月查询机构数'] =qip.getLastMonthQueryOrgTimes(df, 6, "", reportTime)
  1216. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近12个月查询机构数'] =qip.getLastMonthQueryOrgTimes(df, 12, "", reportTime)
  1217. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近24个月查询机构数'] =qip.getLastMonthQueryOrgTimes(df, 24, "", reportTime)
  1218. queryRecordDetailDf.loc[queryRecordDetailIndex, '近3月查询次数贷款审批'] =qip.getLastMonthQueryTimes(df, 3, consts.loanApprove, reportTime)
  1219. queryRecordDetailDf.loc[queryRecordDetailIndex, '近3月查询次数信用卡审批'] =qip.getLastMonthQueryTimes(df, 3, consts.creditCard, reportTime)
  1220. queryRecordDetailDf.loc[queryRecordDetailIndex, '近6月查询次数贷款审批'] =qip.getLastMonthQueryTimes(df, 6, consts.loanApprove, reportTime)
  1221. queryRecordDetailDf.loc[queryRecordDetailIndex, '近6月查询次数信用卡审批'] = qip.getLastMonthQueryTimes(df, 6, consts.creditCard, reportTime)
  1222. queryRecordDetailDf.loc[queryRecordDetailIndex, '近12月查询次数贷款审批'] = qip.getLastMonthQueryTimes(df, 12, consts.loanApprove, reportTime)
  1223. queryRecordDetailDf.loc[queryRecordDetailIndex, '近12月查询次数信用卡审批'] =qip.getLastMonthQueryTimes(df, 12, consts.creditCard, reportTime)
  1224. queryRecordDetailDf.loc[queryRecordDetailIndex, '近3月查询机构数贷款审批'] =qip.getLastMonthQueryOrgTimes(df, 3, consts.loanApprove, reportTime)
  1225. queryRecordDetailDf.loc[queryRecordDetailIndex, '近3月查询机构数信用卡审批'] =qip.getLastMonthQueryOrgTimes(df, 3, consts.creditCard, reportTime)
  1226. queryRecordDetailDf.loc[queryRecordDetailIndex, '近6月查询机构数贷款审批'] =qip.getLastMonthQueryOrgTimes(df, 6, consts.loanApprove, reportTime)
  1227. queryRecordDetailDf.loc[queryRecordDetailIndex, '近6月查询机构数信用卡审批'] = qip.getLastMonthQueryOrgTimes(df, 6, consts.creditCard,reportTime)
  1228. queryRecordDetailDf.loc[queryRecordDetailIndex, '近12月查询机构数贷款审批'] = qip.getLastMonthQueryOrgTimes(df, 12, consts.loanApprove, reportTime)
  1229. queryRecordDetailDf.loc[queryRecordDetailIndex, '近12月查询机构数信用卡审批'] = qip.getLastMonthQueryOrgTimes(df, 12, consts.creditCard,reportTime)
  1230. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近3个月担保资格审查查询次数'] = qip.getLastMonthQueryTimes(df, 3, consts.insuranceAprove,reportTime)
  1231. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近6个月担保资格审查查询次数'] = qip.getLastMonthQueryTimes(df, 6, consts.insuranceAprove,reportTime)
  1232. queryRecordDetailDf.loc[queryRecordDetailIndex, '近12个月担保资格审查查询次数'] = qip.getLastMonthQueryTimes(df, 12, consts.insuranceAprove,reportTime)
  1233. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近6个月贷后管理查询次数'] = qip.getLastMonthQueryTimes(df, 6, consts.loanAfterMgr,reportTime)
  1234. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近12个月贷后管理查询次数'] = qip.getLastMonthQueryTimes(df, 12, consts.loanAfterMgr,reportTime)
  1235. queryRecordDetailDf.loc[queryRecordDetailIndex, '最后一次查询距离现在的月数贷款审批'] = qip.getLastTimeQueryMonth(df, consts.loanApprove,reportTime)
  1236. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近24个月贷后管理查询次数'] = qip.getLastMonthQueryTimes(df, 24, consts.loanAfterMgr, reportTime)
  1237. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近24个月贷款审批审批次数'] = qip.getLastMonthQueryTimes(df, 24, consts.loanApprove, reportTime)
  1238. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近24个月信用卡审批查询次数'] = qip.getLastMonthQueryTimes(df, 24, consts.creditCard,reportTime)
  1239. queryRecordDetailDf.loc[queryRecordDetailIndex, '最近24个月担保资格审查查询次数'] = qip.getLastMonthQueryTimes(df, 24, consts.insuranceAprove,reportTime)
  1240. #三寿 100年所有信用卡审批
  1241. sanshouDf.loc[sanshouIndex, '贷后管理最近3个月内的机构查询次数'] = qip.getLastMonthQueryTimes(df, 3, consts.loanAfterMgr,reportTime)
  1242. sanshouDf.loc[sanshouIndex, '信用卡审批所有机构查询次数'] =qip.getLastMonthQueryTimes(df, 12*100, consts.creditCard, reportTime)
  1243. sanshouDf.loc[sanshouIndex, '所有本人查询次数'] = qip.getSelfLastMonthQueryTimes(df, 12 * 100,reportTime)
  1244. sanshouDf.loc[sanshouIndex, '最近1年内本人查询次数'] = qip.getSelfLastMonthQueryTimes(df, 12, reportTime)
  1245. sanshouDf.loc[sanshouIndex, '最近2年内本人查询次数'] = qip.getSelfLastMonthQueryTimes(df, 24, reportTime)
  1246. # print(queryRecordDetailDf.to_json(orient="index", force_ascii=False))
  1247. def parseHousingFundRcd(self,reportTime,docXml):
  1248. housingfund = docXml.documentElement.getElementsByTagName("HOUSINGFUND");
  1249. if len(housingfund) >0 :
  1250. df = pd.DataFrame()
  1251. for i in range(0, len(housingfund)):
  1252. self.saveNode(housingfund[i])
  1253. df.loc[i, 0] = self.getNodeData(housingfund[i], "ADDRESSDESC")#参缴地
  1254. df.loc[i, 1] = self.getNodeData(housingfund[i], "PAYDATE")#参缴日期
  1255. df.loc[i, 2] = self.getNodeData(housingfund[i], "STATUSDESC")#缴费状态
  1256. df.loc[i, 3] = self.getNodeData(housingfund[i], "BEGINMONTH")#初缴月份
  1257. df.loc[i, 4] = self.getNodeData(housingfund[i], "ENDMONTH")#缴至月份
  1258. df.loc[i, 5] = self.getNodeData(housingfund[i], "COMPROPORTION")#个人存缴比例
  1259. df.loc[i, 6] = self.getNodeData(housingfund[i], "PEPROPORTION")#个人存缴比例
  1260. df.loc[i, 7] = utils.replaceAmt(self.getNodeData(housingfund[i], "MONTHMONEY"))#月缴存额
  1261. df.loc[i, 8] = self.getNodeData(housingfund[i], "COMPANY")#缴费单位
  1262. df.loc[i, 9] = self.getNodeData(housingfund[i], "UPDATEDATE")#信息更新日期
  1263. lastHousingFundRcdDf = df.sort_values(by=9, ascending=(False)).reset_index(drop=True)
  1264. lastHousingFundRcdDf = lastHousingFundRcdDf[0:1] # 最新
  1265. row1 = lastHousingFundRcdDf.loc[0, :].dropna().reset_index(drop=True)
  1266. housingFundRcdDf.loc[housingFundRcdIndex, '参缴地'] = row1[0]
  1267. housingFundRcdDf.loc[housingFundRcdIndex, '参缴日期'] = row1[1]
  1268. housingFundRcdDf.loc[housingFundRcdIndex, '初缴月份'] = row1[3] # 初缴日期
  1269. housingFundRcdDf.loc[housingFundRcdIndex, '缴至月份'] = row1[4]
  1270. housingFundRcdDf.loc[housingFundRcdIndex, '缴费状态'] = row1[2]
  1271. housingFundRcdDf.loc[housingFundRcdIndex, '月缴存额'] = row1[7]
  1272. housingFundRcdDf.loc[housingFundRcdIndex, '个人存缴比例'] = row1[6]
  1273. housingFundRcdDf.loc[housingFundRcdIndex, '单位存缴比例'] = row1[5]
  1274. housingFundRcdDf.loc[housingFundRcdIndex, '缴费单位'] = row1[8] # 扣缴单位
  1275. housingFundRcdDf.loc[housingFundRcdIndex, '信息更新日期'] = row1[9]
  1276. lastDateStr = utils.getLastMonthDate(reportTime, 12)
  1277. avgHousingFundDf = df[df[4] >= lastDateStr]
  1278. housingFundRcdDf.loc[housingFundRcdIndex, '最近1年公积金平均值'] = round(np.mean(avgHousingFundDf[7]), 2)
  1279. lastDateStr = utils.getLastMonthDate(reportTime, 12 * 3)
  1280. avgHousingFundDf = df[df[4] >= lastDateStr]
  1281. housingFundRcdDf.loc[housingFundRcdIndex, '最近3年公积金平均值'] = round(np.mean(avgHousingFundDf[7]), 2)
  1282. # print(housingFundRcdDf.to_json(orient="index", force_ascii=False))
  1283. # 合并被追偿信息
  1284. def mergeRecoveryInfoDf(self, reportTime,docXml):
  1285. tmpNode = docXml.documentElement.getElementsByTagName("FORCEDREPAYINFOBOLS");
  1286. recoveryInfoMergeDf = pd.DataFrame(columns=dfParser.dfHeaderRecoveryInfo)#合并df
  1287. if len(tmpNode)>0:
  1288. forcedrepayinfobols = docXml.documentElement.getElementsByTagName("FORCEDREPAYINFOBOLS")[0]
  1289. creditacctinfobo = forcedrepayinfobols.getElementsByTagName("CREDITACCTINFOBO");
  1290. for i in range(0,len(creditacctinfobo)):
  1291. creditbaseinfobo = creditacctinfobo[i].getElementsByTagName("CREDITBASEINFOBO")[0]
  1292. self.saveNodeWithType(creditbaseinfobo,"FORCEDREPAYINFOBOLS")
  1293. newperformancebo = creditacctinfobo[i].getElementsByTagName("NEWPERFORMANCEBO")[0]
  1294. self.saveNodeWithType(newperformancebo,"FORCEDREPAYINFOBOLS")
  1295. # latemonthlyperformancebo = creditacctinfobo[i].getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  1296. # latemonthlyperformancebo = latemonthlyperformancebo[0]
  1297. specialtradebaseinfosg = creditacctinfobo[i].getElementsByTagName("SPECIALTRADEBASEINFOSG")
  1298. recoveryInfoDf = pd.DataFrame(columns=dfParser.dfHeaderCreditCard, index=[0])
  1299. recoveryInfoDf.loc[0, '账户编号'] = self.getNodeData(creditbaseinfobo,"ACCTNO")
  1300. recoveryInfoDf.loc[0, '管理机构'] = self.getNodeData(creditbaseinfobo,"BUSIORGCODE")
  1301. recoveryInfoDf.loc[0, '业务种类'] = self.getNodeData(creditbaseinfobo,"LOANTYPEDESC")
  1302. recoveryInfoDf.loc[0, '债权接收日期'] = self.getNodeData(creditbaseinfobo,"OPENDATE")
  1303. recoveryInfoDf.loc[0, '债权金额'] = utils.replaceAmt(self.getNodeData(creditbaseinfobo,"LOANAMT"))
  1304. recoveryInfoDf.loc[0, '债权转移时的还款状态'] = self.getNodeData(creditbaseinfobo,"RPYACCOUNTSTATUSDESC")
  1305. recoveryInfoDf.loc[0, '账户状态'] = self.getNodeData(newperformancebo,"ACCTSTATUSDESC")
  1306. accountStatus = self.getNodeData(newperformancebo,"ACCTSTATUSDESC")# 账户状态
  1307. # if accountStatus == "":
  1308. # accountStatus = self.getNodeData(latemonthlyperformancebo, "ACCTSTATUDESC")
  1309. if len(specialtradebaseinfosg)>0:
  1310. self.saveNodeWithType(specialtradebaseinfosg[0],"FORCEDREPAYINFOBOLS")
  1311. recoveryInfoDf.loc[0, '特殊交易类型'] = self.getNodeData(specialtradebaseinfosg[0],"TRANTYPEDESC")
  1312. recoveryInfoDf.loc[0, '发生日期'] = self.getNodeData(specialtradebaseinfosg[0],"TRANDATE")
  1313. recoveryInfoDf.loc[0, '变更月份'] = utils.toInt(self.getNodeData(specialtradebaseinfosg[0],"TRANMONTH"))
  1314. recoveryInfoDf.loc[0, '发生金额'] = utils.replaceAmt(self.getNodeData(specialtradebaseinfosg[0],"TRANAMT"))
  1315. recoveryInfoDf.loc[0, '明细记录'] = self.getNodeData(specialtradebaseinfosg[0],"DETRECORD")
  1316. if accountStatus == "催收":
  1317. recoveryInfoDf.loc[0, '余额'] = utils.replaceAmt(self.getNodeData(newperformancebo,"BALANCE"))
  1318. recoveryInfoDf.loc[0, '最近一次还款日期'] =self.getNodeData(newperformancebo, "REPAYDATE");
  1319. else:
  1320. recoveryInfoDf.loc[0, '账户关闭日期'] = self.getNodeData(newperformancebo,"SETTLEDATE")
  1321. # recoveryInfoDf.loc[0, '截至日期'] = self.getNodeData(newperformancebo,"DUEDATE")
  1322. recoveryInfoMergeDf = pd.concat([recoveryInfoMergeDf, recoveryInfoDf], axis=0,ignore_index=True);
  1323. return recoveryInfoMergeDf
  1324. # 合并贷款记录dataframe为宽表
  1325. def mergeLoanDf(self, reportTime,docXml,type):
  1326. tmpNode = docXml.documentElement.getElementsByTagName(type)
  1327. loanAccountDfs = []
  1328. if len(tmpNode)>0:
  1329. noloopcreditaccountbols = docXml.documentElement.getElementsByTagName(type)[0]
  1330. creditacctinfobo = noloopcreditaccountbols.getElementsByTagName("CREDITACCTINFOBO");
  1331. loanDf = pd.DataFrame(columns=dfParser.dfHeaderLoan, index=[0])
  1332. for i in range(0, len(creditacctinfobo)):
  1333. dfObj = {}
  1334. loanDfObj = loanDf.to_json(orient="index",force_ascii=False)
  1335. loanDfObj = json.loads(loanDfObj)['0']
  1336. creditbaseinfobo = creditacctinfobo[i].getElementsByTagName("CREDITBASEINFOBO")[0]
  1337. self.saveNodeWithType(creditbaseinfobo,type)
  1338. newperformancebo = creditacctinfobo[i].getElementsByTagName("NEWPERFORMANCEBO")[0]
  1339. self.saveNodeWithType(newperformancebo,type)
  1340. latemonthlyperformancebo = creditacctinfobo[i].getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  1341. latemonthlyperformancebo = latemonthlyperformancebo[0]
  1342. self.saveNodeWithType(latemonthlyperformancebo,type)
  1343. specialtradebaseinfosg = creditacctinfobo[i].getElementsByTagName("SPECIALTRADEBASEINFOSG")
  1344. fiveyearhisrpyinfols = creditacctinfobo[i].getElementsByTagName("FIVEYEARHISRPYINFOSG")
  1345. loanDfObj['账户编号'] = self.getNodeData(creditbaseinfobo, "ACCTNO")
  1346. loanDfObj['管理机构'] = self.getNodeData(creditbaseinfobo, "BUSIORGCODE")
  1347. loanDfObj['账户标识'] = self.getNodeData(creditbaseinfobo, "ACCTCODE")
  1348. loanDfObj['开立日期'] = self.getNodeData(creditbaseinfobo, "OPENDATE")
  1349. loanDfObj['到期日期'] = self.getNodeData(creditbaseinfobo, "DUEDATE")
  1350. if type=='LOOPCREDITACCOUNTBOLS':#循环贷款账户
  1351. loanDfObj['借款金额(本金)'] = utils.replaceAmt(self.getNodeData(creditbaseinfobo, "ACCTCREDLINE"))
  1352. else:
  1353. loanDfObj['借款金额(本金)'] = utils.replaceAmt(self.getNodeData(creditbaseinfobo, "LOANAMT"))
  1354. loanDfObj['账户币种'] = self.getNodeData(creditbaseinfobo, "MONEYTYPEDESC")
  1355. loanDfObj['业务种类'] = self.getNodeData(creditbaseinfobo, "LOANTYPEDESC")
  1356. loanDfObj['担保方式'] = self.getNodeData(creditbaseinfobo, "GUARMODEDESC")
  1357. loanDfObj['还款期数'] = utils.toInt(self.getNodeData(creditbaseinfobo, "REPAYPRD"))
  1358. loanDfObj['还款频率'] = self.getNodeData(creditbaseinfobo, "REPAYFREQCYDESC")
  1359. loanDfObj['还款方式'] = self.getNodeData(creditbaseinfobo, "REPAYDESC")
  1360. loanDfObj['共同借款标志'] = self.getNodeData(creditbaseinfobo, "COMMBORROWERMAKERDESC")
  1361. # loanDfObj['截至日期'] = formatDateJz(df4[0]);
  1362. accountStatus = self.getNodeData(latemonthlyperformancebo, "ACCTSTATUDESC")
  1363. if accountStatus == "":
  1364. accountStatus = self.getNodeData(newperformancebo,"ACCTSTATUSDESC")
  1365. loanDfObj['账户状态'] = accountStatus;
  1366. if accountStatus != "结清" and accountStatus != "呆账" and accountStatus != "转出":
  1367. loanDfObj['五级分类'] = self.getNodeData(latemonthlyperformancebo, "FIVECATEDESC");
  1368. loanDfObj['余额(本金)'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "BUSIBAL"))
  1369. loanDfObj['剩余还款期数'] = utils.toInt(self.getNodeData(latemonthlyperformancebo, "REMREPPRD"))
  1370. loanDfObj['本月应还款'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "CURRPYAMT"))
  1371. loanDfObj['应还款日'] = self.getNodeData(latemonthlyperformancebo, "SETTDATE");
  1372. loanDfObj['本月实还款'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "ACTRPYAMT"))
  1373. loanDfObj['最近一次还款日期'] = self.getNodeData(latemonthlyperformancebo, "LATRPYDATE");
  1374. loanDfObj['当前逾期期数'] = utils.toInt(self.getNodeData(latemonthlyperformancebo, "OVERDPRD"))
  1375. loanDfObj['当前逾期总额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "TOTOVERD"))
  1376. loanDfObj['逾期31-60天未还本金'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "OVERD3160PRINC"))
  1377. loanDfObj['逾期61-90天未还本金'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "OVERD6190PRINC"))
  1378. loanDfObj['逾期91-180天未还本金'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "OVERD91180PRINC"))
  1379. loanDfObj['逾期180天以上未还本金'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "OVERDPRINCOVE180"))
  1380. # loanDfObj['截至日期月份'] = utils.difMonthReportTime(formatDateJz(df4[0]), reportTime); # 截止日期离报告时间月份
  1381. elif accountStatus == "结清":
  1382. loanDfObj['账户关闭日期'] = self.getNodeData(newperformancebo,"SETTLEDATE")
  1383. elif accountStatus == "转出":
  1384. loanDfObj['转出月份'] = self.getNodeData(newperformancebo,"ROLLOUTDATE")
  1385. elif accountStatus == "呆账":
  1386. loanDfObj['余额(本金)'] = utils.replaceAmt(self.getNodeData(newperformancebo,"BALANCE"))
  1387. loanDfObj['最近一次还款日期'] = self.getNodeData(newperformancebo, "REPAYDATE")
  1388. loanDfObj['管理机构类型'] = self.getNodeData(creditbaseinfobo, "MANAGEORGTYPEDESC")
  1389. # loanDf = pd.DataFrame(loanDfObj)
  1390. dfObj["loanDf"] = loanDfObj;
  1391. #计算流动负债,汇算才需要计算
  1392. # try:
  1393. # self.getDebt(loanDf,reportTime)
  1394. # except Exception:
  1395. # logger.error(traceback.print_exc())
  1396. # logger.error(traceback.format_exc())
  1397. # 解析还款记录
  1398. loanPayRecord = None
  1399. # 特殊交易
  1400. specialTradeDf = None
  1401. # if(len(fiveyearhisrpyinfols)>0):
  1402. # fiveyearhisrpyinfols = fiveyearhisrpyinfols[0]
  1403. if accountStatus == "正常": # 正常
  1404. recordIndexBegin = 11
  1405. loanPayRecord = self.mergeLoanPayRecordDf(fiveyearhisrpyinfols, loanPayRecord)
  1406. specialTradeDf = self.mergeLoanSpecialTrade(specialtradebaseinfosg, specialTradeDf)
  1407. elif accountStatus == "逾期": # 如果长度小于12后续无需处理
  1408. # 14 11 有提前最新还款记录的为14
  1409. recordIndexBegin = 11
  1410. loanPayRecord = self.mergeLoanPayRecordDf(fiveyearhisrpyinfols, loanPayRecord)
  1411. specialTradeDf = self.mergeLoanSpecialTrade(specialtradebaseinfosg, specialTradeDf)
  1412. elif accountStatus == "结清":
  1413. recordIndexBegin = 9
  1414. loanPayRecord = self.mergeLoanPayRecordDf(fiveyearhisrpyinfols, loanPayRecord)
  1415. specialTradeDf = self.mergeLoanSpecialTrade(specialtradebaseinfosg, specialTradeDf)
  1416. elif accountStatus == "呆账" or accountStatus == "转出":
  1417. recordIndexBegin = 9
  1418. loanPayRecord = self.mergeLoanPayRecordDf(fiveyearhisrpyinfols, loanPayRecord)
  1419. specialTradeDf = self.mergeLoanSpecialTrade(specialtradebaseinfosg, specialTradeDf)
  1420. else:
  1421. loanPayRecord = self.mergeLoanPayRecordDf(fiveyearhisrpyinfols, loanPayRecord)
  1422. specialTradeDf = self.mergeLoanSpecialTrade(specialtradebaseinfosg, specialTradeDf)
  1423. print("===================还款状态不满足条件===================#"+self.getNodeData(creditbaseinfobo, "ACCTNO")+"#"+accountStatus)
  1424. dfObj["loanPayRecordDf"] = loanPayRecord
  1425. dfObj["specialTradeDf"] = specialTradeDf
  1426. loanAccountDfs.append(dfObj)
  1427. return loanAccountDfs
  1428. #计算流动负债
  1429. def getDebt(self, loanDf, reportTime):
  1430. if loanDf.loc[0, '账户状态'] != '结清' and loanDf.loc[0, '业务种类'] != '个人住房商业贷款' \
  1431. and loanDf.loc[0, '业务种类'] != '个人商用房(含商住两用)贷款' and loanDf.loc[0, '业务种类'] != '个人住房公积金贷款' and loanDf.loc[
  1432. 0, '业务种类'] != '个人汽车消费贷款':
  1433. # term1 / term2 / term3
  1434. term1 = None
  1435. term2 = None
  1436. term3 = None
  1437. debt_f12 = 0
  1438. payRate = loanDf.loc[0, '还款频率']
  1439. payDue = loanDf.loc[0, '还款期数']
  1440. payRemainderDue = loanDf.loc[0, '剩余还款期数']
  1441. openDate = loanDf.loc[0, '开立日期']
  1442. expireDate = loanDf.loc[0, '到期日期']
  1443. payoutAmt = loanDf.loc[0, '借款金额(本金)'] # 放款金额
  1444. balance = loanDf.loc[0, '余额(本金)']
  1445. # Step1 - 基础变量计算
  1446. if payRate == '月':
  1447. if str(payDue) != "nan" and payDue > 0:
  1448. term1 = payDue
  1449. else:
  1450. term1 = utils.difMonthReportTimeFloor(openDate, expireDate)
  1451. if str(payRemainderDue) != "nan" and payRemainderDue > 0:
  1452. term2 = payRemainderDue
  1453. else:
  1454. term2 = utils.difMonthReportTimeFloor(reportTime, expireDate)
  1455. term3 = term1 - term2
  1456. else:
  1457. term1 = utils.difMonthReportTimeFloor(openDate, expireDate)
  1458. term2 = utils.difMonthReportTimeFloor(reportTime, expireDate)
  1459. term3 = term1 - term2
  1460. if term1 <= 0 or term2 <= 0 or term1 < term2 or openDate == None or expireDate == None:
  1461. tag0 = 1
  1462. else:
  1463. tag0 = 0
  1464. payloan = utils.null2Zero(payoutAmt) - utils.null2Zero(balance)
  1465. payloan = max(0, payloan)
  1466. termpct_12 = max(0, 1 - 0.25 * int((term2 - 1) / 3))
  1467. if loanDf.loc[0, '担保方式'] == '抵押':
  1468. tag1 = 1
  1469. else:
  1470. tag1 = 0
  1471. curActualPay = loanDf.loc[0, '本月实还款']
  1472. curShouldPay = loanDf.loc[0, '本月应还款']
  1473. if str(curActualPay) != "nan" and str(curShouldPay) != "nan":
  1474. if max(curShouldPay, curActualPay) * term1 >= payoutAmt * 1.5:
  1475. tag2 = 1
  1476. elif max(curShouldPay, curActualPay) * term2 >= balance * 1.5:
  1477. tag2 = 1
  1478. elif term2 > 0 and term3 > 0 and payloan / term3 >= 1.5 * (balance / term2):
  1479. tag2 = 1
  1480. elif term2 > 0 and term3 > 0 and balance / term2 >= 1.5 * (payloan / term3):
  1481. tag2 = 1
  1482. elif payoutAmt < balance:
  1483. tag2 = 1
  1484. else:
  1485. tag2 = 0
  1486. if tag1 == 1:
  1487. pay_rat = 0.0036
  1488. else:
  1489. pay_rat = 0.0083
  1490. if tag1 == 1:
  1491. mthly_intr = 0.07 / 12
  1492. else:
  1493. mthly_intr = 0.18 / 12
  1494. totpayment1 = payoutAmt * mthly_intr * term1 + payoutAmt
  1495. totpayment2 = balance * mthly_intr * term2 + balance
  1496. # Step2-贷款分流负债统计
  1497. if tag0 == 1:
  1498. debt_f12 = balance * (1 + pay_rat * 12)
  1499. elif tag1 == 1:
  1500. debt_f12 = payoutAmt * pay_rat * 12
  1501. elif payRate != '月' or payRate == None:
  1502. monthy_pay_ref1 = totpayment1 / term1;
  1503. monthy_pay_ref2 = totpayment2 / term2;
  1504. monthy_pay_final = max(monthy_pay_ref1, monthy_pay_ref2);
  1505. debt_f12 = min(monthy_pay_final * 12, totpayment1, totpayment2);
  1506. elif tag2 == 1:
  1507. debt_f12 = min(balance * mthly_intr * min(term2, 12) + termpct_12 * balance, totpayment1, totpayment2);
  1508. else:
  1509. monthy_pay_ref1 = ((pay_rat * term1 + 1) * payoutAmt) / term1
  1510. if term2 == 0:
  1511. print(loanDf.loc[0, '账户编号'])
  1512. monthy_pay_ref2 = ((pay_rat * term2 + 1) * balance) / term2
  1513. monthy_pay_final = max(curShouldPay, monthy_pay_ref1, monthy_pay_ref2);
  1514. debt_f12 = min(monthy_pay_final * 12, balance * (1 + pay_rat * 12), balance * (1 + mthly_intr * term2));
  1515. loanDf.loc[0, '贷款负债'] = debt_f12
  1516. def mergeCreditCardDf(self,reportTime,docXml):
  1517. creditCardAccountDfs = []
  1518. tmpNode = docXml.documentElement.getElementsByTagName("CREDITCARDACCOUNTBOLS");
  1519. if len(tmpNode)>0:
  1520. noloopcreditaccountbols = docXml.documentElement.getElementsByTagName("CREDITCARDACCOUNTBOLS")[0]
  1521. creditacctinfobo = noloopcreditaccountbols.getElementsByTagName("CREDITACCTINFOBO");
  1522. for i in range(0, len(creditacctinfobo)):
  1523. dfObj = {}
  1524. creditCardDf = pd.DataFrame(columns=dfParser.dfHeaderCreditCard, index=[0])
  1525. creditbaseinfobo = creditacctinfobo[i].getElementsByTagName("CREDITBASEINFOBO")[0]
  1526. self.saveNodeWithType(creditbaseinfobo,"CREDITCARDACCOUNTBOLS")
  1527. newperformancebo = creditacctinfobo[i].getElementsByTagName("NEWPERFORMANCEBO")[0]
  1528. self.saveNodeWithType(newperformancebo,"CREDITCARDACCOUNTBOLS")
  1529. latemonthlyperformancebo = creditacctinfobo[i].getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  1530. latemonthlyperformancebo = latemonthlyperformancebo[0]
  1531. self.saveNodeWithType(latemonthlyperformancebo,"CREDITCARDACCOUNTBOLS")
  1532. bigquotabaselnfosg = creditacctinfobo[i].getElementsByTagName("BIGQUOTABASELNFOSG")
  1533. fiveyearhisrpyinfols = creditacctinfobo[i].getElementsByTagName("FIVEYEARHISRPYINFOSG")
  1534. creditCardDf.loc[0, '账户编号'] = self.getNodeData(creditbaseinfobo, "ACCTNO")
  1535. creditCardDf.loc[0, '发卡机构'] = self.getNodeData(creditbaseinfobo, "BUSIORGCODE")
  1536. creditCardDf.loc[0, '账户标识'] = self.getNodeData(creditbaseinfobo, "ACCTCODE")
  1537. creditCardDf.loc[0, '开立日期'] = self.getNodeData(creditbaseinfobo, "OPENDATE")
  1538. creditCardDf.loc[0, '账户授信额度'] = utils.replaceAmt(self.getNodeData(creditbaseinfobo, "ACCTCREDLINE"))
  1539. creditCardDf.loc[0, '共享授信额度'] = utils.replaceAmt(self.getNodeData(creditbaseinfobo, "ORGCREDLINE"))
  1540. # 排除美元027
  1541. MONEYTYPEDESC = self.getNodeData(creditbaseinfobo, "MONEYTYPEDESC")
  1542. if MONEYTYPEDESC.find('人民币')<0:
  1543. continue
  1544. # if MONEYTYPEDESC.find('美元')>= 0:
  1545. # continue
  1546. creditCardDf.loc[0, '币种'] = self.getNodeData(creditbaseinfobo, "MONEYTYPEDESC")
  1547. creditCardDf.loc[0, '业务种类'] = self.getNodeData(creditbaseinfobo, "LOANTYPEDESC")
  1548. creditCardDf.loc[0, '担保方式'] = self.getNodeData(creditbaseinfobo, "GUARMODEDESC")
  1549. accountStatus = self.getNodeData(latemonthlyperformancebo, "ACCTSTATUDESC")
  1550. if accountStatus == "":
  1551. accountStatus = self.getNodeData(newperformancebo,"ACCTSTATUSDESC")
  1552. if accountStatus.find('未激活') < 0: # 非未激活
  1553. if accountStatus == "呆账":
  1554. creditCardDf.loc[0, '账户状态'] = accountStatus
  1555. creditCardDf.loc[0, '余额'] = utils.replaceAmt(self.getNodeData(newperformancebo, "BALANCE"))
  1556. creditCardDf.loc[0, '最近一次还款日期'] = self.getNodeData(newperformancebo, "REPAYDATE")
  1557. elif accountStatus != '销户':
  1558. try:
  1559. creditCardDf.loc[0, '账户状态'] =accountStatus
  1560. creditCardDf.loc[0, '余额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "BUSIBAL"))
  1561. creditCardDf.loc[0, '已用额度'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "ACCTBAL"))
  1562. dividePeriodBalance = self.getNodeData(latemonthlyperformancebo, "INSTBAL") # 未出单的大额专项分期余额
  1563. creditCardDf.loc[0, '未出单的大额专项分期余额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "INSTBAL"))
  1564. creditCardDf.loc[0, '剩余分期期数'] = utils.toInt(self.getNodeData(latemonthlyperformancebo, "REMREPPRD"))
  1565. creditCardDf.loc[0, '最近6个月平均使用额度'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "AVGUSEAMOUNT"))
  1566. creditCardDf.loc[0, '最大使用额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "MAXUSEAMOUNT"))
  1567. creditCardDf.loc[0, '账单日'] = self.getNodeData(latemonthlyperformancebo, "SETTDATE")
  1568. creditCardDf.loc[0, '本月应还款'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "CURRPYAMT"))
  1569. creditCardDf.loc[0, '本月实还款'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "ACTRPYAMT"))
  1570. creditCardDf.loc[0, '最近一次还款日期'] = self.getNodeData(latemonthlyperformancebo, "LATRPYDATE");
  1571. creditCardDf.loc[0, '当前逾期期数'] = utils.toInt(self.getNodeData(latemonthlyperformancebo,"OVERDPRD"))
  1572. creditCardDf.loc[0, '当前逾期总额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo,"TOTOVERD"))
  1573. except Exception:
  1574. logger.info("解析贷记卡异常-" + i)
  1575. info = sys.exc_info()
  1576. logger.error(info[0])
  1577. logger.error(info[1])
  1578. logger.error(traceback.extract_tb(info[2]))
  1579. if len(bigquotabaselnfosg) >0:
  1580. bigquotabaselnfosg = bigquotabaselnfosg[0]
  1581. self.saveNodeWithType(bigquotabaselnfosg,"CREDITCARDACCOUNTBOLS")
  1582. # '大额专项分期额度','分期额度生效日期','分期额度到期日期','已用分期金额']
  1583. creditCardDf.loc[0, '大额专项分期额度'] = utils.replaceAmt(self.getNodeData(bigquotabaselnfosg, "SPECLINE"))
  1584. creditCardDf.loc[0, '分期额度生效日期'] = self.getNodeData(bigquotabaselnfosg, "SPECLINE")
  1585. creditCardDf.loc[0, '分期额度到期日期'] = self.getNodeData(bigquotabaselnfosg, "SPECENDDATE")
  1586. creditCardDf.loc[0, '已用分期金额'] = utils.replaceAmt(self.getNodeData(bigquotabaselnfosg, "INSTAMT"))
  1587. else:
  1588. accountStatus = '销户'
  1589. creditCardDf.loc[0, '账户状态'] = '销户'
  1590. else: # 未激活
  1591. creditCardDf.loc[0, '账户状态'] = '未激活'
  1592. accountStatus = '未激活'
  1593. dfObj["creditCardDf"] = creditCardDf;
  1594. # 解析还款记录
  1595. creditCardPayRecord = pd.DataFrame()
  1596. if accountStatus == "正常" or accountStatus == "冻结" or accountStatus == "止付" or accountStatus == "银行止付": # 正常
  1597. recordIndexBegin = 9;
  1598. creditCardPayRecord = self.mergeCreditCardPayRecordDf(fiveyearhisrpyinfols,creditCardPayRecord)
  1599. elif accountStatus == "未激活":
  1600. recordIndexBegin = 0;
  1601. elif accountStatus == "销户" or accountStatus == "呆账":
  1602. recordIndexBegin = 7;
  1603. creditCardPayRecord = self.mergeCreditCardPayRecordDf(fiveyearhisrpyinfols,creditCardPayRecord)
  1604. else:
  1605. creditCardPayRecord = self.mergeCreditCardPayRecordDf(fiveyearhisrpyinfols, creditCardPayRecord)
  1606. print(self.getNodeData(creditbaseinfobo, "ACCTNO")+"===================还款状态不满足条件==================="+"#"+accountStatus)
  1607. dfObj["creditCardPayRecordDf"] = creditCardPayRecord;
  1608. creditCardAccountDfs.append(dfObj)
  1609. return creditCardAccountDfs;
  1610. def mergeCreditCardDfZ(self,reportTime,docXml):
  1611. tmpNode = docXml.documentElement.getElementsByTagName("PASSCREDITCARDACCOUNTBOLS");
  1612. creditCardAccountDfsZ = []
  1613. if len(tmpNode)>0:
  1614. noloopcreditaccountbols = docXml.documentElement.getElementsByTagName("PASSCREDITCARDACCOUNTBOLS")[0]
  1615. creditacctinfobo = noloopcreditaccountbols.getElementsByTagName("CREDITACCTINFOBO");
  1616. for i in range(0, len(creditacctinfobo)):
  1617. dfObj = {}
  1618. creditCardDf = pd.DataFrame(columns=dfParser.dfHeaderCreditCardZ, index=[0])
  1619. creditbaseinfobo = creditacctinfobo[i].getElementsByTagName("CREDITBASEINFOBO")[0]
  1620. self.saveNodeWithType(creditbaseinfobo,"PASSCREDITCARDACCOUNTBOLS")
  1621. newperformancebo = creditacctinfobo[i].getElementsByTagName("NEWPERFORMANCEBO")[0]
  1622. self.saveNodeWithType(newperformancebo,"PASSCREDITCARDACCOUNTBOLS")
  1623. latemonthlyperformancebo = creditacctinfobo[i].getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  1624. latemonthlyperformancebo = latemonthlyperformancebo[0]
  1625. self.saveNodeWithType(latemonthlyperformancebo,"PASSCREDITCARDACCOUNTBOLS")
  1626. fiveyearhisrpyinfols = creditacctinfobo[i].getElementsByTagName("FIVEYEARHISRPYINFOSG")
  1627. creditCardDf.loc[0, '账户编号'] = self.getNodeData(creditbaseinfobo, "ACCTNO")
  1628. creditCardDf.loc[0, '发卡机构'] = self.getNodeData(creditbaseinfobo, "BUSIORGCODE")
  1629. creditCardDf.loc[0, '账户标识'] = self.getNodeData(creditbaseinfobo, "ACCTCODE")
  1630. creditCardDf.loc[0, '开立日期'] = self.getNodeData(creditbaseinfobo, "OPENDATE")
  1631. creditCardDf.loc[0, '账户授信额度'] = utils.replaceAmt(self.getNodeData(creditbaseinfobo, "ACCTCREDLINE"))
  1632. creditCardDf.loc[0, '共享授信额度'] = utils.replaceAmt(self.getNodeData(creditbaseinfobo, "ORGCREDLINE"))
  1633. creditCardDf.loc[0, '币种'] = self.getNodeData(creditbaseinfobo, "MONEYTYPEDESC")
  1634. creditCardDf.loc[0, '担保方式'] = self.getNodeData(creditbaseinfobo, "GUARMODEDESC")
  1635. MONEYTYPEDESC = self.getNodeData(creditbaseinfobo, "MONEYTYPEDESC")
  1636. if MONEYTYPEDESC.find('人民币') < 0:
  1637. continue
  1638. # if self.getNodeData(creditbaseinfobo, "MONEYTYPEDESC").find('美元') >= 0:
  1639. # continue
  1640. accountStatus = self.getNodeData(latemonthlyperformancebo, "ACCTSTATUDESC")
  1641. if accountStatus == "":
  1642. accountStatus =self.getNodeData(newperformancebo,"ACCTSTATUSDESC")
  1643. if accountStatus.find('未激活') < 0: # 非未激活
  1644. if accountStatus == "呆账":
  1645. creditCardDf.loc[0, '账户状态'] = accountStatus
  1646. creditCardDf.loc[0, '余额'] = utils.replaceAmt(self.getNodeData(newperformancebo, "BALANCE"))
  1647. creditCardDf.loc[0, '透支余额'] = utils.replaceAmt(self.getNodeData(newperformancebo, "BALANCE"))
  1648. creditCardDf.loc[0, '最近一次还款日期'] = self.getNodeData(newperformancebo, "REPAYDATE")
  1649. elif accountStatus != '销户':
  1650. try:
  1651. creditCardDf.loc[0, '账户状态'] = accountStatus
  1652. creditCardDf.loc[0, '透支余额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "BUSIBAL"))
  1653. creditCardDf.loc[0, '最近6个月平均透支余额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "LATSIXMNAVGOVDFTBAL"))
  1654. creditCardDf.loc[0, '最大透支余额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "MAXOVERDRAFTBAL"))
  1655. creditCardDf.loc[0, '账单日'] = self.getNodeData(latemonthlyperformancebo, "SETTDATE")
  1656. creditCardDf.loc[0, '本月实还款'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "ACTRPYAMT"))
  1657. creditCardDf.loc[0, '最近一次还款日期'] = self.getNodeData(latemonthlyperformancebo, "LATRPYDATE");
  1658. creditCardDf.loc[0, '透支180天以上未付余额'] = utils.replaceAmt(self.getNodeData(latemonthlyperformancebo, "OVERDRAWBAOVE180"))
  1659. except:
  1660. logger.info("解析准贷记卡异常-" + i);
  1661. else:
  1662. accountStatus = '销户'
  1663. creditCardDf.loc[0, '账户状态'] = '销户'
  1664. creditCardDf.loc[0, '最近一次还款日期'] = ""
  1665. else: # 未激活
  1666. creditCardDf.loc[0, '账户状态'] = '未激活'
  1667. accountStatus = '未激活'
  1668. creditCardDf.loc[0, '最近一次还款日期'] = ""
  1669. dfObj["creditCardDfZ"] = creditCardDf;
  1670. # 解析还款记录
  1671. creditCardPayRecord = pd.DataFrame()
  1672. if accountStatus == "正常" or accountStatus == "冻结" or accountStatus == "止付" or accountStatus == "银行止付": # 正常
  1673. recordIndexBegin = 9;
  1674. creditCardPayRecord = self.mergeCreditCardPayRecordDf(fiveyearhisrpyinfols,creditCardPayRecord)
  1675. elif accountStatus == "未激活":
  1676. recordIndexBegin = 0;
  1677. elif accountStatus == "销户" or accountStatus == "呆账":
  1678. recordIndexBegin = 7;
  1679. creditCardPayRecord = self.mergeCreditCardPayRecordDf(fiveyearhisrpyinfols,creditCardPayRecord)
  1680. else:
  1681. creditCardPayRecord = self.mergeCreditCardPayRecordDf(fiveyearhisrpyinfols, creditCardPayRecord)
  1682. print("账户#" + str(i + 1) + "#" + self.getNodeData(creditbaseinfobo, "ACCTNO")+"===================还款状态不满足条件==================="+"#"+accountStatus)
  1683. dfObj["creditCardPayRecordDfZ"] = creditCardPayRecord;
  1684. creditCardAccountDfsZ.append(dfObj)
  1685. return creditCardAccountDfsZ;
  1686. # 合并贷款还款记录明细
  1687. def mergeLoanPayRecordDf(self,fiveyearhisrpyinfols, loanPayRecord):
  1688. # for i in range(0, len(fiveyearhisrpyinfols)):
  1689. # loanPayRecordTmp = pd.DataFrame(columns=dfParser.dfHeaderLoanPayRecord, index=[0])
  1690. # loanPayRecordTmp.loc[0, '账户编号'] = self.getNodeData(fiveyearhisrpyinfols[i], "ACCTNO");
  1691. # loanPayRecordTmp.loc[0, '还款日期'] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDMON")+"-01";
  1692. # loanPayRecordTmp.loc[0, '还款状态值'] = utils.replaceAmt(self.getNodeData(fiveyearhisrpyinfols[i], "TOTACCTBAL"))
  1693. # loanPayRecordTmp.loc[0, '还款状态'] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDSTATUSCODE");
  1694. # loanPayRecord = pd.concat([loanPayRecord, loanPayRecordTmp], axis=0, ignore_index=True);
  1695. # return loanPayRecord;
  1696. ds = []
  1697. # loanPayRecordTmp = pd.DataFrame(columns=dfParser.dfHeaderLoanPayRecord, index=[0])
  1698. for i in range(0, len(fiveyearhisrpyinfols)):
  1699. dsObj = {}
  1700. # loanPayRecordTmp = pd.DataFrame(columns=dfParser.dfHeaderLoanPayRecord, index=[0])
  1701. # loanPayRecordTmp.loc[0, '账户编号'] = self.getNodeData(fiveyearhisrpyinfols[i], "ACCTNO");
  1702. # loanPayRecordTmp.loc[0, '还款日期'] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDMON") + "-01";
  1703. # loanPayRecordTmp.loc[0, '还款状态值'] = utils.replaceAmt(self.getNodeData(fiveyearhisrpyinfols[i], "TOTACCTBAL"))
  1704. # loanPayRecordTmp.loc[0, '还款状态'] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDSTATUSCODE");
  1705. # loanPayRecord = pd.concat([loanPayRecord, loanPayRecordTmp], axis=0, ignore_index=True);
  1706. dsObj["账户编号"] = self.getNodeData(fiveyearhisrpyinfols[i], "ACCTNO");
  1707. dsObj["还款日期"] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDMON") + "-01";
  1708. dsObj["还款状态值"] = utils.replaceAmt(self.getNodeData(fiveyearhisrpyinfols[i], "TOTACCTBAL"))
  1709. dsObj["还款状态"] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDSTATUSCODE");
  1710. ds.append(dsObj)
  1711. self.saveNodeWithType(fiveyearhisrpyinfols[i],"LOAN")
  1712. # if len(ds)>0:
  1713. # loanPayRecordTmp = pd.DataFrame(ds)
  1714. return ds;
  1715. # 合并贷款还款记录明细
  1716. def mergeCreditCardPayRecordDf(self, fiveyearhisrpyinfols, loanPayRecord):
  1717. # for i in range(0, len(fiveyearhisrpyinfols)):
  1718. # loanPayRecordTmp = pd.DataFrame(columns=dfParser.dfHeaderLoanPayRecord, index=[0])
  1719. # loanPayRecordTmp.loc[0, '账户编号'] = self.getNodeData(fiveyearhisrpyinfols[i], "ACCTNO");
  1720. # loanPayRecordTmp.loc[0, '还款日期'] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDMON") + "-01";
  1721. # loanPayRecordTmp.loc[0, '还款状态值'] = utils.replaceAmt(self.getNodeData(fiveyearhisrpyinfols[i], "TOTACCTBAL"))
  1722. # loanPayRecordTmp.loc[0, '还款状态'] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDSTATUSCODE");
  1723. # loanPayRecord = pd.concat([loanPayRecord, loanPayRecordTmp], axis=0, ignore_index=True);
  1724. # return loanPayRecord;
  1725. ds = []
  1726. # loanPayRecordTmp = pd.DataFrame(columns=dfParser.dfHeaderLoanPayRecord, index=[0])
  1727. loanPayRecordTmp = None
  1728. for i in range(0, len(fiveyearhisrpyinfols)):
  1729. dsObj = {}
  1730. # loanPayRecordTmp = pd.DataFrame(columns=dfParser.dfHeaderLoanPayRecord, index=[0])
  1731. # loanPayRecordTmp.loc[0, '账户编号'] = self.getNodeData(fiveyearhisrpyinfols[i], "ACCTNO");
  1732. # loanPayRecordTmp.loc[0, '还款日期'] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDMON") + "-01";
  1733. # loanPayRecordTmp.loc[0, '还款状态值'] = utils.replaceAmt(self.getNodeData(fiveyearhisrpyinfols[i], "TOTACCTBAL"))
  1734. # loanPayRecordTmp.loc[0, '还款状态'] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDSTATUSCODE");
  1735. # loanPayRecord = pd.concat([loanPayRecord, loanPayRecordTmp], axis=0, ignore_index=True);
  1736. dsObj["账户编号"] = self.getNodeData(fiveyearhisrpyinfols[i], "ACCTNO");
  1737. dsObj["还款日期"] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDMON") + "-01";
  1738. dsObj["还款状态值"] = utils.replaceAmt(self.getNodeData(fiveyearhisrpyinfols[i], "TOTACCTBAL"))
  1739. dsObj["还款状态"] = self.getNodeData(fiveyearhisrpyinfols[i], "OVERDSTATUSCODE");
  1740. self.saveNodeWithType(fiveyearhisrpyinfols[i],"CREDITCARD")
  1741. ds.append(dsObj)
  1742. if len(ds)>0:
  1743. loanPayRecordTmp = pd.DataFrame(ds)
  1744. return loanPayRecordTmp;
  1745. # 合并贷款还款记录明细
  1746. #合并特殊交易
  1747. def mergeLoanSpecialTrade(self,specialtradebaseinfosg, specialTradeDf):
  1748. for i in range(0,len(specialtradebaseinfosg)):
  1749. self.saveNode(specialtradebaseinfosg[i])
  1750. specialTradeDfTmp = pd.DataFrame(columns = dfParser.dfHeaderLoanSpecialTrade, index=[0])
  1751. specialTradeDfTmp.loc[0, '账户编号'] = self.getNodeData(specialtradebaseinfosg[i], "ACCTNO");
  1752. specialTradeDfTmp.loc[0, '特殊交易类型'] = self.getNodeData(specialtradebaseinfosg[i], "TRANTYPEDESC");
  1753. specialTradeDfTmp.loc[0, '发生日期'] = self.getNodeData(specialtradebaseinfosg[i], "TRANDATE");
  1754. specialTradeDfTmp.loc[0, '变更月数'] = utils.toInt(self.getNodeData(specialtradebaseinfosg[i], "TRANMONTH"))
  1755. specialTradeDfTmp.loc[0, '发生金额'] = utils.replaceAmt(self.getNodeData(specialtradebaseinfosg[i], "TRANAMT"))
  1756. specialTradeDfTmp.loc[0, '明细记录'] = self.getNodeData(specialtradebaseinfosg[i], "DETRECORD");
  1757. tradeType = self.getNodeData(specialtradebaseinfosg[i], "TRANTYPEDESC");
  1758. content = self.getNodeData(specialtradebaseinfosg[i], "DETRECORD");
  1759. # TODO 加工严重程度 逻辑待确认
  1760. severity = None
  1761. if tradeType == '提前还款' or tradeType == '提前结清':
  1762. severity = 0
  1763. elif tradeType == '其他' and content.find("提前") >= 0:
  1764. severity = 0
  1765. elif tradeType == '担保人(第三方)代偿':
  1766. severity = 1
  1767. # elif tradeType == "其他" and content.find("担保人代还取消")<0 and content.find("合同展期")<0:
  1768. # severity = 2
  1769. # 同时出现代还和取消
  1770. elif tradeType == "其他" and (content.find("代还") < 0 or content.find("代偿") < 0) and content.find(
  1771. "取消") < 0 and content.find("合同展期") < 0:
  1772. severity = 2
  1773. elif (tradeType == "展期" or tradeType.find('延期') >= 0) and content.find("专升本或研究生入学展期") >= 0:
  1774. severity = 2
  1775. # elif tradeType == "其他" and (content.find("担保人代还取消")>=0 or content.find("合同展期")>=0):
  1776. # severity = 3
  1777. elif tradeType == "其他" and (
  1778. ((content.find("代还") < 0 or content.find("代偿") < 0) and content.find("取消") >= 0) or (
  1779. content.find("合同展期") >= 0)):
  1780. severity = 3
  1781. elif (tradeType == "展期" or tradeType.find('延期') >= 0) and content.find("专升本或研究生入学展期") < 0:
  1782. severity = 3
  1783. elif tradeType == "以资抵债":
  1784. severity = 4
  1785. specialTradeDfTmp.loc[0, '严重程度'] = severity
  1786. specialTradeDf = pd.concat([specialTradeDf, specialTradeDfTmp], axis=0, ignore_index=True);
  1787. return specialTradeDf;
  1788. # 解析被追偿信息汇总
  1789. def parseRecoveryInfoMergeDf(self,df):
  1790. if not df.empty:
  1791. recoveryMaxPayDf = df[df['债权转移时的还款状态'] != '']
  1792. recoveryStatusCs = df[df['账户状态'] == '催收']
  1793. if not recoveryMaxPayDf.empty:
  1794. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '债权转移时的最大还款状态'] = np.max(
  1795. recoveryMaxPayDf['债权转移时的还款状态']);
  1796. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '债权转移时属于催收状态的账户数'] = recoveryStatusCs.index.size;
  1797. briefInfoDf_recoveryInfoSum.loc[recoveryInfoSumIndex, '债权转移时属于催收状态的账户数/被追偿信息总数'] = round(
  1798. recoveryStatusCs.index.size / df.index.size, 2);
  1799. # creditTradeDetailDf_recoveryInfo
  1800. # 被追偿账户总数
  1801. creditTradeDetailDf_recoveryInfo.loc[recoveryInfoIndex, '被追偿账户总数'] = df.index.size;
  1802. creditTradeDetailDf_recoveryInfo.loc[recoveryInfoIndex, '被追偿业务种类'] = df['业务种类'].unique().size;
  1803. creditTradeDetailDf_recoveryInfo.loc[recoveryInfoIndex, '最新一笔被追偿债券接收时间'] = np.max(df['债权接收日期']);
  1804. creditTradeDetailDf_recoveryInfo.loc[recoveryInfoIndex, '总债权金额'] = np.max(df['债权金额']);
  1805. creditTradeDetailDf_recoveryInfo.loc[recoveryInfoIndex, '债权转移时的最大还款状态'] = np.max(
  1806. recoveryMaxPayDf['债权转移时的还款状态']);
  1807. # 解析信贷交易明细-特殊交易
  1808. def parseSpecialTrade(self,df):
  1809. if not df.empty:
  1810. creditTradeDetailHeader_specialTrade.loc[specialTradeIndex, '当前用户发生特殊交易的严重程度'] = np.max(df['严重程度']) # 加工的指标
  1811. maxChangeMonthIndex = np.argmax(np.abs(df['变更月数']))
  1812. meanMonthValue = np.mean(np.abs(df['变更月数']))
  1813. row0 = df.loc[maxChangeMonthIndex, :]
  1814. settleDf = df[(df['特殊交易类型'] == '提前结清') | (df['特殊交易类型'] == '提前还款')]
  1815. debtDf = df[(df['特殊交易类型'] == '以资抵债')]
  1816. creditTradeDetailHeader_specialTrade.loc[specialTradeIndex, '用户发生特殊交易变更月数的最大差值'] = row0[3]
  1817. creditTradeDetailHeader_specialTrade.loc[specialTradeIndex, '用户发生特殊交易变更月数的平均差值'] = round(meanMonthValue, 2)
  1818. creditTradeDetailHeader_specialTrade.loc[specialTradeIndex, '用户特殊交易涉及的发生金额的最大值'] = np.max(df['发生金额'])
  1819. creditTradeDetailHeader_specialTrade.loc[specialTradeIndex, '用户特殊交易涉及的发生金额的平均值'] = round(np.mean(df['发生金额']), 2)
  1820. creditTradeDetailHeader_specialTrade.loc[specialTradeIndex, '用户所有帐户发生提前还款交易的次数统计'] = settleDf.index.size
  1821. creditTradeDetailHeader_specialTrade.loc[specialTradeIndex, '用户所有帐户发生不良特殊交易的次数统计'] = debtDf.index.size;
  1822. # 信贷交易明细-非循环贷账户
  1823. def parseLoanAccountInfo(self,df):
  1824. if not df.empty:
  1825. loanAccountNum = int(briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户账户数'])
  1826. normalDf = df[(df['账户状态'] != '结清') & (df['账户状态'] != '转出') & (df['账户状态'] != '呆账')].reset_index(drop=True)
  1827. normalDf = normalDf[0:loanAccountNum] # 根据非循环贷账户数进行计算进行截取
  1828. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '本月应还款(合计)'] = np.sum(normalDf['本月应还款'])
  1829. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '本月实还款(合计)'] = np.sum(normalDf['本月实还款'])
  1830. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '最近一次还款日期'] = np.max(normalDf['最近一次还款日期'])
  1831. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '当前一共逾期期数'] = np.sum(normalDf['当前逾期期数'])
  1832. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '当前一共逾期总额'] = np.sum(normalDf['当前逾期总额'])
  1833. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '逾期31-60天未还本金(合计)'] = np.sum(
  1834. normalDf['逾期31-60天未还本金'])
  1835. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '逾期61-90天未还本金(合计)'] = np.sum(
  1836. normalDf['逾期61-90天未还本金'])
  1837. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '逾期91-180天未还本金(合计)'] = np.sum(
  1838. normalDf['逾期91-180天未还本金'])
  1839. creditTradeDetailDf_loanAccountInfo.loc[loanInfoIndex, '逾期180天以上未还本金(合计)'] = np.sum(
  1840. normalDf['逾期180天以上未还本金'])
  1841. # 信贷交易明细-循环额度分账户
  1842. def parseCycleCreditAccountInfo(self,df):
  1843. if not df.empty:
  1844. normalDf = df[(df['账户状态'] != '结清') & (df['账户状态'] != '转出') & (df['账户状态'] != '呆账')].reset_index(drop=True)
  1845. loanAccountNum = int(briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户账户数'])
  1846. cycleCreditAccountNum = int(briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户账户数'])
  1847. normalDf = normalDf[loanAccountNum:(loanAccountNum + cycleCreditAccountNum)]
  1848. if not normalDf.empty:
  1849. creditTradeDetailDf_cycleCreditAccountInfo.loc[cycleCreditAccountInfoIndex, '本月应还款(合计)'] = np.sum(
  1850. normalDf['本月应还款'])
  1851. creditTradeDetailDf_cycleCreditAccountInfo.loc[cycleCreditAccountInfoIndex, '本月实还款(合计)'] = np.sum(
  1852. normalDf['本月实还款'])
  1853. creditTradeDetailDf_cycleCreditAccountInfo.loc[cycleCreditAccountInfoIndex, '最近一次还款日期'] = np.max(
  1854. normalDf['最近一次还款日期'])
  1855. creditTradeDetailDf_cycleCreditAccountInfo.loc[cycleCreditAccountInfoIndex, '当前一共逾期期数'] = np.sum(
  1856. normalDf['当前逾期期数'])
  1857. creditTradeDetailDf_cycleCreditAccountInfo.loc[cycleCreditAccountInfoIndex, '当前一共逾期总额'] = np.sum(
  1858. normalDf['当前逾期总额'])
  1859. creditTradeDetailDf_cycleCreditAccountInfo.loc[
  1860. cycleCreditAccountInfoIndex, '逾期31-60天未还本金(合计)'] = np.sum(normalDf['逾期31-60天未还本金'])
  1861. creditTradeDetailDf_cycleCreditAccountInfo.loc[
  1862. cycleCreditAccountInfoIndex, '逾期61-90天未还本金(合计)'] = np.sum(normalDf['逾期61-90天未还本金'])
  1863. creditTradeDetailDf_cycleCreditAccountInfo.loc[
  1864. cycleCreditAccountInfoIndex, '逾期91-180天未还本金(合计)'] = np.sum(normalDf['逾期91-180天未还本金'])
  1865. creditTradeDetailDf_cycleCreditAccountInfo.loc[
  1866. cycleCreditAccountInfoIndex, '逾期180天以上未还本金(合计)'] = np.sum(normalDf['逾期180天以上未还本金'])
  1867. # 信贷交易明细-循环贷账户
  1868. def parseCycleLoanAccountInfo(self,df):
  1869. if not df.empty:
  1870. normalDf = df[(df['账户状态'] != '结清') & (df['账户状态'] != '转出') & (df['账户状态'] != '呆账')]
  1871. loanAccountNum = int(briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户账户数'])
  1872. cycleCreditAccountNum = int(briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户账户数'])
  1873. cycleAccountNum = int(briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环贷账户账户数'])
  1874. normalDf = normalDf[(loanAccountNum + cycleCreditAccountNum):normalDf.index.size]
  1875. if not normalDf.empty:
  1876. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '本月应还款(合计)'] = np.sum(
  1877. normalDf['本月应还款'])
  1878. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '本月实还款(合计)'] = np.sum(
  1879. normalDf['本月实还款'])
  1880. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '最近一次还款日期'] = np.max(
  1881. normalDf['最近一次还款日期'])
  1882. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '当前一共逾期期数'] = np.sum(
  1883. normalDf['当前逾期期数'])
  1884. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '当前一共逾期总额'] = np.sum(
  1885. normalDf['当前逾期总额'])
  1886. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '逾期31-60天未还本金(合计)'] = np.sum(
  1887. normalDf['逾期31-60天未还本金'])
  1888. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '逾期61-90天未还本金(合计)'] = np.sum(
  1889. normalDf['逾期61-90天未还本金'])
  1890. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '逾期91-180天未还本金(合计)'] = np.sum(
  1891. normalDf['逾期91-180天未还本金'])
  1892. creditTradeDetailDf_cycleLoanAccountInfo.loc[cycleLoanAccountInfoIndex, '逾期180天以上未还本金(合计)'] = np.sum(
  1893. normalDf['逾期180天以上未还本金'])
  1894. # 解析贷款账户信息指标
  1895. def parseLoanMergeDf(self,df,reportTime):
  1896. if not df.empty:
  1897. sortDf = df.sort_values(by=["账户关闭日期", "借款金额(本金)"], ascending=(False, False))
  1898. sortDf = sortDf[sortDf['账户状态'] == '结清'];
  1899. sortDf = sortDf.reset_index(drop=True)
  1900. if not sortDf.empty:
  1901. row0 = sortDf.loc[0, :]
  1902. loanAccountInfoDf.loc[loanAccountInfoIndex, '最近一笔结清贷款的贷款金额'] = row0['借款金额(本金)']
  1903. openDate = dfParser.formatDate(row0['开立日期'])
  1904. loanAccountInfoDf.loc[loanAccountInfoIndex, '最近一笔结清贷款的发放距今月数'] = utils.difMonthReportTime(openDate,
  1905. reportTime)
  1906. settleDate = dfParser.formatDate(row0['账户关闭日期'])
  1907. loanAccountInfoDf.loc[loanAccountInfoIndex, '最近一笔结清贷款的结清距今月数'] = utils.difMonthReportTime(settleDate,
  1908. reportTime)
  1909. loanAccountInfoDf.loc[loanAccountInfoIndex, '历史贷款总法人机构数'] = df['管理机构'].unique().size
  1910. #1112 汇算
  1911. notSettleDf = df[df['账户状态'] != '结清'];
  1912. otherDf.loc[otherIndex, '未结清贷款机构数'] = notSettleDf['管理机构'].unique().size
  1913. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前同时在用的贷款机构数'] = df[df['余额(本金)'] > 0]['管理机构'].unique().size
  1914. statusDf = df[(df['账户状态'] != '结清') & (df['账户状态'] != '转出')]
  1915. bankDf = statusDf[statusDf['管理机构'].str.contains('银行')]
  1916. # 没有记录
  1917. if statusDf.index.size == 0:
  1918. isNotBankCust = -1
  1919. else:
  1920. if bankDf.index.size > 0: # 有一条以上不为结清,请包含银行
  1921. isNotBankCust = 1;
  1922. else:
  1923. isNotBankCust = 0;
  1924. loanAccountInfoDf.loc[loanAccountInfoIndex, '是否有非银行贷款客户'] = isNotBankCust
  1925. # 最严重的五级分类
  1926. # fiveType = ""
  1927. # for fiveTypeTmp in consts.fiveType:
  1928. # fiveTypeDf = statusDf[statusDf['五级分类']==fiveTypeTmp];
  1929. # if not fiveTypeDf.empty:
  1930. # fiveType = fiveTypeTmp;
  1931. # break;
  1932. # loanAccountInfoDf.loc[loanAccountInfoIndex, '贷款五级分类'] = fiveType
  1933. # 当前贷款LTV
  1934. # 从“贷款信息”中提取,剔除“账户状态”为结清及转出,并剔除“账户状态”为呆账且本金余额 = 0
  1935. # 的记录后,SUM(本金余额) / SUM(贷款本金)
  1936. # 如本金余额为空和贷款本金为0或为空,则当条记录不计算
  1937. loanLtvDf = df[(df['账户状态'] != '结清') & (df['账户状态'] != '转出') & (df['借款金额(本金)'] > 0) & (df['余额(本金)'] != '')]
  1938. badSetDf = loanLtvDf[~((loanLtvDf['账户状态'] == '呆账') & (loanLtvDf['余额(本金)'] == 0))]
  1939. balanceSum = np.sum(badSetDf['余额(本金)'].astype('int'))
  1940. loanAmtSum = np.sum(badSetDf['借款金额(本金)'].astype('int'))
  1941. if (loanAmtSum != 0):
  1942. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款LTV'] = round(np.divide(balanceSum, loanAmtSum), 2)
  1943. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款最高LTV'] = round(
  1944. np.max(np.divide(badSetDf['余额(本金)'].astype('int'), badSetDf['借款金额(本金)'].astype('int'))), 2)
  1945. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款最低LTV'] = round(
  1946. np.min(np.divide(badSetDf['余额(本金)'].astype('int'), badSetDf['借款金额(本金)'].astype('int'))), 2)
  1947. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款平均LTV'] = round(np.mean(np.divide(badSetDf['余额(本金)'].astype('int'), badSetDf['借款金额(本金)'].astype('int'))), 2)
  1948. # ['个人住房商业贷款','个人商用房(含商住两用)贷款','个人住房公积金贷款','房'],
  1949. houseLtvList = consts.houseLtvList;# ['个人住房商业贷款','个人商用房(含商住两用)贷款','个人住房公积金贷款','房'],
  1950. # houseLtvDf = badSetDf[badSetDf['业务种类'].isin(houseLtvList)]
  1951. # if not houseLtvDf.empty:
  1952. # loanAccountInfoDf.loc[loanAccountInfoIndex, '当前房贷LTV'] = round(np.divide(np.sum(houseLtvDf['余额(本金)'].astype('int')),np.sum(houseLtvDf['借款金额(本金)'].astype('int'))), 2)
  1953. # ['个人住房贷款','个人商用房(包括商住两用)贷款']
  1954. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前房贷LTV'] = lip.getCurLtv(badSetDf, houseLtvList)
  1955. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款机构数量'] = loanLtvDf['管理机构'].unique().size
  1956. cardLtvList = ['个人汽车消费贷款']#, '车'
  1957. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前车贷LTV'] = lip.getCurLtv(badSetDf, cardLtvList)
  1958. operateLtvList = ['个人经营性贷款']
  1959. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前经营贷LTV'] = lip.getCurLtv(badSetDf, operateLtvList)
  1960. consumeLtvList = ['其他个人消费贷款']
  1961. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前消费贷LTV'] = lip.getCurLtv(badSetDf, consumeLtvList)
  1962. bankLtvList = ['商业银行', '外资银行', '村镇银行', '住房储蓄银行', '财务公司']
  1963. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前银行贷LTV'] = lip.getCurBankLtv(badSetDf, bankLtvList)
  1964. bankLtvList = ['消费金融公司', '汽车金融公司', '信托公司'] # TODO
  1965. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前消金贷LTV'] = lip.getCurBankLtv(badSetDf, bankLtvList)
  1966. smallLoanLtvList = ['小额信贷公司']
  1967. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前小贷LTV'] = lip.getCurBankLtv(badSetDf, smallLoanLtvList)
  1968. # 当前贷款最大逾期期数
  1969. # 从“贷款信息”中提取,剔除“账户状态”为结清、转出、呆账、呆帐后,MAX(每笔贷款的当前逾期期数)
  1970. loanOverdueLtvDf = df[(df['账户状态'] != '结清') & (df['账户状态'] != '转出') & (df['账户状态'] != '呆账')]
  1971. if not loanOverdueLtvDf.empty:
  1972. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款最大逾期期数'] = np.max(loanOverdueLtvDf['当前逾期期数'])
  1973. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款最大逾期金额'] = np.max(loanOverdueLtvDf['当前逾期总额'])
  1974. loanOverdueLtvDf = loanOverdueLtvDf.reset_index(drop=True)
  1975. maxOverdueIndex = np.argmax(loanOverdueLtvDf['当前逾期期数'])
  1976. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款最大逾期期数对应的最大逾期金额'] = \
  1977. loanOverdueLtvDf.loc[maxOverdueIndex, :]['当前逾期总额']
  1978. loanAccountInfoDf.loc[loanAccountInfoIndex, '近3月开户最高贷款本金'] = lip.getLastLoanAmtMax(df,
  1979. reportTime,
  1980. 3) # 贷款指标加工单独放到一个文件里
  1981. loanAccountInfoDf.loc[loanAccountInfoIndex, '近3月开户最低贷款本金'] = lip.getLastLoanAmtMin(df,
  1982. reportTime,
  1983. 3)
  1984. loanAccountInfoDf.loc[loanAccountInfoIndex, '近3月开户平均贷款本金'] = lip.getLastLoanAmtAvg(df,
  1985. reportTime,
  1986. 3)
  1987. loanAccountInfoDf.loc[loanAccountInfoIndex, '近6月开户最高贷款本金'] = lip.getLastLoanAmtMax(df,
  1988. reportTime,
  1989. 6)
  1990. loanAccountInfoDf.loc[loanAccountInfoIndex, '近6月开户最低贷款本金'] = lip.getLastLoanAmtMin(df,
  1991. reportTime,
  1992. 6)
  1993. loanAccountInfoDf.loc[loanAccountInfoIndex, '近6月开户平均贷款本金'] = lip.getLastLoanAmtAvg(df,
  1994. reportTime,
  1995. 6)
  1996. loanAccountInfoDf.loc[loanAccountInfoIndex, '近12月开户最高贷款本金'] = lip.getLastLoanAmtMax(df,
  1997. reportTime,
  1998. 12)
  1999. loanAccountInfoDf.loc[loanAccountInfoIndex, '近12月开户最低贷款本金'] = lip.getLastLoanAmtMin(df,
  2000. reportTime,
  2001. 12)
  2002. loanAccountInfoDf.loc[loanAccountInfoIndex, '近12月开户平均贷款本金'] = lip.getLastLoanAmtAvg(df,
  2003. reportTime,
  2004. 12)
  2005. lastLoanDf = loanOverdueLtvDf;
  2006. if not lastLoanDf.empty:
  2007. loanAccountInfoDf.loc[loanAccountInfoIndex, '贷款最近一次还款日期距今时长'] = lip.getLastPayDateMinDays(lastLoanDf,reportTime)
  2008. normalDf = df[(df['账户状态'] == '正常') & (df['当前逾期期数'] == 0)]
  2009. # 未结清贷款总账户数:账户状态不等于结清和转出的记录数
  2010. notSettleDf = df[(df['账户状态'] != '结清') & (df['账户状态'] != '转出')]
  2011. #1113 汇算
  2012. cardLoanCountDf = df[df['业务种类'].isin(cardLtvList)]
  2013. otherDf.loc[otherIndex, '车贷发放笔数'] = cardLoanCountDf.index.size
  2014. #count(贷款账户) where 五级分类 in ('关注','次级','可疑','损失')
  2015. fiveDf = df[df['五级分类'].isin(['关注','次级','可疑','损失'])]
  2016. juziDf.loc[juziIndex, "贷款五级分类命中('关注','次级','可疑','损失')的账户数"] = fiveDf.index.size
  2017. loanStatusDf = df[df['账户状态'].isin(['逾期','呆账','转出','担保物不足','强制平仓','司法追偿'])]
  2018. juziDf.loc[juziIndex, "贷款状态为('逾期','呆账','转出','担保物不足','强制平仓','司法追偿')的账户数"] = loanStatusDf.index.size
  2019. #近12个月信贷最大授信额度
  2020. #max(放款金额) where 担保方式 in ("信用/免担保") and 业务种类 not in ("个人住房商业贷款","个人商用房(含商住两用)贷款","个人住房公积金贷款","个人汽车消费贷款") and (报告日期-开立日期)<=360天
  2021. loanCreditAmtDf = df[df['担保方式'].isin(['信用/免担保'])]
  2022. loanCreditAmtDf = loanCreditAmtDf[(~loanCreditAmtDf['业务种类'].isin(consts.notMortgageList))]
  2023. creditDate = utils.getLastMonthDate(reportTime,12)
  2024. loanCreditAmtDf = loanCreditAmtDf[loanCreditAmtDf["开立日期"]>=creditDate]
  2025. if not loanCreditAmtDf.empty:
  2026. otherDf.loc[otherIndex, "近12个月信贷最大授信额度"] = np.max(loanCreditAmtDf['借款金额(本金)'])
  2027. if not notSettleDf.empty:
  2028. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前正常贷款账户数'] = normalDf.index.size
  2029. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前正常贷款账户数占比'] = round(
  2030. normalDf.index.size / notSettleDf.index.size, 2)
  2031. # 当前未结清贷款余额总和
  2032. # ltvDf = tmpDf[tmpDf['业务种类'].isin(bizTypeList)]
  2033. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前未结清贷款余额总和'] = np.sum(notSettleDf['余额(本金)'])
  2034. # loanAccountInfoDf.loc[loanAccountInfoIndex, '当前未结清贷款余额总和'] = np.sum(notSettleDf['余额(本金)'])
  2035. # 当前未结清住房贷款余额总和
  2036. houseDf = notSettleDf[notSettleDf['业务种类'].isin(houseLtvList)]
  2037. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前未结清住房贷款余额总和'] = np.sum(houseDf['余额(本金)'])
  2038. # 当前未结清汽车贷款余额总和
  2039. cardDf = notSettleDf[notSettleDf['业务种类'].isin(cardLtvList)]
  2040. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前未结清汽车贷款余额总和'] = np.sum(cardDf['余额(本金)'])
  2041. # 当前未结清个人经营性贷款余额总和
  2042. operateLtvDf = notSettleDf[notSettleDf['业务种类'].isin(operateLtvList)]
  2043. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前未结清个人经营性贷款余额总和'] = np.sum(operateLtvDf['余额(本金)'])
  2044. # 当前平均每月贷款余额总和
  2045. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前平均每月贷款余额总和'] = round(np.sum(notSettleDf['余额(本金)']) / 12,
  2046. 2)
  2047. # 当前正常贷款账户余额
  2048. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前正常贷款账户余额'] = np.sum(normalDf['余额(本金)'])
  2049. # "从“贷款信息”中提取,剔除结清、转出,当前正常贷款账户余额/未结清贷款总余额(本金余额加总)
  2050. if np.sum(notSettleDf['余额(本金)']) > 0:
  2051. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前正常贷款账户余额占总余额比'] = round(
  2052. np.sum(normalDf['余额(本金)']) / np.sum(notSettleDf['余额(本金)']), 2)
  2053. #1113 汇算
  2054. #sum(本月应还款) where 业务种类 in ("个人住房商业贷款","个人商用房(含商住两用)贷款","个人住房公积金贷款") and 账户状态 not in("结清","转出","呆账")
  2055. housePayDf = notSettleDf[notSettleDf['业务种类'].isin(consts.houseLtvList)]
  2056. otherDf.loc[otherIndex, '房贷月还总额']=np.sum(housePayDf['本月应还款'])
  2057. cardPayMonthDf = notSettleDf[notSettleDf['业务种类'].isin(cardLtvList)]
  2058. otherDf.loc[otherIndex, '车贷月还总额'] = np.sum(cardPayMonthDf['本月应还款'])
  2059. #小额贷款笔数
  2060. smallLoanDf = notSettleDf[notSettleDf['借款金额(本金)']<=20000]
  2061. otherDf.loc[otherIndex, '小额贷款笔数'] = smallLoanDf.index.size
  2062. settleDf = df[(df['账户状态'] == '结清')]
  2063. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前正常结清贷款账户数'] = settleDf.index.size
  2064. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前正常结清贷款账户数占比'] = round(settleDf.index.size / df.index.size, 2)
  2065. # 贷款24期还款记录次数 TODO
  2066. # 最近3个月个人消费贷款发放额度
  2067. loanAccountInfoDf.loc[loanAccountInfoIndex, '贷款本月实还款金额'] = np.sum(loanOverdueLtvDf['本月应还款'])
  2068. loanAccountInfoDf.loc[loanAccountInfoIndex, '最近3个月个人消费贷款发放额度'] = lip.getLastPerConsumeAmt(df, 3, reportTime)
  2069. loanAccountInfoDf.loc[loanAccountInfoIndex, '最近6个月个人消费贷款发放额度'] = lip.getLastPerConsumeAmt(df, 6, reportTime)
  2070. loanAccountInfoDf.loc[loanAccountInfoIndex, '最近12个月个人消费贷款发放额度'] = lip.getLastPerConsumeAmt(df, 12, reportTime)
  2071. # 未结清贷款平均剩余还款期数
  2072. payPieDf = notSettleDf[notSettleDf['还款期数'] != '']
  2073. if payPieDf.index.size != 0:
  2074. loanAccountInfoDf.loc[loanAccountInfoIndex, '未结清贷款平均剩余还款期数'] = round(
  2075. np.sum(payPieDf['剩余还款期数']) / payPieDf.index.size, 2)
  2076. # 当前贷款本月应还金额总和
  2077. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款本月应还金额总和'] = np.sum(notSettleDf['本月应还款'])
  2078. # 当前贷款本月实还金额总额
  2079. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款本月实还金额总额'] = np.sum(notSettleDf['本月实还款'])
  2080. #1112汇算 非抵押类贷款授信总额
  2081. #sum(放款金额) where 业务种类 not in ("个人住房商业贷款","个人商用房(含商住两用)贷款","个人住房公积金贷款","个人汽车消费贷款")
  2082. # and 担保方式 not in ("抵押") and 账户状态不等于"结清" TODO
  2083. notMortgageList = consts.notMortgageList
  2084. notMortgageSettleDf = df[(df['担保方式'] != '抵押') & (df['账户状态'] != '结清')]
  2085. notMortgageSettleDf = notMortgageSettleDf[(~notMortgageSettleDf['业务种类'].isin(notMortgageList))]
  2086. otherDf.loc[otherIndex,"非抵押类贷款授信总额"]=np.sum(notMortgageSettleDf['借款金额(本金)'])
  2087. otherDf.loc[otherIndex, "未结清非抵押贷款笔数"] = notMortgageSettleDf.index.size
  2088. otherDf.loc[otherIndex, "未结清非抵押类贷款本金余额"] = np.sum(notMortgageSettleDf['余额(本金)'])
  2089. notMortgageDf = df[(df['担保方式'] != '抵押') & (df['账户状态'] != '结清') & (df['账户状态'] != '呆账') & (df['账户状态'] != '转出')]
  2090. notMortgageDf = notMortgageDf[(~notMortgageDf['业务种类'].isin(notMortgageList))]
  2091. otherDf.loc[otherIndex, "未结清非抵押类贷款月还总额"] = np.sum(notMortgageDf['本月应还款'])
  2092. sanshouDf.loc[sanshouIndex,"最大贷款余额"]= np.max(notSettleDf["余额(本金)"])
  2093. sanshouDf.loc[sanshouIndex, "未结清所有贷款合同总额"] = np.sum(notSettleDf["借款金额(本金)"])
  2094. # 解析贷记卡账户信息指标
  2095. def parseCreditCardMergeDf(self,df,reportTime):
  2096. if not df.empty:
  2097. # 历史信用卡总法人机构数
  2098. # creditCardAccountInfoDf.loc[creditCardAccountInfoIndex,'历史信用卡总法人机构数'] = df['发卡机构'].unique().size
  2099. # creditCardUseDf = df[df['已用额度']>0];
  2100. # creditCardAccountInfoDf.loc[creditCardAccountInfoIndex,'当前同时在用的信用卡机构数'] = creditCardUseDf['发卡机构'].unique().size
  2101. fstDate = np.min(df['开立日期']);
  2102. sanshouDf.loc[sanshouIndex, '最早信用卡发卡天数'] = utils.difDateReportTime(reportTime,fstDate)
  2103. # 统一排除
  2104. creditDf = df[(df['币种'] == '人民币元') & (df['账户状态'] != '未激活') & (df['账户状态'] != '销户') & (df['账户状态'] != '呆账')]
  2105. totalAmtDf = df[(df['币种'] == '人民币元') & (df['账户状态'] != '未激活') & (df['账户状态'] != '销户') & (df['账户状态'] != '呆账')]
  2106. # 大额专项分期额度(合计)
  2107. # 已用分期金额(合计)
  2108. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '大额专项分期额度(合计)'] = np.sum(creditDf['大额专项分期额度'])
  2109. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '已用分期金额(合计)'] = np.sum(creditDf['已用分期金额'])
  2110. # creditCardAccountInfoDf.loc[creditCardAccountInfoIndex,'贷记卡账户当前总额度'] = cip.getMaxCreditAmt(creditDf)
  2111. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '最近新发放的3张贷记卡平均额度'] = cip.getAvgCreditAmt(creditDf)
  2112. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡额度使用率超过90%的机构数占比'] = cip.getUseRate(creditDf,
  2113. df, 0.9)
  2114. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡额度使用率超过100%的机构数占比'] = cip.getUseRate(creditDf,
  2115. totalAmtDf,
  2116. 1)
  2117. # 从“贷记卡信息”中提取,计算授信额度时剔除销户,计算已用额度时剔除呆账、呆帐、销户后,SUM(各账户已用额度) / SUM(各账户授信额度)
  2118. useCreditDf = df[(df['币种'] == '人民币元') & (df['账户状态'] != '销户') & (df['账户状态'] != '呆账')]
  2119. totalCreditDf = df[(df['币种'] == '人民币元') & (df['账户状态'] != '销户')]
  2120. totalCreditAmt = np.sum(totalCreditDf['账户授信额度'])
  2121. if totalCreditAmt != 0: # 授信额度不能为0
  2122. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡账户当前总额度使用率'] = round(
  2123. np.sum(useCreditDf['已用额度']) / np.sum(totalCreditDf['账户授信额度']), 2)
  2124. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡账户最高使用额度总的使用率'] = round(
  2125. np.sum(useCreditDf['最大使用额']) / np.sum(totalCreditDf['账户授信额度']), 2)
  2126. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡账户近6月平均额度总的使用率'] = round(
  2127. np.sum(useCreditDf['最近6个月平均使用额度']) / np.sum(totalCreditDf['账户授信额度']), 2)
  2128. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡最大逾期期数'] = np.max(creditDf['当前逾期期数']) # 用于计算
  2129. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡最大逾期金额'] = np.max(creditDf['当前逾期总额'])
  2130. #1112 修改
  2131. otherDf.loc[otherIndex, '贷记卡当前逾期金额'] = np.sum(creditDf['当前逾期总额'])
  2132. if not creditDf.empty:
  2133. creditDf = creditDf.reset_index(drop=True)
  2134. maxOverdueIndex = np.argmax(creditDf['当前逾期期数'])
  2135. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡最大逾期期数对应的最大逾期金额'] = \
  2136. creditDf.loc[maxOverdueIndex, :]['当前逾期总额']
  2137. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近3月开卡最高额度'] = cip.getLastMonthMaxCreditAmt(df,
  2138. reportTime,
  2139. 3)
  2140. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近3月开卡最低额度'] = cip.getLastMonthMinCreditAmt(df,
  2141. reportTime,
  2142. 3)
  2143. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近3月开卡平均额度'] = cip.getLastMonthAvgCreditAmt(df,
  2144. reportTime,
  2145. 3)
  2146. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近6月开卡最高额度'] = cip.getLastMonthMaxCreditAmt(df,
  2147. reportTime,
  2148. 6)
  2149. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近6月开卡最低额度'] = cip.getLastMonthMinCreditAmt(df,
  2150. reportTime,
  2151. 6)
  2152. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近6月开卡平均额度'] = cip.getLastMonthAvgCreditAmt(df,
  2153. reportTime,
  2154. 6)
  2155. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近12月开卡最高额度'] = cip.getLastMonthMaxCreditAmt(df,
  2156. reportTime,
  2157. 12)
  2158. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近12月开卡最低额度'] = cip.getLastMonthMinCreditAmt(df,
  2159. reportTime,
  2160. 12)
  2161. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近12月开卡平均额度'] = cip.getLastMonthAvgCreditAmt(df,
  2162. reportTime,
  2163. 12)
  2164. if not creditDf.empty:
  2165. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡最近一次还款日期距今时长'] = cip.getLastPayDateMinDays(
  2166. creditDf, reportTime)
  2167. paySo = np.sum(creditDf['本月应还款'])
  2168. if (paySo) != 0:
  2169. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡还款比例'] = round(
  2170. np.sum(creditDf['本月实还款']) / np.sum(creditDf['本月应还款']), 2)
  2171. creditDfTmp = creditDf[creditDf['本月应还款'] > 0]
  2172. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡最高还款比例'] = round(
  2173. np.max(np.divide(creditDfTmp['本月实还款'], creditDfTmp['本月应还款'])), 2)
  2174. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡最低还款比例'] = round(
  2175. np.min(np.divide(creditDfTmp['本月实还款'], creditDfTmp['本月应还款'])), 2)
  2176. #贷记卡疑似分期笔数 汇算
  2177. installmentDf = creditDf[(creditDf['本月实还款']>0) & (creditDf['本月应还款']>200) &(creditDf['本月实还款']< creditDf['本月应还款']/9)]
  2178. otherDf.loc[otherIndex, '贷记卡疑似分期笔数'] = installmentDf.index.size
  2179. normalDf = df[(df['币种'] == '人民币元') & (df['账户状态'] == '正常') & (df['当前逾期期数'] == 0)];
  2180. activeDf = df[(df['币种'] == '人民币元') & (df['账户状态'] == '正常')];
  2181. notCloseDf = df[(df['账户状态'] != '销户')]
  2182. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前正常贷记卡账户数'] = normalDf.index.size
  2183. if not notCloseDf.empty and not normalDf.empty:
  2184. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前正常贷记卡账户数占比'] = round(
  2185. normalDf.index.size / notCloseDf.index.size, 2)
  2186. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前正常贷记卡已用额度'] = np.sum(normalDf['已用额度'])
  2187. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前正常且有余额的贷记卡账户数'] = normalDf[
  2188. normalDf['已用额度'] > 0].index.size
  2189. if not creditDf.empty:
  2190. creditUseAmt = np.sum(creditDf['已用额度'])
  2191. if creditUseAmt != 0:
  2192. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前正常贷记卡账户余额占总余额比'] = round(
  2193. np.sum(normalDf['已用额度']) / np.sum(creditDf['已用额度']), 2)
  2194. if notCloseDf.empty:
  2195. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前正常且有余额的贷记卡账户数占比'] = -99
  2196. else:
  2197. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前正常且有余额的贷记卡账户数占比'] = \
  2198. round(creditCardAccountInfoDf.loc[
  2199. creditCardAccountInfoIndex, '当前正常且有余额的贷记卡账户数'] / notCloseDf.index.size, 3)
  2200. # 当前正常贷记卡账户余额占总余额比
  2201. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡本月实还金额总和'] = np.sum(creditDf['本月实还款'])
  2202. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡本月应还金额总和'] = np.sum(creditDf['本月应还款'])
  2203. maxAmtDf = df[(df['币种'] == '人民币元')]
  2204. if not maxAmtDf.empty:
  2205. maxAmtDf = maxAmtDf.reset_index(drop=True)
  2206. maxAmtIndex = np.argmax(maxAmtDf['账户授信额度'])
  2207. maxOpenDate = maxAmtDf.loc[maxAmtIndex, :]['开立日期'];
  2208. creditCardAccountInfoDf.loc[
  2209. creditCardAccountInfoIndex, '额度最高的人民币贷记卡开卡距今月份数'] = utils.difMonthReportTime(maxOpenDate,reportTime);
  2210. # 名下贷记卡数量-状态正常
  2211. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡数量-状态正常'] = df[
  2212. (df['账户状态'] != '销户')].index.size
  2213. # 名下贷记卡数量-状态未激活
  2214. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡数量-状态未激活'] = df[
  2215. (df['账户状态'] == '未激活')].index.size
  2216. # 名下贷记卡数量-状态异常异常包含(2-冻结,3-止付,5-呆帐,10-其他)
  2217. abnormalList = ['冻结', '止付', '呆账', '司法追偿','银行止付']#原来为其他
  2218. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡数量-状态异常'] = df[(df['账户状态'].isin(abnormalList))].index.size
  2219. # 名下贷记卡比例-状态正常
  2220. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡比例-状态正常'] = round(
  2221. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡数量-状态正常'] / df.index.size, 2)
  2222. # 名下贷记卡比例-状态未激活
  2223. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡比例-状态未激活'] = round(
  2224. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡数量-状态未激活'] / df.index.size, 2)
  2225. # 名下贷记卡比例-状态异常
  2226. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡比例-状态异常'] = round(
  2227. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '名下贷记卡数量-状态异常'] / df.index.size, 2)
  2228. #1113汇算
  2229. abnormalList = ['冻结', '止付', '呆账', '司法追偿','银行止付']
  2230. otherDf.loc[otherIndex, "贷记卡状态为('呆账','冻结','止付','司法追偿')的账户数"] = df[(df['账户状态'].isin(abnormalList))].index.size
  2231. availableCreditDf = activeDf[activeDf['最近6个月平均使用额度'] > 500] #正常的信用卡
  2232. otherDf.loc[otherIndex, '有效信用卡张数'] = availableCreditDf.index.size
  2233. #使用中的所有贷记卡中发卡时间距征信查询时间的最大天数 0111三寿
  2234. if not activeDf.empty:
  2235. fstDate = np.min(activeDf['开立日期']);
  2236. sanshouDf.loc[sanshouIndex,"使用中贷记卡最早发卡天数"]=utils.difDateReportTime(reportTime, fstDate)
  2237. # 解析准贷记卡账户信息指标
  2238. def parseCreditCardMergeDfZ(self,df, payRcd):
  2239. if not df.empty:
  2240. overdueCreditCardRcdDf = payRcd[payRcd['账户编号'].isin(df['账户编号'].values)];
  2241. overdueCreditCardRcdDf = utils.replacePayRcdStatusOverdue(overdueCreditCardRcdDf)
  2242. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '本月应还款(合计)'] = np.nansum(df['透支余额'])
  2243. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '本月实还款(合计)'] = np.nansum(df['本月实还款'])
  2244. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '最近一次还款日期'] = np.nanmax(df['最近一次还款日期'])
  2245. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '当前一共透支期数'] = cip.getCurOverdueNum(
  2246. overdueCreditCardRcdDf);
  2247. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '当前一共透支总额'] = np.nansum(df['透支余额'])
  2248. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '透支180天以上未支付余额(合计)'] = np.nansum(
  2249. df['透支180天以上未付余额'])
  2250. # 名下贷记卡数量-状态异常异常包含(2-冻结,3-止付,5-呆帐,10-其他)
  2251. abnormalList = ['冻结', '止付', '呆账', '其他','银行止付']
  2252. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '名下准贷记卡数量-状态异常'] = df[(df['账户状态'].isin(abnormalList))].index.size
  2253. creditDf = df[(df['账户状态'] != '未激活') & (df['账户状态'] != '销户')]
  2254. if not creditDf.empty:
  2255. totalAmt = np.nansum(creditDf['账户授信额度'])
  2256. creditAmt = np.nansum(creditDf['透支余额'])
  2257. if totalAmt != 0:
  2258. # 从“贷记卡信息”中提取,剔除未激活、销户后,所有账户透支金额/所有账户账户授信额度。
  2259. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '全部准贷记卡账户当前总额度使用率'] = round(
  2260. creditAmt / totalAmt, 2)
  2261. # 从“贷记卡信息”中提取,剔除未激活、销户后,MAX(单账户最高透支金额/单账户授信额度)
  2262. creditMaxDf = creditDf[creditDf['账户授信额度'] > 0]
  2263. if not creditMaxDf.empty:
  2264. creditMaxDf = creditMaxDf.fillna(0.0)
  2265. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '准贷记卡账户最高使用额度总的使用率'] = round(
  2266. np.max(np.divide(creditMaxDf['最大透支余额'], creditMaxDf['账户授信额度'])), 2)
  2267. creditMaxDf = creditDf[creditDf['最大透支余额'] > 0]
  2268. if not creditMaxDf.empty:
  2269. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '当前准贷记卡最大透支金额'] = np.max(
  2270. creditMaxDf['最大透支余额'])
  2271. # 从“贷记卡信息”中提取,剔除未激活、销户后,当前透支准贷记卡账户数/总准贷记卡账户数,透支账户判断:透支余额不为0的账户
  2272. creditDfTmp = creditDf[creditDf['透支余额'] > 0]
  2273. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '当前准贷记卡透支账户数占比'] = round(
  2274. creditDfTmp.index.size / creditDf.index.size, 2)
  2275. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '当前准贷记卡本月应还金额总和'] = np.nansum(df['透支余额'])
  2276. creditCardAccountInfoDfZ.loc[creditCardAccountInfoIndexZ, '当前准贷记卡本月实还金额总和'] = np.nansum(df['本月实还款'])
  2277. # 解析使用率 TODO 使用汇总计算还是使用明细计算
  2278. def parseUseRate(self):
  2279. # useRateDf.loc[useRateIndex, '贷记卡账户使用率(已用额度/授信总额)']
  2280. # 从“信贷交易授信及负债信息概要”中“非循环贷账户信息汇总”、“循环额度下分账户信息汇总”、“循环贷账户信息汇总”、“贷记卡账户信息汇总”和“准贷记卡账户信息汇总”里提取,SUM(
  2281. # 所有“余额”、“已用额度”和“透支余额”) / SUM(所有“授信总额”和“授信额度”)
  2282. loanUseAmt = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户余额']
  2283. cycleCreditUseAmt = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户余额']
  2284. cycleUseAmt = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环贷账户余额']
  2285. creditUseAmt = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡已用额度']
  2286. creditAmtUseZ = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡已用额度']
  2287. loanTotalAmt = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '非循环贷账户授信总额']
  2288. cycleCreditTotalAmt = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环额度下分账户授信总额']
  2289. cycleTotalAmt = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '循环贷账户授信总额']
  2290. creditTotalAmt = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '贷记卡授信总额']
  2291. creditAmtTotalZ = briefInfoDf_loanTradeCreditInfo.loc[loanTradeCreditInfoIndex, '准贷记卡授信总额']
  2292. # if str(loanUseAmt)=="nan":
  2293. # loanUseAmt = 0;
  2294. # if str(cycleCreditUseAmt) == "nan":
  2295. # loanUseAmt = 0;
  2296. # if str(cycleCreditUseAmt) == "nan":
  2297. # loanUseAmt = 0;
  2298. useAmt = loanUseAmt + cycleCreditUseAmt + cycleUseAmt + creditUseAmt + creditAmtUseZ
  2299. totalAmt = loanTotalAmt + cycleCreditTotalAmt + cycleTotalAmt + creditTotalAmt + creditAmtTotalZ
  2300. if totalAmt != 0:
  2301. useRateDf.loc[useRateIndex, '全账户使用率(已用额度/授信总额)'] = round(useAmt / totalAmt, 2)
  2302. if loanTotalAmt != 0:
  2303. useRateDf.loc[useRateIndex, '非循环贷账户使用率(已用额度/授信总额)'] = round(loanUseAmt / loanTotalAmt, 2)
  2304. if cycleCreditTotalAmt != 0:
  2305. useRateDf.loc[useRateIndex, '循环额度下分账户使用率(已用额度/授信总额)'] = round(cycleCreditTotalAmt / cycleCreditTotalAmt, 2)
  2306. if cycleTotalAmt != 0:
  2307. useRateDf.loc[useRateIndex, '循环贷账户使用率(已用额度/授信总额)'] = round(cycleUseAmt / cycleTotalAmt, 2)
  2308. if creditTotalAmt != 0:
  2309. useRateDf.loc[useRateIndex, '贷记卡账户使用率(已用额度/授信总额)'] = round(creditUseAmt / creditTotalAmt, 2)
  2310. if creditAmtTotalZ != 0:
  2311. useRateDf.loc[useRateIndex, '准贷记卡账户使用率(已用额度/授信总额)'] = round(creditAmtUseZ / creditAmtTotalZ, 2)
  2312. # 解析开户数
  2313. def parseOpenAccount(self,loanDf, creditCardDf, creditCardDfZ, recoveryInfoMergeDf, loanPayRecordMergeDf,
  2314. creditCardPayRecordMergeDf, creditCardPayRecordMergeDfZ,reportTime):
  2315. openAccountDf.loc[openAccountIndex, '近3个月全账户开户数'] = cip.getOpenAccount(loanDf, reportTime,
  2316. 3) + cip.getOpenAccount(creditCardDf,
  2317. reportTime,
  2318. 3) + cip.getOpenAccount(
  2319. creditCardDfZ, reportTime, 3)
  2320. openAccountDf.loc[openAccountIndex, '近6个月全账户开户数'] = cip.getOpenAccount(loanDf, reportTime,
  2321. 6) + cip.getOpenAccount(creditCardDf,
  2322. reportTime,
  2323. 6) + cip.getOpenAccount(
  2324. creditCardDfZ, reportTime, 6)
  2325. openAccountDf.loc[openAccountIndex, '近9个月全账户开户数'] = cip.getOpenAccount(loanDf, reportTime,
  2326. 9) + cip.getOpenAccount(creditCardDf,
  2327. reportTime,
  2328. 9) + cip.getOpenAccount(
  2329. creditCardDfZ, reportTime, 9)
  2330. openAccountDf.loc[openAccountIndex, '近12个月全账户开户数'] = cip.getOpenAccount(loanDf, reportTime,
  2331. 12) + cip.getOpenAccount(creditCardDf,
  2332. reportTime,
  2333. 12) + cip.getOpenAccount(
  2334. creditCardDfZ, reportTime, 12)
  2335. openAccountDf.loc[openAccountIndex, '近24个月全账户开户数'] = cip.getOpenAccount(loanDf, reportTime,
  2336. 24) + cip.getOpenAccount(creditCardDf,
  2337. reportTime,
  2338. 24) + cip.getOpenAccount(
  2339. creditCardDfZ, reportTime, 24)
  2340. openAccountDf.loc[openAccountIndex, '近3个月消费金融类账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 3,
  2341. consts.bankList)
  2342. openAccountDf.loc[openAccountIndex, '近6个月消费金融类账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 6,
  2343. consts.bankList)
  2344. openAccountDf.loc[openAccountIndex, '近9个月消费金融类账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 9,
  2345. consts.bankList)
  2346. openAccountDf.loc[openAccountIndex, '近12个月消费金融类账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 12,
  2347. consts.bankList)
  2348. openAccountDf.loc[openAccountIndex, '近24个月消费金融类账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 24,
  2349. consts.bankList)
  2350. openAccountDf.loc[openAccountIndex, '近3个月贷款账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 3, "")
  2351. openAccountDf.loc[openAccountIndex, '近6个月贷款账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 6, "")
  2352. openAccountDf.loc[openAccountIndex, '近9个月贷款账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 9, "")
  2353. openAccountDf.loc[openAccountIndex, '近12个月贷款账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 12, "")
  2354. openAccountDf.loc[openAccountIndex, '近24个月贷款账户开户数'] = lip.getOpenAccount(loanDf, reportTime, 24, "")
  2355. openAccountDf.loc[openAccountIndex, '近3个月贷记卡账户开户数'] = cip.getOpenAccount(creditCardDf, reportTime, 3)
  2356. openAccountDf.loc[openAccountIndex, '近6个月贷记卡账户开户数'] = cip.getOpenAccount(creditCardDf, reportTime, 6)
  2357. openAccountDf.loc[openAccountIndex, '近9个月贷记卡账户开户数'] = cip.getOpenAccount(creditCardDf, reportTime, 9)
  2358. openAccountDf.loc[openAccountIndex, '近12个月贷记卡账户开户数'] = cip.getOpenAccount(creditCardDf, reportTime, 12)
  2359. openAccountDf.loc[openAccountIndex, '近24个月贷记卡账户开户数'] = cip.getOpenAccount(creditCardDf, reportTime, 24)
  2360. openAccountDf.loc[openAccountIndex, '近3个月准贷记卡账户开户数'] = cip.getOpenAccount(creditCardDfZ, reportTime, 3)
  2361. openAccountDf.loc[openAccountIndex, '近6个月准贷记卡账户开户数'] = cip.getOpenAccount(creditCardDfZ, reportTime, 6)
  2362. openAccountDf.loc[openAccountIndex, '近9个月准贷记卡账户开户数'] = cip.getOpenAccount(creditCardDfZ, reportTime, 9)
  2363. openAccountDf.loc[openAccountIndex, '近12个月准贷记卡账户开户数'] = cip.getOpenAccount(creditCardDfZ, reportTime, 12)
  2364. openAccountDf.loc[openAccountIndex, '近24个月准贷记卡账户开户数'] = cip.getOpenAccount(creditCardDfZ, reportTime, 24)
  2365. #三寿
  2366. sanshouDf.loc[sanshouIndex, '最近24M发卡数量'] = cip.getOpenAccount(creditCardDf, reportTime, 24)+cip.getOpenAccount(creditCardDfZ, reportTime, 24)
  2367. # 从“信贷交易信息明细”中“非循环贷账户”、“循环额度下分账户”、“循环贷账户”、“贷记卡账户”和“准贷记卡账户”里提取,5年里账户还款状态出现“1、2、3、4、5、6、7、D、Z、G、B”的账户数/所有账户数
  2368. overdueLoanPayRcdDf = loanPayRecordMergeDf[loanPayRecordMergeDf['账户编号'].isin(loanDf['账户编号'].values)]
  2369. overdueLoanPayRcdDf = utils.replacePayRcdStatusOverdue(overdueLoanPayRcdDf)
  2370. overdueLoanPayRcdDf = overdueLoanPayRcdDf[overdueLoanPayRcdDf['还款状态'] > 0]
  2371. overdueCreditPayRcdDf = creditCardPayRecordMergeDf[
  2372. creditCardPayRecordMergeDf['账户编号'].isin(creditCardDf['账户编号'].values)]
  2373. overdueCreditPayRcdDf = utils.replacePayRcdStatusOverdue(overdueCreditPayRcdDf)
  2374. overdueCreditPayRcdDf = overdueCreditPayRcdDf[overdueCreditPayRcdDf['还款状态'] > 0]
  2375. overdueCreditPayRcdDfZ = creditCardPayRecordMergeDfZ[
  2376. creditCardPayRecordMergeDfZ['账户编号'].isin(creditCardDfZ['账户编号'].values)]
  2377. overdueCreditPayRcdDfZ = utils.replacePayRcdStatusOverdue(overdueCreditPayRcdDfZ)
  2378. overdueCreditPayRcdDfZ = overdueCreditPayRcdDfZ[overdueCreditPayRcdDfZ['还款状态'] > 0]
  2379. loanAccountNum = loanPayRecordMergeDf['账户编号'].unique().size
  2380. creditAccountNum = creditCardPayRecordMergeDf['账户编号'].unique().size
  2381. creditAccountNumZ = creditCardPayRecordMergeDfZ['账户编号'].unique().size
  2382. overdueLoanNum = overdueLoanPayRcdDf['账户编号'].unique().size
  2383. overdueCreditNum = overdueCreditPayRcdDf['账户编号'].unique().size
  2384. overdueCreditNumZ = overdueCreditPayRcdDfZ['账户编号'].unique().size
  2385. if (loanAccountNum + creditAccountNum + creditAccountNumZ) > 0:
  2386. openAccountDf.loc[openAccountIndex, '有过逾期记录的账户/全账户数'] = round(
  2387. (overdueLoanNum + overdueCreditNum + overdueCreditNumZ) / (
  2388. loanAccountNum + creditAccountNum + creditAccountNumZ), 2)
  2389. otherPerLoanDf = loanDf[loanDf['业务种类'].isin(consts.bankList)]
  2390. otherPerLoanNum = otherPerLoanDf.index.size;
  2391. overdueOtherPerLoanNum = otherPerLoanDf[
  2392. otherPerLoanDf['账户编号'].isin(overdueLoanPayRcdDf['账户编号'].values)].index.size;
  2393. if otherPerLoanNum != 0:
  2394. openAccountDf.loc[openAccountIndex, '有过逾期记录的消费金融类账户/全消费金融类账户数'] = round(
  2395. overdueOtherPerLoanNum / otherPerLoanNum, 2)
  2396. if loanAccountNum != 0:
  2397. openAccountDf.loc[openAccountIndex, '有过逾期记录的贷款账户/全贷款账户数'] = round(overdueLoanNum / loanAccountNum, 2)
  2398. if creditAccountNum != 0:
  2399. openAccountDf.loc[openAccountIndex, '有过逾期记录的贷记卡账户/全贷记卡账户数'] = round(overdueCreditNum / creditAccountNum, 2)
  2400. if creditAccountNumZ != 0:
  2401. openAccountDf.loc[openAccountIndex, '有过透支记录的准贷记卡账户/全准贷记卡账户数'] = round(overdueCreditNumZ / creditAccountNumZ,
  2402. 2)
  2403. # 0525新增
  2404. pledgeLoanDf = loanDf[loanDf['担保方式'] == '抵押']
  2405. pledgeCreditCardDf = creditCardDf[creditCardDf['担保方式'] == '抵押']
  2406. pledgeCreditCardDfZ = creditCardDfZ[creditCardDfZ['担保方式'] == '抵押']
  2407. isPledge = "否"
  2408. if pledgeLoanDf.index.size + pledgeCreditCardDf.index.size + pledgeCreditCardDfZ.index.size > 0:
  2409. isPledge = "是"
  2410. creditLoanDf = loanDf[loanDf['担保方式'] == '信用/免担保']
  2411. creditCreditCardDf = creditCardDf[creditCardDf['担保方式'] == '信用/免担保']
  2412. creditCreditCardDfZ = creditCardDfZ[creditCardDfZ['担保方式'] == '信用/免担保']
  2413. isCredit = 0
  2414. if creditLoanDf.index.size + creditCreditCardDf.index.size + creditCreditCardDfZ.index.size > 0:
  2415. isCredit = creditLoanDf.index.size + creditCreditCardDf.index.size + creditCreditCardDfZ.index.size
  2416. briefInfoDf_loanTradeInfo.loc[loanTradeInfoIndex, '是否存在担保方式为抵押的贷款'] = isPledge
  2417. briefInfoDf_loanTradeInfo.loc[loanTradeInfoIndex, '担保方式为信用的贷款数量'] = isCredit
  2418. #使用中贷记卡平均发卡天数
  2419. try:
  2420. sanshouDf.loc[sanshouIndex, '使用中贷记卡平均发卡天数'] = cip.getAvgUseCreditCardDay(creditCardDf,creditCardDfZ,reportTime)
  2421. sanshouDf.loc[sanshouIndex, '最大信用账户天数(贷款&贷记卡人民账户)'] = cip.getMaxAmtAccountDay(loanDf,creditCardDf,creditCardDfZ ,reportTime)
  2422. sanshouDf.loc[sanshouIndex, '额度使用>=50%的贷记卡数'] = cip.getUseRateCount(creditCardDf,creditCardDfZ,0.5)
  2423. sanshouDf.loc[sanshouIndex, '额度使用>=75%的贷记卡数'] = cip.getUseRateCount(creditCardDf, creditCardDfZ, 0.75)
  2424. sanshouDf.loc[sanshouIndex, '额度使用>=100%的贷记卡数'] = cip.getUseRateCount(creditCardDf, creditCardDfZ, 1)
  2425. minMonthStr = ""
  2426. fstLoanMon = str(otherDf.loc[otherIndex, '首笔贷款发放月份'])
  2427. fstCreditCardMonth = str(otherDf.loc[otherIndex, '首张贷记卡发卡月份'])
  2428. if fstLoanMon=="nan":
  2429. fstLoanMon = ""
  2430. if fstCreditCardMonth=="nan":
  2431. fstCreditCardMonth = ""
  2432. if fstLoanMon=='' and fstCreditCardMonth!='':
  2433. minMonthStr = otherDf.loc[otherIndex, '首张贷记卡发卡月份']
  2434. elif fstLoanMon!='' and fstCreditCardMonth!='':
  2435. minMonth = [otherDf.loc[otherIndex, '首笔贷款发放月份'], otherDf.loc[otherIndex, '首张贷记卡发卡月份']]
  2436. minMonthStr = min(minMonth)
  2437. elif fstLoanMon!='' and fstCreditCardMonth=='':
  2438. minMonthStr = otherDf.loc[otherIndex, '首笔贷款发放月份']
  2439. if minMonthStr != '':
  2440. sanshouDf.loc[sanshouIndex, '贷款、贷记卡最大天数'] = utils.difDateReportTime(reportTime, minMonthStr)
  2441. if not loanDf.empty:
  2442. openAccount3MDf = loanDf[loanDf['开立日期'] < utils.getLastMonthDate(reportTime, 6)]
  2443. sanshouDf.loc[sanshouIndex, '开户180天以上的贷款笔数'] = openAccount3MDf.index.size
  2444. if not creditCardDf.empty:
  2445. sanshouDf.loc[sanshouIndex, '开户1年以内历史逾期90+贷记卡和准贷记卡数'] =cip.getOverDueCount(creditCardDf,creditCardPayRecordMergeDf,reportTime,3,12)\
  2446. +cip.getOverDueCount(creditCardDfZ,creditCardPayRecordMergeDfZ,reportTime,3,12)
  2447. sanshouDf.loc[sanshouIndex, '开户1年以内历史逾期贷记卡和准贷记卡数'] = cip.getOverDueCount(creditCardDf,creditCardPayRecordMergeDf,reportTime, 1, 12)\
  2448. +cip.getOverDueCount(creditCardDfZ, creditCardPayRecordMergeDfZ, reportTime, 1, 12)
  2449. sanshouDf.loc[sanshouIndex, '开户2年以内历史逾期贷记卡数'] = cip.getOverDueCount(creditCardDf,creditCardPayRecordMergeDf,reportTime, 1, 24)
  2450. except:
  2451. logger.error(traceback.print_exc())
  2452. logger.error(traceback.format_exc())
  2453. # 解析24期还款状态指标
  2454. def parsePayRcdStatus(self,loanMergeDf, creditCardMergeDf, creditCardMergeDfZ, loanPayRecordMergeDf,
  2455. creditCardPayRecordMergeDf, creditCardPayRecordMergeDfZ,reportTime):
  2456. # creditCardPayRecordMergeDf
  2457. # 去掉外币
  2458. creditCardMergeDf = creditCardMergeDf[creditCardMergeDf['币种'] == '人民币元']
  2459. creditCardPayRecordMergeDf = creditCardPayRecordMergeDf[
  2460. creditCardPayRecordMergeDf['账户编号'].isin(creditCardMergeDf['账户编号'].values)]
  2461. reportTime = str(np.datetime64(reportTime, "M")) + "-02" # 06-02,统计24期还款状态报告期,按每月的2号,避免chu'xian
  2462. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近3月逾期期数大于或等于“1”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2463. reportTime, 1, 3)
  2464. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近6月逾期期数大于或等于“1”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2465. reportTime, 1, 6)
  2466. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近12月逾期期数大于或等于“1”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2467. reportTime, 1, 12)
  2468. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近24月逾期期数大于或等于“1”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2469. reportTime, 1, 24)
  2470. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近6月逾期期数大于或等于“2”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2471. reportTime, 2, 6)
  2472. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近12月逾期期数大于或等于“2”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2473. reportTime, 2, 12)
  2474. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近24月逾期期数大于或等于“2”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2475. reportTime, 2, 24)
  2476. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近6月逾期期数大于或等于“3”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2477. reportTime, 3, 6)
  2478. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近12月逾期期数大于或等于“3”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2479. reportTime, 3, 12)
  2480. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近24月逾期期数大于或等于“3”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2481. reportTime, 3, 24)
  2482. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近12月逾期期数大于或大等于“4”的次数'] = prp.getLoanOverdueTimes(
  2483. loanPayRecordMergeDf, reportTime, 4, 12)
  2484. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近24月逾期期数大于或等于“4”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2485. reportTime, 4, 24)
  2486. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近3月逾期期数大于或等于“1”的次数'] = cip.getLoanOverdueTimes(
  2487. creditCardPayRecordMergeDf, reportTime, 1, 3)
  2488. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近6月逾期期数大于或等于“1”的次数'] = cip.getLoanOverdueTimes(
  2489. creditCardPayRecordMergeDf, reportTime, 1, 6)
  2490. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近12月逾期期数大于或等于“1”的次数'] = cip.getLoanOverdueTimes(
  2491. creditCardPayRecordMergeDf, reportTime, 1, 12)
  2492. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近24月逾期期数大于或等于“1”的次数'] = cip.getLoanOverdueTimes(
  2493. creditCardPayRecordMergeDf, reportTime, 1, 24)
  2494. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近6月逾期期数大于或等于“2”的次数'] = cip.getLoanOverdueTimes(
  2495. creditCardPayRecordMergeDf, reportTime, 2, 6)
  2496. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近12月逾期期数大于或等于“2”的次数'] = cip.getLoanOverdueTimes(
  2497. creditCardPayRecordMergeDf, reportTime, 2, 12)
  2498. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近24月逾期期数大于或等于“2”的次数'] = cip.getLoanOverdueTimes(
  2499. creditCardPayRecordMergeDf, reportTime, 2, 24)
  2500. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近6月逾期期数大于或等于“3”的次数'] = cip.getLoanOverdueTimes(
  2501. creditCardPayRecordMergeDf, reportTime, 3, 6)
  2502. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近12月逾期期数大于或等于“3”的次数'] = cip.getLoanOverdueTimes(
  2503. creditCardPayRecordMergeDf, reportTime, 3, 12)
  2504. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近24月逾期期数大于或等于“3”的次数'] = cip.getLoanOverdueTimes(
  2505. creditCardPayRecordMergeDf, reportTime, 3, 24)
  2506. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近12月逾期期数大于或等于“4”的次数'] = cip.getLoanOverdueTimes(
  2507. creditCardPayRecordMergeDf, reportTime, 4, 12)
  2508. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近24月逾期期数大于或等于“4”的次数'] = cip.getLoanOverdueTimes(
  2509. creditCardPayRecordMergeDf, reportTime, 4, 24)
  2510. payRcdStatusDf.loc[payRcdStatusIndex, '准贷记卡账户近6月逾期期数大于或等于“3”的次数'] = cip.getLoanOverdueTimes(
  2511. creditCardPayRecordMergeDfZ, reportTime, 3, 6)
  2512. payRcdStatusDf.loc[payRcdStatusIndex, '准贷记卡账户近12月逾期期数大于或等于“3”的次数'] = cip.getLoanOverdueTimes(
  2513. creditCardPayRecordMergeDfZ, reportTime, 3, 12)
  2514. payRcdStatusDf.loc[payRcdStatusIndex, '准贷记卡账户近24月逾期期数大于或等于“3”的次数'] = cip.getLoanOverdueTimes(
  2515. creditCardPayRecordMergeDfZ, reportTime, 3, 24)
  2516. payRcdStatusDf.loc[payRcdStatusIndex, '准贷记卡账户近6月逾期期数大于或等于“4”的次数'] = cip.getLoanOverdueTimes(
  2517. creditCardPayRecordMergeDfZ, reportTime, 4, 6)
  2518. payRcdStatusDf.loc[payRcdStatusIndex, '准贷记卡账户近12月逾期期数大于或等于“4”的次数'] = cip.getLoanOverdueTimes(
  2519. creditCardPayRecordMergeDfZ, reportTime, 4, 12)
  2520. payRcdStatusDf.loc[payRcdStatusIndex, '准贷记卡账户近24月逾期期数大于或等于“4”的次数'] = cip.getLoanOverdueTimes(
  2521. creditCardPayRecordMergeDfZ, reportTime, 4, 24)
  2522. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近3月逾期期数大于或等于“1”的次数'] = prp.getLoanOverdueTimes(loanPayRecordMergeDf,
  2523. reportTime, 1, 3) \
  2524. + cip.getLoanOverdueTimes(
  2525. creditCardPayRecordMergeDf, reportTime, 1, 3) + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ,
  2526. reportTime, 1, 3)
  2527. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近6月逾期期数大于或等于“1”的次数'] = \
  2528. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 1, 6) + cip.getLoanOverdueTimes(
  2529. creditCardPayRecordMergeDf, reportTime, 1, 6) \
  2530. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 1, 6)
  2531. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近12月逾期期数大于或等于“1”的次数'] = \
  2532. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 1, 12) + cip.getLoanOverdueTimes(
  2533. creditCardPayRecordMergeDf, reportTime, 1, 12) \
  2534. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 1, 12)
  2535. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近24月逾期期数大于或等于“1”的次数'] = \
  2536. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 1, 24) + cip.getLoanOverdueTimes(
  2537. creditCardPayRecordMergeDf, reportTime, 1, 24) \
  2538. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 1, 24)
  2539. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近6月逾期期数大于或等于“2”的次数'] = \
  2540. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 2, 6) + cip.getLoanOverdueTimes(
  2541. creditCardPayRecordMergeDf, reportTime, 2, 6) \
  2542. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 2, 6)
  2543. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近12月逾期期数大于或等于“2”的次数'] = \
  2544. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 2, 12) + cip.getLoanOverdueTimes(
  2545. creditCardPayRecordMergeDf, reportTime, 2, 12) \
  2546. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 2, 12)
  2547. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近24月逾期期数大于或等于“2”的次数'] = \
  2548. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 2, 24) + cip.getLoanOverdueTimes(
  2549. creditCardPayRecordMergeDf, reportTime, 2, 24) \
  2550. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 2, 24)
  2551. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近6月逾期期数大于或等于“3”的次数'] = \
  2552. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 3, 6) + cip.getLoanOverdueTimes(
  2553. creditCardPayRecordMergeDf, reportTime, 3, 6) \
  2554. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 3, 6)
  2555. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近12月逾期期数大于或等于“3”的次数'] = \
  2556. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 3, 12) + cip.getLoanOverdueTimes(
  2557. creditCardPayRecordMergeDf, reportTime, 3, 12) \
  2558. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 3, 12)
  2559. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近24月逾期期数大于或等于“3”的次数'] = \
  2560. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 3, 24) + cip.getLoanOverdueTimes(
  2561. creditCardPayRecordMergeDf, reportTime, 3, 24) \
  2562. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 3, 24)
  2563. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近12月逾期期数大于或等于“4”的次数'] = \
  2564. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 4, 12) + cip.getLoanOverdueTimes(
  2565. creditCardPayRecordMergeDf, reportTime, 4, 12) \
  2566. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 4, 12)
  2567. payRcdStatusDf.loc[payRcdStatusIndex, '全账户近24月逾期期数大于或等于“4”的次数'] = \
  2568. prp.getLoanOverdueTimes(loanPayRecordMergeDf, reportTime, 4, 24) + cip.getLoanOverdueTimes(
  2569. creditCardPayRecordMergeDf, reportTime, 4, 24) \
  2570. + cip.getLoanOverdueTimes(creditCardPayRecordMergeDfZ, reportTime, 4, 24)
  2571. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近24个月是否出现"G"'] = prp.isExistsInd(loanPayRecordMergeDf, reportTime,
  2572. "G", 24)
  2573. payRcdStatusDf.loc[payRcdStatusIndex, '贷记卡账户近24个月是否出现"G"'] = prp.isExistsInd(creditCardPayRecordMergeDf,
  2574. reportTime, "G", 24)
  2575. payRcdStatusDf.loc[payRcdStatusIndex, '准贷记卡账户近24个月是否出现"G"'] = prp.isExistsInd(creditCardPayRecordMergeDfZ,
  2576. reportTime, "G", 24)
  2577. payRcdStatusDf.loc[payRcdStatusIndex, '贷款账户近24个月是否出现"Z"'] = prp.isExistsInd(loanPayRecordMergeDf, reportTime,
  2578. "Z", 24)
  2579. payRcdStatusDf.loc[payRcdStatusIndex, '用户所有贷款账户过去24个月存在逾期的账户数目'] = prp.getLoanOverdueCount(loanPayRecordMergeDf,
  2580. reportTime, 24)
  2581. payRcdStatusDf.loc[payRcdStatusIndex, '用户所有贷款账户过去24个月状态正常账户数目'] = prp.getLoanNormalCount(loanPayRecordMergeDf,
  2582. reportTime, 24)
  2583. payRcdStatusDf.loc[payRcdStatusIndex, '用户所有贷记卡账户过去24个月存在逾期的账户数目'] = prp.getLoanOverdueCount(
  2584. creditCardPayRecordMergeDf, reportTime, 24)
  2585. payRcdStatusDf.loc[payRcdStatusIndex, '用户所有贷记卡账户过去24个月状态正常的账户数目'] = prp.getLoanNormalCount(
  2586. creditCardPayRecordMergeDf, reportTime, 24)
  2587. payRcdStatusDf.loc[payRcdStatusIndex, '用户所有准贷记卡账户过去24个月存在逾期的账户数目'] = prp.getLoanOverdueCount(
  2588. creditCardPayRecordMergeDfZ, reportTime, 24)
  2589. payRcdStatusDf.loc[payRcdStatusIndex, '用户所有准贷记卡账户过去24个月状态正常的账户数目'] = prp.getLoanNormalCount(
  2590. creditCardPayRecordMergeDfZ, reportTime, 24)
  2591. payRcdStatusDf.loc[payRcdStatusIndex, '用户过去3个月最大逾期期数'] = prp.getPayRcdMaxOverdueNumAllAccout(
  2592. loanPayRecordMergeDf, creditCardPayRecordMergeDf, creditCardPayRecordMergeDfZ, reportTime, 3)
  2593. payRcdStatusDf.loc[payRcdStatusIndex, '用户过去6个月最大逾期期数'] = prp.getPayRcdMaxOverdueNumAllAccout(
  2594. loanPayRecordMergeDf, creditCardPayRecordMergeDf, creditCardPayRecordMergeDfZ, reportTime, 6)
  2595. payRcdStatusDf.loc[payRcdStatusIndex, '用户过去12个月最大逾期期数'] = prp.getPayRcdMaxOverdueNumAllAccout(
  2596. loanPayRecordMergeDf, creditCardPayRecordMergeDf, creditCardPayRecordMergeDfZ, reportTime, 12)
  2597. payRcdStatusDf.loc[payRcdStatusIndex, '用户过去24个月最大逾期期数'] = prp.getPayRcdMaxOverdueNumAllAccout(
  2598. loanPayRecordMergeDf, creditCardPayRecordMergeDf, creditCardPayRecordMergeDfZ, reportTime, 24)
  2599. # 概要信息里的字段,从还款状态计算
  2600. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndex, '该用户过去5年出现逾期的所有账户数目'] = \
  2601. prp.getLoanOverdueCount(loanPayRecordMergeDf, reportTime, 24 * 5) + prp.getLoanOverdueCount(
  2602. creditCardPayRecordMergeDf, reportTime, 24 * 5) \
  2603. + prp.getLoanOverdueCount(creditCardPayRecordMergeDfZ, reportTime, 24 * 5)
  2604. #1112
  2605. otherDf.loc[otherIndex, '近12个月最大逾期期数'] = prp.getPayRcdMaxOverdueNumAccout(
  2606. loanPayRecordMergeDf, creditCardPayRecordMergeDf, reportTime, 12)
  2607. # 解析贷记卡还款记录指标
  2608. def parseCreditCardMergeAndPayRecordDf(self,df, payRcdDf,reportTime):
  2609. if not df.empty and not payRcdDf.empty:
  2610. # 正常
  2611. normalDf = df[(df['账户状态'] != '未激活') & (df['账户状态'] != '销户') & (df['账户状态'] != '呆账')]
  2612. if not normalDf.empty:
  2613. overduePayRcdDf = payRcdDf[payRcdDf['账户编号'].isin(normalDf['账户编号'].values)]
  2614. overduePayRcdDf = utils.replacePayRcdStatus(overduePayRcdDf)
  2615. # 计算当前贷款,为还款记录的最后一期 0529
  2616. curOverduePayRcdDf = overduePayRcdDf.sort_values(by=["账户编号", "还款日期"], ascending=(True, False))
  2617. curOverduePayRcdDf = curOverduePayRcdDf.groupby(['账户编号']).head(1)
  2618. curOverduePayRcdDf = curOverduePayRcdDf[curOverduePayRcdDf['还款状态'] > 0]
  2619. # 临时保存,不用过滤还款状态为0的
  2620. payRcdMaxOverdueDf = overduePayRcdDf;
  2621. # overduePayRcdDf = overduePayRcdDf[overduePayRcdDf['还款状态'] > 0]
  2622. # creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡逾期账户数'] = curOverduePayRcdDf['账户编号'].unique().size
  2623. # 从“贷记卡信息”中提取,剔除“账户状态”为未激活、销户、呆账、呆帐后,“当前信用卡逾期账户数”/未销户贷记卡账户数(剔除“账户状态”为未激活、销户、呆账、呆帐后记录条数)
  2624. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡逾期账户数占比'] = round(
  2625. curOverduePayRcdDf['账户编号'].unique().size / normalDf.index.size, 2)
  2626. # 从“贷记卡信息”中提取,剔除“账户状态”为未激活、销户、呆账、呆帐后,对(当前信用卡逾期账户数)按“开户机构代码”去重统计账户状态为逾期,按按“开户机构代码”去重后的记录条数
  2627. overdueCreditCardDf = normalDf[normalDf['账户编号'].isin(curOverduePayRcdDf['账户编号'].values)]
  2628. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡逾期机构数'] = overdueCreditCardDf[
  2629. '发卡机构'].unique().size
  2630. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡逾期机构数占比'] = round(
  2631. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '当前贷记卡逾期机构数'] / normalDf[
  2632. '发卡机构'].unique().size, 2)
  2633. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近3月贷记卡最大逾期期数'] = cip.getPayRcdMaxOverdueNum(
  2634. payRcdMaxOverdueDf, 3);
  2635. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近6月贷记卡最大逾期期数'] = cip.getPayRcdMaxOverdueNum(
  2636. payRcdMaxOverdueDf, 6);
  2637. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近9月贷记卡最大逾期期数'] = cip.getPayRcdMaxOverdueNum(
  2638. payRcdMaxOverdueDf, 9);
  2639. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近12月贷记卡最大逾期期数'] = cip.getPayRcdMaxOverdueNum(
  2640. payRcdMaxOverdueDf, 12);
  2641. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '近24月贷记卡最大逾期期数'] = cip.getPayRcdMaxOverdueNum(
  2642. payRcdMaxOverdueDf, 24);
  2643. creditCardAccountInfoDf.loc[
  2644. creditCardAccountInfoIndex, '近24月贷记卡最大逾期距离现在的月数'] = cip.getPayRcdMaxOverdueNumMonth(
  2645. payRcdMaxOverdueDf, normalDf, reportTime, 24);
  2646. creditCardAccountInfoDf.loc[
  2647. creditCardAccountInfoIndex, '最近3个月贷记卡最大连续逾期月份数'] = cip.getContinuousOverdueMonth(payRcdMaxOverdueDf,
  2648. normalDf, 3);
  2649. creditCardAccountInfoDf.loc[
  2650. creditCardAccountInfoIndex, '最近6个月贷记卡最大连续逾期月份数'] = cip.getContinuousOverdueMonth(payRcdMaxOverdueDf,
  2651. normalDf, 6);
  2652. creditCardAccountInfoDf.loc[
  2653. creditCardAccountInfoIndex, '最近9个月贷记卡最大连续逾期月份数'] = cip.getContinuousOverdueMonth(payRcdMaxOverdueDf,
  2654. normalDf, 9);
  2655. creditCardAccountInfoDf.loc[
  2656. creditCardAccountInfoIndex, '最近12个月贷记卡最大连续逾期月份数'] = cip.getContinuousOverdueMonth(
  2657. payRcdMaxOverdueDf, normalDf, 12);
  2658. creditCardAccountInfoDf.loc[
  2659. creditCardAccountInfoIndex, '最近24个月贷记卡最大连续逾期月份数'] = cip.getContinuousOverdueMonth(
  2660. payRcdMaxOverdueDf, normalDf, 24);
  2661. # payRcdTimesDf = payRcdDf[payRcdDf['账户编号'].isin(normalDf['账户编号'].values)]
  2662. # payRcdTimesDf = payRcdTimesDf.sort_values(by=["账户编号", "还款日期"], ascending=(True, False))
  2663. # payRcdTimesDf = payRcdTimesDf.groupby(['账户编号']).head(24)
  2664. # payStatus = ["G", "D", "C", "N", "M", "1", "2", "3", "4", "5", "6", "7"]
  2665. # payRcdTimesDf = payRcdTimesDf[payRcdTimesDf['还款状态'].isin(payStatus)]
  2666. # payRcdTimes = payRcdTimesDf.groupby(['账户编号'])['还款状态'].count()
  2667. # # 从“贷记卡信息”中提取,剔除未激活、销户、呆账、呆帐后,各账户的还款次数统计“24个月(账户)还款状态”包含"G","D","C","N","M"及数字的个数
  2668. # creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡24期还款记录次数'] = np.max(payRcdTimes)
  2669. creditCardAccountInfoDf.loc[creditCardAccountInfoIndex, '贷记卡24期还款记录次数'] = cip.getPayRcdCount(payRcdDf,normalDf,24)
  2670. otherDf.loc[otherIndex, '近6个月有贷记卡还款记录的月份数'] = cip.getPayRcdCountNew(payRcdDf,reportTime,6)
  2671. otherDf.loc[otherIndex, '近12个月有贷记卡还款记录的月份数'] = cip.getPayRcdCountNew(payRcdDf, reportTime, 12)
  2672. # 解析贷款还款记录指标
  2673. def parseLoanMergeAndPayRecordDf(self,df, payRcdDf,reportTime):
  2674. if not df.empty and not payRcdDf.empty:
  2675. # 正常
  2676. normalDf = df[(df['账户状态'] != '结清') & (df['账户状态'] != '转出') & (df['账户状态'] != '呆账')]
  2677. overduePayRcdDf = payRcdDf[payRcdDf['账户编号'].isin(normalDf['账户编号'].values)]
  2678. overduePayRcdDf = utils.replacePayRcdStatus(overduePayRcdDf)
  2679. # 计算当前贷款,为还款记录的最后一期 0529
  2680. curOverduePayRcdDf = overduePayRcdDf.sort_values(by=["账户编号", "还款日期"], ascending=(True, False))
  2681. curOverduePayRcdDf = curOverduePayRcdDf.groupby(['账户编号']).head(1)
  2682. curOverduePayRcdDf = curOverduePayRcdDf[curOverduePayRcdDf['还款状态'] > 0]
  2683. # 临时保存,不用过滤还款状态为0的
  2684. payRcdMaxOverdueDf = overduePayRcdDf;
  2685. # 所有逾期的记录
  2686. # overduePayRcdDf = overduePayRcdDf[overduePayRcdDf['还款状态']>0]
  2687. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款逾期账户数'] = curOverduePayRcdDf['账户编号'].unique().size
  2688. if normalDf.index.size > 0:
  2689. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款逾期账户数占比'] = round(
  2690. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款逾期账户数'] / normalDf.index.size, 3)
  2691. # 存在逾期的贷款账户 非结清的过滤出逾期的账户号
  2692. overdueLoanDf = normalDf[normalDf['账户编号'].isin(curOverduePayRcdDf['账户编号'].values)]
  2693. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款逾期机构数'] = overdueLoanDf['管理机构'].unique().size
  2694. if normalDf['管理机构'].unique().size > 0:
  2695. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款逾期机构数占比'] = round(
  2696. loanAccountInfoDf.loc[loanAccountInfoIndex, '当前贷款逾期机构数'] / normalDf['管理机构'].unique().size, 2)
  2697. # 还款记录按日期排序最近3笔的最大逾期期数
  2698. loanAccountInfoDf.loc[loanAccountInfoIndex, '近1月贷款的最大逾期期数'] = prp.getPayRcdMaxOverdueNum(payRcdMaxOverdueDf,
  2699. 1);
  2700. loanAccountInfoDf.loc[loanAccountInfoIndex, '近3月贷款的最大逾期期数'] = prp.getPayRcdMaxOverdueNum(payRcdMaxOverdueDf,
  2701. 3);
  2702. loanAccountInfoDf.loc[loanAccountInfoIndex, '近6月贷款的最大逾期期数'] = prp.getPayRcdMaxOverdueNum(payRcdMaxOverdueDf,
  2703. 6);
  2704. loanAccountInfoDf.loc[loanAccountInfoIndex, '近9月贷款的最大逾期期数'] = prp.getPayRcdMaxOverdueNum(payRcdMaxOverdueDf,
  2705. 9);
  2706. loanAccountInfoDf.loc[loanAccountInfoIndex, '近12月贷款的最大逾期期数'] = prp.getPayRcdMaxOverdueNum(
  2707. payRcdMaxOverdueDf, 12);
  2708. loanAccountInfoDf.loc[loanAccountInfoIndex, '近24月贷款的最大逾期期数'] = prp.getPayRcdMaxOverdueNum(
  2709. payRcdMaxOverdueDf, 24);
  2710. loanAccountInfoDf.loc[loanAccountInfoIndex, '近24月贷款最大逾期距离现在的月数'] = prp.getPayRcdMaxOverdueNumMonth(
  2711. payRcdMaxOverdueDf, normalDf, reportTime, 24);
  2712. payStatus = ["G", "D", "C", "N", "M", "1", "2", "3", "4", "5", "6", "7"]
  2713. # 贷款24期还款记录次数 剔除结清 转出 呆账
  2714. # payRcdTimesDf = payRcdDf[payRcdDf['账户编号'].isin(normalDf['账户编号'].values)]
  2715. # payRcdTimesDf = payRcdTimesDf.sort_values(by=["账户编号", "还款日期"], ascending=(True, False))
  2716. # payRcdTimesDf = payRcdTimesDf.groupby(['账户编号']).head(24)
  2717. # # 从“贷款信息”中提取,剔除“账户状态”为结清、转出、呆账、呆帐后,各账户的还款次数统计“24个月(账户)还款状态”包含"G","D","C","N","M"及数字的个数,MAX(各账户的还款次数)
  2718. # payRcdTimesDf = payRcdTimesDf[payRcdTimesDf['还款状态'].isin(payStatus)]
  2719. # payRcdTimes = payRcdTimesDf.groupby(['账户编号'])['还款状态'].count()
  2720. #loanAccountInfoDf.loc[loanAccountInfoIndex, '贷款24期还款记录次数'] = np.max(payRcdTimes)
  2721. loanAccountInfoDf.loc[loanAccountInfoIndex, '贷款24期还款记录次数'] = prp.getPayRcdCount(payRcdDf,normalDf,24);
  2722. otherDf.loc[otherIndex, '最近6个月有贷款还款记录的月份数'] = prp.getPayRcdCountNew(payRcdDf, reportTime, 6);
  2723. otherDf.loc[otherIndex, '最近12个月有贷款还款记录的月份数'] = prp.getPayRcdCountNew(payRcdDf, reportTime, 12);
  2724. #最近一次逾期距今月份数
  2725. def getLastOverdueMonth(self, loanMergeDf, creditCardMergeDf, loanPayRecordMergeDf, creditCardPayRecordMergeDf,
  2726. reportTime):
  2727. result = 120;
  2728. if np.sum(loanMergeDf['当前逾期期数']) > 0 or np.sum(creditCardMergeDf['当前逾期期数']) > 0:
  2729. result = 0
  2730. else:
  2731. payRcdDf = loanPayRecordMergeDf.sort_values(by=["账户编号", "还款日期"], ascending=(True, False))
  2732. payRcdDf = payRcdDf.groupby(['账户编号']).head(60)
  2733. payRcdDf = utils.replacePayRcdStatusOverdue(payRcdDf) # 替换逾期
  2734. payRcdDf = payRcdDf[payRcdDf['还款状态'] > 0]
  2735. payRcdDf = utils.replacePayRcdStatusOverdue(payRcdDf) # 替换逾期
  2736. loanOverdueDate = np.max(payRcdDf['还款日期'])
  2737. payRcdDfCredit = creditCardPayRecordMergeDf.sort_values(by=["账户编号", "还款日期"], ascending=(True, False))
  2738. payRcdDfCredit = utils.replacePayRcdStatusOverdue(payRcdDfCredit) # 替换逾期
  2739. payRcdDfCredit = payRcdDfCredit.groupby(['账户编号']).head(60)
  2740. payRcdDfCredit = payRcdDfCredit[payRcdDfCredit['还款状态'] > 0]
  2741. if not payRcdDf.empty or not payRcdDfCredit.empty:
  2742. creditOverdueDate = np.max(payRcdDfCredit['还款日期'])
  2743. # reportTime = str(np.datetime64(reportTime, "M")) + "-02"
  2744. reportTime = utils.get_last_month_first_day_v2(reportTime)
  2745. overdueDate = None
  2746. if str(loanOverdueDate) != "nan" and str(creditOverdueDate) != "nan":
  2747. overdueDate = max([loanOverdueDate, creditOverdueDate])
  2748. elif str(loanOverdueDate) == "nan" and str(creditOverdueDate) != "nan":
  2749. overdueDate = creditOverdueDate
  2750. elif str(loanOverdueDate) != "nan" and str(creditOverdueDate) == "nan":
  2751. overdueDate = loanOverdueDate
  2752. if overdueDate != None:
  2753. result = utils.difMonthReportTime(overdueDate, reportTime)
  2754. otherDf.loc[otherIndex, "最近一次逾期距今月份数"] = result
  2755. #近12个月贷款和贷记卡还款状态异常次数 慧算1112
  2756. #count(三类贷款账户m1-m12中D/Z/B/G的个数)+count(贷记卡m1-m12中D/Z/B/G的个数)
  2757. def calcPayRcdStatus(self,loanPayRecordMergeDf,creditCardPayRecordMergeDf,reportTime):
  2758. reportTime = str(np.datetime64(reportTime, "M")) + "-02"
  2759. statusList =['G','B','Z','D']
  2760. payDate = utils.getLastMonthDate(reportTime, 12)
  2761. loanPayRcdTmpDf = loanPayRecordMergeDf[loanPayRecordMergeDf['还款日期']>=payDate]
  2762. loanTimes = loanPayRcdTmpDf[(loanPayRcdTmpDf['还款状态'].isin(statusList))].index.size
  2763. creditPayRcdTmpDf = creditCardPayRecordMergeDf[creditCardPayRecordMergeDf['还款日期']>=payDate]
  2764. creditTimes = creditPayRcdTmpDf[(creditPayRcdTmpDf['还款状态'].isin(statusList))].index.size
  2765. result = loanTimes+creditTimes
  2766. otherDf.loc[otherIndex, "近12个月贷款和贷记卡还款状态异常次数"] = result
  2767. #yuan新开发部分
  2768. #yuan新开发部分,暂时不存入数据库
  2769. #基础个人信息1
  2770. def parseBaseIdentity(self,reportTime,docXml):
  2771. tmpNode =docXml.documentElement.getElementsByTagName("BASEINFO")
  2772. if len(tmpNode)>0:
  2773. baseInfo = docXml.documentElement.getElementsByTagName("BASEINFO")[0]
  2774. # print(str(baseInfo))
  2775. # self.saveNode(baseInfo)
  2776. tmpNode = docXml.documentElement.getElementsByTagName("MARRIAGEINFOSG")
  2777. baseIdentityInfoDf.loc[baseIdentityInfo, '性别'] = self.getNodeData(baseInfo,"SEXDESC")
  2778. baseIdentityInfoDf.loc[baseIdentityInfo, '出生日期'] = self.getNodeData(baseInfo,"BIRTHDAY")
  2779. baseIdentityInfoDf.loc[baseIdentityInfo, '国籍'] = self.getNodeData(baseInfo,"NATIONDESC")
  2780. baseIdentityInfoDf.loc[baseIdentityInfo, '户籍地址'] = self.getNodeData(baseInfo,"ADDRESS")
  2781. if len(tmpNode)>0:
  2782. marriageinfosg = docXml.documentElement.getElementsByTagName("MARRIAGEINFOSG")[0]
  2783. self.parseBaseMate(marriageinfosg)
  2784. baseIdentityInfoDf.loc[baseIdentityInfo, '婚姻状况'] = self.getNodeData(marriageinfosg,"MARSTATUDESC")
  2785. baseIdentityInfoDf.loc[baseIdentityInfo, '学历'] = self.getNodeData(baseInfo,"DEGREEDESC")
  2786. baseIdentityInfoDf.loc[baseIdentityInfo, '学位'] = self.getNodeData(baseInfo,"DEGREEDESC")
  2787. baseIdentityInfoDf.loc[baseIdentityInfo, '通讯地址'] = self.getNodeData(baseInfo,"COMMUADDRESS")
  2788. baseIdentityInfoDf.loc[baseIdentityInfo, '就业状况'] = self.getNodeData(baseInfo,"WORKSTATUSDESC")
  2789. # mobiles = docXml.documentElement.getElementsByTagName("TELEPHONEINFOSGLS")
  2790. # if len(mobiles)>0:
  2791. # telephoneinfosgls = docXml.documentElement.getElementsByTagName("TELEPHONEINFOSGLS")[0]
  2792. # telephoneinfosg = telephoneinfosgls.getElementsByTagName("TELEPHONEINFOSG");
  2793. # identityInfoDf.loc[identityInfoIndex, '历史手机号码数'] = len(telephoneinfosg)
  2794. # identityInfoDf.loc[identityInfoIndex, '近3个月手机号码数'] = self.getLastMonthMobileCount(telephoneinfosg, 3, reportTime)
  2795. # identityInfoDf.loc[identityInfoIndex, '近6个月手机号码数'] = self.getLastMonthMobileCount(telephoneinfosg, 6, reportTime)
  2796. # identityInfoDf.loc[identityInfoIndex, '近12个月手机号码数'] = self.getLastMonthMobileCount(telephoneinfosg, 12, reportTime)
  2797. # identityInfoDf.loc[identityInfoIndex, '近24个月手机号码数'] = self.getLastMonthMobileCount(telephoneinfosg, 24, reportTime)
  2798. # print(identityInfoDf.to_json(orient="index",force_ascii=False))
  2799. #基础配偶信息2
  2800. def parseBaseMate(self,marriageinfosg):
  2801. self.saveNode(marriageinfosg)
  2802. baseMateInfoDf.loc[baseMateInfo, '姓名'] = self.getNodeData(marriageinfosg,"SPUOSENAME")
  2803. baseMateInfoDf.loc[baseMateInfo, '证件号码'] = self.getNodeData(marriageinfosg,"CERTNUM")
  2804. baseMateInfoDf.loc[baseMateInfo, '工作单位'] = self.getNodeData(marriageinfosg,"COMPANY")
  2805. baseMateInfoDf.loc[baseMateInfo, '联系电话'] = self.getNodeData(marriageinfosg,"TELNUM")
  2806. # print(mateInfoDf.to_json(orient="index", force_ascii=False))
  2807. # 基础居住信息3
  2808. def parseBaseLiveInfo(self,docXml):
  2809. # residenceinfosgls = docXml.documentElement.getElementsByTagName("RESIDENCEINFOSGLS")
  2810. residenceinfosg = docXml.documentElement.getElementsByTagName("RESIDENCEINFOSG");
  2811. df = pd.DataFrame()
  2812. for i in range(0, len(residenceinfosg)):
  2813. # self.saveNode(residenceinfosg[i])
  2814. resistatusdesc = self.getNodeData(residenceinfosg[i], "RESISTATUSDESC")
  2815. address = self.getNodeData(residenceinfosg[i], "ADDRESS")
  2816. telnum = self.getNodeData(residenceinfosg[i], "TELNUM")
  2817. updatedateinfo = self.getNodeData(residenceinfosg[i], "UPDATEDATEINFO")
  2818. df.loc[i, 0] = resistatusdesc
  2819. df.loc[i, 1] = address
  2820. df.loc[i, 2] = telnum
  2821. df.loc[i, 3] = updatedateinfo
  2822. if len(residenceinfosg)>0:
  2823. baseLiveInfoDf.loc[baseLiveInfo, '居住地址'] = self.getNodeData(residenceinfosg[0],"ADDRESS")
  2824. baseLiveInfoDf.loc[baseLiveInfo, '住宅电话'] = self.getNodeData(residenceinfosg[0],"TELNUM")
  2825. # baseLiveInfoDf.loc[baseLiveInfo, '历史居住地址个数'] = len(residenceinfosg);
  2826. # curDate = np.datetime64(time.strftime("%Y-%m-%d"));
  2827. # last3year = str(curDate)[0:4]
  2828. # last3yearDate = str(int(last3year) - 3) + str(curDate)[4:10]
  2829. # lastLiveDf = df[df[3] >= last3yearDate];
  2830. # liveInfoDf.loc[liveInfoIndex, '最近3年内居住地址个数'] = lastLiveDf.index.size ;
  2831. # houseIndex = df[df[0] == '自置'].index.size > 0
  2832. # if (houseIndex):
  2833. # houseStr = '是'
  2834. # else:
  2835. # houseStr = '否'
  2836. # liveInfoDf.loc[liveInfoIndex, '当前居住状况-是否具有自有住房'] = houseStr;
  2837. baseLiveInfoDf.loc[baseLiveInfo, '居住状况'] = self.getNodeData(residenceinfosg[0],"RESISTATUSDESC")
  2838. baseLiveInfoDf.loc[baseLiveInfo, '信息更新日期'] = self.getNodeData(residenceinfosg[0],"UPDATEDATEINFO")
  2839. # print(liveInfoDf.to_json(orient="index", force_ascii=False))
  2840. # 基础职业信息4
  2841. def parseBaseOccupationInfoDf(self,docXml):
  2842. vocationinfosg = docXml.documentElement.getElementsByTagName("VOCATIONINFOSG");
  2843. df = pd.DataFrame()
  2844. if len(vocationinfosg)>0:
  2845. for i in range(0, len(vocationinfosg)):
  2846. # df.loc[i, 0] = self.getNodeData(vocationinfosg[i], "WORDSTATUSDESC")
  2847. # self.saveNode(vocationinfosg[i])
  2848. df.loc[i, 0] = self.getNodeData(vocationinfosg[i], "CPNTYPEDESC")
  2849. df.loc[i, 1] = self.getNodeData(vocationinfosg[i], "TRADEDESC")
  2850. df.loc[i, 2] = self.getNodeData(vocationinfosg[i], "VOCATIONDESC")
  2851. df.loc[i, 3] = self.getNodeData(vocationinfosg[i], "VOCATIONTITLEDESC")
  2852. df.loc[i, 4] = self.getNodeData(vocationinfosg[i], "COMPANY")
  2853. df.loc[i, 5] = self.getNodeData(vocationinfosg[i], "CPNADDRESS")
  2854. df.loc[i, 6] = self.getNodeData(vocationinfosg[i], "CPNTELNUM")
  2855. df.loc[i, 7] = self.getNodeData(vocationinfosg[i], "BEGINYEAR")
  2856. df.loc[i, 8] = self.getNodeData(vocationinfosg[i], "INFOUPDATEDATE")
  2857. baseOccupationInfoDf.loc[baseOccupationInfo, '工作单位'] = self.getNodeData(vocationinfosg[0], "COMPANY")
  2858. baseOccupationInfoDf.loc[baseOccupationInfo, '单位电话'] = self.getNodeData(vocationinfosg[0], "CPNTELNUM")
  2859. baseOccupationInfoDf.loc[baseOccupationInfo, '单位性质'] = self.getNodeData(vocationinfosg[0], "CPNTYPEDESC")
  2860. baseOccupationInfoDf.loc[baseOccupationInfo, '单位地址'] = self.getNodeData(vocationinfosg[0], "CPNADDRESS")
  2861. baseOccupationInfoDf.loc[baseOccupationInfo, '职业'] = self.getNodeData(vocationinfosg[0], "VOCATIONDESC")
  2862. baseOccupationInfoDf.loc[baseOccupationInfo, '行业'] = self.getNodeData(vocationinfosg[0], "TRADEDESC")
  2863. baseOccupationInfoDf.loc[baseOccupationInfo, '职务'] = self.getNodeData(vocationinfosg[0], "TITLEDESC")
  2864. baseOccupationInfoDf.loc[baseOccupationInfo, '职称'] = self.getNodeData(vocationinfosg[0], "VOCATIONTITLEDESC")
  2865. baseOccupationInfoDf.loc[baseOccupationInfo, '进入本单位年份'] = self.getNodeData(vocationinfosg[0], "BEGINYEAR")
  2866. baseOccupationInfoDf.loc[baseOccupationInfo, '信息更新日期'] = self.getNodeData(vocationinfosg[0], "INFOUPDATEDATE")
  2867. # occupationInfoDf.loc[occupationInfoIndex, '历史工作单位数'] = len(vocationinfosg)
  2868. # print(occupationInfoDf.to_json(orient="index", force_ascii=False))
  2869. # 个人信用报告"数字解读"5
  2870. def personalCreditInfo(self,docXml):
  2871. tmpNode =docXml.documentElement.getElementsByTagName("GRADEINFOSMRY")
  2872. if len(tmpNode)>0:
  2873. personalCreditInfo = docXml.documentElement.getElementsByTagName("GRADEINFOSMRY")[0]
  2874. personalCreditInfoDf.loc[baseMateInfo, '数字解读'] = self.getNodeData(personalCreditInfo,"NUMBERREAD")
  2875. personalCreditInfoDf.loc[baseMateInfo, '相对位置'] = self.getNodeData(personalCreditInfo,"RELPOSITION")
  2876. personalCreditInfoDf.loc[baseMateInfo, '说明'] = self.getNodeData(personalCreditInfo,"SCOREEXPLAINNUM")
  2877. # 信贷交易信息提示6
  2878. def parseBriefInfoHeaderLoanTradeInfo(self,docXml):
  2879. credittipsinfo = docXml.documentElement.getElementsByTagName("CREDITTIPSINFO");
  2880. if len(credittipsinfo)>0:
  2881. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '个人住房贷款账户数'] = utils.toInt(self.getNodeData(credittipsinfo[0],"ACCOUNTNUM"))
  2882. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '个人住房贷款首笔业务发放月份'] = self.getNodeData(credittipsinfo[0],"FIRSTBUSMONTH")
  2883. # self.saveNode(credittipsinfo[0])
  2884. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '个人商用房贷款(包括商住两用)账户数'] = utils.toInt(self.getNodeData(credittipsinfo[1],"ACCOUNTNUM"))
  2885. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '个人商用房贷款(包括商住两用)首笔业务发放月份'] = self.getNodeData(credittipsinfo[1],"FIRSTBUSMONTH")
  2886. # self.saveNode(credittipsinfo[1])
  2887. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '其他类贷款账户数'] = utils.toInt(self.getNodeData(credittipsinfo[2],"ACCOUNTNUM"))
  2888. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '其他类贷款首笔业务发放月份'] = self.getNodeData(credittipsinfo[2],"FIRSTBUSMONTH")
  2889. # self.saveNode(credittipsinfo[2])
  2890. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '贷记卡账户数'] = utils.toInt(self.getNodeData(credittipsinfo[3],"ACCOUNTNUM"))
  2891. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '贷记卡首笔业务发放月份'] = self.getNodeData(credittipsinfo[3],"FIRSTBUSMONTH")
  2892. # self.saveNode(credittipsinfo[3])
  2893. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '准贷记卡账户数'] = utils.toInt(self.getNodeData(credittipsinfo[4],"ACCOUNTNUM"))
  2894. briefInfoHeaderLoanTradeInfoDf.loc[briefInfoHeaderLoanTradeInfo, '准贷记卡首笔业务发放月份'] = self.getNodeData(credittipsinfo[4],"FIRSTBUSMONTH")
  2895. # self.saveNode(credittipsinfo[4])
  2896. #汇算
  2897. # moths = [self.getNodeData(credittipsinfo[0], "FIRSTBUSMONTH"),
  2898. # self.getNodeData(credittipsinfo[1], "FIRSTBUSMONTH"),self.getNodeData(credittipsinfo[2], "FIRSTBUSMONTH")]
  2899. # moths=utils.get_real_arr(moths)
  2900. # if len(moths)>0:
  2901. # otherDf.loc[otherIndex, '首笔贷款发放月份'] = min(moths)
  2902. # otherDf.loc[otherIndex, '首张贷记卡发卡月份'] = self.getNodeData(credittipsinfo[3], "FIRSTBUSMONTH")
  2903. #信贷交易违约信息概要包括7.8.9
  2904. # 被追偿信息汇总7
  2905. def parseCreditTransactionDefaultY(self,docXml):
  2906. recoveredinfosumsmry = docXml.documentElement.getElementsByTagName("RECOVEREDINFOSUMSMRY");
  2907. recorinfosumsg = docXml.documentElement.getElementsByTagName("RECORINFOSUMSG")
  2908. if len(recoveredinfosumsmry)>0:
  2909. if len(recorinfosumsg)>0:
  2910. self.saveNode(recorinfosumsg[0])
  2911. briefInfoDf_recoveryInfoSumY.loc[recoveryInfoSumIndexY, '资产处置业务账户数'] = utils.toInt(self.getNodeData(recorinfosumsg[0],"ACCOUNTNUM"))
  2912. briefInfoDf_recoveryInfoSumY.loc[recoveryInfoSumIndexY, '资产处置业务余额'] = utils.replaceAmt(self.getNodeData(recorinfosumsg[0],"BALANCE"))
  2913. briefInfoDf_recoveryInfoSumY.loc[recoveryInfoSumIndexY, '垫款业务账户数'] = utils.toInt(self.getNodeData(recorinfosumsg[1],"ACCOUNTNUM"))
  2914. briefInfoDf_recoveryInfoSumY.loc[recoveryInfoSumIndexY, '垫款业务余额'] = utils.replaceAmt(self.getNodeData(recorinfosumsg[1],"BALANCE"))
  2915. briefInfoDf_recoveryInfoSumY.loc[recoveryInfoSumIndexY, '合计总账户数'] = utils.toInt(self.getNodeData(recoveredinfosumsmry[0],"ACCOUNTNUMSUM"))
  2916. briefInfoDf_recoveryInfoSumY.loc[recoveryInfoSumIndexY, '合计总余额'] = utils.replaceAmt(self.getNodeData(recoveredinfosumsmry[0],"BALANCESUM"))
  2917. # 解析呆账信息汇总8
  2918. def parseBadDebtsInfoSumDfY(self,docXml):
  2919. baddebtssmry = docXml.documentElement.getElementsByTagName("BADDEBTSSMRY");
  2920. if len(baddebtssmry)>0:
  2921. briefInfoDf_badDebtsInfoSumY.loc[badDebtsInfoIndexY, '账户数'] = utils.toInt(self.getNodeData(baddebtssmry[0],"ACCOUNTNUM"))
  2922. briefInfoDf_badDebtsInfoSumY.loc[badDebtsInfoIndexY, '余额'] = utils.replaceAmt(self.getNodeData(baddebtssmry[0],"BALANCE"));
  2923. # self.saveNode(baddebtssmry[0])
  2924. # print(briefInfoDf_badDebtsInfoSum.to_json(orient="index", force_ascii=False))
  2925. #透支及逾期信息汇总9
  2926. def parseOverdueInfoSumY(self,docXml):
  2927. overdraftsumsg = docXml.documentElement.getElementsByTagName("OVERDRAFTSUMSG");
  2928. df = pd.DataFrame()
  2929. if len(overdraftsumsg)>0:
  2930. for i in range(0, len(overdraftsumsg)):
  2931. df.loc[i, 0] = self.getNodeData(overdraftsumsg[i], "ACCTYPEDESC")
  2932. df.loc[i, 1] = self.getNodeData(overdraftsumsg[i], "ACCSUM")
  2933. df.loc[i, 2] = self.getNodeData(overdraftsumsg[i], "MONTHSUM")
  2934. df.loc[i, 3] = self.getNodeData(overdraftsumsg[i], "OVERDRAFTMAX")
  2935. df.loc[i, 4] = self.getNodeData(overdraftsumsg[i], "OVERMONTH")
  2936. if len(overdraftsumsg)>0:
  2937. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '非循环贷帐户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[0],"ACCSUM"));
  2938. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '非循环贷帐户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[0],"MONTHSUM"));
  2939. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '非循环贷帐户单月最高逾期总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[0],"OVERDRAFTMAX"));
  2940. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '非循环贷帐户最长逾期月数'] = utils.toInt(self.getNodeData(overdraftsumsg[0],"OVERMONTH"));
  2941. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '循环额度下分账户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[1],"ACCSUM"));
  2942. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '循环额度下分账户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[1],"MONTHSUM"));
  2943. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '循环额度下分账户单月最高逾期总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[1],"OVERDRAFTMAX"));
  2944. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '循环额度下分账户最长逾期月数'] = utils.toInt(self.getNodeData(overdraftsumsg[1],"OVERMONTH"));
  2945. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '循环贷账户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[2],"ACCSUM"));
  2946. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '循环贷账户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[2],"MONTHSUM"));
  2947. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '循环贷账户单月最高逾期总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[2],"OVERDRAFTMAX"));
  2948. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '循环贷账户最长逾期月数'] = utils.toInt(self.getNodeData(overdraftsumsg[2],"OVERMONTH"));
  2949. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '贷记卡账户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[3],"ACCSUM"));
  2950. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '贷记卡账户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[3],"MONTHSUM"));
  2951. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '贷记卡账户单月逾期总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[3],"OVERDRAFTMAX"));
  2952. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '贷记卡账户最长逾期月数'] = utils.toInt(self.getNodeData(overdraftsumsg[3],"OVERMONTH"));
  2953. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '准贷记卡账户账户数'] = utils.toInt(self.getNodeData(overdraftsumsg[4],"ACCSUM"));
  2954. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '准贷记卡账户月份数'] = utils.toInt(self.getNodeData(overdraftsumsg[4],"MONTHSUM"));
  2955. briefInfoDf_overdueInfoSumY.loc[overdueInfoSumIndexY, '准贷记卡账户单月透支总额'] = utils.replaceAmt(self.getNodeData(overdraftsumsg[4],"OVERDRAFTMAX"));
  2956. briefInfoDf_overdueInfoSum.loc[overdueInfoSumIndexY, '准贷记卡账户最长透支月数'] = utils.toInt(self.getNodeData(overdraftsumsg[4],"OVERMONTH"));
  2957. #3.5⏹
  2958. # 信贷交易授信及负债信息概10:非循环贷账户信息汇总10
  2959. def parseLoanAccountInfoSumY(self,docXml):
  2960. noncyclicalsmry = docXml.documentElement.getElementsByTagName("NONCYCLICALSMRY");
  2961. if len(noncyclicalsmry)>0:
  2962. # loanAccountInfoSumDf = doFilterCalc(loanAccountInfoSumDf); # 替换为0
  2963. #TODO 需要检查是否都有值
  2964. # loanAccountInfoSumDf = loanAccountInfoSumDf.reset_index(drop=True)
  2965. # row0 = loanAccountInfoSumDf.loc[0, :]
  2966. creditTransactionCreditDf.loc[creditTransactionCredit, '非循环贷账户管理机构数'] = int(self.getNodeData(noncyclicalsmry[0],"MANAGEORGNUM"))
  2967. creditTransactionCreditDf.loc[creditTransactionCredit, '非循环贷账户账户数'] = int(self.getNodeData(noncyclicalsmry[0],"ACCSUM"))
  2968. creditTransactionCreditDf.loc[creditTransactionCredit, '非循环贷账户授信总额'] = utils.replaceAmt(self.getNodeData(noncyclicalsmry[0],"CREDITSUM"))
  2969. creditTransactionCreditDf.loc[creditTransactionCredit, '非循环贷账户余额'] = utils.replaceAmt(self.getNodeData(noncyclicalsmry[0],"BALANCE"))
  2970. creditTransactionCreditDf.loc[creditTransactionCredit, '非循环贷账户6月平均应还款'] = utils.replaceAmt(self.getNodeData(noncyclicalsmry[0],"LATELY6MON"))
  2971. self.saveNode(noncyclicalsmry[0])
  2972. # print(briefInfoDf_loanTradeCreditInfo.to_json(orient="index", force_ascii=False))
  2973. # 循环额度下分账户10
  2974. def parseCycleCreditAccountInfoSumY(self,docXml):
  2975. cybranchaccsmry = docXml.documentElement.getElementsByTagName("CYBRANCHACCSMRY");
  2976. if len(cybranchaccsmry) > 0:
  2977. creditTransactionCreditDf.loc[creditTransactionCredit, '循环额度下分账户管理机构数'] = int(self.getNodeData(cybranchaccsmry[0],"MANAGEORGNUM"))
  2978. creditTransactionCreditDf.loc[creditTransactionCredit, '循环额度下分账户账户数'] = int(self.getNodeData(cybranchaccsmry[0],"ACCSUM"))
  2979. creditTransactionCreditDf.loc[creditTransactionCredit, '循环额度下分账户授信总额'] = utils.replaceAmt(self.getNodeData(cybranchaccsmry[0],"CREDITSUM"))
  2980. creditTransactionCreditDf.loc[creditTransactionCredit, '循环额度下分账户余额'] = utils.replaceAmt(self.getNodeData(cybranchaccsmry[0],"BALANCE"))
  2981. creditTransactionCreditDf.loc[creditTransactionCredit, '循环额度下分账户6月平均应还款'] = utils.replaceAmt(self.getNodeData(cybranchaccsmry[0],"LATELY6MON"))
  2982. self.saveNode(cybranchaccsmry[0])
  2983. # print(briefInfoDf_loanTradeCreditInfo.to_json(orient="index", force_ascii=False))
  2984. # 循环贷账户信息10
  2985. def parseCyleLoanAccountInfoSumY(self,docXml):
  2986. cyclicalloansmry = docXml.documentElement.getElementsByTagName("CYCLICALLOANSMRY");
  2987. if len(cyclicalloansmry) > 0:
  2988. creditTransactionCreditDf.loc[creditTransactionCredit, '循环贷账户管理机构数'] = int(self.getNodeData(cyclicalloansmry[0],"MANAGEORGNUM"))
  2989. creditTransactionCreditDf.loc[creditTransactionCredit, '循环贷账户账户数'] = int(self.getNodeData(cyclicalloansmry[0],"ACCSUM"))
  2990. creditTransactionCreditDf.loc[creditTransactionCredit, '循环贷账户授信总额'] = utils.replaceAmt(self.getNodeData(cyclicalloansmry[0],"CREDITSUM"))
  2991. creditTransactionCreditDf.loc[creditTransactionCredit, '循环贷账户余额'] = utils.replaceAmt(self.getNodeData(cyclicalloansmry[0],"BALANCE"))
  2992. creditTransactionCreditDf.loc[creditTransactionCredit, '循环贷账户6月平均应还款'] = utils.replaceAmt(self.getNodeData(cyclicalloansmry[0],"LATELY6MON"))
  2993. self.saveNode(cyclicalloansmry[0])
  2994. # 解析贷记卡信息汇总10
  2995. def parseCreditCardInfoSumY(self,docXml):
  2996. debitcardaccsmry = docXml.documentElement.getElementsByTagName("DEBITCARDACCSMRY");
  2997. if len(debitcardaccsmry) > 0:
  2998. creditTransactionCreditDf.loc[creditTransactionCredit, '贷记卡发卡机构数'] = int(self.getNodeData(debitcardaccsmry[0],"CARDISSUERNUM"))
  2999. creditTransactionCreditDf.loc[creditTransactionCredit, '贷记卡账户数'] =int(self.getNodeData(debitcardaccsmry[0],"ACCSUM"))
  3000. creditTransactionCreditDf.loc[creditTransactionCredit, '贷记卡授信总额'] = utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"CREDITSUM"))
  3001. creditTransactionCreditDf.loc[creditTransactionCredit, '贷记卡单家机构最高授信额'] = utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"CRAMOUNTMAX"))
  3002. creditTransactionCreditDf.loc[creditTransactionCredit, '贷记卡单家机构最低授信额'] =utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"CRAMOUNTMIN"))
  3003. creditTransactionCreditDf.loc[creditTransactionCredit, '贷记卡已用额度'] = utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"ALREADYUSED"))
  3004. creditTransactionCreditDf.loc[creditTransactionCredit, '贷记卡最近6个月平均使用额度'] = utils.replaceAmt(self.getNodeData(debitcardaccsmry[0],"LATELY6MONUSE"))
  3005. self.saveNode(debitcardaccsmry[0])
  3006. # 解析准贷记卡信息汇总10
  3007. def parseCreditCardInfoSumZY(self,docXml):
  3008. zdebitcardaccsmry = docXml.documentElement.getElementsByTagName("ZDEBITCARDACCSMRY");
  3009. if len(zdebitcardaccsmry) > 0:
  3010. creditTransactionCreditDf.loc[creditTransactionCredit, '准贷记卡发卡机构数'] = int(self.getNodeData(zdebitcardaccsmry[0],"CARDISSUERNUM"))
  3011. creditTransactionCreditDf.loc[creditTransactionCredit, '准贷记卡账户数'] =int(self.getNodeData(zdebitcardaccsmry[0],"ACCSUM"))
  3012. creditTransactionCreditDf.loc[creditTransactionCredit, '准贷记卡授信总额'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"CREDITSUM"))
  3013. creditTransactionCreditDf.loc[creditTransactionCredit, '准贷记卡单家机构最高授信额'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"CRAMOUNTMAX"))
  3014. creditTransactionCreditDf.loc[creditTransactionCredit, '准贷记卡单家机构最低授信额'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"CRAMOUNTMIN"))
  3015. creditTransactionCreditDf.loc[creditTransactionCredit, '准贷记卡已用额度'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"OVERDRAFT"))
  3016. creditTransactionCreditDf.loc[creditTransactionCredit, '准贷记卡最近6个月平均使用额度'] = utils.replaceAmt(self.getNodeData(zdebitcardaccsmry[0],"LATELY6MONDRAFT"))
  3017. self.saveNode(zdebitcardaccsmry[0])
  3018. # # 非信贷交易信息概要11 ?暂不明确
  3019. # def parsePublicInformation(self,docXml):
  3020. # tmpNode =docXml.documentElement.getElementsByTagName("POSTPAYSMRYLS")
  3021. # if len(tmpNode)>0:
  3022. # personalCreditInfo = docXml.documentElement.getElementsByTagName("POSTPAYSMRY")[0]
  3023. #公共信息概要12
  3024. def parsePublicInfoBriefY(self,docXml):
  3025. comminfosmry = docXml.documentElement.getElementsByTagName("COMMINFOSMRY")
  3026. # for item in comminfosmry:
  3027. # self.saveNode(item)
  3028. if len(comminfosmry)>0:
  3029. publicInformationDf.loc[publicInformation, '欠税信息记录数'] = utils.toInt(self.getNodeData(comminfosmry[0],"RECORDNUM"))
  3030. publicInformationDf.loc[publicInformation, '欠税信息涉及金额'] = utils.replaceAmt(self.getNodeData(comminfosmry[0],"INVOLVEMONEY"))
  3031. publicInformationDf.loc[publicInformation, '民事判决信息记录数'] = utils.toInt(self.getNodeData(comminfosmry[1],"RECORDNUM"))
  3032. publicInformationDf.loc[publicInformation, '民事判决信息涉及金额'] = utils.replaceAmt(self.getNodeData(comminfosmry[1],"INVOLVEMONEY"))
  3033. publicInformationDf.loc[publicInformation, '强制执行信息记录数'] = utils.toInt(self.getNodeData(comminfosmry[2],"RECORDNUM"))
  3034. publicInformationDf.loc[publicInformation, '强制执行信息涉及金额'] = utils.replaceAmt(self.getNodeData(comminfosmry[2],"INVOLVEMONEY"))
  3035. publicInformationDf.loc[publicInformation, '行政处罚信息记录数'] = utils.toInt(self.getNodeData(comminfosmry[3],"RECORDNUM"))
  3036. publicInformationDf.loc[publicInformation, '行政处罚信息涉及金额'] = utils.replaceAmt(self.getNodeData(comminfosmry[3],"INVOLVEMONEY"))
  3037. # 查询记录概要13
  3038. def parseQueryRecordSumY(self,docXml):
  3039. laseQuery = docXml.documentElement.getElementsByTagName("LASTQUERYRECORDSG")
  3040. queryrecordsumsg = docXml.documentElement.getElementsByTagName("QUERYRECORDSUMSG")
  3041. if len(laseQuery) > 0:
  3042. queryRecordDf.loc[queryRecord, '上一次查询日期'] = int(self.getNodeData(laseQuery[0],"LASTQUERYDATE"))
  3043. queryRecordDf.loc[queryRecord, '上一次查询机构名称'] = int(self.getNodeData(laseQuery[0],"LASTORGCODE"))
  3044. queryRecordDf.loc[queryRecord, '上一次查询原因'] = int(self.getNodeData(laseQuery[0],"LASTQUERYREASONCODE"))
  3045. if len(queryrecordsumsg) > 0:
  3046. # self.saveNode(queryrecordsumsg[0])
  3047. queryRecordDf.loc[queryRecord, '近1月内的查询机构数-贷款审批'] = int(self.getNodeData(queryrecordsumsg[0],"LAST1ORGSP"))
  3048. queryRecordDf.loc[queryRecord, '近1月内的查询机构数-信用卡审批'] = int(self.getNodeData(queryrecordsumsg[0],"LAST1CREDITSP"))
  3049. queryRecordDf.loc[queryRecord, '近1月内的查询次数-贷款审批'] = int(self.getNodeData(queryrecordsumsg[0],"NUMSP"))
  3050. queryRecordDf.loc[queryRecord, '近1月内的查询次数-信用卡审批'] = int(self.getNodeData(queryrecordsumsg[0],"NUMCREDITSP"))
  3051. queryRecordDf.loc[queryRecord, '近1月内的查询次数-本人查询'] = int(self.getNodeData(queryrecordsumsg[0],"LAST1NUMSELF"))
  3052. queryRecordDf.loc[queryRecord, '近2年内的查询次数-贷后管理'] = int(self.getNodeData(queryrecordsumsg[0],"L2YNUMDH"))
  3053. queryRecordDf.loc[queryRecord, '近2年内的查询次数-担保资格审查'] = int(self.getNodeData(queryrecordsumsg[0],"L2YNUMDBZG"))
  3054. queryRecordDf.loc[queryRecord, '近2年内的查询次数-特约商户实名审查'] = int(self.getNodeData(queryrecordsumsg[0],"L2NUMTYSH"))
  3055. # 三 信贷交易信息明细
  3056. # 被追偿账户基本信息
  3057. def parseRecoveryInfo(self,docXml):
  3058. forcedrepayinfobols = docXml.documentElement.getElementsByTagName("FORCEDREPAYINFOBOLS")
  3059. if len(forcedrepayinfobols)>0:
  3060. force = docXml.documentElement.getElementsByTagName("FORCEDREPAYINFOBOLS")[0]
  3061. base = force.getElementsByTagName("CREDITACCTINFOBO");
  3062. recoveryBaseInfoDf.loc[recoveryBaseInfo, '管理机构'] = self.getNodeData(base[0],"MANAGEORGTYPECODE")
  3063. recoveryBaseInfoDf.loc[recoveryBaseInfo, '业务种类'] = self.getNodeData(base[0],"LOANTYPECODE")
  3064. recoveryBaseInfoDf.loc[recoveryBaseInfo, '债权转移时的还款状态代码'] = self.getNodeData(base[0],"RPYACCOUNTSTATUSCODE")
  3065. #最新表现信息
  3066. latest = force.getElementsByTagName("NEWPERFORMANCEBO");
  3067. # if len(latest)>0:
  3068. recoveryLatestDf.loc[recoveryLatest, '账户状态'] = self.getNodeData(latest[0],"ACCTSTATUSCODE")
  3069. recoveryLatestDf.loc[recoveryLatest, '余额'] = self.getNodeData(latest[0],"BALANCE")
  3070. recoveryLatestDf.loc[recoveryLatest, '最近一次还款日期'] = self.getNodeData(latest[0],"REPAYDATE")
  3071. recoveryLatestDf.loc[recoveryLatest, '账户关闭日期'] = self.getNodeData(latest[0],"SETTLEDATE")
  3072. #特殊交易信息
  3073. special = force.getElementsByTagName("SPECIALTRADEBASEINFOSG");
  3074. # if len(special)>0:
  3075. recoverySpecialDf.loc[recoverySpecial, '特殊交易类型'] = self.getNodeData(special[0],"TRANTYPECODE")
  3076. recoverySpecialDf.loc[recoverySpecial, '发生日期'] = self.getNodeData(special[0],"TRANDATE")
  3077. recoverySpecialDf.loc[recoverySpecial, '变更月数'] = self.getNodeData(special[0],"TRANMONTH")
  3078. recoverySpecialDf.loc[recoverySpecial, '发生金额'] = self.getNodeData(special[0],"TRANAMT")
  3079. recoverySpecialDf.loc[recoverySpecial, '明细记录'] = self.getNodeData(special[0],"DETRECORD")
  3080. # 非循环贷账户
  3081. def parseNoLoopLoan(self,docXml):
  3082. noloopCredit = docXml.documentElement.getElementsByTagName("NOLOOPCREDITACCOUNTBOLS")
  3083. #基本信息
  3084. if len(noloopCredit)>0:
  3085. noloop = docXml.documentElement.getElementsByTagName("NOLOOPCREDITACCOUNTBOLS")[0]
  3086. base = noloop.getElementsByTagName("CREDITACCTINFOBO");
  3087. noLoopLoanBaseDf.loc[noLoopLoanBase, '管理机构'] = self.getNodeData(base[0],"MANAGEORGTYPECODE")
  3088. noLoopLoanBaseDf.loc[noLoopLoanBase, '账户标识'] = self.getNodeData(base[0],"ACCTCODE")
  3089. noLoopLoanBaseDf.loc[noLoopLoanBase, '开立日期'] = self.getNodeData(base[0],"OPENDATE")
  3090. noLoopLoanBaseDf.loc[noLoopLoanBase, '到期日期'] = self.getNodeData(base[0],"DUEDATE")
  3091. noLoopLoanBaseDf.loc[noLoopLoanBase, '借款金额'] = self.getNodeData(base[0],"LOANAMT")
  3092. noLoopLoanBaseDf.loc[noLoopLoanBase, '账户币种'] = self.getNodeData(base[0],"MONEYTYPECODE")
  3093. noLoopLoanBaseDf.loc[noLoopLoanBase, '业务种类'] = self.getNodeData(base[0],"LOANTYPECODE")
  3094. noLoopLoanBaseDf.loc[noLoopLoanBase, '担保方式'] = self.getNodeData(base[0],"GUARMODECODE")
  3095. noLoopLoanBaseDf.loc[noLoopLoanBase, '还款期数'] = self.getNodeData(base[0],"REPAYPRD")
  3096. noLoopLoanBaseDf.loc[noLoopLoanBase, '还款频率'] = self.getNodeData(base[0],"REPAYFREQCYCODE")
  3097. noLoopLoanBaseDf.loc[noLoopLoanBase, '还款方式'] = self.getNodeData(base[0],"REPAYCODE")
  3098. noLoopLoanBaseDf.loc[noLoopLoanBase, '共同借款标志'] = self.getNodeData(base[0],"COMMBORROWERMAKERCODE")
  3099. #最近一次月度表现信息
  3100. LastMonth = noloop.getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  3101. # if len(LastMonth)>0:
  3102. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '账户状态'] = self.getNodeData(LastMonth[0],"ACCTSTATUCODE")
  3103. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '五级分类'] = self.getNodeData(LastMonth[0],"FIVECATECODE")
  3104. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '余额'] = self.getNodeData(LastMonth[0],"BUSIBAL")
  3105. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '剩余还款期数'] = self.getNodeData(LastMonth[0],"REMREPPRD")
  3106. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '结算/应还款日'] = self.getNodeData(LastMonth[0],"SETTDATE")
  3107. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '本月应还款'] = self.getNodeData(LastMonth[0],"CURRPYAMT")
  3108. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '本月实还款'] = self.getNodeData(LastMonth[0],"ACTRPYAMT")
  3109. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '最近一次还款日期'] = self.getNodeData(LastMonth[0],"LATRPYDATE")
  3110. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '当前逾期期数'] = self.getNodeData(LastMonth[0],"OVERDPRD")
  3111. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '当前逾期总额'] = self.getNodeData(LastMonth[0],"TOTOVERD")
  3112. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '逾期 31—60 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD3160PRINC")
  3113. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '逾期 61-90 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD6190PRINC")
  3114. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '逾期 91-180 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD91180PRINC")
  3115. noLoopLoanLastMonthDf.loc[noLoopLoanLastMonth, '逾期 180 天以上未还本金'] = self.getNodeData(LastMonth[0],"OVERDPRINCOVE180")
  3116. #最新表现信息
  3117. latest = noloop.getElementsByTagName("NEWPERFORMANCEBO");
  3118. # if len(latest)>0:
  3119. noLoopLoanLatestDf.loc[noLoopLoanLatest, '余额'] = self.getNodeData(latest[0],"BALANCE")
  3120. noLoopLoanLatestDf.loc[noLoopLoanLatest, '五级分类'] = self.getNodeData(latest[0],"FIVECATECODE")
  3121. noLoopLoanLatestDf.loc[noLoopLoanLatest, '最近一次还款日期'] = self.getNodeData(latest[0],"REPAYDATE")
  3122. noLoopLoanLatestDf.loc[noLoopLoanLatest, '最近一次还款金额'] = self.getNodeData(latest[0],"REPAYAMT")
  3123. noLoopLoanLatestDf.loc[noLoopLoanLatest, '当前还款状态'] = self.getNodeData(latest[0],"RPYSTATUSCODE")
  3124. noLoopLoanLatestDf.loc[noLoopLoanLatest, '信息报告日期'] = self.getNodeData(latest[0],"REPORTDATEINFO")
  3125. noLoopLoanLatestDf.loc[noLoopLoanLatest, '账户状态'] = self.getNodeData(latest[0],"ACCTSTATUSCODE")
  3126. noLoopLoanLatestDf.loc[noLoopLoanLatest, '转出月份'] = self.getNodeData(latest[0],"ROLLOUTDATE")
  3127. noLoopLoanLatestDf.loc[noLoopLoanLatest, '账户关闭日期'] = self.getNodeData(latest[0],"SETTLEDATE")
  3128. #最近 5 年内的历史表现信息
  3129. fiveYear = noloop.getElementsByTagName("FIVEYEARPERFORMANCESG");
  3130. fiveYearHis = noloop.getElementsByTagName("FIVEYEARHISRPYINFOSG")
  3131. # if len(fiveYear)>0:
  3132. fiveYearM = noloop.getElementsByTagName("FIVEYEARPERFORMANCESG")
  3133. fiveYearHis = noloop.getElementsByTagName("FIVEYEARHISRPYINFOSG")
  3134. noLoopLoan5YearDf.loc[noLoopLoan5Year, '起始年月'] = self.getNodeData(fiveYearM[0],"STARTYEARMONTH")
  3135. noLoopLoan5YearDf.loc[noLoopLoan5Year, '截止年月'] = self.getNodeData(fiveYearM[0],"ENDYEARMONTH")
  3136. # if len(fiveYearHis)>0:
  3137. noLoopLoan5YearDf.loc[noLoopLoan5Year, '月份'] = self.getNodeData(fiveYearHis[0], "OVERDMON")
  3138. noLoopLoan5YearDf.loc[noLoopLoan5Year, '还款状态'] = self.getNodeData(fiveYearHis[0],"OVERDSTATUSCODE")
  3139. noLoopLoan5YearDf.loc[noLoopLoan5Year, '逾期(透支)总额'] = self.getNodeData(fiveYearHis[0],"TOTACCTBAL")
  3140. #特殊交易信息
  3141. special = noloop.getElementsByTagName("SPECIALTRADEBASEINFOSG");
  3142. # if len(special)>0:
  3143. noLoopLoan5YearDf.loc[noLoopLoan5Year, '特殊交易类型'] = self.getNodeData(special[0],"TRANTYPECODE")
  3144. noLoopLoan5YearDf.loc[noLoopLoan5Year, '发生日期'] = self.getNodeData(special[0],"TRANDATE")
  3145. noLoopLoan5YearDf.loc[noLoopLoan5Year, '变更月数'] = self.getNodeData(special[0],"TRANMONTH")
  3146. noLoopLoan5YearDf.loc[noLoopLoan5Year, '发生金额'] = self.getNodeData(special[0],"TRANAMT")
  3147. noLoopLoan5YearDf.loc[noLoopLoan5Year, '明细记录'] = self.getNodeData(special[0],"DETRECORD")
  3148. # 循环额度下分账户
  3149. def parseLoopSubAccount(self,docXml):
  3150. loopQuata = docXml.documentElement.getElementsByTagName("LOOPQUOTAACCOUNTBOLS")
  3151. #循环额度下分账户基本信息
  3152. if len(loopQuata)>0:
  3153. loop = docXml.documentElement.getElementsByTagName("LOOPQUOTAACCOUNTBOLS")[0]
  3154. base = loop.getElementsByTagName("CREDITACCTINFOBO");
  3155. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '管理机构'] = self.getNodeData(base[0],"MANAGEORGTYPECODE")
  3156. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '账户标识'] = self.getNodeData(base[0],"ACCTCODE")
  3157. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '开立日期'] = self.getNodeData(base[0],"OPENDATE")
  3158. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '到期日期'] = self.getNodeData(base[0],"DUEDATE")
  3159. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '借款金额'] = self.getNodeData(base[0],"LOANAMT")
  3160. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '账户币种'] = self.getNodeData(base[0],"MONEYTYPECODE")
  3161. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '业务种类'] = self.getNodeData(base[0],"LOANTYPECODE")
  3162. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '担保方式'] = self.getNodeData(base[0],"GUARMODECODE")
  3163. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '还款期数'] = self.getNodeData(base[0],"REPAYPRD")
  3164. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '还款频率'] = self.getNodeData(base[0],"REPAYFREQCYCODE")
  3165. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '还款方式'] = self.getNodeData(base[0],"REPAYCODE")
  3166. LoopSubAccountBaseDf.loc[LoopSubAccountBase, '共同借款标志'] = self.getNodeData(base[0],"COMMBORROWERMAKERCODE")
  3167. #循环额度下分账户最近一次月度表现信息
  3168. LastMonth = loop.getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  3169. # if len(LastMonth)>0:
  3170. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '账户状态'] = self.getNodeData(LastMonth[0],"ACCTSTATUCODE")
  3171. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '五级分类'] = self.getNodeData(LastMonth[0],"FIVECATECODE")
  3172. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '余额'] = self.getNodeData(LastMonth[0],"BUSIBAL")
  3173. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '剩余还款期数'] = self.getNodeData(LastMonth[0],"REMREPPRD")
  3174. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '本月应还款'] = self.getNodeData(LastMonth[0],"CURRPYAMT")
  3175. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '应还款日'] = self.getNodeData(LastMonth[0],"SETTDATE")
  3176. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '本月实还款'] = self.getNodeData(LastMonth[0],"ACTRPYAMT")
  3177. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '最近一次还款日期'] = self.getNodeData(LastMonth[0],"LATRPYDATE")
  3178. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '当前逾期期数'] = self.getNodeData(LastMonth[0],"OVERDPRD")
  3179. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '当前逾期总额'] = self.getNodeData(LastMonth[0],"TOTOVERD")
  3180. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '逾期 31—60 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD3160PRINC")
  3181. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '逾期 61-90 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD6190PRINC")
  3182. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '逾期 91-180 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD91180PRINC")
  3183. LoopSubAccountLastMonthDf.loc[LoopSubAccountLastMonth, '逾期 180 天以上未还本金'] = self.getNodeData(LastMonth[0],"OVERDPRINCOVE180")
  3184. # 循环额度下分账户最近 5 年内的历史表现信息
  3185. fiveYear = loop.getElementsByTagName("FIVEYEARPERFORMANCESG");
  3186. fiveYearHis = fiveYear.getElementsByTagName("FIVEYEARHISRPYINFOSG")
  3187. # if len(fiveYear)>0:
  3188. LoopSubAccount5YearDf.loc[LoopSubAccount5Year, '起始年月'] = self.getNodeData(fiveYear[0],"STARTYEARMONTH")
  3189. LoopSubAccount5YearDf.loc[LoopSubAccount5Year, '截止年月'] = self.getNodeData(fiveYear[0],"ENDYEARMONTH")
  3190. if len(fiveYearHis)>0:
  3191. LoopSubAccount5YearDf.loc[LoopSubAccount5Year, '月份'] = self.getNodeData(fiveYearHis[0], "OVERDMON")
  3192. LoopSubAccount5YearDf.loc[LoopSubAccount5Year, '还款状态'] = self.getNodeData(fiveYearHis[0],"OVERDSTATUSCODE")
  3193. LoopSubAccount5YearDf.loc[LoopSubAccount5Year, '逾期(透支)总额'] = self.getNodeData(fiveYearHis[0],"TOTACCTBAL")
  3194. #循环额度下分帐户特殊交易信息
  3195. special = loop.getElementsByTagName("SPECIALTRADEBASEINFOSG");
  3196. # if len(special)>0:
  3197. LoopSubAccountSpecialDf.loc[LoopSubAccountSpecial, '特殊交易类型'] = self.getNodeData(special[0],"TRANTYPECODE")
  3198. LoopSubAccountSpecialDf.loc[LoopSubAccountSpecial, '发生日期'] = self.getNodeData(special[0],"TRANDATE")
  3199. LoopSubAccountSpecialDf.loc[LoopSubAccountSpecial, '变更月数'] = self.getNodeData(special[0],"TRANMONTH")
  3200. LoopSubAccountSpecialDf.loc[LoopSubAccountSpecial, '发生金额'] = self.getNodeData(special[0],"TRANAMT")
  3201. LoopSubAccountSpecialDf.loc[LoopSubAccountSpecial, '明细记录'] = self.getNodeData(special[0],"DETRECORD")
  3202. # 循环贷账户
  3203. def parseLoopLoan(self,docXml):
  3204. loopCredit = docXml.documentElement.getElementsByTagName("LOOPCREDITACCOUNTBOLS")
  3205. #基本信息
  3206. # base = loop.getElementsByTagName("CREDITACCTINFOBO");
  3207. if len(loopCredit)>0:
  3208. loop = docXml.documentElement.getElementsByTagName("LOOPCREDITACCOUNTBOLS")[0]
  3209. base = loop.getElementsByTagName("CREDITACCTINFOBO");
  3210. LoopLoanBaseDf.loc[LoopLoanBase, '管理机构'] = self.getNodeData(base[0],"MANAGEORGTYPECODE")
  3211. LoopLoanBaseDf.loc[LoopLoanBase, '账户标识'] = self.getNodeData(base[0],"ACCTCODE")
  3212. LoopLoanBaseDf.loc[LoopLoanBase, '开立日期'] = self.getNodeData(base[0],"OPENDATE")
  3213. LoopLoanBaseDf.loc[LoopLoanBase, '到期日期'] = self.getNodeData(base[0],"DUEDATE")
  3214. LoopLoanBaseDf.loc[LoopLoanBase, '账户授信额度'] = self.getNodeData(base[0],"ACCTCREDLINE")
  3215. LoopLoanBaseDf.loc[LoopLoanBase, '账户币种'] = self.getNodeData(base[0],"MONEYTYPECODE")
  3216. LoopLoanBaseDf.loc[LoopLoanBase, '业务种类'] = self.getNodeData(base[0],"LOANTYPECODE")
  3217. LoopLoanBaseDf.loc[LoopLoanBase, '担保方式'] = self.getNodeData(base[0],"GUARMODECODE")
  3218. LoopLoanBaseDf.loc[LoopLoanBase, '还款期数'] = self.getNodeData(base[0],"REPAYPRD")
  3219. LoopLoanBaseDf.loc[LoopLoanBase, '还款频率'] = self.getNodeData(base[0],"REPAYFREQCYCODE")
  3220. LoopLoanBaseDf.loc[LoopLoanBase, '还款方式'] = self.getNodeData(base[0],"REPAYCODE")
  3221. LoopLoanBaseDf.loc[LoopLoanBase, '共同借款标志'] = self.getNodeData(base[0],"COMMBORROWERMAKERCODE")
  3222. #最近一次月度表现信息
  3223. LastMonth = loop.getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  3224. # if len(LastMonth)>0:
  3225. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '账户状态'] = self.getNodeData(LastMonth[0],"ACCTSTATUCODE")
  3226. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '五级分类'] = self.getNodeData(LastMonth[0],"FIVECATECODE")
  3227. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '余额'] = self.getNodeData(LastMonth[0],"BUSIBAL")
  3228. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '剩余还款期数'] = self.getNodeData(LastMonth[0],"REMREPPRD")
  3229. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '结算/应还款日'] = self.getNodeData(LastMonth[0],"SETTDATE")
  3230. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '本月应还款'] = self.getNodeData(LastMonth[0],"CURRPYAMT")
  3231. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '本月实还款'] = self.getNodeData(LastMonth[0],"ACTRPYAMT")
  3232. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '最近一次还款日期'] = self.getNodeData(LastMonth[0],"LATRPYDATE")
  3233. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '当前逾期期数'] = self.getNodeData(LastMonth[0],"OVERDPRD")
  3234. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '当前逾期总额'] = self.getNodeData(LastMonth[0],"TOTOVERD")
  3235. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '逾期 31—60 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD3160PRINC")
  3236. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '逾期 61-90 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD6190PRINC")
  3237. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '逾期 91-180 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD91180PRINC")
  3238. LoopLoanLastMonthDf.loc[LoopLoanLastMonth, '逾期 180 天以上未还本金'] = self.getNodeData(LastMonth[0],"OVERDPRINCOVE180")
  3239. #最新表现信息
  3240. latest = loop.getElementsByTagName("NEWPERFORMANCEBO");
  3241. # if len(latest)>0:
  3242. LoopLoanLatestDf.loc[LoopLoanLatest, '余额'] = self.getNodeData(latest[0],"BALANCE")
  3243. LoopLoanLatestDf.loc[LoopLoanLatest, '五级分类'] = self.getNodeData(latest[0],"FIVECATECODE")
  3244. LoopLoanLatestDf.loc[LoopLoanLatest, '最近一次还款日期'] = self.getNodeData(latest[0],"REPAYDATE")
  3245. LoopLoanLatestDf.loc[LoopLoanLatest, '最近一次还款金额'] = self.getNodeData(latest[0],"REPAYAMT")
  3246. LoopLoanLatestDf.loc[LoopLoanLatest, '当前还款状态'] = self.getNodeData(latest[0],"RPYSTATUSCODE")
  3247. LoopLoanLatestDf.loc[LoopLoanLatest, '信息报告日期'] = self.getNodeData(latest[0],"REPORTDATEINFO")
  3248. LoopLoanLatestDf.loc[LoopLoanLatest, '账户状态'] = self.getNodeData(latest[0],"ACCTSTATUSCODE")
  3249. LoopLoanLatestDf.loc[LoopLoanLatest, '账户关闭日期'] = self.getNodeData(latest[0],"SETTLEDATE")
  3250. #最近 5 年内的历史表现信息
  3251. fiveYear = loop.getElementsByTagName("FIVEYEARPERFORMANCESG");
  3252. fiveYearHis = fiveYear.getElementsByTagName("FIVEYEARHISRPYINFOSG")
  3253. # if len(fiveYear)>0:
  3254. LoopLoan5YearDf.loc[LoopLoan5Year, '起始年月'] = self.getNodeData(fiveYear[0],"STARTYEARMONTH")
  3255. LoopLoan5YearDf.loc[LoopLoan5Year, '截止年月'] = self.getNodeData(fiveYear[0],"ENDYEARMONTH")
  3256. if len(fiveYearHis)>0:
  3257. LoopLoan5YearDf.loc[LoopLoan5Year, '月份'] = self.getNodeData(fiveYearHis[0], "OVERDMON")
  3258. LoopLoan5YearDf.loc[LoopLoan5Year, '还款状态'] = self.getNodeData(fiveYearHis[0],"OVERDSTATUSCODE")
  3259. LoopLoan5YearDf.loc[LoopLoan5Year, '逾期(透支)总额'] = self.getNodeData(fiveYearHis[0],"TOTACCTBAL")
  3260. #特殊交易信息
  3261. special = loop.getElementsByTagName("SPECIALTRADEBASEINFOSG");
  3262. # if len(special)>0:
  3263. LoopLoanSpecialDf.loc[LoopLoanSpecial, '特殊交易类型'] = self.getNodeData(special[0],"TRANTYPECODE")
  3264. LoopLoanSpecialDf.loc[LoopLoanSpecial, '发生日期'] = self.getNodeData(special[0],"TRANDATE")
  3265. LoopLoanSpecialDf.loc[LoopLoanSpecial, '变更月数'] = self.getNodeData(special[0],"TRANMONTH")
  3266. LoopLoanSpecialDf.loc[LoopLoanSpecial, '发生金额'] = self.getNodeData(special[0],"TRANAMT")
  3267. LoopLoanSpecialDf.loc[LoopLoanSpecial, '明细记录'] = self.getNodeData(special[0],"DETRECORD")
  3268. # 贷记卡账户
  3269. def parseCreditCard(self,docXml):
  3270. creditCard = docXml.documentElement.getElementsByTagName("CREDITCARDACCOUNTBOLS")
  3271. #基本信息
  3272. # base = credit.getElementsByTagName("CREDITACCTINFOBO");
  3273. if len(creditCard)>0:
  3274. credit = docXml.documentElement.getElementsByTagName("CREDITCARDACCOUNTBOLS")[0]
  3275. base = credit.getElementsByTagName("CREDITACCTINFOBO");
  3276. # LoopLoanBaseDf.loc[LoopLoanBase, '发卡机构'] = self.getNodeData(base[0],"MANAGEORGTYPECODE")
  3277. creditCardBaseDf.loc[creditCardBase, '账户标识'] = self.getNodeData(base[0],"ACCTCODE")
  3278. creditCardBaseDf.loc[creditCardBase, '开立日期'] = self.getNodeData(base[0],"OPENDATE")
  3279. creditCardBaseDf.loc[creditCardBase, '账户授信额度'] = self.getNodeData(base[0],"ACCTCREDLINE")
  3280. creditCardBaseDf.loc[creditCardBase, '共享授信额度'] = self.getNodeData(base[0],"ORGCREDLINE")
  3281. creditCardBaseDf.loc[creditCardBase, '账户币种'] = self.getNodeData(base[0],"MONEYTYPECODE")
  3282. creditCardBaseDf.loc[creditCardBase, '业务种类'] = self.getNodeData(base[0],"LOANTYPECODE")
  3283. creditCardBaseDf.loc[creditCardBase, '担保方式'] = self.getNodeData(base[0],"GUARMODECODE")
  3284. #最近一次月度表现信息
  3285. LastMonth = credit.getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  3286. # if len(LastMonth)>0:
  3287. creditCardLastMonthDf.loc[creditCardLastMonth, '账户状态'] = self.getNodeData(LastMonth[0],"ACCTSTATUCODE")
  3288. # creditCardLastMonthDf.loc[creditCardLastMonth, '五级分类'] = self.getNodeData(LastMonth[0],"FIVECATECODE")
  3289. creditCardLastMonthDf.loc[creditCardLastMonth, '余额'] = self.getNodeData(LastMonth[0],"BUSIBAL")
  3290. # creditCardLastMonthDf.loc[creditCardLastMonth, '剩余还款期数'] = self.getNodeData(LastMonth[0],"REMREPPRD")
  3291. # creditCardLastMonthDf.loc[creditCardLastMonth, '剩余分期期数'] = self.getNodeData(LastMonth[0],"REMREPPRD")
  3292. creditCardLastMonthDf.loc[creditCardLastMonth, '本月应还款'] = self.getNodeData(LastMonth[0],"CURRPYAMT")
  3293. creditCardLastMonthDf.loc[creditCardLastMonth, '本月实还款'] = self.getNodeData(LastMonth[0],"ACTRPYAMT")
  3294. creditCardLastMonthDf.loc[creditCardLastMonth, '最近一次还款日期'] = self.getNodeData(LastMonth[0],"LATRPYDATE")
  3295. creditCardLastMonthDf.loc[creditCardLastMonth, '已用额度'] = self.getNodeData(LastMonth[0],"ACCTBAL")
  3296. creditCardLastMonthDf.loc[creditCardLastMonth, '未出单的大额专项分期余额'] = self.getNodeData(LastMonth[0],"INSTBAL")
  3297. creditCardLastMonthDf.loc[creditCardLastMonth, '当前逾期期数'] = self.getNodeData(LastMonth[0],"OVERDPRD")
  3298. creditCardLastMonthDf.loc[creditCardLastMonth, '当前逾期总额'] = self.getNodeData(LastMonth[0],"TOTOVERD")
  3299. creditCardLastMonthDf.loc[creditCardLastMonth, '最近6个月平均使用额度'] = self.getNodeData(LastMonth[0],"AVGUSEAMOUNT")
  3300. creditCardLastMonthDf.loc[creditCardLastMonth, '最大使用额度'] = self.getNodeData(LastMonth[0],"MAXUSEAMOUNT")
  3301. # creditCardLastMonthDf.loc[creditCardLastMonth, '逾期 91-180 天未还本金'] = self.getNodeData(LastMonth[0],"OVERD91180PRINC")
  3302. # creditCardLastMonthDf.loc[creditCardLastMonth, '逾期 180 天以上未还本金'] = self.getNodeData(LastMonth[0],"OVERDPRINCOVE180")
  3303. #最新表现信息
  3304. latest = credit.getElementsByTagName("NEWPERFORMANCEBO");
  3305. # if len(latest)>0:
  3306. creditCardLatestDf.loc[creditCardLatest, '余额'] = self.getNodeData(latest[0],"BALANCE")
  3307. creditCardLatestDf.loc[creditCardLatest, '最近一次还款日期'] = self.getNodeData(latest[0],"REPAYDATE")
  3308. creditCardLatestDf.loc[creditCardLatest, '最近一次还款金额'] = self.getNodeData(latest[0],"REPAYAMT")
  3309. creditCardLatestDf.loc[creditCardLatest, '当前还款状态'] = self.getNodeData(latest[0],"RPYSTATUSCODE")
  3310. # creditCardLatestDf.loc[creditCardLatest, '信息报告日期'] = self.getNodeData(latest[0],"REPORTDATEINFO")
  3311. creditCardLatestDf.loc[creditCardLatest, '账户状态'] = self.getNodeData(latest[0],"ACCTSTATUSCODE")
  3312. creditCardLatestDf.loc[creditCardLatest, '账户关闭日期'] = self.getNodeData(latest[0],"SETTLEDATE")
  3313. #yuan 3.12 新增加大额专项
  3314. #最近 5 年内的历史表现信息
  3315. fiveYear = credit.getElementsByTagName("FIVEYEARPERFORMANCESG");
  3316. fiveYearHis = fiveYear.getElementsByTagName("FIVEYEARHISRPYINFOSG")
  3317. # if len(fiveYear)>0:
  3318. creditCard5YearDf.loc[creditCard5Year, '起始年月'] = self.getNodeData(fiveYear[0],"STARTYEARMONTH")
  3319. creditCard5YearDf.loc[creditCard5Year, '截止年月'] = self.getNodeData(fiveYear[0],"ENDYEARMONTH")
  3320. if len(fiveYearHis)>0:
  3321. creditCard5YearDf.loc[creditCard5Year, '月份'] = self.getNodeData(fiveYearHis[0], "OVERDMON")
  3322. creditCard5YearDf.loc[creditCard5Year, '还款状态'] = self.getNodeData(fiveYearHis[0],"OVERDSTATUSCODE")
  3323. creditCard5YearDf.loc[creditCard5Year, '逾期(透支)总额'] = self.getNodeData(fiveYearHis[0],"TOTACCTBAL")
  3324. #贷记卡账户特殊交易说明
  3325. special = credit.getElementsByTagName("SPECIALEVENTBASEINFOSG");
  3326. # if len(special)>0:
  3327. creditCardSpecialDf.loc[creditCardSpecial, '特殊事件类型'] = self.getNodeData(special[0],"SPECIALEVENTTYPECODE")
  3328. creditCardSpecialDf.loc[creditCardSpecial, '特殊事件发生月份'] = self.getNodeData(special[0],"SPECIALEVENTMON")
  3329. #贷记卡账户标注及声明信息
  3330. specialMent = credit.getElementsByTagName("SPECIALTRADEBASEINFOSG");
  3331. # if len(special)>0:
  3332. creditCardSpecialMentDf.loc[creditCardSpecialMent, '特殊交易类型'] = self.getNodeData(specialMent[0],"TRANTYPECODE")
  3333. creditCardSpecialMentDf.loc[creditCardSpecialMent, '发生日期'] = self.getNodeData(specialMent[0],"TRANDATE")
  3334. creditCardSpecialMentDf.loc[creditCardSpecialMent, '变更月数'] = self.getNodeData(specialMent[0],"TRANMONTH")
  3335. creditCardSpecialMentDf.loc[creditCardSpecialMent, '发生金额'] = self.getNodeData(specialMent[0],"TRANAMT")
  3336. creditCardSpecialMentDf.loc[creditCardSpecialMent, '明细记录'] = self.getNodeData(specialMent[0],"DETRECORD")
  3337. # 准贷记卡账户
  3338. def parseQuasiquasiCreditCard(self,docXml):
  3339. quasiCredit = docXml.documentElement.getElementsByTagName("PASSquasiCreditCardACCOUNTBOLS")
  3340. #基本信息
  3341. # base = quasi.getElementsByTagName("CREDITACCTINFOBO");
  3342. if len(quasiCredit)>0:
  3343. quasi = docXml.documentElement.getElementsByTagName("PASSquasiCreditCardACCOUNTBOLS")[0]
  3344. base = quasi.getElementsByTagName("CREDITACCTINFOBO");
  3345. quasiCreditCardBaseDf.loc[quasiCreditCardBase, '账户标识'] = self.getNodeData(base[0],"ACCTCODE")
  3346. quasiCreditCardBaseDf.loc[quasiCreditCardBase, '开立日期'] = self.getNodeData(base[0],"OPENDATE")
  3347. quasiCreditCardBaseDf.loc[quasiCreditCardBase, '账户授信额度'] = self.getNodeData(base[0],"ACCTCREDLINE")
  3348. quasiCreditCardBaseDf.loc[quasiCreditCardBase, '共享授信额度'] = self.getNodeData(base[0],"ORGCREDLINE")
  3349. quasiCreditCardBaseDf.loc[quasiCreditCardBase, '账户币种'] = self.getNodeData(base[0],"MONEYTYPECODE")
  3350. quasiCreditCardBaseDf.loc[quasiCreditCardBase, '担保方式'] = self.getNodeData(base[0],"GUARMODECODE")
  3351. #最近一次月度表现信息
  3352. LastMonth = quasi.getElementsByTagName("LATEMONTHLYPERFORMANCEBO")
  3353. # if len(LastMonth)>0:
  3354. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '账户状态'] = self.getNodeData(LastMonth[0],"ACCTSTATUCODE")
  3355. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '余额'] = self.getNodeData(LastMonth[0],"BUSIBAL")
  3356. # quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '透支余额'] = self.getNodeData(LastMonth[0],"REMREPPRD")
  3357. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '最大透支余额'] = self.getNodeData(LastMonth[0],"MAXOVERDRAFTBAL")
  3358. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '本月应还款'] = self.getNodeData(LastMonth[0],"CURRPYAMT")
  3359. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '本月实还款'] = self.getNodeData(LastMonth[0],"ACTRPYAMT")
  3360. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '最近一次还款日期'] = self.getNodeData(LastMonth[0],"LATRPYDATE")
  3361. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '已用额度'] = self.getNodeData(LastMonth[0],"ACCTBAL")
  3362. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '剩余分期期数'] = self.getNodeData(LastMonth[0],"REMREPPRD")
  3363. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '最近 6 个月 平均透支余额'] = self.getNodeData(LastMonth[0],"LATSIXMNAVGOVDFTBAL")
  3364. quasiCreditCardLastMonthDf.loc[quasiCreditCardLastMonth, '透支 180 天以上未付余额'] = self.getNodeData(LastMonth[0],"OVERDRAWBAOVE180")
  3365. #最新表现信息
  3366. latest = quasi.getElementsByTagName("NEWPERFORMANCEBO");
  3367. # if len(latest)>0:
  3368. quasiCreditCardLatestDf.loc[quasiCreditCardLatest, '余额'] = self.getNodeData(latest[0],"BALANCE")
  3369. quasiCreditCardLatestDf.loc[quasiCreditCardLatest, '最近一次还款日期'] = self.getNodeData(latest[0],"REPAYDATE")
  3370. quasiCreditCardLatestDf.loc[quasiCreditCardLatest, '最近一次还款金额'] = self.getNodeData(latest[0],"REPAYAMT")
  3371. quasiCreditCardLatestDf.loc[quasiCreditCardLatest, '当前还款状态'] = self.getNodeData(latest[0],"RPYSTATUSCODE")
  3372. quasiCreditCardLatestDf.loc[quasiCreditCardLatest, '信息报告日期'] = self.getNodeData(latest[0],"REPORTDATEINFO")
  3373. quasiCreditCardLatestDf.loc[quasiCreditCardLatest, '账户状态'] = self.getNodeData(latest[0],"ACCTSTATUSCODE")
  3374. quasiCreditCardLatestDf.loc[quasiCreditCardLatest, '账户关闭日期'] = self.getNodeData(latest[0],"SETTLEDATE")
  3375. #最近 5 年内的历史表现信息
  3376. fiveYear = quasi.getElementsByTagName("FIVEYEARPERFORMANCESG");
  3377. fiveYearHis = fiveYear.getElementsByTagName("FIVEYEARHISRPYINFOSG")
  3378. # if len(fiveYear)>0:
  3379. quasiCreditCard5YearDf.loc[quasiCreditCard5Year, '起始年月'] = self.getNodeData(fiveYear[0],"STARTYEARMONTH")
  3380. quasiCreditCard5YearDf.loc[quasiCreditCard5Year, '截止年月'] = self.getNodeData(fiveYear[0],"ENDYEARMONTH")
  3381. if len(fiveYearHis)>0:
  3382. quasiCreditCard5YearDf.loc[quasiCreditCard5Year, '月份'] = self.getNodeData(fiveYearHis[0], "OVERDMON")
  3383. quasiCreditCard5YearDf.loc[quasiCreditCard5Year, '还款状态'] = self.getNodeData(fiveYearHis[0],"OVERDSTATUSCODE")
  3384. quasiCreditCard5YearDf.loc[quasiCreditCard5Year, '逾期(透支)总额'] = self.getNodeData(fiveYearHis[0],"TOTACCTBAL")
  3385. #特殊交易信息
  3386. special = quasi.getElementsByTagName("SPECIALTRADEBASEINFOSG");
  3387. # if len(special)>0:
  3388. quasiCreditCardSpecialDf.loc[quasiCreditCardSpecial, '特殊交易类型'] = self.getNodeData(special[0],"TRANTYPECODE")
  3389. quasiCreditCardSpecialDf.loc[quasiCreditCardSpecial, '发生日期'] = self.getNodeData(special[0],"TRANDATE")
  3390. quasiCreditCardSpecialDf.loc[quasiCreditCardSpecial, '变更月数'] = self.getNodeData(special[0],"TRANMONTH")
  3391. quasiCreditCardSpecialDf.loc[quasiCreditCardSpecial, '发生金额'] = self.getNodeData(special[0],"TRANAMT")
  3392. quasiCreditCardSpecialDf.loc[quasiCreditCardSpecial, '明细记录'] = self.getNodeData(special[0],"DETRECORD")
  3393. # 相关还款责任信息
  3394. def parseRelevantRepaymentLiability(self,docXml):
  3395. about = docXml.documentElement.getElementsByTagName("ABOUTREPAYDUTYBASEINFOSG")
  3396. if len(about)>0:
  3397. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '管理机构'] = self.getNodeData(about[0],"MAINBUSIORGNAME")
  3398. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '业务种类'] = self.getNodeData(about[0],"BUSILINESCODE")
  3399. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '开立日期'] = self.getNodeData(about[0],"MAINBUSIOPENDATE")
  3400. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '到期日期'] = self.getNodeData(about[0],"MAINBUSIDUEDATE")
  3401. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '责任人类型'] = self.getNodeData(about[0],"ARLPTYPECODE")
  3402. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '还款责任金额'] = self.getNodeData(about[0],"RPYRESAMT")
  3403. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '币种'] = self.getNodeData(about[0],"MONEYTYPECODE")
  3404. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '保证合同编号'] = self.getNodeData(about[0],"GUARCONNUM")
  3405. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '余额'] = self.getNodeData(about[0],"MAINBUSIBAL")
  3406. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '五级分类'] = self.getNodeData(about[0],"FIVECATECODE")
  3407. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '还款状态'] = self.getNodeData(about[0],"MAINRPYSTATUSCODE")
  3408. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '逾期月数'] = self.getNodeData(about[0],"BUSIMONTH")
  3409. relevantRepaymentLiabilityDf.loc[relevantRepaymentLiability, '账户类型'] = self.getNodeData(about[0],"ACCTYPECODE")
  3410. # 授信协议信息
  3411. def parseCreditAgreement(self,docXml):
  3412. cont = docXml.documentElement.getElementsByTagName("CONTRACTBASEINFOSG")
  3413. if len(cont)>0:
  3414. creditAgreementDf.loc[creditAgreement, '管理机构'] = self.getNodeData(cont[0],"MANAGEORGCODE")
  3415. creditAgreementDf.loc[creditAgreement, '授信协议标识'] = self.getNodeData(cont[0],"CONTXTCODE")
  3416. creditAgreementDf.loc[creditAgreement, '生效日期'] = self.getNodeData(cont[0],"CONEFFDATE")
  3417. creditAgreementDf.loc[creditAgreement, '到期日期'] = self.getNodeData(cont[0],"CONEXPDATE")
  3418. creditAgreementDf.loc[creditAgreement, '授信额度用途'] = self.getNodeData(cont[0],"LIMITPURPOSECODE")
  3419. creditAgreementDf.loc[creditAgreement, '授信额度'] = self.getNodeData(cont[0],"CCAMOUNT")
  3420. creditAgreementDf.loc[creditAgreement, '授信限额'] = self.getNodeData(cont[0],"CREDITLIMIT")
  3421. creditAgreementDf.loc[creditAgreement, '授信限额编号'] = self.getNodeData(cont[0],"CREDITLIMITNUM")
  3422. creditAgreementDf.loc[creditAgreement, '已用额度'] = self.getNodeData(cont[0],"USELIMIT")
  3423. creditAgreementDf.loc[creditAgreement, '币种'] = self.getNodeData(cont[0],"MONEYTYPECODE")
  3424. # /三 信贷交易信息明细
  3425. #后付费记录
  3426. def parsePostPaidRecord(self,docXml):
  3427. post = docXml.documentElement.getElementsByTagName("AFTERPAYMONEYINFOSG")
  3428. if len(post)>0:
  3429. postPaidRecordDf.loc[postPaidRecord, '机构名称'] = self.getNodeData(post[0],"ORGANIZATIONNAME")
  3430. postPaidRecordDf.loc[postPaidRecord, '业务类型'] = self.getNodeData(post[0],"PAYBUSITYPECODE")
  3431. postPaidRecordDf.loc[postPaidRecord, '业务开通日期'] = self.getNodeData(post[0],"BUSIOPENDATE")
  3432. postPaidRecordDf.loc[postPaidRecord, '当前缴费状态'] = self.getNodeData(post[0],"PAYMENTSTATUSCODE")
  3433. postPaidRecordDf.loc[postPaidRecord, '当前欠费金额'] = self.getNodeData(post[0],"OWEAMOUNT")
  3434. postPaidRecordDf.loc[postPaidRecord, '记账年月'] = self.getNodeData(post[0],"ACCOUNTYEARMONTH")
  3435. #欠税记录
  3436. def parseTaxArrears(self,docXml,reportTime):
  3437. tax = docXml.documentElement.getElementsByTagName("OWINGTAXES")
  3438. if len(tax)>0:
  3439. taxArrearsDf.loc[taxArrearsIndex, '主管税务机关'] = self.getNodeData(tax[0],"TAXAUTHORITY")
  3440. taxArrearsDf.loc[taxArrearsIndex, '欠税总额'] = self.getNodeData(tax[0],"OWINGTAXESTOTAL")
  3441. taxArrearsDf.loc[taxArrearsIndex, '欠税统计日期'] = self.getNodeData(tax[0],"OWINGTAXESDATE")
  3442. # 民事判决记录
  3443. def parseCivilJudgment(self,docXml):
  3444. civil = docXml.documentElement.getElementsByTagName("CIVIL")
  3445. # for item in civil:
  3446. # self.saveNode(item)
  3447. if len(civil)>0:
  3448. civilJudgmentDf.loc[civilJudgmentIndex, '立案法院'] = self.getNodeData(civil[0],"COURT")
  3449. civilJudgmentDf.loc[civilJudgmentIndex, '案由'] = self.getNodeData(civil[0],"CAUSEOFACTION")
  3450. civilJudgmentDf.loc[civilJudgmentIndex, '立案日期'] = self.getNodeData(civil[0],"FILINGDATE")
  3451. civilJudgmentDf.loc[civilJudgmentIndex, '结案方式代码'] = self.getNodeData(civil[0],"CLOSEMCODE")
  3452. civilJudgmentDf.loc[civilJudgmentIndex, '结案方式描述'] = self.getNodeData(civil[0],"CLOSEMDESC")
  3453. civilJudgmentDf.loc[civilJudgmentIndex, '判决/调解结果'] = self.getNodeData(civil[0],"JUDRESULT")
  3454. civilJudgmentDf.loc[civilJudgmentIndex, '判决/调解生效日期'] = self.getNodeData(civil[0],"JUDDATE")
  3455. civilJudgmentDf.loc[civilJudgmentIndex, '诉讼标的'] = self.getNodeData(civil[0],"OBJECTOFACTION")
  3456. civilJudgmentDf.loc[civilJudgmentIndex, '诉讼标的金额'] = self.getNodeData(civil[0],"OBJOFACTMONEY")
  3457. #还有近24个月的属性值 由衍生字段添加
  3458. # 强制执行记录
  3459. def parseEnforce(self,docXml):
  3460. enforce = docXml.documentElement.getElementsByTagName("ENFORCEMENT")
  3461. # for item in civil:
  3462. # self.saveNode(item)
  3463. if len(enforce)>0:
  3464. enforceDf.loc[enforceIndex, '执行法院'] = self.getNodeData(enforce[0],"EXECOURT")
  3465. enforceDf.loc[enforceIndex, '执行案由'] = self.getNodeData(enforce[0],"EXECAUOFACTION")
  3466. enforceDf.loc[enforceIndex, '立案日期'] = self.getNodeData(enforce[0],"FILINGDATE")
  3467. enforceDf.loc[enforceIndex, '结案方式代码'] = self.getNodeData(enforce[0],"CLOSEMCODE")
  3468. # enforceDf.loc[enforceIndex, '结案方式描述'] = self.getNodeData(enforce[0],"CLOSEMDESC")
  3469. enforceDf.loc[enforceIndex, '案件状态'] = self.getNodeData(enforce[0],"CASESTATUS")
  3470. enforceDf.loc[enforceIndex, '结案日期'] = self.getNodeData(enforce[0],"CLOSINGDATE")
  3471. enforceDf.loc[enforceIndex, '申请执行标的'] = self.getNodeData(enforce[0],"ASKEXESUB")
  3472. enforceDf.loc[enforceIndex, '申请执行标的金额'] = self.getNodeData(enforce[0],"ASKEXEMONEY")
  3473. enforceDf.loc[enforceIndex, '已执行标的'] = self.getNodeData(enforce[0],"EXEDOBJ")
  3474. enforceDf.loc[enforceIndex, '已执行标的金额'] = self.getNodeData(enforce[0],"EXEDOBJMONEY")
  3475. #行政处罚记录
  3476. def parseAdministrativePunishment(self,docXml,reportTime):
  3477. punish = docXml.documentElement.getElementsByTagName("PENALTY")
  3478. # for item in civil:
  3479. # self.saveNode(item)
  3480. if len(punish)>0:
  3481. administrativePunishmentDf.loc[administrativePunishmentIndex, '处罚机构'] = self.getNodeData(punish[0],"PUNISHORG")
  3482. administrativePunishmentDf.loc[administrativePunishmentIndex, '处罚内容'] = self.getNodeData(punish[0],"PUNISHCON")
  3483. administrativePunishmentDf.loc[administrativePunishmentIndex, '处罚金额'] = self.getNodeData(punish[0],"PUNISHMONEY")
  3484. administrativePunishmentDf.loc[administrativePunishmentIndex, '处罚生效日期'] = self.getNodeData(punish[0],"PUNSTARTDATE")
  3485. administrativePunishmentDf.loc[administrativePunishmentIndex, '处罚截止日期'] = self.getNodeData(punish[0],"PUNENDDATE")
  3486. administrativePunishmentDf.loc[administrativePunishmentIndex, '行政复议结果'] = self.getNodeData(punish[0],"RECRESULT")
  3487. # 住房公积金参缴记录
  3488. def parseHousingProvidentFundParticipation(self,docXml):
  3489. houseFund = docXml.documentElement.getElementsByTagName("HOUSINGFUND")
  3490. # for item in civil:
  3491. # self.saveNode(item)
  3492. if len(houseFund)>0:
  3493. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '参缴地代码'] = self.getNodeData(houseFund[0],"ADDRESSCODE")
  3494. # housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '参缴地描述'] = self.getNodeData(houseFund[0],"ADDRESSDESC")
  3495. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '参缴日期'] = self.getNodeData(houseFund[0],"PAYDATE")
  3496. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '缴费状态代码'] = self.getNodeData(houseFund[0],"STATUSCODE")
  3497. # housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '缴费状态描述'] = self.getNodeData(houseFund[0],"STATUSDESC")
  3498. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '初缴月份'] = self.getNodeData(houseFund[0],"BEGINMONTH")
  3499. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '缴至月份'] = self.getNodeData(houseFund[0],"ENDMONTH")
  3500. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '单位缴存比例'] = self.getNodeData(houseFund[0],"COMPROPORTION")
  3501. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '个人缴存比例'] = self.getNodeData(houseFund[0],"PEPROPORTION")
  3502. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '月缴存额'] = self.getNodeData(houseFund[0],"MONTHMONEY")
  3503. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '缴费单位'] = self.getNodeData(houseFund[0],"COMPANY")
  3504. housingProvidentFundParticipationIndexDf.loc[housingProvidentFundParticipationIndex, '信息更新日期'] = self.getNodeData(houseFund[0],"UPDATEDATE")
  3505. # 低保救助记录
  3506. def parseSubsistenceAllowanceAssistance(self,docXml):
  3507. assistance = docXml.documentElement.getElementsByTagName("ALLOWANC")
  3508. # for item in civil:
  3509. # self.saveNode(item)
  3510. if len(assistance)>0:
  3511. subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '人员类别代码'] = self.getNodeData(assistance[0],"PERTYPECODE")
  3512. # subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '人员类别描述'] = self.getNodeData(assistance[0],"PERTYPEDESC")
  3513. subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '所在地代码'] = self.getNodeData(assistance[0],"ADDRESSCODE")
  3514. # subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '所在地描述'] = self.getNodeData(assistance[0],"ADDRESSDESC")
  3515. subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '工作单位'] = self.getNodeData(assistance[0],"WORKUNIT")
  3516. subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '家庭月收入'] = self.getNodeData(assistance[0],"FAMILYINCOME")
  3517. subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '申请日期'] = self.getNodeData(assistance[0],"APPLYDATE")
  3518. subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '批准日期'] = self.getNodeData(assistance[0],"APPROVEDATE")
  3519. subsistenceAllowanceAssistanceDf.loc[subsistenceAllowanceAssistanceIndex, '信息更新日期'] = self.getNodeData(assistance[0],"UPDATEDATE")
  3520. # 执业资格记录
  3521. def parsePracticeQualification(self,docXml):
  3522. qualification = docXml.documentElement.getElementsByTagName("PRACTISING")
  3523. # for item in civil:
  3524. # self.saveNode(item)
  3525. if len(qualification)>0:
  3526. practiceQualificationDf.loc[practiceQualificationIndex, '执业资格名称'] = self.getNodeData(qualification[0],"NAME")
  3527. practiceQualificationDf.loc[practiceQualificationIndex, '颁发机构'] = self.getNodeData(qualification[0],"ISSUER")
  3528. practiceQualificationDf.loc[practiceQualificationIndex, '等级代码'] = self.getNodeData(qualification[0],"LEVELCODE")
  3529. # practiceQualificationDf.loc[practiceQualificationIndex, '等级描述'] = self.getNodeData(qualification[0],"LEVELDESC")
  3530. practiceQualificationDf.loc[practiceQualificationIndex, '机构所在地代码'] = self.getNodeData(qualification[0],"INSLOCATIONCODE")
  3531. # practiceQualificationDf.loc[practiceQualificationIndex, '机构所在地描述'] = self.getNodeData(qualification[0],"INSLOCATIONDESC")
  3532. practiceQualificationDf.loc[practiceQualificationIndex, '获得年月'] = self.getNodeData(qualification[0],"YEARMONTH")
  3533. practiceQualificationDf.loc[practiceQualificationIndex, '到期年月'] = self.getNodeData(qualification[0],"EXPIREYEMON")
  3534. practiceQualificationDf.loc[practiceQualificationIndex, '吊销年月'] = self.getNodeData(qualification[0],"REVOKEYEMON")
  3535. #行政奖励记录
  3536. def parseAdministrativeIncentive(self,docXml,reportTime):
  3537. incentive = docXml.documentElement.getElementsByTagName("OWINGTAXES")
  3538. # for item in civil:
  3539. # self.saveNode(item)
  3540. if len(incentive)>0:
  3541. administrativeIncentiveDf.loc[administrativeIncentiveIndex, '奖励机构'] = self.getNodeData(incentive[0],"REWARDINS")
  3542. administrativeIncentiveDf.loc[administrativeIncentiveIndex, '奖励内容'] = self.getNodeData(incentive[0],"REWARDCON")
  3543. administrativeIncentiveDf.loc[administrativeIncentiveIndex, '生效年月'] = self.getNodeData(incentive[0],"EFFECTIVEMONTH")
  3544. administrativeIncentiveDf.loc[administrativeIncentiveIndex, '截止年月'] = self.getNodeData(incentive[0],"DEADLINEMONTH")
  3545. # 查询记录
  3546. def parseQueryRecordY(self,docXml):
  3547. record = docXml.documentElement.getElementsByTagName("QUERYRECORDSG")
  3548. if len(record)>0:
  3549. queryRecordDfY.loc[queryRecordIndexY, '查询日期'] = self.getNodeData(record[0],"QUERYDATE")
  3550. queryRecordDfY.loc[queryRecordIndexY, '查询机构类型代码'] = self.getNodeData(record[0],"QORGTYPECODE")
  3551. # queryRecordDfY.loc[queryRecordIndexY, '查询机构类型描述'] = self.getNodeData(record[0],"QORGTYPEDESC")
  3552. queryRecordDfY.loc[queryRecordIndexY, '查询机构'] = self.getNodeData(record[0],"QUERYORG")
  3553. queryRecordDfY.loc[queryRecordIndexY, '查询原因'] = self.getNodeData(record[0],"QUERYREASONCODE")
  3554. # queryRecordDfY.loc[queryRecordIndexY, '查询原因描述'] = self.getNodeData(record[0],"QUERYREASONDESC")