--权限按钮
truncate table T_FM_ROLE_MENU_PERM_BTN
go
delete T_FM_ROLE_MENU_PERM
go

--菜单
truncate table T_PF_MENU
go
delete  T_PF_BTN
go

--列表页查询
truncate table T_PF_QUERY
go
delete T_PF_FORM_QUERY
go

--//列表

delete T_FM_USER_C_C_EDIT_H_COL
go
delete T_FM_USER_C_C_EDIT
go
delete T_FM_USER_CUSTOM_CONFIG_H_COL
go
delete T_FM_USER_CUSTOM_CONFIG_H_TAB
go
delete T_FM_USER_C_C_QUERY_FIELD
go
delete T_FM_USER_C_C_QUERY
go
delete T_FM_USER_CUSTOM_CONFIG
go


delete T_PF_COLUMN
go
delete T_FM_USER_C_C_TABLE
go
delete T_PF_TABLE_PARAMS
go
delete T_FM_USER_CUSTOM_CONFIG_H_TAB
go
delete T_PF_PAGE_TABLE
go

--编辑
delete T_PF_EDIT_COLUMN_FILTER
go
delete T_PF_EDIT_COLUMN_FILL_MAP_D
go
delete T_PF_EDIT_COLUMN_FILL_MAP
go
delete T_FM_USER_C_C_EDIT_H_COL
go
delete T_PF_EDIT_COLUMN
go
 --编辑 填充区域
delete T_PF_PAGE_EDIT_PANEL
go
delete T_FM_USER_C_C_EDIT
go
delete T_PF_PAGE_EDIT
go

--表单
delete T_PF_PAGE_CUSTOM
go
delete T_PF_TREE_COLUMN
go
delete T_PF_PAGE_TREE
go
delete T_PF_SYS_LOG
go
delete T_FM_USER_C_C_QUERY_FIELD
go
delete T_FM_USER_C_C_QUERY
go

/****新****/
delete T_PF_FLOW_INSTANCE_OPER_HIS
go
delete T_PF_FLOW_INSTANCE_TRANS_HIS
go
delete T_PF_FLOW_INSTANCE
go
delete T_PF_FLOW_SCHEME
go


delete T_PF_PAGE_CHART_PARAM
go
delete T_PF_PAGE_CHART
go
/****新****/

delete T_PF_FORM
go


--OrgId 插入
--数据插入
insert into T_FM_ORGANIZATION
select * from mh_db.dbo.T_FM_ORGANIZATION where ID='B043B28B-BBC3-C452-6052-4FBA1457ABFA'

--delete T_FM_ORGANIZATION where ID='B043B28B-BBC3-C452-6052-4FBA1457ABFA'--最后执行语句

--数据插入
insert into T_PF_FORM
select * from mh_db.dbo.T_PF_FORM


--/****新****/


insert into T_PF_FLOW_SCHEME
select * from mh_db.dbo.T_PF_FLOW_SCHEME 

insert into T_PF_PAGE_CHART
select * from mh_db.dbo.T_PF_PAGE_CHART 

insert into T_PF_PAGE_CHART_PARAM
select * from mh_db.dbo.T_PF_PAGE_CHART_PARAM 


insert into T_PF_FLOW_INSTANCE
select * from mh_db.dbo.T_PF_FLOW_INSTANCE 

insert into T_PF_FLOW_INSTANCE_OPER_HIS
select * from mh_db.dbo.T_PF_FLOW_INSTANCE_OPER_HIS 

insert into T_PF_FLOW_INSTANCE_TRANS_HIS
select * from mh_db.dbo.T_PF_FLOW_INSTANCE_TRANS_HIS 

--/****新****/



--insert into T_FM_USER_C_C_QUERY
--select [ID], [USER_CUSTOM_CONFIG_ID], [PAGE_FORM_ID], [TITLE], [IS_DEFAULT], [IS_DELETED], [ORG_ID], [ENTITY_ORG_TPYE], [FORM_ID], [FLOW_STATUS], [FLOW_SEND_STATUS], [FLOW_ID], [CREATE_TIME], [MODIFY_TIME], null [CREATER_ID],null [MODIFIER_ID] from mh_db.dbo.T_FM_USER_C_C_QUERY

--insert into T_FM_USER_C_C_QUERY_FIELD
--select * from mh_db.dbo.T_FM_USER_C_C_QUERY_FIELD

--insert into T_PF_SYS_LOG
--select * from mh_db.dbo.T_PF_SYS_LOG

insert into T_PF_PAGE_TREE
select * from mh_db.dbo.T_PF_PAGE_TREE

insert into T_PF_TREE_COLUMN
select * from mh_db.dbo.T_PF_TREE_COLUMN

insert into T_PF_PAGE_CUSTOM
select * from mh_db.dbo.T_PF_PAGE_CUSTOM

--编辑
insert into T_PF_PAGE_EDIT
select * from mh_db.dbo.T_PF_PAGE_EDIT --如果不行 直接拉取表单的列，demo如下
--select [ID], [PAGE_FORM_ID], [CODE], [EDIT_NAME], [LABEL_NAME], [API_URL], [IS_CONTAINS_NAV], [SEND_TYPE], [WIDTH], [HEIGTH], [QUERY_API_URL], [QUERY_SEND_TYPE], [BATCH_QUERY_API], [BATCH_UPDATE_API], [RELATION_FIELD], [NAV_PROPERTY], [IS_DETAIL_REQUIRED], [CODE_FIELD_NAME], [CODE_RULE_TYPE], [NAV_ROW_CLASS_FILTER], [SORT_FIELDS], [SORT_ORDERS], [CUSTOM_PARAMS], [SUB_TABLE_CONDITION], [PARENT_COPY_FIELD], [CHILD_SET_FIELD], [NUM], [IS_PERMIT_ADD_ROW], [IS_PERMIT_DEL_ROW], [EDIT_PAGE_ENTITY_ORG_TYPE], [IS_SUB_ADD_BTN_DISABLED], [IS_SUB_DELETE_BTN_DISABLED], [SHOW_CHECK], [PARAM_SCHEME_ID], [SRC_ID], [IS_DELETED], [ORG_ID], [ENTITY_ORG_TPYE], [FORM_ID], [FLOW_STATUS], [FLOW_SEND_STATUS], [FLOW_ID], [CREATE_TIME], [MODIFY_TIME], [CREATER_ID], [MODIFIER_ID], [PARENT_ID], [TEXT], [IS_LEAF], [DEFAULT_PAGE_SIZE], [IS_PAGE] from mh_db.dbo.T_PF_PAGE_EDIT

--insert into T_FM_USER_C_C_EDIT
--select * from mh_db.dbo.T_FM_USER_C_C_EDIT

insert into T_PF_PAGE_EDIT_PANEL
select * from mh_db.dbo.T_PF_PAGE_EDIT_PANEL

insert into T_PF_EDIT_COLUMN
select * from mh_db.dbo.T_PF_EDIT_COLUMN --如果不行 直接拉取表单的列，demo如下
--select [ID], [CODE], [PAGE_EDIT_ID], [FIELD_NAME], [IS_TABLE_COLUMN], [LABEL], [IS_DEFAULT], [IS_CUSTOM], [TYPE_NAME], [REQUIRED], [EDITABLE], [PERMIT_EDITABLE], [FORMAT], [INPUT_DATA_API], [INPUT_ID_FIELD], [IS_ONLY_CHECK_LEAF], [INPUT_DATA_LEVEL], [INPUT_FILTER_FIELD], [INPUT_SORT_FIELD], [INPUT_SORT_ORDER], [INPUT_LABEL_FIELD], [INPUT_SHOW_FIELD], [INPUT_NAV_FIELD], [INPUT_SAVE_FIELD], [SELECTD_LABEL_FIELD], [INPUT_FILTER_ORG_TYPE], [IS_IGNORE_TENANT], [INPUT_KEEP_VALUE_BY_NO_SRC], [QUERY_FORMAT], [ENUM], [CONTROL_TYPE], [VALIDATA_TYPE], [NUM], [MIN_LEN], [MAX_LEN], [VERIFY_MSG], [SHOW_FORM_CODE], [SHOW_ID_FIELD], [PAGE_EDIT_PANEL_ID], [IS_CAN_BATCH_EDIT], [EDIT_FORM_CODE], [EDIT_FORM_FILTER], [EDIT_FORM_FILTER_VALUE], [CASE], [WIDTH], [REMARK], [DEFAULT_VALUE], [PROMPT_INFO], [VERIFY_EXPRESS], [VERIFY_TYPE], [VERIFY_ERROR_INFO], [IS_COPY], [CODE_RULE_TYPE], [SRC_ID], [IS_RULE], [IS_DELETED], [ORG_ID], [ENTITY_ORG_TPYE], [FORM_ID], [FLOW_STATUS], [FLOW_SEND_STATUS], [FLOW_ID], [CREATE_TIME], [MODIFY_TIME], [CREATER_ID], [MODIFIER_ID], [HEIGHT], [SHOW_TYPE], [IS_CHECK_MAX], [IS_CHECK_MIN], [MAX_VAL], [MIN_VAL], [STEP] from mh_db.dbo.T_PF_EDIT_COLUMN

insert into T_PF_EDIT_COLUMN_FILL_MAP
select * from mh_db.dbo.T_PF_EDIT_COLUMN_FILL_MAP

insert into T_PF_EDIT_COLUMN_FILL_MAP_D
select * from mh_db.dbo.T_PF_EDIT_COLUMN_FILL_MAP_D



insert into T_FM_USER_CUSTOM_CONFIG
select * from mh_db.dbo.T_FM_USER_CUSTOM_CONFIG

insert into T_FM_USER_C_C_EDIT
select * from mh_db.dbo.T_FM_USER_C_C_EDIT

insert into T_FM_USER_C_C_EDIT_H_COL
select * from mh_db.dbo.T_FM_USER_C_C_EDIT_H_COL




--//列表
insert into T_PF_PAGE_TABLE
select * from mh_db.dbo.T_PF_PAGE_TABLE

insert into T_FM_USER_CUSTOM_CONFIG_H_TAB
select * from mh_db.dbo.T_FM_USER_CUSTOM_CONFIG_H_TAB




insert into T_FM_USER_CUSTOM_CONFIG_H_COL
select * from mh_db.dbo.T_FM_USER_CUSTOM_CONFIG_H_COL

insert into T_FM_USER_C_C_QUERY
select * from mh_db.dbo.T_FM_USER_C_C_QUERY


insert into T_FM_USER_C_C_QUERY_FIELD
select * from mh_db.dbo.T_FM_USER_C_C_QUERY_FIELD

insert into T_FM_USER_C_C_EDIT_H_COL
select * from mh_db.dbo.T_FM_USER_C_C_EDIT_H_COL

insert into T_PF_EDIT_COLUMN_FILTER
select * from mh_db.dbo.T_PF_EDIT_COLUMN_FILTER





----//列表
--insert into T_PF_PAGE_TABLE
--select * from mh_db.dbo.T_PF_PAGE_TABLE

--insert into T_FM_USER_CUSTOM_CONFIG_H_TAB
--select * from mh_db.dbo.T_FM_USER_CUSTOM_CONFIG_H_TAB

insert into T_PF_TABLE_PARAMS
select * from mh_db.dbo.T_PF_TABLE_PARAMS

--insert into T_FM_USER_C_C_TABLE
--select * from mh_db.dbo.T_FM_USER_C_C_TABLE

insert into T_PF_COLUMN
select * from mh_db.dbo.T_PF_COLUMN



--列表页查询
insert into T_PF_FORM_QUERY
select * from mh_db.dbo.T_PF_FORM_QUERY

insert into T_PF_QUERY
select * from mh_db.dbo.T_PF_QUERY

--菜单
insert into T_PF_BTN
select * from mh_db.dbo.T_PF_BTN

insert into T_PF_MENU
select * from mh_db.dbo.T_PF_MENU order by MENU_FORM_ID,IS_LEAF  

--权限按钮
insert into T_FM_ROLE --(具体分析是否重复 修改对应人员关联角色)
select * from mh_db.dbo.T_FM_ROLE where ID not in(select ID from T_FM_ROLE)

insert into T_FM_ROLE_MENU_PERM
select * from mh_db.dbo.T_FM_ROLE_MENU_PERM

insert into T_FM_ROLE_MENU_PERM_BTN
select * from mh_db.dbo.T_FM_ROLE_MENU_PERM_BTN

--OrgId更新
select top 1 ORG_ID from  T_FM_USER

--权限按钮
update  T_FM_ROLE_MENU_PERM set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_ROLE set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_ROLE_MENU_PERM_BTN set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
--菜单
update  T_PF_MENU set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update   T_PF_BTN set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'

--列表页查询
update  T_PF_QUERY set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_FORM_QUERY set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'

--//列表
update  T_PF_COLUMN set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_C_C_TABLE set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_TABLE_PARAMS set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_CUSTOM_CONFIG_H_TAB set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_PAGE_TABLE set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'

--编辑
update  T_PF_EDIT_COLUMN_FILTER set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_EDIT_COLUMN_FILL_MAP_D set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_EDIT_COLUMN_FILL_MAP set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_C_C_EDIT_H_COL set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_EDIT_COLUMN set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
 --编辑 填充区域
update  T_PF_PAGE_EDIT_PANEL set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_C_C_EDIT set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_PAGE_EDIT set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'

--表单
update  T_PF_PAGE_CUSTOM set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_TREE_COLUMN set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_PAGE_TREE set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_SYS_LOG set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_C_C_QUERY_FIELD set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_C_C_QUERY set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_PF_FORM set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'


--不懂是啥 反正插入了就 修改
update  T_FM_USER_C_C_EDIT_H_COL set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_C_C_EDIT set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_CUSTOM_CONFIG_H_COL set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_CUSTOM_CONFIG_H_TAB set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_C_C_QUERY_FIELD set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_C_C_QUERY set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update  T_FM_USER_CUSTOM_CONFIG set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update T_PF_FLOW_SCHEME	set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update T_PF_PAGE_CHART	set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update T_PF_PAGE_CHART_PARAM set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update T_PF_FLOW_INSTANCE set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update T_PF_FLOW_INSTANCE_OPER_HIS set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'
update T_PF_FLOW_INSTANCE_TRANS_HIS set ORG_ID ='3EFD5276-632B-E379-9FF3-7A7546591FCA'


--最后执行语句 
 delete T_FM_ORGANIZATION where ID='B043B28B-BBC3-C452-6052-4FBA1457ABFA'

