From 77304e2e80030936ec535d60c0d37a6309d61aa9 Mon Sep 17 00:00:00 2001 From: P3ngSaM <61768364+P3ngSaM@users.noreply.github.com> Date: Tue, 29 Nov 2022 16:59:59 +0800 Subject: [PATCH] changes --- AppIndicators/Models.py | 1 + AppIndicators/Router.py | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/AppIndicators/Models.py b/AppIndicators/Models.py index 32d181a..8c19eb4 100644 --- a/AppIndicators/Models.py +++ b/AppIndicators/Models.py @@ -34,6 +34,7 @@ class Parameters(Base): ename = Column(String(255)) cname = Column(String(255)) description = Column(LONGTEXT) + path = Column(String(255)) _iid = Column(String(32), ForeignKey("indicator.iid", ondelete="CASCADE")) def to_dict(self): diff --git a/AppIndicators/Router.py b/AppIndicators/Router.py index f38dab9..53af8d8 100644 --- a/AppIndicators/Router.py +++ b/AppIndicators/Router.py @@ -122,6 +122,54 @@ def func(schema: Schemas.RegisterIndicatorReqBody, db: Session = Depends(get_db) return {"info": "Success"} +# 到处指标配置 +@router.post("/export", summary='指标配置导出', tags=["指标"]) +def func(iid_list: list, db: Session = Depends(get_db)): + result = dict() + result['得分级别标准'] = dict() + result['档位得分标准'] = dict() + result['指标及权重'] = list() + result['评级调整'] = list() + result['数据填报'] = dict() + + for iid in iid_list: + indicator = Crud.get_indicator_by_iid(db, iid) + if not indicator: + raise HTTPException(status_code=404, detail="Indicator Not Found") + index = dict() + index['指标'] = indicator.ename + index['指标结构'] = [indicator.cname] + index['指标类型'] = indicator.nature.value + index['档位'] = None + index['权重'] = None + index['计算请求'] = None + index['指标参数'] = list() + params = indicator.parameters + for param in params: + param_dict = dict() + param_dict['参数'] = param.ename + data = param.path.split("-") + param_dict['加载路径'] = data + index['指标参数'].append(param_dict) + result['指标及权重'].append(index) + + for items in result['指标及权重']: + item = items.get('指标参数') + for itm in item: + sheet = itm.get('加载路径') + if sheet: + result['数据填报'][sheet[0]] = list() + + for items in result['指标及权重']: + item = items.get('指标参数') + for itm in item: + sheet = itm.get('加载路径') + if sheet: + result['数据填报'][sheet[0]].append(sheet[-1]) + + return result + + # 新建参数 @router.post("/param/create/{iid}", summary='新建参数', tags=["指标参数"]) def func(iid: str, body: Schemas.EditParamReqBody, db: Session = Depends(get_db)):