YsEntityMapper.xml
6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?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.chinagas.modules.insight.mapper.YsEntityMapper">
<resultMap type="com.chinagas.api.system.domain.YsEntity" id="YsEntityResult">
<result property="objectId" column="OBJECT_ID" />
<result property="parentId" column="PARENT_ID" />
<result property="path" column="PATH" />
<result property="entity" column="ENTITY" />
<result property="entityName" column="ENTITY_NAME" />
<result property="typeName" column="TYPE_NAME" />
<result property="ancestors" column="ancestors" />
<result property="hType" column="H_TYPE" />
</resultMap>
<sql id="selectYsEntityVoLocal">
select e.OBJECT_ID, e.PARENT_ID, e.PATH, e.ENTITY, e.ENTITY_NAME, e.TYPE_NAME,e.ancestors,e.H_TYPE from ys_entity e
</sql>
<sql id="selectYsEntityVoRemote">
select OBJECT_ID, PARENT_ID, PATH, ENTITY, ENTITY_NAME, TYPE_NAME from HSP_ENTITY_TOZRCLOUD_V
</sql>
<select id="selectYsEntityListRemote" parameterType="com.chinagas.api.system.domain.YsEntity" resultMap="YsEntityResult">
<include refid="selectYsEntityVoRemote"/>
<where>
<if test="parentId != null "> and PARENT_ID = #{parentId}</if>
<if test="path != null and path != ''"> and PATH = #{path}</if>
<if test="entity != null and entity != ''"> and ENTITY = #{entity}</if>
<if test="entityName != null and entityName != ''"> and ENTITY_NAME like concat('%', #{entityName}, '%')</if>
<if test="typeName != null and typeName != ''"> and TYPE_NAME like concat('%', #{typeName}, '%')</if>
</where>
</select>
<select id="selectYsEntityList" parameterType="com.chinagas.api.system.domain.YsEntity" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
<where>
<if test="parentId != null "> and e.PARENT_ID = #{parentId}</if>
<if test="path != null and path != ''"> and e.PATH = #{path}</if>
<if test="entity != null and entity != ''"> and e.ENTITY = #{entity}</if>
<if test="entityName != null and entityName != ''"> and e.ENTITY_NAME like concat('%', #{entityName}, '%')</if>
<if test="typeName != null and typeName != ''"> and e.TYPE_NAME like concat('%', #{typeName}, '%')</if>
</where>
</select>
<select id="selectYsEntityByObjectId" parameterType="Long" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
where e.OBJECT_ID = #{objectId}
</select>
<select id="selectYsEntityChildrenSearch" parameterType="com.chinagas.api.system.domain.YsEntity" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
where e.ENTITY_NAME like concat('%', #{entityName}, '%')
and e.ANCESTORS like concat('', #{ancestors}, '%')
</select>
<select id="selectYsEntityChildrenbyId" parameterType="Long" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
where e.PARENT_ID = #{id}
</select>
<select id="selectAllDescendants" parameterType="String" resultType="String">
select entity from ys_entity WHERE FIND_IN_SET(#{entity},ancestors)
</select>
<select id="selectAllCompany" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
WHERE e.entity not like 'EN%'
</select>
<insert id="insertOrUpdateYsEntity" parameterType="com.chinagas.api.system.domain.YsEntity">
insert into ys_entity (
OBJECT_ID,
PARENT_ID,
PATH ,
ENTITY ,
ENTITY_NAME,
TYPE_NAME,
ANCESTORS
) value (
#{objectId},
#{parentId},
#{path},
#{entity},
#{entityName},
#{typeName},
#{ancestors}
) ON DUPLICATE KEY UPDATE OBJECT_ID = #{objectId},
PARENT_ID = #{parentId},
PATH = #{path},
ENTITY = #{entity},
ENTITY_NAME = #{entityName},
TYPE_NAME = #{typeName},
ANCESTORS = #{ancestors}
</insert>
<select id="selectYsEntityByUserId" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
left join ys_entity_user eu on e.entity = eu.entity
where eu.user_id = #{userId}
</select>
<select id="selectYsEntityByUserId3" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
left join ys_entity_dept ed on e.entity = ed.entity
where ed.dept_id = #{deptId}
</select>
<select id="selectYsEntityFkChildrenbyId" parameterType="String" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
where e.h_type = '1' and find_in_set(#{entity}, e.ancestors)
</select>
<select id="selectYsEntityByName" parameterType="com.chinagas.api.system.domain.YsEntity" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
where e.ENTITY_NAME like concat('%', #{entityName}, '%')
limit 15
</select>
<select id="selectYsEntityByEntity" parameterType="com.chinagas.api.system.domain.YsEntity" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
<where>
<if test="entity != null and entity != ''"> and e.ENTITY = #{entity}</if>
</where>
</select>
<select id="getEntitCount" resultType="int">
select count(*) from ys_entity WHERE RIGHT(ys_entity.ENTITY_NAME, 4) = '预算主体';
</select>
<select id="selectYsEntityByEntities" parameterType="com.chinagas.api.system.domain.YsEntity" resultMap="YsEntityResult">
<include refid="selectYsEntityVoLocal"/>
where entity in
<foreach item="entity" collection="array" open="(" separator="," close=")">
#{entity}
</foreach>
</select>
</mapper>