From 60c27c15c277238bf54d436aee210c7c5af7fdc5 Mon Sep 17 00:00:00 2001
From: 换个名字嗨起来 <577530412@qq.com>
Date: Thu, 25 Jul 2024 16:01:45 +0800
Subject: [PATCH] Http响应结果异常输出
---
src/main/java/com/ruoyi/doublePrevention/scheduls/ExecCJReportDateSchedule.java | 37 +++++++++++++++++++++++++++++--------
1 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/ruoyi/doublePrevention/scheduls/ExecCJReportDateSchedule.java b/src/main/java/com/ruoyi/doublePrevention/scheduls/ExecCJReportDateSchedule.java
index 4af8645..1ed2ac6 100644
--- a/src/main/java/com/ruoyi/doublePrevention/scheduls/ExecCJReportDateSchedule.java
+++ b/src/main/java/com/ruoyi/doublePrevention/scheduls/ExecCJReportDateSchedule.java
@@ -10,6 +10,7 @@
import com.ruoyi.doublePrevention.entity.CJReport.CJdto.Data;
import com.ruoyi.doublePrevention.entity.CJReport.CJdto.ErrorMsgDetails;
import com.ruoyi.doublePrevention.entity.CJReport.CJdto.HandlerDO.*;
+import com.ruoyi.doublePrevention.entity.PreventReportConfig;
import com.ruoyi.doublePrevention.enums.CJReportEnum;
import com.ruoyi.doublePrevention.enums.SyncEnum;
import com.ruoyi.doublePrevention.repository.param.HandlerCJReportParam;
@@ -59,6 +60,8 @@
private PreventCJReportPointService CJPointService;
@Autowired
private PreventCJReportOverhaulLogService CJOverhaulLogService;
+ @Autowired
+ private PreventReportConfigService preventReportConfigService;
String token = "GT6gGJV7JV";
String key = "Bv+NeBolwqg2Pbc1yVwrZA==";
@@ -92,9 +95,8 @@
@Transactional
// @Scheduled(cron = "0 0 23 * * ?") //每天晚上23点执行一次0 0 22,23 * * ?
// @Scheduled(cron = "0 0 22,23 * * ?") //每天晚上22、23点执行一次
-// @Scheduled(cron = "0 0/3 * * * ? ") // 分钟
- @Scheduled(cron = "0 0/30 * * * ? ") // 分钟
- //@Scheduled(cron = "0/30 * * * * ?")
+ @Scheduled(cron = "0 0/10 * * * ? ") // 分钟
+// @Scheduled(cron = "0/30 * * * * ?")
public void execReportDateSchedule() throws UnsupportedEncodingException {
logger.info("【####】上报数据开始...");
@@ -111,6 +113,11 @@
logger.info("【token时间】" + formatDate);
+ //使用风险分析单元数据上报主配置,作为自动上报开关
+ PreventReportConfig reportConfig = preventReportConfigService.getReportConfigById(SyncEnum.REPORT_CONFIG_RISK_ANA_UNIT.getCode());
+ if (reportConfig.getReportType() == 0){
+ return;
+ }
/**
* 1、处理安全风险分析单元数据
@@ -474,10 +481,9 @@
cjReportCheckTaskFromWorkDTO.setCreateDate(dateFormat.format(cjTaskFromWork.getCreateDate()));
cjReportCheckTaskFromWorkDTO.setUpdateDate(dateFormat.format(cjTaskFromWork.getUpdateDate()));
cjReportCheckTaskFromWorkDTO.setTaskStartTime(dateFormat.format(cjTaskFromWork.getCreateDate()));
- cjReportCheckTaskFromWorkDTO.setWorkStartTime(dateFormat.format(cjTaskFromWork.getUpdateDate()));
- cjReportCheckTaskFromWorkDTO.setWorkEndTime(dateFormat.format(cjTaskFromWork.getUpdateDate()));
reportCheckTaskFromWorkList.add(cjReportCheckTaskFromWorkDTO);
}
+ System.out.println(Arrays.toString(reportCheckTaskFromWorkList.toArray()));
//数据上报
String AESReportTaskFromWork = encrypt(JSONObject.toJSONString(reportCheckTaskFromWorkList), key.getBytes(), iv.getBytes());
StringBuffer taskFromWorkResultBuffer = null;
@@ -579,10 +585,10 @@
cjReportCheckRecordFromTaskDTO.setIsDefend(cjRecordFromTask.getDefend());
reportRecordFromTaskList.add(cjReportCheckRecordFromTaskDTO);
}
- System.out.println(Arrays.toString(reportRecordFromTaskList.toArray()));
+// System.out.println(Arrays.toString(reportRecordFromTaskList.toArray()));
//数据加密
String AESReportRecordFromTask = encrypt(JSONObject.toJSONString(reportRecordFromTaskList), key.getBytes(), iv.getBytes());
-
+ logger.info("【test】数据加密完成,开始上报数据");
StringBuffer recordFromTaskResultBuffer = null;
//上报数据
try {
@@ -620,14 +626,29 @@
recordFromTaskResultBuffer.append(line);
}
logger.info("result:" + recordFromTaskResultBuffer.toString());
+ }else {
+ logger.info("Http结果:" + responseCode);
}
} catch (Exception e) {
e.printStackTrace();
}
+ logger.info("【test】接收返回值");
+ CJReportResultData CJRecordFromTaskResult = new CJReportResultData();
+ try {
+ CJRecordFromTaskResult = JSONObject.parseObject(recordFromTaskResultBuffer.toString(), CJReportResultData.class);
+ if (ObjectUtils.isEmpty(CJRecordFromTaskResult)){
+ throw new RuntimeException("返回值为空");
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ logger.info("【test】接收返回值异常");
+ }
+
//接收返回值,保存返回值
- CJReportResultData CJRecordFromTaskResult = JSONObject.parseObject(recordFromTaskResultBuffer.toString(), CJReportResultData.class);
+// CJReportResultData CJRecordFromTaskResult = JSONObject.parseObject(recordFromTaskResultBuffer.toString(), CJReportResultData.class);
//接收返回值,保存返回值
+ logger.info("【test】保存上报结果");
List<String> errorIdList= new ArrayList<>();
Data data = JSONObject.parseObject(CJRecordFromTaskResult.getData(), Data.class);
//保存失败结果
--
Gitblit v1.9.2