feat(project):change model
This commit is contained in:
@@ -97,8 +97,8 @@ class Design(pydantic.BaseModel):
|
||||
type: str = Field(description='نوع پروژه در این فیلد قرار می گیرد')
|
||||
budget_id: int = Field(description='کد شناسایی دسته بودچه در این فیلد قرار می گیرد')
|
||||
budget: str = Field(description='دسته بودجه در این فیلد قرار می گیرد')
|
||||
date_send: datetime.datetime = Field(description='تاریخ ابالغ/ارجاع')
|
||||
letter: str = Field(description='شماره نامه')
|
||||
date_send: Optional[datetime.datetime] = Field(description='تاریخ ابالغ/ارجاع')
|
||||
letter: Optional[str] = Field(description='شماره نامه')
|
||||
land_area:Optional[str] = Field(description="مساحت زمین")
|
||||
building_infrastructure:Optional[int] = Field(description="زیربنای ساختمان")
|
||||
site_area:Optional[str] = Field(description="مساحت محوطه")
|
||||
|
||||
@@ -163,6 +163,7 @@ class ReportRepository():
|
||||
return report
|
||||
|
||||
async def list_delay_donut(self, _select: str):
|
||||
get_list = []
|
||||
_map = {'1': 'financial.total', '2': 'force_major.total', '3': 'technical.total', '4': 'extra_new_work',
|
||||
'5': 'other'}
|
||||
report = await use_collection(TaskEnv.CLN_BILL_DELAY).aggregate([
|
||||
@@ -170,7 +171,36 @@ class ReportRepository():
|
||||
{'$group': {"_id": '$project_id'}}
|
||||
]).to_list(None)
|
||||
if report:
|
||||
get_list = []
|
||||
for i in report:
|
||||
get_list.append(i['_id'])
|
||||
return get_list
|
||||
|
||||
async def sum_delay_percent(self):
|
||||
result = {}
|
||||
result['less_than_20'] = []
|
||||
result['bet_20_50']= []
|
||||
result['bet_50_100'] = []
|
||||
result['bet_100_200'] = []
|
||||
result['upper_than_200'] = []
|
||||
get_dict_project_id = {}
|
||||
report = await use_collection(TaskEnv.CLN_BILL_DELAY).aggregate([
|
||||
{'$group': {"_id": '$project_id', 'sum':{'$sum':'$total_day'}}}
|
||||
]).to_list(None)
|
||||
get_list_project_id = [i['_id'] for i in report] if report else []
|
||||
get_dict_project_id.update( {str(i['_id']):i for i in report} if report else [])
|
||||
list_project = await use_collection(TaskEnv.CLN_PROJECT).find({"_id":{"$in":get_list_project_id}}).to_list(None)
|
||||
if list_project:
|
||||
for i in list_project:
|
||||
if i['monitor']['detail']['first_time']:
|
||||
cal = (get_dict_project_id[str(i["_id"])]['sum']/i['monitor']['detail']['first_time'])*100
|
||||
if cal < 20 :
|
||||
result['less_than_20'].append(i)
|
||||
elif cal < 50:
|
||||
result['bet_20_50'].append(i)
|
||||
elif cal < 100:
|
||||
result['bet_50_100'].append(i)
|
||||
elif cal < 200:
|
||||
result['bet_100_200'].append(i)
|
||||
else:
|
||||
result['upper_than_200'].append(i)
|
||||
return result
|
||||
|
||||
@@ -33,6 +33,11 @@ def exist_project_state():
|
||||
def delay_donut():
|
||||
pass
|
||||
|
||||
@router.get('/donut/delay/percent', tags=_tag_base)
|
||||
@shrink(repo.sum_delay_percent)
|
||||
def sum_delay_percent():
|
||||
pass
|
||||
|
||||
@router.get('/donut/delay/{_select}', tags=_tag_base)
|
||||
@shrink(repo.list_delay_donut)
|
||||
def list_delay_donut(_select):
|
||||
|
||||
Reference in New Issue
Block a user