service.py 67 KB

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