Merge pull request '兼容PostgreSQL' (#159) from feature/dxf into develop

Reviewed-on: #159
pull/161/head^2
dxfeng 2 years ago
commit fe30e86d12

@ -193,6 +193,17 @@
and t.subCompanyName like '%'||#{CompanyPO.subCompanyName}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="postgresql">
<if test=" CompanyPO.subCompanyCode != null and CompanyPO.subCompanyCode != '' ">
and t.subCompanyCode like '%'||#{CompanyPO.subCompanyCode}||'%'
</if>
<if test=" CompanyPO.subCompanyDesc != null and CompanyPO.subCompanyDesc != '' ">
and t.subCompanyDesc like '%'||#{CompanyPO.subCompanyDesc}||'%'
</if>
<if test=" CompanyPO.subCompanyName != null and CompanyPO.subCompanyName != '' ">
and t.subCompanyName like '%'||#{CompanyPO.subCompanyName}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="sqlserver">
<if test=" CompanyPO.subCompanyCode != null and CompanyPO.subCompanyCode != '' ">
@ -215,6 +226,9 @@
<sql id="subsWhere" databaseId="sqlserver">
and isnull(canceled,0)=0
</sql>
<sql id="subsWhere" databaseId="postgresql">
and COALESCE(canceled,'0')='0'
</sql>
<sql id="isCanceled">
and ifnull(canceled,0)=
@ -228,5 +242,9 @@
and isnull(canceled,0)=
#{CompanyPO.canceled}
</sql>
<sql id="isCanceled" databaseId="postgresql">
and COALESCE(canceled,'0')=
#{CompanyPO.canceled}
</sql>
</mapper>

@ -175,6 +175,14 @@
and t.departmentName like '%'||#{departmentPO.departmentName}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="postgresql">
<if test=" departmentPO.departmentCode != null and departmentPO.departmentCode != '' ">
and t.departmentCode like '%'||#{departmentPO.departmentCode}||'%'
</if>
<if test=" departmentPO.departmentName != null and departmentPO.departmentName != '' ">
and t.departmentName like '%'||#{departmentPO.departmentName}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="sqlserver">
<if test=" departmentPO.departmentCode != null and departmentPO.departmentCode != '' ">
@ -200,5 +208,10 @@
and isnull(canceled,0)= #{departmentPO.canceled}
</if>
</sql>
<sql id="isCanceled" databaseId="postgresql">
<if test=" departmentPO.canceled != null">
and COALESCE(canceled,'0')= #{departmentPO.canceled}
</if>
</sql>
</mapper>

@ -12,6 +12,11 @@
AND t.lastname like '%'||#{lastName}||'%'
</if>
</sql>
<sql id="likeSql" databaseId="postgresql">
<if test="lastName != null and lastName != ''">
AND t.lastname like '%'||#{lastName}||'%'
</if>
</sql>
<sql id="likeSql" databaseId="sqlserver">
<if test="lastName != null and lastName != ''">
AND t.lastname like '%'+#{lastName}+'%'

@ -120,6 +120,22 @@
left join jcl_org_grade f on d.${grade}=f.id
where a.status &lt; 4
</insert>
<insert id="insertResToMap" databaseId="postgresql">
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,e.level_name,f.grade_name, COALESCE( b.id, 0 ) +200000000,b.id,
0,TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'),'2099-12-31'
from hrmresource a
left join jcl_org_job b ON a.JOBTITLE = b.ec_jobTitle and a.subcompanyid1=b.ec_company and a.departmentid=b.ec_department
left join HrmJobTitles c on b.ec_jobTitle = c.id
left join cus_fielddata d on a.id = d.id and d.scope='HrmCustomFieldByInfoType' and d.scopeid=3
left join jcl_org_level e on NULLIF(d.${level},'')=e.id
left join jcl_org_grade f on NULLIF(d.${grade},'')=f.id
where a.status &lt; 4
</insert>
<insert id="insertResToMap" parameterType="java.lang.String" databaseId="oracle">
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleaderimg,
@ -181,6 +197,28 @@
left join HrmJobTitles g on a.ec_jobTitle = g.id
where ifnull(a.delete_type,0) &lt;&gt; 1 and ifnull(a.forbidden_tag,0) &lt;&gt; 1
</insert>
<insert id="insertJobToMap" databaseId="postgresql">
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,
COALESCE(e.fcnt,0),COALESCE(f.fcnt,0),0,TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'),'2099-12-31'
from JCL_ORG_job as a
left join (select job_id,sum(COALESCE(staff_num,0)) fcnt from JCL_ORG_STAFF
where plan_id in (select id from JCL_ORG_STAFFPLAN
where time_start&lt;=TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd') and time_end &gt; TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd') and delete_type=0)
group by job_id) e on a.id=e.job_id
left join ( select c.id,count(1) fcnt from hrmresource a
left join Hrmjobtitles b on a.jobtitle=b.id and a.status&lt;4
left join jcl_org_job c on b.id=c.ec_jobtitle and a.subcompanyid1=c.ec_company and a.departmentid=c.ec_department
group by c.id) f
on f.id=a.id
left join HrmJobTitles g on a.ec_jobTitle = g.id
where COALESCE(a.delete_type,0) &lt;&gt; 1 and COALESCE(a.forbidden_tag,0) &lt;&gt; 1
</insert>
<insert id="insertJobToMap" databaseId="oracle">
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,
@ -244,6 +282,26 @@
left join jcl_org_grade g on e.${grade}=g.id
where ifnull(a.canceled,0) &lt;&gt; 1
</insert>
<insert id="insertDeptToMap" databaseId="postgresql">
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,b.BMFZR,c.messagerurl,
c.lastname,c.jobtitle,d.jobtitlemark,f.level_name,g.grade_name,
(case COALESCE(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid+100000000 end),
(case COALESCE(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid end),
0,0,0,TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'),'2099-12-31'
from
HrmDepartment as a
left join hrmdepartmentdefined as b on a.id=b.deptid
left join hrmresource as c on NULLIF(b.BMFZR,'')=c.ID
left join hrmjobtitles as d on c.JOBTITLE=d.id
left join cus_fielddata e on c.id = e.id and e.scope='HrmCustomFieldByInfoType' and e.scopeid=3
left join jcl_org_level f on NULLIF(e.${level},'')=f.id
left join jcl_org_grade g on NULLIF(e.${grade},'')=g.id
where COALESCE(a.canceled,'0') &lt;&gt; '1'
</insert>
<insert id="insertDeptToMap" databaseId="oracle">
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
@ -284,6 +342,16 @@
0,0,0,NOW(),'2099-12-31' from hrmsubcompany as a
where IFNULL(a.canceled,0) &lt;&gt; 1
</insert>
<insert id="insertSubComToMap" databaseId="postgresql">
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,'','','',COALESCE(a.supsubcomid,0),COALESCE(a.supsubcomid,0),
0,0,0,TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'),'2099-12-31' from hrmsubcompany as a
where COALESCE(a.canceled,'0') &lt;&gt; '1'
</insert>
<insert id="insertSubComToMap" databaseId="oracle">
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
@ -319,6 +387,14 @@
0, NULL, NULL, 0, NULL, -1, 0,
0, 0, 0, NOW(), '2099-12-31' FROM hrmcompany
</insert>
<insert id="insertComToMap" databaseId="postgresql">
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, TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'), '2099-12-31' FROM hrmcompany
</insert>
<delete id="deleteJobNull">
delete from jcl_org_map where ftype =3 and fdateend &gt; #{currentDate} and id not in (select a.FPARENTID from (select FPARENTID from jcl_org_map where ftype=4 and fdateend &gt; #{currentDate}) a)
</delete>

@ -561,6 +561,10 @@
and NVL(ec_department,0) =
#{parentDepartment}
</sql>
<sql id="nullparentDept" databaseId="postgresql">
and COALESCE(ec_department,0) =
#{parentDepartment}
</sql>
<sql id="likeSQL">
@ -604,6 +608,26 @@
and t.work_authority like '%'||#{jobPO.workAuthority}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="postgresql">
<if test=" jobPO.jobNo != null and jobPO.jobNo != '' ">
and t.job_no like '%'||#{jobPO.jobNo}||'%'
</if>
<if test=" jobPO.jobTitleName != null and jobPO.jobTitleName != '' ">
and h.jobtitlename like '%'||#{jobPO.jobTitleName}||'%'
</if>
<if test=" jobPO.workplace != null and jobPO.workplace != '' ">
and t.workplace like '%'||#{jobPO.workplace}||'%'
</if>
<if test=" jobPO.description != null and jobPO.description != '' ">
and t.description like '%'||#{jobPO.description}||'%'
</if>
<if test=" jobPO.workDuty != null and jobPO.workDuty != '' ">
and t.work_duty like '%'||#{jobPO.workDuty}||'%'
</if>
<if test=" jobPO.workAuthority != null and jobPO.workAuthority != '' ">
and t.work_authority like '%'||#{jobPO.workAuthority}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="sqlserver">
<if test=" jobPO.jobNo != null and jobPO.jobNo != '' ">

@ -389,6 +389,11 @@
AND t.lastname like '%'||#{resourcePO.lastName}||'%'
</if>
</sql>
<sql id="likeSql" databaseId="postgresql">
<if test="resourcePO.lastName != null and resourcePO.lastName != ''">
AND t.lastname like '%'||#{resourcePO.lastName}||'%'
</if>
</sql>
<sql id="likeSql" databaseId="sqlserver">
<if test="resourcePO.lastName != null and resourcePO.lastName != ''">
AND t.lastname like '%'+#{resourcePO.lastName}+'%'

@ -150,6 +150,11 @@
AND t.last_name like '%'||#{param.lastName}||'%'
</if>
</sql>
<sql id="likeSql" databaseId="postgresql">
<if test="param.lastName != null and param.lastName != ''">
AND t.last_name like '%'||#{param.lastName}||'%'
</if>
</sql>
<sql id="likeSql" databaseId="sqlserver">
<if test="param.lastName != null and param.lastName != ''">
AND t.last_name like '%'+#{param.lastName}+'%'

@ -280,6 +280,9 @@
<sql id="likeSQL" databaseId="oracle">
','||level_id||',' like '%,'||#{levelId}+',%'
</sql>
<sql id="likeSQL" databaseId="postgresql">
','||level_id||',' like '%,'||#{levelId}+',%'
</sql>
<sql id="likeSQL" databaseId="sqlserver">
','+level_id+',' like '%,'+cast(#{levelId} as varchar(20))+',%'
</sql>

@ -1,30 +0,0 @@
package com.engine.organization.mapper.trigger;
import com.engine.organization.entity.hrmresource.po.HrmResourcePO;
import org.apache.ibatis.annotations.Param;
import weaver.hrm.passwordprotection.domain.HrmResource;
import java.sql.Date;
/**
* @Author dxfeng
* @Date 2022/8/30
* @Version V1.0
**/
public interface CompTriggerMapper {
Integer getEcCompanyIdByUuid(@Param("uuid") String uuid);
HrmResource getHrmResourceById(@Param("id") Integer id);
String getJobTitleMarkById(@Param("id") Integer id);
Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("compId") Integer compId);
int deleteMap(@Param("ftype") Integer ftype, @Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin);
int updateMap(@Param("ftype") Integer ftype, @Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin, @Param("fdate") Date fdate);
HrmResourcePO getResourceByEcId(@Param("ecId") Integer ecId);
}

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.organization.mapper.trigger.CompTriggerMapper">
<update id="updateMap">
update jcl_org_map
<set>
fdateend=#{fdate},
</set>
where ftype=#{ftype} and fobjid=#{fobjid} and fdateend &gt; #{fdatebegin}
</update>
<delete id="deleteMap">
delete
from jcl_org_map
where ftype = #{ftype}
and fobjid = #{fobjid}
and fdatebegin = #{fdatebegin}
</delete>
<select id="getEcCompanyIdByUuid" resultType="java.lang.Integer">
select id
from HrmSubCompany
where uuid = #{uuid}
</select>
<select id="getHrmResourceById" resultType="weaver.hrm.passwordprotection.domain.HrmResource">
select messagerurl, lastname, jobtitle
from hrmresource
where id = #{id}
</select>
<select id="getJobTitleMarkById" resultType="java.lang.String">
select jobtitlemark
from hrmjobtitles
where id = #{id}
</select>
<select id="sumStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{fdatebegin}
and time_end &gt;= #{fdatebegin})
and comp_id = #{compId}
</select>
<select id="getResourceByEcId" resultMap="com.engine.organization.mapper.resource.ResourceMapper.HrmResourceMap">
select
<include refid="com.engine.organization.mapper.resource.ResourceMapper.baseColumns"/>
from jcl_org_hrmresource t
inner join hrmresource a on t.uuid = a.uuid
where t.delete_type = 0 and a.id = #{ecId}
</select>
</mapper>

@ -1,20 +0,0 @@
package com.engine.organization.mapper.trigger;
import org.apache.ibatis.annotations.Param;
import java.sql.Date;
/**
* @Author dxfeng
* @Date 2022/8/30
* @Version V1.0
**/
public interface DepartmentTriggerMapper {
Integer getEcDepartmentIdByUuid(@Param("uuid") String uuid);
Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("departmentId") Integer departmentId);
Integer countHrmResource(@Param("departmentid") Integer departmentid);
}

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.organization.mapper.trigger.DepartmentTriggerMapper">
<select id="getEcDepartmentIdByUuid" resultType="java.lang.Integer">
select id
from HrmDepartment
where uuid = #{uuid}
</select>
<select id="sumStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{fdatebegin}
and time_end &gt;= #{fdatebegin})
and dept_id = #{departmentId}
</select>
<select id="countHrmResource" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and departmentid = #{departmentid}
</select>
</mapper>

@ -1,24 +0,0 @@
package com.engine.organization.mapper.trigger;
import org.apache.ibatis.annotations.Param;
import java.sql.Date;
/**
* @Author dxfeng
* @Date 2022/8/30
* @Version V1.0
**/
public interface GroupTriggerMapper {
Integer getInfoValue(@Param("id") Integer id);
Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin);
Integer countHrmResource();
int deleteMap(@Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin);
int updateMap(@Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin, @Param("fdate") Date fdate);
}

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.organization.mapper.trigger.GroupTriggerMapper">
<update id="updateMap">
update jcl_org_map
set fdateend=#{fdate}
where fobjid = #{fobjid}
and fdateend &gt; #{fdatebegin}
</update>
<delete id="deleteMap">
delete
from jcl_org_map
where fobjid = 0
and fdatebegin = #{fdatebegin}
</delete>
<select id="getInfoValue" resultType="java.lang.Integer">
select fvalue
from jcl_info
where id = #{id}
</select>
<select id="sumStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{fdatebegin}
and time_end &gt;= #{fdatebegin})
</select>
<select id="countHrmResource" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
</select>
</mapper>

@ -1,21 +0,0 @@
package com.engine.organization.mapper.trigger;
import org.apache.ibatis.annotations.Param;
import weaver.hrm.passwordprotection.domain.HrmResource;
import java.sql.Date;
import java.util.List;
/**
* @author:dxfeng
* @createTime: 2022/09/01
* @version: 1.0
*/
public interface HrmResourceTriggerMapper {
HrmResource getHrmResource(@Param("id") Long id);
List<Long> getFidsByFleader(@Param("fLeader") String fLeader, @Param("currentDate") Date currentDate);
int updateLeaders(@Param("currentDate") Date currentDate,@Param("fLeader") String fLeader, @Param("fLeaderImg") String fLeaderImg, @Param("fLeaderName") String fLeaderName, @Param("fLeaderJobId") Integer fLeaderJobId, @Param("fLeaderJob") String fLeaderJob, @Param("fLeaderLv") String fLeaderLv, @Param("fLeaderSt") String fLeaderSt);
}

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.organization.mapper.trigger.HrmResourceTriggerMapper">
<update id="updateLeaders">
update jcl_org_map
<set>
fleaderimg = #{fLeaderImg},
fleadername = #{fLeaderName},
fleaderjobid = #{fLeaderJobId},
fleaderjob = #{fLeaderJob},
fleaderlv = #{fLeaderLv},
fleaderst = #{fLeaderSt},
</set>
where fleader = #{fLeader} AND fdatebegin &lt;= #{currentDate}
AND fdateend &gt;= #{currentDate}
</update>
<select id="getHrmResource" resultType="weaver.hrm.passwordprotection.domain.HrmResource">
select id, workcode, lastname, status, messagerurl, jobtitle
from hrmresource
where id = #{id}
</select>
<select id="getFidsByFleader" resultType="java.lang.Long">
SELECT fid
FROM jcl_org_map
WHERE FLEADER = #{fLeader}
AND FDATEBEGIN &lt;= #{currentDate}
AND FDATEEND &gt;= #{currentDate}
</select>
</mapper>

@ -1,15 +0,0 @@
package com.engine.organization.mapper.trigger;
import org.apache.ibatis.annotations.Param;
import java.sql.Date;
/**
* @Author dxfeng
* @Date 2022/8/30
* @Version V1.0
**/
public interface JobTriggerMapper {
Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("jobId") Integer jobId);
}

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.organization.mapper.trigger.JobTriggerMapper">
<select id="sumStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{fdatebegin}
and time_end &gt;= #{fdatebegin})
and job_id = #{jobId}
</select>
</mapper>

@ -1,36 +0,0 @@
package com.engine.organization.mapper.trigger;
import org.apache.ibatis.annotations.Param;
import java.sql.Date;
/**
* @author:dxfeng
* @createTime: 2022/09/21
* @version: 1.0
*/
public interface StaffTriggerMapper {
//Integer countCompanyUsers(@Param("ecCompanyId") String ecCompanyId);
//Integer countDepartmentUsers(@Param("ecDepartmentId") String ecDepartmentId);
//Integer countJobUsers(@Param("jobTitle") String jobTitle);
Integer countOnJobByJObId(@Param("jobId") String jobId);
//Integer countAllUsers();
Integer countCompanyStaffNum(@Param("currentDate") Date currentDate, @Param("companyId") String companyId);
Integer countDepartmentStaffNum(@Param("currentDate") Date currentDate, @Param("departmentId") String departmentId);
Integer countJobStaffNum(@Param("currentDate") Date currentDate, @Param("jobId") String jobId);
Integer updateOrgStaffs(@Param("currentDate") Date currentDate, @Param("fType") String fType, @Param("fObjId") String fObjId, @Param("fPlan") Integer fPlan, @Param("fOnJob") Integer fOnJob);
String getIdByObjIdAndType(@Param("currentDate") Date currentDate, @Param("fObjId") String fObjId, @Param("fType") String fType);
Integer sumPlanByParentId(@Param("currentDate") Date currentDate, @Param("parentId") String parentId);
Integer sumOnJobByParentId(@Param("currentDate") Date currentDate, @Param("parentId") String parentId);
}

@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.organization.mapper.trigger.StaffTriggerMapper">
<update id="updateOrgStaffs">
update jcl_org_map
<set>
FPLAN = #{fPlan},
FONJOB = #{fOnJob},
</set>
where FTYPE =#{fType} and FOBJID=#{fObjId}
AND FDATEBEGIN &lt;= #{currentDate}
AND FDATEEND &gt;= #{currentDate}
</update>
<select id="countCompanyUsers" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and subcompanyid1 = #{ecCompanyId}
</select>
<select id="countDepartmentUsers" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and departmentid = #{ecDepartmentId}
</select>
<select id="countJobUsers" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and jobtitle = #{jobTitle}
</select>
<select id="countAllUsers" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
</select>
<select id="countCompanyStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{currentDate}
and time_end &gt;= #{currentDate}
and delete_type = 0
and control_dimension = 1)
and comp_id = #{companyId}
and delete_type = 0
</select>
<select id="countDepartmentStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{currentDate}
and time_end &gt;= #{currentDate}
and delete_type = 0
and control_dimension = 2)
and dept_id = #{departmentId}
and delete_type = 0
</select>
<select id="countJobStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{currentDate}
and time_end &gt;= #{currentDate}
and delete_type = 0
and control_dimension = 3)
and job_id = #{jobId}
and delete_type = 0
</select>
<select id="getIdByObjIdAndType" resultType="java.lang.String">
select id
from jcl_org_map
where fobjid = #{fObjId}
and ftype = #{fType}
AND FDATEBEGIN &lt;= #{currentDate}
AND FDATEEND &gt;= #{currentDate}
</select>
<select id="sumPlanByParentId" resultType="java.lang.Integer">
select sum(fplan)
from jcl_org_map
where fparentid = #{parentId}
AND FDATEBEGIN &lt;= #{currentDate}
AND FDATEEND &gt;= #{currentDate}
</select>
<select id="sumOnJobByParentId" resultType="java.lang.Integer">
select sum(fonjob)
from jcl_org_map
where fparentid = #{parentId}
AND FDATEBEGIN &lt;= #{currentDate}
AND FDATEEND &gt;= #{currentDate}
</select>
<select id="countOnJobByJObId" resultType="java.lang.Integer">
select count(1)
from jcl_org_hrmresource a
where a.job_title = #{jobId} and a.status &lt; 4
</select>
</mapper>

@ -6,11 +6,9 @@ import com.engine.core.impl.Service;
import com.engine.organization.entity.map.JclOrgMap;
import com.engine.organization.entity.scheme.po.GradePO;
import com.engine.organization.entity.scheme.po.LevelPO;
import com.engine.organization.entity.staff.po.StaffPO;
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
import com.engine.organization.mapper.scheme.GradeMapper;
import com.engine.organization.mapper.scheme.LevelMapper;
import com.engine.organization.mapper.staff.StaffMapper;
import com.engine.organization.service.OrgChartService;
import com.engine.organization.util.HasRightUtil;
import com.engine.organization.util.OrganizationDateUtil;
@ -101,7 +99,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
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 {
}else {
whereSql += " and ((fdatebegin <= '" + date + "' and fdateend >= '" + date + "') or (fdatebegin <= '" + date + "' and fdateend is null )) ";
}
whereSql += " and fclass = " + fclass + " ";
@ -141,7 +139,8 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
// 获取根节点
RecordSet rs = new RecordSet();
rs.executeQuery("select id, fname, ftype, fparentid, fnumber, fobjid, fisvitual from jcl_org_map " + whereSql + whereItemSql);
String sql = "select id, fname, ftype, fparentid, fnumber, fobjid, fisvitual from jcl_org_map " + whereSql + whereItemSql;
rs.executeQuery(sql);
List<Map<String, Object>> list = new ArrayList<>();
String id = null;
if (rs.next()) {
@ -227,7 +226,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
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 {
}else {
whereSql += " and ((t.fdatebegin <= '" + date + "' and t.fdateend >= '" + date + "') or (t.fdatebegin <= '" + date + "' and t.fdateend is null )) ";
}
whereSql += " and t.fclass = " + fclass + " ";
@ -393,7 +392,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
if (StringUtils.isNotBlank(bmfzr)) {
String[] split = bmfzr.split(",");
for (String s : split) {
jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getResInfo(level, grade,s);
jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getResInfo(level, grade, s);
break;
}
}
@ -539,6 +538,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
private JclOrgMapper getJclOrgMapMapper() {
return MapperProxyFactory.getProxy(JclOrgMapper.class);
}
@Override
public String synchronousData(Map<String, Object> request2Map, User user) {
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
@ -549,13 +549,13 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
java.sql.Date time = new java.sql.Date(calendar.getTime().getTime());
// 自下向上刷新
getJclOrgMapMapper().deleteAllMap(date);
getJclOrgMapMapper().updateAllMap(date,time);
getJclOrgMapMapper().updateAllMap(date, time);
//同步人员信息
getJclOrgMapMapper().insertResToMap(level,grade);
getJclOrgMapMapper().insertResToMap(level, grade);
//同步岗位信息
getJclOrgMapMapper().insertJobToMap();
//同步部门信息
getJclOrgMapMapper().insertDeptToMap(level,grade);
getJclOrgMapMapper().insertDeptToMap(level, grade);
//同步分部信息
getJclOrgMapMapper().insertSubComToMap();
//同步集团信息
@ -563,17 +563,18 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
//清除部门合并、转移造成的脏数据
getJclOrgMapMapper().deleteJobNull(date);
//刷新在岗数、编制数(从岗位向上刷,岗位不需处理)
List<JclOrgMap> jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType("3",date);
for (JclOrgMap jclOrgMap : jclOrgMaps){
List<JclOrgMap> jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType("3", date);
for (JclOrgMap jclOrgMap : jclOrgMaps) {
int id = jclOrgMap.getId();
countJobAndPlans("3",id,currentDate);
countJobAndPlans("3", id, currentDate);
}
return "同步成功";
}
/**
*
*/
void countJobAndPlans(String type,int id,String currentDate) {
void countJobAndPlans(String type, int id, String currentDate) {
java.sql.Date date = new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime());
RecordSet rs = new RecordSet();
//处理上级
@ -605,15 +606,17 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
}
}
private String getFieldName(String fieldabel) {
RecordSet recordSet = new RecordSet();
String fieldname = null;
recordSet.executeQuery("select fieldname from jcl_org_field where fieldlabel='" + fieldabel+"'");
recordSet.executeQuery("select fieldname from jcl_org_field where fieldlabel='" + fieldabel + "'");
if (recordSet.next()) {
fieldname = recordSet.getString("fieldname");
}
return fieldname;
}
static class OrgSelectItem {
private String id;
private String fnumber;

@ -67,6 +67,27 @@ public enum DBType implements DBOperateAdapter {
public String ifNull(String some, String defaultValue) {
return " NVL(" + some + ",'" + defaultValue + "')";
}
},
POSTGRESQL("postgresql") {
@Override
public String like(String some) {
return " like '%" + some + "%' ";
}
@Override
public String concat(String some) {
return " ',' ||" + some + "|| ',' ";
}
@Override
public String currentDate() {
return "now()";
}
@Override
public String ifNull(String some, String defaultValue) {
return " COALESCE(" + some + ",'" + defaultValue + "')";
}
};
private String dbtype;

Loading…
Cancel
Save