service.py 71 KB

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