| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import xml.etree.ElementTree as ET
- from subdir import service
- from bson.objectid import ObjectId
- from pymongo import AsyncMongoClient
- import asyncio
- import uuid
- client = AsyncMongoClient()
- async def resolve(data):
- db = client["baojia"]
- collection = db["jingjibiao"]
- document = await collection.find_one({'_id': ObjectId(data)})
- dxgc = document['Dxgcxx']
- result = []
- for entry in dxgc:
- newone = {"名称" : entry['Dxgcmc'], "工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "", "备注":"", "key" : str(uuid.uuid4()) }
- children = []
- for dwgc in entry['Dwgc']:
- children.append({"名称" : dwgc['Dwgcmc'],"工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "","备注":"", "key" : dwgc['Dwgcbh']})
- newone["children"] = children
- result.append(newone)
- collection = db["qufei"]
- await collection.insert_one({"biao_id": data, "qufei": [{
- "名称" : document['Xmmc'], "工程类型":"", "工程类别": "", "管理费(%)": "", "利润(%)": "", "备注":"", "key" : str(uuid.uuid4()), "children" : result
- }]})
- import os
- ttt = ['686f656fca53720d42995c7a', '686f6579ec813b9efd38db53', '686f65845e169131760f1420']
- asyncio.run(resolve(ttt[0]))
|