db.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. import xml.etree.ElementTree as ET
  2. from subdir import service
  3. from bson.objectid import ObjectId
  4. import uuid
  5. def getDingercj_(root, bh, bt, qdbm, debm):
  6. result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  7. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
  8. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  9. item = None
  10. for child in root:
  11. if child.tag == "Dxgcxx":
  12. for child1 in child:
  13. Dwgcbh = child1.attrib["Dwgcbh"]
  14. if Dwgcbh == bh:
  15. item = child1
  16. break
  17. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  18. Fywj = None
  19. for child in item:
  20. if child.tag == 'Qdxm':
  21. Fywj= child
  22. break
  23. Rcjhz = None
  24. for child in item:
  25. if child.tag == 'Rcjhz':
  26. Rcjhz = child
  27. break
  28. kv = {}
  29. for entry in Rcjhz:
  30. kv[entry.attrib["RcjId"]]=entry
  31. container = None
  32. for child in Fywj:
  33. ##child is mx
  34. if child.tag == "QdBt":
  35. if child.attrib["Mc"] == bt:
  36. container = child
  37. break
  38. if not container:
  39. container = Fywj
  40. zimu = None
  41. for child in container:
  42. if child.attrib["Qdbm"] == qdbm:
  43. zimu = child
  44. break
  45. box = None
  46. if not zimu:
  47. return result
  48. for child in zimu:
  49. if child.tag == "Qdxdezj":
  50. box = child
  51. break
  52. hlmx_parent = None
  53. for child in box:
  54. if child.attrib["Debm"] == debm:
  55. for grandchild in child:
  56. if grandchild.tag == "Qdxdercjhl":
  57. hlmx_parent = grandchild
  58. for child in hlmx_parent:
  59. result.append([child.attrib["RcjId"],
  60. kv[child.attrib["RcjId"]].attrib["RcjBm"],
  61. kv[child.attrib["RcjId"]].attrib["Mc"],
  62. kv[child.attrib["RcjId"]].attrib["Ggxh"],
  63. kv[child.attrib["RcjId"]].attrib["Dw"],
  64. kv[child.attrib["RcjId"]].attrib["Dj"],
  65. kv[child.attrib["RcjId"]].attrib["Cd"],
  66. kv[child.attrib["RcjId"]].attrib["Gycs"],
  67. kv[child.attrib["RcjId"]].attrib["Rcjlb"],
  68. kv[child.attrib["RcjId"]].attrib["Jgbz"],
  69. child.attrib["Rcjhl"], child.attrib["Rcjhj"], "",
  70. "", "", ""
  71. ])
  72. return result
  73. def getQingdanrcj_(root, bh, bt, bm):
  74. result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  75. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
  76. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  77. item = None
  78. for child in root:
  79. if child.tag == "Dxgcxx":
  80. for child1 in child:
  81. Dwgcbh = child1.attrib["Dwgcbh"]
  82. if Dwgcbh == bh:
  83. item = child1
  84. break
  85. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  86. Fywj = None
  87. for child in item:
  88. if child.tag == 'Qdxm':
  89. Fywj= child
  90. break
  91. Rcjhz = None
  92. for child in item:
  93. if child.tag == 'Rcjhz':
  94. Rcjhz = child
  95. break
  96. kv = {}
  97. for entry in Rcjhz:
  98. kv[entry.attrib["RcjId"]]=entry
  99. container = None
  100. for child in Fywj:
  101. ##child is mx
  102. if child.tag == "QdBt":
  103. if child.attrib["Mc"] == bt:
  104. container = child
  105. break
  106. if not container:
  107. container = Fywj
  108. zimu = None
  109. for child in container:
  110. if child.attrib["Qdbm"] == bm:
  111. zimu = child
  112. break
  113. box = None
  114. if not zimu:
  115. return result
  116. for child in zimu:
  117. if child.tag == "Qdxrcjhl":
  118. box = child
  119. break
  120. for child in box:
  121. result.append([child.attrib["RcjId"],
  122. kv[child.attrib["RcjId"]].attrib["RcjBm"],
  123. kv[child.attrib["RcjId"]].attrib["Mc"],
  124. kv[child.attrib["RcjId"]].attrib["Ggxh"],
  125. kv[child.attrib["RcjId"]].attrib["Dw"],
  126. kv[child.attrib["RcjId"]].attrib["Dj"],
  127. kv[child.attrib["RcjId"]].attrib["Cd"],
  128. kv[child.attrib["RcjId"]].attrib["Gycs"],
  129. kv[child.attrib["RcjId"]].attrib["Rcjlb"],
  130. kv[child.attrib["RcjId"]].attrib["Jgbz"],
  131. child.attrib["Rcjhl"], child.attrib["Rcjhj"], child.attrib["Zgjbz"],
  132. child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"]
  133. ])
  134. return result
  135. def getDjcsDingercj_(root, bh, bt, qdbm, debm):
  136. result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  137. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
  138. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  139. item = None
  140. for child in root:
  141. if child.tag == "Dxgcxx":
  142. for child1 in child:
  143. Dwgcbh = child1.attrib["Dwgcbh"]
  144. if Dwgcbh == bh:
  145. item = child1
  146. break
  147. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  148. Fywj = None
  149. for child in item:
  150. if child.tag == 'Csxm':
  151. Fywj= child
  152. break
  153. Rcjhz = None
  154. for child in item:
  155. if child.tag == 'Rcjhz':
  156. Rcjhz = child
  157. break
  158. kv = {}
  159. for entry in Rcjhz:
  160. kv[entry.attrib["RcjId"]]=entry
  161. container = None
  162. for child in Fywj:
  163. if child.tag == "DjCs":
  164. container = child
  165. break
  166. zimu = None
  167. for child in container:
  168. if child.attrib["Bm"] == qdbm:
  169. zimu = child
  170. break
  171. box = None
  172. if not zimu:
  173. return result
  174. for child in zimu:
  175. if child.tag == "Csxdezj":
  176. box = child
  177. break
  178. hlmx_parent = None
  179. for child in box:
  180. if child.attrib["Debm"] == debm:
  181. for grandchild in child:
  182. if grandchild.tag == "Csxdercjhl":
  183. hlmx_parent = grandchild
  184. for child in hlmx_parent:
  185. result.append([child.attrib["RcjId"],
  186. kv[child.attrib["RcjId"]].attrib["RcjBm"],
  187. kv[child.attrib["RcjId"]].attrib["Mc"],
  188. kv[child.attrib["RcjId"]].attrib["Ggxh"],
  189. kv[child.attrib["RcjId"]].attrib["Dw"],
  190. kv[child.attrib["RcjId"]].attrib["Dj"],
  191. kv[child.attrib["RcjId"]].attrib["Cd"],
  192. kv[child.attrib["RcjId"]].attrib["Gycs"],
  193. kv[child.attrib["RcjId"]].attrib["Rcjlb"],
  194. kv[child.attrib["RcjId"]].attrib["Jgbz"],
  195. child.attrib["Rcjhl"], child.attrib["Rcjhj"], "",
  196. "", "", ""
  197. ])
  198. return result
  199. def getDjcsQingdanrcj_(root, bh, bt, bm):
  200. result = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地",
  201. "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]]
  202. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  203. item = None
  204. for child in root:
  205. if child.tag == "Dxgcxx":
  206. for child1 in child:
  207. Dwgcbh = child1.attrib["Dwgcbh"]
  208. if Dwgcbh == bh:
  209. item = child1
  210. break
  211. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  212. Fywj = None
  213. for child in item:
  214. if child.tag == 'Csxm':
  215. Fywj= child
  216. break
  217. hl_parent = None
  218. for child in Fywj:
  219. if child.tag == "DjCs":
  220. hl_parent = child
  221. Rcjhz = None
  222. for child in item:
  223. if child.tag == 'Rcjhz':
  224. Rcjhz = child
  225. break
  226. kv = {}
  227. for entry in Rcjhz:
  228. kv[entry.attrib["RcjId"]]=entry
  229. zimu = None
  230. for child in hl_parent:
  231. if child.attrib["Bm"] == bm:
  232. zimu = child
  233. break
  234. box = None
  235. if not zimu:
  236. return result
  237. for child in zimu:
  238. if child.tag == "Csxrcjhl":
  239. box = child
  240. break
  241. for child in box:
  242. result.append([child.attrib["RcjId"],
  243. kv[child.attrib["RcjId"]].attrib["RcjBm"],
  244. kv[child.attrib["RcjId"]].attrib["Mc"],
  245. kv[child.attrib["RcjId"]].attrib["Ggxh"],
  246. kv[child.attrib["RcjId"]].attrib["Dw"],
  247. kv[child.attrib["RcjId"]].attrib["Dj"],
  248. kv[child.attrib["RcjId"]].attrib["Cd"],
  249. kv[child.attrib["RcjId"]].attrib["Gycs"],
  250. kv[child.attrib["RcjId"]].attrib["Rcjlb"],
  251. kv[child.attrib["RcjId"]].attrib["Jgbz"],
  252. child.attrib["Rcjhl"], child.attrib["Rcjhj"], child.attrib["Zgjbz"],
  253. child.attrib["Zyclbz"], child.attrib["Zcbz"], child.attrib["Sbbz"]
  254. ])
  255. return result
  256. async def resolve(manager, websocket, data, client):
  257. tree = ET.parse("data/" + data)
  258. root = tree.getroot()
  259. print(root)
  260. Dwgcbh = []
  261. jingjibiao = {}
  262. jingjibiao["BiaoDuanNO"] = root.attrib["BiaoDuanNO"]
  263. jingjibiao["Jsfs"] = root.attrib["Jsfs"]
  264. jingjibiao["Version"] = root.attrib["Version"]
  265. jingjibiao["Xmmc"] = root.attrib["Xmmc"]
  266. jingjibiao["Dxgcxx"] = []
  267. for child in root:
  268. if child.tag == "ZhaoBiaoXx":
  269. jingjibiao["ZhaoBiaoXx"] = {}
  270. jingjibiao["ZhaoBiaoXx"]["BzTime"] = child.attrib["BzTime"]
  271. jingjibiao["ZhaoBiaoXx"]["Bzr"] = child.attrib["Bzr"]
  272. jingjibiao["ZhaoBiaoXx"]["FhTime"] = child.attrib["FhTime"]
  273. jingjibiao["ZhaoBiaoXx"]["Fhr"] = child.attrib["Fhr"]
  274. jingjibiao["ZhaoBiaoXx"]["Zbr"] = child.attrib["Zbr"]
  275. jingjibiao["ZhaoBiaoXx"]["ZbrDb"] = child.attrib["ZbrDb"]
  276. jingjibiao["ZhaoBiaoXx"]["Zxr"] = child.attrib["Zxr"]
  277. jingjibiao["ZhaoBiaoXx"]["ZxrDb"] = child.attrib["ZxrDb"]
  278. elif child.tag == "TouBiaoXx":
  279. jingjibiao["TouBiaoXx"] = {}
  280. jingjibiao["TouBiaoXx"]["Zbr"] = child.attrib["Zbr"]
  281. jingjibiao["TouBiaoXx"]["Tbr"] = child.attrib["Tbr"]
  282. jingjibiao["TouBiaoXx"]["TbrDb"] = child.attrib["TbrDb"]
  283. jingjibiao["TouBiaoXx"]["Bzr"] = child.attrib["Bzr"]
  284. jingjibiao["TouBiaoXx"]["BzTime"] = child.attrib["BzTime"]
  285. jingjibiao["TouBiaoXx"]["Tbzj"] = child.attrib["Tbzj"]
  286. jingjibiao["TouBiaoXx"]["Zgj"] = child.attrib["Zgj"]
  287. jingjibiao["TouBiaoXx"]["Aqwmf"] = child.attrib["Aqwmf"]
  288. jingjibiao["TouBiaoXx"]["Gf"] = child.attrib["Gf"]
  289. elif child.tag == "Dxgcxx":
  290. Dxgcxx = {}
  291. Dxgcxx["Aqwmf"] = child.attrib["Aqwmf"]
  292. Dxgcxx["Dxgcbh"] = child.attrib["Dxgcbh"]
  293. Dxgcxx["Dxgcmc"] = child.attrib["Dxgcmc"]
  294. Dxgcxx["Gf"] = child.attrib["Gf"]
  295. Dxgcxx["Je"] = child.attrib["Je"]
  296. Dxgcxx["Zgj"] = child.attrib["Zgj"]
  297. Dxgcxx["Dwgc"] = []
  298. for grandchild in child:
  299. if grandchild.tag == "Dwgcxx":
  300. Dwgcxx = {}
  301. Dwgcxx["DogNum"] = grandchild.attrib["DogNum"]
  302. Dwgcxx["Dwgcbh"] = grandchild.attrib["Dwgcbh"]
  303. Dwgcbh.append({"bh": grandchild.attrib["Dwgcbh"], "num": grandchild.attrib["DogNum"]})
  304. Dwgcxx["Dwgcmc"] = grandchild.attrib["Dwgcmc"]
  305. Dwgcxx["MachineKey"] = grandchild.attrib["MachineKey"]
  306. Dwgcxx["SoftName"] = grandchild.attrib["SoftName"]
  307. Dwgcxx["SoftNum"] = grandchild.attrib["SoftNum"]
  308. Dwgcxx["Zylb"] = grandchild.attrib["Zylb"]
  309. Dxgcxx["Dwgc"].append(Dwgcxx)
  310. jingjibiao["Dxgcxx"].append(Dxgcxx)
  311. db = client["baojia"]
  312. collection = db["jingjibiao"]
  313. biao_id = (await collection.insert_one(jingjibiao)).inserted_id
  314. biao_id = str(biao_id)
  315. collection = db["Dwgc"]
  316. for entry in Dwgcbh:
  317. bjhz = service.getBjhz(root, entry["bh"])###array which contains __children
  318. gfsj = service.getGfsj(root, entry["bh"])##array which contains __children
  319. qtxm = service.getQtxm(root, entry["bh"])##array which contains __children
  320. zlje = service.getZlje(root, entry["bh"])
  321. jrg = service.getJrg(root, entry["bh"])
  322. zcbfwf = service.getZcbfwf(root, entry["bh"])
  323. fbrgycl = service.getFbrgycl(root, entry["bh"])
  324. rcjhz = service.getRcjhz(root, entry["bh"])
  325. zjcs = service.getZjcs(root, entry["bh"])
  326. qdbt = service.getQdxm(root, entry["bh"])
  327. Dwgc = {}
  328. Dwgc["bjhz"] = bjhz
  329. Dwgc["gfsj"] = gfsj
  330. Dwgc["qtxm"] = qtxm
  331. Dwgc["zlje"] = zlje
  332. Dwgc["jrg"] = jrg
  333. Dwgc["zcbfwf"] = zcbfwf
  334. Dwgc["fbrgycl"] = fbrgycl
  335. Dwgc["rcjhz"] = rcjhz
  336. Dwgc["zjcs"] = zjcs
  337. Dwgc["qdbt"] = qdbt
  338. Dwgc["DogNum"] = entry["num"]
  339. Dwgc["Dwgcbh"] = entry["bh"]
  340. Dwgc["biao_id"] = biao_id
  341. await collection.insert_one(Dwgc)
  342. collection = db["Djcs"]
  343. for entry in Dwgcbh:
  344. djcs = service.getDjcs(root, entry["bh"])
  345. for cs in djcs:
  346. cs["DogNum"] = entry["num"]
  347. cs["Dwgcbh"] = entry["bh"]
  348. cs["biao_id"] = entry["biao_id"]
  349. rcj = getDjcsQingdanrcj_(root, entry["bh"], "", cs['清单编码'])
  350. cs["rcj"] = rcj
  351. if "__children" in cs:
  352. children = cs["__children"]
  353. for child in children:
  354. dercj = getDjcsDingercj_(root, entry["bh"], "", cs["清单编码"], child["清单编码"])
  355. child["dercj"] = dercj
  356. await collection.insert_one(cs)
  357. collection = db["qdxm"]
  358. for entry in Dwgcbh:
  359. bts = service.getQdxm(root, entry["bh"])
  360. for bt in bts:
  361. qdmx = service.getQdmx(root, entry["bh"], bt)
  362. for qd in qdmx:
  363. qd["DogNum"] = entry["num"]
  364. qd["Dwgcbh"] = entry["bh"]
  365. qd["biao_id"] = biao_id
  366. qd["bt"] = bt
  367. rcj = getQingdanrcj_(root, entry["bh"], bt, qd["清单编码"])
  368. qd["rcj"] = rcj
  369. if "__children" in qd:
  370. children = qd["__children"]
  371. for child in children:
  372. dercj = getDingercj_(root, entry["bh"], bt, qd["清单编码"], child["清单编码"])
  373. child["dercj"] = dercj
  374. child['fuzhuEnable'] = False
  375. await collection.insert_one(qd)
  376. collection = db["qufei"]
  377. document = jingjibiao
  378. dxgc = document['Dxgcxx']
  379. result = []
  380. for entry in dxgc:
  381. newone = {"名称" : entry['Dxgcmc'], "工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "","备注":"", "key" : str(uuid.uuid4()) }
  382. children = []
  383. for dwgc in entry['Dwgc']:
  384. children.append({"名称" : dwgc['Dwgcmc'], "工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "","备注":"", "key" : dwgc['Dwgcbh']})
  385. newone["children"] = children
  386. result.append(newone)
  387. await collection.insert_one({"biao_id": biao_id, "qufei": [{
  388. "名称" : document['Xmmc'], "工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "","备注":"", "key" : str(uuid.uuid4()), "children" : result
  389. }]})
  390. await manager.send_personal_message(f"You wrote: {data}", websocket)
  391. async def list_files(client):
  392. db = client["baojia"]
  393. collection = db["jingjibiao"]
  394. result = []
  395. async for post in collection.find():
  396. result.append([str(post['_id']), post["Xmmc"]])
  397. return result
  398. def getDwgc(id, Zylb):
  399. result = []
  400. #result.append(["ming cheng", "jin e", "zan gu jia", "anquan wenming fei", "guifei"])
  401. ##result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  402. id = id + "Zylb" + Zylb
  403. result.append({"id": id + "bao jia hui zong", "label": "报价汇总表"})
  404. result.append({"id": id + "gui fei shui jin", "label": "规费税金"})
  405. result.append({"id": id + "qing dan xiang mu", "label": "清单项目"})
  406. result.append({"id": id + "cuo shi xiang mu", "label": "措施项目"})
  407. result.append({"id": id +"qi ta xiang mu", "label": "其他项目"})
  408. result.append({"id": id +"zan lie jin e", "label": "暂列金额"})
  409. result.append({"id": id +"cai liao zan gu jia", "label": "材料暂估价"})
  410. result.append({"id": id + "zhuan ye gong cheng zan gu jia", "label": "专业工程暂估价"})
  411. result.append({"id": id + "ji ri gong", "label": "计日工"})
  412. result.append({"id": id + "zong cheng bao fu wu fei", "label": "总承包服务费"})
  413. result.append({"id": id + "zong jia xiang mu jin du kuan zhi fu fen jie", "label": "总价项目进度款支付分解"})
  414. result.append({"id": id + "fa bao ren gong ying cai liao", "label": "发包人供应材料"})
  415. result.append({"id": id + "cheng bao ren gong ying cai liao", "label": "承包人供应材料"})
  416. result.append({"id": id + "ren cai ji hui zong", "label": "人材机汇总"})
  417. return result
  418. async def getOutline(client, id):
  419. db = client["baojia"]
  420. collection = db["jingjibiao"]
  421. document = await collection.find_one({'_id': ObjectId(id)})
  422. result = []
  423. if 'TouBiaoXx' in document:
  424. result.append({"id" : "TouBiaoXx", "label" : "投标信息" })
  425. if 'Dxgcxx' in document:
  426. Dxgcxx = document["Dxgcxx"]
  427. for dxgc in Dxgcxx:
  428. result2 = []
  429. Dwgc = dxgc["Dwgc"]
  430. for grandchild in Dwgc:
  431. result2.append({"id" : grandchild['Dwgcbh'], "Zylb":grandchild['Zylb'], "label": grandchild["Dwgcmc"], "children" : getDwgc(grandchild['Dwgcbh'], grandchild['Zylb'])})
  432. result.append({"id" : dxgc['Dxgcbh'], "label" : dxgc['Dxgcmc'], "children" : result2})
  433. return result
  434. async def getDetail(client, id):
  435. db = client["baojia"]
  436. collection = db["jingjibiao"]
  437. document = await collection.find_one({'_id': ObjectId(id)})
  438. result = []
  439. result.append(["名称", "金额", "暂估价", "安全文明施工费", "规费"])
  440. if 'TouBiaoXx' in document:
  441. toubiaoxx = document["TouBiaoXx"]
  442. result.append([toubiaoxx["Zbr"], toubiaoxx["Tbzj"], toubiaoxx["Zgj"], toubiaoxx["Aqwmf"], toubiaoxx["Gf"]])
  443. if 'Dxgcxx' in document:
  444. Dxgcxx = document["Dxgcxx"]
  445. for dxgc in Dxgcxx:
  446. result.append([dxgc["Dxgcmc"], dxgc["Je"], dxgc["Zgj"], dxgc["Aqwmf"], dxgc["Gf"]])
  447. return result
  448. async def getBjhz(client, objectid, id):
  449. db = client["baojia"]
  450. collection = db["Dwgc"]
  451. document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
  452. return document['bjhz']
  453. async def getGfsj(client, objectid, id):
  454. db = client["baojia"]
  455. collection = db["Dwgc"]
  456. document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
  457. return document['gfsj']
  458. async def getQtxm(client, objectid, id):
  459. db = client["baojia"]
  460. collection = db["Dwgc"]
  461. document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
  462. return document['qtxm']
  463. async def getZlje(client, objectid, id):
  464. db = client["baojia"]
  465. collection = db["Dwgc"]
  466. document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
  467. return document['zlje']
  468. async def getJrg(client, objectid, id):
  469. db = client["baojia"]
  470. collection = db["Dwgc"]
  471. document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
  472. return document['jrg']
  473. async def getZcbfwf(client, objectid, id):
  474. db = client["baojia"]
  475. collection = db["Dwgc"]
  476. document = await collection.find_one({"Dwgcbh": id, "biao_id": objectid})
  477. return document['zcbfwf']
  478. async def getFbrgycl(client, objectid, id):
  479. db = client["baojia"]
  480. collection = db["Dwgc"]
  481. document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
  482. return document['fbrgycl']
  483. async def getRcjhz(client, objectid, id):
  484. db = client["baojia"]
  485. collection = db["Dwgc"]
  486. document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
  487. return document['rcjhz']
  488. async def getZjcs(client, objectid, id):
  489. db = client["baojia"]
  490. collection = db["Dwgc"]
  491. document = await collection.find_one({ "Dwgcbh": id, "biao_id": objectid})
  492. return document['zjcs']
  493. async def getDjcs(client, objectid, id):
  494. db = client["baojia"]
  495. collection = db["Djcs"]
  496. result = []
  497. async for post in collection.find({"Dwgcbh": id, "biao_id": objectid}):
  498. ##post["ID"] = post["_id"]
  499. del post["_id"]
  500. del post["rcj"]
  501. del post["DogNum"]
  502. result.append(post)
  503. return result
  504. async def getDjcsQingdanrcj(client, name, bh, bt, bm):
  505. db = client["baojia"]
  506. collection = db["Djcs"]
  507. document = await collection.find_one({ "Dwgcbh": bh, "清单编码": bm, "biao_id": name})
  508. result = document["rcj"]
  509. return result
  510. async def getDjcsDingercj(client, name, bh, bt, qdbm, debm):
  511. db = client["baojia"]
  512. collection = db["Djcs"]
  513. document = await collection.find_one({"Dwgcbh": bh, "清单编码": qdbm, "biao_id": name})
  514. children = document["__children"]
  515. result = []
  516. for child in children:
  517. if child["清单编码"] == debm:
  518. result = child["dercj"]
  519. return result
  520. async def getQdxm(client, name, bh):
  521. db = client["baojia"]
  522. collection = db["Dwgc"]
  523. document = await collection.find_one({'biao_id': name, "Dwgcbh": bh})
  524. if document:
  525. return document['qdbt']
  526. else:
  527. return []
  528. async def getQdmx(client, name, bh, bt):
  529. db = client["baojia"]
  530. collection = db["qdxm"]
  531. result = []
  532. async for post in collection.find({'biao_id': name, "Dwgcbh": bh, "bt": bt}):
  533. ##post["ID"] = post["_id"]
  534. del post["_id"]
  535. #del post["rcj"]
  536. #del post["DogNum"]
  537. result.append(post)
  538. return result
  539. async def getQingdanrcj(client, name, bh, bt, bm):
  540. db = client["baojia"]
  541. collection = db["qdxm"]
  542. document = await collection.find_one({ "Dwgcbh": bh, "清单编码": bm, "biao_id": name, "bt": bt})
  543. result = document["rcj"]
  544. return result
  545. async def getDingercj(client, name, bh, bt, qdbm, debm):
  546. db = client["baojia"]
  547. collection = db["qdxm"]
  548. document = await collection.find_one({"Dwgcbh": bh, "清单编码": qdbm, "biao_id": name, "bt": bt})
  549. result = []
  550. if "__children" in document:
  551. children = document["__children"]
  552. for child in children:
  553. if child["清单编码"] == debm:
  554. result = child["dercj"]
  555. return result
  556. async def getQufei(client, id):
  557. db = client["baojia"]
  558. collection = db["qufei"]
  559. document = await collection.find_one({'biao_id': id})
  560. return document['qufei']
  561. async def save(client, data):
  562. db = client["baojia"]
  563. collection = db["qdxm"]
  564. for entry in data:
  565. entry["__children"] = entry["children"]
  566. del entry["children"]
  567. await collection.replace_one({"biao_id": entry["biao_id"], "Dwgcbh": entry["Dwgcbh"], "bt": entry["bt"], "清单编码": entry["清单编码"]}, entry)
  568. return {"result": "ok"}
  569. async def applyFL(client, id, data):
  570. db = client["baojia"]
  571. collection = db["qufei"]
  572. await collection.replace_one({"biao_id": id}, {"biao_id": id, "qufei": data})
  573. return {"result": "ok"}