You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-hrm-organization/docs/非标从发SQL脚本/MySQL.sql

69 lines
6.1 KiB
SQL

-- 更新表结构
alter table JCL_ORG_COMP add ec_company int;
alter table JCL_ORG_DEPT add ec_company int;
alter table JCL_ORG_DEPT add ec_department int;
alter table jcl_org_staffplan add ec_company varchar(100);
alter table jcl_org_staff add ec_company int;
alter table jcl_org_staff add ec_department int;
alter table JCL_ORG_STAFFS add description varchar(200);
-- 插入自定义信息
insert INTO jcl_field_extendinfo (extend_type, table_name, field_name, field_name_desc, field_type, control_type, extend_group_id, isenable, isrequired, list_show, search_show, edit_show, add_show, browser_show, show_order, creator, delete_type, create_time, update_time, browser_type, custom_value, is_system_default) VALUES (1, 'JCL_ORG_COMP', 'ec_company', '上级公司', 'int', 3, 1, 1, 0, 1, 1, 1, 1, 1, 6, 1, 0, now(), NULL, '164', '["browser",{"valueSpan":"分部","replaceDatas":[{"name":"分部","id":"164"}],"value":"164"}]', 0);
insert INTO jcl_field_extendinfo (extend_type, table_name, field_name, field_name_desc, field_type, control_type, extend_group_id, isenable, isrequired, list_show, search_show, edit_show, add_show, browser_show, show_order, creator, delete_type, create_time, update_time, browser_type, custom_value, is_system_default) VALUES (2, 'JCL_ORG_DEPT', 'ec_company', '所属分部', 'int', 3, 2, 1, 1, 1, 1, 1, 1, 1, 4, 1, 0, now(), NULL, '164', '["browser",{"valueSpan":"分部","replaceDatas":[{"name":"分部","id":"164"}],"value":"164"}]', 0);
insert INTO jcl_field_extendinfo (extend_type, table_name, field_name, field_name_desc, field_type, control_type, extend_group_id, isenable, isrequired, list_show, search_show, edit_show, add_show, browser_show, show_order, creator, delete_type, create_time, update_time, browser_type, custom_value, is_system_default) VALUES (2, 'JCL_ORG_DEPT', 'ec_department', '上级部门', 'int', 3, 2, 1, 0, 1, 1, 1, 1, 1, 5, 1, 0, now(), NULL, '4', '["browser",{"valueSpan":"部门","replaceDatas":[{"name":"部门","id":"4"}],"value":"4"}]', 0);
-- 更新自定义字段信息
update jcl_field_extendinfo set list_show =0,search_show =0,edit_show =0,add_show =0 where table_name ='JCL_ORG_COMP' and field_name ='parent_company';
update jcl_field_extendinfo set list_show =0,search_show =0,edit_show =0,add_show =0 where table_name ='JCL_ORG_DEPT' and field_name ='parent_comp';
update jcl_field_extendinfo set list_show =0,search_show =0,edit_show =0,add_show =0 where table_name ='JCL_ORG_DEPT' and field_name ='parent_dept';
update jcl_field_extendinfo set search_show=0,edit_show=0,add_show=0 where table_name ='JCL_ORG_JOB' and field_name='ec_company';
-- 更新浏览按钮
update WORKFLOW_BROWSERURL set TYPEID ='2' where ID = '666';
update datashowparam set ISSHOWNAME =0 where SEARCHNAME = 'post_info_no';
update datashowparam set ISSHOWNAME =1 where SEARCHNAME = 'post_info_name';
-- 更新视图
drop view v_jcl_zdzj;
drop view v_jcl_post;
create view v_jcl_zdzj as
select concat('A',xl.id) fid,xl.sequence_name fname,'0' fparentid,xl.sequence_no fno,xl.id fobjid,'1' as ftype
from jcl_org_sequence xl
inner join JCL_ORG_GRADE zj on zj.scheme_id=xl.scheme_id and ifnull(zj.forbidden_tag,0)<>1 and ifnull(zj.delete_type,0)<>1
inner join JCL_ORG_LEVEL zd on zd.scheme_id=zd.scheme_id and ifnull(zd.forbidden_tag,0)<>1 and ifnull(zd.delete_type,0)<>1
where ifnull(xl.forbidden_tag,0)<>1 and ifnull(xl.delete_type,0)<>1
union
select concat(xl.id,'A',zj.id),zj.grade_name,concat('A',xl.id),zj.grade_no,zj.id,'2' as ftype
from JCL_ORG_GRADE zj
inner join jcl_org_sequence xl on zj.scheme_id=xl.scheme_id
inner join JCL_ORG_LEVEL zd on concat(',',zj.level_id,',') like concat('%,',zd.id,',%') and ifnull(zd.forbidden_tag,0)<>1 and ifnull(zd.delete_type,0)<>1
where ifnull(zj.forbidden_tag,0)<>1 and ifnull(zj.delete_type,0)<>1
union
select concat(xl.id,'A',zj.id,'A',zd.id),zd.level_name,concat(xl.id,'A',zj.id),zd.level_no,zd.id,'3' as ftype
from JCL_ORG_LEVEL zd
inner join JCL_ORG_GRADE zj on concat(',',zj.level_id,',') like concat('%,',zd.id,',%')
inner join jcl_org_sequence xl on zj.scheme_id=xl.scheme_id
where ifnull(zd.forbidden_tag,0)<>1 and ifnull(zd.delete_type,0)<>1;
create view v_jcl_post as
select a.id*-1 fid,a.post_name fname,0 fparentid from JCL_ORG_POST a
inner join JCL_ORG_POST_INFO b on a.id =b.post_id and ifnull(b.forbidden_tag,0)<>1 and ifnull(b.delete_type,0)<>1
where ifnull(a.delete_type,0)<>1
union
select id,post_info_name,post_id*-1 from JCL_ORG_POST_INFO
where ifnull(forbidden_tag,0)<>1 and ifnull(delete_type,0)<>1;
--- MySQL
-- 更新分部ec_company
update jcl_org_comp d set ec_company = ( select eccompany from ( select b.id as parent_company, c.id as eccompany from jcl_org_comp a inner join jcl_org_comp b on a.parent_company = b.id inner join hrmsubcompany c on b.uuid = c.uuid group by b.id ) e where d.parent_company = e.parent_company );
-- 更新部门ec_department、ec_company
update JCL_ORG_DEPT d set ec_department = ( select ecdepartment from ( select b.id as parent_dept, c.id as ecdepartment from JCL_ORG_DEPT a inner join JCL_ORG_DEPT b on a.parent_dept = b.id inner join hrmdepartment c on b.uuid = c.uuid group by b.id ) e where d.parent_dept = e.parent_dept );
update JCL_ORG_DEPT d set ec_company = ( select eccompany from ( select a.id as id, c.id as eccompany from jcl_org_comp a inner join hrmsubcompany c on a.uuid = c.uuid) e where d.parent_comp = e.id );
-- 更新人员jobtitle
-- update hrmresource set jobtitle = ( select id from HRMJOBTITLES where JOBTITLENAME = ( select JOB_NAME from jcl_org_job where id = ( select FIELD100002 from CUS_FIELDDATA where scope = 'HrmCustomFieldByInfoType' and SCOPEID = '-1' and CUS_FIELDDATA.ID = hrmresource.ID)));
-- 更新岗位ec_company、ec_department
update jcl_org_job d set ec_company = (select eccompany from ( select a.id as id, c.id as eccompany from jcl_org_comp a inner join hrmsubcompany c on a.uuid = c.uuid) e where d.parent_comp = e.id );
update jcl_org_job d set ec_department = ( select ec_department from ( select a.id as id, c.id as ec_department from jcl_org_dept a inner join hrmdepartment c on a.uuid = c.uuid) e where d.parent_dept = e.id );