service.py 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773
  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. shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
  835. hit = shu[shu["ID"]==int(name)]
  836. print(hit)
  837. if len(hit) == 0:
  838. return []
  839. hit0 = hit.iloc[0]
  840. index = str(hit0['pblbh'])
  841. index_list = index.split(";")
  842. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  843. filtered = gj[gj["PBBH"].str.startswith(tuple(index_list))]
  844. return filtered.to_json(force_ascii=False)
  845. def getSingleDeXilie(zhuanye, debh):
  846. if zhuanye == 10:
  847. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  848. if A1:
  849. return A1, A2, A3, A4, A5, A6, A7, 10
  850. else:
  851. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_sz(debh)
  852. return A1, A2, A3, A4,A5, A6, A7, 20
  853. elif zhuanye == 20:##shizheng
  854. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_sz(debh)
  855. if A1:
  856. return A1, A2, A3, A4, A5, A6, A7, 20
  857. else:
  858. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  859. if A1:
  860. return A1, A2, A3, A4, A5, A6, A7, 10
  861. else:
  862. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  863. return A1, A2, A3, A4, A5, A6, A7, 30
  864. elif zhuanye == 30:##anzhuang
  865. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  866. return A1, A2, A3, A4, A5, A6, A7, 30
  867. elif zhuanye == 40:##yuanlin
  868. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_yl(debh)
  869. return A1, A2, A3, A4, A5, A6, A7, 40
  870. elif zhuanye == 50: ## xiushan tujian
  871. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_xstj(debh)
  872. if A1:
  873. return A1, A2, A3, A4, A5, A6, A7, 50
  874. else:
  875. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  876. return A1, A2, A3, A4,A5, A6, A7, 10
  877. else:
  878. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_xsaz(debh)
  879. if A1:
  880. return A1, A2, A3, A4, A5, A6, A7, 60
  881. else:
  882. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  883. return A1, A2, A3, A4,A5, A6, A7, 30
  884. def getSingleDeXilie_xsaz(debh):
  885. id = None
  886. bz_selected = []
  887. bz_selected2 = []
  888. if "附注" in debh:
  889. position = debh.find("附注")
  890. debh = debh[:position]
  891. if "*" in debh:
  892. position = debh.find("*")
  893. debh = debh[:position]
  894. if debh.endswith("换"):
  895. debh = debh[:-1]
  896. if "[" in debh:
  897. position = debh.find("[")
  898. debh = debh[:position-1]
  899. gj = pd.read_csv("de/xsaz/JD_DanWeiGJ.csv")
  900. filtered = gj[gj["DEBH"]==debh]
  901. print(filtered)
  902. if len(filtered) > 0:
  903. index = (filtered.iloc[0]["YSDELBH"])
  904. shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
  905. hit = shu[shu["zjh"]==index]
  906. if len(hit) > 0:
  907. id = hit.iloc[0]["ID"]
  908. beizhu = str(filtered.iloc[0]["BZBH"])
  909. if 'nan' in beizhu:
  910. pass
  911. else:
  912. beizhus = beizhu.split(";")
  913. print(beizhus)
  914. bzfile = pd.read_csv("de/xsaz/JD_BeiZhuZK.csv")
  915. bzfile2 = pd.read_csv("de/xsaz/JD_BeiZhuFK.csv", dtype=str)
  916. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  917. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  918. else:
  919. return None, None, None, None, None, None, None
  920. ####rengong
  921. rgde = []
  922. rg = pd.read_csv("de/xsaz/JD_GuJiaRG.csv")
  923. filtered1 = rg[rg["DEBH"]==debh]
  924. for i in range(len(filtered1)):
  925. rgde_ = {}
  926. gr = filtered1.iloc[i]["RGR"]##gongri
  927. gf = filtered1.iloc[i]["RGF"]##gongfei
  928. rcjID = filtered1.iloc[i]["RcjID"]
  929. detail = pd.read_csv("de/xsaz/JD_CaiLiaoK.csv")
  930. filtered2 = detail[detail["RcjID"]==rcjID]
  931. if len(filtered2) > 0:
  932. CLBH = filtered2.iloc[0]["CLBH"]
  933. CLMC = filtered2.iloc[0]["CLMC"]
  934. JLDW = filtered2.iloc[0]["JLDW"]
  935. YSJG = filtered2.iloc[0]["YSJG"]
  936. rgde_["CLBH"] = CLBH
  937. rgde_["CLMC"] = CLMC
  938. rgde_["JLDW"] = JLDW
  939. rgde_["YSJG"] = YSJG.item()
  940. rgde_["gr"] = gr.item()
  941. rgde_["gf"] = gf.item()
  942. rgde.append(rgde_)
  943. ##print(rgde)
  944. ####jixie
  945. jxde = []
  946. jx = pd.read_csv("de/xsaz/JD_GuJiaJX.csv")
  947. filtered1 = jx[jx["DEBH"]==debh]
  948. for i in range(len(filtered1)):
  949. jxde_ = {}
  950. sl = filtered1.iloc[i]["SL"]##shuliang
  951. hj = filtered1.iloc[i]["HJ"]##hejia
  952. rcjID = filtered1.iloc[i]["RcjID"]
  953. detail = pd.read_csv("de/xsaz/JD_JiXieK.csv")
  954. filtered2 = detail[detail["RcjID"]==rcjID]
  955. if len(filtered2) > 0:
  956. jxbh = filtered2.iloc[0]["jxbh"]
  957. jxmc = filtered2.iloc[0]["jxmc"]
  958. DW = filtered2.iloc[0]["DW"]
  959. tbdj = filtered2.iloc[0]["tbdj"]
  960. jxde_["jxbh"] = jxbh
  961. jxde_["jxmc"] = jxmc
  962. jxde_["DW"] = DW
  963. jxde_["tbdj"] = tbdj.item()
  964. jxde_["sl"] = sl.item()
  965. jxde_["hj"] = hj.item()
  966. jxde.append(jxde_)
  967. ####cailiao
  968. clde = []
  969. cl = pd.read_csv("de/xsaz/JD_GuJiaCL.csv")
  970. filtered1 = cl[cl["DEBH"]==debh]
  971. for i in range(len(filtered1)):
  972. clde_ = {}
  973. SL = filtered1.iloc[i]["SL"]##shuliang
  974. HJ = filtered1.iloc[i]["HJ"]##hejia
  975. rcjID = filtered1.iloc[i]["RcjID"]
  976. detail = pd.read_csv("de/xsaz/JD_CaiLiaoK.csv")
  977. filtered2 = detail[detail["RcjID"]==rcjID]
  978. if len(filtered2) > 0:
  979. CLBH = filtered2.iloc[0]["CLBH"]
  980. CLMC = filtered2.iloc[0]["CLMC"]
  981. JLDW = filtered2.iloc[0]["JLDW"]
  982. YSJG = filtered2.iloc[0]["YSJG"]
  983. clde_["CLBH"] = CLBH
  984. clde_["CLMC"] = CLMC
  985. clde_["JLDW"] = JLDW
  986. clde_["YSJG"] = YSJG.item()
  987. clde_["SL"] = SL.item()
  988. clde_["HJ"] = HJ.item()
  989. clde.append(clde_)
  990. else:
  991. detail = pd.read_csv("de/xsaz/JD_PeiBi.csv")
  992. filtered2 = detail[detail["RcjID"]==rcjID]
  993. if len(filtered2) > 0:
  994. CLBH = filtered2.iloc[0]["PBBH"]
  995. CLMC = filtered2.iloc[0]["PBMC"]
  996. JLDW = filtered2.iloc[0]["DW"]
  997. YSJG = filtered2.iloc[0]["PBDJ"]
  998. clde_["CLBH"] = CLBH.item()
  999. clde_["CLMC"] = CLMC
  1000. clde_["JLDW"] = JLDW
  1001. clde_["YSJG"] = YSJG.item()
  1002. clde_["SL"] = SL.item()
  1003. clde_["HJ"] = HJ.item()
  1004. clde.append(clde_)
  1005. 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
  1006. def getSingleDeXilie_xstj(debh):
  1007. id = None
  1008. bz_selected = []
  1009. bz_selected2 = []
  1010. if "附注" in debh:
  1011. position = debh.find("附注")
  1012. debh = debh[:position]
  1013. if "*" in debh:
  1014. position = debh.find("*")
  1015. debh = debh[:position]
  1016. if debh.endswith("换"):
  1017. debh = debh[:-1]
  1018. if "[" in debh:
  1019. position = debh.find("[")
  1020. debh = debh[:position-1]
  1021. gj = pd.read_csv("de/xstj/JD_DanWeiGJ.csv")
  1022. filtered = gj[gj["DEBH"]==debh]
  1023. print(filtered)
  1024. if len(filtered) > 0:
  1025. index = (filtered.iloc[0]["YSDELBH"])
  1026. shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
  1027. hit = shu[shu["zjh"]==index]
  1028. if len(hit) > 0:
  1029. id = hit.iloc[0]["ID"]
  1030. beizhu = str(filtered.iloc[0]["BZBH"])
  1031. if 'nan' in beizhu:
  1032. pass
  1033. else:
  1034. beizhus = beizhu.split(";")
  1035. print(beizhus)
  1036. bzfile = pd.read_csv("de/xstj/JD_BeiZhuZK.csv")
  1037. bzfile2 = pd.read_csv("de/xstj/JD_BeiZhuFK.csv", dtype=str)
  1038. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1039. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1040. else:
  1041. return None, None, None, None, None, None, None
  1042. ####rengong
  1043. rgde = []
  1044. rg = pd.read_csv("de/xstj/JD_GuJiaRG.csv")
  1045. filtered1 = rg[rg["DEBH"]==debh]
  1046. for i in range(len(filtered1)):
  1047. rgde_ = {}
  1048. gr = filtered1.iloc[i]["RGR"]##gongri
  1049. gf = filtered1.iloc[i]["RGF"]##gongfei
  1050. rcjID = filtered1.iloc[i]["RcjID"]
  1051. detail = pd.read_csv("de/xstj/JD_CaiLiaoK.csv")
  1052. filtered2 = detail[detail["RcjID"]==rcjID]
  1053. if len(filtered2) > 0:
  1054. CLBH = filtered2.iloc[0]["CLBH"]
  1055. CLMC = filtered2.iloc[0]["CLMC"]
  1056. JLDW = filtered2.iloc[0]["JLDW"]
  1057. YSJG = filtered2.iloc[0]["YSJG"]
  1058. rgde_["CLBH"] = CLBH
  1059. rgde_["CLMC"] = CLMC
  1060. rgde_["JLDW"] = JLDW
  1061. rgde_["YSJG"] = YSJG.item()
  1062. rgde_["gr"] = gr.item()
  1063. rgde_["gf"] = gf.item()
  1064. rgde.append(rgde_)
  1065. ##print(rgde)
  1066. ####jixie
  1067. jxde = []
  1068. jx = pd.read_csv("de/xstj/JD_GuJiaJX.csv")
  1069. filtered1 = jx[jx["DEBH"]==debh]
  1070. for i in range(len(filtered1)):
  1071. jxde_ = {}
  1072. sl = filtered1.iloc[i]["SL"]##shuliang
  1073. hj = filtered1.iloc[i]["HJ"]##hejia
  1074. rcjID = filtered1.iloc[i]["RcjID"]
  1075. detail = pd.read_csv("de/xstj/JD_JiXieK.csv")
  1076. filtered2 = detail[detail["RcjID"]==rcjID]
  1077. if len(filtered2) > 0:
  1078. jxbh = filtered2.iloc[0]["jxbh"]
  1079. jxmc = filtered2.iloc[0]["jxmc"]
  1080. DW = filtered2.iloc[0]["DW"]
  1081. tbdj = filtered2.iloc[0]["tbdj"]
  1082. jxde_["jxbh"] = jxbh
  1083. jxde_["jxmc"] = jxmc
  1084. jxde_["DW"] = DW
  1085. jxde_["tbdj"] = tbdj.item()
  1086. jxde_["sl"] = sl.item()
  1087. jxde_["hj"] = hj.item()
  1088. jxde.append(jxde_)
  1089. ####cailiao
  1090. clde = []
  1091. cl = pd.read_csv("de/xstj/JD_GuJiaCL.csv")
  1092. filtered1 = cl[cl["DEBH"]==debh]
  1093. for i in range(len(filtered1)):
  1094. clde_ = {}
  1095. SL = filtered1.iloc[i]["SL"]##shuliang
  1096. HJ = filtered1.iloc[i]["HJ"]##hejia
  1097. rcjID = filtered1.iloc[i]["RcjID"]
  1098. detail = pd.read_csv("de/xstj/JD_CaiLiaoK.csv")
  1099. filtered2 = detail[detail["RcjID"]==rcjID]
  1100. if len(filtered2) > 0:
  1101. CLBH = filtered2.iloc[0]["CLBH"]
  1102. CLMC = filtered2.iloc[0]["CLMC"]
  1103. JLDW = filtered2.iloc[0]["JLDW"]
  1104. YSJG = filtered2.iloc[0]["YSJG"]
  1105. clde_["CLBH"] = CLBH
  1106. clde_["CLMC"] = CLMC
  1107. clde_["JLDW"] = JLDW
  1108. clde_["YSJG"] = YSJG.item()
  1109. clde_["SL"] = SL.item()
  1110. clde_["HJ"] = HJ.item()
  1111. clde.append(clde_)
  1112. else:
  1113. detail = pd.read_csv("de/xstj/JD_PeiBi.csv")
  1114. filtered2 = detail[detail["RcjID"]==rcjID]
  1115. if len(filtered2) > 0:
  1116. CLBH = filtered2.iloc[0]["PBBH"]
  1117. CLMC = filtered2.iloc[0]["PBMC"]
  1118. JLDW = filtered2.iloc[0]["DW"]
  1119. YSJG = filtered2.iloc[0]["PBDJ"]
  1120. clde_["CLBH"] = CLBH.item()
  1121. clde_["CLMC"] = CLMC
  1122. clde_["JLDW"] = JLDW
  1123. clde_["YSJG"] = YSJG.item()
  1124. clde_["SL"] = SL.item()
  1125. clde_["HJ"] = HJ.item()
  1126. clde.append(clde_)
  1127. 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
  1128. def getSingleDeXilie_yl(debh):
  1129. id = None
  1130. bz_selected = []
  1131. bz_selected2 = []
  1132. if "附注" in debh:
  1133. position = debh.find("附注")
  1134. debh = debh[:position]
  1135. if "*" in debh:
  1136. position = debh.find("*")
  1137. debh = debh[:position]
  1138. if debh.endswith("换"):
  1139. debh = debh[:-1]
  1140. if "[" in debh:
  1141. position = debh.find("[")
  1142. debh = debh[:position-1]
  1143. gj = pd.read_csv("de/yl/JD_DanWeiGJ.csv")
  1144. filtered = gj[gj["DEBH"]==debh]
  1145. print(filtered)
  1146. if len(filtered) > 0:
  1147. index = (filtered.iloc[0]["YSDELBH"])
  1148. shu = pd.read_csv("de/yl/JD_DingEShu.csv")
  1149. hit = shu[shu["zjh"]==index]
  1150. if len(hit) > 0:
  1151. id = hit.iloc[0]["ID"]
  1152. beizhu = str(filtered.iloc[0]["BZBH"])
  1153. if 'nan' in beizhu:
  1154. pass
  1155. else:
  1156. beizhus = beizhu.split(";")
  1157. print(beizhus)
  1158. bzfile = pd.read_csv("de/yl/JD_BeiZhuZK.csv")
  1159. bzfile2 = pd.read_csv("de/yl/JD_BeiZhuFK.csv", dtype=str)
  1160. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1161. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1162. else:
  1163. return None, None, None, None, None, None, None
  1164. ####rengong
  1165. rgde = []
  1166. rg = pd.read_csv("de/yl/JD_GuJiaRG.csv")
  1167. filtered1 = rg[rg["DEBH"]==debh]
  1168. for i in range(len(filtered1)):
  1169. rgde_ = {}
  1170. gr = filtered1.iloc[i]["RGR"]##gongri
  1171. gf = filtered1.iloc[i]["RGF"]##gongfei
  1172. rcjID = filtered1.iloc[i]["RcjID"]
  1173. detail = pd.read_csv("de/yl/JD_CaiLiaoK.csv")
  1174. filtered2 = detail[detail["RcjID"]==rcjID]
  1175. if len(filtered2) > 0:
  1176. CLBH = filtered2.iloc[0]["CLBH"]
  1177. CLMC = filtered2.iloc[0]["CLMC"]
  1178. JLDW = filtered2.iloc[0]["JLDW"]
  1179. YSJG = filtered2.iloc[0]["YSJG"]
  1180. rgde_["CLBH"] = CLBH
  1181. rgde_["CLMC"] = CLMC
  1182. rgde_["JLDW"] = JLDW
  1183. rgde_["YSJG"] = YSJG.item()
  1184. rgde_["gr"] = gr.item()
  1185. rgde_["gf"] = gf.item()
  1186. rgde.append(rgde_)
  1187. ##print(rgde)
  1188. ####jixie
  1189. jxde = []
  1190. jx = pd.read_csv("de/yl/JD_GuJiaJX.csv")
  1191. filtered1 = jx[jx["DEBH"]==debh]
  1192. for i in range(len(filtered1)):
  1193. jxde_ = {}
  1194. sl = filtered1.iloc[i]["SL"]##shuliang
  1195. hj = filtered1.iloc[i]["HJ"]##hejia
  1196. rcjID = filtered1.iloc[i]["RcjID"]
  1197. detail = pd.read_csv("de/yl/JD_JiXieK.csv")
  1198. filtered2 = detail[detail["RcjID"]==rcjID]
  1199. if len(filtered2) > 0:
  1200. jxbh = filtered2.iloc[0]["jxbh"]
  1201. jxmc = filtered2.iloc[0]["jxmc"]
  1202. DW = filtered2.iloc[0]["DW"]
  1203. tbdj = filtered2.iloc[0]["tbdj"]
  1204. jxde_["jxbh"] = jxbh
  1205. jxde_["jxmc"] = jxmc
  1206. jxde_["DW"] = DW
  1207. jxde_["tbdj"] = tbdj.item()
  1208. jxde_["sl"] = sl.item()
  1209. jxde_["hj"] = hj.item()
  1210. jxde.append(jxde_)
  1211. ####cailiao
  1212. clde = []
  1213. cl = pd.read_csv("de/yl/JD_GuJiaCL.csv")
  1214. filtered1 = cl[cl["DEBH"]==debh]
  1215. for i in range(len(filtered1)):
  1216. clde_ = {}
  1217. SL = filtered1.iloc[i]["SL"]##shuliang
  1218. HJ = filtered1.iloc[i]["HJ"]##hejia
  1219. rcjID = filtered1.iloc[i]["RcjID"]
  1220. detail = pd.read_csv("de/yl/JD_CaiLiaoK.csv")
  1221. filtered2 = detail[detail["RcjID"]==rcjID]
  1222. if len(filtered2) > 0:
  1223. CLBH = filtered2.iloc[0]["CLBH"]
  1224. CLMC = filtered2.iloc[0]["CLMC"]
  1225. JLDW = filtered2.iloc[0]["JLDW"]
  1226. YSJG = filtered2.iloc[0]["YSJG"]
  1227. clde_["CLBH"] = CLBH
  1228. clde_["CLMC"] = CLMC
  1229. clde_["JLDW"] = JLDW
  1230. clde_["YSJG"] = YSJG.item()
  1231. clde_["SL"] = SL.item()
  1232. clde_["HJ"] = HJ.item()
  1233. clde.append(clde_)
  1234. else:
  1235. detail = pd.read_csv("de/yl/JD_PeiBi.csv")
  1236. filtered2 = detail[detail["RcjID"]==rcjID]
  1237. if len(filtered2) > 0:
  1238. CLBH = filtered2.iloc[0]["PBBH"]
  1239. CLMC = filtered2.iloc[0]["PBMC"]
  1240. JLDW = filtered2.iloc[0]["DW"]
  1241. YSJG = filtered2.iloc[0]["PBDJ"]
  1242. clde_["CLBH"] = CLBH.item()
  1243. clde_["CLMC"] = CLMC
  1244. clde_["JLDW"] = JLDW
  1245. clde_["YSJG"] = YSJG.item()
  1246. clde_["SL"] = SL.item()
  1247. clde_["HJ"] = HJ.item()
  1248. clde.append(clde_)
  1249. 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
  1250. def getSingleDeXilie_az(debh):
  1251. id = None
  1252. bz_selected = []
  1253. bz_selected2 = []
  1254. if "附注" in debh:
  1255. position = debh.find("附注")
  1256. debh = debh[:position]
  1257. if "*" in debh:
  1258. position = debh.find("*")
  1259. debh = debh[:position]
  1260. if debh.endswith("换"):
  1261. debh = debh[:-1]
  1262. if "[" in debh:
  1263. position = debh.find("[")
  1264. debh = debh[:position-1]
  1265. gj = pd.read_csv("de/az/JD_DanWeiGJ.csv")
  1266. filtered = gj[gj["DEBH"]==debh]
  1267. print(filtered)
  1268. if len(filtered) > 0:
  1269. index = (filtered.iloc[0]["YSDELBH"])
  1270. shu = pd.read_csv("de/az/JD_DingEShu.csv")
  1271. hit = shu[shu["zjh"]==index]
  1272. if len(hit) > 0:
  1273. id = hit.iloc[0]["ID"]
  1274. beizhu = str(filtered.iloc[0]["BZBH"])
  1275. if 'nan' in beizhu:
  1276. pass
  1277. else:
  1278. beizhus = beizhu.split(";")
  1279. print(beizhus)
  1280. bzfile = pd.read_csv("de/az/JD_BeiZhuZK.csv")
  1281. bzfile2 = pd.read_csv("de/az/JD_BeiZhuFK.csv", dtype=str)
  1282. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1283. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1284. else:
  1285. return None, None, None, None, None, None, None
  1286. ####rengong
  1287. rgde = []
  1288. rg = pd.read_csv("de/az/JD_GuJiaRG.csv")
  1289. filtered1 = rg[rg["DEBH"]==debh]
  1290. for i in range(len(filtered1)):
  1291. rgde_ = {}
  1292. gr = filtered1.iloc[i]["RGR"]##gongri
  1293. gf = filtered1.iloc[i]["RGF"]##gongfei
  1294. rcjID = filtered1.iloc[i]["RcjID"]
  1295. detail = pd.read_csv("de/az/JD_CaiLiaoK.csv")
  1296. filtered2 = detail[detail["RcjID"]==rcjID]
  1297. if len(filtered2) > 0:
  1298. CLBH = filtered2.iloc[0]["CLBH"]
  1299. CLMC = filtered2.iloc[0]["CLMC"]
  1300. JLDW = filtered2.iloc[0]["JLDW"]
  1301. YSJG = filtered2.iloc[0]["YSJG"]
  1302. rgde_["CLBH"] = CLBH
  1303. rgde_["CLMC"] = CLMC
  1304. rgde_["JLDW"] = JLDW
  1305. rgde_["YSJG"] = YSJG
  1306. rgde_["gr"] = gr
  1307. rgde_["gf"] = gf
  1308. rgde.append(rgde_)
  1309. ##print(rgde)
  1310. ####jixie
  1311. jxde = []
  1312. jx = pd.read_csv("de/az/JD_GuJiaJX.csv")
  1313. filtered1 = jx[jx["DEBH"]==debh]
  1314. for i in range(len(filtered1)):
  1315. jxde_ = {}
  1316. sl = filtered1.iloc[i]["SL"]##shuliang
  1317. hj = filtered1.iloc[i]["HJ"]##hejia
  1318. rcjID = filtered1.iloc[i]["RcjID"]
  1319. detail = pd.read_csv("de/az/JD_JiXieK.csv")
  1320. filtered2 = detail[detail["RcjID"]==rcjID]
  1321. if len(filtered2) > 0:
  1322. jxbh = filtered2.iloc[0]["jxbh"]
  1323. jxmc = filtered2.iloc[0]["jxmc"]
  1324. DW = filtered2.iloc[0]["DW"]
  1325. tbdj = filtered2.iloc[0]["tbdj"]
  1326. jxde_["jxbh"] = jxbh
  1327. jxde_["jxmc"] = jxmc
  1328. jxde_["DW"] = DW
  1329. jxde_["tbdj"] = tbdj
  1330. jxde_["sl"] = sl
  1331. jxde_["hj"] = hj
  1332. jxde.append(jxde_)
  1333. ####cailiao
  1334. clde = []
  1335. cl = pd.read_csv("de/az/JD_GuJiaCL.csv")
  1336. filtered1 = cl[cl["DEBH"]==debh]
  1337. for i in range(len(filtered1)):
  1338. clde_ = {}
  1339. SL = filtered1.iloc[i]["SL"]##shuliang
  1340. HJ = filtered1.iloc[i]["HJ"]##hejia
  1341. rcjID = filtered1.iloc[i]["RcjID"]
  1342. detail = pd.read_csv("de/az/JD_CaiLiaoK.csv")
  1343. filtered2 = detail[detail["RcjID"]==rcjID]
  1344. if len(filtered2) > 0:
  1345. CLBH = filtered2.iloc[0]["CLBH"]
  1346. CLMC = filtered2.iloc[0]["CLMC"]
  1347. JLDW = filtered2.iloc[0]["JLDW"]
  1348. YSJG = filtered2.iloc[0]["YSJG"]
  1349. clde_["CLBH"] = CLBH
  1350. clde_["CLMC"] = CLMC
  1351. clde_["JLDW"] = JLDW
  1352. clde_["YSJG"] = YSJG
  1353. clde_["SL"] = SL
  1354. clde_["HJ"] = HJ
  1355. clde.append(clde_)
  1356. else:
  1357. detail = pd.read_csv("de/az/JD_PeiBi.csv")
  1358. filtered2 = detail[detail["RcjID"]==rcjID]
  1359. if len(filtered2) > 0:
  1360. CLBH = filtered2.iloc[0]["PBBH"]
  1361. CLMC = filtered2.iloc[0]["PBMC"]
  1362. JLDW = filtered2.iloc[0]["DW"]
  1363. YSJG = filtered2.iloc[0]["PBDJ"]
  1364. clde_["CLBH"] = CLBH
  1365. clde_["CLMC"] = CLMC
  1366. clde_["JLDW"] = JLDW
  1367. clde_["YSJG"] = YSJG
  1368. clde_["SL"] = SL
  1369. clde_["HJ"] = HJ
  1370. clde.append(clde_)
  1371. 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
  1372. def getSingleDeXilie_sz(debh):
  1373. id = None
  1374. bz_selected = []
  1375. bz_selected2 = []
  1376. if "附注" in debh:
  1377. position = debh.find("附注")
  1378. debh = debh[:position]
  1379. if "*" in debh:
  1380. position = debh.find("*")
  1381. debh = debh[:position]
  1382. if debh.endswith("换"):
  1383. debh = debh[:-1]
  1384. if "[" in debh:
  1385. position = debh.find("[")
  1386. debh = debh[:position-1]
  1387. gj = pd.read_csv("de/sz/JD_DanWeiGJ.csv")
  1388. filtered = gj[gj["DEBH"]==debh]
  1389. print(filtered)
  1390. if len(filtered) > 0:
  1391. index = (filtered.iloc[0]["YSDELBH"])
  1392. shu = pd.read_csv("de/sz/JD_DingEShu.csv")
  1393. hit = shu[shu["zjh"]==index]
  1394. if len(hit) > 0:
  1395. id = hit.iloc[0]["ID"]
  1396. beizhu = str(filtered.iloc[0]["BZBH"])
  1397. if 'nan' in beizhu:
  1398. pass
  1399. else:
  1400. beizhus = beizhu.split(";")
  1401. print(beizhus)
  1402. bzfile = pd.read_csv("de/sz/JD_BeiZhuZK.csv")
  1403. bzfile2 = pd.read_csv("de/sz/JD_BeiZhuFK.csv", dtype=str)
  1404. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1405. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1406. else:
  1407. return None, None, None, None, None, None, None
  1408. ####rengong
  1409. rgde = []
  1410. rg = pd.read_csv("de/sz/JD_GuJiaRG.csv")
  1411. filtered1 = rg[rg["DEBH"]==debh]
  1412. for i in range(len(filtered1)):
  1413. rgde_ = {}
  1414. gr = filtered1.iloc[i]["RGR"]##gongri
  1415. gf = filtered1.iloc[i]["RGF"]##gongfei
  1416. rcjID = filtered1.iloc[i]["RcjID"]
  1417. detail = pd.read_csv("de/sz/JD_CaiLiaoK.csv")
  1418. filtered2 = detail[detail["RcjID"]==rcjID]
  1419. if len(filtered2) > 0:
  1420. CLBH = filtered2.iloc[0]["CLBH"]
  1421. CLMC = filtered2.iloc[0]["CLMC"]
  1422. JLDW = filtered2.iloc[0]["JLDW"]
  1423. YSJG = filtered2.iloc[0]["YSJG"]
  1424. rgde_["CLBH"] = CLBH
  1425. rgde_["CLMC"] = CLMC
  1426. rgde_["JLDW"] = JLDW
  1427. rgde_["YSJG"] = YSJG
  1428. rgde_["gr"] = gr
  1429. rgde_["gf"] = gf
  1430. rgde.append(rgde_)
  1431. ##print(rgde)
  1432. ####jixie
  1433. jxde = []
  1434. jx = pd.read_csv("de/sz/JD_GuJiaJX.csv")
  1435. filtered1 = jx[jx["DEBH"]==debh]
  1436. for i in range(len(filtered1)):
  1437. jxde_ = {}
  1438. sl = filtered1.iloc[i]["SL"]##shuliang
  1439. hj = filtered1.iloc[i]["HJ"]##hejia
  1440. rcjID = filtered1.iloc[i]["RcjID"]
  1441. detail = pd.read_csv("de/sz/JD_JiXieK.csv")
  1442. filtered2 = detail[detail["RcjID"]==rcjID]
  1443. if len(filtered2) > 0:
  1444. jxbh = filtered2.iloc[0]["jxbh"]
  1445. jxmc = filtered2.iloc[0]["jxmc"]
  1446. DW = filtered2.iloc[0]["DW"]
  1447. tbdj = filtered2.iloc[0]["tbdj"]
  1448. jxde_["jxbh"] = jxbh
  1449. jxde_["jxmc"] = jxmc
  1450. jxde_["DW"] = DW
  1451. jxde_["tbdj"] = tbdj
  1452. jxde_["sl"] = sl
  1453. jxde_["hj"] = hj
  1454. jxde.append(jxde_)
  1455. ####cailiao
  1456. clde = []
  1457. cl = pd.read_csv("de/sz/JD_GuJiaCL.csv")
  1458. filtered1 = cl[cl["DEBH"]==debh]
  1459. for i in range(len(filtered1)):
  1460. clde_ = {}
  1461. SL = filtered1.iloc[i]["SL"]##shuliang
  1462. HJ = filtered1.iloc[i]["HJ"]##hejia
  1463. rcjID = filtered1.iloc[i]["RcjID"]
  1464. detail = pd.read_csv("de/sz/JD_CaiLiaoK.csv")
  1465. filtered2 = detail[detail["RcjID"]==rcjID]
  1466. if len(filtered2) > 0:
  1467. CLBH = filtered2.iloc[0]["CLBH"]
  1468. CLMC = filtered2.iloc[0]["CLMC"]
  1469. JLDW = filtered2.iloc[0]["JLDW"]
  1470. YSJG = filtered2.iloc[0]["YSJG"]
  1471. clde_["CLBH"] = CLBH
  1472. clde_["CLMC"] = CLMC
  1473. clde_["JLDW"] = JLDW
  1474. clde_["YSJG"] = YSJG
  1475. clde_["SL"] = SL
  1476. clde_["HJ"] = HJ
  1477. clde.append(clde_)
  1478. else:
  1479. detail = pd.read_csv("de/sz/JD_PeiBi.csv")
  1480. filtered2 = detail[detail["RcjID"]==rcjID]
  1481. if len(filtered2) > 0:
  1482. CLBH = filtered2.iloc[0]["PBBH"]
  1483. CLMC = filtered2.iloc[0]["PBMC"]
  1484. JLDW = filtered2.iloc[0]["DW"]
  1485. YSJG = filtered2.iloc[0]["PBDJ"]
  1486. clde_["CLBH"] = CLBH
  1487. clde_["CLMC"] = CLMC
  1488. clde_["JLDW"] = JLDW
  1489. clde_["YSJG"] = YSJG
  1490. clde_["SL"] = SL
  1491. clde_["HJ"] = HJ
  1492. clde.append(clde_)
  1493. 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
  1494. def getSingleDeXilie_tj(debh):
  1495. id = None
  1496. bz_selected = []
  1497. bz_selected2 = []
  1498. if "附注" in debh:
  1499. position = debh.find("附注")
  1500. debh = debh[:position]
  1501. if "*" in debh:
  1502. position = debh.find("*")
  1503. debh = debh[:position]
  1504. if debh.endswith("换"):
  1505. debh = debh[:-1]
  1506. if "[" in debh:
  1507. position = debh.find("[")
  1508. debh = debh[:position-1]
  1509. gj = pd.read_csv("de/tj/JD_DanWeiGJ.csv")
  1510. filtered = gj[gj["DEBH"]==debh]
  1511. print(filtered)
  1512. if len(filtered) > 0:
  1513. index = int(filtered.iloc[0]["YSDELBH"])
  1514. shu = pd.read_csv("de/tj/JD_DingEShu.csv")
  1515. hit = shu[shu["zjh"]==index]
  1516. if len(hit) > 0:
  1517. id = hit.iloc[0]["ID"]
  1518. beizhu = str(filtered.iloc[0]["BZBH"])
  1519. if 'nan' in beizhu:
  1520. pass
  1521. else:
  1522. beizhus = beizhu.split(";")
  1523. print(beizhus)
  1524. bzfile = pd.read_csv("de/tj/JD_BeiZhuZK.csv")
  1525. bzfile2 = pd.read_csv("de/tj/JD_BeiZhuFK.csv", dtype=str)
  1526. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1527. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1528. else:
  1529. return None, None, None, None, None, None, None
  1530. ####rengong
  1531. rgde = []
  1532. rg = pd.read_csv("de/tj/JD_GuJiaRG.csv")
  1533. filtered1 = rg[rg["DEBH"]==debh]
  1534. for i in range(len(filtered1)):
  1535. rgde_ = {}
  1536. gr = filtered1.iloc[i]["RGR"]##gongri
  1537. gf = filtered1.iloc[i]["RGF"]##gongfei
  1538. rcjID = filtered1.iloc[i]["RcjID"]
  1539. detail = pd.read_csv("de/tj/JD_CaiLiaoK.csv")
  1540. filtered2 = detail[detail["RcjID"]==rcjID]
  1541. if len(filtered2) > 0:
  1542. CLBH = filtered2.iloc[0]["CLBH"]
  1543. CLMC = filtered2.iloc[0]["CLMC"]
  1544. JLDW = filtered2.iloc[0]["JLDW"]
  1545. YSJG = filtered2.iloc[0]["YSJG"]
  1546. rgde_["CLBH"] = CLBH
  1547. rgde_["CLMC"] = CLMC
  1548. rgde_["JLDW"] = JLDW
  1549. rgde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1550. rgde_["gr"] = gr.item() if type(gr) == float64 else gr
  1551. rgde_["gf"] = gf.item() if type(gf) == float64 else gf
  1552. rgde.append(rgde_)
  1553. ##print(rgde)
  1554. ####jixie
  1555. jxde = []
  1556. jx = pd.read_csv("de/tj/JD_GuJiaJX.csv")
  1557. filtered1 = jx[jx["DEBH"]==debh]
  1558. for i in range(len(filtered1)):
  1559. jxde_ = {}
  1560. sl = filtered1.iloc[i]["SL"]##shuliang
  1561. hj = filtered1.iloc[i]["HJ"]##hejia
  1562. rcjID = filtered1.iloc[i]["RcjID"]
  1563. detail = pd.read_csv("de/tj/JD_JiXieK.csv")
  1564. filtered2 = detail[detail["RcjID"]==rcjID]
  1565. if len(filtered2) > 0:
  1566. jxbh = filtered2.iloc[0]["jxbh"]
  1567. jxmc = filtered2.iloc[0]["jxmc"]
  1568. DW = filtered2.iloc[0]["DW"]
  1569. tbdj = filtered2.iloc[0]["tbdj"]
  1570. jxde_["jxbh"] = jxbh
  1571. jxde_["jxmc"] = jxmc
  1572. jxde_["DW"] = DW
  1573. jxde_["tbdj"] = tbdj.item() if type(tbdj) == float64 else tbdj
  1574. jxde_["sl"] = sl.item() if type(sl) == float64 else sl
  1575. jxde_["hj"] = hj.item() if type(hj) == float64 else hj
  1576. jxde.append(jxde_)
  1577. ####cailiao
  1578. clde = []
  1579. cl = pd.read_csv("de/tj/JD_GuJiaCL.csv")
  1580. filtered1 = cl[cl["DEBH"]==debh]
  1581. for i in range(len(filtered1)):
  1582. clde_ = {}
  1583. SL = filtered1.iloc[i]["SL"]##shuliang
  1584. HJ = filtered1.iloc[i]["HJ"]##hejia
  1585. rcjID = filtered1.iloc[i]["RcjID"]
  1586. detail = pd.read_csv("de/tj/JD_CaiLiaoK.csv")
  1587. filtered2 = detail[detail["RcjID"]==rcjID]
  1588. if len(filtered2) > 0:
  1589. CLBH = filtered2.iloc[0]["CLBH"]
  1590. CLMC = filtered2.iloc[0]["CLMC"]
  1591. JLDW = filtered2.iloc[0]["JLDW"]
  1592. YSJG = filtered2.iloc[0]["YSJG"]
  1593. clde_["CLBH"] = CLBH
  1594. clde_["CLMC"] = CLMC
  1595. clde_["JLDW"] = JLDW
  1596. clde_["YSJG"] = YSJG
  1597. clde_["SL"] = SL
  1598. clde_["HJ"] = HJ
  1599. clde.append(clde_)
  1600. else:
  1601. detail = pd.read_csv("de/tj/JD_PeiBi.csv")
  1602. filtered2 = detail[detail["RcjID"]==rcjID]
  1603. if len(filtered2) > 0:
  1604. CLBH = filtered2.iloc[0]["PBBH"]
  1605. CLMC = filtered2.iloc[0]["PBMC"]
  1606. JLDW = filtered2.iloc[0]["DW"]
  1607. YSJG = filtered2.iloc[0]["PBDJ"]
  1608. clde_["CLBH"] = CLBH
  1609. clde_["CLMC"] = CLMC
  1610. clde_["JLDW"] = JLDW
  1611. clde_["YSJG"] = YSJG
  1612. clde_["SL"] = SL
  1613. clde_["HJ"] = HJ
  1614. clde.append(clde_)
  1615. 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
  1616. def getDwgc(root, id, Zylb):
  1617. result = []
  1618. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  1619. item = None
  1620. for child in root:
  1621. if child.tag == "Dxgcxx":
  1622. for child1 in child:
  1623. Dwgcbh = child1.attrib["Dwgcbh"]
  1624. if Dwgcbh == id:
  1625. item = child1
  1626. break
  1627. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  1628. id = id + "Zylb" + Zylb
  1629. for child in item:
  1630. if child.tag == "Fywj":
  1631. result.append({"id": id + "bao jia hui zong", "label": "报价汇总表"})
  1632. elif child.tag == "Gfsj":
  1633. result.append({"id": id + "gui fei shui jin", "label": "规费税金"})
  1634. elif child.tag == "Qdxm":
  1635. result.append({"id": id + "qing dan xiang mu", "label": "清单项目"})
  1636. elif child.tag == "Csxm":
  1637. result.append({"id": id + "cuo shi xiang mu", "label": "措施项目"})
  1638. elif child.tag == "Qtxm":
  1639. result.append({"id": id +"qi ta xiang mu", "label": "其他项目"})
  1640. elif child.tag == "Zlje":
  1641. result.append({"id": id +"zan lie jin e", "label": "暂列金额"})
  1642. elif child.tag == "Clzg":
  1643. result.append({"id": id +"cai liao zan gu jia", "label": "材料暂估价"})
  1644. elif child.tag == "Zygczg":
  1645. result.append({"id": id + "zhuan ye gong cheng zan gu jia", "label": "专业工程暂估价"})
  1646. elif child.tag == "Jrg":
  1647. result.append({"id": id + "ji ri gong", "label": "计日工"})
  1648. elif child.tag == "Zcbfwf":
  1649. result.append({"id": id + "zong cheng bao fu wu fei", "label": "总承包服务费"})
  1650. elif child.tag == "Zjxmjdkzffj":
  1651. result.append({"id": id + "zong jia xiang mu jin du kuan zhi fu fen jie", "label": "总价项目进度款支付分解"})
  1652. elif child.tag == "Fbrgycl":
  1653. result.append({"id": id + "fa bao ren gong ying cai liao", "label": "发包人供应材料"})
  1654. elif child.tag == "Cbrgycl":
  1655. result.append({"id": id + "cheng bao ren gong ying cai liao", "label": "承包人供应材料"})
  1656. elif child.tag == "Rcjhz":
  1657. result.append({"id": id + "ren cai ji hui zong", "label": "人材机汇总"})
  1658. else:
  1659. print(child.tag)
  1660. print("WARNING####################################################################")
  1661. return result