OrganizationMapper.xml
13 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?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.lhcredit.project.business.organization.mapper.OrganizationMapper">
<resultMap type="Organization" id="OrganizationResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="creditNo" column="credit_no" />
<result property="orgType" column="org_type" />
<result property="status" column="status" />
<result property="operName" column="oper_name" />
<result property="regAddress" column="reg_address" />
<result property="startDate" column="start_date" />
<result property="scope" column="scope" />
<result property="registCapi" column="regist_capi" />
<result property="scopeType" column="scope_type" />
<result property="department" column="department" />
<result property="creditLevel" column="credit_level" />
<result property="creditScore" column="credit_score" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="delStatus" column="del_status" />
</resultMap>
<sql id="selectOrganizationVo">
select id, name, credit_no, org_type, status, oper_name, reg_address, start_date, scope, regist_capi, scope_type, department, credit_level, credit_score, create_time, update_time, del_status from organization
</sql>
<select id="selectOrganizationList" parameterType="Organization" resultMap="OrganizationResult">
<include refid="selectOrganizationVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="name != null and name != '' "> and name = #{name}</if>
<if test="creditNo != null and creditNo != '' "> and credit_no = #{creditNo}</if>
<if test="orgType != null and orgType != '' "> and org_type = #{orgType}</if>
<if test="status != null and status != '' "> and status = #{status}</if>
<if test="operName != null and operName != '' "> and oper_name = #{operName}</if>
<if test="regAddress != null and regAddress != '' "> and reg_address = #{regAddress}</if>
<if test="startDate != null and startDate != '' "> and start_date = #{startDate}</if>
<if test="scope != null and scope != '' "> and scope = #{scope}</if>
<if test="registCapi != null "> and regist_capi = #{registCapi}</if>
<if test="scopeType != null and scopeType != '' "> and scope_type = #{scopeType}</if>
<if test="department != null and department != '' "> and department = #{department}</if>
<if test="creditLevel != null and creditLevel != '' "> and credit_level = #{creditLevel}</if>
<if test="creditScore != null "> and credit_score = #{creditScore}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="delStatus != null and delStatus != '' "> and del_status = #{delStatus}</if>
</where>
</select>
<select id="selectOrganizationById" parameterType="Long" resultMap="OrganizationResult">
<include refid="selectOrganizationVo"/>
where id = #{id}
</select>
<insert id="insertOrganization" parameterType="Organization" useGeneratedKeys="true" keyProperty="id">
insert into organization
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != '' ">name,</if>
<if test="creditNo != null and creditNo != '' ">credit_no,</if>
<if test="orgType != null and orgType != '' ">org_type,</if>
<if test="status != null and status != '' ">status,</if>
<if test="operName != null and operName != '' ">oper_name,</if>
<if test="regAddress != null and regAddress != '' ">reg_address,</if>
<if test="startDate != null and startDate != '' ">start_date,</if>
<if test="scope != null and scope != '' ">scope,</if>
<if test="registCapi != null ">regist_capi,</if>
<if test="scopeType != null and scopeType != '' ">scope_type,</if>
<if test="department != null and department != '' ">department,</if>
<if test="creditLevel != null and creditLevel != '' ">credit_level,</if>
<if test="creditScore != null ">credit_score,</if>
<if test="createTime != null ">create_time,</if>
<if test="updateTime != null ">update_time,</if>
<if test="delStatus != null and delStatus != '' ">del_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != '' ">#{name},</if>
<if test="creditNo != null and creditNo != '' ">#{creditNo},</if>
<if test="orgType != null and orgType != '' ">#{orgType},</if>
<if test="status != null and status != '' ">#{status},</if>
<if test="operName != null and operName != '' ">#{operName},</if>
<if test="regAddress != null and regAddress != '' ">#{regAddress},</if>
<if test="startDate != null and startDate != '' ">#{startDate},</if>
<if test="scope != null and scope != '' ">#{scope},</if>
<if test="registCapi != null ">#{registCapi},</if>
<if test="scopeType != null and scopeType != '' ">#{scopeType},</if>
<if test="department != null and department != '' ">#{department},</if>
<if test="creditLevel != null and creditLevel != '' ">#{creditLevel},</if>
<if test="creditScore != null ">#{creditScore},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="updateTime != null ">#{updateTime},</if>
<if test="delStatus != null and delStatus != '' ">#{delStatus},</if>
</trim>
</insert>
<update id="updateOrganization" parameterType="Organization">
update organization
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != '' ">name = #{name},</if>
<if test="creditNo != null and creditNo != '' ">credit_no = #{creditNo},</if>
<if test="orgType != null and orgType != '' ">org_type = #{orgType},</if>
<if test="status != null and status != '' ">status = #{status},</if>
<if test="operName != null and operName != '' ">oper_name = #{operName},</if>
<if test="regAddress != null and regAddress != '' ">reg_address = #{regAddress},</if>
<if test="startDate != null and startDate != '' ">start_date = #{startDate},</if>
<if test="scope != null and scope != '' ">scope = #{scope},</if>
<if test="registCapi != null ">regist_capi = #{registCapi},</if>
<if test="scopeType != null and scopeType != '' ">scope_type = #{scopeType},</if>
<if test="department != null and department != '' ">department = #{department},</if>
<if test="creditLevel != null and creditLevel != '' ">credit_level = #{creditLevel},</if>
<if test="creditScore != null ">credit_score = #{creditScore},</if>
<if test="createTime != null ">create_time = #{createTime},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if>
<if test="delStatus != null and delStatus != '' ">del_status = #{delStatus},</if>
</trim>
where id = #{id}
</update>
<update id="updateOrganizationByCode" parameterType="Organization">
update organization
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != '' ">name = #{name},</if>
<if test="orgType != null and orgType != '' ">org_type = #{orgType},</if>
<if test="status != null and status != '' ">status = #{status},</if>
<if test="operName != null and operName != '' ">oper_name = #{operName},</if>
<if test="regAddress != null and regAddress != '' ">reg_address = #{regAddress},</if>
<if test="startDate != null and startDate != '' ">start_date = #{startDate},</if>
<if test="scope != null and scope != '' ">scope = #{scope},</if>
<if test="registCapi != null ">regist_capi = #{registCapi},</if>
<if test="scopeType != null and scopeType != '' ">scope_type = #{scopeType},</if>
<if test="department != null and department != '' ">department = #{department},</if>
<if test="creditLevel != null and creditLevel != '' ">credit_level = #{creditLevel},</if>
<if test="creditScore != null ">credit_score = #{creditScore},</if>
<if test="createTime != null ">create_time = #{createTime},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if>
<if test="delStatus != null and delStatus != '' ">del_status = #{delStatus},</if>
</trim>
where credit_no = #{creditNo}
</update>
<delete id="deleteOrganizationById" parameterType="Long">
delete from organization where id = #{id}
</delete>
<delete id="deleteOrganizationByIds" parameterType="String">
delete from organization where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectAllOrganizationGroupLevel" resultType="java.util.Map">
SELECT credit_level as creditLevel,count(*) as num from organization GROUP BY credit_level
</select>
<select id="selectAllOrganizationGroupReg" resultType="java.util.Map">
SELECT registCapiStr,count(*) as num from ( select CASE
WHEN regist_capi < 5 THEN '0(含)~5万'
WHEN regist_capi>=5 and regist_capi < 10 THEN '5(含)~10万'
WHEN regist_capi>=10 and regist_capi < 50 THEN '10(含)~50万'
WHEN regist_capi>=50 and regist_capi < 100 THEN '50(含)~100万'
WHEN regist_capi>=100 and regist_capi < 300 THEN '100(含)~300万'
WHEN regist_capi>=300 THEN '300万(含)以上'
END as registCapiStr from organization
) as org group by registCapiStr
</select>
<select id="selectAllOrganizationGroupOrgTyp" resultType="java.util.Map">
SELECT org_type as orgType,count(*) as num from organization GROUP BY org_type
</select>
<select id="selectAllOrganizationGroupScopeTyp" resultType="java.util.Map">
SELECT scope_type as scopeType,count(*) as num from organization GROUP BY scope_type
</select>
<select id="selectAllOrganizationCount" resultType="Integer">
SELECT count(*) as num from organization where del_status='0'
</select>
<select id="selectOrganizationListBy" parameterType="Organization" resultMap="OrganizationResult">
select * from (SELECT TIMESTAMPDIFF(YEAR,start_date, NOW()) AS num,o.* FROM organization o) as org
<where>
<if test="id != null "> and id = #{id}</if>
<if test="name != null and name != '' "> and name = #{name}</if>
<if test="creditNo != null and creditNo != '' "> and credit_no = #{creditNo}</if>
<if test="orgType != null and orgType != '' "> and org_type = #{orgType}</if>
<if test="status != null and status != '' "> and status = #{status}</if>
<if test="operName != null and operName != '' "> and oper_name = #{operName}</if>
<if test="regAddress != null and regAddress != '' "> and reg_address = #{regAddress}</if>
<if test="scope != null and scope != '' "> and scope = #{scope}</if>
<if test="beginRegistCapi !=null">
and regist_capi >= #{beginRegistCapi}
</if>
<if test="endRegistCapi !=null">
and regist_capi < #{endRegistCapi}
</if>
<if test="beginEstablish !=null">
and num > #{beginEstablish}
</if>
<if test="endEstablish !=null">
and mun <= #{endEstablish}
</if>
<if test="scopeType != null and scopeType != '' "> and scope_type = #{scopeType}</if>
<if test="department != null and department != '' "> and department = #{department}</if>
<if test="creditLevel != null and creditLevel != '' "> and credit_level = #{creditLevel}</if>
<if test="creditScore != null "> and credit_score = #{creditScore}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="delStatus != null and delStatus != '' "> and del_status = #{delStatus}</if>
</where>
</select>
</mapper>