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/sqlupgrade/Mysql/sql202212120503.sql

72 lines
3.4 KiB
SQL

delete from jcl_org_cardaccess;
insert into jcl_org_cardaccess (type_id, type_name, status, all_people , superior , all_superior ,
delete_type, creator, create_time, update_time) select ID,
FORMLABEL , 1, 0, 0, 0, 0, 1, now(),
now() from cus_treeform where scope='HrmCustomFieldByInfoType';
update jcl_org_cardbutton set name = '详细信息', url = '/spa/hrm/index_mobx.html#/main/hrm/card/cardInfo/${id}' where id = 1;
delete from jcl_org_map;
INSERT INTO jcl_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname,
fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid,
fplan, fonjob, fisvitual, fdatebegin, fdateend)
SELECT 0, 0, 0, uuid, 0, '行政维度', '00', companyname,
0, NULL, NULL, 0, NULL, -1, 0,
0, 0, 0, NOW(), '2099-12-31' FROM hrmcompany;
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,
fplan,fonjob,fisvitual,fdatebegin,fdateend)
select a.id,1,a.id,a.uuid,0,'行政维度', '',a.subcompanyname,null,'',
'',NULL,'','','',ifnull(a.supsubcomid,0),ifnull(a.supsubcomid,0),
0,0,0,NOW(),'2099-12-31' from hrmsubcompany as a
where IFNULL(a.canceled,0) <>1;
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,
fplan,fonjob,fisvitual,fdatebegin,fdateend)
select a.id+100000000,2,a.id,a.uuid,0,'行政维度',a.DEPARTMENTCODE,a.departmentname,a.BMFZR,b.messagerurl,
b.lastname,b.jobtitle,c.jobtitlemark,null,null,
(case ifnull(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid+100000000 end),
(case ifnull(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid end),
0,0,0,NOW(),'2099-12-31'
from
HrmDepartment as a
left join hrmresource as b on a.BMFZR=b.ID
left join hrmjobtitles as c on b.JOBTITLE=c.id
where IFNULL(a.canceled,0) <>1;
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,
fparentid,fobjparentid,
fplan,fonjob,fisvitual,fdatebegin,fdateend)
select a.id+200000000,3,a.id,g.uuid,0,'行政维度',a.job_no,g.jobtitlename,
ec_department+100000000,
ec_department,
ifnull(e.fcnt,0),ifnull(f.fcnt,0),0,NOW(),'2099-12-31'
from JCL_ORG_job as a
left join (select job_id,sum(ifnull(staff_num,0)) fcnt from JCL_ORG_STAFF
where plan_id in (select id from JCL_ORG_STAFFPLAN
where time_start<=NOW() and time_end>NOW() and delete_type=0)
group by job_id) e on a.id=e.job_id
left join (select JOBTITLE,count(1) fcnt from hrmresource group by JOBTITLE
) f
on f.JOBTITLE=a.ec_jobTitle
left join HrmJobTitles g on a.ec_jobTitle = g.id
where ifnull(a.delete_type,0) <>1 and ifnull(a.forbidden_tag,0) <>1;
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleaderimg,
fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,
fisvitual,fdatebegin,fdateend)
select a.id+300000000,4,a.id,a.uuid,0,'行政维度',a.workcode,a.LASTNAME,a.messagerurl,
c.id,c.jobtitlename,null,null, ifnull( b.id, '' ) +200000000,b.id,
0,NOW(),'2099-12-31'
from hrmresource a
left join jcl_org_job b ON a.JOBTITLE = b.ec_jobTitle
left join HrmJobTitles c on b.ec_jobTitle = c.id
where a.status<4;