From 8c0dbedc025d83c552c0a6013ce3d7180f4a8f56 Mon Sep 17 00:00:00 2001 From: "youHong.ai" <774495953@qq.com> Date: Thu, 24 Nov 2022 15:08:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=B8=B8=E7=94=A8=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 常用信息.md | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) diff --git a/常用信息.md b/常用信息.md index 765c46e..3581327 100644 --- a/常用信息.md +++ b/常用信息.md @@ -118,4 +118,256 @@ myComp.setState({test1: test2}); mysqldump -uroot -p'passowrd' --single-transaction -R -E --databases ecology_dev> /tmp/ecology_dev_back.sql ``` +**mysql常用视图** + +```mysql +# 流程类型视图,可用于数据集成或流览按钮 +create or replace view workflow_type_info_view as +select wb.id, + wb.workflowname, + wt.typename, + wb.workflowdesc, + (IF(wb.version is null, 1, wb.version)) version +from workflow_base wb + RIGHT JOIN workflow_type wt on wb.workflowtype = wt.id; + +# 流程表单视图,用于流览按钮或数据集成,配置流程类型表可以用字段联动获取流程表表名 +create or replace view workflow_table_view as +select base.id, + base.workflowname, + base.formid, + bill.tablename, + (IF(base.version is null, 1, base.version)) version +from workflow_bill bill + join workflow_base base on base.formid = bill.id; + +# 流程明细表信息,可用流程主表查询对应的明细表信息,用于流览框 +create or replace view workflow_detail_table_view as +select CONCAT(bill.id, '-', base.id) id, + bill.id bill_id, + base.id workflow_id, + base.workflowname, + base.formid main_formid, + bill.tablename +from workflow_billdetailtable bill + join workflow_base base on base.formid = bill.billid; + +# 流程和建模字段视图,更具流程和建模的billid可以查询流程和建模中的字段信息 +create or replace view workflow_field_table_view as +select wb.id, + wb.fieldname, + concat(ht.indexdesc, ':', wb.fieldname) indexdesc, + ( + case + when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid) + when wb.detailtable = '' + then (select distinct tablename from workflow_bill where id = wb.billid) + else wb.detailtable + end + ) tablename, + billid, + ( + case + when wb.detailtable = '' then 'main table' + when wb.detailtable is null then 'main table' + else wb.detailtable end + ) showtablename, + (case + when wb.fieldhtmltype = '1' then '单行文本框' + when wb.FIELDHTMLTYPE = '2' then '多行文本框' + when wb.FIELDHTMLTYPE = '3' then '流览框' + when wb.FIELDHTMLTYPE = '4' then 'check框' + when wb.FIELDHTMLTYPE = '5' then '选择框' + else '附件上传' end) fieldhtmltype +from workflow_billfield wb + left join htmllabelindex ht on wb.fieldlabel = ht.id; + +# 建模表信息视图 +create or replace view mode_bill_info_view as +select bill.id, bill.tablename, hti.indexdesc +from workflow_bill bill + left join htmllabelindex hti on hti.id = bill.namelabel +where bill.id < 0 + and bill.tablename like 'uf%'; + +# 流程节点信息视图 +create or replace view workflow_node_info_view as +select distinct nb.id, + nb.nodename, + (case when wb.version is null then 1 else wb.version end) version, + fn.workflowid +from workflow_nodebase nb + left join workflow_flownode fn on nb.id = fn.nodeid + left join workflow_base wb on wb.id = fn.workflowid; + +``` + +**oracle常用视图,与mysql对应** + +```oracle +create or replace view workflow_type_info_view as +select wb.id, + wb.workflowname, + wt.typename, + wb.workflowdesc, + (IF(wb.version is null, 1, wb.version)) version +from workflow_base wb + RIGHT JOIN workflow_type wt on wb.workflowtype = wt.id +/ + +create or replace view workflow_table_view as +select base.id, + base.workflowname, + base.formid, + bill.tablename, + (IF(base.version is null, 1, base.version)) version +from workflow_bill bill + join workflow_base base on base.formid = bill.id +/ + +create or replace view workflow_detail_table_view as +select (bill.id || '-' || base.id) id, + bill.id bill_id, + base.id workflow_id, + base.workflowname, + base.formid main_formid, + bill.tablename +from workflow_billdetailtable bill + join workflow_base base on base.formid = bill.billid +/ + + +create or replace view workflow_field_table_view as +select wb.id, + wb.fieldname, + (ht.indexdesc || ':' || wb.fieldname) indexdesc, + ( + case + when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid) + when wb.detailtable = '' + then (select distinct tablename from workflow_bill where id = wb.billid) + else wb.detailtable + end + ) tablename, + billid, + ( + case + when wb.detailtable = '' then 'main table' + when wb.detailtable is null then 'main table' + else wb.detailtable end + ) showtablename, + (case + when wb.fieldhtmltype = '1' then '单行文本框' + when wb.FIELDHTMLTYPE = '2' then '多行文本框' + when wb.FIELDHTMLTYPE = '3' then '流览框' + when wb.FIELDHTMLTYPE = '4' then 'check框' + when wb.FIELDHTMLTYPE = '5' then '选择框' + else '附件上传' end) fieldhtmltype +from workflow_billfield wb + left join htmllabelindex ht on wb.fieldlabel = ht.id +/ + +create or replace view mode_bill_info_view as +select bill.id, bill.tablename, hti.indexdesc +from workflow_bill bill + left join htmllabelindex hti on hti.id = bill.namelabel +where bill.id < 0 + and bill.tablename like 'uf%' +/ + +create or replace view workflow_node_info_view as +select distinct nb.id, + nb.nodename, + (case when wb.version is null then 1 else wb.version end) version, + fn.workflowid +from workflow_nodebase nb + left join workflow_flownode fn on nb.id = fn.nodeid + left join workflow_base wb on wb.id = fn.workflowid +/ + +``` + +**sqlserver常用视图,与mysql对应** + +```sql +create view workflow_type_info_view as +select wb.id, + wb.workflowname, + wt.typename, + wb.workflowdesc, + ( + IF(wb.version is null, 1, wb.version)) version +from workflow_base wb + RIGHT JOIN workflow_type wt on wb.workflowtype = wt.id; + +create +or replace view workflow_table_view as +select base.id, + base.workflowname, + base.formid, + bill.tablename, + ( + IF(base.version is null, 1, base.version)) version +from workflow_bill bill + join workflow_base base on base.formid = bill.id; + +create +or replace view workflow_detail_table_view as +select (bill.id + '-' + base.id) id, + bill.id bill_id, + base.id workflow_id, + base.workflowname, + base.formid main_formid, + bill.tablename +from workflow_billdetailtable bill + join workflow_base base on base.formid = bill.billid; + + +create view workflow_field_table_view as +select wb.id, + wb.fieldname, + (ht.indexdesc + ':' + wb.fieldname) indexdesc, + ( + case + when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid) + when wb.detailtable = '' + then (select distinct tablename from workflow_bill where id = wb.billid) + else wb.detailtable + end + ) tablename, + billid, + ( + case + when wb.detailtable = '' then 'main table' + when wb.detailtable is null then 'main table' + else wb.detailtable end + ) showtablename, + (case + when wb.fieldhtmltype = '1' then '单行文本框' + when wb.FIELDHTMLTYPE = '2' then '多行文本框' + when wb.FIELDHTMLTYPE = '3' then '流览框' + when wb.FIELDHTMLTYPE = '4' then 'check框' + when wb.FIELDHTMLTYPE = '5' then '选择框' + else '附件上传' end) fieldhtmltype +from workflow_billfield wb + left join htmllabelindex ht on wb.fieldlabel = ht.id; + +create view mode_bill_info_view as +select bill.id, bill.tablename, hti.indexdesc +from workflow_bill bill + left join htmllabelindex hti on hti.id = bill.namelabel +where bill.id < 0 + and bill.tablename like 'uf%'; + +create view workflow_node_info_view as +select distinct nb.id, + nb.nodename, + (case when wb.version is null then 1 else wb.version end) version, + fn.workflowid +from workflow_nodebase nb + left join workflow_flownode fn on nb.id = fn.nodeid + left join workflow_base wb on wb.id = fn.workflowid; + +``` + ### 后端