feat:add monitor sts project
This commit is contained in:
@@ -14,5 +14,7 @@ class TaskEnv:
|
||||
CLN_FINANCIAL_STATUS = 'financial_status'
|
||||
CLN_FINANCIAL_ADJUST = 'financial_adjust'
|
||||
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
|
||||
|
||||
class UpdateSts(pydantic.BaseModel):
|
||||
sts: Literal[1, 2, 3, 4] = Field(description="""
|
||||
1.شروع نشده
|
||||
2.جاری
|
||||
3.متوقف
|
||||
4.خاتمه یافته
|
||||
sts: Literal[1, 2, 3, 4,5] = Field(description="""
|
||||
""")
|
||||
reason_stop: Optional[str] = Field(description="دلیل موقف کردن پروژه در این فیلد قرار می گیرد")
|
||||
class Budget(pydantic.BaseModel):
|
||||
@@ -83,6 +79,14 @@ class Monitor(pydantic.BaseModel):
|
||||
agent:Optional[AgentMonitor] = Field(description="عوامل پروژه")
|
||||
status_branch:Optional[StatusBranch] = Field(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):
|
||||
code: Optional[str] = Field(description='کد در این فیلد قرار می گیرد')
|
||||
title: str = Field(description='عنوان در این فیلد قرار می گیرد')
|
||||
@@ -122,4 +126,14 @@ class ProjectModel(BaseModel):
|
||||
monitor:Optional[Monitor] = 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 core.repositories.base import BaseRepository
|
||||
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
|
||||
MODEL = PhysicalProgressModel
|
||||
@@ -16,4 +18,9 @@ class PhysicalProgressRepository(BaseRepository):
|
||||
if last:
|
||||
return last[0]
|
||||
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.models.monitor_rial_progress import RialProgressModel
|
||||
from app.repositories.project import ProjectRepository
|
||||
from core.repositories.base import BaseRepository
|
||||
from core.service.mongo_db import use_collection
|
||||
from core.utils.crudify import mongo_inserter
|
||||
|
||||
|
||||
class RialProgressRepository(BaseRepository):
|
||||
def __init__(self):
|
||||
@@ -14,4 +17,9 @@ class RialProgressRepository(BaseRepository):
|
||||
if last:
|
||||
return last[0]
|
||||
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 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.service.mongo_db import use_collection
|
||||
|
||||
@@ -56,7 +58,30 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
||||
await use_collection(COLLECTION).update_one({"_id":_id},{"$set":{
|
||||
'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):
|
||||
old_project = await use_collection(COLLECTION).find_one({"_id":_id})
|
||||
@@ -74,4 +99,35 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
||||
|
||||
async def list_project_monitor(self):
|
||||
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')
|
||||
repo = PhysicalProgressRepository()
|
||||
|
||||
@router.post('/create', response_model=ThisModel, tags=_tag_base)
|
||||
@router.post('/create', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی')
|
||||
@shrink(repo.create)
|
||||
def create(coding: ThisModel = Body(...)):
|
||||
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)
|
||||
def last_record(project_id:UUID):
|
||||
pass
|
||||
|
||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی')
|
||||
@shrink(repo.update)
|
||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||
pass
|
||||
|
||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی')
|
||||
@shrink(repo.get)
|
||||
def get(_id: UUID):
|
||||
pass
|
||||
@@ -39,7 +39,7 @@ def get(_id: UUID):
|
||||
# def delete(_id: UUID):
|
||||
# pass
|
||||
|
||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base)
|
||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base, description='پیشرفت فیزیکی')
|
||||
@shrink(repo.fetch)
|
||||
def fetch(body: TableEngineRequestType = Body(...)):
|
||||
pass
|
||||
|
||||
@@ -14,22 +14,22 @@ _tag_base = [router_base_url]
|
||||
router = generate_router(router_base_url, auth_dependencies=False, version='v2')
|
||||
repo = RialProgressRepository()
|
||||
|
||||
@router.post('/create', response_model=ThisModel, tags=_tag_base)
|
||||
@router.post('/create', response_model=ThisModel, tags=_tag_base, description='پیشرفت ریالی')
|
||||
@shrink(repo.create)
|
||||
def create(coding: ThisModel = Body(...)):
|
||||
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)
|
||||
def last_record(project_id:UUID):
|
||||
pass
|
||||
|
||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت ریالی')
|
||||
@shrink(repo.update)
|
||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||
pass
|
||||
|
||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت ریالی')
|
||||
@shrink(repo.get)
|
||||
def get(_id: UUID):
|
||||
pass
|
||||
@@ -39,7 +39,7 @@ def get(_id: UUID):
|
||||
# def delete(_id: UUID):
|
||||
# pass
|
||||
|
||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base)
|
||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base, description='پیشرفت ریالی')
|
||||
@shrink(repo.fetch)
|
||||
def fetch(body: TableEngineRequestType = Body(...)):
|
||||
pass
|
||||
|
||||
@@ -14,22 +14,22 @@ _tag_base = [router_base_url]
|
||||
router = generate_router(router_base_url, auth_dependencies=False, version='v2')
|
||||
repo = SecondaryProgressRepository()
|
||||
|
||||
@router.post('/create', response_model=ThisModel, tags=_tag_base)
|
||||
@router.post('/create', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||
@shrink(repo.create)
|
||||
def create(coding: ThisModel = Body(...)):
|
||||
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)
|
||||
def last_record(project_id:UUID):
|
||||
pass
|
||||
|
||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||
@shrink(repo.update)
|
||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||
pass
|
||||
|
||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||
@shrink(repo.get)
|
||||
def get(_id: UUID):
|
||||
pass
|
||||
@@ -39,7 +39,7 @@ def get(_id: UUID):
|
||||
# def delete(_id: UUID):
|
||||
# pass
|
||||
|
||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base)
|
||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base, description='پیشرفت فیزیکی فرعی')
|
||||
@shrink(repo.fetch)
|
||||
def fetch(body: TableEngineRequestType = Body(...)):
|
||||
pass
|
||||
|
||||
@@ -36,6 +36,20 @@ def list_project_monitor():
|
||||
def update_design_sts(_id: UUID, coding: UpdateSts = Body(...)):
|
||||
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)
|
||||
@shrink(repo.update)
|
||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||
|
||||
Reference in New Issue
Block a user