Browse Source

试验-成渝第三方接口
1、接口添加定时任务
2、接口添加本地禁止执行代码(测试的时候去掉)

LHB 1 week ago
parent
commit
206026e838

+ 21 - 2
blade-service/blade-business/src/main/java/org/springblade/business/scheduled/ChenYuTestScheduled.java

@@ -20,12 +20,14 @@ import org.springblade.business.scheduled.vo.ThirdLogin;
 import org.springblade.business.service.TrialCyFinishTestReportService;
 import org.springblade.business.service.TrialCyTestTypeService;
 import org.springblade.business.service.TrialCyThirdReportService;
+import org.springblade.common.utils.SystemUtils;
 import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.core.tool.utils.CollectionUtil;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.entity.ProjectInfo;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
@@ -140,7 +142,7 @@ public class ChenYuTestScheduled {
         //成功
         if (state == 1) {
             JSONObject data = (JSONObject) post.getData();
-            bladeRedis.setEx(TOKEN_REDIS_KEY, data.getString("token"), data.getLong("expireSecond"));
+            bladeRedis.setEx(TOKEN_REDIS_KEY, data.getString("token"), data.getLong("expireSecond") - 60);
             return data.getString("token");
         } else {
             log.error("---------#成渝第三方接口访问失败:" + post.getMessage());
@@ -152,7 +154,11 @@ public class ChenYuTestScheduled {
     /**
      * 获取合同段列表接口
      */
+    @Scheduled(cron = "0 0 * * * ?")
     public void getContractSectByProjCode() {
+        if(!SystemUtils.isLinux()){
+            return;
+        }
         //清空缓存
         contractCodeMap.clear();
 
@@ -224,7 +230,11 @@ public class ChenYuTestScheduled {
     /**
      * 获取标段已完成(已签章完成)的检测报告
      */
+    @Scheduled(cron = "0 0 * * * ?")
     public void getFinishTestReport() {
+        if(!SystemUtils.isLinux()){
+            return;
+        }
         String url = "/open/TestReport/GetFinishTestReport";
 
         String token = bladeRedis.get(TOKEN_REDIS_KEY);
@@ -288,7 +298,11 @@ public class ChenYuTestScheduled {
     /**
      * 获取已上传的外委检测报告/第三方检测报告/上传报告
      */
+    @Scheduled(cron = "0 0 * * * ?")
     public void getThirdReport() {
+        if(!SystemUtils.isLinux()){
+            return;
+        }
         String url = "/open/ThirdReport/GetThirdReport";
 
         String token = bladeRedis.get(TOKEN_REDIS_KEY);
@@ -354,7 +368,12 @@ public class ChenYuTestScheduled {
     /**
      * 获取检测项目树(包括自建试验、外委、第三方、上传报告)
      */
-    public void GetAllTestType() {
+    @Scheduled(cron = "0 0 * * * ?")
+    public void getAllTestType() {
+        if(!SystemUtils.isLinux()){
+            return;
+        }
+
         String url = "/open/ThirdReport/GetAllTestType";
         String token = bladeRedis.get(TOKEN_REDIS_KEY);
         if (token == null) {