200 lines
6.3 KiB
XML
200 lines
6.3 KiB
XML
<?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.bonus.hnrn.rnbmw.manager.dao.OrgDao">
|
|
|
|
<resultMap id="ZNode" type="com.bonus.hnrn.rnbmw.manager.entity.ZNode"></resultMap>
|
|
|
|
<delete id="deleteTeamType">
|
|
update bm_sub_team_type set IS_ACTIVE = '0' WHERE ID = #{id}
|
|
</delete>
|
|
|
|
<select id="getAll" parameterType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean" resultMap="ZNode">
|
|
SELECT
|
|
po.ID AS id,
|
|
po.PARENT_ID AS pId ,
|
|
po.COMPANY_ID as companyId,
|
|
po.TYPE as type,
|
|
po.`NAME` as name
|
|
FROM
|
|
pm_organization_year po
|
|
LEFT JOIN pm_organization_year pom on po.PARENT_ID = pom.id
|
|
LEFT JOIN pm_company pc on po.COMPANY_ID = pc.ID
|
|
WHERE
|
|
po.is_active = '1'
|
|
|
|
<if test="orgId != null and orgId != ''">
|
|
<if test='roleLevel == "1"'>
|
|
AND po.company_id = #{companyId}
|
|
</if>
|
|
<if test='roleLevel == "2"'>
|
|
and(
|
|
po.id = (SELECT PARENT_ID FROM pm_organization_year WHERE id = #{orgId} AND is_active = '1') or
|
|
po.id = #{orgId} or
|
|
po.id in (SELECT id FROM pm_organization_year WHERE PARENT_ID = #{orgId} AND is_active = '1') or
|
|
po.PARENT_ID in (SELECT id FROM pm_organization_year WHERE PARENT_ID = #{orgId} AND is_active = '1')
|
|
)
|
|
</if>
|
|
</if>
|
|
<!-- <if test="companyId!=null and companyId!='' ">-->
|
|
<!-- and pc.ID =#{companyId}-->
|
|
<!-- </if>-->
|
|
</select>
|
|
|
|
|
|
<select id="getTeamTypeList" parameterType="com.bonus.hnrn.rnbmw.manager.entity.ZNode" resultMap="ZNode">
|
|
SELECT
|
|
bstt.ID AS id,bstt.`NAME` AS name,'0' AS pId,'0' AS companyId
|
|
FROM bm_sub_team_type bstt
|
|
WHERE bstt.IS_ACTIVE = '1'
|
|
<if test="companyId != null and companyId != ''">
|
|
AND bstt.company_id = #{companyId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getTeamNumByType" resultType="int">
|
|
SELECT count(1) from bm_sub_team WHERE IS_ACTIVE = '1' and team_type_id = #{id}
|
|
</select>
|
|
|
|
<select id="getCompanyTree" parameterType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean" resultMap="ZNode">
|
|
SELECT
|
|
ID AS id,
|
|
PARENT_ID AS pId ,
|
|
`NAME` as name,
|
|
COMPANY_ID as companyId
|
|
FROM
|
|
pm_organization
|
|
WHERE
|
|
is_active = '1'
|
|
<if test="orgId != null and orgId != ''">
|
|
<if test='roleLevel == "1"'>
|
|
AND COMPANY_ID = #{companyId}
|
|
</if>
|
|
|
|
<if test='roleLevel == "2"'>
|
|
AND COMPANY_ID = #{companyId} AND PARENT_ID = '0' or id = #{orgId} or PARENT_ID = #{orgId}
|
|
</if>
|
|
|
|
<if test='roleLevel == "3"'>
|
|
AND COMPANY_ID = #{companyId} AND PARENT_ID = '0'
|
|
or id = (SELECT PARENT_ID AS pId from pm_organization WHERE is_active = '1' AND id= #{orgId}) or id = #{orgId}
|
|
</if>
|
|
|
|
<if test='roleLevel == "4"'>
|
|
AND COMPANY_ID = #{companyId} AND PARENT_ID = '0' or id = #{orgId} or PARENT_ID = #{orgId} and is_active = '1'
|
|
and id in (SELECT COMPANY_ID FROM bm_sub_pro_relation sub LEFT JOIN bm_project bm on bm.id = sub.pro_id WHERE sub_id = #{subId})
|
|
</if>
|
|
</if>
|
|
/*UNION
|
|
SELECT id, 'zyry' as pid,org_name as name,'0' as companyId FROM own_company
|
|
WHERE is_active = '1'*/
|
|
</select>
|
|
|
|
|
|
<insert id="addOrg" parameterType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean">
|
|
insert into pm_organization( NAME,PARENT_ID,IS_ACTIVE,TYPE,update_time,COMPANY_ID)
|
|
values ( #{name},#{parentId},'1',#{type},now(),#{companyId})
|
|
</insert>
|
|
|
|
<insert id="addTeamType">
|
|
insert into bm_sub_team_type(NAME,company_id) values (#{name},#{companyId})
|
|
</insert>
|
|
|
|
<insert id="addOrgYear" useGeneratedKeys = "true" keyProperty = "id">
|
|
insert into pm_organization_year( NAME,PARENT_ID,IS_ACTIVE,TYPE,update_time,COMPANY_ID)
|
|
values ( #{name},#{parentId},'1',#{type},now(),#{companyId})
|
|
|
|
</insert>
|
|
<insert id="addOrgIs">
|
|
insert into pm_organization( NAME,PARENT_ID,IS_ACTIVE,TYPE,update_time,COMPANY_ID)
|
|
values ( #{name},#{parentId},'0',#{type},now(),#{companyId})
|
|
</insert>
|
|
|
|
<update id="updateOrg" parameterType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean">
|
|
update pm_organization
|
|
<set>
|
|
<if test="name != null">
|
|
NAME =#{name},
|
|
</if>
|
|
</set>
|
|
where ID = #{id}
|
|
</update>
|
|
|
|
<update id="deleteOrg" parameterType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean">
|
|
update pm_organization set IS_ACTIVE = 0 WHERE ID = #{id}
|
|
</update>
|
|
|
|
<update id="deleteOrgYear" parameterType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean">
|
|
update pm_organization_year set IS_ACTIVE = 0 WHERE ID = #{id}
|
|
</update>
|
|
|
|
<update id="updateTeamType">
|
|
update bm_sub_team_type
|
|
<set>
|
|
<if test="name != null">
|
|
NAME =#{name},
|
|
</if>
|
|
</set>
|
|
where ID = #{id}
|
|
</update>
|
|
|
|
<update id="updateOrgYear">
|
|
update pm_organization_year
|
|
<set>
|
|
<if test="name != null">
|
|
NAME =#{name},
|
|
</if>
|
|
</set>
|
|
where ID = #{id}
|
|
</update>
|
|
|
|
<select id="findCompanyInfo" resultType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean" parameterType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean" >
|
|
SELECT po.ID as companyId,po.`NAME` as companyName,po.PARENT_ID as parentId
|
|
FROM pm_organization po
|
|
|
|
WHERE po.ID = #{id} AND po.IS_ACTIVE = 1
|
|
</select>
|
|
|
|
<select id="getProId" resultType="java.lang.Integer">
|
|
SELECT count(*) FROM bm_project
|
|
WHERE company_id = #{id} and is_active = '1'
|
|
</select>
|
|
|
|
<select id="getCompanyTreeListOWN" resultType="com.bonus.hnrn.rnbmw.manager.entity.ZNode">
|
|
SELECT 'x' as id , null as pid , '请选择用工单位' as name , null as companyId FROM
|
|
pm_organization
|
|
|
|
UNION
|
|
|
|
SELECT
|
|
ID AS id,
|
|
PARENT_ID AS pId ,
|
|
`NAME` as name,
|
|
COMPANY_ID as companyId
|
|
FROM
|
|
pm_organization
|
|
WHERE
|
|
is_active = '1' AND TYPE !='3'
|
|
|
|
<!--<if test="orgIds != null and orgIds != ''">
|
|
AND ID = #{orgIds} or ID = (SELECT PARENT_ID FROM pm_organization WHERE id = #{orgIds} )
|
|
</if>-->
|
|
|
|
|
|
<if test="orgIds != null and orgIds != ''">
|
|
<if test='roleLevel == "1"'>
|
|
AND ID = #{orgIds} or ID in(SELECT id FROM pm_organization WHERE company_id = #{companyId} AND IS_ACTIVE ='1' AND TYPE !='3')
|
|
</if>
|
|
|
|
<if test='roleLevel == "2"'>
|
|
AND ID = #{orgIds} or ID = (SELECT PARENT_ID FROM pm_organization WHERE id = #{orgIds} )
|
|
</if>
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="getOrgId" resultType="com.bonus.hnrn.rnbmw.manager.entity.OrgBean">
|
|
SELECT PARENT_ID as parentId FROM `pm_organization_year`
|
|
WHERE id = #{parentId}
|
|
</select>
|
|
</mapper> |