兼容Oracle

pull/193/MERGE^2
dxfeng 3 years ago
parent 1318fc1aba
commit e4d9d80fee

@ -10,17 +10,31 @@ vleader int;
vdatebegin date; vdatebegin date;
vplan int; vplan int;
vonjob int; vonjob int;
vcnt int;
begin begin
if :new.companyname!=:old.companyname then if :new.companyname!=:old.companyname then
select count(1) into vcnt from jcl_info where id=1;
if vcnt=1 then
select to_number(fvalue) into vleader from jcl_info where id=1; select to_number(fvalue) into vleader from jcl_info where id=1;
end if;
select count(1) into vcnt from hrmresource where id=vleader;
if vcnt=1 then
select messagerurl,lastname,jobtitle into vleaderimg,vleadername,vleaderjobid select messagerurl,lastname,jobtitle into vleaderimg,vleadername,vleaderjobid
from hrmresource where id=vleader; from hrmresource where id=vleader;
end if;
select count(1) into vcnt from hrmjobtitles where id=vleaderjobid;
if vcnt=1 then
select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid; select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid;
end if;
select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=vleader;
if vcnt=1 then
select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata
where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=vleader; where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=vleader;
end if;
vdatebegin:=sysdate; vdatebegin:=sysdate;
@ -60,6 +74,7 @@ vdatebegin date;
vobjparentid int; vobjparentid int;
vplan int; vplan int;
vonjob int; vonjob int;
vcnt int;
begin begin
if :new.comp_name!=:old.comp_name or :new.comp_principal!=:old.comp_principal or :new.parent_company!=:old.parent_company if :new.comp_name!=:old.comp_name or :new.comp_principal!=:old.comp_principal or :new.parent_company!=:old.parent_company
or :new.forbidden_tag!=:old.forbidden_tag or :new.DELETE_TYPE!=:old.DELETE_TYPE then or :new.forbidden_tag!=:old.forbidden_tag or :new.DELETE_TYPE!=:old.DELETE_TYPE then
@ -68,13 +83,28 @@ begin
vparentid:=nvl(:new.parent_company,0); vparentid:=nvl(:new.parent_company,0);
vobjparentid:=nvl(:new.parent_company,0); vobjparentid:=nvl(:new.parent_company,0);
select count(1) into vcnt from HrmSubCompany where uuid=:new.uuid;
if vcnt=1 then
select id into vecid from HrmSubCompany where uuid=:new.uuid; select id into vecid from HrmSubCompany where uuid=:new.uuid;
end if;
select count(1) into vcnt from hrmresource where id=:new.comp_principal;
if vcnt=1 then
select messagerurl,lastname,jobtitle into vleaderimg,vleadername,vleaderjobid from hrmresource where id=:new.comp_principal; select messagerurl,lastname,jobtitle into vleaderimg,vleadername,vleaderjobid from hrmresource where id=:new.comp_principal;
end if;
select count(1) into vcnt from hrmjobtitles where id=vleaderjobid;
if vcnt=1 then
select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid; select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid;
end if;
select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.comp_principal;
if vcnt=1 then
select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata
where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.comp_principal; where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.comp_principal;
select sum(nvl(staff_num,0)) into vplan from JCL_ORG_STAFF end if;
where plan_id in (select id from JCL_ORG_STAFFPLAN where time_start<=vdatebegin and time_end>=vdatebegin) and comp_id=:new.id;
select sum(nvl(staff_num,0)) into vplan from JCL_ORG_STAFF;
select count(1) into vonjob from hrmresource where status<=3 and subcompanyid1=vecid; select count(1) into vonjob from hrmresource where status<=3 and subcompanyid1=vecid;
delete from jcl_org_map where ftype=1 and fobjid=:new.id and fdatebegin=vdatebegin; delete from jcl_org_map where ftype=1 and fobjid=:new.id and fdatebegin=vdatebegin;
@ -108,6 +138,7 @@ st int;
vleaderlv VARCHAR2(255); vleaderlv VARCHAR2(255);
vplan int; vplan int;
vonjob int; vonjob int;
vcnt int;
begin begin
if :new.dept_name!=:old.dept_name or :new.dept_principal!=:old.dept_principal or :new.parent_comp!=:old.parent_comp if :new.dept_name!=:old.dept_name or :new.dept_principal!=:old.dept_principal or :new.parent_comp!=:old.parent_comp
or :new.parent_dept!=:old.parent_dept or :new.forbidden_tag!=:old.forbidden_tag or :new.DELETE_TYPE!=:old.DELETE_TYPE then or :new.parent_dept!=:old.parent_dept or :new.forbidden_tag!=:old.forbidden_tag or :new.DELETE_TYPE!=:old.DELETE_TYPE then
@ -126,15 +157,28 @@ else
vobjparentid:=:new.parent_dept+st; vobjparentid:=:new.parent_dept+st;
end if; end if;
select count(1) into vcnt from HrmDepartment where uuid=:new.uuid;
if vcnt=1 then
select id into vecid from HrmDepartment where uuid=:new.uuid; select id into vecid from HrmDepartment where uuid=:new.uuid;
end if;
select count(1) into vcnt from hrmresource where id=:new.dept_principal;
if vcnt=1 then
select messagerurl,lastname,jobtitle into vleaderimg,vleadername,veaderjobid select messagerurl,lastname,jobtitle into vleaderimg,vleadername,veaderjobid
from hrmresource where id=:new.dept_principal; from hrmresource where id=:new.dept_principal;
end if;
select count(1) into vcnt from hrmjobtitles where id=:new.dept_principal;
if vcnt=1 then
select jobtitlemark into vleaderjob from hrmjobtitles where id=:new.dept_principal; select jobtitlemark into vleaderjob from hrmjobtitles where id=:new.dept_principal;
end if;
select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.dept_principal;
if vcnt=1 then
select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata
where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.dept_principal; where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.dept_principal;
end if;
select sum(nvl(staff_num,0)) into vplan from JCL_ORG_STAFF select sum(nvl(staff_num,0)) into vplan from JCL_ORG_STAFF
where plan_id in (select id from JCL_ORG_STAFFPLAN where time_start<=vdatebegin and time_end>=vdatebegin) and dept_id=:new.id; where plan_id in (select id from JCL_ORG_STAFFPLAN where time_start<=vdatebegin and time_end>=vdatebegin) and dept_id=:new.id;
@ -215,6 +259,7 @@ st int;
vleaderlv VARCHAR2(255); vleaderlv VARCHAR2(255);
vstr VARCHAR2(255); vstr VARCHAR2(255);
vwz int; vwz int;
vcnt int;
begin begin
if :new.lastname!=:old.lastname or :new.status!=:old.status then if :new.lastname!=:old.lastname or :new.status!=:old.status then
st:=100000000; st:=100000000;
@ -227,17 +272,29 @@ begin
else else
vdelete:=1; vdelete:=1;
end if; end if;
select count(1) into vcnt from hrmjobtitles where id=:new.jobtitle;
if vcnt=1 then
select jobtitlemark into vleaderjob from hrmjobtitles where id=:new.jobtitle; select jobtitlemark into vleaderjob from hrmjobtitles where id=:new.jobtitle;
end if;
select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id;
if vcnt=1 then
select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata
where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id; where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id;
end if;
delete from jcl_org_map where ftype=4 and fobjid=:new.id and fdatebegin=vdatebegin; delete from jcl_org_map where ftype=4 and fobjid=:new.id and fdatebegin=vdatebegin;
update jcl_org_map set fdateend=vdatebegin-1 where ftype=4 and fobjid=:new.id and fdateend>vdatebegin; update jcl_org_map set fdateend=vdatebegin-1 where ftype=4 and fobjid=:new.id and fdateend>vdatebegin;
select nvl(field100002,'') into vstr from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id;
select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=:new.id;
if vcnt=1 then
select nvl(field100002,'') into vstr from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=:new.id;
end if;
vwz:=Instr(vstr,'_'); vwz:=Instr(vstr,'_');
vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz)); vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz));
vparentid:=vobjparentid+sj; vparentid:=vobjparentid+sj;
@ -274,6 +331,7 @@ st int;
vleaderlv VARCHAR2(255); vleaderlv VARCHAR2(255);
vstr VARCHAR2(255); vstr VARCHAR2(255);
vwz int; vwz int;
vcnt int;
begin begin
if :new.field100002!=:old.field100002 then if :new.field100002!=:old.field100002 then
st:=100000000; st:=100000000;
@ -281,19 +339,28 @@ begin
sk:=300000000; sk:=300000000;
vdatebegin:=to_date(sysdate); vdatebegin:=to_date(sysdate);
select count(1) into vcnt from hrmresource where id=:new.id;
if vcnt=1 then
select workcode,lastname,case when status<=3 then 0 else 1 end,messagerurl,lastname,jobtitle,uuid select workcode,lastname,case when status<=3 then 0 else 1 end,messagerurl,lastname,jobtitle,uuid
into vnumber,vname,vdelete,vleaderimg,vleadername,vleaderjobid,vuuid from hrmresource where id=:new.id; into vnumber,vname,vdelete,vleaderimg,vleadername,vleaderjobid,vuuid from hrmresource where id=:new.id;
end if;
select count(1) into vcnt from hrmjobtitles where id=vleaderjobid;
if vcnt=1 then
select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid; select jobtitlemark into vleaderjob from hrmjobtitles where id=vleaderjobid;
end if;
select count(1) into vcnt from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id;
if vcnt=1 then
select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata select nvl(field100008,''),nvl(field100007,'') into vleaderst,vleaderlv from cus_fielddata
where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id; where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=:new.id;
end if;
vstr:=nvl(:new.field100002,''); vstr:=nvl(:new.field100002,'');
vwz:=Instr(vstr,'_'); vwz:=Instr(vstr,'_');
vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz)); vobjparentid:=to_number(substr(vstr,vwz+1,length(vstr)-vwz));
vparentid:=vobjparentid+sj; vparentid:=vobjparentid+sj;
delete from jcl_org_map where ftype=4 and fobjid=:new.id and fdatebegin=vdatebegin; delete from jcl_org_map where ftype=4 and fobjid=:new.id and fdatebegin=vdatebegin;
update jcl_org_map set fdateend=vdatebegin-1 where ftype=4 and fobjid=:new.id and fdateend>vdatebegin; update jcl_org_map set fdateend=vdatebegin-1 where ftype=4 and fobjid=:new.id and fdateend>vdatebegin;
if vdelete=0 then if vdelete=0 then

@ -317,8 +317,8 @@
<select id="listCompsByIds" resultType="java.util.Map"> <select id="listCompsByIds" resultType="java.util.Map">
select select
id, id as "id",
comp_name as name comp_name as "name"
from jcl_org_comp t from jcl_org_comp t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -93,8 +93,8 @@
<select id="listDeptsByIds" resultType="java.util.Map"> <select id="listDeptsByIds" resultType="java.util.Map">
select select
id, id as "id",
dept_name as name dept_name as "name"
from jcl_org_dept t from jcl_org_dept t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -396,8 +396,8 @@
</select> </select>
<select id="listJobsByIds" resultType="java.util.Map"> <select id="listJobsByIds" resultType="java.util.Map">
select select
id, id as "id",
job_name as name job_name as "name"
from jcl_org_job t from jcl_org_job t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -51,8 +51,8 @@
<select id="listPostInfosByIds" resultType="java.util.Map"> <select id="listPostInfosByIds" resultType="java.util.Map">
select select
id, id as "id",
post_info_name as name post_info_name as "name"
from jcl_org_post_info t from jcl_org_post_info t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -38,8 +38,8 @@
<!-- 浏览按钮赋值、展示用 --> <!-- 浏览按钮赋值、展示用 -->
<select id="listPostsByIds" resultType="java.util.Map"> <select id="listPostsByIds" resultType="java.util.Map">
select select
id, id as "id",
post_name as name post_name as "name"
from jcl_org_post t from jcl_org_post t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -68,8 +68,8 @@
</select> </select>
<select id="listGradessByIds" resultType="java.util.Map"> <select id="listGradessByIds" resultType="java.util.Map">
select select
id, id as "id",
grade_name as name grade_name as "name"
from jcl_org_grade t from jcl_org_grade t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -57,8 +57,8 @@
<select id="listLevelsByIds" resultType="java.util.Map"> <select id="listLevelsByIds" resultType="java.util.Map">
select select
id, id as "id",
level_name as name level_name as "name"
from jcl_org_level t from jcl_org_level t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -47,8 +47,8 @@
</select> </select>
<select id="listSchemesByIds" resultType="java.util.Map"> <select id="listSchemesByIds" resultType="java.util.Map">
select select
id, id as "id",
scheme_name as name scheme_name as "name"
from jcl_org_scheme t from jcl_org_scheme t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -51,8 +51,8 @@
<select id="listSequencesByIds" resultType="java.util.Map"> <select id="listSequencesByIds" resultType="java.util.Map">
select select
id, id as "id",
sequence_name as name sequence_name as "name"
from jcl_org_sequence t from jcl_org_sequence t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -52,8 +52,8 @@
</select> </select>
<select id="listPlansByIds" resultType="java.util.Map"> <select id="listPlansByIds" resultType="java.util.Map">
select select
id, id as "id",
plan_name as name plan_name as "name"
from jcl_org_staffplan t from jcl_org_staffplan t
WHERE delete_type = 0 WHERE delete_type = 0
AND id IN AND id IN

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.organization.service.OrgChartService; import com.engine.organization.service.OrgChartService;
import com.engine.organization.util.db.DBType;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.hrm.User; import weaver.hrm.User;
@ -64,14 +65,17 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
String fclass = (String) request2Map.get("fclass"); // 维度 String fclass = (String) request2Map.get("fclass"); // 维度
String fisvitual = (String) request2Map.get("fisvitual"); // 是否显示虚拟组织 String fisvitual = (String) request2Map.get("fisvitual"); // 是否显示虚拟组织
if (StringUtils.isBlank(fisvitual)) { if (StringUtils.isBlank(fisvitual)) {
fisvitual = "0"; fisvitual = "0";
} }
String whereSql = " where 1 = 1 "; String whereSql = " where 1 = 1 ";
if (DBType.isOracle()) {
whereSql += " and ((fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and fdateend >= to_date('" + date + "','yyyy-MM-DD')) or (fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and fdateend is null )) ";
} else {
whereSql += " and ((fdatebegin <= '" + date + "' and fdateend >= '" + date + "') or (fdatebegin <= '" + date + "' and fdateend is null )) "; whereSql += " and ((fdatebegin <= '" + date + "' and fdateend >= '" + date + "') or (fdatebegin <= '" + date + "' and fdateend is null )) ";
}
whereSql += " and fclass = " + fclass + " "; whereSql += " and fclass = " + fclass + " ";
if ("0".equals(fisvitual)) { if ("0".equals(fisvitual)) {
@ -172,7 +176,11 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
} }
String whereSql = " where 1 = 1 "; String whereSql = " where 1 = 1 ";
if (DBType.isOracle()) {
whereSql += " and ((t.fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and t.fdateend >= to_date('" + date + "','yyyy-MM-DD')) or (t.fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and t.fdateend is null )) ";
} else {
whereSql += " and ((t.fdatebegin <= '" + date + "' and t.fdateend >= '" + date + "') or (t.fdatebegin <= '" + date + "' and t.fdateend is null )) "; whereSql += " and ((t.fdatebegin <= '" + date + "' and t.fdateend >= '" + date + "') or (t.fdatebegin <= '" + date + "' and t.fdateend is null )) ";
}
whereSql += " and t.fclass = " + fclass + " "; whereSql += " and t.fclass = " + fclass + " ";
if ("0".equals(fisvitual)) { if ("0".equals(fisvitual)) {

Loading…
Cancel
Save