service.py 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845
  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 getZygczgj(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 == 'Zygczg':
  621. Fywj= child
  622. break
  623. for child in Fywj:
  624. result.append(
  625. [child.attrib["Xh"],
  626. child.attrib["Mc"], child.attrib["Gcnr"], child.attrib["Je"], child.attrib["Bz"]]
  627. )
  628. return result
  629. def getQtxm(root, id):
  630. result = []
  631. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  632. item = None
  633. for child in root:
  634. if child.tag == "Dxgcxx":
  635. for child1 in child:
  636. Dwgcbh = child1.attrib["Dwgcbh"]
  637. if Dwgcbh == id:
  638. item = child1
  639. break
  640. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  641. Fywj = None
  642. for child in item:
  643. if child.tag == 'Qtxm':
  644. Fywj= child
  645. break
  646. for child in Fywj:
  647. ##child is mx
  648. xh = child.attrib["Xh"]
  649. if "." in xh:
  650. count = 0
  651. for entry in xh:
  652. if entry == ".":
  653. count = count + 1
  654. if count == 1:
  655. parent = result[-1]
  656. if "__children" in parent:
  657. children = parent["__children"]
  658. children.append(
  659. {"序号":xh, "名称": child.attrib["Mc"],
  660. "金额": child.attrib["Je"], "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}
  661. )
  662. else:
  663. parent["__children"] = [
  664. {"序号":xh, "名称": child.attrib["Mc"],
  665. "金额": child.attrib["Je"], "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}]
  666. else:
  667. result.append(
  668. {"序号":xh, "名称": child.attrib["Mc"],
  669. "金额": child.attrib["Je"], "项目类别" : child.attrib["Xmlb"], "备注" : child.attrib["Bz"]}
  670. )
  671. return result
  672. def getGfsj(root, id):
  673. result = []
  674. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  675. item = None
  676. for child in root:
  677. if child.tag == "Dxgcxx":
  678. for child1 in child:
  679. Dwgcbh = child1.attrib["Dwgcbh"]
  680. if Dwgcbh == id:
  681. item = child1
  682. break
  683. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  684. Fywj = None
  685. for child in item:
  686. if child.tag == 'Gfsj':
  687. Fywj= child
  688. break
  689. for child in Fywj:
  690. ##child is mx
  691. xh = child.attrib["Xh"]
  692. if "." in xh:
  693. count = 0
  694. for entry in xh:
  695. if entry == ".":
  696. count = count + 1
  697. if count == 1:
  698. parent = result[-1]
  699. if "__children" in parent:
  700. children = parent["__children"]
  701. children.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "费率": child.attrib['Fl'], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]})
  702. else:
  703. parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "费率": child.attrib['Fl'], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]}]
  704. elif count == 2:
  705. parent = result[-1]
  706. if "__children" in parent:
  707. parent = parent["__children"][-1]
  708. print(parent)
  709. if "__children" in parent:
  710. children = parent["__children"]
  711. children.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "费率": child.attrib['Fl'], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]})
  712. else:
  713. parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "费率": child.attrib['Fl'], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]}]
  714. else:
  715. ###["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  716. result.append({"序号":xh, "名称": child.attrib["Mc"], "取费基数": child.attrib["Qfjs"], "计算基础": child.attrib["Jsjc"], "费率": child.attrib['Fl'], "金额": child.attrib["Je"], "类别" : child.attrib["Fyxlb"]})
  717. return result
  718. def getBjhz(root, id):
  719. print(root)
  720. print(id)
  721. result = []
  722. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  723. item = None
  724. for child in root:
  725. if child.tag == "Dxgcxx":
  726. for child1 in child:
  727. Dwgcbh = child1.attrib["Dwgcbh"]
  728. if Dwgcbh == id:
  729. item = child1
  730. break
  731. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  732. print(item)
  733. Fywj = None
  734. for child in item:
  735. if child.tag == 'Fywj':
  736. Fywj= child
  737. break
  738. for child in Fywj:
  739. ##child is mx
  740. xh = child.attrib["Xh"]
  741. if "." in xh:
  742. count = 0
  743. for entry in xh:
  744. if entry == ".":
  745. count = count + 1
  746. if count == 1:
  747. parent = result[-1]
  748. if "__children" in parent:
  749. children = parent["__children"]
  750. children.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})
  751. else:
  752. parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]}]
  753. elif count == 2:
  754. parent = result[-1]
  755. if "__children" in parent:
  756. parent = parent["__children"][-1]
  757. print(parent)
  758. if "__children" in parent:
  759. children = parent["__children"]
  760. children.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})
  761. else:
  762. parent["__children"] = [{"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"], "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]}]
  763. else:
  764. ###"序号", "名称", "金额", "暂估价", "类别"]
  765. result.append({"序号":xh, "名称": child.attrib["Mc"], "金额": child.attrib["Je"],
  766. "暂估价" : child.attrib["Zgj"], "类别" : child.attrib["Fyxlb"]})
  767. return result
  768. def processDes(dataframe, from_, end, level):
  769. result = []
  770. for i in range(from_, end):
  771. item = dataframe.iloc[i]
  772. fbcch = str(item['fbcch'])
  773. if fbcch == str(level):
  774. entry = {"id": str(item["ID"]), "label": str(item["zjbt"])}
  775. next = i + 1
  776. while next < end and str(dataframe.iloc[next]["fbcch"]) != str(level):
  777. next = next + 1
  778. entry["children"] = processDes(dataframe, i + 1, next, level + 1)
  779. result.append(entry)
  780. return result
  781. def processPbs(dataframe, from_, end, level):
  782. result = []
  783. for i in range(from_, end):
  784. item = dataframe.iloc[i]
  785. fbcch = str(item['fbcch'])
  786. if fbcch == str(level):
  787. entry = {"id": str(item["ID"]), "label": str(item["flmc"]), "data": item["pblbh"]}
  788. next = i + 1
  789. while next < end and str(dataframe.iloc[next]["fbcch"]) != str(level):
  790. next = next + 1
  791. entry["children"] = processPbs(dataframe, i + 1, next, level + 1)
  792. result.append(entry)
  793. return result
  794. def getCankao():
  795. tree = ET.parse('de/DeData_Fl.xml')
  796. root = tree.getroot()
  797. JSFF = None
  798. CsFl = None
  799. result = []
  800. for child in root:
  801. if child.tag == "JJFF":
  802. for grandchild in child:
  803. if grandchild.tag == 'JSFF':
  804. JSFF = grandchild
  805. for child in JSFF:
  806. if child.attrib['Markup'] == '1':
  807. for grandchild in child:
  808. if grandchild.tag == 'CsFl':
  809. CsFl = grandchild
  810. for child in CsFl:
  811. result.append({'工程类型': child.attrib['Gclx'], '名称': child.attrib['Mc'], '计算基础': child.attrib['Jsjc'],
  812. '参考费率': child.attrib['CkFl'], '地区': child.attrib['Dq'], '备注': child.attrib['Bz']})
  813. return result
  814. def getDes(value):
  815. if value == 10:
  816. shu = pd.read_csv("de/tj/JD_DingEShu.csv")
  817. elif value == 20:
  818. shu = pd.read_csv("de/sz/JD_DingEShu.csv")
  819. elif value == 30:
  820. shu = pd.read_csv("de/az/JD_DingEShu.csv")
  821. elif value == 40:
  822. shu = pd.read_csv("de/yl/JD_DingEShu.csv")
  823. elif value == 50:
  824. shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
  825. else:
  826. shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
  827. length = len(shu)
  828. return processDes(shu, 1, length, 2)
  829. def getPbs(value):
  830. if value == 10:
  831. shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
  832. else:
  833. shu = pd.read_csv("de/sz/JD_PeiBiFLB.csv")
  834. length = len(shu)
  835. return processPbs(shu, 0, length, 1)
  836. def getDeXilie(value, id):
  837. print(type(id))
  838. if value == 10:
  839. shu = pd.read_csv("de/tj/JD_DingEShu.csv")
  840. elif value == 20:
  841. shu = pd.read_csv("de/sz/JD_DingEShu.csv")
  842. elif value == 30:
  843. shu = pd.read_csv("de/az/JD_DingEShu.csv")
  844. elif value == 40:
  845. shu = pd.read_csv("de/yl/JD_DingEShu.csv")
  846. elif value == 50:
  847. shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
  848. else:
  849. shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
  850. hit = shu[shu["ID"]==int(id)]
  851. print(hit)
  852. if len(hit) == 0:
  853. return []
  854. hit0 = hit.iloc[0]
  855. index = str(hit0['zjh'])
  856. print("index=" + index)
  857. if value == 10:
  858. gj = pd.read_csv("de/tj/JD_DanWeiGJ.csv")
  859. filtered = gj[gj["YSDELBH"]==int(index)]
  860. elif value == 20:
  861. gj = pd.read_csv("de/sz/JD_DanWeiGJ.csv")
  862. filtered = gj[gj["YSDELBH"]==(index)]
  863. elif value == 30:
  864. gj = pd.read_csv("de/az/JD_DanWeiGJ.csv")
  865. filtered = gj[gj["YSDELBH"]==(index)]
  866. elif value == 40:
  867. gj = pd.read_csv("de/yl/JD_DanWeiGJ.csv")
  868. filtered = gj[gj["YSDELBH"]==int(index)]
  869. elif value == 50:
  870. gj = pd.read_csv("de/xstj/JD_DanWeiGJ.csv")
  871. filtered = gj[gj["YSDELBH"]==int(index)]
  872. else:
  873. gj = pd.read_csv("de/xsaz/JD_DanWeiGJ.csv")
  874. filtered = gj[gj["YSDELBH"]==int(index)]
  875. return filtered.to_json(force_ascii=False)
  876. def getQufei(name):
  877. if name == "0":
  878. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  879. return gj.to_json(force_ascii=False)
  880. shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
  881. hit = shu[shu["ID"]==int(name)]
  882. print(hit)
  883. if len(hit) == 0:
  884. return []
  885. hit0 = hit.iloc[0]
  886. index = str(hit0['pblbh'])
  887. index_list = index.split(";")
  888. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  889. filtered = gj[gj["PBBH"].str.startswith(tuple(index_list))]
  890. return filtered.to_json(force_ascii=False)
  891. def getPbxl(name):
  892. if name == "0":
  893. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  894. return gj.to_json(force_ascii=False)
  895. shu = pd.read_csv("de/tj/JD_PeiBiFLB.csv")
  896. hit = shu[shu["ID"]==int(name)]
  897. print(hit)
  898. if len(hit) == 0:
  899. return []
  900. hit0 = hit.iloc[0]
  901. index = str(hit0['pblbh'])
  902. index_list = index.split(";")
  903. gj = pd.read_csv("de/tj/JD_PeiBi.csv")
  904. filtered = gj[gj["PBBH"].str.startswith(tuple(index_list))]
  905. return filtered.to_json(force_ascii=False)
  906. def getSingleDeXilie(zhuanye, debh):
  907. if zhuanye == 10:
  908. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  909. if A1:
  910. return A1, A2, A3, A4, A5, A6, A7, 10
  911. else:
  912. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_sz(debh)
  913. return A1, A2, A3, A4,A5, A6, A7, 20
  914. elif zhuanye == 20:##shizheng
  915. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_sz(debh)
  916. if A1:
  917. return A1, A2, A3, A4, A5, A6, A7, 20
  918. else:
  919. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  920. if A1:
  921. return A1, A2, A3, A4, A5, A6, A7, 10
  922. else:
  923. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  924. return A1, A2, A3, A4, A5, A6, A7, 30
  925. elif zhuanye == 30:##anzhuang
  926. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  927. return A1, A2, A3, A4, A5, A6, A7, 30
  928. elif zhuanye == 40:##yuanlin
  929. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_yl(debh)
  930. return A1, A2, A3, A4, A5, A6, A7, 40
  931. elif zhuanye == 50: ## xiushan tujian
  932. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_xstj(debh)
  933. if A1:
  934. return A1, A2, A3, A4, A5, A6, A7, 50
  935. else:
  936. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_tj(debh)
  937. return A1, A2, A3, A4,A5, A6, A7, 10
  938. else:
  939. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_xsaz(debh)
  940. if A1:
  941. return A1, A2, A3, A4, A5, A6, A7, 60
  942. else:
  943. A1, A2, A3, A4, A5, A6, A7 = getSingleDeXilie_az(debh)
  944. return A1, A2, A3, A4,A5, A6, A7, 30
  945. def getSingleDeXilie_xsaz(debh):
  946. id = None
  947. bz_selected = []
  948. bz_selected2 = []
  949. if "附注" in debh:
  950. position = debh.find("附注")
  951. debh = debh[:position]
  952. if "*" in debh:
  953. position = debh.find("*")
  954. debh = debh[:position]
  955. if debh.endswith("换"):
  956. debh = debh[:-1]
  957. if "[" in debh:
  958. position = debh.find("[")
  959. debh = debh[:position-1]
  960. gj = pd.read_csv("de/xsaz/JD_DanWeiGJ.csv")
  961. filtered = gj[gj["DEBH"]==debh]
  962. print(filtered)
  963. if len(filtered) > 0:
  964. index = (filtered.iloc[0]["YSDELBH"])
  965. shu = pd.read_csv("de/xsaz/JD_DingEShu.csv")
  966. hit = shu[shu["zjh"]==index]
  967. if len(hit) > 0:
  968. id = hit.iloc[0]["ID"]
  969. beizhu = str(filtered.iloc[0]["BZBH"])
  970. if 'nan' in beizhu:
  971. pass
  972. else:
  973. beizhus = beizhu.split(";")
  974. print(beizhus)
  975. bzfile = pd.read_csv("de/xsaz/JD_BeiZhuZK.csv")
  976. bzfile2 = pd.read_csv("de/xsaz/JD_BeiZhuFK.csv", dtype=str)
  977. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  978. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  979. else:
  980. return None, None, None, None, None, None, None
  981. ####rengong
  982. rgde = []
  983. rg = pd.read_csv("de/xsaz/JD_GuJiaRG.csv")
  984. filtered1 = rg[rg["DEBH"]==debh]
  985. for i in range(len(filtered1)):
  986. rgde_ = {}
  987. gr = filtered1.iloc[i]["RGR"]##gongri
  988. gf = filtered1.iloc[i]["RGF"]##gongfei
  989. rcjID = filtered1.iloc[i]["RcjID"]
  990. detail = pd.read_csv("de/xsaz/JD_CaiLiaoK.csv")
  991. filtered2 = detail[detail["RcjID"]==rcjID]
  992. if len(filtered2) > 0:
  993. CLBH = filtered2.iloc[0]["CLBH"]
  994. CLMC = filtered2.iloc[0]["CLMC"]
  995. JLDW = filtered2.iloc[0]["JLDW"]
  996. YSJG = filtered2.iloc[0]["YSJG"]
  997. rgde_["CLBH"] = CLBH
  998. rgde_["CLMC"] = CLMC
  999. rgde_["JLDW"] = JLDW
  1000. rgde_["YSJG"] = YSJG.item()
  1001. rgde_["gr"] = gr.item()
  1002. rgde_["gf"] = gf.item()
  1003. rgde.append(rgde_)
  1004. ##print(rgde)
  1005. ####jixie
  1006. jxde = []
  1007. jx = pd.read_csv("de/xsaz/JD_GuJiaJX.csv")
  1008. filtered1 = jx[jx["DEBH"]==debh]
  1009. for i in range(len(filtered1)):
  1010. jxde_ = {}
  1011. sl = filtered1.iloc[i]["SL"]##shuliang
  1012. hj = filtered1.iloc[i]["HJ"]##hejia
  1013. rcjID = filtered1.iloc[i]["RcjID"]
  1014. detail = pd.read_csv("de/xsaz/JD_JiXieK.csv")
  1015. filtered2 = detail[detail["RcjID"]==rcjID]
  1016. if len(filtered2) > 0:
  1017. jxbh = filtered2.iloc[0]["jxbh"]
  1018. jxmc = filtered2.iloc[0]["jxmc"]
  1019. DW = filtered2.iloc[0]["DW"]
  1020. tbdj = filtered2.iloc[0]["tbdj"]
  1021. jxde_["jxbh"] = jxbh
  1022. jxde_["jxmc"] = jxmc
  1023. jxde_["DW"] = DW
  1024. jxde_["tbdj"] = tbdj.item()
  1025. jxde_["sl"] = sl.item()
  1026. jxde_["hj"] = hj.item()
  1027. jxde.append(jxde_)
  1028. ####cailiao
  1029. clde = []
  1030. cl = pd.read_csv("de/xsaz/JD_GuJiaCL.csv")
  1031. filtered1 = cl[cl["DEBH"]==debh]
  1032. for i in range(len(filtered1)):
  1033. clde_ = {}
  1034. SL = filtered1.iloc[i]["SL"]##shuliang
  1035. HJ = filtered1.iloc[i]["HJ"]##hejia
  1036. rcjID = filtered1.iloc[i]["RcjID"]
  1037. detail = pd.read_csv("de/xsaz/JD_CaiLiaoK.csv")
  1038. filtered2 = detail[detail["RcjID"]==rcjID]
  1039. if len(filtered2) > 0:
  1040. CLBH = filtered2.iloc[0]["CLBH"]
  1041. CLMC = filtered2.iloc[0]["CLMC"]
  1042. JLDW = filtered2.iloc[0]["JLDW"]
  1043. YSJG = filtered2.iloc[0]["YSJG"]
  1044. clde_["CLBH"] = CLBH
  1045. clde_["CLMC"] = CLMC
  1046. clde_["JLDW"] = JLDW
  1047. clde_["YSJG"] = YSJG.item()
  1048. clde_["SL"] = SL.item()
  1049. clde_["HJ"] = HJ.item()
  1050. clde.append(clde_)
  1051. else:
  1052. detail = pd.read_csv("de/xsaz/JD_PeiBi.csv")
  1053. filtered2 = detail[detail["RcjID"]==rcjID]
  1054. if len(filtered2) > 0:
  1055. CLBH = filtered2.iloc[0]["PBBH"]
  1056. CLMC = filtered2.iloc[0]["PBMC"]
  1057. JLDW = filtered2.iloc[0]["DW"]
  1058. YSJG = filtered2.iloc[0]["PBDJ"]
  1059. clde_["CLBH"] = CLBH.item()
  1060. clde_["CLMC"] = CLMC
  1061. clde_["JLDW"] = JLDW
  1062. clde_["YSJG"] = YSJG.item()
  1063. clde_["SL"] = SL.item()
  1064. clde_["HJ"] = HJ.item()
  1065. clde.append(clde_)
  1066. 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
  1067. def getSingleDeXilie_xstj(debh):
  1068. id = None
  1069. bz_selected = []
  1070. bz_selected2 = []
  1071. if "附注" in debh:
  1072. position = debh.find("附注")
  1073. debh = debh[:position]
  1074. if "*" in debh:
  1075. position = debh.find("*")
  1076. debh = debh[:position]
  1077. if debh.endswith("换"):
  1078. debh = debh[:-1]
  1079. if "[" in debh:
  1080. position = debh.find("[")
  1081. debh = debh[:position-1]
  1082. gj = pd.read_csv("de/xstj/JD_DanWeiGJ.csv")
  1083. filtered = gj[gj["DEBH"]==debh]
  1084. print(filtered)
  1085. if len(filtered) > 0:
  1086. index = (filtered.iloc[0]["YSDELBH"])
  1087. shu = pd.read_csv("de/xstj/JD_DingEShu.csv")
  1088. hit = shu[shu["zjh"]==index]
  1089. if len(hit) > 0:
  1090. id = hit.iloc[0]["ID"]
  1091. beizhu = str(filtered.iloc[0]["BZBH"])
  1092. if 'nan' in beizhu:
  1093. pass
  1094. else:
  1095. beizhus = beizhu.split(";")
  1096. print(beizhus)
  1097. bzfile = pd.read_csv("de/xstj/JD_BeiZhuZK.csv")
  1098. bzfile2 = pd.read_csv("de/xstj/JD_BeiZhuFK.csv", dtype=str)
  1099. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1100. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1101. else:
  1102. return None, None, None, None, None, None, None
  1103. ####rengong
  1104. rgde = []
  1105. rg = pd.read_csv("de/xstj/JD_GuJiaRG.csv")
  1106. filtered1 = rg[rg["DEBH"]==debh]
  1107. for i in range(len(filtered1)):
  1108. rgde_ = {}
  1109. gr = filtered1.iloc[i]["RGR"]##gongri
  1110. gf = filtered1.iloc[i]["RGF"]##gongfei
  1111. rcjID = filtered1.iloc[i]["RcjID"]
  1112. detail = pd.read_csv("de/xstj/JD_CaiLiaoK.csv")
  1113. filtered2 = detail[detail["RcjID"]==rcjID]
  1114. if len(filtered2) > 0:
  1115. CLBH = filtered2.iloc[0]["CLBH"]
  1116. CLMC = filtered2.iloc[0]["CLMC"]
  1117. JLDW = filtered2.iloc[0]["JLDW"]
  1118. YSJG = filtered2.iloc[0]["YSJG"]
  1119. rgde_["CLBH"] = CLBH
  1120. rgde_["CLMC"] = CLMC
  1121. rgde_["JLDW"] = JLDW
  1122. rgde_["YSJG"] = YSJG.item()
  1123. rgde_["gr"] = gr.item()
  1124. rgde_["gf"] = gf.item()
  1125. rgde.append(rgde_)
  1126. ##print(rgde)
  1127. ####jixie
  1128. jxde = []
  1129. jx = pd.read_csv("de/xstj/JD_GuJiaJX.csv")
  1130. filtered1 = jx[jx["DEBH"]==debh]
  1131. for i in range(len(filtered1)):
  1132. jxde_ = {}
  1133. sl = filtered1.iloc[i]["SL"]##shuliang
  1134. hj = filtered1.iloc[i]["HJ"]##hejia
  1135. rcjID = filtered1.iloc[i]["RcjID"]
  1136. detail = pd.read_csv("de/xstj/JD_JiXieK.csv")
  1137. filtered2 = detail[detail["RcjID"]==rcjID]
  1138. if len(filtered2) > 0:
  1139. jxbh = filtered2.iloc[0]["jxbh"]
  1140. jxmc = filtered2.iloc[0]["jxmc"]
  1141. DW = filtered2.iloc[0]["DW"]
  1142. tbdj = filtered2.iloc[0]["tbdj"]
  1143. jxde_["jxbh"] = jxbh
  1144. jxde_["jxmc"] = jxmc
  1145. jxde_["DW"] = DW
  1146. jxde_["tbdj"] = tbdj.item()
  1147. jxde_["sl"] = sl.item()
  1148. jxde_["hj"] = hj.item()
  1149. jxde.append(jxde_)
  1150. ####cailiao
  1151. clde = []
  1152. cl = pd.read_csv("de/xstj/JD_GuJiaCL.csv")
  1153. filtered1 = cl[cl["DEBH"]==debh]
  1154. for i in range(len(filtered1)):
  1155. clde_ = {}
  1156. SL = filtered1.iloc[i]["SL"]##shuliang
  1157. HJ = filtered1.iloc[i]["HJ"]##hejia
  1158. rcjID = filtered1.iloc[i]["RcjID"]
  1159. detail = pd.read_csv("de/xstj/JD_CaiLiaoK.csv")
  1160. filtered2 = detail[detail["RcjID"]==rcjID]
  1161. if len(filtered2) > 0:
  1162. CLBH = filtered2.iloc[0]["CLBH"]
  1163. CLMC = filtered2.iloc[0]["CLMC"]
  1164. JLDW = filtered2.iloc[0]["JLDW"]
  1165. YSJG = filtered2.iloc[0]["YSJG"]
  1166. clde_["CLBH"] = CLBH
  1167. clde_["CLMC"] = CLMC
  1168. clde_["JLDW"] = JLDW
  1169. clde_["YSJG"] = YSJG.item()
  1170. clde_["SL"] = SL.item()
  1171. clde_["HJ"] = HJ.item()
  1172. clde.append(clde_)
  1173. else:
  1174. detail = pd.read_csv("de/xstj/JD_PeiBi.csv")
  1175. filtered2 = detail[detail["RcjID"]==rcjID]
  1176. if len(filtered2) > 0:
  1177. CLBH = filtered2.iloc[0]["PBBH"]
  1178. CLMC = filtered2.iloc[0]["PBMC"]
  1179. JLDW = filtered2.iloc[0]["DW"]
  1180. YSJG = filtered2.iloc[0]["PBDJ"]
  1181. clde_["CLBH"] = CLBH.item()
  1182. clde_["CLMC"] = CLMC
  1183. clde_["JLDW"] = JLDW
  1184. clde_["YSJG"] = YSJG.item()
  1185. clde_["SL"] = SL.item()
  1186. clde_["HJ"] = HJ.item()
  1187. clde.append(clde_)
  1188. 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
  1189. def getSingleDeXilie_yl(debh):
  1190. id = None
  1191. bz_selected = []
  1192. bz_selected2 = []
  1193. if "附注" in debh:
  1194. position = debh.find("附注")
  1195. debh = debh[:position]
  1196. if "*" in debh:
  1197. position = debh.find("*")
  1198. debh = debh[:position]
  1199. if debh.endswith("换"):
  1200. debh = debh[:-1]
  1201. if "[" in debh:
  1202. position = debh.find("[")
  1203. debh = debh[:position-1]
  1204. gj = pd.read_csv("de/yl/JD_DanWeiGJ.csv")
  1205. filtered = gj[gj["DEBH"]==debh]
  1206. print(filtered)
  1207. if len(filtered) > 0:
  1208. index = (filtered.iloc[0]["YSDELBH"])
  1209. shu = pd.read_csv("de/yl/JD_DingEShu.csv")
  1210. hit = shu[shu["zjh"]==index]
  1211. if len(hit) > 0:
  1212. id = hit.iloc[0]["ID"]
  1213. beizhu = str(filtered.iloc[0]["BZBH"])
  1214. if 'nan' in beizhu:
  1215. pass
  1216. else:
  1217. beizhus = beizhu.split(";")
  1218. print(beizhus)
  1219. bzfile = pd.read_csv("de/yl/JD_BeiZhuZK.csv")
  1220. bzfile2 = pd.read_csv("de/yl/JD_BeiZhuFK.csv", dtype=str)
  1221. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1222. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1223. else:
  1224. return None, None, None, None, None, None, None
  1225. ####rengong
  1226. rgde = []
  1227. rg = pd.read_csv("de/yl/JD_GuJiaRG.csv")
  1228. filtered1 = rg[rg["DEBH"]==debh]
  1229. for i in range(len(filtered1)):
  1230. rgde_ = {}
  1231. gr = filtered1.iloc[i]["RGR"]##gongri
  1232. gf = filtered1.iloc[i]["RGF"]##gongfei
  1233. rcjID = filtered1.iloc[i]["RcjID"]
  1234. detail = pd.read_csv("de/yl/JD_CaiLiaoK.csv")
  1235. filtered2 = detail[detail["RcjID"]==rcjID]
  1236. if len(filtered2) > 0:
  1237. CLBH = filtered2.iloc[0]["CLBH"]
  1238. CLMC = filtered2.iloc[0]["CLMC"]
  1239. JLDW = filtered2.iloc[0]["JLDW"]
  1240. YSJG = filtered2.iloc[0]["YSJG"]
  1241. rgde_["CLBH"] = CLBH
  1242. rgde_["CLMC"] = CLMC
  1243. rgde_["JLDW"] = JLDW
  1244. rgde_["YSJG"] = YSJG.item()
  1245. rgde_["gr"] = gr.item()
  1246. rgde_["gf"] = gf.item()
  1247. rgde.append(rgde_)
  1248. ##print(rgde)
  1249. ####jixie
  1250. jxde = []
  1251. jx = pd.read_csv("de/yl/JD_GuJiaJX.csv")
  1252. filtered1 = jx[jx["DEBH"]==debh]
  1253. for i in range(len(filtered1)):
  1254. jxde_ = {}
  1255. sl = filtered1.iloc[i]["SL"]##shuliang
  1256. hj = filtered1.iloc[i]["HJ"]##hejia
  1257. rcjID = filtered1.iloc[i]["RcjID"]
  1258. detail = pd.read_csv("de/yl/JD_JiXieK.csv")
  1259. filtered2 = detail[detail["RcjID"]==rcjID]
  1260. if len(filtered2) > 0:
  1261. jxbh = filtered2.iloc[0]["jxbh"]
  1262. jxmc = filtered2.iloc[0]["jxmc"]
  1263. DW = filtered2.iloc[0]["DW"]
  1264. tbdj = filtered2.iloc[0]["tbdj"]
  1265. jxde_["jxbh"] = jxbh
  1266. jxde_["jxmc"] = jxmc
  1267. jxde_["DW"] = DW
  1268. jxde_["tbdj"] = tbdj.item()
  1269. jxde_["sl"] = sl.item()
  1270. jxde_["hj"] = hj.item()
  1271. jxde.append(jxde_)
  1272. ####cailiao
  1273. clde = []
  1274. cl = pd.read_csv("de/yl/JD_GuJiaCL.csv")
  1275. filtered1 = cl[cl["DEBH"]==debh]
  1276. for i in range(len(filtered1)):
  1277. clde_ = {}
  1278. SL = filtered1.iloc[i]["SL"]##shuliang
  1279. HJ = filtered1.iloc[i]["HJ"]##hejia
  1280. rcjID = filtered1.iloc[i]["RcjID"]
  1281. detail = pd.read_csv("de/yl/JD_CaiLiaoK.csv")
  1282. filtered2 = detail[detail["RcjID"]==rcjID]
  1283. if len(filtered2) > 0:
  1284. CLBH = filtered2.iloc[0]["CLBH"]
  1285. CLMC = filtered2.iloc[0]["CLMC"]
  1286. JLDW = filtered2.iloc[0]["JLDW"]
  1287. YSJG = filtered2.iloc[0]["YSJG"]
  1288. clde_["CLBH"] = CLBH
  1289. clde_["CLMC"] = CLMC
  1290. clde_["JLDW"] = JLDW
  1291. clde_["YSJG"] = YSJG.item()
  1292. clde_["SL"] = SL.item()
  1293. clde_["HJ"] = HJ.item()
  1294. clde.append(clde_)
  1295. else:
  1296. detail = pd.read_csv("de/yl/JD_PeiBi.csv")
  1297. filtered2 = detail[detail["RcjID"]==rcjID]
  1298. if len(filtered2) > 0:
  1299. CLBH = filtered2.iloc[0]["PBBH"]
  1300. CLMC = filtered2.iloc[0]["PBMC"]
  1301. JLDW = filtered2.iloc[0]["DW"]
  1302. YSJG = filtered2.iloc[0]["PBDJ"]
  1303. clde_["CLBH"] = CLBH.item()
  1304. clde_["CLMC"] = CLMC
  1305. clde_["JLDW"] = JLDW
  1306. clde_["YSJG"] = YSJG.item()
  1307. clde_["SL"] = SL.item()
  1308. clde_["HJ"] = HJ.item()
  1309. clde.append(clde_)
  1310. 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
  1311. def getSingleDeXilie_az(debh):
  1312. id = None
  1313. bz_selected = []
  1314. bz_selected2 = []
  1315. if "附注" in debh:
  1316. position = debh.find("附注")
  1317. debh = debh[:position]
  1318. if "*" in debh:
  1319. position = debh.find("*")
  1320. debh = debh[:position]
  1321. if debh.endswith("换"):
  1322. debh = debh[:-1]
  1323. if "[" in debh:
  1324. position = debh.find("[")
  1325. debh = debh[:position-1]
  1326. gj = pd.read_csv("de/az/JD_DanWeiGJ.csv")
  1327. filtered = gj[gj["DEBH"]==debh]
  1328. print(filtered)
  1329. if len(filtered) > 0:
  1330. index = (filtered.iloc[0]["YSDELBH"])
  1331. shu = pd.read_csv("de/az/JD_DingEShu.csv")
  1332. hit = shu[shu["zjh"]==index]
  1333. if len(hit) > 0:
  1334. id = hit.iloc[0]["ID"]
  1335. beizhu = str(filtered.iloc[0]["BZBH"])
  1336. if 'nan' in beizhu:
  1337. pass
  1338. else:
  1339. beizhus = beizhu.split(";")
  1340. print(beizhus)
  1341. bzfile = pd.read_csv("de/az/JD_BeiZhuZK.csv")
  1342. bzfile2 = pd.read_csv("de/az/JD_BeiZhuFK.csv", dtype=str)
  1343. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1344. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1345. else:
  1346. return None, None, None, None, None, None, None
  1347. ####rengong
  1348. rgde = []
  1349. rg = pd.read_csv("de/az/JD_GuJiaRG.csv")
  1350. filtered1 = rg[rg["DEBH"]==debh]
  1351. for i in range(len(filtered1)):
  1352. rgde_ = {}
  1353. gr = filtered1.iloc[i]["RGR"]##gongri
  1354. gf = filtered1.iloc[i]["RGF"]##gongfei
  1355. rcjID = filtered1.iloc[i]["RcjID"]
  1356. detail = pd.read_csv("de/az/JD_CaiLiaoK.csv")
  1357. filtered2 = detail[detail["RcjID"]==rcjID]
  1358. if len(filtered2) > 0:
  1359. CLBH = filtered2.iloc[0]["CLBH"]
  1360. CLMC = filtered2.iloc[0]["CLMC"]
  1361. JLDW = filtered2.iloc[0]["JLDW"]
  1362. YSJG = filtered2.iloc[0]["YSJG"]
  1363. rgde_["CLBH"] = CLBH
  1364. rgde_["CLMC"] = CLMC
  1365. rgde_["JLDW"] = JLDW
  1366. rgde_["YSJG"] = YSJG
  1367. rgde_["gr"] = gr
  1368. rgde_["gf"] = gf
  1369. rgde.append(rgde_)
  1370. ##print(rgde)
  1371. ####jixie
  1372. jxde = []
  1373. jx = pd.read_csv("de/az/JD_GuJiaJX.csv")
  1374. filtered1 = jx[jx["DEBH"]==debh]
  1375. for i in range(len(filtered1)):
  1376. jxde_ = {}
  1377. sl = filtered1.iloc[i]["SL"]##shuliang
  1378. hj = filtered1.iloc[i]["HJ"]##hejia
  1379. rcjID = filtered1.iloc[i]["RcjID"]
  1380. detail = pd.read_csv("de/az/JD_JiXieK.csv")
  1381. filtered2 = detail[detail["RcjID"]==rcjID]
  1382. if len(filtered2) > 0:
  1383. jxbh = filtered2.iloc[0]["jxbh"]
  1384. jxmc = filtered2.iloc[0]["jxmc"]
  1385. DW = filtered2.iloc[0]["DW"]
  1386. tbdj = filtered2.iloc[0]["tbdj"]
  1387. jxde_["jxbh"] = jxbh
  1388. jxde_["jxmc"] = jxmc
  1389. jxde_["DW"] = DW
  1390. jxde_["tbdj"] = tbdj
  1391. jxde_["sl"] = sl
  1392. jxde_["hj"] = hj
  1393. jxde.append(jxde_)
  1394. ####cailiao
  1395. clde = []
  1396. cl = pd.read_csv("de/az/JD_GuJiaCL.csv")
  1397. filtered1 = cl[cl["DEBH"]==debh]
  1398. for i in range(len(filtered1)):
  1399. clde_ = {}
  1400. SL = filtered1.iloc[i]["SL"]##shuliang
  1401. HJ = filtered1.iloc[i]["HJ"]##hejia
  1402. rcjID = filtered1.iloc[i]["RcjID"]
  1403. detail = pd.read_csv("de/az/JD_CaiLiaoK.csv")
  1404. filtered2 = detail[detail["RcjID"]==rcjID]
  1405. if len(filtered2) > 0:
  1406. CLBH = filtered2.iloc[0]["CLBH"]
  1407. CLMC = filtered2.iloc[0]["CLMC"]
  1408. JLDW = filtered2.iloc[0]["JLDW"]
  1409. YSJG = filtered2.iloc[0]["YSJG"]
  1410. clde_["CLBH"] = CLBH
  1411. clde_["CLMC"] = CLMC
  1412. clde_["JLDW"] = JLDW
  1413. clde_["YSJG"] = YSJG
  1414. clde_["SL"] = SL
  1415. clde_["HJ"] = HJ
  1416. clde.append(clde_)
  1417. else:
  1418. detail = pd.read_csv("de/az/JD_PeiBi.csv")
  1419. filtered2 = detail[detail["RcjID"]==rcjID]
  1420. if len(filtered2) > 0:
  1421. CLBH = filtered2.iloc[0]["PBBH"]
  1422. CLMC = filtered2.iloc[0]["PBMC"]
  1423. JLDW = filtered2.iloc[0]["DW"]
  1424. YSJG = filtered2.iloc[0]["PBDJ"]
  1425. clde_["CLBH"] = CLBH
  1426. clde_["CLMC"] = CLMC
  1427. clde_["JLDW"] = JLDW
  1428. clde_["YSJG"] = YSJG
  1429. clde_["SL"] = SL
  1430. clde_["HJ"] = HJ
  1431. clde.append(clde_)
  1432. 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
  1433. def getSingleDeXilie_sz(debh):
  1434. id = None
  1435. bz_selected = []
  1436. bz_selected2 = []
  1437. if "附注" in debh:
  1438. position = debh.find("附注")
  1439. debh = debh[:position]
  1440. if "*" in debh:
  1441. position = debh.find("*")
  1442. debh = debh[:position]
  1443. if debh.endswith("换"):
  1444. debh = debh[:-1]
  1445. if "[" in debh:
  1446. position = debh.find("[")
  1447. debh = debh[:position-1]
  1448. gj = pd.read_csv("de/sz/JD_DanWeiGJ.csv")
  1449. filtered = gj[gj["DEBH"]==debh]
  1450. print(filtered)
  1451. if len(filtered) > 0:
  1452. index = (filtered.iloc[0]["YSDELBH"])
  1453. shu = pd.read_csv("de/sz/JD_DingEShu.csv")
  1454. hit = shu[shu["zjh"]==index]
  1455. if len(hit) > 0:
  1456. id = hit.iloc[0]["ID"]
  1457. beizhu = str(filtered.iloc[0]["BZBH"])
  1458. if 'nan' in beizhu:
  1459. pass
  1460. else:
  1461. beizhus = beizhu.split(";")
  1462. print(beizhus)
  1463. bzfile = pd.read_csv("de/sz/JD_BeiZhuZK.csv")
  1464. bzfile2 = pd.read_csv("de/sz/JD_BeiZhuFK.csv", dtype=str)
  1465. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1466. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1467. else:
  1468. return None, None, None, None, None, None, None
  1469. ####rengong
  1470. rgde = []
  1471. rg = pd.read_csv("de/sz/JD_GuJiaRG.csv")
  1472. filtered1 = rg[rg["DEBH"]==debh]
  1473. for i in range(len(filtered1)):
  1474. rgde_ = {}
  1475. gr = filtered1.iloc[i]["RGR"]##gongri
  1476. gf = filtered1.iloc[i]["RGF"]##gongfei
  1477. rcjID = filtered1.iloc[i]["RcjID"]
  1478. detail = pd.read_csv("de/sz/JD_CaiLiaoK.csv")
  1479. filtered2 = detail[detail["RcjID"]==rcjID]
  1480. if len(filtered2) > 0:
  1481. CLBH = filtered2.iloc[0]["CLBH"]
  1482. CLMC = filtered2.iloc[0]["CLMC"]
  1483. JLDW = filtered2.iloc[0]["JLDW"]
  1484. YSJG = filtered2.iloc[0]["YSJG"]
  1485. rgde_["CLBH"] = CLBH
  1486. rgde_["CLMC"] = CLMC
  1487. rgde_["JLDW"] = JLDW
  1488. rgde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1489. rgde_["gr"] = gr.item() if type(gr) == float64 else gr
  1490. rgde_["gf"] = gf.item() if type(gf) == float64 else gf
  1491. rgde.append(rgde_)
  1492. ##print(rgde)
  1493. ####jixie
  1494. jxde = []
  1495. jx = pd.read_csv("de/sz/JD_GuJiaJX.csv")
  1496. filtered1 = jx[jx["DEBH"]==debh]
  1497. for i in range(len(filtered1)):
  1498. jxde_ = {}
  1499. sl = filtered1.iloc[i]["SL"]##shuliang
  1500. hj = filtered1.iloc[i]["HJ"]##hejia
  1501. rcjID = filtered1.iloc[i]["RcjID"]
  1502. detail = pd.read_csv("de/sz/JD_JiXieK.csv")
  1503. filtered2 = detail[detail["RcjID"]==rcjID]
  1504. if len(filtered2) > 0:
  1505. jxbh = filtered2.iloc[0]["jxbh"]
  1506. jxmc = filtered2.iloc[0]["jxmc"]
  1507. DW = filtered2.iloc[0]["DW"]
  1508. tbdj = filtered2.iloc[0]["tbdj"]
  1509. jxde_["jxbh"] = jxbh
  1510. jxde_["jxmc"] = jxmc
  1511. jxde_["DW"] = DW
  1512. jxde_["tbdj"] = tbdj.item() if type(tbdj) == float64 else tbdj
  1513. jxde_["sl"] = sl.item() if type(sl) == float64 else sl
  1514. jxde_["hj"] = hj.item() if type(hj) == float64 else hj
  1515. jxde.append(jxde_)
  1516. ####cailiao
  1517. clde = []
  1518. cl = pd.read_csv("de/sz/JD_GuJiaCL.csv")
  1519. filtered1 = cl[cl["DEBH"]==debh]
  1520. for i in range(len(filtered1)):
  1521. clde_ = {}
  1522. SL = filtered1.iloc[i]["SL"]##shuliang
  1523. HJ = filtered1.iloc[i]["HJ"]##hejia
  1524. rcjID = filtered1.iloc[i]["RcjID"]
  1525. detail = pd.read_csv("de/sz/JD_CaiLiaoK.csv")
  1526. filtered2 = detail[detail["RcjID"]==rcjID]
  1527. if len(filtered2) > 0:
  1528. CLBH = filtered2.iloc[0]["CLBH"]
  1529. CLMC = filtered2.iloc[0]["CLMC"]
  1530. JLDW = filtered2.iloc[0]["JLDW"]
  1531. YSJG = filtered2.iloc[0]["YSJG"]
  1532. clde_["CLBH"] = CLBH
  1533. clde_["CLMC"] = CLMC
  1534. clde_["JLDW"] = JLDW
  1535. clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1536. clde_["SL"] = SL.item() if type(SL) == float64 else SL
  1537. clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
  1538. clde.append(clde_)
  1539. else:
  1540. detail = pd.read_csv("de/sz/JD_PeiBi.csv")
  1541. filtered2 = detail[detail["RcjID"]==rcjID]
  1542. if len(filtered2) > 0:
  1543. CLBH = filtered2.iloc[0]["PBBH"]
  1544. CLMC = filtered2.iloc[0]["PBMC"]
  1545. JLDW = filtered2.iloc[0]["DW"]
  1546. YSJG = filtered2.iloc[0]["PBDJ"]
  1547. clde_["CLBH"] = CLBH
  1548. clde_["CLMC"] = CLMC
  1549. clde_["JLDW"] = JLDW
  1550. clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1551. clde_["SL"] = SL.item() if type(SL) == float64 else SL
  1552. clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
  1553. clde.append(clde_)
  1554. 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
  1555. def getSingleDeXilie_tj(debh):
  1556. id = None
  1557. bz_selected = []
  1558. bz_selected2 = []
  1559. if "附注" in debh:
  1560. position = debh.find("附注")
  1561. debh = debh[:position]
  1562. if "*" in debh:
  1563. position = debh.find("*")
  1564. debh = debh[:position]
  1565. if debh.endswith("换"):
  1566. debh = debh[:-1]
  1567. if "[" in debh:
  1568. position = debh.find("[")
  1569. debh = debh[:position-1]
  1570. gj = pd.read_csv("de/tj/JD_DanWeiGJ.csv")
  1571. filtered = gj[gj["DEBH"]==debh]
  1572. print(filtered)
  1573. if len(filtered) > 0:
  1574. index = int(filtered.iloc[0]["YSDELBH"])
  1575. shu = pd.read_csv("de/tj/JD_DingEShu.csv")
  1576. hit = shu[shu["zjh"]==index]
  1577. if len(hit) > 0:
  1578. id = hit.iloc[0]["ID"]
  1579. beizhu = str(filtered.iloc[0]["BZBH"])
  1580. if 'nan' in beizhu:
  1581. pass
  1582. else:
  1583. beizhus = beizhu.split(";")
  1584. print(beizhus)
  1585. bzfile = pd.read_csv("de/tj/JD_BeiZhuZK.csv")
  1586. bzfile2 = pd.read_csv("de/tj/JD_BeiZhuFK.csv", dtype=str)
  1587. bz_selected = bzfile[bzfile["BZBH"].isin(beizhus)]
  1588. bz_selected2 = bzfile2[bzfile2["BZBH"].isin(beizhus)]
  1589. else:
  1590. return None, None, None, None, None, None, None
  1591. ####rengong
  1592. rgde = []
  1593. rg = pd.read_csv("de/tj/JD_GuJiaRG.csv")
  1594. filtered1 = rg[rg["DEBH"]==debh]
  1595. for i in range(len(filtered1)):
  1596. rgde_ = {}
  1597. gr = filtered1.iloc[i]["RGR"]##gongri
  1598. gf = filtered1.iloc[i]["RGF"]##gongfei
  1599. rcjID = filtered1.iloc[i]["RcjID"]
  1600. detail = pd.read_csv("de/tj/JD_CaiLiaoK.csv")
  1601. filtered2 = detail[detail["RcjID"]==rcjID]
  1602. if len(filtered2) > 0:
  1603. CLBH = filtered2.iloc[0]["CLBH"]
  1604. CLMC = filtered2.iloc[0]["CLMC"]
  1605. JLDW = filtered2.iloc[0]["JLDW"]
  1606. YSJG = filtered2.iloc[0]["YSJG"]
  1607. rgde_["CLBH"] = CLBH
  1608. rgde_["CLMC"] = CLMC
  1609. rgde_["JLDW"] = JLDW
  1610. rgde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1611. rgde_["gr"] = gr.item() if type(gr) == float64 else gr
  1612. rgde_["gf"] = gf.item() if type(gf) == float64 else gf
  1613. rgde.append(rgde_)
  1614. ##print(rgde)
  1615. ####jixie
  1616. jxde = []
  1617. jx = pd.read_csv("de/tj/JD_GuJiaJX.csv")
  1618. filtered1 = jx[jx["DEBH"]==debh]
  1619. for i in range(len(filtered1)):
  1620. jxde_ = {}
  1621. sl = filtered1.iloc[i]["SL"]##shuliang
  1622. hj = filtered1.iloc[i]["HJ"]##hejia
  1623. rcjID = filtered1.iloc[i]["RcjID"]
  1624. detail = pd.read_csv("de/tj/JD_JiXieK.csv")
  1625. filtered2 = detail[detail["RcjID"]==rcjID]
  1626. if len(filtered2) > 0:
  1627. jxbh = filtered2.iloc[0]["jxbh"]
  1628. jxmc = filtered2.iloc[0]["jxmc"]
  1629. DW = filtered2.iloc[0]["DW"]
  1630. tbdj = filtered2.iloc[0]["tbdj"]
  1631. jxde_["jxbh"] = jxbh
  1632. jxde_["jxmc"] = jxmc
  1633. jxde_["DW"] = DW
  1634. jxde_["tbdj"] = tbdj.item() if type(tbdj) == float64 else tbdj
  1635. jxde_["sl"] = sl.item() if type(sl) == float64 else sl
  1636. jxde_["hj"] = hj.item() if type(hj) == float64 else hj
  1637. jxde.append(jxde_)
  1638. ####cailiao
  1639. clde = []
  1640. cl = pd.read_csv("de/tj/JD_GuJiaCL.csv")
  1641. filtered1 = cl[cl["DEBH"]==debh]
  1642. for i in range(len(filtered1)):
  1643. clde_ = {}
  1644. SL = filtered1.iloc[i]["SL"]##shuliang
  1645. HJ = filtered1.iloc[i]["HJ"]##hejia
  1646. rcjID = filtered1.iloc[i]["RcjID"]
  1647. detail = pd.read_csv("de/tj/JD_CaiLiaoK.csv")
  1648. filtered2 = detail[detail["RcjID"]==rcjID]
  1649. if len(filtered2) > 0:
  1650. CLBH = filtered2.iloc[0]["CLBH"]
  1651. CLMC = filtered2.iloc[0]["CLMC"]
  1652. JLDW = filtered2.iloc[0]["JLDW"]
  1653. YSJG = filtered2.iloc[0]["YSJG"]
  1654. clde_["CLBH"] = CLBH
  1655. clde_["CLMC"] = CLMC
  1656. clde_["JLDW"] = JLDW
  1657. clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1658. clde_["SL"] = SL.item() if type(SL) == float64 else SL
  1659. clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
  1660. clde.append(clde_)
  1661. else:
  1662. detail = pd.read_csv("de/tj/JD_PeiBi.csv")
  1663. filtered2 = detail[detail["RcjID"]==rcjID]
  1664. if len(filtered2) > 0:
  1665. CLBH = filtered2.iloc[0]["PBBH"]
  1666. CLMC = filtered2.iloc[0]["PBMC"]
  1667. JLDW = filtered2.iloc[0]["DW"]
  1668. YSJG = filtered2.iloc[0]["PBDJ"]
  1669. clde_["CLBH"] = CLBH
  1670. clde_["CLMC"] = CLMC
  1671. clde_["JLDW"] = JLDW
  1672. clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
  1673. clde_["SL"] = SL.item() if type(SL) == float64 else SL
  1674. clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
  1675. clde.append(clde_)
  1676. 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
  1677. def getDwgc(root, id, Zylb):
  1678. result = []
  1679. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  1680. item = None
  1681. for child in root:
  1682. if child.tag == "Dxgcxx":
  1683. for child1 in child:
  1684. Dwgcbh = child1.attrib["Dwgcbh"]
  1685. if Dwgcbh == id:
  1686. item = child1
  1687. break
  1688. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  1689. id = id + "Zylb" + Zylb
  1690. for child in item:
  1691. if child.tag == "Fywj":
  1692. result.append({"id": id + "bao jia hui zong", "label": "报价汇总表"})
  1693. elif child.tag == "Gfsj":
  1694. result.append({"id": id + "gui fei shui jin", "label": "规费税金"})
  1695. elif child.tag == "Qdxm":
  1696. result.append({"id": id + "qing dan xiang mu", "label": "清单项目"})
  1697. elif child.tag == "Csxm":
  1698. result.append({"id": id + "cuo shi xiang mu", "label": "措施项目"})
  1699. elif child.tag == "Qtxm":
  1700. result.append({"id": id +"qi ta xiang mu", "label": "其他项目"})
  1701. elif child.tag == "Zlje":
  1702. result.append({"id": id +"zan lie jin e", "label": "暂列金额"})
  1703. elif child.tag == "Clzg":
  1704. result.append({"id": id +"cai liao zan gu jia", "label": "材料暂估价"})
  1705. elif child.tag == "Zygczg":
  1706. result.append({"id": id + "zhuan ye gong cheng zan gu jia", "label": "专业工程暂估价"})
  1707. elif child.tag == "Jrg":
  1708. result.append({"id": id + "ji ri gong", "label": "计日工"})
  1709. elif child.tag == "Zcbfwf":
  1710. result.append({"id": id + "zong cheng bao fu wu fei", "label": "总承包服务费"})
  1711. elif child.tag == "Zjxmjdkzffj":
  1712. result.append({"id": id + "zong jia xiang mu jin du kuan zhi fu fen jie", "label": "总价项目进度款支付分解"})
  1713. elif child.tag == "Fbrgycl":
  1714. result.append({"id": id + "fa bao ren gong ying cai liao", "label": "发包人供应材料"})
  1715. elif child.tag == "Cbrgycl":
  1716. result.append({"id": id + "cheng bao ren gong ying cai liao", "label": "承包人供应材料"})
  1717. elif child.tag == "Rcjhz":
  1718. result.append({"id": id + "ren cai ji hui zong", "label": "人材机汇总"})
  1719. else:
  1720. print(child.tag)
  1721. print("WARNING####################################################################")
  1722. return result