|
@@ -3,132 +3,67 @@
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.persagy.dmp.rwd.define.dao.ObjectInfoMapper">
|
|
|
-
|
|
|
- <resultMap id="BaseResultMap" type="com.persagy.dmp.define.entity.ObjectInfoDefine">
|
|
|
- <id property="id" column="id" jdbcType="VARCHAR"/>
|
|
|
- <result property="code" column="code" jdbcType="VARCHAR"/>
|
|
|
- <result property="name" column="name" jdbcType="VARCHAR"/>
|
|
|
- <result property="aliasCode" column="alias_code" jdbcType="VARCHAR"/>
|
|
|
- <result property="aliasName" column="alias_name" jdbcType="VARCHAR"/>
|
|
|
- <result property="classCode" column="class_code" jdbcType="VARCHAR"/>
|
|
|
- <result property="groupCode" column="group_code" jdbcType="VARCHAR"/>
|
|
|
- <result property="projectId" column="project_id" jdbcType="VARCHAR"/>
|
|
|
- <result property="category" column="category" jdbcType="VARCHAR"/>
|
|
|
- <result property="firstTag" column="first_tag" jdbcType="VARCHAR"/>
|
|
|
- <result property="secondTag" column="second_tag" jdbcType="VARCHAR"/>
|
|
|
- <result property="priority" column="priority" jdbcType="VARCHAR"/>
|
|
|
- <result property="inputMode" column="input_mode" jdbcType="VARCHAR"/>
|
|
|
- <result property="unit" column="unit" jdbcType="VARCHAR"/>
|
|
|
- <result property="dataType" column="data_type" jdbcType="VARCHAR"/>
|
|
|
- <result property="isMultiple" column="is_multiple" jdbcType="INTEGER"/>
|
|
|
- <result property="isRegion" column="is_region" jdbcType="INTEGER"/>
|
|
|
- <result property="formater" column="formater" jdbcType="VARCHAR"/>
|
|
|
- <result property="dataSource" column="data_source" jdbcType="OTHER" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
|
|
|
- <result property="remark" column="remark" jdbcType="VARCHAR"/>
|
|
|
- <result property="subFlag" column="sub_flag" jdbcType="INTEGER"/>
|
|
|
- <result property="weakPoint" column="weak_point" jdbcType="INTEGER"/>
|
|
|
- <result property="showOrder" column="show_order" jdbcType="INTEGER"/>
|
|
|
- <result property="version" column="version" jdbcType="VARCHAR"/>
|
|
|
- <result property="creator" column="creator" jdbcType="VARCHAR"/>
|
|
|
- <result property="creationTime" column="creation_time" jdbcType="CHAR"/>
|
|
|
- <result property="modifier" column="modifier" jdbcType="VARCHAR"/>
|
|
|
- <result property="modifiedTime" column="modified_time" jdbcType="CHAR"/>
|
|
|
- <result property="valid" column="valid" jdbcType="TINYINT"/>
|
|
|
- <result property="ts" column="ts" jdbcType="TIMESTAMP"/>
|
|
|
- </resultMap>
|
|
|
-
|
|
|
- <sql id="Base_Column_List">
|
|
|
- id,`code`,`name`,
|
|
|
- alias_code,alias_name,class_code,
|
|
|
- group_code,project_id,category,
|
|
|
- first_tag,second_tag,priority,
|
|
|
- input_mode,unit,data_type,
|
|
|
- is_multiple,is_region,formater,
|
|
|
- data_source,remark,sub_flag,
|
|
|
- weak_point,show_order,version,
|
|
|
- creator,creation_time,modifier,
|
|
|
- modified_time,valid,ts
|
|
|
+ <!-- 类型如果重复则会出现多条,因此这里先用distinct容错.将基础类型的信息点与非基础信息点一起返回,且class_code改为对应的非基础对象类型 -->
|
|
|
+ <sql id="SelectColumns">
|
|
|
+ select distinct
|
|
|
+ dt_define_info.id, dt_define_info.code, dt_define_info.name, dt_define_info.alias_code,
|
|
|
+ dt_define_info.alias_name, dt_define_type.code as class_code, dt_define_info.group_code,
|
|
|
+ dt_define_info.project_id,dt_define_info.category,dt_define_info.first_tag,
|
|
|
+ dt_define_info.second_tag, dt_define_info.priority,dt_define_info.input_mode,
|
|
|
+ dt_define_info.unit,dt_define_info.data_type,dt_define_info.is_multiple,dt_define_info.is_region,
|
|
|
+ dt_define_info.formater,dt_define_info.data_source,dt_define_info.remark,dt_define_info.sub_flag,
|
|
|
+ dt_define_info.weak_point,dt_define_info.show_order,dt_define_info.version,dt_define_info.creator,
|
|
|
+ dt_define_info.creation_time,dt_define_info.modifier,dt_define_info.modified_time,
|
|
|
+ dt_define_info.valid,dt_define_info.ts
|
|
|
</sql>
|
|
|
- <select id="queryByClassCodes" resultMap="BaseResultMap">
|
|
|
- SELECT
|
|
|
- *
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT DISTINCT
|
|
|
- dt_define_info.*
|
|
|
- FROM
|
|
|
- dt_define_info
|
|
|
- INNER JOIN dt_define_type ON dt_define_info.class_code = dt_define_type.CODE
|
|
|
- WHERE
|
|
|
- <foreach collection="classCodes" item="classCode" separator="," open="class_code IN (" close=")">
|
|
|
- #{classCode}
|
|
|
+ <!--
|
|
|
+ 1. 如果为基础类型、且为平台级,优先级100
|
|
|
+ 2. 如果为基础类型、且为集团级,优先级200
|
|
|
+ 3. 如果为基础类型、且为项目级,优先级300
|
|
|
+ 4. 如果为非基础类型、且为平台级,优先级400
|
|
|
+ 5. 如果为非基础类型、且为集团级,优先级500
|
|
|
+ 6. 如果为非基础类型、且为项目级,优先级600
|
|
|
+ -->
|
|
|
+ <sql id="ShowLevelSQL">
|
|
|
+ (case
|
|
|
+ when dt_define_info.class_code in ('project','building','floor','space','system','equipment','shaft','component','virtual','tool','material')
|
|
|
+ and dt_define_info.project_id = '0' then 100
|
|
|
+ when dt_define_info.class_code in ('project','building','floor','space','system','equipment','shaft','component','virtual','tool','material')
|
|
|
+ and dt_define_info.project_id = dt_define_info.group_code then 200
|
|
|
+ when dt_define_info.class_code in ('project','building','floor','space','system','equipment','shaft','component','virtual','tool','material')
|
|
|
+ and dt_define_info.project_id != dt_define_info.group_code then 300
|
|
|
+ when dt_define_info.class_code not in ('project','building','floor','space','system','equipment','shaft','component','virtual','tool','material')
|
|
|
+ and dt_define_info.project_id = '0' then 400
|
|
|
+ when dt_define_info.class_code not in ('project','building','floor','space','system','equipment','shaft','component','virtual','tool','material')
|
|
|
+ and dt_define_info.project_id = dt_define_info.group_code then 500
|
|
|
+ when dt_define_info.class_code not in ('project','building','floor','space','system','equipment','shaft','component','virtual','tool','material')
|
|
|
+ and dt_define_info.project_id != dt_define_info.group_code then 600
|
|
|
+ else 0 end)
|
|
|
+ </sql>
|
|
|
+ <select id="queryByClassCodes" resultType="com.persagy.dmp.define.entity.ObjectInfoDefine">
|
|
|
+ select ${ew.sqlSelect}
|
|
|
+ from (
|
|
|
+ <include refid="SelectColumns"/>
|
|
|
+ from dt_define_type inner join dt_define_info on dt_define_info.class_code in (dt_define_type.code, dt_define_type.obj_type)
|
|
|
+ and dt_define_type.valid = 1 and dt_define_info.valid = 1
|
|
|
+ <if test="projectIds!=null and projectIds.size>0">
|
|
|
+ <foreach collection="projectIds" item="projectId" separator="," open=" and dt_define_info.project_id IN (" close=")">
|
|
|
+ #{projectId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ where exists(select 1 from (
|
|
|
+ select dt_define_type.code class_code, dt_define_info.code code, max(<include refid="ShowLevelSQL"/>) max_show_level
|
|
|
+ from dt_define_type inner join dt_define_info on dt_define_info.class_code in (dt_define_type.code, dt_define_type.obj_type)
|
|
|
+ and dt_define_type.valid = 1 and dt_define_info.valid = 1
|
|
|
+ <if test="projectIds!=null and projectIds.size>0">
|
|
|
+ <foreach collection="projectIds" item="projectId" separator="," open="where dt_define_info.project_id IN (" close=")">
|
|
|
+ #{projectId}
|
|
|
</foreach>
|
|
|
- AND EXISTS (
|
|
|
- SELECT
|
|
|
- 1
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- dt_define_info.CODE,
|
|
|
- max(
|
|
|
- CASE
|
|
|
- WHEN dt_define_info.class_code = dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id = '0' THEN
|
|
|
- 100
|
|
|
- WHEN dt_define_info.class_code = dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id = dt_define_info.group_code THEN
|
|
|
- 200
|
|
|
- WHEN dt_define_info.class_code = dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id != dt_define_info.group_code THEN
|
|
|
- 300
|
|
|
- WHEN dt_define_info.class_code != dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id = '0' THEN
|
|
|
- 400
|
|
|
- WHEN dt_define_info.class_code != dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id = dt_define_info.group_code THEN
|
|
|
- 500
|
|
|
- WHEN dt_define_info.class_code != dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id != dt_define_info.group_code THEN
|
|
|
- 600 ELSE 0
|
|
|
- END
|
|
|
- ) show_level
|
|
|
- FROM
|
|
|
- dt_define_info
|
|
|
- INNER JOIN dt_define_type ON dt_define_info.class_code = dt_define_type.CODE
|
|
|
- WHERE
|
|
|
- <foreach collection="classCodes" item="classCode" separator="," open="class_code IN (" close=")">
|
|
|
- #{classCode}
|
|
|
- </foreach>
|
|
|
- GROUP BY
|
|
|
- dt_define_info.CODE
|
|
|
- ) T
|
|
|
- WHERE
|
|
|
- T.CODE = dt_define_info.CODE
|
|
|
- AND (
|
|
|
- CASE
|
|
|
- WHEN dt_define_info.class_code = dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id = '0' THEN
|
|
|
- 100
|
|
|
- WHEN dt_define_info.class_code = dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id = dt_define_info.group_code THEN
|
|
|
- 200
|
|
|
- WHEN dt_define_info.class_code = dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id != dt_define_info.group_code THEN
|
|
|
- 300
|
|
|
- WHEN dt_define_info.class_code != dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id = '0' THEN
|
|
|
- 400
|
|
|
- WHEN dt_define_info.class_code != dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id = dt_define_info.group_code THEN
|
|
|
- 500
|
|
|
- WHEN dt_define_info.class_code != dt_define_type.obj_type
|
|
|
- AND dt_define_info.project_id != dt_define_info.group_code THEN
|
|
|
- 600 ELSE 0
|
|
|
- END
|
|
|
- ) = T.show_level
|
|
|
- )
|
|
|
- ) dt_define_info WHERE ${ew.expression.sqlSegment};
|
|
|
+ </if>
|
|
|
+ group by dt_define_type.code, dt_define_info.code
|
|
|
+ ) T
|
|
|
+ where T.class_code = dt_define_type.code and T.code = dt_define_info.code and T.max_show_level = <include refid="ShowLevelSQL"/>)
|
|
|
+ ) dt_define_info
|
|
|
+ WHERE ${ew.expression.sqlSegment}
|
|
|
</select>
|
|
|
-
|
|
|
-
|
|
|
</mapper>
|