|
|
|
<?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.comp.CompMapper">
|
|
|
|
<resultMap id="BaseResultMap" type="com.engine.organization.entity.company.po.CompPO">
|
|
|
|
<result column="id" property="id"/>
|
|
|
|
<result column="comp_no" property="compNo"/>
|
|
|
|
<result column="comp_name" property="compName"/>
|
|
|
|
<result column="comp_name_short" property="compNameShort"/>
|
|
|
|
<result column="parent_company" property="parentCompany"/>
|
|
|
|
<result column="org_code" property="orgCode"/>
|
|
|
|
<result column="industry" property="industry"/>
|
|
|
|
<result column="comp_principal" property="compPrincipal"/>
|
|
|
|
<result column="description" property="description"/>
|
|
|
|
<result column="forbidden_tag" property="forbiddenTag"/>
|
|
|
|
<result column="creator" property="creator"/>
|
|
|
|
<result column="delete_type" property="deleteType"/>
|
|
|
|
<result column="create_time" property="createTime"/>
|
|
|
|
<result column="update_time" property="updateTime"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!-- 表字段 -->
|
|
|
|
<sql id="baseColumns">
|
|
|
|
t
|
|
|
|
.
|
|
|
|
id
|
|
|
|
, t.comp_no
|
|
|
|
, t.comp_name
|
|
|
|
, t.comp_name_short
|
|
|
|
, t.parent_company
|
|
|
|
, t.org_code
|
|
|
|
, t.industry
|
|
|
|
, t.comp_principal
|
|
|
|
, t.description
|
|
|
|
, t.forbidden_tag
|
|
|
|
, t.creator
|
|
|
|
, t.delete_type
|
|
|
|
, t.create_time
|
|
|
|
, t.update_time
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<sql id="nullSql">
|
|
|
|
and ifnull(parent_company,'0')='0'
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<sql id="nullSql" databaseId="sqlserver">
|
|
|
|
and isnull(parent_company,'0')='0'
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<sql id="nullSql" databaseId="oracle">
|
|
|
|
and NVL(parent_company,'0')='0'
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.company.po.CompPO" keyProperty="id"
|
|
|
|
keyColumn="id" useGeneratedKeys="true">
|
|
|
|
INSERT INTO jcl_org_comp
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="creator != null">
|
|
|
|
creator,
|
|
|
|
</if>
|
|
|
|
<if test="deleteType != null">
|
|
|
|
delete_type,
|
|
|
|
</if>
|
|
|
|
<if test="createTime != null">
|
|
|
|
create_time,
|
|
|
|
</if>
|
|
|
|
<if test="updateTime != null">
|
|
|
|
update_time,
|
|
|
|
</if>
|
|
|
|
<if test="compNo != null ">
|
|
|
|
comp_no,
|
|
|
|
</if>
|
|
|
|
<if test="compName != null ">
|
|
|
|
comp_name,
|
|
|
|
</if>
|
|
|
|
<if test="compNameShort != null ">
|
|
|
|
comp_name_short,
|
|
|
|
</if>
|
|
|
|
<if test="parentCompany != null ">
|
|
|
|
parent_company,
|
|
|
|
</if>
|
|
|
|
<if test="orgCode != null ">
|
|
|
|
org_code,
|
|
|
|
</if>
|
|
|
|
<if test="industry != null ">
|
|
|
|
industry,
|
|
|
|
</if>
|
|
|
|
<if test="compPrincipal != null ">
|
|
|
|
comp_principal,
|
|
|
|
</if>
|
|
|
|
<if test="description != null ">
|
|
|
|
description,
|
|
|
|
</if>
|
|
|
|
forbidden_tag,
|
|
|
|
</trim>
|
|
|
|
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="creator != null">
|
|
|
|
#{creator},
|
|
|
|
</if>
|
|
|
|
<if test="deleteType != null">
|
|
|
|
#{deleteType},
|
|
|
|
</if>
|
|
|
|
<if test="createTime != null">
|
|
|
|
#{createTime},
|
|
|
|
</if>
|
|
|
|
<if test="updateTime != null">
|
|
|
|
#{updateTime},
|
|
|
|
</if>
|
|
|
|
<if test="compNo != null ">
|
|
|
|
#{compNo},
|
|
|
|
</if>
|
|
|
|
<if test="compName != null ">
|
|
|
|
#{compName},
|
|
|
|
</if>
|
|
|
|
<if test="compNameShort != null ">
|
|
|
|
#{compNameShort},
|
|
|
|
</if>
|
|
|
|
<if test="parentCompany != null ">
|
|
|
|
#{parentCompany},
|
|
|
|
</if>
|
|
|
|
<if test="orgCode != null ">
|
|
|
|
#{orgCode},
|
|
|
|
</if>
|
|
|
|
<if test="industry != null ">
|
|
|
|
#{industry},
|
|
|
|
</if>
|
|
|
|
<if test="compPrincipal != null ">
|
|
|
|
#{compPrincipal},
|
|
|
|
</if>
|
|
|
|
<if test="description != null ">
|
|
|
|
#{description},
|
|
|
|
</if>
|
|
|
|
0,
|
|
|
|
</trim>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<select id="list" resultMap="BaseResultMap">
|
|
|
|
SELECT
|
|
|
|
<include refid="baseColumns"/>
|
|
|
|
FROM
|
|
|
|
jcl_org_comp t
|
|
|
|
WHERE t.delete_type = 0
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="listParent" resultMap="BaseResultMap">
|
|
|
|
SELECT
|
|
|
|
<include refid="baseColumns"/>
|
|
|
|
FROM
|
|
|
|
jcl_org_comp t
|
|
|
|
WHERE t.delete_type = 0
|
|
|
|
<include refid="nullSql"/>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="listChild" resultMap="BaseResultMap">
|
|
|
|
SELECT
|
|
|
|
<include refid="baseColumns"/>
|
|
|
|
FROM
|
|
|
|
jcl_org_comp t
|
|
|
|
WHERE t.delete_type = 0
|
|
|
|
AND parent_company IN
|
|
|
|
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="listById" resultMap="BaseResultMap">
|
|
|
|
SELECT
|
|
|
|
<include refid="baseColumns"/>
|
|
|
|
FROM
|
|
|
|
jcl_org_comp t
|
|
|
|
WHERE t.delete_type = 0
|
|
|
|
and id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="listByNo" parameterType="com.engine.organization.entity.company.po.CompPO" resultMap="BaseResultMap">
|
|
|
|
select
|
|
|
|
<include refid="baseColumns"/>
|
|
|
|
from jcl_org_comp t where comp_no = #{compNo} AND delete_type = 0
|
|
|
|
</select>
|
|
|
|
<select id="listByFilter" parameterType="com.engine.organization.entity.company.po.CompPO"
|
|
|
|
resultMap="BaseResultMap">
|
|
|
|
SELECT
|
|
|
|
<include refid="baseColumns"/>
|
|
|
|
FROM
|
|
|
|
jcl_org_comp t
|
|
|
|
WHERE t.delete_type = 0
|
|
|
|
<include refid="likeSQL"/>
|
|
|
|
<if test=" parentCompany != null ">
|
|
|
|
and t.parent_company = #{parentCompany}
|
|
|
|
</if>
|
|
|
|
<if test=" industry != null ">
|
|
|
|
and t.industry = #{industry}
|
|
|
|
</if>
|
|
|
|
<if test=" compPrincipal != null ">
|
|
|
|
and t.comp_principal = #{compPrincipal}
|
|
|
|
</if>
|
|
|
|
<if test=" forbiddenTag != null ">
|
|
|
|
and t.forbidden_tag = #{forbiddenTag}
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="listCompsByIds" resultType="java.util.Map">
|
|
|
|
select
|
|
|
|
id,
|
|
|
|
comp_name as name
|
|
|
|
from jcl_org_comp t
|
|
|
|
WHERE delete_type = 0
|
|
|
|
AND id IN
|
|
|
|
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="listChildByPID" resultMap="BaseResultMap">
|
|
|
|
SELECT
|
|
|
|
<include refid="baseColumns"/>
|
|
|
|
FROM
|
|
|
|
jcl_org_comp t
|
|
|
|
WHERE t.delete_type = 0
|
|
|
|
and parent_company = #{pid}
|
|
|
|
</select>
|
|
|
|
<select id="countChildByPID" resultType="java.lang.Integer">
|
|
|
|
SELECT count(1)
|
|
|
|
FROM jcl_org_comp t
|
|
|
|
WHERE t.delete_type = 0
|
|
|
|
and parent_company = #{pid}
|
|
|
|
</select>
|
|
|
|
<select id="getCompsByIds" resultMap="BaseResultMap">
|
|
|
|
select
|
|
|
|
<include refid="baseColumns"/>
|
|
|
|
from jcl_org_comp t
|
|
|
|
WHERE delete_type = 0
|
|
|
|
AND id IN
|
|
|
|
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
<select id="listUsedId" resultType="java.lang.String">
|
|
|
|
select parent_comp
|
|
|
|
from JCL_ORG_DEPT
|
|
|
|
where delete_type = 0
|
|
|
|
union
|
|
|
|
select parent_comp
|
|
|
|
from JCL_ORG_JOB
|
|
|
|
where delete_type = 0
|
|
|
|
union
|
|
|
|
select company_id
|
|
|
|
from JCL_ORG_STAFFPLAN
|
|
|
|
where delete_type = 0
|
|
|
|
union
|
|
|
|
select comp_id
|
|
|
|
from JCL_ORG_STAFF
|
|
|
|
where delete_type = 0
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.sequence.po.SequencePO">
|
|
|
|
update jcl_org_comp
|
|
|
|
<set>
|
|
|
|
forbidden_tag=#{forbiddenTag},
|
|
|
|
</set>
|
|
|
|
WHERE id = #{id} AND delete_type = 0
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<update id="deleteByIds">
|
|
|
|
UPDATE jcl_org_comp
|
|
|
|
SET delete_type = 1
|
|
|
|
WHERE delete_type = 0
|
|
|
|
AND id IN
|
|
|
|
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<update id="updateBaseComp" parameterType="com.engine.organization.entity.company.po.CompPO">
|
|
|
|
update jcl_org_comp
|
|
|
|
<set>
|
|
|
|
creator=#{creator},
|
|
|
|
update_time=#{updateTime},
|
|
|
|
comp_name=#{compName},
|
|
|
|
comp_name_short=#{compNameShort},
|
|
|
|
parent_company=#{parentCompany},
|
|
|
|
org_code=#{orgCode},
|
|
|
|
industry=#{industry},
|
|
|
|
comp_principal=#{compPrincipal},
|
|
|
|
description=#{description},
|
|
|
|
</set>
|
|
|
|
WHERE id = #{id} AND delete_type = 0
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<sql id="likeSQL">
|
|
|
|
<if test=" compNo != null and compNo != '' ">
|
|
|
|
and t.comp_no like CONCAT('%',#{compNo},'%')
|
|
|
|
</if>
|
|
|
|
<if test=" compName != null and compName != '' ">
|
|
|
|
and t.comp_name like CONCAT('%',#{compName},'%')
|
|
|
|
</if>
|
|
|
|
<if test=" compNameShort != null and compNameShort != '' ">
|
|
|
|
and t.comp_name_short like CONCAT('%',#{compNameShort},'%')
|
|
|
|
</if>
|
|
|
|
<if test=" orgCode != null and orgCode != '' ">
|
|
|
|
and t.org_code like CONCAT('%',#{orgCode},'%')
|
|
|
|
</if>
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<sql id="likeSQL" databaseId="oracle">
|
|
|
|
<if test=" compNo != null and compNo != '' ">
|
|
|
|
and t.comp_no like '%'||#{compNo}||'%'
|
|
|
|
</if>
|
|
|
|
<if test=" compName != null and compName != '' ">
|
|
|
|
and t.comp_name like '%'||#{compName}||'%'
|
|
|
|
</if>
|
|
|
|
<if test=" compNameShort != null and compNameShort != '' ">
|
|
|
|
and t.comp_name_short like '%'||#{compNameShort}||'%'
|
|
|
|
</if>
|
|
|
|
<if test=" orgCode != null and orgCode != '' ">
|
|
|
|
and t.org_code like '%'||#{orgCode}||'%'
|
|
|
|
</if>
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<sql id="likeSQL" databaseId="sqlserver">
|
|
|
|
<if test=" compNo != null and compNo != '' ">
|
|
|
|
and t.comp_no like '%'+#{compNo}+'%'
|
|
|
|
</if>
|
|
|
|
<if test=" compName != null and compName != '' ">
|
|
|
|
and t.comp_name like '%'+#{compName}+'%'
|
|
|
|
</if>
|
|
|
|
<if test=" compNameShort != null and compNameShort != '' ">
|
|
|
|
and t.comp_name_short like '%'+#{compNameShort}+'%'
|
|
|
|
</if>
|
|
|
|
<if test=" orgCode != null and orgCode != '' ">
|
|
|
|
and t.org_code like '%'+#{orgCode}+'%'
|
|
|
|
</if>
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
</mapper>
|