limeng пре 7 месеци
родитељ
комит
f3d5339958

+ 0 - 6
src/main/java/com/sooka/sponest/dataexchange/remoteapi/fallback/center/lawenforcement/RemoteLawenforcementBaseServiceFallbackFactory.java

@@ -3,18 +3,12 @@ package com.sooka.sponest.dataexchange.remoteapi.fallback.center.lawenforcement;
 
 import com.alibaba.fastjson.JSONArray;
 import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.dataexchange.exchange.domian.DataExchangeEntity;
-import com.sooka.sponest.dataexchange.remoteapi.service.center.data.RemoteDataBaseService;
-import com.sooka.sponest.dataexchange.remoteapi.service.center.event.RemoteEventBaseService;
 import com.sooka.sponest.dataexchange.remoteapi.service.center.lawenforcement.RemoteLawenforcementBaseService;
-import com.sooka.sponest.dataexchange.sendChange.domian.CenterdataTKeyProjects;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.cloud.openfeign.FallbackFactory;
 import org.springframework.stereotype.Component;
 
-import java.util.List;
-
 
 @Component
 public class RemoteLawenforcementBaseServiceFallbackFactory implements FallbackFactory<RemoteLawenforcementBaseService> {

+ 0 - 4
src/main/java/com/sooka/sponest/dataexchange/remoteapi/service/center/lawenforcement/RemoteLawenforcementBaseService.java

@@ -3,15 +3,11 @@ package com.sooka.sponest.dataexchange.remoteapi.service.center.lawenforcement;
 
 import com.alibaba.fastjson.JSONArray;
 import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.dataexchange.remoteapi.fallback.center.data.RemoteDataBaseServiceFallbackFactory;
 import com.sooka.sponest.dataexchange.remoteapi.fallback.center.lawenforcement.RemoteLawenforcementBaseServiceFallbackFactory;
 import com.sooka.sponest.dataexchange.remoteapi.service.ModulesServiceNameContants;
-import com.sooka.sponest.dataexchange.sendChange.domian.CenterdataTKeyProjects;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 
-import java.util.List;
-
 
 @FeignClient(
         contextId = "RemoteLawenforcementBaseService",

+ 26 - 50
src/main/java/com/sooka/sponest/dataexchange/sendChange/quartz/EquipDataJob.java

@@ -1,21 +1,18 @@
 package com.sooka.sponest.dataexchange.sendChange.quartz;
 
 
+import cn.hutool.http.HttpStatus;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.dahuatech.hutool.http.Method;
+import com.dahuatech.icc.oauth.http.IccHttpHttpRequest;
 import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.dataexchange.remoteapi.service.center.data.RemoteDataBaseService;
 import com.sooka.sponest.dataexchange.remoteapi.service.center.lawenforcement.RemoteLawenforcementBaseService;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -31,14 +28,12 @@ public class EquipDataJob {
     @Resource
     private RemoteLawenforcementBaseService remoteLawenforcementBaseService;
 
-//    @Value("${equioData.accessKey}")
-//    private String accessKey;
-//
-//    @Value("${equioData.ip}")
-//    private String ip;
+    private String accessKey;
 
-//    @Scheduled(cron = "0 0/10 * * * ?")
-@Scheduled(cron = "0/10 * * * * ?")
+    private String ip;
+
+    //    @Scheduled(cron = "0 0/10 * * * ?")
+    @Scheduled(cron = "0/10 * * * * ?")
     public void getEquipJobRecords() throws Exception {
         log.info("定时任务调用省平台工单开始");
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -50,61 +45,42 @@ public class EquipDataJob {
         // 获取当前时间前10分钟的日期
         calendar.add(Calendar.MINUTE, -15);
         String startTime = URLEncoder.encode(sdf.format(calendar.getTime()), "UTF-8");
-//        String accessKey = a"d99f0830813a4d82921aefa002ddfb22";
         String accessKey = "e85332c67204481a911aaed7cdc123be";
-        String accessKey1 = "Basic";
         String accessKey2 = "Basic NmRiNjc5NTBkYzQ2OGJlMzM3YzE5MzhmMGJiMWY5YTg6MTRjYjM0ZGY2ODVhY2Y5MDNmYzY5OWU2ZTEwYmY2OGE=";
         String accessKey3 = "pUrKvA";
         Integer page = 1;
+        String prBody = null;
         for (int i = 1; i <= page; i++) {
-//            String urlString = ip + "/dev-api/outData/getJobRecords?page=" + page + "&size=10&updateStartTime=" + startTime + "&updateEndTime=" + endTime;
-//            String urlString = "http://36.135.7.83:81/dev-api/outData/getJobRecords?page=" + page + "&size=5&updateStartTime=2024-05-20%2010:50:33&updateEndTime=2024-11-20%2010:50:33";
-            String urlString = "http://172.24.5.241:6689/api/interface?page=1&size=1&createStartTime=2024-04-11 00:00:00&createEndTime=2024-04-12 12:00:00";
-            log.info("请求地址:{}", urlString);
+            String urlString = "http://172.24.5.241:6689/api/interface?page=" + page + "&size=10&updateStartTime=" + startTime + "&updateEndTime=" + endTime;
             try {
-                URL url = new URL(urlString);
-                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
-                connection.setRequestMethod("GET");
-                connection.setRequestProperty("access-key", accessKey);
-                connection.setRequestProperty("Authorization-Type", accessKey1);
-                connection.setRequestProperty("Authorization", accessKey2);
-                connection.setRequestProperty("Service-ID", accessKey3);
-                int responseCode = connection.getResponseCode();
-                log.info("connection.getResponseCode():{}", connection.getResponseCode());
-                log.info("connection:{}", connection.getResponseMessage());
-                if (responseCode == HttpURLConnection.HTTP_OK) {
-                    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-                    String inputLine;
-                    StringBuilder response = new StringBuilder();
-                    while ((inputLine = in.readLine()) != null) {
-                        response.append(inputLine);
-                    }
-                    in.close();
-                    JSONObject jsonObject = JSONObject.parseObject(response.toString());
-                    log.info("jsonObject:{}", jsonObject);
-                    page = (Integer) JSONObject.parseObject(jsonObject.get("data").toString()).get("pages");
+                log.info("----开始执行----{}------请求地址:{}", "调用省平台工单接口", urlString);
+                IccHttpHttpRequest pr = new IccHttpHttpRequest(urlString, Method.GET);
+                pr.getHttpRequest().header("access-key", accessKey);
+                pr.getHttpRequest().header("Authorization-Type", "Basic");//固定
+                pr.getHttpRequest().header("Authorization", accessKey2);
+                pr.getHttpRequest().header("Service-ID", accessKey3);
+                prBody = pr.execute();
+                JSONObject jsonObject = JSONObject.parseObject(prBody);
+                if ((Integer) jsonObject.get("code") == HttpStatus.HTTP_OK) {
+                    log.info("prBody解析成功");
+                    page = (Integer) jsonObject.get("pages");
+                    log.info("page = "+page);
                     JSONArray jsonArray = JSONObject.parseArray(JSONObject.parseObject(jsonObject.get("data").toString()).get("records").toString());
-                    log.info("jsonArray:{}", jsonArray);
+                    log.info("jsonArray = "+jsonArray);
                     R<?> result = remoteLawenforcementBaseService.insertEnforceLawInfoByList(jsonArray);
                     log.info("result:{}", result);
                     if (result.getCode() == 200) {
-                        log.info("推送成功");
+                        log.info("数字执法---推送成功");
                     } else {
-                        log.error("推送失败");
+                        log.error("数字执法---推送失败:{}", result);
                     }
-                    log.info("定时任务调用省平台工单结束");
-                } else {
-                    log.error("调用接口返回code代码:{}", responseCode);
                 }
             } catch (Exception e) {
-                log.error("调用接口报错");
+                log.error("调用接口报错 prBody:{}", prBody);
                 e.printStackTrace();
             }
         }
-
     }
-
-
 }