feat(report):change report sts
This commit is contained in:
@@ -6,6 +6,8 @@ from pydantic import Field
|
|||||||
|
|
||||||
class StatusReport(pydantic.BaseModel):
|
class StatusReport(pydantic.BaseModel):
|
||||||
state: Optional[str]
|
state: Optional[str]
|
||||||
|
type_id: Optional[int] = Field(description='کد شناسایی نوع پروژه در این فیلد قرار می گیرد')
|
||||||
|
nature_id: Optional[int] = Field(description='کد شناسایی ماهبت در این فیلد قرار می گیرد')
|
||||||
|
|
||||||
class ReportCountry(pydantic.BaseModel):
|
class ReportCountry(pydantic.BaseModel):
|
||||||
type_id: int = Field(description='کد شناسایی نوع پروژه در این فیلد قرار می گیرد')
|
type_id: int = Field(description='کد شناسایی نوع پروژه در این فیلد قرار می گیرد')
|
||||||
|
|||||||
@@ -9,9 +9,12 @@ class ReportRepository():
|
|||||||
async def project_status(self, _inp: StatusReport, type):
|
async def project_status(self, _inp: StatusReport, type):
|
||||||
if _inp.state:
|
if _inp.state:
|
||||||
match = {f'{type}.sts': {'$exists': 1}, 'design.state': _inp.state}
|
match = {f'{type}.sts': {'$exists': 1}, 'design.state': _inp.state}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
match = {f'{type}.sts': {'$exists': 1}}
|
match = {f'{type}.sts': {'$exists': 1}}
|
||||||
|
if _inp.type_id:
|
||||||
|
match.update({'design.type_id': _inp.type_id})
|
||||||
|
if _inp.nature_id:
|
||||||
|
match.update({'design.nature_id': _inp.nature_id})
|
||||||
report = await use_collection(TaskEnv.CLN_PROJECT).aggregate([
|
report = await use_collection(TaskEnv.CLN_PROJECT).aggregate([
|
||||||
{
|
{
|
||||||
"$match": match
|
"$match": match
|
||||||
@@ -41,12 +44,6 @@ class ReportRepository():
|
|||||||
match.update({'design.nature_id': _inp.nature_id})
|
match.update({'design.nature_id': _inp.nature_id})
|
||||||
if _inp.monitor_type:
|
if _inp.monitor_type:
|
||||||
match.update({'monitor.base_information.type': _inp.monitor_type})
|
match.update({'monitor.base_information.type': _inp.monitor_type})
|
||||||
|
|
||||||
# count_nature = await use_collection(TaskEnv.CLN_PROJECT).count_documents(
|
|
||||||
# {'design.nature_id':_inp.nature_id,'design.state':_inp.state})
|
|
||||||
# count_type = await use_collection(TaskEnv.CLN_PROJECT).count_documents({'design.type_id': _inp.type_id,'design.state':_inp.state})
|
|
||||||
# count_monitor_type = await use_collection(TaskEnv.CLN_PROJECT).count_documents({'monitor.base_information.type': _inp.monitor_type,'design.state':_inp.state})
|
|
||||||
|
|
||||||
report = await use_collection(TaskEnv.CLN_PROJECT).aggregate([
|
report = await use_collection(TaskEnv.CLN_PROJECT).aggregate([
|
||||||
{"$match": match},
|
{"$match": match},
|
||||||
{'$group': {
|
{'$group': {
|
||||||
@@ -132,6 +129,7 @@ class ReportRepository():
|
|||||||
return report
|
return report
|
||||||
|
|
||||||
async def list_donut(self, _inp: DonutList):
|
async def list_donut(self, _inp: DonutList):
|
||||||
|
_filter = None
|
||||||
if _inp.type == 1:
|
if _inp.type == 1:
|
||||||
_filter = {'design.nature_id': int(_inp.donut_select)}
|
_filter = {'design.nature_id': int(_inp.donut_select)}
|
||||||
if _inp.type == 2:
|
if _inp.type == 2:
|
||||||
@@ -173,6 +171,7 @@ class ReportRepository():
|
|||||||
if report:
|
if report:
|
||||||
for i in report:
|
for i in report:
|
||||||
get_list.append(i['_id'])
|
get_list.append(i['_id'])
|
||||||
|
# projects = await use_collection(TaskEnv.CLN_PROJECT).find({"_id":{"$in":get_list}}).to_list(None)
|
||||||
return get_list
|
return get_list
|
||||||
|
|
||||||
async def sum_delay_percent(self):
|
async def sum_delay_percent(self):
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ _tag_base = [router_base_url]
|
|||||||
router = generate_router(router_base_url, auth_dependencies=False, version='v2')
|
router = generate_router(router_base_url, auth_dependencies=False, version='v2')
|
||||||
repo = ReportRepository()
|
repo = ReportRepository()
|
||||||
|
|
||||||
|
#نقشه:وضعیت های طراحی
|
||||||
@router.post('/design/sts', tags=_tag_base)
|
@router.post('/design/sts', tags=_tag_base)
|
||||||
@shrink(repo.project_status_design)
|
@shrink(repo.project_status_design)
|
||||||
def project_status_design(_inp: StatusReport):
|
def project_status_design(_inp: StatusReport):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#نقشه:وضعیت های نظارت
|
||||||
@router.post('/monitor/sts', tags=_tag_base)
|
@router.post('/monitor/sts', tags=_tag_base)
|
||||||
@shrink(repo.project_status_monitor)
|
@shrink(repo.project_status_monitor)
|
||||||
def project_status_monitor(_inp: StatusReport):
|
def project_status_monitor(_inp: StatusReport):
|
||||||
|
|||||||
Reference in New Issue
Block a user