feat(report):add design_progress_status

This commit is contained in:
shahzeydyfah
2025-01-23 23:20:42 +03:30
parent d1e4a58909
commit b08d2f6f4e
3 changed files with 46 additions and 4 deletions
+6 -1
View File
@@ -1,3 +1,4 @@
import datetime
import uuid
from typing import Optional, Literal
@@ -23,4 +24,8 @@ class DelayDonutDetail(pydantic.BaseModel):
class DonutList(pydantic.BaseModel):
type: int = Field(description='مقدار وارد شده در گزارش قبل')
donut_select: str = Field(description='آیتم دونات انتخاب شده')
donut_select: str = Field(description='آیتم دونات انتخاب شده')
class PhysicalMonth(pydantic.BaseModel):
from_date:datetime.datetime
to_date:datetime.datetime
+29 -1
View File
@@ -1,8 +1,9 @@
import uuid
from datetime import time
from app.config import TaskEnv
from app.models.project import ProjectPriceReport
from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail
from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail, PhysicalMonth
from core.service.mongo_db import use_collection
@@ -394,3 +395,30 @@ class ReportRepository():
else:
result_report['upper_than_5'].append(i["_id"])
return result_report
async def progress_month_report(self,_inp:PhysicalMonth):
from datetime import datetime, time
to_date = datetime.combine(_inp.to_date.date(), time.max)
from_date = _inp.from_date.combine(_inp.from_date.date(), time.min)
result = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).aggregate([
{"$match":{"date_at":{"$lte":to_date,"$gte":from_date}}},
{"$group":
{'_id': {"year": "$year", "month": "$month"},
'avg': {'$avg': "$real"}},
}
]).to_list(None)
return result
async def design_progress_status(self):
result = await use_collection("design_progress").aggregate([
{'$match':{'complete_at':{"$exists":0},'parent_id':{"$exists":0}}},
{"$group":
{'_id': '$type',
'count': {'$sum': 1},
"projectIds": {"$addToSet": "$project_id"},
},
}
]).to_list(None)
return result
+11 -2
View File
@@ -2,7 +2,7 @@ import uuid
from fastapi import Body
from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail
from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail, PhysicalMonth
from app.repositories.report import ReportRepository
from core.app import app
from core.utils.router import generate_router, shrink
@@ -101,6 +101,15 @@ def progress_report():
def progress_avg_report():
pass
# میانگین پیشرفت ماهیانه پروژه ها نمودار میله ای-بدون وزن
@router.post('/progress_phisica/avg/month', tags=_tag_base)
@shrink(repo.progress_month_report)
def progress_month_report(_inp:PhysicalMonth = Body(...)):
pass
# وضعیت پروژه های در دست طراحی
@router.get('/design_progress/status', tags=_tag_base)
@shrink(repo.design_progress_status)
def design_progress_status():
pass
app.include_router(router)