service.py 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793
  1. import xml.etree.ElementTree as ET
  2. from typing import Union
  3. from fastapi import FastAPI
  4. import os
  5. import uuid
  6. import re
  7. from fastapi.middleware.cors import CORSMiddleware
  8. from pydantic import BaseModel
  9. import pandas as pd
  10. from numpy import float64
  11. def getDjcsDingercj(root, bh, bt, qdbm, debm):
  12. result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  13. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
  14. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  15. item = None
  16. for child in root:
  17. if child.tag == "Dxgcxx":
  18. for child1 in child:
  19. Dwgcbh = child1.attrib["Dwgcbh"]
  20. if Dwgcbh == bh:
  21. item = child1
  22. break
  23. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  24. Fywj = None
  25. for child in item:
  26. if child.tag == 'Csxm':
  27. Fywj= child
  28. break
  29. Rcjhz = None
  30. for child in item:
  31. if child.tag == 'Rcjhz':
  32. Rcjhz = child
  33. break
  34. kv = {}
  35. for entry in Rcjhz:
  36. kv[entry.attrib["RcjId"]]=entry
  37. container = None
  38. for child in Fywj:
  39. if child.tag == "DjCs":
  40. container = child
  41. break
  42. zimu = None
  43. for child in container:
  44. if child.attrib["Bm"] == qdbm:
  45. zimu = child
  46. break
  47. box = None
  48. if not zimu:
  49. return result
  50. for child in zimu:
  51. if child.tag == "Csxdezj":
  52. box = child
  53. break
  54. hlmx_parent = None
  55. for child in box:
  56. if child.attrib["Debm"] == debm:
  57. for grandchild in child:
  58. if grandchild.tag == "Csxdercjhl":
  59. hlmx_parent = grandchild
  60. for child in hlmx_parent:
  61. result.append([child.attrib["RcjId"],
  62. kv[child.attrib["RcjId"]].attrib["RcjBm"],
  63. kv[child.attrib["RcjId"]].attrib["Mc"],
  64. kv[child.attrib["RcjId"]].attrib["Ggxh"],
  65. kv[child.attrib["RcjId"]].attrib["Dw"],
  66. kv[child.attrib["RcjId"]].attrib["Dj"],
  67. kv[child.attrib["RcjId"]].attrib["Cd"],
  68. kv[child.attrib["RcjId"]].attrib["Gycs"],
  69. kv[child.attrib["RcjId"]].attrib["Rcjlb"],
  70. kv[child.attrib["RcjId"]].attrib["Jgbz"],
  71. child.attrib["Rcjhl"], child.attrib["Rcjhj"], "",
  72. "", "", ""
  73. ])
  74. return result
  75. def getDingercj(root, bh, bt, qdbm, debm):
  76. result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  77. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
  78. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  79. item = None
  80. for child in root:
  81. if child.tag == "Dxgcxx":
  82. for child1 in child:
  83. Dwgcbh = child1.attrib["Dwgcbh"]
  84. if Dwgcbh == bh:
  85. item = child1
  86. break
  87. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  88. Fywj = None
  89. for child in item:
  90. if child.tag == 'Qdxm':
  91. Fywj= child
  92. break
  93. Rcjhz = None
  94. for child in item:
  95. if child.tag == 'Rcjhz':
  96. Rcjhz = child
  97. break
  98. kv = {}
  99. for entry in Rcjhz:
  100. kv[entry.attrib["RcjId"]]=entry
  101. container = None
  102. for child in Fywj:
  103. ##child is mx
  104. if child.tag == "QdBt":
  105. if child.attrib["Mc"] == bt:
  106. container = child
  107. break
  108. if not container:
  109. container = Fywj
  110. zimu = None
  111. for child in container:
  112. if child.attrib["Qdbm"] == qdbm:
  113. zimu = child
  114. break
  115. box = None
  116. if not zimu:
  117. return result
  118. for child in zimu:
  119. if child.tag == "Qdxdezj":
  120. box = child
  121. break
  122. hlmx_parent = None
  123. for child in box:
  124. if child.attrib["Debm"] == debm:
  125. for grandchild in child:
  126. if grandchild.tag == "Qdxdercjhl":
  127. hlmx_parent = grandchild
  128. for child in hlmx_parent:
  129. result.append([child.attrib["RcjId"],
  130. kv[child.attrib["RcjId"]].attrib["RcjBm"],
  131. kv[child.attrib["RcjId"]].attrib["Mc"],
  132. kv[child.attrib["RcjId"]].attrib["Ggxh"],
  133. kv[child.attrib["RcjId"]].attrib["Dw"],
  134. kv[child.attrib["RcjId"]].attrib["Dj"],
  135. kv[child.attrib["RcjId"]].attrib["Cd"],
  136. kv[child.attrib["RcjId"]].attrib["Gycs"],
  137. kv[child.attrib["RcjId"]].attrib["Rcjlb"],
  138. kv[child.attrib["RcjId"]].attrib["Jgbz"],
  139. child.attrib["Rcjhl"], child.attrib["Rcjhj"], "",
  140. "", "", ""
  141. ])
  142. return result
  143. def getDjcsQingdanrcj(root, bh, bt, bm):
  144. result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  145. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
  146. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  147. item = None
  148. for child in root:
  149. if child.tag == "Dxgcxx":
  150. for child1 in child:
  151. Dwgcbh = child1.attrib["Dwgcbh"]
  152. if Dwgcbh == bh:
  153. item = child1
  154. break
  155. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  156. Fywj = None
  157. for child in item:
  158. if child.tag == 'Csxm':
  159. Fywj= child
  160. break
  161. hl_parent = None
  162. for child in Fywj:
  163. if child.tag == "DjCs":
  164. hl_parent = child
  165. Rcjhz = None
  166. for child in item:
  167. if child.tag == 'Rcjhz':
  168. Rcjhz = child
  169. break
  170. kv = {}
  171. for entry in Rcjhz:
  172. kv[entry.attrib["RcjId"]]=entry
  173. zimu = None
  174. for child in hl_parent:
  175. if child.attrib["Bm"] == bm:
  176. zimu = child
  177. break
  178. box = None
  179. if not zimu:
  180. return result
  181. for child in zimu:
  182. if child.tag == "Csxrcjhl":
  183. box = child
  184. break
  185. for child in box:
  186. result.append([child.attrib["RcjId"],
  187. kv[child.attrib["RcjId"]].attrib["RcjBm"],
  188. kv[child.attrib["RcjId"]].attrib["Mc"],
  189. kv[child.attrib["RcjId"]].attrib["Ggxh"],
  190. kv[child.attrib["RcjId"]].attrib["Dw"],
  191. kv[child.attrib["RcjId"]].attrib["Dj"],
  192. kv[child.attrib["RcjId"]].attrib["Cd"],
  193. kv[child.attrib["RcjId"]].attrib["Gycs"],
  194. kv[child.attrib["RcjId"]].attrib["Rcjlb"],
  195. kv[child.attrib["RcjId"]].attrib["Jgbz"],
  196. child.attrib["Rcjhl"], child.attrib["Rcjhj"], child.attrib["Zgjbz"],
  197. child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"]
  198. ])
  199. return result
  200. def getQingdanTuijian(bh, bt, bm):
  201. result = [["ID", "定额编号", "工程量名称", "工作内容" ]]
  202. try:
  203. all = pd.read_csv("QingDanAllInOne.csv")
  204. bm_ = int(bm) // 1000
  205. hit = all[all["qdbh"] == str(bm_)]
  206. for i in range(len(hit)):
  207. result.append([hit.iloc[i]["index"].item(), hit.iloc[i]["debh"], hit.iloc[i]["gclmc"], hit.iloc[i]["work"]])
  208. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  209. finally:
  210. return result
  211. def getQingdanrcj(root, bh, bt, bm):
  212. result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  213. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
  214. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  215. item = None
  216. for child in root:
  217. if child.tag == "Dxgcxx":
  218. for child1 in child:
  219. Dwgcbh = child1.attrib["Dwgcbh"]
  220. if Dwgcbh == bh:
  221. item = child1
  222. break
  223. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  224. Fywj = None
  225. for child in item:
  226. if child.tag == 'Qdxm':
  227. Fywj= child
  228. break
  229. Rcjhz = None
  230. for child in item:
  231. if child.tag == 'Rcjhz':
  232. Rcjhz = child
  233. break
  234. kv = {}
  235. for entry in Rcjhz:
  236. kv[entry.attrib["RcjId"]]=entry
  237. container = None
  238. for child in Fywj:
  239. ##child is mx
  240. if child.tag == "QdBt":
  241. if child.attrib["Mc"] == bt:
  242. container = child
  243. break
  244. if not container:
  245. container = Fywj
  246. zimu = None
  247. for child in container:
  248. if child.attrib["Qdbm"] == bm:
  249. zimu = child
  250. break
  251. box = None
  252. if not zimu:
  253. return result
  254. for child in zimu:
  255. if child.tag == "Qdxrcjhl":
  256. box = child
  257. break
  258. for child in box:
  259. result.append([child.attrib["RcjId"],
  260. kv[child.attrib["RcjId"]].attrib["RcjBm"],
  261. kv[child.attrib["RcjId"]].attrib["Mc"],
  262. kv[child.attrib["RcjId"]].attrib["Ggxh"],
  263. kv[child.attrib["RcjId"]].attrib["Dw"],
  264. kv[child.attrib["RcjId"]].attrib["Dj"],
  265. kv[child.attrib["RcjId"]].attrib["Cd"],
  266. kv[child.attrib["RcjId"]].attrib["Gycs"],
  267. kv[child.attrib["RcjId"]].attrib["Rcjlb"],
  268. kv[child.attrib["RcjId"]].attrib["Jgbz"],
  269. child.attrib["Rcjhl"], child.attrib["Rcjhj"], child.attrib["Zgjbz"],
  270. child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"]
  271. ])
  272. return result
  273. def getDjcs(root, id):
  274. result = []
  275. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  276. item = None
  277. for child in root:
  278. if child.tag == "Dxgcxx":
  279. for child1 in child:
  280. Dwgcbh = child1.attrib["Dwgcbh"]
  281. if Dwgcbh == id:
  282. item = child1
  283. break
  284. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  285. Fywj = None
  286. for child in item:
  287. if child.tag == 'Csxm':
  288. Fywj= child
  289. break
  290. Djcs_parent = None
  291. for child in Fywj:
  292. if child.tag == 'DjCs':
  293. Djcs_parent = child
  294. break
  295. for child in Djcs_parent:
  296. ##child is mx {
  297. result.append({
  298. "序号": child.attrib["Xh"], "清单编码": child.attrib["Bm"], "名称" : child.attrib["Mc"],
  299. "项目特征" : child.attrib["Xmtz"],
  300. "计算规则" : child.attrib["Jsgz"], "单位" : child.attrib["Dw"], "数量" : child.attrib["Sl"],
  301. "综合单价" : child.attrib["Zhdj"], "合价" : child.attrib["Zhhj"], "人工费" : child.attrib["Rgf"],
  302. "主材费" : child.attrib["Zcf"],
  303. "设备费" : child.attrib["Sbf"], "辅材费" : child.attrib["Fcf"], "材料费" : child.attrib["Clf"],
  304. "机械费" : child.attrib["Jxf"], "管理费" : child.attrib["Glf"], "利润" : child.attrib["Lr"],
  305. "暂估价" : child.attrib["Zgj"], "综合人工工日" : child.attrib["Zgr"] })
  306. __children = []
  307. zj_parent = None
  308. for grandchild in child:
  309. if grandchild.tag == "Csxdezj":
  310. zj_parent = grandchild
  311. if zj_parent:
  312. for entry in zj_parent:
  313. __children.append({
  314. "序号": None, "清单编码": entry.attrib["Debm"], "名称" : entry.attrib["Mc"],
  315. "项目特征" : None,
  316. "计算规则" : None, "单位" : entry.attrib["Dw"], "数量" : entry.attrib["DwQdSl"],
  317. "综合单价" : entry.attrib["Dj"], "合价" : entry.attrib["Hj"], "人工费" : entry.attrib["Rgf"],
  318. "主材费" : entry.attrib["Zcf"],
  319. "设备费" : entry.attrib["Sbf"], "辅材费" : entry.attrib["Fcf"], "材料费" : entry.attrib["Clf"],
  320. "机械费" : entry.attrib["Jxf"], "管理费" : entry.attrib["Glf"], "利润" : entry.attrib["Lr"],
  321. "暂估价" : None, "综合人工工日" : None })
  322. if len(__children) > 0:
  323. result[-1]["__children"] = __children
  324. return result
  325. def getQdmx(root, bh, bt):
  326. result = []
  327. #result = [["序号", "清单编码", "名称", "项目特征", "计算规则", "单位", "数量", "综合单价", "合价", "人工费", "主材费", "设备费", "辅材费", "材料费", "机械费", "管理费", "利润" , "暂估价", "综合人工工日", "备注" ]]
  328. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  329. item = None
  330. for child in root:
  331. if child.tag == "Dxgcxx":
  332. for child1 in child:
  333. Dwgcbh = child1.attrib["Dwgcbh"]
  334. if Dwgcbh == bh:
  335. item = child1
  336. break
  337. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  338. Fywj = None
  339. for child in item:
  340. if child.tag == 'Qdxm':
  341. Fywj= child
  342. break
  343. container = None
  344. for child in Fywj:
  345. ##child is mx
  346. print(child.attrib["Mc"])
  347. if child.tag == "QdBt":
  348. if child.attrib["Mc"] == bt:
  349. container = child
  350. break
  351. if not container:
  352. container = Fywj
  353. for child in container:
  354. print(child)
  355. #result = [["序号", "清单编码", "名称", "项目特征", "计算规则", "单位", "数量", "综合单价", "合价", "人工费", "主材费",
  356. # "设备费", "辅材费", "材料费", "机械费", "管理费", "利润" , "暂估价", "综合人工工日", "备注" ]]
  357. result.append({
  358. "操作" : "",
  359. "序号": child.attrib["Xh"], "清单编码" : child.attrib["Qdbm"], "名称" : child.attrib["Mc"],"项目特征" : child.attrib["Xmtz"],
  360. "计算规则" : child.attrib["Jsgz"],
  361. "单位" : child.attrib["Dw"],
  362. "数量": child.attrib["Sl"],
  363. "综合单价" : child.attrib["Zhdj"],
  364. "合价" : child.attrib["Zhhj"],
  365. "人工费": child.attrib["Rgf"],
  366. "主材费" : child.attrib["Zcf"],
  367. "设备费": child.attrib["Sbf"],
  368. "辅材费": child.attrib["Fcf"],
  369. "材料费" : child.attrib["Clf"],
  370. "机械费" : child.attrib["Jxf"],
  371. "管理费": child.attrib["Glf"],
  372. "利润": child.attrib["Lr"],
  373. "暂估价" : child.attrib["Zgj"],
  374. "综合人工工日" : child.attrib["Zgr"],
  375. "备注" : child.attrib["Bz"]}
  376. )
  377. for child_zj in child:
  378. if child_zj.tag == "Qdxdezj":
  379. for child_mx in child_zj:
  380. if child_mx.tag == "QdxdezjMx":
  381. parent = result[-1]
  382. if "__children" in parent:
  383. parent["__children"].append({
  384. "操作" : "",
  385. "序号": None, "清单编码" : child_mx.attrib["Debm"], "名称" : child_mx.attrib["Mc"],"项目特征" : None,
  386. "计算规则" : None,
  387. "单位" : child_mx.attrib["Dw"],
  388. "数量": child_mx.attrib["DwQdSl"],
  389. "综合单价" : child_mx.attrib["Dj"],
  390. "合价" : child_mx.attrib["Hj"],
  391. "人工费": child_mx.attrib["Rgf"],
  392. "主材费" : child_mx.attrib["Zcf"],
  393. "设备费": child_mx.attrib["Sbf"],
  394. "辅材费": child_mx.attrib["Fcf"],
  395. "材料费" : child_mx.attrib["Clf"],
  396. "机械费" : child_mx.attrib["Jxf"],
  397. "管理费": child_mx.attrib["Glf"],
  398. "利润": child_mx.attrib["Lr"],
  399. "暂估价" : None,
  400. "综合人工工日" : None,
  401. "备注" : None}
  402. )
  403. else:
  404. parent["__children"] = [{
  405. "操作" : "",
  406. "序号": None, "清单编码" : child_mx.attrib["Debm"], "名称" : child_mx.attrib["Mc"],"项目特征" : None,
  407. "计算规则" : None,
  408. "单位" : child_mx.attrib["Dw"],
  409. "数量": child_mx.attrib["DwQdSl"],
  410. "综合单价" : child_mx.attrib["Dj"],
  411. "合价" : child_mx.attrib["Hj"],
  412. "人工费": child_mx.attrib["Rgf"],
  413. "主材费" : child_mx.attrib["Zcf"],
  414. "设备费": child_mx.attrib["Sbf"],
  415. "辅材费": child_mx.attrib["Fcf"],
  416. "材料费" : child_mx.attrib["Clf"],
  417. "机械费" : child_mx.attrib["Jxf"],
  418. "管理费": child_mx.attrib["Glf"],
  419. "利润": child_mx.attrib["Lr"],
  420. "暂估价" : None,
  421. "综合人工工日" : None,
  422. "备注" : None}]
  423. return result
  424. def getQdxm(root, id):
  425. result = []
  426. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  427. item = None
  428. for child in root:
  429. if child.tag == "Dxgcxx":
  430. for child1 in child:
  431. Dwgcbh = child1.attrib["Dwgcbh"]
  432. if Dwgcbh == id:
  433. item = child1
  434. break
  435. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  436. Fywj = None
  437. for child in item:
  438. if child.tag == 'Qdxm':
  439. Fywj= child
  440. break
  441. for child in Fywj:
  442. ##child is mx
  443. if child.tag == "QdBt":
  444. result.append(child.attrib["Mc"])
  445. if len(result) == 0:
  446. result.append("Default")
  447. return result
  448. def getZjcs(root, id):
  449. result = []
  450. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  451. item = None
  452. for child in root:
  453. if child.tag == "Dxgcxx":
  454. for child1 in child:
  455. Dwgcbh = child1.attrib["Dwgcbh"]
  456. if Dwgcbh == id:
  457. item = child1
  458. break
  459. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  460. Fywj = None
  461. for child in item:
  462. if child.tag == 'Csxm':
  463. Fywj= child
  464. break
  465. Zjcs_parent = None
  466. for child in Fywj:
  467. if child.tag == 'ZjCs':
  468. Zjcs_parent = child
  469. break
  470. for child in Zjcs_parent:
  471. ##child is mx {
  472. result.append({
  473. "序号" : child.attrib["Xh"], "清单编码": child.attrib["Bm"], "名称" : child.attrib["Mc"],
  474. "计算基数" : child.attrib["Js"],
  475. "计算基础" : child.attrib["Jsjc"], "费率" : child.attrib["Fl"],
  476. "金额" : child.attrib["Je"], "项目类别" : child.attrib["Xmlb"]})
  477. __children = []
  478. for grandchild in child:
  479. __children.append({
  480. "序号" : None, "清单编码": None, "名称" : grandchild.attrib["Mc"],
  481. "计算基数" : grandchild.attrib["Js"],
  482. "计算基础" : grandchild.attrib["Jsjc"], "费率" : grandchild.attrib["Fl"],
  483. "金额" : grandchild.attrib["Je"], "项目类别" : grandchild.attrib["Xmlb"]})
  484. if len(__children) > 0:
  485. result[-1]["__children"] = __children
  486. return result
  487. def getZcbfwf(root, id):
  488. result = [["序号", "名称", "项目价值", "服务内容", "计算基础", "费率", "金额"]]
  489. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  490. item = None
  491. for child in root:
  492. if child.tag == "Dxgcxx":
  493. for child1 in child:
  494. Dwgcbh = child1.attrib["Dwgcbh"]
  495. if Dwgcbh == id:
  496. item = child1
  497. break
  498. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  499. Fywj = None
  500. for child in item:
  501. if child.tag == 'Zcbfwf':
  502. Fywj= child
  503. break
  504. for child in Fywj:
  505. result.append(
  506. [child.attrib["Xh"],
  507. child.attrib["Mc"], child.attrib["Xmjz"], child.attrib["Fwnr"], child.attrib["Jsjc"],
  508. child.attrib["Fl"], child.attrib["Je"]]
  509. )
  510. return result
  511. def getRcjhz(root, id):
  512. result = [[ "ID", "编码", "名称", "规格型号", "单位", "数量", "单价", "合价", "产地",
  513. "供应厂商", "人材机类别", "主要材料标志", "主材标志", "设备标志", "甲供标志", "暂估价标志"]]
  514. for child in root:
  515. if child.tag == "Dxgcxx":
  516. for child1 in child:
  517. Dwgcbh = child1.attrib["Dwgcbh"]
  518. if Dwgcbh == id:
  519. item = child1
  520. break
  521. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  522. Fywj = None
  523. for child in item:
  524. if child.tag == 'Rcjhz':
  525. Fywj= child
  526. break
  527. for child in Fywj:
  528. result.append(
  529. [
  530. child.attrib["RcjId"], child.attrib["RcjBm"], child.attrib["Mc"], child.attrib["Ggxh"],
  531. child.attrib["Dw"], child.attrib["Sl"], child.attrib["Dj"], child.attrib["Hj"],
  532. child.attrib["Cd"], child.attrib["Gycs"], child.attrib["Rcjlb"],
  533. child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"], child.attrib["Jgbz"],
  534. child.attrib["Zgjbz"]]
  535. )
  536. return result
  537. def getFbrgycl(root, id):
  538. result = [["序号", "ID", "材料编号", "名称", "规格型号", "单位", "数量", "单价", "合价", "交货方式", "送达地点", "备注"]]
  539. for child in root:
  540. if child.tag == "Dxgcxx":
  541. for child1 in child:
  542. Dwgcbh = child1.attrib["Dwgcbh"]
  543. if Dwgcbh == id:
  544. item = child1
  545. break
  546. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  547. Fywj = None
  548. for child in item:
  549. if child.tag == 'Fbrgycl':
  550. Fywj= child
  551. break
  552. for child in Fywj:
  553. result.append(
  554. [child.attrib["Xh"],
  555. child.attrib["RcjId"], child.attrib["Clbh"], child.attrib["Mc"], child.attrib["Ggxh"],
  556. child.attrib["Dw"], child.attrib["Sl"], child.attrib["Dj"], child.attrib["Hj"], child.attrib["Jhfs"],
  557. child.attrib["Sddd"], child.attrib["Bz"]]
  558. )
  559. return result
  560. def getJrg(root, id):
  561. result = [["序号", "名称", "金额", "类别"]]
  562. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  563. item = None
  564. for child in root:
  565. if child.tag == "Dxgcxx":
  566. for child1 in child:
  567. Dwgcbh = child1.attrib["Dwgcbh"]
  568. if Dwgcbh == id:
  569. item = child1
  570. break
  571. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  572. Fywj = None
  573. for child in item:
  574. if child.tag == 'Jrg':
  575. Fywj= child
  576. break
  577. for child in Fywj:
  578. result.append(
  579. [child.attrib["Xh"],
  580. child.attrib["Mc"], child.attrib["Je"], child.attrib["Lb"]]
  581. )
  582. return result
  583. def getZlje(root, id):
  584. result = [["序号", "名称", "单位", "暂定金额", "备注"]]
  585. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  586. item = None
  587. for child in root:
  588. if child.tag == "Dxgcxx":
  589. for child1 in child:
  590. Dwgcbh = child1.attrib["Dwgcbh"]
  591. if Dwgcbh == id:
  592. item = child1
  593. break
  594. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  595. Fywj = None
  596. for child in item:
  597. if child.tag == 'Zlje':
  598. Fywj= child
  599. break
  600. for child in Fywj:
  601. result.append(
  602. [child.attrib["Xh"],
  603. child.attrib["Mc"], child.attrib["Dw"], child.attrib["Zdje"], child.attrib["Bz"]]
  604. )
  605. return result
  606. def getQtxm(root, id):
  607. result = []
  608. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  609. item = None
  610. for child in root:
  611. if child.tag == "Dxgcxx":
  612. for child1 in child:
  613. Dwgcbh = child1.attrib["Dwgcbh"]
  614. if Dwgcbh == id:
  615. item = child1
  616. break
  617. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  618. Fywj = None
  619. for child in item:
  620. if child.tag == 'Qtxm':
  621. Fywj= child
  622. break
  623. for child in Fywj:
  624. ##child is mx
  625. xh = child.attrib["Xh"]
  626. if "." in xh:
  627. count = 0
  628. for entry in xh:
  629. if entry == ".":
  630. count = count + 1
  631. if count == 1:
  632. parent = result[-1]
  633. if "__children" in parent:
  634. children = parent["__children"]
  635. children.append(
  636. {"序号":xh, "名称": child.attrib["Mc"],
  637. "金额": child.attrib["Je"], "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}
  638. )
  639. else:
  640. parent["__children"] = [
  641. {"序号":xh, "名称": child.attrib["Mc"],
  642. "金额": child.attrib["Je"], "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}]
  643. else:
  644. result.append(
  645. {"序号":xh, "名称": child.attrib["Mc"],
  646. "金额": child.attrib["Je"], "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}
  647. )
  648. return result
  649. def getGfsj(root, id):
  650. result = []
  651. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  652. item = None
  653. for child in root:
  654. if child.tag == "Dxgcxx":
  655. for child1 in child:
  656. Dwgcbh = child1.attrib["Dwgcbh"]
  657. if Dwgcbh == id:
  658. item = child1
  659. break
  660. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  661. Fywj = None
  662. for child in item:
  663. if child.tag == 'Gfsj':
  664. Fywj= child
  665. break
  666. for child in Fywj:
  667. ##child is mx
  668. xh = child.attrib["Xh"]
  669. if "." in xh:
  670. count = 0
  671. for entry in xh:
  672. if entry == ".":
  673. count = count + 1
  674. if count == 1:
  675. parent = result[-1]
  676. if "__children" in parent:
  677. children = parent["__children"]
  678. children.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]})
  679. else:
  680. parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]}]
  681. elif count == 2:
  682. parent = result[-1]
  683. if "__children" in parent:
  684. parent = parent["__children"][-1]
  685. print(parent)
  686. if "__children" in parent:
  687. children = parent["__children"]
  688. children.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]})
  689. else:
  690. parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]}]
  691. else:
  692. ###["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  693. result.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]})
  694. return result
  695. def getBjhz(root, id):
  696. print(root)
  697. print(id)
  698. result = []
  699. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  700. item = None
  701. for child in root:
  702. if child.tag == "Dxgcxx":
  703. for child1 in child:
  704. Dwgcbh = child1.attrib["Dwgcbh"]
  705. if Dwgcbh == id:
  706. item = child1
  707. break
  708. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  709. print(item)
  710. Fywj = None
  711. for child in item:
  712. if child.tag == 'Fywj':
  713. Fywj= child
  714. break
  715. for child in Fywj:
  716. ##child is mx
  717. xh = child.attrib["Xh"]
  718. if "." in xh:
  719. count = 0
  720. for entry in xh:
  721. if entry == ".":
  722. count = count + 1
  723. if count == 1:
  724. parent = result[-1]
  725. if "__children" in parent:
  726. children = parent["__children"]
  727. children.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})
  728. else:
  729. parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]}]
  730. elif count == 2:
  731. parent = result[-1]
  732. if "__children" in parent:
  733. parent = parent["__children"][-1]
  734. print(parent)
  735. if "__children" in parent:
  736. children = parent["__children"]
  737. children.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})
  738. else:
  739. parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]}]
  740. else:
  741. ###"序号", "名称", "金额", "暂估价", "类别"]
  742. result.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"],
  743. "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})
  744. return result
  745. def processDes(dataframe, from_, end, level):
  746. result = []
  747. for i in range(from_, end):
  748. item = dataframe.iloc[i]
  749. fbcch = str(item['fbcch'])
  750. if fbcch == str(level):
  751. entry = {"id": str(item["ID"]), "label": str(item["zjbt"])}
  752. next = i + 1
  753. while next < end and str(dataframe.iloc[next]["fbcch"]) != str(level):
  754. next = next + 1
  755. entry["children"] = processDes(dataframe, i + 1, next, level + 1)
  756. result.append(entry)
  757. return result
  758. def processPbs(dataframe, from_, end, level):
  759. result = []
  760. for i in range(from_, end):
  761. item = dataframe.iloc[i]
  762. fbcch = str(item['fbcch'])
  763. if fbcch == str(level):
  764. entry = {"id": str(item["ID"]), "label": str(item["flmc"]), "data": item["pblbh"]}
  765. next = i + 1
  766. while next < end and str(dataframe.iloc[next]["fbcch"]) != str(level):
  767. next = next + 1
  768. entry["children"] = processPbs(dataframe, i + 1, next, level + 1)
  769. result.append(entry)
  770. return result
  771. def getDes(value):
  772. if value == 10:
  773. shu = pd.read_csv("de/tj/JD_DingEShu.csv")
  774. elif value == 20:
  775. shu = pd.read_csv("de/sz/JD_DingEShu.csv")
  776. elif value == 30:
  777. shu = pd.read_csv("de/az/JD_DingEShu.csv")
  778. elif value == 40:
  779. shu = pd.read_csv("de/yl/JD_DingEShu.csv")
  780. elif value == 50:
  781. shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
  782. else:
  783. shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
  784. length = len(shu)
  785. return processDes(shu, 1, length, 2)
  786. def getPbs(value):
  787. if value == 10:
  788. shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
  789. else:
  790. shu = pd.read_csv("de/sz/JD_PeiBiFLB.csv")
  791. length = len(shu)
  792. return processPbs(shu, 0, length, 1)
  793. def getDeXilie(value, id):
  794. print(type(id))
  795. if value == 10:
  796. shu = pd.read_csv("de/tj/JD_DingEShu.csv")
  797. elif value == 20:
  798. shu = pd.read_csv("de/sz/JD_DingEShu.csv")
  799. elif value == 30:
  800. shu = pd.read_csv("de/az/JD_DingEShu.csv")
  801. elif value == 40:
  802. shu = pd.read_csv("de/yl/JD_DingEShu.csv")
  803. elif value == 50:
  804. shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
  805. else:
  806. shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
  807. hit = shu[shu["ID"]==int(id)]
  808. print(hit)
  809. if len(hit) == 0:
  810. return []
  811. hit0 = hit.iloc[0]
  812. index = str(hit0['zjh'])
  813. print("index=" + index)
  814. if value == 10:
  815. gj = pd.read_csv("de/tj/JD_DanWeiGJ.csv")
  816. filtered = gj[gj["YSDELBH"]==int(index)]
  817. elif value == 20:
  818. gj = pd.read_csv("de/sz/JD_DanWeiGJ.csv")
  819. filtered = gj[gj["YSDELBH"]==(index)]
  820. elif value == 30:
  821. gj = pd.read_csv("de/az/JD_DanWeiGJ.csv")
  822. filtered = gj[gj["YSDELBH"]==(index)]
  823. elif value == 40:
  824. gj = pd.read_csv("de/yl/JD_DanWeiGJ.csv")
  825. filtered = gj[gj["YSDELBH"]==int(index)]
  826. elif value == 50:
  827. gj = pd.read_csv("de/xstj/JD_DanWeiGJ.csv")
  828. filtered = gj[gj["YSDELBH"]==int(index)]
  829. else:
  830. gj = pd.read_csv("de/xsaz/JD_DanWeiGJ.csv")
  831. filtered = gj[gj["YSDELBH"]==int(index)]
  832. return filtered.to_json(force_ascii=False)
  833. def getQufei(name):
  834. if name == "0":
  835. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  836. return gj.to_json(force_ascii=False)
  837. shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
  838. hit = shu[shu["ID"]==int(name)]
  839. print(hit)
  840. if len(hit) == 0:
  841. return []
  842. hit0 = hit.iloc[0]
  843. index = str(hit0['pblbh'])
  844. index_list = index.split(";")
  845. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  846. filtered = gj[gj["PBBH"].str.startswith(tuple(index_list))]
  847. return filtered.to_json(force_ascii=False)
  848. def getPbxl(name):
  849. if name == "0":
  850. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  851. return gj.to_json(force_ascii=False)
  852. shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
  853. hit = shu[shu["ID"]==int(name)]
  854. print(hit)
  855. if len(hit) == 0:
  856. return []
  857. hit0 = hit.iloc[0]
  858. index = str(hit0['pblbh'])
  859. index_list = index.split(";")
  860. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  861. filtered = gj[gj["PBBH"].str.startswith(tuple(index_list))]
  862. return filtered.to_json(force_ascii=False)
  863. def getSingleDeXilie(zhuanye, debh):
  864. if zhuanye == 10:
  865. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  866. if A1:
  867. return A1, A2, A3, A4, A5, A6, A7, 10
  868. else:
  869. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_sz(debh)
  870. return A1, A2, A3, A4,A5, A6, A7, 20
  871. elif zhuanye == 20:##shizheng
  872. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_sz(debh)
  873. if A1:
  874. return A1, A2, A3, A4, A5, A6, A7, 20
  875. else:
  876. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  877. if A1:
  878. return A1, A2, A3, A4, A5, A6, A7, 10
  879. else:
  880. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  881. return A1, A2, A3, A4, A5, A6, A7, 30
  882. elif zhuanye == 30:##anzhuang
  883. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  884. return A1, A2, A3, A4, A5, A6, A7, 30
  885. elif zhuanye == 40:##yuanlin
  886. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_yl(debh)
  887. return A1, A2, A3, A4, A5, A6, A7, 40
  888. elif zhuanye == 50: ## xiushan tujian
  889. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_xstj(debh)
  890. if A1:
  891. return A1, A2, A3, A4, A5, A6, A7, 50
  892. else:
  893. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  894. return A1, A2, A3, A4,A5, A6, A7, 10
  895. else:
  896. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_xsaz(debh)
  897. if A1:
  898. return A1, A2, A3, A4, A5, A6, A7, 60
  899. else:
  900. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  901. return A1, A2, A3, A4,A5, A6, A7, 30
  902. def getSingleDeXilie_xsaz(debh):
  903. id = None
  904. bz_selected = []
  905. bz_selected2 = []
  906. if "附注" in debh:
  907. position = debh.find("附注")
  908. debh = debh[:position]
  909. if "*" in debh:
  910. position = debh.find("*")
  911. debh = debh[:position]
  912. if debh.endswith("换"):
  913. debh = debh[:-1]
  914. if "[" in debh:
  915. position = debh.find("[")
  916. debh = debh[:position-1]
  917. gj = pd.read_csv("de/xsaz/JD_DanWeiGJ.csv")
  918. filtered = gj[gj["DEBH"]==debh]
  919. print(filtered)
  920. if len(filtered) > 0:
  921. index = (filtered.iloc[0]["YSDELBH"])
  922. shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
  923. hit = shu[shu["zjh"]==index]
  924. if len(hit) > 0:
  925. id = hit.iloc[0]["ID"]
  926. beizhu = str(filtered.iloc[0]["BZBH"])
  927. if 'nan' in beizhu:
  928. pass
  929. else:
  930. beizhus = beizhu.split(";")
  931. print(beizhus)
  932. bzfile = pd.read_csv("de/xsaz/JD_BeiZhuZK.csv")
  933. bzfile2 = pd.read_csv("de/xsaz/JD_BeiZhuFK.csv", dtype=str)
  934. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  935. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  936. else:
  937. return None, None, None, None, None, None, None
  938. ####rengong
  939. rgde = []
  940. rg = pd.read_csv("de/xsaz/JD_GuJiaRG.csv")
  941. filtered1 = rg[rg["DEBH"]==debh]
  942. for i in range(len(filtered1)):
  943. rgde_ = {}
  944. gr = filtered1.iloc[i]["RGR"]##gongri
  945. gf = filtered1.iloc[i]["RGF"]##gongfei
  946. rcjID = filtered1.iloc[i]["RcjID"]
  947. detail = pd.read_csv("de/xsaz/JD_CaiLiaoK.csv")
  948. filtered2 = detail[detail["RcjID"]==rcjID]
  949. if len(filtered2) > 0:
  950. CLBH = filtered2.iloc[0]["CLBH"]
  951. CLMC = filtered2.iloc[0]["CLMC"]
  952. JLDW = filtered2.iloc[0]["JLDW"]
  953. YSJG = filtered2.iloc[0]["YSJG"]
  954. rgde_["CLBH"] = CLBH
  955. rgde_["CLMC"] = CLMC
  956. rgde_["JLDW"] = JLDW
  957. rgde_["YSJG"] = YSJG.item()
  958. rgde_["gr"] = gr.item()
  959. rgde_["gf"] = gf.item()
  960. rgde.append(rgde_)
  961. ##print(rgde)
  962. ####jixie
  963. jxde = []
  964. jx = pd.read_csv("de/xsaz/JD_GuJiaJX.csv")
  965. filtered1 = jx[jx["DEBH"]==debh]
  966. for i in range(len(filtered1)):
  967. jxde_ = {}
  968. sl = filtered1.iloc[i]["SL"]##shuliang
  969. hj = filtered1.iloc[i]["HJ"]##hejia
  970. rcjID = filtered1.iloc[i]["RcjID"]
  971. detail = pd.read_csv("de/xsaz/JD_JiXieK.csv")
  972. filtered2 = detail[detail["RcjID"]==rcjID]
  973. if len(filtered2) > 0:
  974. jxbh = filtered2.iloc[0]["jxbh"]
  975. jxmc = filtered2.iloc[0]["jxmc"]
  976. DW = filtered2.iloc[0]["DW"]
  977. tbdj = filtered2.iloc[0]["tbdj"]
  978. jxde_["jxbh"] = jxbh
  979. jxde_["jxmc"] = jxmc
  980. jxde_["DW"] = DW
  981. jxde_["tbdj"] = tbdj.item()
  982. jxde_["sl"] = sl.item()
  983. jxde_["hj"] = hj.item()
  984. jxde.append(jxde_)
  985. ####cailiao
  986. clde = []
  987. cl = pd.read_csv("de/xsaz/JD_GuJiaCL.csv")
  988. filtered1 = cl[cl["DEBH"]==debh]
  989. for i in range(len(filtered1)):
  990. clde_ = {}
  991. SL = filtered1.iloc[i]["SL"]##shuliang
  992. HJ = filtered1.iloc[i]["HJ"]##hejia
  993. rcjID = filtered1.iloc[i]["RcjID"]
  994. detail = pd.read_csv("de/xsaz/JD_CaiLiaoK.csv")
  995. filtered2 = detail[detail["RcjID"]==rcjID]
  996. if len(filtered2) > 0:
  997. CLBH = filtered2.iloc[0]["CLBH"]
  998. CLMC = filtered2.iloc[0]["CLMC"]
  999. JLDW = filtered2.iloc[0]["JLDW"]
  1000. YSJG = filtered2.iloc[0]["YSJG"]
  1001. clde_["CLBH"] = CLBH
  1002. clde_["CLMC"] = CLMC
  1003. clde_["JLDW"] = JLDW
  1004. clde_["YSJG"] = YSJG.item()
  1005. clde_["SL"] = SL.item()
  1006. clde_["HJ"] = HJ.item()
  1007. clde.append(clde_)
  1008. else:
  1009. detail = pd.read_csv("de/xsaz/JD_PeiBi.csv")
  1010. filtered2 = detail[detail["RcjID"]==rcjID]
  1011. if len(filtered2) > 0:
  1012. CLBH = filtered2.iloc[0]["PBBH"]
  1013. CLMC = filtered2.iloc[0]["PBMC"]
  1014. JLDW = filtered2.iloc[0]["DW"]
  1015. YSJG = filtered2.iloc[0]["PBDJ"]
  1016. clde_["CLBH"] = CLBH.item()
  1017. clde_["CLMC"] = CLMC
  1018. clde_["JLDW"] = JLDW
  1019. clde_["YSJG"] = YSJG.item()
  1020. clde_["SL"] = SL.item()
  1021. clde_["HJ"] = HJ.item()
  1022. clde.append(clde_)
  1023. return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
  1024. def getSingleDeXilie_xstj(debh):
  1025. id = None
  1026. bz_selected = []
  1027. bz_selected2 = []
  1028. if "附注" in debh:
  1029. position = debh.find("附注")
  1030. debh = debh[:position]
  1031. if "*" in debh:
  1032. position = debh.find("*")
  1033. debh = debh[:position]
  1034. if debh.endswith("换"):
  1035. debh = debh[:-1]
  1036. if "[" in debh:
  1037. position = debh.find("[")
  1038. debh = debh[:position-1]
  1039. gj = pd.read_csv("de/xstj/JD_DanWeiGJ.csv")
  1040. filtered = gj[gj["DEBH"]==debh]
  1041. print(filtered)
  1042. if len(filtered) > 0:
  1043. index = (filtered.iloc[0]["YSDELBH"])
  1044. shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
  1045. hit = shu[shu["zjh"]==index]
  1046. if len(hit) > 0:
  1047. id = hit.iloc[0]["ID"]
  1048. beizhu = str(filtered.iloc[0]["BZBH"])
  1049. if 'nan' in beizhu:
  1050. pass
  1051. else:
  1052. beizhus = beizhu.split(";")
  1053. print(beizhus)
  1054. bzfile = pd.read_csv("de/xstj/JD_BeiZhuZK.csv")
  1055. bzfile2 = pd.read_csv("de/xstj/JD_BeiZhuFK.csv", dtype=str)
  1056. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1057. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1058. else:
  1059. return None, None, None, None, None, None, None
  1060. ####rengong
  1061. rgde = []
  1062. rg = pd.read_csv("de/xstj/JD_GuJiaRG.csv")
  1063. filtered1 = rg[rg["DEBH"]==debh]
  1064. for i in range(len(filtered1)):
  1065. rgde_ = {}
  1066. gr = filtered1.iloc[i]["RGR"]##gongri
  1067. gf = filtered1.iloc[i]["RGF"]##gongfei
  1068. rcjID = filtered1.iloc[i]["RcjID"]
  1069. detail = pd.read_csv("de/xstj/JD_CaiLiaoK.csv")
  1070. filtered2 = detail[detail["RcjID"]==rcjID]
  1071. if len(filtered2) > 0:
  1072. CLBH = filtered2.iloc[0]["CLBH"]
  1073. CLMC = filtered2.iloc[0]["CLMC"]
  1074. JLDW = filtered2.iloc[0]["JLDW"]
  1075. YSJG = filtered2.iloc[0]["YSJG"]
  1076. rgde_["CLBH"] = CLBH
  1077. rgde_["CLMC"] = CLMC
  1078. rgde_["JLDW"] = JLDW
  1079. rgde_["YSJG"] = YSJG.item()
  1080. rgde_["gr"] = gr.item()
  1081. rgde_["gf"] = gf.item()
  1082. rgde.append(rgde_)
  1083. ##print(rgde)
  1084. ####jixie
  1085. jxde = []
  1086. jx = pd.read_csv("de/xstj/JD_GuJiaJX.csv")
  1087. filtered1 = jx[jx["DEBH"]==debh]
  1088. for i in range(len(filtered1)):
  1089. jxde_ = {}
  1090. sl = filtered1.iloc[i]["SL"]##shuliang
  1091. hj = filtered1.iloc[i]["HJ"]##hejia
  1092. rcjID = filtered1.iloc[i]["RcjID"]
  1093. detail = pd.read_csv("de/xstj/JD_JiXieK.csv")
  1094. filtered2 = detail[detail["RcjID"]==rcjID]
  1095. if len(filtered2) > 0:
  1096. jxbh = filtered2.iloc[0]["jxbh"]
  1097. jxmc = filtered2.iloc[0]["jxmc"]
  1098. DW = filtered2.iloc[0]["DW"]
  1099. tbdj = filtered2.iloc[0]["tbdj"]
  1100. jxde_["jxbh"] = jxbh
  1101. jxde_["jxmc"] = jxmc
  1102. jxde_["DW"] = DW
  1103. jxde_["tbdj"] = tbdj.item()
  1104. jxde_["sl"] = sl.item()
  1105. jxde_["hj"] = hj.item()
  1106. jxde.append(jxde_)
  1107. ####cailiao
  1108. clde = []
  1109. cl = pd.read_csv("de/xstj/JD_GuJiaCL.csv")
  1110. filtered1 = cl[cl["DEBH"]==debh]
  1111. for i in range(len(filtered1)):
  1112. clde_ = {}
  1113. SL = filtered1.iloc[i]["SL"]##shuliang
  1114. HJ = filtered1.iloc[i]["HJ"]##hejia
  1115. rcjID = filtered1.iloc[i]["RcjID"]
  1116. detail = pd.read_csv("de/xstj/JD_CaiLiaoK.csv")
  1117. filtered2 = detail[detail["RcjID"]==rcjID]
  1118. if len(filtered2) > 0:
  1119. CLBH = filtered2.iloc[0]["CLBH"]
  1120. CLMC = filtered2.iloc[0]["CLMC"]
  1121. JLDW = filtered2.iloc[0]["JLDW"]
  1122. YSJG = filtered2.iloc[0]["YSJG"]
  1123. clde_["CLBH"] = CLBH
  1124. clde_["CLMC"] = CLMC
  1125. clde_["JLDW"] = JLDW
  1126. clde_["YSJG"] = YSJG.item()
  1127. clde_["SL"] = SL.item()
  1128. clde_["HJ"] = HJ.item()
  1129. clde.append(clde_)
  1130. else:
  1131. detail = pd.read_csv("de/xstj/JD_PeiBi.csv")
  1132. filtered2 = detail[detail["RcjID"]==rcjID]
  1133. if len(filtered2) > 0:
  1134. CLBH = filtered2.iloc[0]["PBBH"]
  1135. CLMC = filtered2.iloc[0]["PBMC"]
  1136. JLDW = filtered2.iloc[0]["DW"]
  1137. YSJG = filtered2.iloc[0]["PBDJ"]
  1138. clde_["CLBH"] = CLBH.item()
  1139. clde_["CLMC"] = CLMC
  1140. clde_["JLDW"] = JLDW
  1141. clde_["YSJG"] = YSJG.item()
  1142. clde_["SL"] = SL.item()
  1143. clde_["HJ"] = HJ.item()
  1144. clde.append(clde_)
  1145. return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
  1146. def getSingleDeXilie_yl(debh):
  1147. id = None
  1148. bz_selected = []
  1149. bz_selected2 = []
  1150. if "附注" in debh:
  1151. position = debh.find("附注")
  1152. debh = debh[:position]
  1153. if "*" in debh:
  1154. position = debh.find("*")
  1155. debh = debh[:position]
  1156. if debh.endswith("换"):
  1157. debh = debh[:-1]
  1158. if "[" in debh:
  1159. position = debh.find("[")
  1160. debh = debh[:position-1]
  1161. gj = pd.read_csv("de/yl/JD_DanWeiGJ.csv")
  1162. filtered = gj[gj["DEBH"]==debh]
  1163. print(filtered)
  1164. if len(filtered) > 0:
  1165. index = (filtered.iloc[0]["YSDELBH"])
  1166. shu = pd.read_csv("de/yl/JD_DingEShu.csv")
  1167. hit = shu[shu["zjh"]==index]
  1168. if len(hit) > 0:
  1169. id = hit.iloc[0]["ID"]
  1170. beizhu = str(filtered.iloc[0]["BZBH"])
  1171. if 'nan' in beizhu:
  1172. pass
  1173. else:
  1174. beizhus = beizhu.split(";")
  1175. print(beizhus)
  1176. bzfile = pd.read_csv("de/yl/JD_BeiZhuZK.csv")
  1177. bzfile2 = pd.read_csv("de/yl/JD_BeiZhuFK.csv", dtype=str)
  1178. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1179. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1180. else:
  1181. return None, None, None, None, None, None, None
  1182. ####rengong
  1183. rgde = []
  1184. rg = pd.read_csv("de/yl/JD_GuJiaRG.csv")
  1185. filtered1 = rg[rg["DEBH"]==debh]
  1186. for i in range(len(filtered1)):
  1187. rgde_ = {}
  1188. gr = filtered1.iloc[i]["RGR"]##gongri
  1189. gf = filtered1.iloc[i]["RGF"]##gongfei
  1190. rcjID = filtered1.iloc[i]["RcjID"]
  1191. detail = pd.read_csv("de/yl/JD_CaiLiaoK.csv")
  1192. filtered2 = detail[detail["RcjID"]==rcjID]
  1193. if len(filtered2) > 0:
  1194. CLBH = filtered2.iloc[0]["CLBH"]
  1195. CLMC = filtered2.iloc[0]["CLMC"]
  1196. JLDW = filtered2.iloc[0]["JLDW"]
  1197. YSJG = filtered2.iloc[0]["YSJG"]
  1198. rgde_["CLBH"] = CLBH
  1199. rgde_["CLMC"] = CLMC
  1200. rgde_["JLDW"] = JLDW
  1201. rgde_["YSJG"] = YSJG.item()
  1202. rgde_["gr"] = gr.item()
  1203. rgde_["gf"] = gf.item()
  1204. rgde.append(rgde_)
  1205. ##print(rgde)
  1206. ####jixie
  1207. jxde = []
  1208. jx = pd.read_csv("de/yl/JD_GuJiaJX.csv")
  1209. filtered1 = jx[jx["DEBH"]==debh]
  1210. for i in range(len(filtered1)):
  1211. jxde_ = {}
  1212. sl = filtered1.iloc[i]["SL"]##shuliang
  1213. hj = filtered1.iloc[i]["HJ"]##hejia
  1214. rcjID = filtered1.iloc[i]["RcjID"]
  1215. detail = pd.read_csv("de/yl/JD_JiXieK.csv")
  1216. filtered2 = detail[detail["RcjID"]==rcjID]
  1217. if len(filtered2) > 0:
  1218. jxbh = filtered2.iloc[0]["jxbh"]
  1219. jxmc = filtered2.iloc[0]["jxmc"]
  1220. DW = filtered2.iloc[0]["DW"]
  1221. tbdj = filtered2.iloc[0]["tbdj"]
  1222. jxde_["jxbh"] = jxbh
  1223. jxde_["jxmc"] = jxmc
  1224. jxde_["DW"] = DW
  1225. jxde_["tbdj"] = tbdj.item()
  1226. jxde_["sl"] = sl.item()
  1227. jxde_["hj"] = hj.item()
  1228. jxde.append(jxde_)
  1229. ####cailiao
  1230. clde = []
  1231. cl = pd.read_csv("de/yl/JD_GuJiaCL.csv")
  1232. filtered1 = cl[cl["DEBH"]==debh]
  1233. for i in range(len(filtered1)):
  1234. clde_ = {}
  1235. SL = filtered1.iloc[i]["SL"]##shuliang
  1236. HJ = filtered1.iloc[i]["HJ"]##hejia
  1237. rcjID = filtered1.iloc[i]["RcjID"]
  1238. detail = pd.read_csv("de/yl/JD_CaiLiaoK.csv")
  1239. filtered2 = detail[detail["RcjID"]==rcjID]
  1240. if len(filtered2) > 0:
  1241. CLBH = filtered2.iloc[0]["CLBH"]
  1242. CLMC = filtered2.iloc[0]["CLMC"]
  1243. JLDW = filtered2.iloc[0]["JLDW"]
  1244. YSJG = filtered2.iloc[0]["YSJG"]
  1245. clde_["CLBH"] = CLBH
  1246. clde_["CLMC"] = CLMC
  1247. clde_["JLDW"] = JLDW
  1248. clde_["YSJG"] = YSJG.item()
  1249. clde_["SL"] = SL.item()
  1250. clde_["HJ"] = HJ.item()
  1251. clde.append(clde_)
  1252. else:
  1253. detail = pd.read_csv("de/yl/JD_PeiBi.csv")
  1254. filtered2 = detail[detail["RcjID"]==rcjID]
  1255. if len(filtered2) > 0:
  1256. CLBH = filtered2.iloc[0]["PBBH"]
  1257. CLMC = filtered2.iloc[0]["PBMC"]
  1258. JLDW = filtered2.iloc[0]["DW"]
  1259. YSJG = filtered2.iloc[0]["PBDJ"]
  1260. clde_["CLBH"] = CLBH.item()
  1261. clde_["CLMC"] = CLMC
  1262. clde_["JLDW"] = JLDW
  1263. clde_["YSJG"] = YSJG.item()
  1264. clde_["SL"] = SL.item()
  1265. clde_["HJ"] = HJ.item()
  1266. clde.append(clde_)
  1267. return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
  1268. def getSingleDeXilie_az(debh):
  1269. id = None
  1270. bz_selected = []
  1271. bz_selected2 = []
  1272. if "附注" in debh:
  1273. position = debh.find("附注")
  1274. debh = debh[:position]
  1275. if "*" in debh:
  1276. position = debh.find("*")
  1277. debh = debh[:position]
  1278. if debh.endswith("换"):
  1279. debh = debh[:-1]
  1280. if "[" in debh:
  1281. position = debh.find("[")
  1282. debh = debh[:position-1]
  1283. gj = pd.read_csv("de/az/JD_DanWeiGJ.csv")
  1284. filtered = gj[gj["DEBH"]==debh]
  1285. print(filtered)
  1286. if len(filtered) > 0:
  1287. index = (filtered.iloc[0]["YSDELBH"])
  1288. shu = pd.read_csv("de/az/JD_DingEShu.csv")
  1289. hit = shu[shu["zjh"]==index]
  1290. if len(hit) > 0:
  1291. id = hit.iloc[0]["ID"]
  1292. beizhu = str(filtered.iloc[0]["BZBH"])
  1293. if 'nan' in beizhu:
  1294. pass
  1295. else:
  1296. beizhus = beizhu.split(";")
  1297. print(beizhus)
  1298. bzfile = pd.read_csv("de/az/JD_BeiZhuZK.csv")
  1299. bzfile2 = pd.read_csv("de/az/JD_BeiZhuFK.csv", dtype=str)
  1300. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1301. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1302. else:
  1303. return None, None, None, None, None, None, None
  1304. ####rengong
  1305. rgde = []
  1306. rg = pd.read_csv("de/az/JD_GuJiaRG.csv")
  1307. filtered1 = rg[rg["DEBH"]==debh]
  1308. for i in range(len(filtered1)):
  1309. rgde_ = {}
  1310. gr = filtered1.iloc[i]["RGR"]##gongri
  1311. gf = filtered1.iloc[i]["RGF"]##gongfei
  1312. rcjID = filtered1.iloc[i]["RcjID"]
  1313. detail = pd.read_csv("de/az/JD_CaiLiaoK.csv")
  1314. filtered2 = detail[detail["RcjID"]==rcjID]
  1315. if len(filtered2) > 0:
  1316. CLBH = filtered2.iloc[0]["CLBH"]
  1317. CLMC = filtered2.iloc[0]["CLMC"]
  1318. JLDW = filtered2.iloc[0]["JLDW"]
  1319. YSJG = filtered2.iloc[0]["YSJG"]
  1320. rgde_["CLBH"] = CLBH
  1321. rgde_["CLMC"] = CLMC
  1322. rgde_["JLDW"] = JLDW
  1323. rgde_["YSJG"] = YSJG
  1324. rgde_["gr"] = gr
  1325. rgde_["gf"] = gf
  1326. rgde.append(rgde_)
  1327. ##print(rgde)
  1328. ####jixie
  1329. jxde = []
  1330. jx = pd.read_csv("de/az/JD_GuJiaJX.csv")
  1331. filtered1 = jx[jx["DEBH"]==debh]
  1332. for i in range(len(filtered1)):
  1333. jxde_ = {}
  1334. sl = filtered1.iloc[i]["SL"]##shuliang
  1335. hj = filtered1.iloc[i]["HJ"]##hejia
  1336. rcjID = filtered1.iloc[i]["RcjID"]
  1337. detail = pd.read_csv("de/az/JD_JiXieK.csv")
  1338. filtered2 = detail[detail["RcjID"]==rcjID]
  1339. if len(filtered2) > 0:
  1340. jxbh = filtered2.iloc[0]["jxbh"]
  1341. jxmc = filtered2.iloc[0]["jxmc"]
  1342. DW = filtered2.iloc[0]["DW"]
  1343. tbdj = filtered2.iloc[0]["tbdj"]
  1344. jxde_["jxbh"] = jxbh
  1345. jxde_["jxmc"] = jxmc
  1346. jxde_["DW"] = DW
  1347. jxde_["tbdj"] = tbdj
  1348. jxde_["sl"] = sl
  1349. jxde_["hj"] = hj
  1350. jxde.append(jxde_)
  1351. ####cailiao
  1352. clde = []
  1353. cl = pd.read_csv("de/az/JD_GuJiaCL.csv")
  1354. filtered1 = cl[cl["DEBH"]==debh]
  1355. for i in range(len(filtered1)):
  1356. clde_ = {}
  1357. SL = filtered1.iloc[i]["SL"]##shuliang
  1358. HJ = filtered1.iloc[i]["HJ"]##hejia
  1359. rcjID = filtered1.iloc[i]["RcjID"]
  1360. detail = pd.read_csv("de/az/JD_CaiLiaoK.csv")
  1361. filtered2 = detail[detail["RcjID"]==rcjID]
  1362. if len(filtered2) > 0:
  1363. CLBH = filtered2.iloc[0]["CLBH"]
  1364. CLMC = filtered2.iloc[0]["CLMC"]
  1365. JLDW = filtered2.iloc[0]["JLDW"]
  1366. YSJG = filtered2.iloc[0]["YSJG"]
  1367. clde_["CLBH"] = CLBH
  1368. clde_["CLMC"] = CLMC
  1369. clde_["JLDW"] = JLDW
  1370. clde_["YSJG"] = YSJG
  1371. clde_["SL"] = SL
  1372. clde_["HJ"] = HJ
  1373. clde.append(clde_)
  1374. else:
  1375. detail = pd.read_csv("de/az/JD_PeiBi.csv")
  1376. filtered2 = detail[detail["RcjID"]==rcjID]
  1377. if len(filtered2) > 0:
  1378. CLBH = filtered2.iloc[0]["PBBH"]
  1379. CLMC = filtered2.iloc[0]["PBMC"]
  1380. JLDW = filtered2.iloc[0]["DW"]
  1381. YSJG = filtered2.iloc[0]["PBDJ"]
  1382. clde_["CLBH"] = CLBH
  1383. clde_["CLMC"] = CLMC
  1384. clde_["JLDW"] = JLDW
  1385. clde_["YSJG"] = YSJG
  1386. clde_["SL"] = SL
  1387. clde_["HJ"] = HJ
  1388. clde.append(clde_)
  1389. return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
  1390. def getSingleDeXilie_sz(debh):
  1391. id = None
  1392. bz_selected = []
  1393. bz_selected2 = []
  1394. if "附注" in debh:
  1395. position = debh.find("附注")
  1396. debh = debh[:position]
  1397. if "*" in debh:
  1398. position = debh.find("*")
  1399. debh = debh[:position]
  1400. if debh.endswith("换"):
  1401. debh = debh[:-1]
  1402. if "[" in debh:
  1403. position = debh.find("[")
  1404. debh = debh[:position-1]
  1405. gj = pd.read_csv("de/sz/JD_DanWeiGJ.csv")
  1406. filtered = gj[gj["DEBH"]==debh]
  1407. print(filtered)
  1408. if len(filtered) > 0:
  1409. index = (filtered.iloc[0]["YSDELBH"])
  1410. shu = pd.read_csv("de/sz/JD_DingEShu.csv")
  1411. hit = shu[shu["zjh"]==index]
  1412. if len(hit) > 0:
  1413. id = hit.iloc[0]["ID"]
  1414. beizhu = str(filtered.iloc[0]["BZBH"])
  1415. if 'nan' in beizhu:
  1416. pass
  1417. else:
  1418. beizhus = beizhu.split(";")
  1419. print(beizhus)
  1420. bzfile = pd.read_csv("de/sz/JD_BeiZhuZK.csv")
  1421. bzfile2 = pd.read_csv("de/sz/JD_BeiZhuFK.csv", dtype=str)
  1422. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1423. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1424. else:
  1425. return None, None, None, None, None, None, None
  1426. ####rengong
  1427. rgde = []
  1428. rg = pd.read_csv("de/sz/JD_GuJiaRG.csv")
  1429. filtered1 = rg[rg["DEBH"]==debh]
  1430. for i in range(len(filtered1)):
  1431. rgde_ = {}
  1432. gr = filtered1.iloc[i]["RGR"]##gongri
  1433. gf = filtered1.iloc[i]["RGF"]##gongfei
  1434. rcjID = filtered1.iloc[i]["RcjID"]
  1435. detail = pd.read_csv("de/sz/JD_CaiLiaoK.csv")
  1436. filtered2 = detail[detail["RcjID"]==rcjID]
  1437. if len(filtered2) > 0:
  1438. CLBH = filtered2.iloc[0]["CLBH"]
  1439. CLMC = filtered2.iloc[0]["CLMC"]
  1440. JLDW = filtered2.iloc[0]["JLDW"]
  1441. YSJG = filtered2.iloc[0]["YSJG"]
  1442. rgde_["CLBH"] = CLBH
  1443. rgde_["CLMC"] = CLMC
  1444. rgde_["JLDW"] = JLDW
  1445. rgde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1446. rgde_["gr"] = gr.item() if type(gr) == float64 else gr
  1447. rgde_["gf"] = gf.item() if type(gf) == float64 else gf
  1448. rgde.append(rgde_)
  1449. ##print(rgde)
  1450. ####jixie
  1451. jxde = []
  1452. jx = pd.read_csv("de/sz/JD_GuJiaJX.csv")
  1453. filtered1 = jx[jx["DEBH"]==debh]
  1454. for i in range(len(filtered1)):
  1455. jxde_ = {}
  1456. sl = filtered1.iloc[i]["SL"]##shuliang
  1457. hj = filtered1.iloc[i]["HJ"]##hejia
  1458. rcjID = filtered1.iloc[i]["RcjID"]
  1459. detail = pd.read_csv("de/sz/JD_JiXieK.csv")
  1460. filtered2 = detail[detail["RcjID"]==rcjID]
  1461. if len(filtered2) > 0:
  1462. jxbh = filtered2.iloc[0]["jxbh"]
  1463. jxmc = filtered2.iloc[0]["jxmc"]
  1464. DW = filtered2.iloc[0]["DW"]
  1465. tbdj = filtered2.iloc[0]["tbdj"]
  1466. jxde_["jxbh"] = jxbh
  1467. jxde_["jxmc"] = jxmc
  1468. jxde_["DW"] = DW
  1469. jxde_["tbdj"] = tbdj.item() if type(tbdj) == float64 else tbdj
  1470. jxde_["sl"] = sl.item() if type(sl) == float64 else sl
  1471. jxde_["hj"] = hj.item() if type(hj) == float64 else hj
  1472. jxde.append(jxde_)
  1473. ####cailiao
  1474. clde = []
  1475. cl = pd.read_csv("de/sz/JD_GuJiaCL.csv")
  1476. filtered1 = cl[cl["DEBH"]==debh]
  1477. for i in range(len(filtered1)):
  1478. clde_ = {}
  1479. SL = filtered1.iloc[i]["SL"]##shuliang
  1480. HJ = filtered1.iloc[i]["HJ"]##hejia
  1481. rcjID = filtered1.iloc[i]["RcjID"]
  1482. detail = pd.read_csv("de/sz/JD_CaiLiaoK.csv")
  1483. filtered2 = detail[detail["RcjID"]==rcjID]
  1484. if len(filtered2) > 0:
  1485. CLBH = filtered2.iloc[0]["CLBH"]
  1486. CLMC = filtered2.iloc[0]["CLMC"]
  1487. JLDW = filtered2.iloc[0]["JLDW"]
  1488. YSJG = filtered2.iloc[0]["YSJG"]
  1489. clde_["CLBH"] = CLBH
  1490. clde_["CLMC"] = CLMC
  1491. clde_["JLDW"] = JLDW
  1492. clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1493. clde_["SL"] = SL.item() if type(SL) == float64 else SL
  1494. clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
  1495. clde.append(clde_)
  1496. else:
  1497. detail = pd.read_csv("de/sz/JD_PeiBi.csv")
  1498. filtered2 = detail[detail["RcjID"]==rcjID]
  1499. if len(filtered2) > 0:
  1500. CLBH = filtered2.iloc[0]["PBBH"]
  1501. CLMC = filtered2.iloc[0]["PBMC"]
  1502. JLDW = filtered2.iloc[0]["DW"]
  1503. YSJG = filtered2.iloc[0]["PBDJ"]
  1504. clde_["CLBH"] = CLBH
  1505. clde_["CLMC"] = CLMC
  1506. clde_["JLDW"] = JLDW
  1507. clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1508. clde_["SL"] = SL.item() if type(SL) == float64 else SL
  1509. clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
  1510. clde.append(clde_)
  1511. return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
  1512. def getSingleDeXilie_tj(debh):
  1513. id = None
  1514. bz_selected = []
  1515. bz_selected2 = []
  1516. if "附注" in debh:
  1517. position = debh.find("附注")
  1518. debh = debh[:position]
  1519. if "*" in debh:
  1520. position = debh.find("*")
  1521. debh = debh[:position]
  1522. if debh.endswith("换"):
  1523. debh = debh[:-1]
  1524. if "[" in debh:
  1525. position = debh.find("[")
  1526. debh = debh[:position-1]
  1527. gj = pd.read_csv("de/tj/JD_DanWeiGJ.csv")
  1528. filtered = gj[gj["DEBH"]==debh]
  1529. print(filtered)
  1530. if len(filtered) > 0:
  1531. index = int(filtered.iloc[0]["YSDELBH"])
  1532. shu = pd.read_csv("de/tj/JD_DingEShu.csv")
  1533. hit = shu[shu["zjh"]==index]
  1534. if len(hit) > 0:
  1535. id = hit.iloc[0]["ID"]
  1536. beizhu = str(filtered.iloc[0]["BZBH"])
  1537. if 'nan' in beizhu:
  1538. pass
  1539. else:
  1540. beizhus = beizhu.split(";")
  1541. print(beizhus)
  1542. bzfile = pd.read_csv("de/tj/JD_BeiZhuZK.csv")
  1543. bzfile2 = pd.read_csv("de/tj/JD_BeiZhuFK.csv", dtype=str)
  1544. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1545. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1546. else:
  1547. return None, None, None, None, None, None, None
  1548. ####rengong
  1549. rgde = []
  1550. rg = pd.read_csv("de/tj/JD_GuJiaRG.csv")
  1551. filtered1 = rg[rg["DEBH"]==debh]
  1552. for i in range(len(filtered1)):
  1553. rgde_ = {}
  1554. gr = filtered1.iloc[i]["RGR"]##gongri
  1555. gf = filtered1.iloc[i]["RGF"]##gongfei
  1556. rcjID = filtered1.iloc[i]["RcjID"]
  1557. detail = pd.read_csv("de/tj/JD_CaiLiaoK.csv")
  1558. filtered2 = detail[detail["RcjID"]==rcjID]
  1559. if len(filtered2) > 0:
  1560. CLBH = filtered2.iloc[0]["CLBH"]
  1561. CLMC = filtered2.iloc[0]["CLMC"]
  1562. JLDW = filtered2.iloc[0]["JLDW"]
  1563. YSJG = filtered2.iloc[0]["YSJG"]
  1564. rgde_["CLBH"] = CLBH
  1565. rgde_["CLMC"] = CLMC
  1566. rgde_["JLDW"] = JLDW
  1567. rgde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1568. rgde_["gr"] = gr.item() if type(gr) == float64 else gr
  1569. rgde_["gf"] = gf.item() if type(gf) == float64 else gf
  1570. rgde.append(rgde_)
  1571. ##print(rgde)
  1572. ####jixie
  1573. jxde = []
  1574. jx = pd.read_csv("de/tj/JD_GuJiaJX.csv")
  1575. filtered1 = jx[jx["DEBH"]==debh]
  1576. for i in range(len(filtered1)):
  1577. jxde_ = {}
  1578. sl = filtered1.iloc[i]["SL"]##shuliang
  1579. hj = filtered1.iloc[i]["HJ"]##hejia
  1580. rcjID = filtered1.iloc[i]["RcjID"]
  1581. detail = pd.read_csv("de/tj/JD_JiXieK.csv")
  1582. filtered2 = detail[detail["RcjID"]==rcjID]
  1583. if len(filtered2) > 0:
  1584. jxbh = filtered2.iloc[0]["jxbh"]
  1585. jxmc = filtered2.iloc[0]["jxmc"]
  1586. DW = filtered2.iloc[0]["DW"]
  1587. tbdj = filtered2.iloc[0]["tbdj"]
  1588. jxde_["jxbh"] = jxbh
  1589. jxde_["jxmc"] = jxmc
  1590. jxde_["DW"] = DW
  1591. jxde_["tbdj"] = tbdj.item() if type(tbdj) == float64 else tbdj
  1592. jxde_["sl"] = sl.item() if type(sl) == float64 else sl
  1593. jxde_["hj"] = hj.item() if type(hj) == float64 else hj
  1594. jxde.append(jxde_)
  1595. ####cailiao
  1596. clde = []
  1597. cl = pd.read_csv("de/tj/JD_GuJiaCL.csv")
  1598. filtered1 = cl[cl["DEBH"]==debh]
  1599. for i in range(len(filtered1)):
  1600. clde_ = {}
  1601. SL = filtered1.iloc[i]["SL"]##shuliang
  1602. HJ = filtered1.iloc[i]["HJ"]##hejia
  1603. rcjID = filtered1.iloc[i]["RcjID"]
  1604. detail = pd.read_csv("de/tj/JD_CaiLiaoK.csv")
  1605. filtered2 = detail[detail["RcjID"]==rcjID]
  1606. if len(filtered2) > 0:
  1607. CLBH = filtered2.iloc[0]["CLBH"]
  1608. CLMC = filtered2.iloc[0]["CLMC"]
  1609. JLDW = filtered2.iloc[0]["JLDW"]
  1610. YSJG = filtered2.iloc[0]["YSJG"]
  1611. clde_["CLBH"] = CLBH
  1612. clde_["CLMC"] = CLMC
  1613. clde_["JLDW"] = JLDW
  1614. clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1615. clde_["SL"] = SL.item() if type(SL) == float64 else SL
  1616. clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
  1617. clde.append(clde_)
  1618. else:
  1619. detail = pd.read_csv("de/tj/JD_PeiBi.csv")
  1620. filtered2 = detail[detail["RcjID"]==rcjID]
  1621. if len(filtered2) > 0:
  1622. CLBH = filtered2.iloc[0]["PBBH"]
  1623. CLMC = filtered2.iloc[0]["PBMC"]
  1624. JLDW = filtered2.iloc[0]["DW"]
  1625. YSJG = filtered2.iloc[0]["PBDJ"]
  1626. clde_["CLBH"] = CLBH
  1627. clde_["CLMC"] = CLMC
  1628. clde_["JLDW"] = JLDW
  1629. clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1630. clde_["SL"] = SL.item() if type(SL) == float64 else SL
  1631. clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
  1632. clde.append(clde_)
  1633. return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
  1634. def getDwgc(root, id, Zylb):
  1635. result = []
  1636. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  1637. item = None
  1638. for child in root:
  1639. if child.tag == "Dxgcxx":
  1640. for child1 in child:
  1641. Dwgcbh = child1.attrib["Dwgcbh"]
  1642. if Dwgcbh == id:
  1643. item = child1
  1644. break
  1645. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  1646. id = id + "Zylb" + Zylb
  1647. for child in item:
  1648. if child.tag == "Fywj":
  1649. result.append({"id": id + "bao jia hui zong", "label": "报价汇总表"})
  1650. elif child.tag == "Gfsj":
  1651. result.append({"id": id + "gui fei shui jin", "label": "规费税金"})
  1652. elif child.tag == "Qdxm":
  1653. result.append({"id": id + "qing dan xiang mu", "label": "清单项目"})
  1654. elif child.tag == "Csxm":
  1655. result.append({"id": id + "cuo shi xiang mu", "label": "措施项目"})
  1656. elif child.tag == "Qtxm":
  1657. result.append({"id": id +"qi ta xiang mu", "label": "其他项目"})
  1658. elif child.tag == "Zlje":
  1659. result.append({"id": id +"zan lie jin e", "label": "暂列金额"})
  1660. elif child.tag == "Clzg":
  1661. result.append({"id": id +"cai liao zan gu jia", "label": "材料暂估价"})
  1662. elif child.tag == "Zygczg":
  1663. result.append({"id": id + "zhuan ye gong cheng zan gu jia", "label": "专业工程暂估价"})
  1664. elif child.tag == "Jrg":
  1665. result.append({"id": id + "ji ri gong", "label": "计日工"})
  1666. elif child.tag == "Zcbfwf":
  1667. result.append({"id": id + "zong cheng bao fu wu fei", "label": "总承包服务费"})
  1668. elif child.tag == "Zjxmjdkzffj":
  1669. result.append({"id": id + "zong jia xiang mu jin du kuan zhi fu fen jie", "label": "总价项目进度款支付分解"})
  1670. elif child.tag == "Fbrgycl":
  1671. result.append({"id": id + "fa bao ren gong ying cai liao", "label": "发包人供应材料"})
  1672. elif child.tag == "Cbrgycl":
  1673. result.append({"id": id + "cheng bao ren gong ying cai liao", "label": "承包人供应材料"})
  1674. elif child.tag == "Rcjhz":
  1675. result.append({"id": id + "ren cai ji hui zong", "label": "人材机汇总"})
  1676. else:
  1677. print(child.tag)
  1678. print("WARNING####################################################################")
  1679. return result