def delete(self, doc_id, commit_user, commit=True): """ #删除整个文档 :param doc_id: :return: """ update_time = self.get_current_time() commit_list = [] from app.ctrl.ctrl_ds_rel_spec import CtrlDSRelSpec from app.ctrl.ctrl_ds_scene import CtrlDSScene commit_list += CtrlDSAstah().delete_by_doc_id(doc_id) commit_list += CtrlDSRelSpec().delete_by_doc_id(doc_id) commit_list += CtrlDsIf().delete_by_doc_id(doc_id) commit_list += CtrlDSSection().delete_section(doc_id, commit_user) commit_list += CtrlDSScene().del_rel_tag(doc_id) doc_log_list, error = self.delete_ds_doc(doc_id) if error: return error commit_list += doc_log_list if not commit: return commit_list self.commit_log(commit_list, commit_user, update_time) db.session.commit() from app.db import cache cache.delete('get_model_tree') # 删除缓存 return None
def get_db_for_journal(self, doc_id): """设计方档整体备份使用 :param doc_id: :return: """ from app.ctrl.ctrl_ds_rel_spec import CtrlDSRelSpec from app.ctrl.ctrl_ds_scene import CtrlDSScene db_objs = [] q = db.session.query(Ds_Doc).filter(Ds_Doc.doc_id == doc_id).first() ds_doc = q astahs = CtrlDSAstah().get_db_for_journal(doc_id) if astahs: db_objs += astahs ifs = CtrlDsIf().get_db_for_journal(doc_id) if ifs: db_objs += ifs specs = CtrlDSRelSpec().get_db_for_journal(doc_id) if specs: db_objs += specs drbfms = CtrlDSScene().get_db_for_journal(doc_id) if drbfms: db_objs += drbfms sections = CtrlDSSection().get_db_for_journal(doc_id) if sections: db_objs += sections if ds_doc: db_objs.append(ds_doc) return db_objs
def get(self, sec_id): result = {"result": "NG", "content": []} spec = CtrlDSRelSpec().get(sec_id) if spec: result["result"] = "OK" result["content"] = spec return result
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
def get(self, proj_id): """ usecase选择式样书的接口 :return: """ result = {"result": "NG", "content": []} spec_list = CtrlDSRelSpec().get_project_spec(proj_id) if spec_list: result["result"] = "OK" result["content"] = spec_list return result
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
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
def copy_basic_to_detail(self, basic_doc_id, commit_user, ds_doc): """ 把基本设计的内容拷贝到详细设计 :param doc_id: :return: """ update_time = ds_doc.get('update_time') commit_log_list = [] doc_log = self.common_add(self.db_object, ds_doc, None, self.col_list, self.key_col) detail_doc_id = doc_log.get('key_id') self.add_detail_doc_rel(basic_doc_id, detail_doc_id, commit_log_list) basic_doc_data = self.get_doc(basic_doc_id, detail='detail') sub_list = basic_doc_data.get('sub') from app.ctrl.ctrl_ds_rel_spec import CtrlDSRelSpec doc_spec_list, status = CtrlDSRelSpec().get_by_doc_id(basic_doc_id, None) self.copy_ds_spec(detail_doc_id, None, doc_spec_list, commit_log_list) commit_log_list += self.copy_doc_sub(sub_list, detail_doc_id, commit_user, update_time) self.commit_log(commit_log_list, commit_user, update_time) return detail_doc_id, commit_log_list