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
8009d2d7
Commit
8009d2d7
authored
Apr 27, 2021
by
陶光胜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'developer' into 'master'
Developer See merge request
!15
parents
b01106da
4c39c7d8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
29 deletions
+70
-29
DownloadTaskServiceImpl.java
...cloud/data/hook/service/impl/DownloadTaskServiceImpl.java
+10
-4
FlatQueryResultServiceImpl.java
...ud/data/hook/service/impl/FlatQueryResultServiceImpl.java
+38
-16
FreeQueryServiceImpl.java
...ic/cloud/data/hook/service/impl/FreeQueryServiceImpl.java
+22
-9
No files found.
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/DownloadTaskServiceImpl.java
View file @
8009d2d7
...
@@ -16,6 +16,7 @@ import com.github.pagehelper.PageHelper;
...
@@ -16,6 +16,7 @@ import com.github.pagehelper.PageHelper;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.opencsv.CSVWriter
;
import
com.opencsv.CSVWriter
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.concurrent.BasicThreadFactory
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -28,6 +29,9 @@ import java.sql.ResultSet;
...
@@ -28,6 +29,9 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
...
@@ -143,11 +147,13 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService {
...
@@ -143,11 +147,13 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService {
}
}
/** 下载任务执行计时器 */
/** 下载任务执行计时器 */
private
Timer
downloadTaskTimer
=
new
Timer
();
//private Timer downloadTaskTimer = new Timer();
ScheduledExecutorService
deleteExpireTaskService
=
new
ScheduledThreadPoolExecutor
(
1
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"deleteExpireTask-%d"
).
daemon
(
true
).
build
());
/** 启动自动清理下载任务服务 */
/** 启动自动清理下载任务服务 */
private
void
runDownloadCleanTask
(
Integer
interval
)
{
private
void
runDownloadCleanTask
(
Integer
interval
)
{
this
.
downloadTaskTimer
.
schedule
(
new
TimerTask
()
{
deleteExpireTaskService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Calendar
calc
=
Calendar
.
getInstance
();
Calendar
calc
=
Calendar
.
getInstance
();
...
@@ -160,8 +166,8 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService {
...
@@ -160,8 +166,8 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService {
deleteDownloadTask
(
task
.
getId
());
deleteDownloadTask
(
task
.
getId
());
}
// 遍历删除
}
// 遍历删除
}
// IF OVER
}
// IF OVER
}
// run Define Over
}
},
interval
*
1000
,
interval
*
1000
);
// 配置中的值为毫秒
},
interval
*
1000
,
interval
*
1000
,
TimeUnit
.
MILLISECONDS
);
}
}
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FlatQueryResultServiceImpl.java
View file @
8009d2d7
...
@@ -21,6 +21,7 @@ import com.opencsv.ResultSetHelper;
...
@@ -21,6 +21,7 @@ import com.opencsv.ResultSetHelper;
import
io.netty.handler.codec.http.HttpUtil
;
import
io.netty.handler.codec.http.HttpUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.concurrent.BasicThreadFactory
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Sheet
;
...
@@ -38,6 +39,9 @@ import java.sql.*;
...
@@ -38,6 +39,9 @@ import java.sql.*;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
...
@@ -502,11 +506,13 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -502,11 +506,13 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
/** 下载任务执行计时器 */
/** 下载任务执行计时器 */
private
Timer
downloadTaskTimer
=
new
Timer
();
//private Timer downloadTaskTimer = new Timer();
ScheduledExecutorService
downloadService
=
new
ScheduledThreadPoolExecutor
(
1
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"downloadTimer-%d"
).
daemon
(
true
).
build
());
/** 启动自助指标查询计划任务 */
/** 启动自助指标查询计划任务 */
private
void
runDownloadTask
(
Integer
interval
)
{
private
void
runDownloadTask
(
Integer
interval
)
{
this
.
downloadTaskTimer
.
schedule
(
new
TimerTask
()
{
downloadService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
try
{
try
{
...
@@ -684,18 +690,19 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -684,18 +690,19 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
log
.
debug
(
"自助指标下载异常"
,
e
.
getMessage
());
log
.
debug
(
"自助指标下载异常"
,
e
.
getMessage
());
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
// run Define Over
}
},
interval
*
1000
,
interval
*
1000
);
// 配置中的值为毫秒
},
interval
*
1000
,
interval
*
1000
,
TimeUnit
.
MILLISECONDS
);
}
}
/** 下载任务执行计时器 */
/** 下载任务执行计时器 */
private
Timer
balaDownloadTaskTimer
=
new
Timer
();
//private Timer balaDownloadTaskTimer = new Timer();
ScheduledExecutorService
balaDownloadService
=
new
ScheduledThreadPoolExecutor
(
1
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"balaDownloadTimer-%d"
).
daemon
(
true
).
build
());
/** 启动自助指标查询计划任务 */
/** 启动自助指标查询计划任务 */
private
void
runBalaDownloadTask
(
Integer
interval
)
{
private
void
runBalaDownloadTask
(
Integer
interval
)
{
this
.
balaDownload
TaskTimer
.
schedule
(
new
TimerTask
()
{
this
.
balaDownload
Service
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
try
{
try
{
...
@@ -872,19 +879,19 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -872,19 +879,19 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
log
.
debug
(
"自助指标下载异常"
,
e
.
getMessage
());
log
.
debug
(
"自助指标下载异常"
,
e
.
getMessage
());
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
// run Define Over
}
},
interval
*
1000
,
interval
*
1000
);
// 配置中的值为毫秒
},
interval
*
1000
,
interval
*
1000
,
TimeUnit
.
MILLISECONDS
);
}
}
/** 下载申请检查计时器 */
/** 下载申请检查计时器 */
private
Timer
applyTimer
=
new
Timer
();
//
private Timer applyTimer = new Timer();
/** 运行下载申请任务
ScheduledExecutorService
applyService
=
new
ScheduledThreadPoolExecutor
(
1
,
* @param interval
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"applyTimer-%d"
).
daemon
(
true
).
build
());
*/
p
rivate
void
runApplyTask
(
Integer
interval
)
{
p
ublic
void
runApplyTask
(
Integer
interval
)
{
this
.
applyTimer
.
schedule
(
new
TimerTask
()
{
applyService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
List
<
DownloadTask
>
waitingTasks
=
DownloadTaskServiceImpl
.
getInstance
().
getDownloadTaskOfWaiting
(
QueryDataSource
.
FLAT_QUERY
);
List
<
DownloadTask
>
waitingTasks
=
DownloadTaskServiceImpl
.
getInstance
().
getDownloadTaskOfWaiting
(
QueryDataSource
.
FLAT_QUERY
);
...
@@ -894,6 +901,9 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -894,6 +901,9 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
// String applyStatusText = HttpUtils.doGet("http://www.gicdev.com/api-admin/apply-info?type=2&applyId=" + task.getApplyId());
// String applyStatusText = HttpUtils.doGet("http://www.gicdev.com/api-admin/apply-info?type=2&applyId=" + task.getApplyId());
String
applyStatusText
=
HttpUtils
.
doGet
(
"http://hope.demogic.com/api-admin/apply-info?type=2&applyId="
+
task
.
getApplyId
());
String
applyStatusText
=
HttpUtils
.
doGet
(
"http://hope.demogic.com/api-admin/apply-info?type=2&applyId="
+
task
.
getApplyId
());
log
.
debug
(
"runApplyTask.run"
,
"查询自助指标查询 "
+
task
.
getId
()
+
" 审核状态码"
+
applyStatusText
);
log
.
debug
(
"runApplyTask.run"
,
"查询自助指标查询 "
+
task
.
getId
()
+
" 审核状态码"
+
applyStatusText
);
if
(
StringUtils
.
isBlank
(
applyStatusText
)){
break
;
}
boolean
conditionRemove
=
false
;
// 从上传条件移除
boolean
conditionRemove
=
false
;
// 从上传条件移除
boolean
conditionUpdate
=
false
;
// 更新条件
boolean
conditionUpdate
=
false
;
// 更新条件
if
(
applyStatusText
.
indexOf
(
"\"checkStatus\":0"
)
>
0
)
{
// 如果自审核通过
if
(
applyStatusText
.
indexOf
(
"\"checkStatus\":0"
)
>
0
)
{
// 如果自审核通过
...
@@ -937,9 +947,21 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -937,9 +947,21 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
// IF ELSE OVER
}
// IF ELSE OVER
}
}
}
// FOR OVER
}
// FOR OVER
}
},
interval
*
1000
,
interval
*
1000
,
TimeUnit
.
MILLISECONDS
);
}
/* *//** 运行下载申请任务
* @param interval
*//*
private void runApplyTask(Integer interval) {
this.applyTimer.schedule(new TimerTask() {
@Override
public void run() {
} // RUN OVER
} // RUN OVER
}, interval * 1000, interval * 1000);// 配置中的值为毫秒
}, interval * 1000, interval * 1000);// 配置中的值为毫秒
}
}
*/
}
}
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FreeQueryServiceImpl.java
View file @
8009d2d7
...
@@ -19,6 +19,8 @@ import com.google.common.collect.Lists;
...
@@ -19,6 +19,8 @@ import com.google.common.collect.Lists;
import
com.opencsv.CSVWriter
;
import
com.opencsv.CSVWriter
;
import
com.opencsv.ResultSetHelper
;
import
com.opencsv.ResultSetHelper
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.concurrent.BasicThreadFactory
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Sheet
;
...
@@ -34,6 +36,9 @@ import java.sql.*;
...
@@ -34,6 +36,9 @@ import java.sql.*;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
...
@@ -351,11 +356,13 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
...
@@ -351,11 +356,13 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
private
static
SimpleDateFormat
timeFormatter
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
private
static
SimpleDateFormat
timeFormatter
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
/** 下载任务执行计时器 */
/** 下载任务执行计时器 */
private
Timer
downloadTaskTimer
=
new
Timer
();
//private Timer downloadTaskTimer = new Timer();
ScheduledExecutorService
freeDownloadService
=
new
ScheduledThreadPoolExecutor
(
1
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"freeDownloadTimer-%d"
).
daemon
(
true
).
build
());
/** 启动自助指标查询计划任务 */
/** 启动自助指标查询计划任务 */
private
void
runDownloadTask
(
Integer
interval
)
{
private
void
runDownloadTask
(
Integer
interval
)
{
this
.
downloadTaskTimer
.
schedule
(
new
TimerTask
()
{
freeDownloadService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
try
{
try
{
...
@@ -515,18 +522,21 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
...
@@ -515,18 +522,21 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
log
.
debug
(
"自定义查询下载异常"
,
e
.
getMessage
());
log
.
debug
(
"自定义查询下载异常"
,
e
.
getMessage
());
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
// run Define Over
}
},
interval
*
1000
,
interval
*
1000
);
// 配置中的值为毫秒
},
interval
*
1000
,
interval
*
1000
,
TimeUnit
.
MILLISECONDS
);
}
}
/** 下载申请检查计时器 */
/** 下载申请检查计时器 */
private
Timer
applyTimer
=
new
Timer
();
//private Timer applyTimer = new Timer();
ScheduledExecutorService
freeApplyService
=
new
ScheduledThreadPoolExecutor
(
1
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"freeApplyTimer-%d"
).
daemon
(
true
).
build
());
/** 运行下载申请任务
/** 运行下载申请任务
* @param interval
* @param interval
*/
*/
private
void
runApplyTask
(
Integer
interval
)
{
private
void
runApplyTask
(
Integer
interval
)
{
this
.
applyTimer
.
schedule
(
new
TimerTask
()
{
this
.
freeApplyService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
List
<
DownloadTask
>
waitingTasks
=
DownloadTaskServiceImpl
.
getInstance
().
getDownloadTaskOfWaiting
(
QueryDataSource
.
FREE_QUERY
);
List
<
DownloadTask
>
waitingTasks
=
DownloadTaskServiceImpl
.
getInstance
().
getDownloadTaskOfWaiting
(
QueryDataSource
.
FREE_QUERY
);
...
@@ -536,6 +546,9 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
...
@@ -536,6 +546,9 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
// String applyStatusText = HttpUtils.doGet("http://www.gicdev.com/api-admin/apply-info?type=2&applyId=" + task.getApplyId());
// String applyStatusText = HttpUtils.doGet("http://www.gicdev.com/api-admin/apply-info?type=2&applyId=" + task.getApplyId());
String
applyStatusText
=
HttpUtils
.
doGet
(
"http://hope.demogic.com/api-admin/apply-info?type=2&applyId="
+
task
.
getApplyId
());
String
applyStatusText
=
HttpUtils
.
doGet
(
"http://hope.demogic.com/api-admin/apply-info?type=2&applyId="
+
task
.
getApplyId
());
log
.
debug
(
"runApplyTask.run"
,
"查询自助指标查询 "
+
task
.
getId
()
+
" 审核状态码"
+
applyStatusText
);
log
.
debug
(
"runApplyTask.run"
,
"查询自助指标查询 "
+
task
.
getId
()
+
" 审核状态码"
+
applyStatusText
);
if
(
StringUtils
.
isBlank
(
applyStatusText
)){
break
;
}
boolean
conditionRemove
=
false
;
// 从上传条件移除
boolean
conditionRemove
=
false
;
// 从上传条件移除
boolean
conditionUpdate
=
false
;
// 更新条件
boolean
conditionUpdate
=
false
;
// 更新条件
if
(
applyStatusText
.
indexOf
(
"\"checkStatus\":0"
)
>
0
)
{
// 如果自审核通过
if
(
applyStatusText
.
indexOf
(
"\"checkStatus\":0"
)
>
0
)
{
// 如果自审核通过
...
@@ -578,9 +591,9 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
...
@@ -578,9 +591,9 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
}
// IF OVER
}
// IF OVER
}
// IF ELSE OVER
}
// IF ELSE OVER
}
}
}
// FOR OVER
}
}
// RUN OVER
}
},
interval
*
1000
,
interval
*
1000
);
// 配置中的值为毫秒
},
interval
*
1000
,
interval
*
1000
,
TimeUnit
.
MILLISECONDS
);
}
}
...
...
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