feat:add monitor sts project
This commit is contained in:
@@ -14,5 +14,7 @@ class TaskEnv:
|
|||||||
CLN_FINANCIAL_STATUS = 'financial_status'
|
CLN_FINANCIAL_STATUS = 'financial_status'
|
||||||
CLN_FINANCIAL_ADJUST = 'financial_adjust'
|
CLN_FINANCIAL_ADJUST = 'financial_adjust'
|
||||||
CLN_DELIVERY = 'delivery'
|
CLN_DELIVERY = 'delivery'
|
||||||
|
CLN_PROJECT_STS = 'project_sts'
|
||||||
|
CLN_PROJECT = 'project'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+19
-5
@@ -8,11 +8,7 @@ from typing import Optional, List, Literal
|
|||||||
from core.models.base import BaseModel
|
from core.models.base import BaseModel
|
||||||
|
|
||||||
class UpdateSts(pydantic.BaseModel):
|
class UpdateSts(pydantic.BaseModel):
|
||||||
sts: Literal[1, 2, 3, 4] = Field(description="""
|
sts: Literal[1, 2, 3, 4,5] = Field(description="""
|
||||||
1.شروع نشده
|
|
||||||
2.جاری
|
|
||||||
3.متوقف
|
|
||||||
4.خاتمه یافته
|
|
||||||
""")
|
""")
|
||||||
reason_stop: Optional[str] = Field(description="دلیل موقف کردن پروژه در این فیلد قرار می گیرد")
|
reason_stop: Optional[str] = Field(description="دلیل موقف کردن پروژه در این فیلد قرار می گیرد")
|
||||||
class Budget(pydantic.BaseModel):
|
class Budget(pydantic.BaseModel):
|
||||||
@@ -83,6 +79,14 @@ class Monitor(pydantic.BaseModel):
|
|||||||
agent:Optional[AgentMonitor] = Field(description="عوامل پروژه")
|
agent:Optional[AgentMonitor] = Field(description="عوامل پروژه")
|
||||||
status_branch:Optional[StatusBranch] = Field(description="وضعیت انشعابات")
|
status_branch:Optional[StatusBranch] = Field(description="وضعیت انشعابات")
|
||||||
has_design:bool=Field(default=True,description='آیا این پروژه طراحی دارد؟')
|
has_design:bool=Field(default=True,description='آیا این پروژه طراحی دارد؟')
|
||||||
|
sts: Optional[Literal[1, 2, 3, 4, 5]] = Field(default=1, description="""
|
||||||
|
1.شروع نشده
|
||||||
|
2.جاری
|
||||||
|
3.متوقف
|
||||||
|
4.تحویل موقت
|
||||||
|
5.خاتمه یافته
|
||||||
|
""")
|
||||||
|
reason_sts: Optional[str] = Field(description="دلیل موقف کردن پروژه در این فیلد قرار می گیرد")
|
||||||
class Design(pydantic.BaseModel):
|
class Design(pydantic.BaseModel):
|
||||||
code: Optional[str] = Field(description='کد در این فیلد قرار می گیرد')
|
code: Optional[str] = Field(description='کد در این فیلد قرار می گیرد')
|
||||||
title: str = Field(description='عنوان در این فیلد قرار می گیرد')
|
title: str = Field(description='عنوان در این فیلد قرار می گیرد')
|
||||||
@@ -122,4 +126,14 @@ class ProjectModel(BaseModel):
|
|||||||
monitor:Optional[Monitor] = Field(description="فیلدهای نظارت")
|
monitor:Optional[Monitor] = Field(description="فیلدهای نظارت")
|
||||||
design:Design = Field(description='فیلدهای طراحی')
|
design:Design = Field(description='فیلدهای طراحی')
|
||||||
|
|
||||||
|
class ProjectSts(BaseModel):
|
||||||
|
id: Optional[uuid.UUID] = Field(alias='_id')
|
||||||
|
project_id: Optional[uuid.UUID] = Field(description="کد شناسایی پروژه در این فیلد قرار می گیرد")
|
||||||
|
type: Optional[Literal['design','monitor']] = Field(description="نوع پروژه در این فیلد قرار می گیرد")
|
||||||
|
sts: Optional[int] = Field(description='وضعیت مورد نظر در این فیلد قرار می گیرد')
|
||||||
|
description:Optional[str] = Field(description='توضیحات وضعیت در این فیلد قرار می گیرد')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ from app.config import TaskEnv
|
|||||||
from app.models.monito_physical_progress import PhysicalProgressModel
|
from app.models.monito_physical_progress import PhysicalProgressModel
|
||||||
from core.repositories.base import BaseRepository
|
from core.repositories.base import BaseRepository
|
||||||
from core.service.mongo_db import use_collection
|
from core.service.mongo_db import use_collection
|
||||||
|
from core.utils.crudify import mongo_inserter
|
||||||
|
from app.repositories.project import ProjectRepository
|
||||||
|
|
||||||
COLLECTION = TaskEnv.CLN_MONITOR_PYSICAL
|
COLLECTION = TaskEnv.CLN_MONITOR_PYSICAL
|
||||||
MODEL = PhysicalProgressModel
|
MODEL = PhysicalProgressModel
|
||||||
@@ -16,4 +18,9 @@ class PhysicalProgressRepository(BaseRepository):
|
|||||||
if last:
|
if last:
|
||||||
return last[0]
|
return last[0]
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
async def create(self,_inp:MODEL):
|
||||||
|
create = await mongo_inserter(_inp,COLLECTION,getter=self.get)
|
||||||
|
await ProjectRepository().set_sts_two_for_monitor(_inp.project_id)
|
||||||
|
return create
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ import uuid
|
|||||||
|
|
||||||
from app.config import TaskEnv
|
from app.config import TaskEnv
|
||||||
from app.models.monitor_rial_progress import RialProgressModel
|
from app.models.monitor_rial_progress import RialProgressModel
|
||||||
|
from app.repositories.project import ProjectRepository
|
||||||
from core.repositories.base import BaseRepository
|
from core.repositories.base import BaseRepository
|
||||||
from core.service.mongo_db import use_collection
|
from core.service.mongo_db import use_collection
|
||||||
|
from core.utils.crudify import mongo_inserter
|
||||||
|
|
||||||
|
|
||||||
class RialProgressRepository(BaseRepository):
|
class RialProgressRepository(BaseRepository):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -14,4 +17,9 @@ class RialProgressRepository(BaseRepository):
|
|||||||
if last:
|
if last:
|
||||||
return last[0]
|
return last[0]
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
async def create(self,_inp:RialProgressModel):
|
||||||
|
create = await mongo_inserter(_inp,TaskEnv.CLN_MONITOR_RIAL,getter=self.get)
|
||||||
|
await ProjectRepository().set_sts_two_for_monitor(_inp.project_id)
|
||||||
|
return create
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
import uuid
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
|
|
||||||
from app.models.project import ProjectModel, UpdateSts
|
from app.config import TaskEnv
|
||||||
|
from app.models.project import ProjectModel, UpdateSts, ProjectSts
|
||||||
from core.repositories.base import BaseRepository
|
from core.repositories.base import BaseRepository
|
||||||
from core.service.mongo_db import use_collection
|
from core.service.mongo_db import use_collection
|
||||||
|
|
||||||
@@ -56,7 +58,30 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
|||||||
await use_collection(COLLECTION).update_one({"_id":_id},{"$set":{
|
await use_collection(COLLECTION).update_one({"_id":_id},{"$set":{
|
||||||
'design.sts':update.sts,'design.reason_stop':update.reason_stop
|
'design.sts':update.sts,'design.reason_stop':update.reason_stop
|
||||||
}})
|
}})
|
||||||
return True
|
sts_class = ProjectSts(
|
||||||
|
project_id= _id,
|
||||||
|
type = 'design',
|
||||||
|
sts= update.sts,
|
||||||
|
description= update.reason_stop
|
||||||
|
).init_id().cu_at()
|
||||||
|
await use_collection(TaskEnv.CLN_PROJECT_STS).insert_one(sts_class.mongo_dict())
|
||||||
|
return await self.get(_id)
|
||||||
|
|
||||||
|
async def update_monitor_sts(self, _id: UUID, update: UpdateSts):
|
||||||
|
old_project = await use_collection(COLLECTION).find_one({"_id":_id})
|
||||||
|
if not old_project:
|
||||||
|
raise HTTPException(status_code=400,detail='این پروژه وجود ندارد')
|
||||||
|
await use_collection(COLLECTION).update_one({"_id":_id},{"$set":{
|
||||||
|
'monitor.sts':update.sts,'monitor.reason_sts':update.reason_stop
|
||||||
|
}})
|
||||||
|
sts_class = ProjectSts(
|
||||||
|
project_id= _id,
|
||||||
|
type = 'monitor',
|
||||||
|
sts= update.sts,
|
||||||
|
description= update.reason_stop
|
||||||
|
).init_id().cu_at()
|
||||||
|
await use_collection(TaskEnv.CLN_PROJECT_STS).insert_one(sts_class.mongo_dict())
|
||||||
|
return await self.get(_id)
|
||||||
|
|
||||||
async def delete(self, _id: UUID):
|
async def delete(self, _id: UUID):
|
||||||
old_project = await use_collection(COLLECTION).find_one({"_id":_id})
|
old_project = await use_collection(COLLECTION).find_one({"_id":_id})
|
||||||
@@ -74,4 +99,35 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
|||||||
|
|
||||||
async def list_project_monitor(self):
|
async def list_project_monitor(self):
|
||||||
project = await use_collection(COLLECTION).find({'monitor':{"$exists":1}}).to_list(None)
|
project = await use_collection(COLLECTION).find({'monitor':{"$exists":1}}).to_list(None)
|
||||||
return project
|
return project
|
||||||
|
|
||||||
|
async def list_sts_design(self,_id:uuid.UUID):
|
||||||
|
sts_project = await use_collection(TaskEnv.CLN_PROJECT_STS).find({
|
||||||
|
"project_id":_id,
|
||||||
|
"type":"design"
|
||||||
|
}).to_list(None)
|
||||||
|
return sts_project
|
||||||
|
|
||||||
|
async def list_sts_monitor(self,_id:uuid.UUID):
|
||||||
|
sts_project = await use_collection(TaskEnv.CLN_PROJECT_STS).find({
|
||||||
|
"project_id":_id,
|
||||||
|
"type":"monitor"
|
||||||
|
}).to_list(None)
|
||||||
|
return sts_project
|
||||||
|
|
||||||
|
async def set_sts_two_for_monitor(self,project_id:uuid.UUID):
|
||||||
|
project = await use_collection(TaskEnv.CLN_PROJECT).find_one({"_id": project_id})
|
||||||
|
if not ('sts' in project['monitor'] and project['monitor']['sts'] > 1):
|
||||||
|
await use_collection(TaskEnv.CLN_PROJECT).update_one(
|
||||||
|
{'_id': project_id},
|
||||||
|
{"$set":{"monitor.sts": 2}})
|
||||||
|
|
||||||
|
sts_class = ProjectSts(
|
||||||
|
project_id=project_id,
|
||||||
|
type='monitor',
|
||||||
|
sts=2
|
||||||
|
).init_id().cu_at()
|
||||||
|
await use_collection(TaskEnv.CLN_PROJECT_STS).insert_one(sts_class.mongo_dict())
|
||||||
|
|
||||||
|
|
||||||
|
return True
|
||||||
@@ -14,22 +14,22 @@ _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 = PhysicalProgressRepository()
|
repo = PhysicalProgressRepository()
|
||||||
|
|
||||||
@router.post('/create', response_model=ThisModel, tags=_tag_base)
|
@router.post('/create', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی')
|
||||||
@shrink(repo.create)
|
@shrink(repo.create)
|
||||||
def create(coding: ThisModel = Body(...)):
|
def create(coding: ThisModel = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.post('/last/{project_id}', response_model=ThisModel, tags=_tag_base)
|
@router.post('/last/{project_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی')
|
||||||
@shrink(repo.last_record)
|
@shrink(repo.last_record)
|
||||||
def last_record(project_id:UUID):
|
def last_record(project_id:UUID):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی')
|
||||||
@shrink(repo.update)
|
@shrink(repo.update)
|
||||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base)
|
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی')
|
||||||
@shrink(repo.get)
|
@shrink(repo.get)
|
||||||
def get(_id: UUID):
|
def get(_id: UUID):
|
||||||
pass
|
pass
|
||||||
@@ -39,7 +39,7 @@ def get(_id: UUID):
|
|||||||
# def delete(_id: UUID):
|
# def delete(_id: UUID):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base)
|
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base, description='پیشرفت فیزیکی')
|
||||||
@shrink(repo.fetch)
|
@shrink(repo.fetch)
|
||||||
def fetch(body: TableEngineRequestType = Body(...)):
|
def fetch(body: TableEngineRequestType = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -14,22 +14,22 @@ _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 = RialProgressRepository()
|
repo = RialProgressRepository()
|
||||||
|
|
||||||
@router.post('/create', response_model=ThisModel, tags=_tag_base)
|
@router.post('/create', response_model=ThisModel, tags=_tag_base, description='پیشرفت ریالی')
|
||||||
@shrink(repo.create)
|
@shrink(repo.create)
|
||||||
def create(coding: ThisModel = Body(...)):
|
def create(coding: ThisModel = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.post('/last/{project_id}', response_model=ThisModel, tags=_tag_base)
|
@router.post('/last/{project_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت ریالی')
|
||||||
@shrink(repo.last_record)
|
@shrink(repo.last_record)
|
||||||
def last_record(project_id:UUID):
|
def last_record(project_id:UUID):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت ریالی')
|
||||||
@shrink(repo.update)
|
@shrink(repo.update)
|
||||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base)
|
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت ریالی')
|
||||||
@shrink(repo.get)
|
@shrink(repo.get)
|
||||||
def get(_id: UUID):
|
def get(_id: UUID):
|
||||||
pass
|
pass
|
||||||
@@ -39,7 +39,7 @@ def get(_id: UUID):
|
|||||||
# def delete(_id: UUID):
|
# def delete(_id: UUID):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base)
|
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base, description='پیشرفت ریالی')
|
||||||
@shrink(repo.fetch)
|
@shrink(repo.fetch)
|
||||||
def fetch(body: TableEngineRequestType = Body(...)):
|
def fetch(body: TableEngineRequestType = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -14,22 +14,22 @@ _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 = SecondaryProgressRepository()
|
repo = SecondaryProgressRepository()
|
||||||
|
|
||||||
@router.post('/create', response_model=ThisModel, tags=_tag_base)
|
@router.post('/create', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||||
@shrink(repo.create)
|
@shrink(repo.create)
|
||||||
def create(coding: ThisModel = Body(...)):
|
def create(coding: ThisModel = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.post('/last/{project_id}', response_model=ThisModel, tags=_tag_base)
|
@router.post('/last/{project_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||||
@shrink(repo.last_record)
|
@shrink(repo.last_record)
|
||||||
def last_record(project_id:UUID):
|
def last_record(project_id:UUID):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||||
@shrink(repo.update)
|
@shrink(repo.update)
|
||||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base)
|
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||||
@shrink(repo.get)
|
@shrink(repo.get)
|
||||||
def get(_id: UUID):
|
def get(_id: UUID):
|
||||||
pass
|
pass
|
||||||
@@ -39,7 +39,7 @@ def get(_id: UUID):
|
|||||||
# def delete(_id: UUID):
|
# def delete(_id: UUID):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base)
|
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||||
@shrink(repo.fetch)
|
@shrink(repo.fetch)
|
||||||
def fetch(body: TableEngineRequestType = Body(...)):
|
def fetch(body: TableEngineRequestType = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -36,6 +36,20 @@ def list_project_monitor():
|
|||||||
def update_design_sts(_id: UUID, coding: UpdateSts = Body(...)):
|
def update_design_sts(_id: UUID, coding: UpdateSts = Body(...)):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@router.get('/design/list/sts/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||||
|
@shrink(repo.list_sts_design)
|
||||||
|
def list_sts_design(_id: UUID):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@router.put('/monitor/sts/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||||
|
@shrink(repo.update_monitor_sts)
|
||||||
|
def update_monitor_sts(_id: UUID, coding: UpdateSts = Body(...)):
|
||||||
|
pass
|
||||||
|
@router.get('/monitor/list/sts/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||||
|
@shrink(repo.list_sts_monitor)
|
||||||
|
def list_sts_monitor(_id: UUID):
|
||||||
|
pass
|
||||||
|
|
||||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||||
@shrink(repo.update)
|
@shrink(repo.update)
|
||||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||||
|
|||||||
Reference in New Issue
Block a user