Kaynağa Gözat

代码优化

yangbq 1 ay önce
ebeveyn
işleme
4e6b09097c

+ 17 - 1
src/main/java/com/sckj/project/config/RestTemplateConfig.java

@@ -1,7 +1,12 @@
 package com.sckj.project.config;
 
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.ClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 import org.springframework.web.client.RestTemplate;
 
 
@@ -11,6 +16,17 @@ public class RestTemplateConfig {
 
     @Bean
     public RestTemplate restTemplate() {
-        return new RestTemplate();
+        PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
+        CloseableHttpClient httpClient = HttpClients.custom()
+                .setConnectionManager(connectionManager)
+                .build();
+
+        ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
+        // 设置连接超时时间
+        ((HttpComponentsClientHttpRequestFactory) factory).setConnectTimeout(6000);
+        // 设置读取超时时间
+        ((HttpComponentsClientHttpRequestFactory) factory).setReadTimeout(60000);
+
+        return new RestTemplate(factory);
     }
 }

+ 14 - 0
src/main/java/com/sckj/project/constants/Constants.java

@@ -0,0 +1,14 @@
+package com.sckj.project.constants;
+
+/**
+ * @Description
+ * @Author bqyang
+ * @Date 2025/3/7 11:26
+ * @Version 1.0
+ */
+public class Constants {
+
+    public static final String REQUEST_HEAD = "X-Access-Token";
+
+    public static final String REQUEST_HEAD_SCR = "M2p5yEL67eZct7gtvT";
+}

+ 9 - 18
src/main/java/com/sckj/project/task/BuildingTaskService.java → src/main/java/com/sckj/project/service/task/BuildingTaskService.java

@@ -1,4 +1,4 @@
-package com.sckj.project.task;
+package com.sckj.project.service.task;
 
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
@@ -7,23 +7,19 @@ import com.sckj.project.config.ApiUrlConfig;
 import com.sckj.project.domain.building.LargeBuilding;
 import com.sckj.project.domain.building.LargeBuildingControl;
 import com.sckj.project.domain.building.LargeBuildingControlAmmeterDetail;
-import com.sckj.project.domain.logistics.LargeHousingLand;
 import com.sckj.project.service.building.ILargePlatBuildingAmmeterDetailService;
 import com.sckj.project.service.building.ILargePlatBuildingControlService;
 import com.sckj.project.service.building.ILargePlatBuildingService;
-import com.sckj.project.util.AESUtil;
+import com.sckj.project.util.HttpRequestUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestClientException;
-import org.springframework.web.client.RestTemplate;
 
 import java.util.List;
-
+@Slf4j
 @Service
 public class BuildingTaskService {
 
@@ -37,14 +33,11 @@ public class BuildingTaskService {
     private ILargePlatBuildingAmmeterDetailService largePlatBuildingAmmeterDetailService;
 
     @Autowired
-    private RestTemplate restTemplate;
+    private HttpRequestUtil httpRequestUtil;
 
     public JSONArray callExternalApi(String url) {
         try {
-            HttpHeaders headers = new HttpHeaders();
-            headers.set("X-Access-Token", AESUtil.encrypt("M2p5yEL67eZct7gtvT"));
-            HttpEntity<String> entity = new HttpEntity<>(null, headers);
-            ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
+            ResponseEntity<String> response = httpRequestUtil.get(url);
             if (StringUtils.isEmpty(response.getBody())){
                 return null;
             }
@@ -69,7 +62,7 @@ public class BuildingTaskService {
             largePlatBuildingService.remove(new LambdaQueryWrapper<>());
             largePlatBuildingService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*楼宇中控*/
@@ -85,7 +78,7 @@ public class BuildingTaskService {
             largePlatBuildingControlService.remove(new LambdaQueryWrapper<>());
             largePlatBuildingControlService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*楼宇中控电表明细表*/
@@ -101,10 +94,8 @@ public class BuildingTaskService {
             largePlatBuildingAmmeterDetailService.remove(new LambdaQueryWrapper<>());
             largePlatBuildingAmmeterDetailService.saveBatch(list);
         } catch (Exception e) {
-
+          e.getMessage();
         }
 
-
-        System.out.println("楼宇运行同步完成");
     }
 }

+ 9 - 20
src/main/java/com/sckj/project/task/CarTaskService.java → src/main/java/com/sckj/project/service/task/CarTaskService.java

@@ -1,31 +1,26 @@
-package com.sckj.project.task;
+package com.sckj.project.service.task;
 
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckj.project.config.ApiUrlConfig;
-import com.sckj.project.domain.car.LargeCar;
 import com.sckj.project.domain.car.LargeCarDetail;
 import com.sckj.project.domain.car.LargeCarRank;
 import com.sckj.project.domain.car.LargeWarnDetail;
-import com.sckj.project.domain.engineering.LargeCamera;
 import com.sckj.project.service.car.ILargeCarDetailService;
 import com.sckj.project.service.car.ILargeCarRankService;
 import com.sckj.project.service.car.ILargeCarService;
 import com.sckj.project.service.car.ILargeWarnDetailService;
-import com.sckj.project.util.AESUtil;
+import com.sckj.project.util.HttpRequestUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestClientException;
-import org.springframework.web.client.RestTemplate;
 
 import java.util.List;
-
+@Slf4j
 @Service
 public class CarTaskService {
 
@@ -42,14 +37,11 @@ public class CarTaskService {
     private ILargeCarRankService largeCarRankService;
 
     @Autowired
-    private RestTemplate restTemplate;
+    private HttpRequestUtil httpRequestUtil;
 
     public JSONArray callExternalApi(String url) {
         try {
-            HttpHeaders headers = new HttpHeaders();
-            headers.set("X-Access-Token", AESUtil.encrypt("M2p5yEL67eZct7gtvT"));
-            HttpEntity<String> entity = new HttpEntity<>(null, headers);
-            ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
+            ResponseEntity<String> response = httpRequestUtil.get(url);
             if (StringUtils.isEmpty(response.getBody())){
                 return null;
             }
@@ -77,7 +69,7 @@ public class CarTaskService {
             largeCarDetailService.remove(new LambdaQueryWrapper<>());
             largeCarDetailService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*公务用车预警明细表*/
@@ -93,7 +85,7 @@ public class CarTaskService {
             largeWarnDetailService.remove(new LambdaQueryWrapper<>());
             largeWarnDetailService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*公务用车单车活跃排名表*/
@@ -109,10 +101,7 @@ public class CarTaskService {
             largeCarRankService.remove(new LambdaQueryWrapper<>());
             largeCarRankService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
-
-
-        System.out.println("公务用车同步完成");
     }
 }

+ 9 - 19
src/main/java/com/sckj/project/task/EngineeringTaskService.java → src/main/java/com/sckj/project/service/task/EngineeringTaskService.java

@@ -1,29 +1,26 @@
-package com.sckj.project.task;
+package com.sckj.project.service.task;
 
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckj.project.config.ApiUrlConfig;
-import com.sckj.project.domain.building.LargeBuilding;
 import com.sckj.project.domain.engineering.LargeCamera;
 import com.sckj.project.domain.engineering.LargeIssue;
 import com.sckj.project.domain.engineering.LargeProject;
 import com.sckj.project.service.engineering.ILargeCameraService;
 import com.sckj.project.service.engineering.ILargePlatIssueService;
 import com.sckj.project.service.engineering.ILargePlatProjectService;
-import com.sckj.project.util.AESUtil;
+import com.sckj.project.util.HttpRequestUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestClientException;
-import org.springframework.web.client.RestTemplate;
 
 import java.util.List;
 
+@Slf4j
 @Service
 public class EngineeringTaskService {
 
@@ -36,18 +33,12 @@ public class EngineeringTaskService {
     @Autowired
     private ILargePlatProjectService largePlatProjectService;
 
-//    @Autowired
-//    private GenericService<LargeProject> service28;
-
     @Autowired
-    private RestTemplate restTemplate;
+    private HttpRequestUtil httpRequestUtil;
 
     public JSONArray callExternalApi(String url) {
         try {
-            HttpHeaders headers = new HttpHeaders();
-            headers.set("X-Access-Token", AESUtil.encrypt("M2p5yEL67eZct7gtvT"));
-            HttpEntity<String> entity = new HttpEntity<>(null, headers);
-            ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
+            ResponseEntity<String> response = httpRequestUtil.get(url);
             if (StringUtils.isEmpty(response.getBody())){
                 return null;
             }
@@ -72,7 +63,7 @@ public class EngineeringTaskService {
             largeCameraService.remove(new LambdaQueryWrapper<>());
             largeCameraService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*上报问题表*/
@@ -88,7 +79,7 @@ public class EngineeringTaskService {
             largePlatIssueService.remove(new LambdaQueryWrapper<>());
             largePlatIssueService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*项目表*/
@@ -104,9 +95,8 @@ public class EngineeringTaskService {
             largePlatProjectService.remove(new LambdaQueryWrapper<>());
             largePlatProjectService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
-        System.out.println("工程现场同步完成");
     }
 }

+ 14 - 20
src/main/java/com/sckj/project/task/LogisticsTaskService.java → src/main/java/com/sckj/project/service/task/LogisticsTaskService.java

@@ -1,25 +1,24 @@
-package com.sckj.project.task;
+package com.sckj.project.service.task;
 
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckj.project.config.ApiUrlConfig;
-import com.sckj.project.domain.logistics.*;
-import com.sckj.project.domain.service.PlatBasicsSystem;
+import com.sckj.project.domain.logistics.LargeBuildingAssetDirs;
+import com.sckj.project.domain.logistics.LargeHousingLand;
+import com.sckj.project.domain.logistics.LargeOfficeAssetDirs;
+import com.sckj.project.domain.logistics.LargeServiceAssetDirs;
 import com.sckj.project.service.logistics.*;
-import com.sckj.project.util.AESUtil;
+import com.sckj.project.util.HttpRequestUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestClientException;
-import org.springframework.web.client.RestTemplate;
 
 import java.util.List;
-
+@Slf4j
 @Service
 public class LogisticsTaskService {
 
@@ -39,14 +38,11 @@ public class LogisticsTaskService {
     private ILargePlatLogisticsServiceAssetService largePlatLogisticsServiceAssetService;
 
     @Autowired
-    private RestTemplate restTemplate;
+    private HttpRequestUtil httpRequestUtil;
 
     public JSONArray callExternalApi(String url) {
         try {
-            HttpHeaders headers = new HttpHeaders();
-            headers.set("X-Access-Token", AESUtil.encrypt("M2p5yEL67eZct7gtvT"));
-            HttpEntity<String> entity = new HttpEntity<>(null, headers);
-            ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
+            ResponseEntity<String> response = httpRequestUtil.get(url);
             if (StringUtils.isEmpty(response.getBody())){
                 return null;
             }
@@ -71,7 +67,7 @@ public class LogisticsTaskService {
             largePlatHousingLandService.remove(new LambdaQueryWrapper<>());
             largePlatHousingLandService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*后勤运行监控中心表*/
@@ -90,7 +86,7 @@ public class LogisticsTaskService {
             largePlatLogisticsBuildingAssetService.remove(new LambdaQueryWrapper<>());
             largePlatLogisticsBuildingAssetService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*办公资产表*/
@@ -106,7 +102,7 @@ public class LogisticsTaskService {
             largePlatLogisticsOfficeAssetService.remove(new LambdaQueryWrapper<>());
             largePlatLogisticsOfficeAssetService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*服务设备表*/
@@ -122,10 +118,8 @@ public class LogisticsTaskService {
             largePlatLogisticsServiceAssetService.remove(new LambdaQueryWrapper<>());
             largePlatLogisticsServiceAssetService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
-
-        System.out.println("后勤资源同步完成");
     }
 }

+ 11 - 20
src/main/java/com/sckj/project/task/ServiceTaskService.java → src/main/java/com/sckj/project/service/task/ServiceTaskService.java

@@ -1,4 +1,4 @@
-package com.sckj.project.task;
+package com.sckj.project.service.task;
 
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
@@ -6,21 +6,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckj.project.config.ApiUrlConfig;
 import com.sckj.project.domain.service.*;
 import com.sckj.project.service.service.*;
-import com.sckj.project.util.AESUtil;
+import com.sckj.project.util.HttpRequestUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestClientException;
-import org.springframework.web.client.RestTemplate;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-
+@Slf4j
 @Service
 public class ServiceTaskService {
 
@@ -82,15 +77,12 @@ public class ServiceTaskService {
     private ILargePlatPropertyToolsService largePlatPropertyToolsService;
 
     @Autowired
-    private RestTemplate restTemplate;
+    private HttpRequestUtil httpRequestUtil;
 
 
     public JSONArray callExternalApi(String url) {
         try {
-            HttpHeaders headers = new HttpHeaders();
-            headers.set("X-Access-Token", AESUtil.encrypt("M2p5yEL67eZct7gtvT"));
-            HttpEntity<String> entity = new HttpEntity<>(null, headers);
-            ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
+            ResponseEntity<String> response = httpRequestUtil.get(url);
             if (StringUtils.isEmpty(response.getBody())){
                 return null;
             }
@@ -127,7 +119,7 @@ public class ServiceTaskService {
             largePlatBasicsSystemService.remove(new LambdaQueryWrapper<>());
             largePlatBasicsSystemService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*员工健康*/
@@ -146,7 +138,7 @@ public class ServiceTaskService {
             largePlatEmployeeHealthIllnessService.remove(new LambdaQueryWrapper<>());
             largePlatEmployeeHealthIllnessService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*员工概况*/
@@ -165,7 +157,7 @@ public class ServiceTaskService {
             largePlatEmployeeTypeFlowService.remove(new LambdaQueryWrapper<>());
             largePlatEmployeeTypeFlowService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*菜谱数据*/
@@ -190,7 +182,7 @@ public class ServiceTaskService {
             largePlatGreenSmartRankService.remove(new LambdaQueryWrapper<>());
             largePlatGreenSmartRankService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*食堂安全管理*/
@@ -212,7 +204,7 @@ public class ServiceTaskService {
             largePlatPostStationChartService.remove(new LambdaQueryWrapper<>());
             largePlatPostStationChartService.saveBatch(list);
         } catch (Exception e) {
-
+            e.getMessage();
         }
 
         /*共享驿站*/
@@ -224,6 +216,5 @@ public class ServiceTaskService {
         /*工具表列表*/
         largePlatPropertyToolsService.saveOrUpdate(callExternalApi(ApiUrlConfig.getPropertyToolsUrl()));
 
-        System.out.println("服务保障同步完成");
     }
 }

+ 28 - 43
src/main/java/com/sckj/project/task/ProjectTaskController.java

@@ -1,41 +1,10 @@
 package com.sckj.project.task;
 
-import cn.hutool.json.JSONUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.sckj.project.config.ApiUrlConfig;
-import com.sckj.project.domain.building.LargeBuilding;
-import com.sckj.project.domain.building.LargeBuildingControl;
-import com.sckj.project.domain.building.LargeBuildingControlAmmeterDetail;
-import com.sckj.project.domain.car.LargeCar;
-import com.sckj.project.domain.car.LargeCarDetail;
-import com.sckj.project.domain.car.LargeCarRank;
-import com.sckj.project.domain.car.LargeWarnDetail;
-import com.sckj.project.domain.engineering.LargeCamera;
-import com.sckj.project.domain.engineering.LargeIssue;
-import com.sckj.project.domain.engineering.LargeProject;
-import com.sckj.project.domain.logistics.*;
-import com.sckj.project.domain.service.*;
-import com.sckj.project.service.building.ILargePlatBuildingAmmeterDetailService;
-import com.sckj.project.service.building.ILargePlatBuildingControlService;
-import com.sckj.project.service.building.ILargePlatBuildingService;
-import com.sckj.project.service.car.ILargeCarDetailService;
-import com.sckj.project.service.car.ILargeCarRankService;
-import com.sckj.project.service.car.ILargeCarService;
-import com.sckj.project.service.car.ILargeWarnDetailService;
-import com.sckj.project.service.engineering.ILargeCameraService;
-import com.sckj.project.service.engineering.ILargePlatIssueService;
-import com.sckj.project.service.engineering.ILargePlatProjectService;
-import com.sckj.project.service.logistics.*;
-import com.sckj.project.service.service.*;
+import com.sckj.project.service.task.*;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestClientException;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.List;
 
 /**
  * @Description
@@ -43,55 +12,71 @@ import java.util.List;
  * @Date 2025/3/4 15:02
  * @Version 1.0
  */
+@Slf4j
 @Component
 public class ProjectTaskController {
 
     @Autowired
     private ServiceTaskService serviceTaskService;
-
-
     @Autowired
     private LogisticsTaskService logisticsTaskService;
-
-
     @Autowired
     private BuildingTaskService buildingTaskService;
-
-
     @Autowired
     private EngineeringTaskService engineeringTaskService;
-
-
     @Autowired
     private CarTaskService carTaskService;
 
 
-
-
+    /**
+     *  服务保障中心
+     */
     @Scheduled(cron = "0 */2 * * * ?")
     public void taskService() {
+        log.info("服务保障中心定时任务开始执行");
         serviceTaskService.myTask();
+        log.info("服务保障中心定时任务开始执行完成");
     }
 
 
+    /**
+     *  后勤资源监控
+     */
     @Scheduled(cron = "0 */2 * * * ?")
     public void taskLogistics(){
+        log.info("后勤资源监控定时任务开始执行");
         logisticsTaskService.myTask();
+        log.info("后勤资源监控定时任务开始执行完成");
     }
 
 
+    /**
+     *  楼宇运行监控
+     */
     @Scheduled(cron = "0 */2 * * * ?")
     public void taskBuilding(){
+        log.info("楼宇运行监控定时任务开始执行");
         buildingTaskService.myTask();
+        log.info("楼宇运行监控定时任务开始执行完成");
     }
 
+    /**
+     *  工程现场监控
+     */
     @Scheduled(cron = "0 */2 * * * ?")
     public void taskEngineering(){
+        log.info("工程现场监控定时任务开始执行");
         engineeringTaskService.myTask();
+        log.info("工程现场监控定时任务开始执行完成");
     }
 
+    /**
+     *  公务用车
+     */
     @Scheduled(cron = "0 */2 * * * ?")
     public void taskCar(){
+        log.info("公务用车定时任务开始执行");
         carTaskService.myTask();
+        log.info("公务用车定时任务开始执行完成");
     }
 }

+ 35 - 0
src/main/java/com/sckj/project/util/HttpRequestUtil.java

@@ -0,0 +1,35 @@
+package com.sckj.project.util;
+
+import com.sckj.project.constants.Constants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @Description
+ * @Author bqyang
+ * @Date 2025/3/7 11:33
+ * @Version 1.0
+ */
+@Component
+public class HttpRequestUtil {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    /**
+     * 发送GET请求
+     */
+    public ResponseEntity<String>  get(String url) {
+        HttpHeaders headers = new HttpHeaders();
+        headers.set(Constants.REQUEST_HEAD, AESUtil.encrypt(Constants.REQUEST_HEAD_SCR));
+        HttpEntity<String> entity = new HttpEntity<>(null, headers);
+        ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
+        return responseEntity;
+    }
+
+}

+ 11 - 40
src/main/resources/application-dev.yml

@@ -1,20 +1,21 @@
 spring:
   application:
-    name: "spring-boot-demo"
+    name: "project-syn-service"
     version: "1.0.0"
-  redis:
-    host: 127.0.0.1
-    port: 6379
-    password: 1qaz2wsx
-    database: 0
   datasource:
     dynamic:
-      primary: primaryDataSource
+      primary: master
+      type: com.alibaba.druid.pool.DruidDataSource
+      druid:
+        initial-size: 5
+        max-active: 8
+        min-idle: 3
+        max-wait: 1000
       datasource:
-        primaryDataSource:
-          url: jdbc:mysql://localhost:3306/sxgw?characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=GMT%2B8
+        master:
+          url: jdbc:mysql://localhost:3306/sxgw?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
           username: root
-          password: qwer123456
+          password: 1qaz2wsx
           driver-class-name: com.mysql.cj.jdbc.Driver
 
 mybatis-plus:
@@ -39,83 +40,53 @@ apiurl:
 
   # 服务保障中心
   accessUrl: /getServiceAccess
-
   basicsApiUrl: /getServiceBasics
-
   basicsCompanyUrl: /getServiceBasicsCompany
-
   basicsServerUrl: /getServiceBasicsServer
-
   basicsSystemUrl: /getServiceBasicsSystem
-
   healthUrl: /getServiceHealth
-
   healthIllnessUrl: /getServiceHealthIllness
-
   employeeTypeUrl: /getServiceEmployeeType
-
   employeeTypeFlowUrl: /getServiceEmployeeTypeFlow
-
   greenFoodsUrl: /getServiceGreenFoods
-
   greenSmartUrl: /getServiceGreenSmart
-
   greenSmartOtherUrl: /getServiceGreenSmartOther
-
   greenSmartRankUrl: /getServiceGreenSmartRank
-
   greenSmartSafetyUrl: /getServiceGreenSmartSafety
-
   postStationUrl: /getServicePostStation
-
   postStationChartUrl: /getServicePostStationChart
-
   propertyUrl: /getServiceProperty
-
   propertyListUrl: /getServicePropertyList
-
   propertyToolsUrl: /getServicePropertyTools
 
 
   # 楼宇运行监控
   buildingUrl: /getServiceBuilding
-
   buildingControlUrl: /getServiceBuildingControl
-
   buildingAmmeterDetailUrl: /getServiceBuildingAmmeterDetail
 
 
 
   # 工程现场监控
   engineerCameraUrl: /getServiceEngineerCamera
-
   engineerIssueUrl: /getServiceEngineerIssue
-
   engineerPlanUrl: /getServiceEngineerPlan
-
   engineerProjectUrl: /getServiceEngineerProject
 
 
   # 后勤运行监控
   logisticsHousingUrl: /getServiceLogisticsHousing
-
   logisticsUrl: /getServiceLogistics
-
   logisticsBuildingAssetUrl: /getServiceLogisticsBuildingAsset
-
   logisticsOfficeAssetUrl: /getServiceLogisticsOfficeAsset
-
   logisticsServiceAssetUrl: /getServiceLogisticsServiceAsset
 
 
 
   # 公务用车监控
   carUrl: /getServicePublicCar
-
   carChangeUrl: /getServicePublicCarChange
-
   carWarnUrl: /getServicePublicCarWarn
-
   carRankUrl: /getServicePublicCarRank
 
 

+ 91 - 2
src/main/resources/application-prod.yml

@@ -1,2 +1,91 @@
-server:
-  port: 18080
+spring:
+  application:
+    name: "project-syn-service"
+    version: "1.0.0"
+  datasource:
+    dynamic:
+      primary: master
+      type: com.alibaba.druid.pool.DruidDataSource
+      druid:
+        initial-size: 5
+        max-active: 8
+        min-idle: 3
+        max-wait: 1000
+      datasource:
+        master:
+          url: jdbc:mysql://localhost:3306/sxgw?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
+          username: root
+          password: qwer123456
+          driver-class-name: com.mysql.cj.jdbc.Driver
+
+
+mybatis-plus:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    map-underscore-to-camel-case: true
+  mapper-locations: classpath*:mapper/*.xml
+  global-config:
+    db-config:
+      id-type: auto
+
+logging:
+  level:
+    root: info
+
+
+
+# 接口地址配置
+apiurl:
+  # 接口前缀
+  prefixUrl: http://192.168.110.247:8115/synchronize
+
+  # 服务保障中心
+  accessUrl: /getServiceAccess
+  basicsApiUrl: /getServiceBasics
+  basicsCompanyUrl: /getServiceBasicsCompany
+  basicsServerUrl: /getServiceBasicsServer
+  basicsSystemUrl: /getServiceBasicsSystem
+  healthUrl: /getServiceHealth
+  healthIllnessUrl: /getServiceHealthIllness
+  employeeTypeUrl: /getServiceEmployeeType
+  employeeTypeFlowUrl: /getServiceEmployeeTypeFlow
+  greenFoodsUrl: /getServiceGreenFoods
+  greenSmartUrl: /getServiceGreenSmart
+  greenSmartOtherUrl: /getServiceGreenSmartOther
+  greenSmartRankUrl: /getServiceGreenSmartRank
+  greenSmartSafetyUrl: /getServiceGreenSmartSafety
+  postStationUrl: /getServicePostStation
+  postStationChartUrl: /getServicePostStationChart
+  propertyUrl: /getServiceProperty
+  propertyListUrl: /getServicePropertyList
+  propertyToolsUrl: /getServicePropertyTools
+
+
+  # 楼宇运行监控
+  buildingUrl: /getServiceBuilding
+  buildingControlUrl: /getServiceBuildingControl
+  buildingAmmeterDetailUrl: /getServiceBuildingAmmeterDetail
+
+
+
+  # 工程现场监控
+  engineerCameraUrl: /getServiceEngineerCamera
+  engineerIssueUrl: /getServiceEngineerIssue
+  engineerPlanUrl: /getServiceEngineerPlan
+  engineerProjectUrl: /getServiceEngineerProject
+
+
+  # 后勤运行监控
+  logisticsHousingUrl: /getServiceLogisticsHousing
+  logisticsUrl: /getServiceLogistics
+  logisticsBuildingAssetUrl: /getServiceLogisticsBuildingAsset
+  logisticsOfficeAssetUrl: /getServiceLogisticsOfficeAsset
+  logisticsServiceAssetUrl: /getServiceLogisticsServiceAsset
+
+
+
+  # 公务用车监控
+  carUrl: /getServicePublicCar
+  carChangeUrl: /getServicePublicCarChange
+  carWarnUrl: /getServicePublicCarWarn
+  carRankUrl: /getServicePublicCarRank