Esempio n. 1
0
 def get_model_ref_by_doc_id(self, doc_id):
     """获取该设计书所属模块的关联模块
     """
     rst_model_list, model_list = [], []
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     doc_info = CtrlDsDoc().get_doc(doc_id)
     if not doc_info:
         return [], '指定的设计书不存在!'
     proj_id, model_id = doc_info.get("proj_id"), doc_info.get("model_id")
     curr_model = self._get_model_by_doc_id(doc_id)
     if curr_model:
         model_list.append({
             "model_id": curr_model.get("model_id"),
             "title": curr_model.get("title")
         })
     model_list += self.get_model_ref(proj_id, model_id)
     if not model_list:
         return [], '没有关联模块!'
     for model in model_list:
         model["model_name"] = model.pop('title')
         model["checked"] = False
         model["failure_id_list"] = {
             'havething_list': [],
             'nothing_list': []
         }
         rst_model_list.append(model)
     return rst_model_list, 'OK'
Esempio n. 2
0
 def _sub_model(self,
                type,
                model_dict,
                model_id,
                proj_id,
                model_list,
                top_list,
                level=1):
     model_sub_q = (db.session.query(Model).outerjoin(
         ProjectModelRel,
         Model.model_id == ProjectModelRel.model_id).filter(
             and_(ProjectModelRel.proj_id == proj_id,
                  ProjectModelRel.parent_model_id == model_id)).order_by(
                      Model.title).all())
     if "layer%s" % str(level) not in top_list:
         top_list.append("layer%s" % str(level))
     if len(model_sub_q):
         for sub in model_sub_q:
             down_level = level + 1
             model_dict["layer%s" % str(down_level)] = {
                 "id": sub.model_id,
                 "title": sub.title
             }
             self._sub_model(type, model_dict, sub.model_id, proj_id,
                             model_list, top_list, down_level)
             model_dict = dict()
     else:
         model_dict["sub_level"] = "layer%s" % str(level)
         if type == "PART":
             doc_dict = CtrlDsDoc().get_latest_doc(model_id)
             if doc_dict.get('doc_id'):
                 model_list.append(model_dict)
         else:
             model_list.append(model_dict)
Esempio n. 3
0
 def export_drbfm(self, proj_id, doc_id):
     from app.ctrl.ctrl_project import CtrlProject
     from app.export_doc.export_factory import ExportDrbfmFactory
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     msg, file_path = '', ''
     _, proj_list = CtrlProject().get(proj_id)
     if proj_list:
         proj_name = proj_list[0].get("proj_name")
     else:
         msg = '指定的项目不存在!'
         return msg, file_path
     out_dir = os.path.join("export_root", "drbfm")
     drbfm_data = self.get_drbfm_new(doc_id)
     export_obj = ExportDrbfmFactory.create(proj_name)
     doc_data = CtrlDsDoc().get_doc(doc_id)
     if doc_data:
         doc_name = doc_data.get('title')
     else:
         msg = '该文档不存在!'
         return msg, file_path
     export_obj.drbfm_data = drbfm_data
     file_path = export_obj.write_drbfm_data(out_dir, doc_name)
     return msg, file_path