feat(report):add delay detail

This commit is contained in:
shahzeydyfah
2025-01-16 12:36:33 +03:30
parent 6dcde300b1
commit 0ee3ce0afc
3 changed files with 50 additions and 10 deletions
+28 -2
View File
@@ -1,7 +1,7 @@
import uuid
from app.config import TaskEnv
from app.models.report import StatusReport, ReportCountry, DonutList
from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail
from core.service.mongo_db import use_collection
@@ -159,8 +159,9 @@ class ReportRepository():
return report
async def delay_donut(self):
async def delay_donut(self, project_id:uuid.UUID):
report = await use_collection(TaskEnv.CLN_BILL_DELAY).aggregate([
{"$match":{'project_id':project_id}},
{'$group': {"_id": None, "total_financial": {"$sum": "$financial.total"},
"total_force_major": {"$sum": "$force_major.total"},
"total_technical": {"$sum": "$technical.total"},
@@ -169,6 +170,31 @@ class ReportRepository():
}}
]).to_list(None)
return report
async def delay_donut_detail(self, _inp:DelayDonutDetail):
_group = {}
if _inp.select == 'financial':
_group = {"_id": None, "total_status": {"$sum": "$financial.status"},
"total_prepayment": {"$sum": "$financial.prepayment"},
"total_modification": {"$sum": "$financial.modification"},
"total_good_job": {"$sum": "$financial.good_job"},
}
elif _inp.select == 'force_major':
_group = {"_id": None, "total_force_event": {"$sum": "$force_major.force_event"},
"total_material": {"$sum": "$force_major.material"},
"total_rules": {"$sum": "$force_major.rules"},
"total_define_indicators": {"$sum": "$force_major.define_indicators"},
}
elif _inp.select == 'technical':
_group = {"_id": None, "total_map_technical": {"$sum": "$technical.map_technical"},
"total_permit": {"$sum": "$technical.permit"},
"total_purchase": {"$sum": "$technical.purchase"},
"total_suspense": {"$sum": "$technical.suspense"},
}
report = await use_collection(TaskEnv.CLN_BILL_DELAY).aggregate([
{"$match": {'project_id': _inp.project_id}},
{'$group': _group}
]).to_list(None)
return report
async def list_delay_donut(self, _select: str):
get_list = []