Пример #1
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)
Пример #2
0
 def add2(self, data_dict):
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     update_time = self.get_current_time()
     micro_ver = data_dict.get('micro_ver')
     doc_id = data_dict.get('doc_id')
     commit_user = data_dict.get('commit_user')
     content = data_dict.get('content')
     if not doc_id:
         return False, '未指定文档ID!'
     doc_data, error = CtrlDsDoc().ds_doc_exist(doc_id)
     if error:
         return False, error
     old_micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
     flag, error = self.diff_ver(micro_ver, old_micro_ver)
     if not flag:
         return 0, error
     data_list = []
     new_gid_list = []
     old_data_list = self.get_old_data(DSRelTag, DSRelTag.doc_id, doc_id)
     old_gid_list = []
     commit_list = []
     for old_data in old_data_list:
         old_gid_list.append(old_data.get('gid'))
     for data in content:
         tag_id = data.get('tag_id')
         changes = data.get('changes')
         for change in changes:
             if change.get('gid'):
                 new_gid_list.append(change.get('gid'))
             change_info = dict()
             change_info['gid'] = change.get('gid')
             change_info['doc_id'] = doc_id
             change_info['tag_id'] = tag_id
             change_info['before_change'] = change.get('before_change')
             change_info['change'] = change.get('change')
             change_info['before_influence'] = change.get(
                 'before_influence')
             change_info['influence'] = change.get('influence')
             change_info['order_id'] = changes.index(change) + 1
             data_list.append(change_info)
     try:
         for old_gid in old_gid_list:
             if old_gid not in new_gid_list:
                 commit_list += self.del_scene_considers(old_gid)
         commit_list += self.add_list(
             DSRelTag, data_list, old_data_list, DSRelTag.gid, [
                 DSRelTag.before_change.name, DSRelTag.change.name,
                 DSRelTag.before_influence.name, DSRelTag.influence.name,
                 DSRelTag.order_id.name
             ])
         if commit_list:
             log_doc = CtrlDsDoc().update_ver(doc_id, commit_user)
             commit_list.append(log_doc)
         self.commit_log(commit_list, commit_user, update_time)
         db.session.commit()
         return doc_id, 'OK'
     except Exception as e:
         db.session.rollback()
         current_app.logger.error('%s' % e)
         return 0, "服务异常!请联系管理员!"
Пример #3
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'
Пример #4
0
 def update_if(self, data_info):
     try:
         update_time = self.get_current_time()
         doc_id = data_info.get(DSDocIf.doc_id.name)
         if not doc_id:
             return False, '没有指定文档ID!'
         from app.ctrl.ctrl_ds_doc import CtrlDsDoc
         doc_data, error = CtrlDsDoc().ds_doc_exist(doc_id)
         if error:
             return 0, error
         commit_user = data_info.get('commit_user')
         if_data = data_info.get('if_data')
         error = self.diff_if_ver(if_data)
         if error:
             return False, error
         new_if_data = self.get_new_if_list(if_data, doc_id)
         old_if_data = self.get_old_data(self.db_object, DSDocIf.doc_id,
                                         doc_id)
         commit_list = self.add_list(self.db_object, new_if_data,
                                     old_if_data, self.key_col,
                                     self.col_list)
         if commit_list:
             log_doc = CtrlDsDoc().update_ver(doc_id, commit_user)
             commit_list.append(log_doc)
         self.commit_log(commit_list, commit_user, update_time)
         db.session.commit()
         return True, ''
     except Exception as e:
         db.session.rollback()
         current_app.logger.error('%s' % e)
         return False, "服务异常!请联系管理员!"
Пример #5
0
 def add_scene(self, data_json):
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     update_time = self.get_current_time()
     micro_ver = data_json.get('micro_ver')
     doc_id = data_json.get('doc_id')
     commit_user = data_json.get('commit_user')
     content = data_json.get('content')
     if not doc_id:
         return False, '未指定文档ID!'
     doc_data, error = CtrlDsDoc().ds_doc_exist(doc_id)
     if error:
         return False, error
     old_micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
     flag, error = self.diff_ver(micro_ver, old_micro_ver)
     if not flag:
         return 0, error
     commit_list = []
     old_data_list = self.get_old_data(DSRelTag, DSRelTag.doc_id, doc_id)
     old_tag_list = []
     del_data_list = []
     for old_data in old_data_list:
         tag_id = old_data.get('tag_id')
         if tag_id not in old_tag_list:
             old_tag_list.append(tag_id)
         if tag_id not in content:
             del_data_list.append(old_data)
             commit_list += self.del_scene_considers(
                 old_data.get('gid'))  # 刪除已刪除場景下的考慮點
     add_data_list = []
     for tag_id in content:
         new_data = {
             'doc_id': doc_id,
             'tag_id': tag_id,
             'before_change': None,
             'change': None,
             'before_influence': None,
             'influence': None,
             'order_id': 1
         }
         if tag_id not in old_tag_list:
             add_data_list.append(new_data)
     try:
         commit_list += self.add_list(DSRelTag, [], del_data_list,
                                      DSRelTag.gid, [])
         commit_list += self.add_list(DSRelTag, add_data_list, [],
                                      DSRelTag.gid, [])
         if commit_list:
             log_doc = CtrlDsDoc().update_ver(doc_id, commit_user)
             commit_list.append(log_doc)
         self.commit_log(commit_list, commit_user, update_time)
         db.session.commit()
         return doc_id, 'OK'
     except Exception as e:
         db.session.rollback()
         current_app.logger.error('%s' % e)
         return 0, "服务异常!请联系管理员!"
Пример #6
0
 def get(self, model_id, doc_type, tag_id):
     """
     :param model_id, doc_type, tag_id
     :return: 获取Model下某tag下的所有文档
     """
     result = {"result": "NG"}
     ctrl_doc = CtrlDsDoc()
     docs = ctrl_doc.get_ds_doc_by_tag(model_id, tag_id, doc_type)
     if docs:
         result["result"] = "OK"
         result["content"] = docs
     return result
Пример #7
0
 def add(self, data_dict):
     update_time = self.get_current_time()
     micro_ver = data_dict.get('micro_ver')
     doc_id = data_dict.get(DSRelSpec.doc_id.name)
     commit_user = data_dict.get('commit_user')
     content = data_dict.get('content')
     if not doc_id:
         return False, '未指定文档ID!'
     doc_data, error = CtrlDsDoc().ds_doc_exist(doc_id)
     if error:
         return False, error
     old_micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
     flag, error = self.diff_ver(micro_ver, old_micro_ver)
     if not flag:
         return 0, error
     data_list = []
     old_spec_list = self.get_old_data(self.db_object, DSRelSpec.doc_id, doc_id)
     old_data_list = []
     for old_data in old_spec_list:
         if old_data.get('sec_id'):
             old_data_list.append(old_data)
     for data in content:
         sec_id = data.get(DSRelSpec.sec_id.name)
         if not sec_id:
             return 0, '没有指定USECASE_ID!'
         old_data, error = CtrlDSSection().session_is_exist(sec_id)
         if error:
             return 0, error
         specs = data.get('specs')
         if not specs:
             continue
         spec_info = dict()
         spec_info[DSRelSpec.gid.name] = specs.get('gid')
         spec_info[DSRelSpec.doc_id.name] = int(doc_id)
         spec_info[DSRelSpec.sec_id.name] = int(sec_id)
         spec_info[DSRelSpec.spec_id.name] = specs.get(DSRelSpec.spec_id.name)
         spec_info[DSRelSpec.func_id.name] = specs.get(DSRelSpec.func_id.name)
         data_list.append(spec_info)
         # if not spec_list:
         #     return 0, '无式样书!'
     try:
         commit_list = self.add_list(self.db_object, data_list, old_data_list,
                                     self.key_col, self.col_list)
         if commit_list:
             log_doc = CtrlDsDoc().update_ver(doc_id, commit_user)
             commit_list.append(log_doc)
         self.commit_log(commit_list, commit_user, update_time)
         db.session.commit()
         return doc_id, 'OK'
     except Exception as e:
         db.session.rollback()
         current_app.logger.error('%s' % e)
         return 0, "服务异常!请联系管理员!"
Пример #8
0
 def get(self, doc_id, type=None):
     """
     :param doc_id:
     :return: 获取设计文档信息
     """
     result = {"result": "OK"}
     ctrl_doc = CtrlDsDoc()
     # ctrl_section = CtrlDSSection()
     try:
         ds_doc = ctrl_doc.get_doc(doc_id, type)
         # doc_section = ctrl_section.get_sections(doc_id)
         # sec_type_list = ctrl_section.get_section_type(orient='list')
         # for type_dict in sec_type_list:
         #     sec_type = type_dict.get('sec_type')
         #     if sec_type not in doc_section:
         #         doc_section[sec_type] = []
         # ds_doc.update(doc_section)
         # doc = {"doc_type": "BASIC",
         #        "title": "文档标题",
         #        "ver": "文档版本",
         #        "model_id": "文档所属模块",
         #        "create_time": "2018-5-9",
         #        "update_time": "2018-5-9",
         #        "creator": "文档创建者",
         #        "editor": "最后更新人/编辑者",
         #        "locked": "N",
         #        "SUMMARY": "Markdown0",
         #        "USERCASE": [{"content": "Markdown1",
         #                      "tags": [{"tag_id": 106, "tag": "NativeAPP"},
         #                               {"tag_id": 107, "tag": "Html5APP"},
         #                               ]
         #                      }
         #                     ],
         #        "SEQUENCE": [{"content": "Markdown2",
         #                      "tags": [{"tag_id": 106, "tag": "NativeAPP"},
         #                               {"tag_id": 107, "tag": "Html5APP"},
         #                               ]
         #                      }
         #                     ],  # 时序图
         #        "CLASS": [],  # 类图
         #        "BLOCK": [],
         #        "RESOURCE": [],  # 资源
         #        "IF": [],  # 接口
         #        "STD": [],  # 状态图
         #        }
         result["content"] = ds_doc
     except Exception as e:
         current_app.logger.error('%s' % e)
         result["result"] = "NG"
         result["error"] = "服务异常!请联系管理员!"
     return result
Пример #9
0
    def add_doc_spec(self, data_dict):
        update_time = self.get_current_time()
        commit_user = data_dict.get('commit_user')
        micro_ver = data_dict.get('micro_ver')
        doc_id = data_dict.get(DSRelSpec.doc_id.name)
        if not doc_id:
            return False, '未指定文档ID!'
        doc_data, error = CtrlDsDoc().ds_doc_exist(doc_id)
        if error:
            return 0, error
        spec_list = []
        for _, data_list in data_dict.items():
            if type(data_list) == list:
                for spec in data_list:
                    spec_info = dict()
                    spec_info[DSRelSpec.gid.name] = spec.get('gid')
                    spec_info[DSRelSpec.doc_id.name] = int(doc_id)
                    spec_info[DSRelSpec.spec_id.name] = spec.get('spec_id')
                    spec_info[DSRelSpec.sec_id.name] = None
                    spec_info[DSRelSpec.func_id.name] = None
                    spec_list.append(spec_info)
        # if not spec_list:
        #     return 0, '无式样书!'
        # sec_id = data_dict.get(DSRelSpec.sec_id.name)
        try:

            # if not sec_id:
            #     return 0, '没有指定USECASE_ID!'
            old_micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
            flag, error = self.diff_ver(micro_ver, old_micro_ver)
            if not flag:
                return 0, error
            spec_id_list = []
            old_data_list = self.get_old_data(self.db_object, [DSRelSpec.doc_id, DSRelSpec.sec_id],
                                              {'doc_id': doc_id, 'sec_id': None})
            for spec_info in spec_list:
                spec_id_list.append(spec_info.get(DSRelSpec.spec_id.name))
            commit_list = self.add_list(self.db_object, spec_list, old_data_list,
                                        self.key_col, self.col_list)
            commit_list += self.delete_usecase_spec(doc_id, spec_id_list)
            if commit_list:
                log_dict = CtrlDsDoc().update_ver(doc_id, commit_user)
                commit_list.append(log_dict)
            self.commit_log(commit_list, commit_user, update_time)
            db.session.commit()
            return doc_id, 'OK'
        except Exception as e:
            db.session.rollback()
            current_app.logger.error('%s' % e)
            return 0, "服务异常!请联系管理员!"
Пример #10
0
 def get(self, doc_id):
     """
     查看基本/详细设计信息
     :param doc_id:
     :return:
     """
     result = {"result": "NG", "content": ''}
     ctrl_doc = CtrlDsDoc()
     doc_data = ctrl_doc.get_ds_doc(doc_id)
     if doc_data:
         result["result"] = "OK"
         result["content"] = doc_data
     else:
         result["error"] = "该文档不存在!"
     return result
Пример #11
0
 def get(self):
     result = {"result": "NG"}
     status_list = CtrlDsDoc().get_doc_status()
     if status_list:
         result["content"] = status_list
         result["result"] = "OK"
     return result
Пример #12
0
 def get(self):
     result = {"result": "NG"}
     doc_types = CtrlDsDoc().get_doc_type(orient='list')
     if doc_types:
         result["content"] = doc_types
         result["result"] = "OK"
     return result
Пример #13
0
 def get(self, proj_id, model_id):
     result = {"result": "NG", "content": []}
     doc_list = CtrlDsDoc().get_basic_doc_for_detail(proj_id, model_id)
     if doc_list:
         result['result'] = "OK"
         result['content'] = doc_list
     return result
Пример #14
0
 def _get_doc_typs(self):
     doc_types = CtrlDsDoc().get_doc_type(orient='list')
     for doc_type in doc_types:
         doc_type["id"] = doc_type.pop(DSDocType.doc_type.name)
         doc_type["title"] = doc_type.pop(DSDocType.describe.name)
         doc_type["type"] = "doc_type"
         doc_type["sub"] = []
     return doc_types
Пример #15
0
 def add_tag_considers(self, data_json):
     """
     给场景选择影响模块
     :param data_json:
     :return:
     """
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     update_time = self.get_current_time()
     micro_ver = data_json.get('micro_ver')
     doc_id = data_json.get('doc_id')
     commit_user = data_json.get('commit_user')
     content = data_json.get('consider')
     if not doc_id:
         return False, '未指定文档ID!'
     doc_data, error = CtrlDsDoc().ds_doc_exist(doc_id)
     if error:
         return False, error
     old_micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
     flag, error = self.diff_ver(micro_ver, old_micro_ver)
     if not flag:
         return 0, error
     new_data_list = []
     old_data_list = []
     for data in content:
         if not data:
             continue
         change_list = data[0].get('change_list')
         new_data, old_data = self.get_new_tag_consider(change_list)
         new_data_list += new_data
         old_data_list += old_data
     for new_data in new_data_list:
         for old_data in old_data_list:
             if (new_data.get('change_id') == old_data.get('change_id')
                     and new_data.get('change_type')
                     == old_data.get('change_type') and
                     new_data.get('model_id') == old_data.get('model_id')):
                 new_data['gid'] = old_data.get('gid')
                 break
     commit_list = self.add_list(
         DSRelModel, new_data_list, old_data_list, DSRelModel.gid, [
             DSRelModel.checked.name, DSRelModel.failure_id_list.name,
             DSRelModel.result.name
         ])
     self.commit_log(commit_list, commit_user, update_time)
     db.session.commit()
     return doc_id, None
Пример #16
0
 def add(self, data_dict, commit_user):
     update_time = self.get_current_time()
     micro_ver = data_dict.get('micro_ver')
     doc_id = data_dict.get(DSRelScene.doc_id.name)
     if not doc_id:
         return False, '未指定文档ID!'
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     doc_data, error = CtrlDsDoc().ds_doc_exist(doc_id)
     if error:
         return False, error
     sec_id = data_dict.get(DSRelScene.sec_id.name)
     if not sec_id:
         return False, '没有指定USECASE_ID!'
     old_data, error = CtrlDSSection().session_is_exist(sec_id)
     if error:
         return 0, error
     old_micro_ver = CtrlDSSection().get_sec_ver(sec_id)
     flag, error = self.diff_ver(micro_ver, old_micro_ver)
     if not flag:
         return False, error
     old_scenes_data = self.get_old_data(self.db_object, DSRelScene.sec_id,
                                         sec_id)
     scenes = data_dict.get("scenes")
     try:
         drbfm_log_list = self.delete_scene_drbfm(sec_id, scenes,
                                                  old_scenes_data)
         new_scene_list = self.get_new_scene_list(scenes, doc_id, sec_id)
         scene_log_list = self.add_list(self.db_object, new_scene_list,
                                        old_scenes_data, self.key_col,
                                        self.col_list)
         db.session.flush()
         consider_log_list = CtrlDSConsider().create_considers(sec_id)
         commit_list = drbfm_log_list + scene_log_list + consider_log_list
         if commit_list:
             log_dict = CtrlDSSection().update_ver(sec_id)
             commit_list.append(log_dict)
             log_doc = CtrlDsDoc().update_ver(doc_id, commit_user)
             commit_list.append(log_doc)
         self.commit_log(commit_list, commit_user, update_time)
         db.session.commit()
         return sec_id, 'OK'
     except Exception as e:
         db.session.rollback()
         current_app.logger.error('%s' % e)
         return 0, "服务异常!请联系管理员!"
Пример #17
0
 def delete_attach(self, doc_id, attach_id, commit_user):
     update_time = self.get_current_time()
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     commit_list = self.delete_by_doc_id(doc_id, attach_id)
     if commit_list:
         log_doc = CtrlDsDoc().update_ver(doc_id, commit_user)
         commit_list.append(log_doc)
     self.commit_log(commit_list, commit_user, update_time)
     db.session.commit()
Пример #18
0
 def get(self, doc_id):
     result = {"result": "NG", "content": []}
     spec = CtrlDSRelSpec().get(doc_id)
     micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
     if spec:
         result["result"] = "OK"
         result["content"] = spec
     result["micro_ver"] = micro_ver
     return result
Пример #19
0
 def post(self):
     data_json = request.get_json()
     result = {"result": "NG", 'error': ''}
     flag, error = CtrlDsDoc().update_doc_status(data_json)
     if flag:
         result['result'] = 'OK'
     else:
         result['error'] = error
     return result
Пример #20
0
 def post(self):
     data_json = request.get_json()
     result = {"result": "NG", 'error': ''}
     error = CtrlDsDoc().up_doc_ver(data_json)
     if not error:
         result['result'] = 'OK'
     else:
         result['error'] = error
     return result
Пример #21
0
 def add(self, drbfm_data, commit_user):
     update_time = self.get_current_time()
     from app.ctrl.ctrl_ds_section import CtrlDSSection
     micro_ver = drbfm_data.get('micro_ver')
     doc_id = drbfm_data.get('doc_id')
     if not doc_id:
         return False, '未指定文档ID!'
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     doc_data, error = CtrlDsDoc().ds_doc_exist(doc_id)
     if error:
         return False, error
     content = drbfm_data.get('content')
     if content:
         sec_id = drbfm_data.get('content')[0].get('sec_id')
         if not sec_id:
             return False, '没有指定USECASE_ID!'
         old_data, error = CtrlDSSection().session_is_exist(sec_id)
         if error:
             return 0, error
         old_micro_ver = CtrlDSSection().get_sec_ver(sec_id)
         flag, error = self.diff_ver(micro_ver, old_micro_ver)
         if not flag:
             return False, error
     try:
         new_data_list = self.get_new_drbfm(content)
         old_data_list = self.get_old_data(self.db_object, DSDrbfm.sec_id,
                                           sec_id)
         commit_list = self.add_list(self.db_object, new_data_list,
                                     old_data_list, self.key_col,
                                     self.col_list)
         if commit_list:
             log_dict = CtrlDSSection().update_ver(sec_id)
             commit_list.append(log_dict)
             log_doc = CtrlDsDoc().update_ver(doc_id, commit_user)
             commit_list.append(log_doc)
         self.commit_log(commit_list, commit_user, update_time)
         db.session.commit()
         return sec_id, 'ok'
     except Exception as e:
         current_app.logger.error('%s' % e)
         db.session.rollback()
         return False, "服务异常!请联系管理员!"
Пример #22
0
 def post(self):
     result = {"result": "NG", "doc_id": 0, 'error': ''}
     data_json = request.get_json()
     doc_id, error = CtrlDSRelSpec().add(data_json)
     if doc_id:
         micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
         result['result'] = "OK"
         result['doc_id'] = doc_id
         result["micro_ver"] = micro_ver
     else:
         result['error'] = error
     return result
Пример #23
0
 def delete(self, _id, type, commit_user):
     """
     :param id:
     :param del_type:  doc/usercase
     :return:
     """
     result = {"result": "OK"}
     try:
         if type == "doc":
             ctrl_obj = CtrlDsDoc()
         elif type == "usercase":
             ctrl_obj = CtrlDSSection()
         error = ctrl_obj.delete(_id, commit_user)
         if error:
             result["result"] = "NG"
             result["error"] = error
     except Exception as e:
         current_app.logger.error('%s' % e)
         result["result"] = "NG"
         result["error"] = "服务异常!请联系管理员!"
     return result
Пример #24
0
 def get(self, doc_id=0):
     """获取设计文档关系的场景(场景的考虑点使用)"""
     result = {"result": "NG", 'content': []}
     if doc_id:  # 取所有场景(TAG)
         # scenes = CtrlDSScene().get_scene()
         tags = CtrlDSScene().get_tags_by_doc_id(doc_id)
         if tags:
             result['result'] = "OK"
             result['content'] = tags
         micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
         result["micro_ver"] = micro_ver
     return result
Пример #25
0
 def delete_by_if_id(self, if_id, commit_user):
     from app.ctrl.ctrl_ds_doc import CtrlDsDoc
     try:
         q = db.session.query(DSDocIf).filter(DSDocIf.if_id == if_id)
         doc_id = q.doc_id
         q.delete()
         CtrlDsDoc().update_doc_ver(doc_id, commit_user)
         db.session.commit()
         return True, ''
     except Exception as e:
         db.session.rollback()
         current_app.logger.error('%s' % e)
         return False, "服务异常!请联系管理员!"
Пример #26
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
Пример #27
0
 def get(self, doc_id, search_str=''):
     """
     获取文档下的式样书
     :param doc_id:
     :param search_str:
     :return:
     """
     result = {"result": "NG", "content": []}
     spec, status = CtrlDSRelSpec().get_by_doc_id(doc_id, search_str)
     micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
     if spec:
         result["result"] = "OK"
         result["content"] = spec
     result["micro_ver"] = micro_ver
     return result
Пример #28
0
 def get(self, doc_id=0, type='change'):
     result = {"result": "NG"}
     if not doc_id:  # 取所有场景(TAG)
         # scenes = CtrlDSScene().get_scene()
         scenes = CtrlDSScene().get_scene3()
     else:
         # scenes = CtrlDSScene().get_scene_by_sec(doc_id)
         if type == 'change':  # 修改点、影响点
             scenes = CtrlDSScene().get_scene_by_doc2(doc_id)
         else:  # 已选择
             scenes = CtrlDSScene().get_scene_by_doc(doc_id)
     micro_ver = CtrlDsDoc().get_doc_ver(doc_id)
     result["micro_ver"] = micro_ver
     if scenes:
         result['result'] = "OK"
         result['content'] = scenes
     return result
Пример #29
0
 def post(self):
     """
     新增设计文档
     :return:
     """
     data_json = request.get_json()
     result = {"result": "NG", 'error': ''}
     doc_type = data_json.get("doc_type")
     proj_id = data_json.get("proj_id")
     model_id = data_json.get("model_id")
     commit_user = data_json.get("commit_user")
     doc_id, error = CtrlDsDoc().add_new_doc(doc_type, proj_id, model_id,
                                             commit_user)
     if doc_id:
         result["result"] = "OK"
         result["content"] = doc_id
         # 删除
         print('delete_memoized: get_model_top, proj_id=%s' % proj_id)
         del_cache_model_top(proj_id)
     else:
         result["error"] = error
     return result
Пример #30
0
    def read_json(self,
                  json_url,
                  model_id,
                  creator,
                  doc_type,
                  proj_id=27,
                  f_txt=None):
        update_time = self.get_current_time()
        try:
            with open(json_url, 'r', encoding='gbk') as load_f:
                load_dict = json.load(load_f)
        except:
            try:
                with open(json_url, 'r', encoding='utf8') as load_f:
                    load_dict = json.load(load_f)
            except:
                f_txt.write("异常文件:" + json_url + "\n")
                return
        if not load_dict:
            print("空json文件!")
        doc_name = load_dict.get('basicDesignName')
        doc_id = self.get_doc_by_name(doc_name)
        if doc_id:
            CtrlDsDoc().delete(doc_id, "Admin", commit=False)
            # seq_list = CtrlDSSection().get_sequence2(doc_id)
            # if seq_list:
            #     # 把activity图都放在第一个时序图下面
            #     seq_id = seq_list[0].get('sec_id')
            #     act_list = load_dict.get('activityImaList')
            #     self.import_sequence(act_list, "Activity", doc_id, parent_sec_id=seq_id)
            #     db.session.commit()

        usecase_list = load_dict.get('usecaseImaList')
        if not usecase_list:
            f_txt.write("没有usecase的文件:" + json_url + "\n")
            return
        doc_data = {
            'doc_type': doc_type,
            'title': doc_name,
            'proj_id': proj_id,
            'model_id': model_id,
            'create_time': update_time,
            'update_time': update_time,
            'creator': creator,
            'editor': creator,
            'summary': '',
            'ver': '',
            'status': 1
        }
        self.init_version(doc_data, 'doc')
        commit_list = []
        doc_log = self.import_db(doc_data, Ds_Doc, Ds_Doc.doc_id)
        doc_id = doc_log.get('key_id')
        commit_list.append(doc_log)
        if_list = load_dict.get('ifList')
        commit_list += self.import_if(if_list, doc_id)
        usecase_log = self.import_section(usecase_list, "COMMON", doc_id)
        if usecase_log:
            commit_list.append(usecase_log)
        seq_list = load_dict.get('sequenceImaList')
        seq_commit = self.import_sequence(seq_list, "SEQUENCE", doc_id)
        commit_list = commit_list + seq_commit
        if seq_commit:
            seq_id = seq_commit[0].get('key_id')
            act_list = load_dict.get('activityImaList')
            commit_list += self.import_sequence(act_list,
                                                "Activity",
                                                doc_id,
                                                parent_sec_id=seq_id)
        std_list = load_dict.get('stateImaList')
        std_log = self.import_section(std_list, "STD", doc_id)
        if std_log:
            commit_list.append(std_log)
        block_list = load_dict.get('blockImgList')
        block_log = self.import_section(block_list, 'BLOCK', doc_id)
        if block_log:
            commit_list.append(block_log)
        class_list = load_dict.get('classImaList')
        class_log = self.import_section(class_list, 'CLASS', doc_id)
        if class_log:
            commit_list.append(class_log)
        self.commit_log(commit_list, creator, update_time)
        db.session.commit()
        from app.db import cache
        cache.delete('get_model_tree')  # 删除缓存