feat(report):add design_progress_status
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import datetime
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Optional, Literal
|
from typing import Optional, Literal
|
||||||
|
|
||||||
@@ -24,3 +25,7 @@ class DelayDonutDetail(pydantic.BaseModel):
|
|||||||
class DonutList(pydantic.BaseModel):
|
class DonutList(pydantic.BaseModel):
|
||||||
type: int = Field(description='مقدار وارد شده در گزارش قبل')
|
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
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
from datetime import time
|
||||||
|
|
||||||
from app.config import TaskEnv
|
from app.config import TaskEnv
|
||||||
from app.models.project import ProjectPriceReport
|
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
|
from core.service.mongo_db import use_collection
|
||||||
|
|
||||||
|
|
||||||
@@ -394,3 +395,30 @@ class ReportRepository():
|
|||||||
else:
|
else:
|
||||||
result_report['upper_than_5'].append(i["_id"])
|
result_report['upper_than_5'].append(i["_id"])
|
||||||
return result_report
|
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
@@ -2,7 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from fastapi import Body
|
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 app.repositories.report import ReportRepository
|
||||||
from core.app import app
|
from core.app import app
|
||||||
from core.utils.router import generate_router, shrink
|
from core.utils.router import generate_router, shrink
|
||||||
@@ -101,6 +101,15 @@ def progress_report():
|
|||||||
def progress_avg_report():
|
def progress_avg_report():
|
||||||
pass
|
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)
|
app.include_router(router)
|
||||||
Reference in New Issue
Block a user