feat(project):add CLN_PROJECT_PRICE_REPORT
This commit is contained in:
@@ -27,6 +27,28 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
||||
code = coding.design.nature + coding.design.type + code
|
||||
return code
|
||||
|
||||
async def create_report_price(self, _inp: ProjectModel):
|
||||
if _inp.monitor and _inp.monitor.detail and _inp.monitor.detail.first_amount:
|
||||
price = {
|
||||
'_id': uuid.uuid4(),
|
||||
'project_id': _inp.id,
|
||||
'first_amount': _inp.monitor.detail.first_amount
|
||||
}
|
||||
await use_collection(TaskEnv.CLN_PROJECT_PRICE_REPORT).insert_one(price)
|
||||
return True
|
||||
async def update_report_price(self,update:ProjectModel):
|
||||
if update.monitor and update.monitor.detail and update.monitor.detail.first_amount:
|
||||
price = await use_collection(TaskEnv.CLN_PROJECT_PRICE_REPORT).find_one({'project_id': update.id})
|
||||
if not price:
|
||||
price = {
|
||||
'_id': uuid.uuid4(),
|
||||
'project_id': update.id,
|
||||
'first_amount': update.monitor.detail.first_amount
|
||||
}
|
||||
await use_collection(TaskEnv.CLN_PROJECT_PRICE_REPORT).insert_one(price)
|
||||
else:
|
||||
await use_collection(TaskEnv.CLN_PROJECT_PRICE_REPORT).update_one({'project_id': update.id}, {'first_amount': update.monitor.detail.first_amount})
|
||||
return True
|
||||
|
||||
async def create(self,coding:ProjectModel):
|
||||
coding.counter = 1
|
||||
@@ -39,13 +61,7 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
||||
if coding.monitor:
|
||||
coding.monitor.code = 'S'+code
|
||||
coding.has_monitor = True
|
||||
if coding.monitor.detail and coding.monitor.detail.first_amount :
|
||||
price = {
|
||||
'_id': uuid.uuid4(),
|
||||
'project_id': coding.id,
|
||||
'first_amount': coding.monitor.detail.first_amount
|
||||
}
|
||||
await use_collection(TaskEnv.CLN_PROJECT_PRICE_REPORT).insert_one(price)
|
||||
await self.create_report_price(coding)
|
||||
else:
|
||||
coding.has_monitor = False
|
||||
|
||||
@@ -66,6 +82,16 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
||||
update.monitor.code = 'S' + code
|
||||
if update.monitor:
|
||||
update.has_monitor = True
|
||||
if update.monitor.detail and update.monitor.detail.first_amount:
|
||||
price = await use_collection(TaskEnv.CLN_PROJECT_PRICE_REPORT).find_one({'project_id':_id})
|
||||
if not price:
|
||||
price = {
|
||||
'_id': uuid.uuid4(),
|
||||
'project_id': _id,
|
||||
'first_amount': update.monitor.detail.first_amount
|
||||
}
|
||||
await use_collection(TaskEnv.CLN_PROJECT_PRICE_REPORT).insert_one(price)
|
||||
|
||||
update.u_at()
|
||||
await use_collection(COLLECTION).update_one({"_id":_id},{"$set":update.mongo_dict()})
|
||||
return await self.get(_id)
|
||||
|
||||
Reference in New Issue
Block a user