补齐业务路由与页面权限控制
This commit is contained in:
@@ -9,7 +9,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.models.site import Site
|
||||
from app.models.startup_feasibility import StartupFeasibility
|
||||
from app.models.startup_ethics import StartupEthics
|
||||
from app.models.finance_contract import FinanceContract
|
||||
from app.models.contract_fee import ContractFee
|
||||
from app.models.kickoff_meeting import KickoffMeeting
|
||||
from app.models.subject import Subject
|
||||
|
||||
@@ -59,7 +59,7 @@ async def get_project_overview(db: AsyncSession, study_id: uuid.UUID) -> Dict:
|
||||
institution_status = "COMPLETED" if feas.get("approved_date") else "IN_PROGRESS" if feas.get("submit_date") else "NOT_STARTED"
|
||||
institution_completed = feas.get("approved_date")
|
||||
|
||||
# 伦理审批状态 - 依赖机构立项完成
|
||||
# 伦理记录状态 - 依赖机构立项完成
|
||||
eth = ethics_data.get(site_id_str, {})
|
||||
if institution_status == "COMPLETED":
|
||||
ethics_status = "COMPLETED" if eth.get("approved_date") else "IN_PROGRESS" if eth.get("submit_date") else "NOT_STARTED"
|
||||
@@ -68,7 +68,7 @@ async def get_project_overview(db: AsyncSession, study_id: uuid.UUID) -> Dict:
|
||||
ethics_status = "NOT_STARTED"
|
||||
ethics_completed = eth.get("approved_date") if institution_status == "COMPLETED" else None
|
||||
|
||||
# 合同签署状态 - 依赖伦理审批完成
|
||||
# 合同签署状态 - 依赖伦理记录完成
|
||||
contract = contract_data.get(site_id_str, {})
|
||||
if ethics_status == "COMPLETED":
|
||||
contract_status = "COMPLETED" if contract.get("signed_date") else "NOT_STARTED"
|
||||
@@ -202,28 +202,22 @@ async def _get_ethics_data(db: AsyncSession, study_id: uuid.UUID, site_ids: List
|
||||
|
||||
async def _get_contract_data(db: AsyncSession, study_id: uuid.UUID, site_ids: List[uuid.UUID]) -> Dict:
|
||||
"""获取各中心的合同签署数据"""
|
||||
# FinanceContract 通过 site_name 关联,需要先获取site名称映射
|
||||
stmt_sites = select(Site.id, Site.name).where(Site.id.in_(site_ids))
|
||||
result = await db.execute(stmt_sites)
|
||||
site_name_map = {row.name: str(row.id) for row in result.all()}
|
||||
|
||||
stmt = select(
|
||||
FinanceContract.site_name,
|
||||
func.min(FinanceContract.signed_date).label("signed_date")
|
||||
ContractFee.center_id,
|
||||
func.min(ContractFee.signed_date).label("signed_date")
|
||||
).where(
|
||||
FinanceContract.study_id == study_id
|
||||
).group_by(FinanceContract.site_name)
|
||||
ContractFee.project_id == study_id,
|
||||
ContractFee.center_id.in_(site_ids),
|
||||
).group_by(ContractFee.center_id)
|
||||
|
||||
result = await db.execute(stmt)
|
||||
rows = result.all()
|
||||
|
||||
data = {}
|
||||
for row in rows:
|
||||
site_id_str = site_name_map.get(row.site_name)
|
||||
if site_id_str:
|
||||
data[site_id_str] = {
|
||||
"signed_date": row.signed_date.isoformat() if row.signed_date else None,
|
||||
}
|
||||
data[str(row.center_id)] = {
|
||||
"signed_date": row.signed_date.isoformat() if row.signed_date else None,
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user