service.py 72 KB

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