service.py 67 KB

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