EnterpriseInfoMapper.xml
19.2 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<?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.ruoyi.web.controller.business.mapper.EnterpriseInfoMapper">
<resultMap type="EnterpriseInfo" id="EnterpriseInfoResult">
<result property="id" column="id" />
<result property="ename" column="ename" />
<result property="creditCode" column="credit_code" />
<result property="legalpersonName" column="legalperson_name" />
<result property="estiblishTime" column="estiblish_time" />
<result property="regCapital" column="reg_capital" />
<result property="regInstitute" column="reg_institute" />
<result property="regStatus" column="reg_status" />
<result property="businessScope" column="business_scope" />
<result property="enterpriseAddress" column="enterprise_address" />
<result property="menlei" column="menlei" />
<result property="regLocation" column="reg_location" />
<result property="dataStatus" column="data_status" />
<result property="creditFraction" column="credit_fraction" />
<result property="creditLevel" column="credit_level" />
<result property="industryName" column="industry_name" />
<result property="industry" column="industry" />
<result property="regStatusCode" column="reg_status_code" />
<result property="newRegCapital" column="new_reg_capital" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectEnterpriseInfoVo">
select id, ename, credit_code, legalperson_name, estiblish_time, reg_capital, reg_institute, reg_status, business_scope, enterprise_address, menlei, reg_location, data_status, credit_fraction, credit_level,industry_name,industry,reg_status_code, new_reg_capital,create_time, update_time from enterprise_info
</sql>
<select id="selectEnterpriseInfoList" parameterType="EnterpriseInfo" resultMap="EnterpriseInfoResult">
<!-- <include refid="selectEnterpriseInfoVo"/>-->
select
a.id,
a.ename,
a.credit_code,
a.legalperson_name,
a.estiblish_time,
a.reg_capital,
a.reg_institute,
a.reg_status,
a.business_scope,
a.enterprise_address,
a.menlei,
a.reg_location,
a.data_status,
a.credit_fraction,
a.credit_level,
a.industry_name,
a.industry,
a.reg_status_code,
a.new_reg_capital,
a.create_time,
a.update_time
from
enterprise_info a
<!--(科技型中小企业: 1, 高新技术企业:2, 瞪羚企业:3, 独角兽企业:4, 专精特新小巨人企业: 5)-->
<if test="tableType != null and tableType !=''">
join
<choose>
<when test="tableType == 1"> tech_medium_enterprise t on a.credit_code = t.credit_code and t.year = extract (year from CURRENT_DATE) -1 </when>
<when test="tableType == 2"> high_tech_enterprise h on a.credit_code = h.credit_code and h.year = extract (year from CURRENT_DATE) -1 </when>
<when test="tableType == 3"> gazelle_enterprise g on a.credit_code = g.credit_code and g.year = extract (year from CURRENT_DATE) -1</when>
<when test="tableType == 4"> unicorn_enterprise u on a.credit_code = u.credit_code and u.year = extract (year from CURRENT_DATE) -1</when>
<when test="tableType == 5"> giant_enterprise i on a.credit_code = i.credit_code and i.year = extract (year from CURRENT_DATE) -1</when>
<otherwise></otherwise>
</choose>
</if>
<if test="tagName != null and tagName != ''">
join enterprise_tags b on a.credit_code = b.enterprise_code
</if>
<where>
a.data_status = '0'
<!--<if test="tableType != null and tableType !=''">
<choose>
<when test="tableType == 1">t.year = extract (year from CURRENT_DATE) -1 </when>
<when test="tableType == 2">h.year = extract (year from CURRENT_DATE) -1</when>
<when test="tableType == 3">g.year = extract (year from CURRENT_DATE) -1</when>
<when test="tableType == 4">u.year = extract (year from CURRENT_DATE) -1</when>
<when test="tableType == 5">i.year = extract (year from CURRENT_DATE) -1</when>
<otherwise></otherwise>
</choose>
</if>-->
<if test="ename != null and ename != ''"> and a.ename like concat('%', #{ename}, '%')</if>
<if test="creditCode != null and creditCode != ''"> and a.credit_code = #{creditCode}</if>
<if test="legalpersonName != null and legalpersonName != ''"> and a.legalperson_name like concat('%', #{legalpersonName}, '%')</if>
<if test="estiblishTimeStart != null and estiblishTimeStart != ''">
and a.estiblish_time::date >= to_date(#{estiblishTimeStart},'yyyy-MM-dd')
</if>
<if test="estiblishTimeEnd != null and estiblishTimeEnd != ''">
and a.estiblish_time::Date <= to_date(#{estiblishTimeEnd},'yyyy-MM-dd')
</if>
<!-- <if test="regCapital != null and regCapital != ''"> and reg_capital = #{regCapital}</if>-->
<if test="regCapitalStart != null ">
and a.reg_capital > #{regCapitalStart}
</if>
<if test="regCapitalEnd != null ">
and a.reg_capital <= #{regCapitalEnd}
</if>
<!-- <if test="creditFraction != null and creditFraction != ''"> and credit_fraction = #{creditFraction}</if>-->
<if test="creditFractionStart != null ">
and a.credit_fraction > #{creditFractionStart}
</if>
<if test="creditFractionEnd != null ">
and a.credit_fraction <= #{creditFractionEnd}
</if>
<if test="regInstitute != null and regInstitute != ''"> and a.reg_institute = #{regInstitute}</if>
<!-- <if test="regStatus != null and regStatus != ''"> and a.reg_status = #{regStatus}</if>-->
<if test="businessScope != null and businessScope != ''"> and a.business_scope = #{businessScope}</if>
<if test="enterpriseAddress != null and enterpriseAddress != ''"> and a.enterprise_address = #{enterpriseAddress}</if>
<if test="menlei != null and menlei != ''"> and a.menlei = #{menlei}</if>
<if test="regLocation != null and regLocation != ''"> and a.reg_location = #{regLocation}</if>
<if test="dataStatus != null and dataStatus != ''"> and a.data_status = #{dataStatus}</if>
<if test="creditLevel != null and creditLevel != ''"> and a.credit_level = #{creditLevel}</if>
<if test="industryName != null and industryName != ''"> and a.industry_name = #{industryName}</if>
<if test="industry != null and industry != ''"> and a.industry = #{industry}</if>
<if test="regStatusCode != null and regStatusCode != ''"> and a.reg_status_code = #{regStatusCode}</if>
<if test="newRegCapital != null and newRegCapital != ''"> and a.new_reg_capital = #{newRegCapital}</if>
<if test="tagName != null and tagName != ''"> and b.tag_name = #{tagName}</if>
</where>
</select>
<select id="selectEnterpriseInfoById" parameterType="Long" resultMap="EnterpriseInfoResult">
</select>
<insert id="insertEnterpriseInfo" parameterType="EnterpriseInfo">
insert into enterprise_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="ename != null">ename,</if>
<if test="creditCode != null">credit_code,</if>
<if test="legalpersonName != null">legalperson_name,</if>
<if test="estiblishTime != null">estiblish_time,</if>
<if test="regCapital != null">reg_capital,</if>
<if test="regInstitute != null">reg_institute,</if>
<if test="regStatus != null">reg_status,</if>
<if test="businessScope != null">business_scope,</if>
<if test="enterpriseAddress != null">enterprise_address,</if>
<if test="menlei != null">menlei,</if>
<if test="regLocation != null">reg_location,</if>
<if test="dataStatus != null">data_status,</if>
<if test="creditFraction != null">credit_fraction,</if>
<if test="creditLevel != null">credit_level,</if>
<if test="industryName != null">industry_name,</if>
<if test="industry != null">industry,</if>
<if test="regStatusCode != null">reg_status_code,</if>
<if test="newRegCapital != null">new_reg_capital,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="ename != null">#{ename},</if>
<if test="creditCode != null">#{creditCode},</if>
<if test="legalpersonName != null">#{legalpersonName},</if>
<if test="estiblishTime != null">#{estiblishTime},</if>
<if test="regCapital != null">#{regCapital},</if>
<if test="regInstitute != null">#{regInstitute},</if>
<if test="regStatus != null">#{regStatus},</if>
<if test="businessScope != null">#{businessScope},</if>
<if test="enterpriseAddress != null">#{enterpriseAddress},</if>
<if test="menlei != null">#{menlei},</if>
<if test="regLocation != null">#{regLocation},</if>
<if test="dataStatus != null">#{dataStatus},</if>
<if test="creditFraction != null">#{creditFraction},</if>
<if test="creditLevel != null">#{creditLevel},</if>
<if test="industryName != null">#{industry_name},</if>
<if test="industry != null">#{industry},</if>
<if test="regStatusCode != null">#{reg_status_code},</if>
<if test="newRegCapital != null">#{new_reg_capital},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateEnterpriseInfo" parameterType="EnterpriseInfo">
update enterprise_info
<trim prefix="SET" suffixOverrides=",">
<if test="ename != null">ename = #{ename},</if>
<if test="creditCode != null">credit_code = #{creditCode},</if>
<if test="legalpersonName != null">legalperson_name = #{legalpersonName},</if>
<if test="estiblishTime != null">estiblish_time = #{estiblishTime},</if>
<if test="regCapital != null">reg_capital = #{regCapital},</if>
<if test="regInstitute != null">reg_institute = #{regInstitute},</if>
<if test="regStatus != null">reg_status = #{regStatus},</if>
<if test="businessScope != null">business_scope = #{businessScope},</if>
<if test="enterpriseAddress != null">enterprise_address = #{enterpriseAddress},</if>
<if test="menlei != null">menlei = #{menlei},</if>
<if test="regLocation != null">reg_location = #{regLocation},</if>
<if test="dataStatus != null">data_status = #{dataStatus},</if>
<if test="creditFraction != null">credit_fraction = #{creditFraction},</if>
<if test="creditLevel != null">credit_level = #{creditLevel},</if>
<if test="industryName != null">industry_name = #{industryName},</if>
<if test="industry != null">industry = #{industry},</if>
<if test="regStatusCode != null">reg_status_code = #{regStatusCode},</if>
<if test="newRegCapital != null">new_reg_capital = #{newRegCapital},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEnterpriseInfoById" parameterType="Long">
delete from enterprise_info where id = #{id}
</delete>
<delete id="deleteEnterpriseInfoByIds" parameterType="String">
delete from enterprise_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getEnterpriseCount" resultType="EnterpriseInfo">
select (select COUNT(distinct credit_code) from credit_nx.giant_enterprise) as giantCount,
(select COUNT(distinct credit_code) from credit_nx.unicorn_enterprise) as unicornCount,
(select COUNT(distinct credit_code) from credit_nx.tech_medium_enterprise) as techMediumCount,
(select COUNT(distinct credit_code) from credit_nx.high_tech_enterprise) as highTechCount,
(select COUNT(distinct credit_code) from credit_nx.gazelle_enterprise) as gazelleCount
</select>
<select id="getAllEnterpriseCountTrend" resultType="EnterpriseInfo" parameterType="EnterpriseInfo">
SELECT
COUNT(a.id) AS counts,
EXTRACT(YEAR FROM a.estiblish_time) AS years
FROM
credit_nx.enterprise_info a
WHERE
a.data_status = '0'
AND EXTRACT(YEAR FROM a.estiblish_time) >= #{estiblishTimeStart}
AND EXTRACT(YEAR FROM a.estiblish_time) <= #{estiblishTimeEnd}
<if test="regLocation != null and regLocation != ''"> and a.reg_location = #{regLocation}</if>
<if test="menlei != null and menlei != ''"> and a.menlei = #{menlei}</if>
<if test="regStatusCode != null and regStatusCode != ''"> and a.reg_status_code = #{regStatusCode}</if>
GROUP BY
years
ORDER BY
years ASC
</select>
<select id="getTypeEnterpriseCountTrend" resultType="EnterpriseInfo" parameterType="EnterpriseInfo">
select
COUNT(a.id) AS counts,
t."year" as years
FROM
credit_nx.enterprise_info a
<if test="tableType != null and tableType !=''">
<!--(科技型中小企业: 1, 高新技术企业:2, 瞪羚企业:3, 独角兽企业:4, 专精特新小巨人企业: 5)-->
<choose>
<when test="tableType == 1">join credit_nx.tech_medium_enterprise t on a.credit_code = t.credit_code</when>
<when test="tableType == 2">join credit_nx.high_tech_enterprise t on a.credit_code = t.credit_code</when>
<when test="tableType == 3">join credit_nx.gazelle_enterprise t on a.credit_code = t.credit_code</when>
<when test="tableType == 4">join credit_nx.unicorn_enterprise t on a.credit_code = t.credit_code</when>
<when test="tableType == 5">join credit_nx.giant_enterprise t on a.credit_code = t.credit_code</when>
<otherwise></otherwise>
</choose>
</if>
WHERE
a.data_status = '0'
AND t."year" >= #{estiblishTimeStart}
and t."year" <= #{estiblishTimeEnd}
<if test="regLocation != null and regLocation != ''"> and a.reg_location = #{regLocation}</if>
<if test="menlei != null and menlei != ''"> and a.menlei = #{menlei}</if>
<if test="regStatusCode != null and regStatusCode != ''"> and a.reg_status_code = #{regStatusCode}</if>
GROUP BY
years
order by
years ASC
</select>
<select id="getEnterpriseCountByType" resultType="EnterpriseInfo" parameterType="EnterpriseInfo">
SELECT
COUNT(a.id) AS counts
<choose>
<when test="groupBy == 1">,a.reg_location AS regLocation</when>
<when test="groupBy == 2">,a.credit_level AS creditLevel</when>
<otherwise></otherwise>
</choose>
FROM
credit_nx.enterprise_info a
WHERE
a.data_status = '0'
AND EXTRACT(YEAR FROM a.estiblish_time) = #{estiblishTimeStart}
<if test="menlei != null and menlei != ''"> and a.menlei = #{menlei}</if>
<if test="groupBy != null and groupBy != ''">
GROUP BY
<choose>
<when test="groupBy == 1">
a.reg_location
ORDER BY
a.reg_location
</when>
<when test="groupBy == 2">
a.credit_level
ORDER BY
a.credit_level
</when>
<otherwise></otherwise>
</choose>
</if>
</select>
<select id="getEnterpriseCountRegCapTrend" resultType="EnterpriseInfo" parameterType="EnterpriseInfo">
select
case
when reg_capital > 0 and reg_capital <= 1000 then '0-1000万'
when reg_capital > 1000 and reg_capital <= 5000 then '1000万-5000万'
when reg_capital > 5000 and reg_capital <= 10000 then '5000万-1亿'
when reg_capital > 10000 and reg_capital <= 100000 then '1亿-10亿'
when reg_capital > 100000 then '10亿以上'
else '其他'
end as 'newRegCapital',
count(*) as counts
from
credit_nx.enterprise_info
where
extract (year from estiblish_time) = #{estiblishTimeStart}
<if test="regLocation != null and regLocation != ''"> and reg_location = #{regLocation}</if>
<if test="menlei != null and menlei != ''"> and menlei = #{menlei}</if>
group by newRegCapital
order by newRegCapital
</select>
<select id="getEnterpriseType" resultType="EnterpriseInfo">
SELECT
e.id,
COUNT(DISTINCT t.id) as techMediumCount,
COUNT(DISTINCT h.id) as highTechCount,
COUNT(DISTINCT g.id) as gazelleCount ,
COUNT(DISTINCT u.id) as unicornCount,
COUNT(DISTINCT i.id) as giantCount
FROM
credit_nx.enterprise_info e
LEFT JOIN credit_nx.tech_medium_enterprise t ON e.credit_code = t.credit_code and t.year = extract (year from CURRENT_DATE) -1
LEFT JOIN credit_nx.high_tech_enterprise h ON e.credit_code = h.credit_code and h.year = extract (year from CURRENT_DATE) -1
LEFT JOIN credit_nx.gazelle_enterprise g ON e.credit_code = g.credit_code and g.year = extract (year from CURRENT_DATE) -1
LEFT JOIN credit_nx.unicorn_enterprise u ON e.credit_code = u.credit_code and u.year = extract (year from CURRENT_DATE) -1
LEFT JOIN credit_nx.giant_enterprise i ON e.credit_code = i.credit_code and i.year = extract (year from CURRENT_DATE) -1
WHERE e.credit_code = #{creditCode}
GROUP BY e.id;
</select>
</mapper>