feat(project):change model
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user