ecology_maven/sql/common-sql-mysql.sql

50 lines
1.9 KiB
MySQL
Raw Permalink Normal View History

2022-08-19 18:07:25 +08:00
create or replace view workflow_type_info_view as
select wb.id,wb.workflowname,wt.typename,wb.workflowdesc,
(case when wb.version is null then 1 else wb.version end) 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 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 ;
create or replace view workflow_field_table_view as
select
wb.id,
wb.fieldname,
ht.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 'workflow main table'
when wb.detailtable is null then 'workflow main table'
else wb.detailtable end
) showtablename,
wb.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;