Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nnjcy-data-model
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
梁家彪
nnjcy-data-model
Commits
c358eb9a
Commit
c358eb9a
authored
Mar 08, 2024
by
wqc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
大屏库里查询sql优化
parent
127a9e77
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
219 additions
and
19 deletions
+219
-19
data-collect-server/src/main/java/com/zq/datacollect/DataCollectApplication.java
+5
-1
data-collect-server/src/main/java/com/zq/datacollect/config/TokenFilter.java
+1
-2
data-collect-server/src/main/java/com/zq/datacollect/controller/BigScreenController.java
+21
-13
data-collect-server/src/main/java/com/zq/datacollect/entity/CommonQuerySettings.java
+58
-0
data-collect-server/src/main/java/com/zq/datacollect/holder/ConnectDB.java
+80
-0
data-collect-server/src/main/java/com/zq/datacollect/holder/ConnectionHolder.java
+20
-0
data-collect-server/src/main/java/com/zq/datacollect/holder/DatabaseHolder.java
+1
-3
data-collect-server/src/main/java/com/zq/datacollect/mapper/CommonQuerySettingsDao.java
+7
-0
data-collect-server/src/main/java/com/zq/datacollect/service/BigScreenService.java
+0
-0
data-collect-server/src/main/java/com/zq/datacollect/service/CommonQuerysService.java
+26
-0
data-collect-server/src/main/java/com/zq/datacollect/service/impl/BigScreenServiceImpl.java
+0
-0
No files found.
data-collect-server/src/main/java/com/zq/datacollect/DataCollectApplication.java
View file @
c358eb9a
...
...
@@ -3,9 +3,13 @@ package com.zq.datacollect;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
@
SpringBootApplication
@
EnableScheduling
@MapperScan
({
"com.zq.datacollect.mapper"
})
@EnableDiscoveryClient
@SpringBootApplication
public
class
DataCollectApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
data-collect-server/src/main/java/com/zq/datacollect/config/TokenFilter.java
View file @
c358eb9a
...
...
@@ -37,8 +37,7 @@ import java.io.IOException;
* @author /
*/
@Slf4j
public
class
TokenFilter
extends
GenericFilterBean
{
public
class
TokenFilter
extends
GenericFilterBean
{
private
final
TokenProvider
tokenProvider
;
private
RedisUtils
redisUtils
;
...
...
data-collect-server/src/main/java/com/zq/datacollect/controller/BigScreenController.java
View file @
c358eb9a
package
com
.
zq
.
datacollect
.
controller
;
import
com.zq.common.annotation.AnonymousAccess
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.datacollect.service.BigScreenService
;
import
com.zq.datacollect.service.DataCollecSiteService
;
...
...
@@ -9,6 +10,7 @@ import io.swagger.annotations.ApiParam;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.sql.SQLException
;
@RestController
@Api
(
tags
=
"大屏数据显示"
)
...
...
@@ -29,31 +31,32 @@ public class BigScreenController {
@ApiOperation
(
"获取检察院数据统计"
)
@GetMapping
(
value
=
"/getAllCount"
)
public
ResultVo
getAllCount
()
{
public
ResultVo
getAllCount
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getAllCount
());
}
@ApiOperation
(
"获取模型类型数据统计"
)
@GetMapping
(
value
=
"/getModelTypeCount"
)
public
ResultVo
getModelTypeCount
()
{
@AnonymousAccess
public
ResultVo
getModelTypeCount
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getModelTypeCount
());
}
@ApiOperation
(
"获取模型地区数据统计"
)
@GetMapping
(
value
=
"/getModelCityCount"
)
public
ResultVo
getModelCityCount
()
{
public
ResultVo
getModelCityCount
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getModelCityCount
());
}
@ApiOperation
(
"获取业务类型数据统计"
)
@GetMapping
(
value
=
"/getYwuType"
)
public
ResultVo
getYwuType
()
{
public
ResultVo
getYwuType
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getYwuType
());
}
@ApiOperation
(
"获取市内各地区线索数据统计"
)
@GetMapping
(
value
=
"/getCluesNum"
)
public
ResultVo
getCluesNum
()
{
public
ResultVo
getCluesNum
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getCluesNum
());
}
...
...
@@ -89,31 +92,31 @@ public class BigScreenController {
@ApiOperation
(
"办案成效数据"
)
@GetMapping
(
value
=
"/bacxData"
)
public
ResultVo
getBacxData
()
{
public
ResultVo
getBacxData
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getBacxData
());
}
@ApiOperation
(
"模型应用成效"
)
@GetMapping
(
value
=
"/modelEffect"
)
public
ResultVo
getModelEffect
(
@RequestParam
String
shiyuan
)
{
public
ResultVo
getModelEffect
(
@RequestParam
String
shiyuan
)
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getModelEffect
(
shiyuan
));
}
@ApiOperation
(
"办案总量"
)
@GetMapping
(
value
=
"/getBazlNums"
)
public
ResultVo
getbazlNums
()
{
public
ResultVo
getbazlNums
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getbazlNums
());
}
@ApiOperation
(
"取保候审案件长期未结列表"
)
@GetMapping
(
value
=
"/getQbhsajcqwjList"
)
public
ResultVo
getQbhsajcqwjList
()
{
public
ResultVo
getQbhsajcqwjList
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getQbhsajcqwjList
());
}
@ApiOperation
(
"模型类型"
)
@GetMapping
(
value
=
"/getProxyType"
)
public
ResultVo
getProxyType
()
{
public
ResultVo
getProxyType
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getProxyType
());
}
...
...
@@ -126,22 +129,27 @@ public class BigScreenController {
@ApiOperation
(
"平台成果"
)
@GetMapping
(
value
=
"/getPingTaiData"
)
public
ResultVo
getPingTaiData
()
{
public
ResultVo
getPingTaiData
()
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getPingTaiData
());
}
@ApiOperation
(
"质量指标"
)
@GetMapping
(
value
=
"/getZhiBiaoData"
)
public
ResultVo
getZhiBiaoData
(
@RequestParam
String
diqu
,
String
type
)
{
public
ResultVo
getZhiBiaoData
(
@RequestParam
String
diqu
,
String
type
)
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getZhiBiaoData
(
diqu
,
type
));
}
@ApiOperation
(
"法律监督"
)
@GetMapping
(
value
=
"/getJianDuData"
)
public
ResultVo
getJianDuData
(
@RequestParam
String
diqu
,
String
type
)
{
public
ResultVo
getJianDuData
(
@RequestParam
String
diqu
,
String
type
)
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getJianDuData
(
diqu
,
type
));
}
@ApiOperation
(
"重大敏感案件跟踪情况"
)
@GetMapping
(
value
=
"/getZdmgajData"
)
public
ResultVo
getZdmgajData
(
@RequestParam
String
diqu
)
throws
SQLException
{
return
ResultVo
.
success
(
bigScreenService
.
getZdmgajData
(
diqu
));
}
}
data-collect-server/src/main/java/com/zq/datacollect/entity/CommonQuerySettings.java
0 → 100644
View file @
c358eb9a
package
com
.
zq
.
datacollect
.
entity
;
import
com.baomidou.mybatisplus.annotation.*
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName
(
value
=
"common_query_setting"
)
public
class
CommonQuerySettings
{
/**
* id
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
* 查询数据源id
*/
private
Long
queryDbId
;
/**
* 查询名称
*/
private
String
queryName
;
/**
* 查询显示的字段(元数据的名称)
*/
private
String
showFlied
;
/**
* 查询的where条件,包含需要条件的参数
*/
private
String
queryWhere
;
/**
* 查询SQL
*/
private
String
querySql
;
/**
* createTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* updateTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
updateTime
;
}
data-collect-server/src/main/java/com/zq/datacollect/holder/ConnectDB.java
0 → 100644
View file @
c358eb9a
package
com
.
zq
.
datacollect
.
holder
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.druid.pool.DruidPooledConnection
;
import
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder
;
import
com.zq.common.exception.BusinessException
;
import
com.zq.datacollect.entity.QueryDb
;
import
com.zq.datacollect.service.CommonQuerysService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PreDestroy
;
import
javax.annotation.Resource
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Component
public
class
ConnectDB
implements
ApplicationRunner
{
@Resource
private
CommonQuerysService
service
;
private
Map
<
Integer
,
DruidPooledConnection
>
connectionMap
=
new
HashMap
<>();
@Override
public
void
run
(
ApplicationArguments
args
)
throws
SQLException
{
List
<
QueryDb
>
datasource
=
service
.
getDatasource
();
for
(
QueryDb
ds
:
datasource
)
{
DruidDataSource
druidDataSource
=
DruidDataSourceBuilder
.
create
().
build
();
String
url
=
""
;
String
className
=
""
;
switch
(
ds
.
getDbType
())
{
case
1
:
className
=
"com.mysql.cj.jdbc.Driver"
;
url
=
"jdbc:mysql://"
+
ds
.
getDbIp
()
+
":"
+
ds
.
getDbPort
()
+
"/"
+
ds
.
getDbName
()
+
"?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&useOldAliasMetadataBehavior=true"
;
break
;
case
2
:
className
=
"oracle.jdbc.driver.OracleDriver"
;
url
=
"jdbc:oracle:thin:@//"
+
ds
.
getDbIp
()
+
":"
+
ds
.
getDbPort
()
+
"/"
+
ds
.
getDbName
();
break
;
case
3
:
className
=
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
;
url
=
"jdbc:sqlserver://"
+
ds
.
getDbIp
()
+
":"
+
ds
.
getDbPort
()
+
"/"
+
ds
.
getDbName
();
break
;
default
:
throw
new
BusinessException
(
"不支持的数据库"
);
}
druidDataSource
.
setDriverClassName
(
className
);
druidDataSource
.
setUrl
(
url
);
druidDataSource
.
setUsername
(
ds
.
getUsername
());
druidDataSource
.
setPassword
(
ds
.
getPassword
());
druidDataSource
.
init
();
DruidPooledConnection
connection
=
druidDataSource
.
getConnection
();
connectionMap
.
put
(
ds
.
getId
(),
connection
);
}
log
.
info
(
"成功加载数据库:"
+
connectionMap
.
size
());
}
@Bean
public
ConnectionHolder
getConnectionHolder
(){
return
new
ConnectionHolder
(
connectionMap
);
}
@PreDestroy
public
void
onClose
(){
for
(
DruidPooledConnection
connection
:
connectionMap
.
values
())
{
try
{
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
data-collect-server/src/main/java/com/zq/datacollect/holder/ConnectionHolder.java
0 → 100644
View file @
c358eb9a
package
com
.
zq
.
datacollect
.
holder
;
import
com.alibaba.druid.pool.DruidPooledConnection
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
ConnectionHolder
{
private
Map
<
Integer
,
DruidPooledConnection
>
connectionMap
=
new
HashMap
<>();
public
ConnectionHolder
(
Map
<
Integer
,
DruidPooledConnection
>
connectionMap
)
{
this
.
connectionMap
=
connectionMap
;
}
public
DruidPooledConnection
get
(
Integer
id
){
return
connectionMap
.
get
(
id
);
}
}
data-collect-server/src/main/java/com/zq/datacollect/holder/DatabaseHolder.java
View file @
c358eb9a
...
...
@@ -5,8 +5,6 @@ import com.zq.common.exception.BusinessException;
import
com.zq.datacollect.entity.QueryDb
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -25,7 +23,7 @@ public class DatabaseHolder {
switch
(
dbType
)
{
case
1
:
className
=
"com.mysql.cj.jdbc.Driver"
;
url
=
"jdbc:mysql://"
+
dbIp
+
":"
+
dbPort
+
"/"
+
dbName
+
"?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&autoReconnect=true"
;
url
=
"jdbc:mysql://"
+
dbIp
+
":"
+
dbPort
+
"/"
+
dbName
+
"?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&autoReconnect=true
&useOldAliasMetadataBehavior=true
"
;
break
;
case
2
:
className
=
"oracle.jdbc.driver.OracleDriver"
;
...
...
data-collect-server/src/main/java/com/zq/datacollect/mapper/CommonQuerySettingsDao.java
0 → 100644
View file @
c358eb9a
package
com
.
zq
.
datacollect
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.zq.datacollect.entity.CommonQuerySettings
;
public
interface
CommonQuerySettingsDao
extends
BaseMapper
<
CommonQuerySettings
>
{
}
data-collect-server/src/main/java/com/zq/datacollect/service/BigScreenService.java
View file @
c358eb9a
This diff is collapsed.
Click to expand it.
data-collect-server/src/main/java/com/zq/datacollect/service/CommonQuerysService.java
0 → 100644
View file @
c358eb9a
package
com
.
zq
.
datacollect
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zq.datacollect.entity.CommonQuerySettings
;
import
com.zq.datacollect.entity.QueryDb
;
import
com.zq.datacollect.mapper.CommonQuerySettingsDao
;
import
com.zq.datacollect.mapper.QueryDbMapper
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
CommonQuerysService
extends
ServiceImpl
<
CommonQuerySettingsDao
,
CommonQuerySettings
>
{
@Resource
private
QueryDbMapper
queryDbDao
;
public
List
<
QueryDb
>
getDatasource
()
{
return
queryDbDao
.
selectList
(
new
QueryWrapper
<>());
}
}
data-collect-server/src/main/java/com/zq/datacollect/service/impl/BigScreenServiceImpl.java
0 → 100644
View file @
c358eb9a
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment