Commit 953f9721 by landerliang@163.com

自动签章上传,异步问题,本次还没测试是否解决

parent 1c70fb6d
......@@ -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;
}
}
......@@ -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
......
......@@ -145,7 +145,7 @@ public class QuartzJobServiceImpl implements QuartzJobService {
}
}
@Async
//@Async
@Override
@Transactional(rollbackFor = Exception.class)
public void executionSubJob(String[] tasks) throws InterruptedException {
......
......@@ -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(">> 本次自动签章任务执行完毕!");
}
}
......@@ -41,7 +41,7 @@ import java.util.concurrent.*;
* @author /
* @date 2019-01-07
*/
@Async
//@Async
@SuppressWarnings({"unchecked","all"})
public class ExecutionJob extends QuartzJobBean {
......
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.isNotBlank(businessKey,"缺少参数businessKey");
AssertUtil.isTrue(StrUtil.isNotBlank(businessKey) && !businessKey.equals("null"),"当前检测报告未上传文件,缺少businessKey");
return ResultVo.success(reportService.getUploadFileList(businessKey));
}
......
......@@ -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.getInspectionNum()));
ReportPdfVo reportPdfVo = reportPdfMapper.selectOne(new QueryWrapper<ReportPdfVo>().lambda().eq(ReportPdfVo::getReportNum, testReportVo.getInspectionReportNo()));
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.getInspectionNum());
reportPdfVo.setReportNum(testReportVo.getInspectionNum());
reportPdfVo.setReportName(testReportVo.getInspectionReportNo() + ".pdf");
reportPdfVo.setReportNum(testReportVo.getInspectionReportNo());
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);
}
}
}
......
......@@ -90,7 +90,7 @@ public class CarReportUtil {
webDriver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS)
.setScriptTimeout(60,TimeUnit.SECONDS).pageLoadTimeout(120,TimeUnit.SECONDS);
Thread.sleep(2000);
Thread.sleep(3000);
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");
......
......@@ -5,7 +5,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
jackson:
time-zone: GMT+8
data:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment