Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
car-reptiles
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
梁辉
car-reptiles
Commits
953f9721
Commit
953f9721
authored
Dec 23, 2020
by
landerliang@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自动签章上传,异步问题,本次还没测试是否解决
parent
1c70fb6d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
19 deletions
+39
-19
car-reptiles-common/src/main/java/me/zhengjie/exception/BusinessException.java
+6
-0
car-reptiles-system/src/main/java/me/zhengjie/AppRun.java
+1
-1
car-reptiles-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java
+1
-1
car-reptiles-system/src/main/java/me/zhengjie/modules/quartz/task/ReportTask.java
+3
-1
car-reptiles-system/src/main/java/me/zhengjie/modules/quartz/utils/ExecutionJob.java
+1
-1
car-reptiles-system/src/main/java/me/zhengjie/modules/system/rest/ReportController.java
+2
-1
car-reptiles-system/src/main/java/me/zhengjie/modules/system/service/ReportService.java
+19
-11
car-reptiles-system/src/main/java/me/zhengjie/modules/system/util/CarReportUtil.java
+5
-2
car-reptiles-system/src/main/resources/config/application.yml
+1
-1
No files found.
car-reptiles-common/src/main/java/me/zhengjie/exception/BusinessException.java
View file @
953f9721
...
...
@@ -7,6 +7,8 @@ public class BusinessException extends RuntimeException {
private
int
code
=
400
;
private
boolean
success
=
false
;
public
BusinessException
(
String
message
)
{
super
(
message
);
}
...
...
@@ -24,4 +26,8 @@ public class BusinessException extends RuntimeException {
public
int
getCode
()
{
return
code
;
}
public
boolean
isSuccess
()
{
return
success
;
}
}
car-reptiles-system/src/main/java/me/zhengjie/AppRun.java
View file @
953f9721
...
...
@@ -38,7 +38,7 @@ import org.springframework.web.client.RestTemplate;
* @date 2018/11/15 9:20:19
*/
@MapperScan
(
"me.zhengjie.modules.system.repository"
)
@EnableAsync
//
@EnableAsync
@RestController
@Api
(
hidden
=
true
)
@SpringBootApplication
...
...
car-reptiles-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java
View file @
953f9721
...
...
@@ -145,7 +145,7 @@ public class QuartzJobServiceImpl implements QuartzJobService {
}
}
@Async
//
@Async
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
executionSubJob
(
String
[]
tasks
)
throws
InterruptedException
{
...
...
car-reptiles-system/src/main/java/me/zhengjie/modules/quartz/task/ReportTask.java
View file @
953f9721
...
...
@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import
me.zhengjie.modules.system.service.ReportService
;
import
me.zhengjie.utils.AssertUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -19,7 +20,7 @@ public class ReportTask {
@Autowired
private
ReportService
reportService
;
public
void
run
(
String
param
){
public
void
run
(
String
param
)
{
log
.
info
(
">>> 开始自动爬取新的检测报告进行下载、签章、上传"
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
param
);
...
...
@@ -39,5 +40,6 @@ public class ReportTask {
reportService
.
autoDownloadAndSignAndUploadReport
(
jsonObject
.
getString
(
"account"
),
jsonObject
.
getString
(
"password"
),
jsonObject
.
getString
(
"snKey1"
),
jsonObject
.
getString
(
"snKey2"
),
jsonObject
.
getString
(
"snKey3"
),
jsonObject
.
getString
(
"snName1"
),
jsonObject
.
getString
(
"snName2"
),
jsonObject
.
getString
(
"snName3"
));
log
.
info
(
">> 本次自动签章任务执行完毕!"
);
}
}
car-reptiles-system/src/main/java/me/zhengjie/modules/quartz/utils/ExecutionJob.java
View file @
953f9721
...
...
@@ -41,7 +41,7 @@ import java.util.concurrent.*;
* @author /
* @date 2019-01-07
*/
@Async
//
@Async
@SuppressWarnings
({
"unchecked"
,
"all"
})
public
class
ExecutionJob
extends
QuartzJobBean
{
...
...
car-reptiles-system/src/main/java/me/zhengjie/modules/system/rest/ReportController.java
View file @
953f9721
package
me
.
zhengjie
.
modules
.
system
.
rest
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -169,7 +170,7 @@ public class ReportController {
@ApiOperation
(
"查看上传文件个数"
)
@GetMapping
(
"/showFiles/{businessKey}"
)
public
ResultVo
<
List
<
UploadFileViewVo
>>
showFiles
(
@PathVariable
String
businessKey
){
AssertUtil
.
is
NotBlank
(
businessKey
,
"缺少参数
businessKey"
);
AssertUtil
.
is
True
(
StrUtil
.
isNotBlank
(
businessKey
)
&&
!
businessKey
.
equals
(
"null"
),
"当前检测报告未上传文件,缺少
businessKey"
);
return
ResultVo
.
success
(
reportService
.
getUploadFileList
(
businessKey
));
}
...
...
car-reptiles-system/src/main/java/me/zhengjie/modules/system/service/ReportService.java
View file @
953f9721
...
...
@@ -123,7 +123,6 @@ public class ReportService {
* 自动下载检测报告并签章上传
*
*/
@Async
public
void
autoDownloadAndSignAndUploadReport
(
String
account
,
String
password
,
String
snKey1
,
String
snKey2
,
String
snKey3
,
String
snName1
,
String
snName2
,
String
snName3
){
...
...
@@ -133,9 +132,9 @@ public class ReportService {
log
.
info
(
">> 定时扫描未签章上传的检测报告,扫描结果:{} 条数据"
,
testReportVos
.
size
());
for
(
TestReportVo
testReportVo:
testReportVos
){
//根据报告编码查询数据库是否已下载 未下载则进行自动下载签章和上传
ReportPdfVo
reportPdfVo
=
reportPdfMapper
.
selectOne
(
new
QueryWrapper
<
ReportPdfVo
>().
lambda
().
eq
(
ReportPdfVo:
:
getReportNum
,
testReportVo
.
getInspection
Num
()));
ReportPdfVo
reportPdfVo
=
reportPdfMapper
.
selectOne
(
new
QueryWrapper
<
ReportPdfVo
>().
lambda
().
eq
(
ReportPdfVo:
:
getReportNum
,
testReportVo
.
getInspection
ReportNo
()));
if
(
reportPdfVo
==
null
){
log
.
info
(
">>
当前自动爬取的检测报告车牌号:{}, 检测状态:{}, 检测报告单号:{}"
,
testReportVo
.
getVLPN
(),
testReportVo
.
getNewVDCT
(),
testReportVo
.
getInspectionNum
());
log
.
info
(
">>
遍历爬取的检测报告车牌号:{}, 检测状态:{}, 检测报告单号:{}"
,
testReportVo
.
getVLPN
(),
testReportVo
.
getNewVDCT
(),
testReportVo
.
getInspectionReportNo
());
ReportDetailsReqVo
reportDetailsReqVo
=
new
ReportDetailsReqVo
();
reportDetailsReqVo
.
setCarNum
(
testReportVo
.
getVLPN
());
...
...
@@ -147,13 +146,11 @@ public class ReportService {
reportPdfVo
.
setPath
(
path
);
reportPdfVo
.
setVehicleId
(
testReportVo
.
getVehicleID
());
reportPdfVo
.
setUniqueString
(
testReportVo
.
getUniqueString
());
reportPdfVo
.
setReportName
(
testReportVo
.
getInspection
Num
()
);
reportPdfVo
.
setReportNum
(
testReportVo
.
getInspection
Num
());
reportPdfVo
.
setReportName
(
testReportVo
.
getInspection
ReportNo
()
+
".pdf"
);
reportPdfVo
.
setReportNum
(
testReportVo
.
getInspection
ReportNo
());
reportPdfVo
.
setBusinessKey
(
testReportVo
.
getBusinessKey
());
reportPdfVo
.
setCreateTime
(
DateUtil
.
date
());
reportPdfVo
.
setCarNum
(
testReportVo
.
getVLPN
());
//写入pdf下载记录
reportPdfMapper
.
insert
(
reportPdfVo
);
//根据snKey查询签章信息
...
...
@@ -179,18 +176,29 @@ public class ReportService {
ResultVo
.
class
);
AssertUtil
.
isTrue
(
responseEntity
.
getStatusCode
()
==
HttpStatus
.
OK
&&
responseEntity
.
getBody
().
getData
()!=
null
,
responseEntity
.
getBody
().
getErrMsg
());
log
.
info
(
">> 自动签章完成!开始进行报告上传........"
);
//更新数据库的报告详情
ReportPdfVo
signatureReport
=
JSONUtil
.
toBean
(
JSONUtil
.
toJsonPrettyStr
(
responseEntity
.
getBody
().
getData
()),
ReportPdfVo
.
class
);
reportPdfMapper
.
updateById
(
signatureReport
);
//reportPdfMapper.updateById(signatureReport);
//修改签章后的pdf文件名称和文件路径
reportPdfVo
.
setPath
(
signatureReport
.
getPath
());
reportPdfVo
.
setReportName
(
signatureReport
.
getReportName
());
//上传文件 (连同检测报告全部文件)
Integer
success
=
carReportUtil
.
autoUploadReportPost
(
account
,
password
,
signatureReport
,
signatureVo1
.
getDeptId
());
Integer
success
=
carReportUtil
.
autoUploadReportPost
(
account
,
password
,
reportPdfVo
,
signatureVo1
.
getDeptId
());
//上传成功的文件小于2个则视为上传失败,清除下载记录
if
(
success
<
2
){
/*
if(success < 2){
deleteReportPdf(signatureReport.getReportNum());
}
}
*/
if
(
success
>=
2
){
log
.
info
(
">> 成功自动上传:{} 个文件,本次上传任务完成!"
,
success
);
//写入pdf下载记录
reportPdfMapper
.
insert
(
reportPdfVo
);
}
}
}
...
...
car-reptiles-system/src/main/java/me/zhengjie/modules/system/util/CarReportUtil.java
View file @
953f9721
...
...
@@ -90,7 +90,7 @@ public class CarReportUtil {
webDriver
.
manage
().
timeouts
().
implicitlyWait
(
60
,
TimeUnit
.
SECONDS
)
.
setScriptTimeout
(
60
,
TimeUnit
.
SECONDS
).
pageLoadTimeout
(
120
,
TimeUnit
.
SECONDS
);
Thread
.
sleep
(
2
000
);
Thread
.
sleep
(
3
000
);
String
body
=
webDriver
.
getPageSource
();
body
=
body
.
replace
(
"../../Scripts"
,
host
+
"/Scripts"
)
...
...
@@ -761,6 +761,8 @@ public class CarReportUtil {
driver
.
manage
().
timeouts
().
implicitlyWait
(
60
,
TimeUnit
.
SECONDS
)
.
setScriptTimeout
(
60
,
TimeUnit
.
SECONDS
).
pageLoadTimeout
(
120
,
TimeUnit
.
SECONDS
);
Thread
.
sleep
(
1000
);
//点击完检测报告的超链接后,抓取frame窗口的元素
WebElement
homeFrame
=
driver
.
findElement
(
new
By
.
ByXPath
(
"//*[@id=\"tabs\"]/div[2]/div[2]/div/iframe"
));
//切换到iframe页面
...
...
@@ -769,6 +771,7 @@ public class CarReportUtil {
frameDriver
.
manage
().
timeouts
().
implicitlyWait
(
60
,
TimeUnit
.
SECONDS
)
.
setScriptTimeout
(
60
,
TimeUnit
.
SECONDS
).
pageLoadTimeout
(
120
,
TimeUnit
.
SECONDS
);
Thread
.
sleep
(
1000
);
frameDriver
.
findElement
(
new
By
.
ByXPath
(
"//*[@id=\"table_Condition\"]/tbody/tr[2]/td[3]/input"
)).
click
();
...
...
@@ -942,7 +945,7 @@ public class CarReportUtil {
MyContext
.
PHOTO_TABLE_NAME
,
MyContext
.
PHOTO_WHERE
,
fldsVo
.
getFld
(),
conditionVoList
,
null
,
5
);
JSONObject
body
=
JSONUtil
.
createObj
();
body
.
put
(
"data"
,
queryDataVo
);
body
.
put
(
"rows"
,
20
);
body
.
put
(
"rows"
,
5
);
body
.
put
(
"page"
,
1
);
body
.
put
(
"sort"
,
"DetectEndTime"
);
body
.
put
(
"order"
,
"DESC"
);
...
...
car-reptiles-system/src/main/resources/config/application.yml
View file @
953f9721
...
...
@@ -5,7 +5,7 @@ spring:
freemarker
:
check-template-location
:
false
profiles
:
active
:
dev
active
:
prod
jackson
:
time-zone
:
GMT+8
data
:
...
...
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