From 5b45d4ba77a209251ce8e21c5392a62eea32a57a Mon Sep 17 00:00:00 2001
From: zhouwenxuan <1175765986@qq.com>
Date: 星期三, 12 七月 2023 10:54:35 +0800
Subject: [PATCH] 停用检修记录

---
 src/main/java/com/ruoyi/doublePrevention/scheduls/ExecCJReportDateSchedule.java |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/ruoyi/doublePrevention/scheduls/ExecCJReportDateSchedule.java b/src/main/java/com/ruoyi/doublePrevention/scheduls/ExecCJReportDateSchedule.java
index f2967f7..0f3be9e 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;
@@ -28,6 +29,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.*;
+import java.lang.reflect.Array;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
@@ -58,6 +60,8 @@
     private PreventCJReportPointService CJPointService;
     @Autowired
     private PreventCJReportOverhaulLogService CJOverhaulLogService;
+    @Autowired
+    private PreventReportConfigService preventReportConfigService;
 
     String token = "GT6gGJV7JV";
     String key = "Bv+NeBolwqg2Pbc1yVwrZA==";
@@ -89,8 +93,10 @@
 
 
     @Transactional
-//    @Scheduled(cron = "0 0 23 * * ?")    //每天晚上23点执行一次
-//    @Scheduled(cron = "0 0/2 * * * ? ")    // 分钟
+//    @Scheduled(cron = "0 0 23 * * ?")    //每天晚上23点执行一次0 0 22,23 * * ?
+//    @Scheduled(cron = "0 0 22,23 * * ?")    //每天晚上22、23点执行一次
+//    @Scheduled(cron = "0 0/1 * * * ? ")    // 分钟
+    @Scheduled(cron = "0 0/20 * * * ? ")    // 分钟
     //@Scheduled(cron = "0/30 * * * * ?")
     public void execReportDateSchedule() throws UnsupportedEncodingException {
         logger.info("【####】上报数据开始...");
@@ -108,10 +114,15 @@
 
         logger.info("【token时间】" + formatDate);
 
+        //使用风险分析单元数据上报主配置,作为自动上报开关
+        PreventReportConfig reportConfig = preventReportConfigService.getReportConfigById(SyncEnum.REPORT_CONFIG_RISK_ANA_UNIT.getCode());
+        if (reportConfig.getReportType() == 0){
+            return;
+        }
+
         /**
          * 1、处理安全风险分析单元数据
          * */
-
         logger.info("【1】安全风险分析单元-处理数据...");
         List<PreventCJReportRiskAnaUnit> CJRiskAnaUnits = CJRiskAnaUnitService.listReportUnitDate();
         if (ObjectUtils.isNotEmpty(CJRiskAnaUnits)){
@@ -279,7 +290,7 @@
                 os.write(JSON.toJSONString(paraMap).getBytes());
                 //得到响应码
                 responseCode = con.getResponseCode();
-                //本段日志,测试成功后,可注释掉
+                //确认响应流不为空
                 if (responseCode == HttpURLConnection.HTTP_OK) {
                     //得到响应流
                     InputStream inputStream = con.getInputStream();
@@ -471,10 +482,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;
@@ -497,7 +507,7 @@
                 con.setRequestProperty("X-Access-Token",token+formatDate.toString());
                 OutputStream os = con.getOutputStream();
                 Map paraMap = new HashMap();
-                paraMap.put("data", AESReportTaskFromWork); /**封装数据*/
+                paraMap.put("data", AESReportTaskFromWork);
                 //组装入参,设置请求体
                 os.write(JSON.toJSONString(paraMap).getBytes());
                 //得到响应码
@@ -576,6 +586,7 @@
                 cjReportCheckRecordFromTaskDTO.setIsDefend(cjRecordFromTask.getDefend());
                 reportRecordFromTaskList.add(cjReportCheckRecordFromTaskDTO);
             }
+//            System.out.println(Arrays.toString(reportRecordFromTaskList.toArray()));
             //数据加密
             String AESReportRecordFromTask = encrypt(JSONObject.toJSONString(reportRecordFromTaskList), key.getBytes(), iv.getBytes());
 

--
Gitblit v1.9.2