feat:add monitor physical progress
This commit is contained in:
@@ -6,4 +6,7 @@ class TaskEnv:
|
||||
CLN_AUDIT_PROGRAM = 'audit_program'
|
||||
CLN_BILL_DELAY = 'bill_delay'
|
||||
CLN_CONTRACT = 'contract'
|
||||
CLN_BILL = 'bill'
|
||||
CLN_MONITOR_PYSICAL = 'monitor_physical'
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import datetime
|
||||
import uuid
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from core.models.base import BaseModel
|
||||
|
||||
|
||||
class PhysicalProgressModel(BaseModel):
|
||||
id: Optional[uuid.UUID] = Field(alias='_id')
|
||||
project_id:Optional[uuid.UUID] = Field(description="کد شناسایی پروژه در این فیلد قرار می گیرد")
|
||||
program:Optional[int] = Field(description=" برنامه ای")
|
||||
real:Optional[int] = Field(description=" واقعی")
|
||||
medium_progress:Optional[int] = Field(description="متوسط پیشرفت فیزیکی ماهانه از ابتدا تا کنون")
|
||||
deviation:Optional[int] = Field(description="انحراف از برنامه")
|
||||
date_at:Optional[datetime.datetime] = Field(description="تاریخ گزارش پیشرفت")
|
||||
@@ -0,0 +1,19 @@
|
||||
import uuid
|
||||
|
||||
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
|
||||
|
||||
COLLECTION = TaskEnv.CLN_MONITOR_PYSICAL
|
||||
MODEL = PhysicalProgressModel
|
||||
class PhysicalProgressRepository(BaseRepository):
|
||||
def __init__(self):
|
||||
super().__init__(collection=TaskEnv.CLN_MONITOR_PYSICAL, model=PhysicalProgressModel)
|
||||
|
||||
async def last_record(self,project_id:uuid.UUID):
|
||||
last = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).find({'project_id':project_id}).sort("$natural", -1).to_list(None)
|
||||
if last:
|
||||
return last[0]
|
||||
else:
|
||||
return {}
|
||||
@@ -8,3 +8,5 @@ from .factor_audit import *
|
||||
from .program_audit import *
|
||||
from .bill_delay import *
|
||||
from .contract import *
|
||||
# from .bill import *
|
||||
from .monitor_physical import *
|
||||
@@ -0,0 +1,47 @@
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import Body
|
||||
|
||||
from app.models.monito_physical_progress import PhysicalProgressModel
|
||||
from app.repositories.monitor_physical_progress import PhysicalProgressRepository
|
||||
from core.app import app
|
||||
from core.utils.router import generate_router, shrink
|
||||
from core.utils.table_engine import TableEngineExport, TableEngineRequestType
|
||||
|
||||
ThisModel = PhysicalProgressModel
|
||||
router_base_url = 'monitor-physical'
|
||||
_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)
|
||||
@shrink(repo.create)
|
||||
def create(coding: ThisModel = Body(...)):
|
||||
pass
|
||||
|
||||
@router.post('/last/{project_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@shrink(repo.last_record)
|
||||
def last_record(project_id:UUID):
|
||||
pass
|
||||
|
||||
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@shrink(repo.update)
|
||||
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||
pass
|
||||
|
||||
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@shrink(repo.get)
|
||||
def get(_id: UUID):
|
||||
pass
|
||||
|
||||
@router.delete('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||
@shrink(repo.delete)
|
||||
def delete(_id: UUID):
|
||||
pass
|
||||
|
||||
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base)
|
||||
@shrink(repo.fetch)
|
||||
def fetch(body: TableEngineRequestType = Body(...)):
|
||||
pass
|
||||
|
||||
app.include_router(router)
|
||||
Reference in New Issue
Block a user