Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-cloud
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data-hook
gic-cloud
Commits
fbf34941
Commit
fbf34941
authored
Jun 11, 2020
by
陶光胜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'developer' into 'master'
Developer See merge request
!3
parents
639c8de0
a75ca6cf
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
359 additions
and
39 deletions
+359
-39
pom.xml
gic-cloud-data-hook-api/pom.xml
+1
-1
FlatQueryTable.java
.../java/com/gic/cloud/data/hook/api/dto/FlatQueryTable.java
+17
-0
FreeQuerySource.java
...java/com/gic/cloud/data/hook/api/dto/FreeQuerySource.java
+29
-0
FlatQueryTaskCondition.java
...ic/cloud/data/hook/api/entity/FlatQueryTaskCondition.java
+9
-0
IFlatQueryResultService.java
.../cloud/data/hook/api/service/IFlatQueryResultService.java
+4
-3
IFlatQueryTableService.java
...c/cloud/data/hook/api/service/IFlatQueryTableService.java
+3
-1
IFreeQueryService.java
...om/gic/cloud/data/hook/api/service/IFreeQueryService.java
+2
-4
pom.xml
gic-cloud-data-hook-service/pom.xml
+1
-1
HiveHelper.java
...main/java/com/gic/cloud/data/hook/service/HiveHelper.java
+24
-0
MysqlHelper.java
...ain/java/com/gic/cloud/data/hook/service/MysqlHelper.java
+4
-1
FlatQueryTableDao.java
...om/gic/cloud/data/hook/service/dao/FlatQueryTableDao.java
+1
-1
FlatQueryResultServiceImpl.java
...ud/data/hook/service/impl/FlatQueryResultServiceImpl.java
+29
-9
FlatQueryTableServiceImpl.java
...oud/data/hook/service/impl/FlatQueryTableServiceImpl.java
+2
-2
FreeQueryServiceImpl.java
...ic/cloud/data/hook/service/impl/FreeQueryServiceImpl.java
+6
-1
data-hook-flat-query-source.xml
...ervice/src/main/resources/data-hook-flat-query-source.xml
+24
-0
DownloadRecordDao.xml
...k-service/src/main/resources/mapper/DownloadRecordDao.xml
+5
-3
FlatQueryTableDao.xml
...k-service/src/main/resources/mapper/FlatQueryTableDao.xml
+10
-1
pom.xml
gic-cloud-data-hook/pom.xml
+1
-1
AlarmController.java
...ain/java/com/gic/cloud/data/hook/web/AlarmController.java
+108
-0
DownloadTaskController.java
...a/com/gic/cloud/data/hook/web/DownloadTaskController.java
+4
-4
FlatQueryController.java
...java/com/gic/cloud/data/hook/web/FlatQueryController.java
+56
-4
FreeQueryController.java
...java/com/gic/cloud/data/hook/web/FreeQueryController.java
+17
-1
data-hook-dubbo-config.xml
...a-hook/src/main/webapp/WEB-INF/data-hook-dubbo-config.xml
+2
-1
No files found.
gic-cloud-data-hook-api/pom.xml
View file @
fbf34941
...
...
@@ -20,7 +20,7 @@
<name>
${project.artifactId}
</name>
<properties>
<libraryVersion>
3.0-SNAPSHOT
</libraryVersion>
</properties>
<distributionManagement>
<snapshotRepository>
...
...
gic-cloud-data-hook-api/src/main/java/com/gic/cloud/data/hook/api/dto/FlatQueryTable.java
View file @
fbf34941
...
...
@@ -129,6 +129,23 @@ public class FlatQueryTable implements Serializable {
this
.
isFavo
=
isFavo
;
}
private
String
authStoreId
;
public
String
getAuthStoreId
()
{
return
authStoreId
;
}
public
void
setAuthStoreId
(
String
authStoreId
)
{
this
.
authStoreId
=
authStoreId
;
}
private
String
authDesc
;
public
String
getAuthDesc
()
{
return
authDesc
;
}
public
void
setAuthDesc
(
String
authDesc
)
{
this
.
authDesc
=
authDesc
;
}
}
gic-cloud-data-hook-api/src/main/java/com/gic/cloud/data/hook/api/dto/FreeQuerySource.java
View file @
fbf34941
package
com
.
gic
.
cloud
.
data
.
hook
.
api
.
dto
;
import
java.io.Serializable
;
import
java.util.Date
;
/** 自定义查询 DTO
*
...
...
@@ -110,4 +111,32 @@ public class FreeQuerySource implements Serializable {
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
private
String
database
=
""
;
private
Integer
isPrivate
=
0
;
private
Date
dbExpiration
;
public
String
getDatabase
()
{
return
database
;
}
public
void
setDatabase
(
String
database
)
{
this
.
database
=
database
;
}
public
Integer
getIsPrivate
()
{
return
isPrivate
;
}
public
void
setIsPrivate
(
Integer
isPrivate
)
{
this
.
isPrivate
=
isPrivate
;
}
public
Date
getDbExpiration
()
{
return
dbExpiration
;
}
public
void
setDbExpiration
(
Date
dbExpiration
)
{
this
.
dbExpiration
=
dbExpiration
;
}
}
gic-cloud-data-hook-api/src/main/java/com/gic/cloud/data/hook/api/entity/FlatQueryTaskCondition.java
View file @
fbf34941
...
...
@@ -177,4 +177,13 @@ public class FlatQueryTaskCondition {
}
private
List
<
String
>
authStoreIdList
;
public
List
<
String
>
getAuthStoreIdList
()
{
return
authStoreIdList
;
}
public
void
setAuthStoreIdList
(
List
<
String
>
authStoreIdList
)
{
this
.
authStoreIdList
=
authStoreIdList
;
}
}
gic-cloud-data-hook-api/src/main/java/com/gic/cloud/data/hook/api/service/IFlatQueryResultService.java
View file @
fbf34941
...
...
@@ -22,7 +22,7 @@ public interface IFlatQueryResultService {
* @return
*/
public
FlatQueryResult
getFlatQueryResult
(
String
tableId
,
List
<
String
>
enterpriseIds
,
List
<
FlatQueryCondition
>
queryConditions
,
String
orderField
,
String
orderDir
,
Boolean
execDistinct
,
Integer
queryDataType
,
Integer
limitRange
,
int
dataPermission
);
Boolean
execDistinct
,
Integer
queryDataType
,
Integer
limitRange
,
int
dataPermission
,
List
<
String
>
authStoreList
);
/** 评估自助指标查询下载任务数据量
* @param tableId
...
...
@@ -34,7 +34,7 @@ public interface IFlatQueryResultService {
* @return
*/
public
Integer
estimateFlatQueryDownloadTask
(
String
tableId
,
List
<
String
>
enterpriseIds
,
List
<
FlatQueryCondition
>
queryConditions
,
String
orderField
,
String
orderDir
,
Boolean
execDistinct
);
String
orderField
,
String
orderDir
,
Boolean
execDistinct
,
List
<
String
>
authStoreIdList
);
/** 创建自助指标查询的下载任务
* @param userId
...
...
@@ -51,7 +51,8 @@ public interface IFlatQueryResultService {
*/
public
DownloadTask
buildFlatQueryDownloadTask
(
String
userId
,
String
name
,
String
moduleName
,
Integer
amount
,
String
format
,
String
tableId
,
List
<
String
>
enterpriseIds
,
List
<
FlatQueryCondition
>
queryConditions
,
String
orderField
,
String
orderDir
,
Boolean
execDistinct
,
String
useCompress
,
Integer
queryDataType
,
String
applyId
);
String
useCompress
,
Integer
queryDataType
,
String
applyId
,
List
<
String
>
authStoreIdList
);
/** 获取自助指标字段过滤条件数据
* @param tableId
...
...
gic-cloud-data-hook-api/src/main/java/com/gic/cloud/data/hook/api/service/IFlatQueryTableService.java
View file @
fbf34941
...
...
@@ -5,6 +5,8 @@ import com.gic.cloud.data.hook.api.dto.FlatQueryFavo;
import
com.gic.cloud.data.hook.api.dto.FlatQueryTable
;
import
com.gic.cloud.data.hook.api.dto.FlatQueryTableDetail
;
import
java.util.List
;
/** 自助查询表对象服务
* @author Sam.Z
*/
...
...
@@ -24,7 +26,7 @@ public interface IFlatQueryTableService {
* @param pageSize 分页数据数量
* @return
*/
public
Page
<
FlatQueryTable
>
queryFlatQueryTablePage
(
String
userId
,
String
fuzzy
,
int
pageNum
,
int
pageSize
);
public
Page
<
FlatQueryTable
>
queryFlatQueryTablePage
(
String
userId
,
String
fuzzy
,
int
pageNum
,
int
pageSize
,
List
<
String
>
authTables
);
/** 获取指定自助查询表的详细信息
* @param userId 指定的用户主键
...
...
gic-cloud-data-hook-api/src/main/java/com/gic/cloud/data/hook/api/service/IFreeQueryService.java
View file @
fbf34941
package
com
.
gic
.
cloud
.
data
.
hook
.
api
.
service
;
import
com.gic.cloud.data.hook.api.dto.DownloadTask
;
import
com.gic.cloud.data.hook.api.dto.FreeQueryRecord
;
import
com.gic.cloud.data.hook.api.dto.FreeQueryResult
;
import
com.gic.cloud.data.hook.api.dto.FreeQueryTable
;
import
com.gic.cloud.data.hook.api.dto.*
;
import
java.util.List
;
...
...
@@ -79,4 +76,5 @@ public interface IFreeQueryService {
public
List
<
String
>
getColumnsByTable
(
String
tableName
);
FreeQuerySource
getFreeQuerySource
(
String
enterpriseId
);
}
gic-cloud-data-hook-service/pom.xml
View file @
fbf34941
...
...
@@ -43,7 +43,7 @@
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-cloud-data-hook-api
</artifactId>
<version>
${
dataHookVersion
}
</version>
<version>
${
gic-cloud-data-hook-api
}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/HiveHelper.java
View file @
fbf34941
...
...
@@ -24,10 +24,13 @@ public class HiveHelper implements ApplicationContextAware {
/** 内置数据源 */
private
static
DataSource
source
=
null
;
private
static
DataSource
downloadSource
=
null
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
log
.
debug
(
"setApplicationContext"
,
"准备初始化 Hive 连接池"
);
source
=
(
DataSource
)
applicationContext
.
getBean
(
"hiveSource"
);
downloadSource
=
(
DataSource
)
applicationContext
.
getBean
(
"downloadHiveSource"
);
}
/** 获取 Hive 数据源
...
...
@@ -62,5 +65,26 @@ public class HiveHelper implements ApplicationContextAware {
}
// TRY CATCH OVER
}
public
static
Connection
getDownloadHiveConnection
()
{
Connection
conn
=
null
;
try
{
// String url = "jdbc:hive2://115.159.205.44:10015/data_test";
// //String url = "jdbc:hive2://10.0.0.3:10015/data_test";
// Class.forName("org.apache.hive.jdbc.HiveDriver");
// conn = DriverManager.getConnection(url, "hadoop", "");
conn
=
downloadSource
.
getConnection
();
return
conn
;
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
if
(
conn
!=
null
)
{
try
{
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
// TRY CATCH OVER
}
}
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/MysqlHelper.java
View file @
fbf34941
...
...
@@ -46,7 +46,7 @@ public class MysqlHelper implements ApplicationContextAware {
}
/** MysqlHelper 单例 */
p
rivate
static
MysqlHelper
instance
=
null
;
p
ublic
static
MysqlHelper
instance
=
null
;
/** 构造函数 */
public
MysqlHelper
()
{
...
...
@@ -77,6 +77,9 @@ public class MysqlHelper implements ApplicationContextAware {
source
.
setUrl
(
url
);
source
.
setUsername
(
result
.
getString
(
"usr"
));
source
.
setPassword
(
result
.
getString
(
"password"
));
source
.
setDatabase
(
result
.
getString
(
"database"
));
source
.
setDbExpiration
(
result
.
getDate
(
"db_expiration"
));
source
.
setIsPrivate
(
result
.
getInt
(
"isprivate"
));
conn
.
close
();
return
source
;
}
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/dao/FlatQueryTableDao.java
View file @
fbf34941
...
...
@@ -24,7 +24,7 @@ public interface FlatQueryTableDao {
* @param fuzzy 模糊查询条件
* @return 自助查询表信息列表
*/
List
<
FlatQueryTable
>
getFlatQueryTable
(
@Param
(
"userId"
)
String
userId
,
@Param
(
"fuzzy"
)
String
fuzzy
);
List
<
FlatQueryTable
>
getFlatQueryTable
(
@Param
(
"userId"
)
String
userId
,
@Param
(
"fuzzy"
)
String
fuzzy
,
@Param
(
"authTables"
)
List
<
String
>
authTables
);
/** 更新自助查询表信息
* @param table
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FlatQueryResultServiceImpl.java
View file @
fbf34941
package
com
.
gic
.
cloud
.
data
.
hook
.
service
.
impl
;
import
cn.medubi.client.utils.LogPak
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.cloud.common.api.base.Page
;
import
com.gic.cloud.data.hook.api.dto.*
;
import
com.gic.cloud.data.hook.api.entity.*
;
...
...
@@ -17,6 +18,7 @@ import com.google.common.collect.Lists;
import
com.opencsv.CSVWriter
;
import
com.opencsv.ResultSetHelper
;
import
io.netty.handler.codec.http.HttpUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
...
...
@@ -76,7 +78,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
* @return
*/
public
String
buildFlatQuerySQL
(
Boolean
queryOrDownload
,
String
tableId
,
List
<
String
>
enterpriseIds
,
List
<
FlatQueryCondition
>
queryConditions
,
String
orderField
,
String
orderDir
,
Boolean
execDistinct
,
Integer
limitRange
)
{
Boolean
execDistinct
,
Integer
limitRange
,
List
<
String
>
authStoreIdList
)
{
log
.
debug
(
"buildFlatQuerySQL"
,
"自助指标查询来自 "
+
enterpriseIds
.
get
(
0
));
// 查询处理开始
String
queryDistinct
=
execDistinct
?
" DISTINCT "
:
""
;
...
...
@@ -152,6 +154,19 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
// IF OVER
}
// FOR OVER
//管辖门店权限控制
log
.
debug
(
"buildAuthQuery"
,
JSON
.
toJSONString
(
authStoreIdList
));
if
(
CollectionUtils
.
isNotEmpty
(
authStoreIdList
)){
FlatQueryTable
table
=
this
.
flatQueryTableDao
.
getFlatQueryTableById
(
null
,
tableId
);
if
(
table
!=
null
){
queryFilters
+=
" AND "
+
table
.
getAuthStoreId
()
+
" in("
;
for
(
int
i
=
0
;
i
<
authStoreIdList
.
size
();
i
++){
queryFilters
+=
i
==
0
?
"'"
+
authStoreIdList
.
get
(
i
)
+
"'"
:
",'"
+
authStoreIdList
.
get
(
i
)
+
"'"
;
}
queryFilters
+=
")"
;
}
}
log
.
debug
(
"buildAuthQueryResult"
,
queryFilters
);
// 最终处理 queryFilters、LIMIT、DISTINCT
if
(!
StringUtils
.
isNotBlank
(
queryFilters
))
queryFilters
=
" AND "
+
queryFilters
;
// if (!queryFilters.equals("")) queryFilters = " WHERE " + queryFilters;
String
queryLimit
=
limitRange
>
0
?
" limit "
+
limitRange
:
""
;
...
...
@@ -163,7 +178,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
@Override
public
FlatQueryResult
getFlatQueryResult
(
String
tableId
,
List
<
String
>
enterpriseIds
,
List
<
FlatQueryCondition
>
queryConditions
,
String
orderField
,
String
orderDir
,
Boolean
execDistinct
,
Integer
queryDataType
,
Integer
limitRange
,
int
dataPermission
)
{
Boolean
execDistinct
,
Integer
queryDataType
,
Integer
limitRange
,
int
dataPermission
,
List
<
String
>
authStoreIdList
)
{
log
.
debug
(
"getFlatQueryResult"
,
"自助指标查询来自 "
+
enterpriseIds
.
get
(
0
));
// 定义返回值
FlatQueryResult
result
=
new
FlatQueryResult
();
...
...
@@ -176,7 +191,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
orderField
,
orderDir
,
execDistinct
,
limitRange
);
limitRange
,
authStoreIdList
);
// 进行查询
Connection
conn
=
HiveHelper
.
getHiveConnection
();
if
(
conn
!=
null
)
{
...
...
@@ -329,7 +345,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
*/
public
Integer
estimateFlatQueryDownloadTask
(
String
tableId
,
List
<
String
>
enterpriseIds
,
List
<
FlatQueryCondition
>
queryConditions
,
String
orderField
,
String
orderDir
,
Boolean
execDistinct
)
{
String
orderDir
,
Boolean
execDistinct
,
List
<
String
>
authStoreIdList
)
{
Integer
result
=
-
1
;
// 生成正式查询
String
preQuery
=
this
.
buildFlatQuerySQL
(
...
...
@@ -340,7 +356,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
orderField
,
orderDir
,
execDistinct
,
0
);
0
,
authStoreIdList
);
String
finQuery
=
"SELECT COUNT(1) FROM ("
+
preQuery
+
") AS tmpTable"
;
Connection
conn
=
HiveHelper
.
getHiveConnection
();
if
(
conn
!=
null
)
{
...
...
@@ -384,7 +401,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
* @return
*/
public
DownloadTask
buildFlatQueryDownloadTask
(
String
userId
,
String
name
,
String
moduleName
,
Integer
amount
,
String
format
,
String
tableId
,
List
<
String
>
enterpriseIds
,
List
<
FlatQueryCondition
>
queryConditions
,
String
orderField
,
String
orderDir
,
Boolean
execDistinct
,
String
useCompress
,
Integer
queryDataType
,
String
applyId
)
{
String
useCompress
,
Integer
queryDataType
,
String
applyId
,
List
<
String
>
authStoreIdList
)
{
log
.
debug
(
"buildFlatQueryDownloadTask"
,
"自助指标下载请求来自 "
+
enterpriseIds
.
get
(
0
));
// 增加下载量
FlatQueryTable
table
=
this
.
flatQueryTableDao
.
getFlatQueryTableById
(
userId
,
tableId
);
...
...
@@ -436,7 +453,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
if
(
curTask
.
getApplyPermitted
().
equals
(
Global
.
YES
))
{
condition
.
setBuildPermitted
(
Global
.
YES
);
}
else
condition
.
setBuildPermitted
(
Global
.
NO
);
//设置管辖门店权限
condition
.
setAuthStoreIdList
(
authStoreIdList
);
// 保存至列表
this
.
taskConditions
.
add
(
condition
);
return
curTask
;
...
...
@@ -481,9 +499,11 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
condition
.
getConditions
(),
condition
.
getOrderField
(),
condition
.
getOrderDir
(),
condition
.
getExecDistinct
(),
0
);
condition
.
getExecDistinct
(),
0
,
condition
.
getAuthStoreIdList
());
Connection
conn
=
HiveHelper
.
getHiveConnection
();
Connection
conn
=
HiveHelper
.
get
Download
HiveConnection
();
if
(
conn
!=
null
)
{
try
{
Statement
stat
=
conn
.
createStatement
();
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FlatQueryTableServiceImpl.java
View file @
fbf34941
...
...
@@ -46,10 +46,10 @@ public class FlatQueryTableServiceImpl implements IFlatQueryTableService {
}
@Override
public
Page
<
FlatQueryTable
>
queryFlatQueryTablePage
(
String
userId
,
String
fuzzy
,
int
pageNum
,
int
pageSize
)
{
public
Page
<
FlatQueryTable
>
queryFlatQueryTablePage
(
String
userId
,
String
fuzzy
,
int
pageNum
,
int
pageSize
,
List
<
String
>
authTables
)
{
Page
<
FlatQueryTable
>
result
=
new
Page
<>();
PageHelper
.
startPage
(
pageNum
,
pageSize
);
// 设置分页参数
List
<
FlatQueryTable
>
query
=
flatQueryTableDao
.
getFlatQueryTable
(
userId
,
fuzzy
);
List
<
FlatQueryTable
>
query
=
flatQueryTableDao
.
getFlatQueryTable
(
userId
,
fuzzy
,
authTables
);
// 生成数据输出信息
PageInfo
<
FlatQueryTable
>
preResult
=
new
PageInfo
<>(
query
);
result
.
setList
(
preResult
.
getList
());
// 设置数据集
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FreeQueryServiceImpl.java
View file @
fbf34941
...
...
@@ -46,7 +46,7 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
public
static
final
String
SAVE_FOLDER
=
"/usr/local/data-hook-file"
;
/** 脱敏字段 */
public
static
final
List
<
String
>
FILTERS_PHONE_ONLY
=
Arrays
.
asList
(
"mobile"
,
"phone"
,
"enterprise_name"
,
"phone_number"
,
"receive_phone_number"
,
"use_phone_number"
,
"use_card_num"
);
public
static
final
List
<
String
>
FILTERS_PHONE_ONLY
=
Arrays
.
asList
(
"mobile"
,
"phone"
,
"enterprise_name"
,
"phone_number"
,
"receive_phone_number"
,
"use_phone_number"
);
/** 脱敏字段 */
public
static
final
List
<
String
>
FILTERS_PHONE_AND_CARD
=
Arrays
.
asList
(
"card_num"
,
"mobile"
,
"phone"
,
"enterprise_name"
,
"phone_number"
,
"receive_phone_number"
,
"receive_card_num"
,
"use_phone_number"
,
"use_card_num"
);
...
...
@@ -161,6 +161,11 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
}
@Override
public
FreeQuerySource
getFreeQuerySource
(
String
enterpriseId
)
{
return
MysqlHelper
.
instance
.
getFreeQuerySource
(
enterpriseId
);
}
@Override
public
Integer
getFreeQueryCount
(
String
sql
,
String
enterpriseId
)
{
//sql = prefixSQL(enterpriseId, sql);
Integer
result
=
-
1
;
...
...
gic-cloud-data-hook-service/src/main/resources/data-hook-flat-query-source.xml
View file @
fbf34941
...
...
@@ -35,4 +35,27 @@
</property>
</bean>
<bean
class=
"org.apache.commons.dbcp.BasicDataSource"
id=
"downloadHiveSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"org.apache.hive.jdbc.HiveDriver"
/>
<!--<property name="url" value="jdbc:hive2://115.159.205.44:10015/data_test" />-->
<property
name=
"url"
value=
"${hive.download.url}"
/>
<property
name=
"username"
value=
"${hive.username}"
/>
<property
name=
"password"
value=
""
/>
<property
name=
"maxActive"
>
<value>
20
</value>
</property>
<property
name=
"maxIdle"
>
<value>
5
</value>
</property>
<property
name=
"minIdle"
>
<value>
1
</value>
</property>
<property
name=
"testWhileIdle"
>
<value>
true
</value>
</property>
<property
name=
"maxWait"
>
<value>
120000
</value>
</property>
</bean>
</beans>
\ No newline at end of file
gic-cloud-data-hook-service/src/main/resources/mapper/DownloadRecordDao.xml
View file @
fbf34941
...
...
@@ -39,8 +39,10 @@
FROM
<include
refid=
"queryTables"
/>
<include
refid=
"queryJoins"
/>
WHERE
q.user_id = #{userId}
WHERE 1=1
<if
test=
"userId != null and userId !=''"
>
and q.user_id = #{userId}
</if>
<if
test=
"startTime != null"
>
AND q.download_time
<![CDATA[ >= ]]>
#{startTime}
</if>
...
...
@@ -50,7 +52,7 @@
<if
test=
"queryDataType != -1"
>
AND t.query_data_type = #{queryDataType}
</if>
<if
test=
"fuzzyRange != ''"
>
<if
test=
"fuzzyRange != ''
and fuzzy !=''
"
>
<bind
name=
"pattern"
value=
"'%' + fuzzy + '%'"
/>
<choose>
<when
test=
"fuzzyRange == 'reportId'"
>
...
...
gic-cloud-data-hook-service/src/main/resources/mapper/FlatQueryTableDao.xml
View file @
fbf34941
...
...
@@ -18,7 +18,9 @@
q.description,
q.click_count,
q.download_count,
f.is_favo
f.is_favo,
q.auth_store_id,
q.auth_desc
</sql>
<sql
id=
"queryJoins"
>
...
...
@@ -58,6 +60,13 @@
OR q.name LIKE #{pattern}
OR q.description LIKE #{pattern}
</if>
<if
test=
"authTables != null and authTables.size()>0"
>
where q.table_id in
<foreach
close=
")"
collection=
"authTables"
index=
"index"
item=
"item"
open=
"("
separator=
","
>
#{item}
</foreach>
</if>
ORDER BY
f.is_favo DESC,
CONVERT(q.name USING gbk)
...
...
gic-cloud-data-hook/pom.xml
View file @
fbf34941
...
...
@@ -36,7 +36,7 @@
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-cloud-data-hook-api
</artifactId>
<version>
${
dataHookVersion
}
</version>
<version>
${
gic-cloud-data-hook-api
}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
...
...
gic-cloud-data-hook/src/main/java/com/gic/cloud/data/hook/web/AlarmController.java
0 → 100644
View file @
fbf34941
package
com
.
gic
.
cloud
.
data
.
hook
.
web
;
import
com.gic.clerk.api.constant.ThirdProjectEnum
;
import
com.gic.clerk.api.dto.right.RightMenuDTO
;
import
com.gic.clerk.api.service.RightService
;
import
com.gic.cloud.data.hook.api.dto.FreeQuerySource
;
import
com.gic.cloud.data.hook.api.service.IFreeQueryService
;
import
com.gic.enterprise.api.dto.EnterpriseDTO
;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.web.common.utils.SessionContextUtils
;
import
com.lmax.disruptor.util.DaemonThreadFactory
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
@Controller
public
class
AlarmController
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
AlarmController
.
class
);
@Autowired
private
EnterpriseService
enterpriseService
;
@Autowired
private
IFreeQueryService
freeQueryService
;
@Autowired
private
RightService
rightService
;
@RequestMapping
(
"service-alarm"
)
public
Map
<
String
,
Object
>
serviceAlarm
(){
EnterpriseDTO
enterprise
=
this
.
enterpriseService
.
getEnterpriseById
(
SessionContextUtils
.
getLoginUserEnterpriseId
());
Integer
alarmWay
=
enterprise
.
getAlarmWay
();
Date
expireTime
=
enterprise
.
getDatahookEndDate
();
return
this
.
getAlarmResult
(
expireTime
,
alarmWay
);
}
@RequestMapping
(
"custom-alarm"
)
public
Map
<
String
,
Object
>
customAlarm
(){
EnterpriseDTO
enterprise
=
this
.
enterpriseService
.
getEnterpriseById
(
SessionContextUtils
.
getLoginUserEnterpriseId
());
Integer
alarmWay
=
enterprise
.
getAlarmWay
();
FreeQuerySource
freeQuerySource
=
this
.
freeQueryService
.
getFreeQuerySource
(
SessionContextUtils
.
getLoginUserEnterpriseId
());
Date
expireTime
=
freeQuerySource
.
getDbExpiration
();
Map
<
String
,
Object
>
alarmResult
=
this
.
getAlarmResult
(
expireTime
,
alarmWay
);
alarmResult
.
put
(
"isPrivate"
,
freeQuerySource
.
getIsPrivate
());
alarmResult
.
put
(
"customSearch"
,
0
);
List
<
RightMenuDTO
>
list
=
this
.
rightService
.
listSuperAdminAllGicWebMenu
(
SessionContextUtils
.
getLoginUserEnterpriseId
(),
ThirdProjectEnum
.
DATA_HOOK
.
getCode
());
if
(
org
.
apache
.
commons
.
collections
.
CollectionUtils
.
isNotEmpty
(
list
)){
for
(
RightMenuDTO
menuDTO
:
list
){
if
(
"custom_search"
.
equals
(
menuDTO
.
getMenuCode
())
&&
SessionContextUtils
.
getLoginUser
().
getSuperAdmin
()
==
1
){
alarmResult
.
put
(
"customSearch"
,
1
);
}
}
}
return
alarmResult
;
}
private
Map
<
String
,
Object
>
getAlarmResult
(
Date
expireTime
,
Integer
alarmWay
){
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
if
(
expireTime
!=
null
){
if
(
expireTime
.
before
(
new
Date
())){
result
.
put
(
"type"
,
2
);
result
.
put
(
"remain"
,
0
);
}
else
{
Date
alarmTime
=
null
;
Calendar
calendar
=
Calendar
.
getInstance
();
if
(
alarmWay
==
1
){
calendar
.
setTime
(
expireTime
);
calendar
.
add
(
Calendar
.
MONTH
,
-
2
);
}
else
if
(
alarmWay
==
2
){
calendar
.
setTime
(
expireTime
);
calendar
.
add
(
Calendar
.
MONTH
,
-
1
);
}
else
{
calendar
.
setTime
(
expireTime
);
calendar
.
add
(
Calendar
.
DATE
,
-
7
);
}
alarmTime
=
calendar
.
getTime
();
if
(
alarmTime
.
before
(
new
Date
())){
result
.
put
(
"type"
,
1
);
result
.
put
(
"remain"
,
getDays
(
expireTime
));
}
else
{
result
.
put
(
"type"
,
0
);
result
.
put
(
"remain"
,
0
);
}
}
}
else
{
result
.
put
(
"type"
,
0
);
result
.
put
(
"remain"
,
0
);
}
return
result
;
}
private
long
getDays
(
Date
expireTime
){
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
try
{
Date
date
=
dateFormat
.
parse
(
dateFormat
.
format
(
expireTime
));
Date
now
=
dateFormat
.
parse
(
dateFormat
.
format
(
new
Date
()));
long
l
=
(
date
.
getTime
()
-
now
.
getTime
())
/
3600
/
24
/
1000
;
return
l
;
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
0
;
}
}
gic-cloud-data-hook/src/main/java/com/gic/cloud/data/hook/web/DownloadTaskController.java
View file @
fbf34941
...
...
@@ -6,6 +6,7 @@ import com.gic.cloud.data.hook.api.dto.DownloadTask;
import
com.gic.cloud.data.hook.api.dto.RiskModeRecord
;
import
com.gic.cloud.data.hook.api.entity.GeneralResult
;
import
com.gic.cloud.data.hook.api.service.IDownloadTaskService
;
import
com.gic.web.common.utils.SessionContextUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -89,8 +90,9 @@ public class DownloadTaskController {
String
finEndTimeText
=
StringUtils
.
isNoneBlank
(
endTimeText
)
?
endTimeText
+
" 23:59:59"
:
""
;
Date
startTime
=
finStartTimeText
.
equals
(
""
)
?
null
:
datetimeFormatter
.
parse
(
finStartTimeText
);
Date
endTime
=
finEndTimeText
.
equals
(
""
)
?
null
:
datetimeFormatter
.
parse
(
finEndTimeText
);
System
.
out
.
println
(
startTime
);
System
.
out
.
println
(
endTime
);
if
(
SessionContextUtils
.
getLoginUser
().
getSuperAdmin
()
==
1
){
userId
=
null
;
}
return
this
.
downloadTaskService
.
getDownloadRecordPage
(
userId
,
enterpriseId
,
startTime
,
endTime
,
queryDataType
,
fuzzyRange
,
fuzzy
,
pageNum
,
pageSize
);
}
...
...
@@ -112,8 +114,6 @@ public class DownloadTaskController {
String
finEndTimeText
=
StringUtils
.
isNoneBlank
(
endTimeText
)
?
endTimeText
+
" 23:59:59"
:
""
;
Date
startTime
=
finStartTimeText
.
equals
(
""
)
?
null
:
datetimeFormatter
.
parse
(
finStartTimeText
);
Date
endTime
=
finEndTimeText
.
equals
(
""
)
?
null
:
datetimeFormatter
.
parse
(
finEndTimeText
);
// Date startTime = startTimeText.equals("") ? null : datetimeFormatter.parse(startTimeText);
// Date endTime = endTimeText.equals("") ? null : datetimeFormatter.parse(endTimeText);
return
this
.
downloadTaskService
.
getRiskModeRecordPage
(
enterpriseId
,
startTime
,
endTime
,
riskDuration
,
fuzzyRange
,
fuzzy
,
pageNum
,
pageSize
);
}
...
...
gic-cloud-data-hook/src/main/java/com/gic/cloud/data/hook/web/FlatQueryController.java
View file @
fbf34941
package
com
.
gic
.
cloud
.
data
.
hook
.
web
;
import
com.gic.clerk.api.constant.ThirdProjectEnum
;
import
com.gic.clerk.api.dto.AuthorizedUser
;
import
com.gic.clerk.api.dto.PowerClerkDTO
;
import
com.gic.clerk.api.dto.right.RightMenuDTO
;
import
com.gic.clerk.api.service.PowerService
;
import
com.gic.clerk.api.service.RightService
;
import
com.gic.cloud.common.api.base.Page
;
import
com.gic.cloud.data.hook.api.dto.*
;
import
com.gic.cloud.data.hook.api.entity.FlatQueryCondition
;
...
...
@@ -9,8 +15,11 @@ import com.gic.cloud.data.hook.api.entity.Global;
import
com.gic.cloud.data.hook.api.service.IFlatQueryResultService
;
import
com.gic.cloud.data.hook.api.service.IFlatQueryTableService
;
import
com.gic.cloud.data.hook.api.service.IMyFlatQueryService
;
import
com.gic.enterprise.api.constant.StoreWidget
;
import
com.gic.enterprise.api.dto.EnterpriseSettingDTO
;
import
com.gic.enterprise.api.dto.StoreWidgetDTO
;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.enterprise.api.service.StoreWidgetService
;
import
com.gic.web.common.utils.SessionContextUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -47,6 +56,12 @@ public class FlatQueryController {
private
IMyFlatQueryService
myFlatQueryService
;
@Autowired
private
EnterpriseService
enterpriseService
;
@Autowired
private
StoreWidgetService
storeWidgetService
;
@Autowired
private
PowerService
powerService
;
@Autowired
private
RightService
rightService
;
/** 查询表定义及下载量等信息
...
...
@@ -57,7 +72,22 @@ public class FlatQueryController {
*/
@RequestMapping
(
"/flat-query-table-page"
)
public
Page
<
FlatQueryTable
>
flatQueryTablePage
(
String
userId
,
String
fuzzy
,
Integer
pageNum
,
Integer
pageSize
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
return
this
.
flatQueryTableService
.
queryFlatQueryTablePage
(
userId
,
fuzzy
,
pageNum
,
pageSize
);
// 限定 10 个/分页
List
<
RightMenuDTO
>
list
=
this
.
rightService
.
listSuperAdminAllGicWebMenu
(
SessionContextUtils
.
getLoginUserEnterpriseId
(),
ThirdProjectEnum
.
DATA_HOOK
.
getCode
());
List
<
String
>
tables
=
new
ArrayList
<>();
if
(
org
.
apache
.
commons
.
collections
.
CollectionUtils
.
isNotEmpty
(
list
)){
for
(
RightMenuDTO
menuDTO
:
list
){
if
(
SessionContextUtils
.
getLoginUser
().
getSuperAdmin
()
!=
1
){
if
(
"extract_integral_cost_bill_m"
.
equals
(
menuDTO
.
getMenuCode
())){
continue
;
}
}
tables
.
add
(
menuDTO
.
getMenuCode
());
}
}
if
(
CollectionUtils
.
isEmpty
(
tables
)){
tables
.
add
(
"-1"
);
}
return
this
.
flatQueryTableService
.
queryFlatQueryTablePage
(
userId
,
fuzzy
,
pageNum
,
pageSize
,
tables
);
// 限定 10 个/分页
}
/** 切换自助查询表的收藏状态
...
...
@@ -124,7 +154,8 @@ public class FlatQueryController {
executeRequest
.
getExecDistinct
(),
executeRequest
.
getQueryDataType
(),
1000
,
dataPermission
);
// 强制 1000 限制
dataPermission
,
this
.
getAuthStoreId
());
// 强制 1000 限制
}
/** 获取自助查询下载量评估
...
...
@@ -142,7 +173,8 @@ public class FlatQueryController {
executeRequest
.
getQueryConditions
(),
executeRequest
.
getOrderField
(),
executeRequest
.
getOrderDir
(),
executeRequest
.
getExecDistinct
()
executeRequest
.
getExecDistinct
(),
this
.
getAuthStoreId
()
);
result
.
setInfo
(
String
.
valueOf
(
amount
));
return
result
;
...
...
@@ -184,7 +216,8 @@ public class FlatQueryController {
executeRequest
.
getExecDistinct
(),
executeRequest
.
getUseCompress
()
?
Global
.
YES
:
Global
.
NO
,
executeRequest
.
getQueryDataType
(),
executeRequest
.
getApplyId
()
executeRequest
.
getApplyId
(),
this
.
getAuthStoreId
()
);
}
...
...
@@ -259,6 +292,25 @@ public class FlatQueryController {
}
private
List
<
String
>
getAuthStoreId
(){
List
<
String
>
list
=
new
ArrayList
<>();
AuthorizedUser
user
=
SessionContextUtils
.
getLoginUser
();
if
(
user
.
getSuperAdmin
()
!=
1
){
EnterpriseSettingDTO
setting
=
this
.
enterpriseService
.
getEnterpriseSettingByEnterpriseId
(
user
.
getEnterpriseId
());
if
(
setting
.
getEnableAccessControl
()
!=
null
&&
setting
.
getEnableAccessControl
()
==
1
)
{
PowerClerkDTO
clerkDetail
=
this
.
powerService
.
getClerkDetail
(
user
.
getUserId
());
StoreWidgetDTO
widgetDTO
=
this
.
storeWidgetService
.
getStoreWidgetBykey
(
clerkDetail
.
getStoreWidgetId
());
if
(
StoreWidget
.
ALL
!=
widgetDTO
.
getSelectType
()){
List
<
String
>
authStoreList
=
this
.
storeWidgetService
.
getStoreWidgetStore
(
clerkDetail
.
getStoreWidgetId
(),
user
.
getEnterpriseId
(),
null
,
null
,
null
);
list
.
addAll
(
authStoreList
);
if
(
CollectionUtils
.
isEmpty
(
list
)){
list
.
add
(
"1"
);
}
}
}
}
return
list
;
}
...
...
gic-cloud-data-hook/src/main/java/com/gic/cloud/data/hook/web/FreeQueryController.java
View file @
fbf34941
package
com
.
gic
.
cloud
.
data
.
hook
.
web
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.cloud.common.api.base.Page
;
import
com.gic.cloud.data.hook.api.dto.*
;
import
com.gic.cloud.data.hook.api.entity.FlatQueryExecuteRequest
;
import
com.gic.cloud.data.hook.api.entity.GeneralResult
;
import
com.gic.cloud.data.hook.api.service.IFlatQueryResultService
;
import
com.gic.cloud.data.hook.api.service.IFreeQueryService
;
import
com.gic.enterprise.api.dto.EnterpriseDTO
;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.web.common.utils.SessionContextUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -119,7 +121,14 @@ public class FreeQueryController {
@RequestMapping
(
"/get-free-query-count"
)
public
GeneralResult
getFreeQueryCount
(
String
sql
,
String
enterpriseId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
GeneralResult
result
=
new
GeneralResult
();
result
.
setInfo
(
String
.
valueOf
(
this
.
freeQueryService
.
getFreeQueryCount
(
sql
,
enterpriseId
)));
FreeQuerySource
freeQuerySource
=
this
.
freeQueryService
.
getFreeQuerySource
(
SessionContextUtils
.
getLoginUserEnterpriseId
());
Date
expireTime
=
freeQuerySource
.
getDbExpiration
();
Integer
isPrivate
=
freeQuerySource
.
getIsPrivate
();
if
(
isPrivate
!=
null
&&
isPrivate
==
1
&&
expireTime
!=
null
&&
expireTime
.
before
(
new
Date
())){
result
.
setInfo
(
"0"
);
}
else
{
result
.
setInfo
(
String
.
valueOf
(
this
.
freeQueryService
.
getFreeQueryCount
(
sql
,
enterpriseId
)));
}
return
result
;
}
...
...
@@ -164,5 +173,12 @@ public class FreeQueryController {
}
@RequestMapping
(
"/get-custom-database"
)
public
FreeQuerySource
getCustomDatabase
(){
FreeQuerySource
freeQuerySource
=
this
.
freeQueryService
.
getFreeQuerySource
(
SessionContextUtils
.
getLoginUserEnterpriseId
());
System
.
out
.
println
(
JSON
.
toJSONString
(
freeQuerySource
));
return
freeQuerySource
;
}
}
gic-cloud-data-hook/src/main/webapp/WEB-INF/data-hook-dubbo-config.xml
View file @
fbf34941
...
...
@@ -25,7 +25,8 @@
<dubbo:reference
interface=
"com.gic.clerk.api.service.ClerkService"
id=
"clerkService"
timeout=
"6000"
retries=
"0"
/>
<dubbo:reference
interface=
"com.gic.clerk.api.service.UserService"
id=
"userService"
timeout=
"6000"
retries=
"0"
/>
<dubbo:reference
interface=
"com.gic.clerk.api.service.PowerService"
id=
"powerService"
timeout=
"6000"
retries=
"0"
/>
<dubbo:reference
interface=
"com.gic.enterprise.api.service.StoreWidgetService"
id=
"storeWidgetService"
timeout=
"6000"
retries=
"0"
/>
<dubbo:reference
interface=
"com.gic.clerk.api.service.RightService"
id=
"rightService"
timeout=
"6000"
retries=
"0"
/>
<!--<dubbo:reference interface="com.gic.enterprise.api.service.EnterPerformanceService" id="enterPerformanceService" timeout="10000" retries="0" />
<dubbo:reference interface="com.gic.cloud.communicate.api.service.performance.CloudPerformanceService" id="cloudPerformanceService" timeout="10000" retries="0" />
<dubbo:reference interface="com.gic.cloud.communicate.api.service.store.AreaService" id="areaService" timeout="10000" retries="0" />-->
...
...
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