parseCreditXml.py1111 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. #coding=utf-8
  2. from xml.dom import minidom
  3. import base64
  4. import sys
  5. import os
  6. from ini_op import Config;
  7. base_dir = os.path.dirname(os.path.abspath(__file__))
  8. config = Config(base_dir+"/config.ini");
  9. productNumXy = config.get("baseconf", "productNumXy")
  10. productNumJz = config.get("baseconf","productNumJz")
  11. productNumXxw = config.get("baseconf","productNumXxw")
  12. productNumFb = config.get("baseconf", "productNumFb")
  13. productNumKcd = config.get("baseconf", "productNumKcd")
  14. productNumFd = config.get("baseconf", "productNumFd")
  15. productNumKn = config.get("baseconf", "productNumKn")
  16. productNumHst = config.get("baseconf", "productNumHst")
  17. productNumQk = config.get("baseconf", "productNumQk")
  18. productNumHc = config.get("baseconf", "productNumHc")
  19. productNum500 = config.get("baseconf", "productNum500")
  20. productNumHsz = config.get("baseconf", "productNumHsz")
  21. #简营
  22. productNumJy = config.get("baseconf", "productNumJy")
  23. #新版桔子
  24. productNumJzA = config.get("baseconf", "productNumJzA")
  25. #仁东
  26. productNumRd = config.get("baseconf", "productNumRd")
  27. #恒昌新
  28. productNumHcNew = config.get("baseconf", "productNumHcNew")
  29. isPlt = config.get("baseconf", "isPlt");
  30. import xyHttp
  31. import hst_rule_set
  32. import pboc_hc
  33. import log
  34. import shutil
  35. logger = log.logger
  36. import time
  37. from dbController import DbController
  38. dbController = DbController();
  39. import json
  40. import requests
  41. import timeit
  42. import traceback
  43. import gzip
  44. import io
  45. from xmlParser import XmlParser;
  46. from xmlParserHsz import XmlParserHsz;
  47. from pboc.invokePboc import PBOC
  48. from mailUtil import MailUtil
  49. def gzip_str(string_):
  50. out = io.BytesIO()
  51. with gzip.GzipFile(fileobj=out, mode='w') as fo:
  52. fo.write(string_.encode())
  53. bytes_obj = out.getvalue()
  54. return bytes_obj
  55. def gunzip_bytes_obj(bytes_obj):
  56. in_ = io.BytesIO()
  57. in_.write(bytes_obj)
  58. in_.seek(0)
  59. with gzip.GzipFile(fileobj=in_, mode='rb') as fo:
  60. gunzipped_bytes_obj = fo.read()
  61. return gunzipped_bytes_obj.decode()
  62. #解析xml数据
  63. def getBusinessInfo(xmlFile):
  64. doc = minidom.parse(xmlFile)
  65. request = doc.documentElement.getElementsByTagName("request")[0]
  66. responseBody = doc.documentElement.getElementsByTagName("responseBody")[0]
  67. responseHeader = doc.documentElement.getElementsByTagName("responseHeader")[0]
  68. result = ""
  69. xmlData = ""
  70. isBaihu = "0";
  71. if len(responseBody.childNodes)==0:
  72. mailUtil = MailUtil();
  73. webhook = 'https://oapi.dingtalk.com/robot/send?access_token=64d8b2c7fed4949e9433b807c7c5559939f1517af8f77c1dacb4de19c6910b56'
  74. if getNodeData(responseHeader,"resultMsg")=="查询成功,无报告":
  75. isBaihu = "1"
  76. else:
  77. isBaihu = "2"#查询失败
  78. mailUtil.dingtalk("号码:" + xmlFile.split("_")[0] + " 查询失败 ", webhook)
  79. else:
  80. responseBodyText = responseBody.childNodes[0].data
  81. decrpyt_bytes = base64.b64decode(responseBodyText)
  82. xmlData = gunzip_bytes_obj(decrpyt_bytes)
  83. # print(xmlData)
  84. #remove by chenqiwang 1105
  85. xmlPath = xmlFile+".txt"
  86. # with open(xmlPath, 'w', encoding='utf-8') as fp:
  87. # fp.write(xmlData)
  88. # 非小赢需要解析
  89. productNum = getNodeData(request, "productNum")
  90. sqlMap = []
  91. if productNum != productNumXy:
  92. if xmlData !="":
  93. if productNum == productNumHsz:
  94. result,sqlMap = parseHsz(xmlData)
  95. else:
  96. #跑数据的时候改为parseHsz
  97. result,sqlMap = parse(xmlData)
  98. data = {
  99. "businessNum":getNodeData(request,"businessNum"),
  100. "coopBusinessNum": getNodeData(request, "coopBusinessNum"),
  101. "customerNum":getNodeData(request,"customerNum"),
  102. "certificateNum": getNodeData(request, "certificateNum"),
  103. "productNum": productNum,
  104. "creditXml":xmlData,
  105. "extend": getNodeData(request, "extend"),
  106. "result":result,
  107. "isBaihu":isBaihu,
  108. "sqlMap":sqlMap
  109. }
  110. return data
  111. #解析xml报文
  112. def parse(xmlData):
  113. xmlParse = XmlParser()
  114. result = ""
  115. try:
  116. result,sqlMap = xmlParse.parse(xmlData)
  117. except:
  118. info = sys.exc_info()
  119. logger.error(info[0])
  120. logger.error(info[1])
  121. logger.error(traceback.extract_tb(info[2], 1))
  122. return result,sqlMap
  123. #解析xml报文 汇算帐
  124. def parseHsz(xmlData):
  125. xmlParseHsz = XmlParserHsz()
  126. result = ""
  127. try:
  128. result = xmlParseHsz.parse(xmlData)
  129. except:
  130. info = sys.exc_info()
  131. logger.error(info[0])
  132. logger.error(info[1])
  133. logger.error(traceback.extract_tb(info[2], 1))
  134. return result
  135. def getNodeData(request,key):
  136. data = request.getElementsByTagName(key)[0].childNodes[0].data
  137. return data;
  138. # if __name__ == '__main__':
  139. # businessInfo = getBusinessInfo('./test.xml')
  140. # print(businessInfo)
  141. # xml = ""
  142. # data = base64.b64encode(xml.encode("UTF-8"))
  143. # print(str(data))
  144. #调用http
  145. def process(businessInfo,basePath,xml_path):
  146. productNum = businessInfo["productNum"]
  147. if productNumXy.find(productNum) >= 0:
  148. try:
  149. result = xyHttp.call_credit(businessInfo)
  150. # result = json.loads(result);
  151. # logger.info(result)
  152. #上传审批结果
  153. jsonPath = basePath + businessInfo["certificateNum"] + ".txt"
  154. logger.info(jsonPath)
  155. with open(jsonPath, 'w', encoding='utf-8') as fp:
  156. fp.write(result)
  157. uploadJsonFile(businessInfo,jsonPath)
  158. #移动xml文件
  159. try:
  160. dayStrPath = basePath+productNum+"/"+time.strftime('%Y%m%d', time.localtime(time.time()))+"/";
  161. descXmlPath = dayStrPath +"xml/"+ os.path.basename(xml_path)
  162. descJsonPath = dayStrPath+"txt/" + os.path.basename(jsonPath)
  163. if not os.path.exists(basePath+productNum):
  164. os.mkdir(basePath+productNum)
  165. if not os.path.exists(dayStrPath):
  166. os.mkdir(dayStrPath)
  167. if not os.path.exists(dayStrPath+"xml/"):
  168. os.mkdir(dayStrPath + "xml/")
  169. if not os.path.exists(dayStrPath+"txt/"):
  170. os.mkdir(dayStrPath+"txt/")
  171. logger.info("移动文件 from " + xml_path + " to " + descXmlPath)
  172. if isPlt == "1":
  173. move(xml_path, descXmlPath)
  174. shutil.move(jsonPath, descJsonPath)
  175. except:
  176. logger.error(businessInfo["certificateNum"]+"#创建文件夹或者移动文件失败,不影响业务")
  177. logger.error(traceback.print_exc())
  178. logger.error(traceback.format_exc())
  179. except:
  180. logger.error(traceback.print_exc())
  181. logger.error(traceback.format_exc())
  182. mailUtil = MailUtil();
  183. webhook = 'https://oapi.dingtalk.com/robot/send?access_token=64d8b2c7fed4949e9433b807c7c5559939f1517af8f77c1dacb4de19c6910b56'
  184. mailUtil.dingtalk("号码:" + businessInfo["certificateNum"] + " 调用xy服务失败 ", webhook)
  185. elif productNumQk.find(productNum) >= 0 or productNumHsz.find(productNum) >= 0 or productNumHc.find(productNum) >= 0 \
  186. or productNumJzA.find(productNum) >= 0 or productNumRd.find(productNum) >= 0 or productNumHcNew.find(productNum) >= 0:#洽客
  187. txtPath = xml_path.replace(".xml", ".txt")
  188. with open(txtPath, 'w', encoding='utf-8') as fp:
  189. fp.write(businessInfo["result"])
  190. if productNumQk.find(productNum) >= 0:
  191. result = xyHttp.callQk(businessInfo)
  192. if productNumHc.find(productNum) >= 0:
  193. result = xyHttp.callHc(businessInfo)
  194. elif productNumHsz.find(productNum) >= 0:
  195. result = xyHttp.callHsz(businessInfo)
  196. elif productNumJzA.find(productNum) >= 0:
  197. result = xyHttp.callJz(businessInfo)
  198. elif productNumRd.find(productNum) >= 0:
  199. result = xyHttp.callRd(businessInfo)
  200. elif productNumHcNew.find(productNum) >= 0:
  201. result = pboc_hc.renhang_rules(businessInfo)
  202. # result = json.loads(result);
  203. logger.info(result)
  204. #上传审批结果
  205. jsonPath = basePath + businessInfo["certificateNum"] + ".txt"
  206. logger.info(jsonPath)
  207. with open(jsonPath, 'w', encoding='utf-8') as fp:
  208. fp.write(result)
  209. uploadJsonFile(businessInfo,jsonPath)
  210. #移动xml文件
  211. dayStrPath = basePath+productNum+"/"+time.strftime('%Y%m%d', time.localtime(time.time()))+"/";
  212. descXmlPath = dayStrPath +"xml/"+ os.path.basename(xml_path)
  213. descJsonPath = dayStrPath+"txt/" + os.path.basename(jsonPath)
  214. descTxtPath = dayStrPath + "txt/" + os.path.basename(txtPath)
  215. if not os.path.exists(basePath+productNum):
  216. os.mkdir(basePath+productNum)
  217. if not os.path.exists(dayStrPath):
  218. os.mkdir(dayStrPath)
  219. if not os.path.exists(dayStrPath+"xml/"):
  220. os.mkdir(dayStrPath + "xml/")
  221. if not os.path.exists(dayStrPath+"txt/"):
  222. os.mkdir(dayStrPath+"txt/")
  223. logger.info("移动文件 from " + xml_path + " to " + descXmlPath)
  224. if isPlt == "1":
  225. move(xml_path, descXmlPath)
  226. shutil.move(jsonPath, descJsonPath)
  227. shutil.move(txtPath, descTxtPath)
  228. else:
  229. #走jar包逻辑
  230. # print(businessInfo["result"])
  231. txtPath = xml_path.replace(".xml",".txt")
  232. with open(txtPath, 'w', encoding='utf-8') as fp:
  233. fp.write(businessInfo["result"])
  234. if productNum == productNumJz:#桔子
  235. invokePboc(businessInfo, txtPath)
  236. #移动xml文件
  237. descXmlPath = basePath + "execed_new/" + os.path.basename(xml_path)
  238. if isPlt == "1":
  239. move(xml_path, descXmlPath)
  240. elif productNum == productNumXxw:#新希望
  241. invokeXxw(businessInfo, txtPath);
  242. jsonPath = basePath + businessInfo["certificateNum"] + ".txt"
  243. #移动xml文件
  244. descXmlPath = basePath + "execed_new/" + os.path.basename(xml_path)
  245. if not os.path.exists(basePath + "execed_new/"):
  246. os.mkdir(basePath + "execed_new/")
  247. logger.info("移动文件 from " + xml_path + " to " + descXmlPath)
  248. if isPlt == "1":
  249. move(xml_path, descXmlPath)
  250. elif productNum == productNumFb or productNum== productNumKcd or productNum500.find(productNum)>=0:#没有java包 #快车道和风暴 上传500个字段
  251. logger.info(businessInfo["productNum"])
  252. uploadJsonFile(businessInfo,txtPath)
  253. # 移动xml文件
  254. descXmlPath = basePath + "execed_new/" + os.path.basename(xml_path)
  255. if not os.path.exists(basePath + "execed_new/"):
  256. os.mkdir(basePath + "execed_new/")
  257. logger.info("移动文件 from " + xml_path + " to " + descXmlPath)
  258. if isPlt == "1":
  259. move(xml_path, descXmlPath)
  260. elif productNumJy.find(productNum)>=0:#简营
  261. logger.info(businessInfo["productNum"])
  262. jsonPath = txtPath.replace(".txt","_json.txt")
  263. #写入数据到文件
  264. xyHttp.buildJyData(businessInfo,jsonPath)
  265. uploadJsonFile(businessInfo, jsonPath)
  266. # 移动xml文件
  267. descXmlPath = basePath + "execed_new/" + os.path.basename(xml_path)
  268. if not os.path.exists(basePath + "execed_new/"):
  269. os.mkdir(basePath + "execed_new/")
  270. logger.info("移动文件 from " + xml_path + " to " + descXmlPath)
  271. if isPlt == "1":
  272. descTxtPath = basePath + "execed_txt/" + os.path.basename(jsonPath)
  273. try:
  274. shutil.move(jsonPath, descTxtPath)
  275. except Exception:
  276. pass
  277. move(xml_path, descXmlPath)
  278. elif productNum == productNumFd:#分蛋 白户审批通过
  279. if businessInfo["result"]!="":
  280. result = xyHttp.callNewModel(businessInfo)
  281. uploadAudit(result,businessInfo["businessNum"],productNum)
  282. else:
  283. result = {"approveResult":"1","rule":"白户"}
  284. uploadAudit(result, businessInfo["businessNum"], productNum)
  285. # 移动xml文件
  286. descXmlPath = basePath + "execed_new/" + os.path.basename(xml_path)
  287. if not os.path.exists(basePath + "execed_new/"):
  288. os.mkdir(basePath + "execed_new/")
  289. logger.info("移动文件 from " + xml_path + " to " + descXmlPath)
  290. if isPlt == "1":
  291. move(xml_path, descXmlPath)
  292. elif productNumKn.find(productNum)>=0 :#快牛本地jar包,本地jar改为逗号配置
  293. if businessInfo["result"]!="":
  294. result = xyHttp.callLocal(businessInfo)
  295. uploadAudit(result,businessInfo["businessNum"],productNum)
  296. else:
  297. result = {"approveResult":"0","rule":"白户"}
  298. uploadAudit(result, businessInfo["businessNum"], productNum)
  299. # 移动xml文件
  300. descXmlPath = basePath + "execed_new/" + os.path.basename(xml_path)
  301. if not os.path.exists(basePath + "execed_new/"):
  302. os.mkdir(basePath + "execed_new/")
  303. logger.info("移动文件 from " + xml_path + " to " + descXmlPath)
  304. if isPlt == "1":
  305. move(xml_path, descXmlPath)
  306. elif productNum == productNumHst:#海盛通
  307. if businessInfo["result"]!="":
  308. result = hst_rule_set.callLocal(businessInfo)
  309. uploadAudit(result,businessInfo["businessNum"],productNum)
  310. else:
  311. result = {"approveResult":"0","rule":"白户"}
  312. uploadAudit(result, businessInfo["businessNum"], productNum)
  313. # 移动xml文件
  314. descXmlPath = basePath + "execed_new/" + os.path.basename(xml_path)
  315. if not os.path.exists(basePath + "execed_new/"):
  316. os.mkdir(basePath + "execed_new/")
  317. logger.info("移动文件 from " + xml_path + " to " + descXmlPath)
  318. if isPlt == "1":
  319. move(xml_path, descXmlPath)
  320. else:
  321. i=0
  322. #本地jar
  323. if isPlt == "1":
  324. if not os.path.exists(basePath + "execed_txt/"):
  325. os.mkdir(basePath + "execed_txt/")
  326. descTxtPath = basePath + "execed_txt/" + os.path.basename(txtPath)
  327. shutil.move(txtPath, descTxtPath)
  328. #调用jar包
  329. def move(xml_path, descXmlPath):
  330. try:
  331. shutil.move(xml_path, descXmlPath)
  332. if not os.path.exists(basePath + "execed_xml/"):
  333. os.mkdir(basePath + "execed_xml/")
  334. shutil.move(xml_path+".txt", descXmlPath.replace("execed_new","execed_xml")+".txt")
  335. # os.remove(xml_path+".txt")#删除生成的xml.txt文件
  336. except:
  337. logger.info("移动文件 from " + xml_path + " to " + descXmlPath +" error")
  338. def invokePboc(businessInfo,txtPath):
  339. # ===================================
  340. try:
  341. businessNum = businessInfo["businessNum"]
  342. coopBusinessNum = businessInfo["coopBusinessNum"]
  343. pboc = PBOC()
  344. jarTxt = pboc.calc(txtPath,coopBusinessNum);
  345. result = json.loads(jarTxt)
  346. logger.info(result)
  347. if result.get("errcode")== None:
  348. uploadAudit(result,businessNum,businessInfo["productNum"])
  349. else:
  350. if businessInfo["isBaihu"]=="1":
  351. result = {"approveResult":"1"}
  352. uploadAudit(result, businessNum, businessInfo["productNum"])
  353. logger.error(result["errmsg"])
  354. except:
  355. logger.error("certificateNum=" + businessInfo["coopBusinessNum"])
  356. info = sys.exc_info()
  357. logger.error(info[0])
  358. logger.error(info[1])
  359. # logging.log(logging.ERROR, info[2])
  360. logger.error(traceback.extract_tb(info[2], 1))
  361. #调用xxwjar包
  362. def invokeXxw(businessInfo,txtPath):
  363. try:
  364. businessNum = businessInfo["businessNum"]
  365. coopBusinessNum = businessInfo["coopBusinessNum"]
  366. customerNum = businessInfo["customerNum"]
  367. certificateNum = businessInfo["certificateNum"]
  368. pboc = PBOC()
  369. jarTxt = pboc.calcXxw(coopBusinessNum,customerNum,txtPath);
  370. logger.info("jarTxt:"+jarTxt)
  371. result = json.loads(jarTxt)
  372. jsonPath = basePath+certificateNum+".txt"
  373. # logger.info(jsonPath)
  374. with open(jsonPath, 'w', encoding='utf-8') as fp:
  375. fp.write(jarTxt)
  376. uploadJsonFile(businessInfo,jsonPath)
  377. if not os.path.exists(basePath + "execed_txt/"):
  378. os.mkdir(basePath + "execed_txt/")
  379. descJsonPath = basePath + "execed_txt/" + os.path.basename(jsonPath)
  380. shutil.move(jsonPath, descJsonPath)
  381. except:
  382. logger.error("certificateNum=" + businessInfo["coopBusinessNum"])
  383. info = sys.exc_info()
  384. logger.error(info[0])
  385. logger.error(info[1])
  386. logger.error(traceback.extract_tb(info[2], 1))
  387. #上传审批结果
  388. def uploadAudit(result,businessNum,productNum):
  389. approvalType = result["approveResult"]
  390. if productNum == productNumJz:
  391. if approvalType=="1":
  392. approvalOpinion = "征信通过"
  393. approvalType = "4"
  394. else:
  395. approvalOpinion = "征信拒绝"
  396. approvalType = "3"
  397. elif productNumKn.find(productNum)>=0 or productNum == productNumHst or productNum == productNumFd:
  398. if approvalType=="1":
  399. approvalOpinion = "征信通过"
  400. approvalType = "4"
  401. else:#快牛 需要添加拒绝原因
  402. approvalOpinion = "征信拒绝" + "#" + result["rule"]
  403. approvalType = "3"
  404. taskKey = config.get("baseconf","taskKey")
  405. appoveApiUrl = config.get("baseconf","appoveApiUrl")
  406. key = config.get("baseconf", "AESKey")
  407. data = {"header":{
  408. "ticket": "2938123198320412343",
  409. "timestamp": int(int(round(time.time() * 1000+60*1000))),
  410. "nonce": config.get("baseconf", "nonce")
  411. },
  412. "body":{"approvalType": approvalType, "businessNum": businessNum,"taskKey":taskKey,"approvalOpinion":approvalOpinion}}
  413. access_token = dbController.getToken();
  414. if access_token == "":#获取token失败重新获取
  415. access_token = dbController.getToken();
  416. appoveApiUrl = appoveApiUrl+"?access_token="+access_token
  417. headers = {"Content-Type": "application/json"}
  418. jsonStr = json.dumps(data);
  419. jsonStr = jsonStr.replace('"',"\\\"")#必须替换才行
  420. logger.info(jsonStr)
  421. pboc = PBOC();
  422. encryData = pboc.encrypt(jsonStr,key)
  423. encryData = encryData[0:len(encryData)-2]
  424. logger.info(encryData)
  425. response = requests.post(appoveApiUrl, data=encryData,headers=headers)
  426. text = response.text
  427. pboc = PBOC();
  428. resultText = pboc.decrypt(text, config.get("baseconf", "AESKey"))
  429. logger.info(businessNum + "#" + "uploadAudit upload_result:" + resultText)
  430. #上传解析json
  431. def uploadJsonFile(businessInfo,json_path):
  432. # ===================================
  433. try:
  434. fileName = os.path.basename(json_path)
  435. #上传文件逻辑
  436. logger.info(json_path+"#"+"准备上传文件")
  437. uploadApiUrl = config.get("baseconf", "uploadApiUrl");
  438. token = dbController.getToken();
  439. if token == "":#如果获取失败,重新获取
  440. token = dbController.getToken();
  441. uploadApiUrl = uploadApiUrl + "?access_token=" + token
  442. files = {'file': open(json_path, 'rb')}
  443. logger.info(fileName+"#"+"businessNum:"+businessInfo["businessNum"])
  444. data = {'docType': "23", 'businessNum': businessInfo["businessNum"]}
  445. response = requests.post(uploadApiUrl, files=files, data=data,timeout=15)
  446. text = response.text
  447. logger.info("上传结果:"+text)
  448. pboc = PBOC();
  449. resultText = pboc.decrypt(text,config.get("baseconf", "AESKey"))
  450. logger.info(fileName+"#"+"uploadJsonFile:" + resultText)
  451. except:
  452. logger.error("certificateNum="+businessInfo["coopBusinessNum"])
  453. info = sys.exc_info()
  454. logger.error(info[0])
  455. logger.error(info[1])
  456. # logging.log(logging.ERROR, info[2])
  457. logger.error(traceback.extract_tb(info[2], 1))
  458. mailUtil = MailUtil();
  459. webhook = 'https://oapi.dingtalk.com/robot/send?access_token=64d8b2c7fed4949e9433b807c7c5559939f1517af8f77c1dacb4de19c6910b56'
  460. mailUtil.dingtalk("号码:" + businessInfo["certificateNum"]+"-"+businessInfo["businessNum"] + " 上传文件失败 ", webhook)
  461. if __name__ == '__main__':
  462. file_name = ""
  463. basePath = "D:/mydocument/myproject/git/parse/"
  464. # basePath = "D:/mydocument/myprojects/creditreport/parse/"
  465. file_name = "黄振武_420115199306180091_230034699446131714.xml"
  466. file_name = "周平强_360122197901070610_255387334772537344.xml"
  467. file_name = "lwl_450803199507215834_254603000272664585.xml"
  468. # file_name="dqy_320821199205184730_255559091387119623.xml"
  469. file_name='zl_342425199204087911_255220233202055177.xml'
  470. file_name="sxg_330719197909242017_257564808331673603.xml"
  471. file_name="pxy_522401199510147022_258623031256039426.xml"
  472. file_name = "任赞_130185199601221319_257538384191307779.xml"
  473. file_name="hrh_430722198805068479_255677390955493378.xml"
  474. file_name="杨同山_340406197907213451_236806485030479874.xml"
  475. # file_name = "1_210303197510273014_269873665141647369-202012091702117200.xml"
  476. # file_name="任赞_130185199601221319_257538384191307779"
  477. file_name="艾红平_520202198707150427_384652376306363396-202110221031275368.xml"
  478. xml_path = basePath + file_name
  479. start = timeit.default_timer();
  480. if len(sys.argv) > 1:
  481. basePath = sys.argv[1]
  482. xml_path = basePath + sys.argv[2]
  483. file_name = sys.argv[2]
  484. logger.info(xml_path+" 解析开始")
  485. businessInfo = getBusinessInfo(xml_path)
  486. # logger.info(businessInfo)
  487. if businessInfo["isBaihu"]!="2":#白户不上传1211
  488. try:
  489. process(businessInfo,basePath,xml_path)
  490. except:
  491. logger.error(traceback.print_exc())
  492. logger.error(traceback.format_exc())
  493. s = timeit.default_timer() - start;
  494. logger.info(str(s) + " 秒")
  495. logger.info(xml_path+" 解析完成")
  496. # 执行sql开始
  497. logger.info(xml_path + " 执行sql解析开始")
  498. sqlMap = businessInfo["sqlMap"]
  499. # 执行sql完成
  500. # logger.info(sqlMap)
  501. try:
  502. start = timeit.default_timer();
  503. dbController.getConn()
  504. for sql in sqlMap:
  505. dbController.execSql(sql)
  506. dbController.commit()
  507. s = timeit.default_timer() - start;
  508. logger.info(xml_path+str(s) + " 秒")
  509. except:
  510. logger.error(traceback.print_exc())
  511. logger.error(traceback.format_exc())
  512. logger.info(xml_path + " 执行sql解析失败")
  513. logger.info(xml_path + " 执行sql解析完成")