dengsixing 1 місяць тому
батько
коміт
6007c75e7d

+ 14 - 0
pom.xml

@@ -88,6 +88,14 @@
 <!--                    <groupId>org.springframework</groupId>-->
 <!--                    <artifactId>spring-web</artifactId>-->
 <!--                </exclusion>-->
+                <exclusion>
+                    <groupId>org.apache.poi</groupId>
+                    <artifactId>poi-ooxml</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.poi</groupId>
+                    <artifactId>poi</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
 
@@ -137,6 +145,12 @@
             <groupId>com.dtflys.forest</groupId>
             <artifactId>forest-spring-boot-starter</artifactId>
             <version>1.5.19</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>commons-io</groupId>
+                    <artifactId>commons-io</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>

+ 2 - 5
src/main/java/com/fdkankan/external/Application.java

@@ -1,14 +1,11 @@
 package com.fdkankan.external;
 
 import com.dtflys.forest.springboot.annotation.ForestScan;
-import com.mybatisflex.core.FlexGlobalConfig;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.ComponentScans;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 @SpringBootApplication
@@ -17,8 +14,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableScheduling
 @ComponentScan(basePackages = {"com.fdkankan.*"})
 @EnableDiscoveryClient
-public class Application {
+public class ExternalApplication {
     public static void main(String[] args) {
-        SpringApplication.run(Application.class, args);
+        SpringApplication.run(ExternalApplication.class, args);
     }
 }

+ 1 - 1
src/main/java/com/fdkankan/external/ScenePushBean.java

@@ -1,4 +1,4 @@
-package com.fdkankan.external;
+package com.fdkankan.external.bean;
 
 import lombok.AllArgsConstructor;
 import lombok.Builder;

+ 5 - 7
src/main/java/com/fdkankan/external/controller/XinxizhongxinController.java

@@ -23,18 +23,16 @@ public class XinxizhongxinController {
     private IZgxxzxPushLogService zgxxzxPushLogService;
 
     @SignVerification
-    @PostMapping("import")
-    private ResultData importExcel(@RequestParam("file")MultipartFile file) throws IOException {
+    @PostMapping("pushScene")
+    public ResultData importExcel(@RequestParam("file")MultipartFile file) throws IOException {
         xinxizhongxinService.importExcel(file);
         return ResultData.ok();
     }
 
     @SignVerification
     @PostMapping("taskList")
-    private ResultData<PageInfo<ZgxxzxPushLog>> taskList(@RequestBody TaskPageRequest request) throws IOException {
-        return ResultData.ok(xinxizhongxinService.taskList(request));
+    public ResultData<PageInfo<ZgxxzxPushLog>> taskList(@RequestBody TaskPageRequest request) throws IOException {
+        PageInfo<ZgxxzxPushLog> zgxxzxPushLogPageInfo = xinxizhongxinService.taskList(request);
+        return ResultData.ok(zgxxzxPushLogPageInfo);
     }
-
-
-
 }

+ 3 - 1
src/main/java/com/fdkankan/external/entity/ZgxxzxPushLog.java

@@ -29,7 +29,7 @@ public class ZgxxzxPushLog implements Serializable {
     @Id(keyType = KeyType.Auto)
     private BigInteger id;
 
-    @ExcelProperty("字符串标题")
+    @ExcelProperty("场景码")
     private String num;
 
     private String title;
@@ -43,4 +43,6 @@ public class ZgxxzxPushLog implements Serializable {
 
     private Date updateTime;
 
+    private String taskId;
+
 }

+ 19 - 0
src/main/java/com/fdkankan/external/httpclient/XxzxClient.java

@@ -0,0 +1,19 @@
+package com.fdkankan.external.httpclient;
+
+
+import com.dtflys.forest.annotation.Get;
+import com.dtflys.forest.annotation.Header;
+import com.dtflys.forest.annotation.Var;
+import com.fdkankan.external.response.Result;
+import com.fdkankan.web.response.ResultData;
+
+import java.util.Map;
+
+public interface XxzxClient {
+
+    @Get(url = "${url}")
+    ResultData<Integer> getDeployStatus(@Var("url") String url);
+
+
+
+}

+ 2 - 2
src/main/java/com/fdkankan/external/schedule/ScheduleJob.java

@@ -50,9 +50,9 @@ public class ScheduleJob {
 
     @Scheduled(fixedDelay = 30*1000)
     public void syncPushResult() {
-        log.info("中国文物信息中心场景推送场景结果同步开始");
+        log.info("中国文物信息中心场景推送结果同步开始");
         xinxizhongxinService.syncPushResult();
-        log.info("中国文物信息中心场景推送场景结果同步结束");
+        log.info("中国文物信息中心场景推送结果同步结束");
     }
 
 }

+ 1 - 3
src/main/java/com/fdkankan/external/service/ISceneOfflinePackagePushService.java

@@ -1,11 +1,9 @@
 package com.fdkankan.external.service;
 
-import com.fdkankan.external.ScenePushBean;
+import com.fdkankan.external.bean.ScenePushBean;
 import com.mybatisflex.core.service.IService;
 import com.fdkankan.external.entity.SceneOfflinePackagePush;
 
-import java.util.Map;
-
 /**
  * 场景离线包推送表 服务层。
  *

+ 3 - 9
src/main/java/com/fdkankan/external/service/impl/SceneOfflinePackagePushServiceImpl.java

@@ -5,9 +5,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.TimeInterval;
 import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.lang.UUID;
 import cn.hutool.core.thread.ExecutorBuilder;
-import cn.hutool.core.util.RuntimeUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ZipUtil;
 import cn.hutool.http.HttpUtil;
@@ -15,11 +13,9 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.CommonSuccessStatus;
-import com.fdkankan.common.constant.FileSizeUnitType;
 import com.fdkankan.common.constant.SceneSource;
 import com.fdkankan.common.util.DateExtUtil;
-import com.fdkankan.common.util.FileSizeUtil;
-import com.fdkankan.external.ScenePushBean;
+import com.fdkankan.external.bean.ScenePushBean;
 import com.fdkankan.external.bean.DownloadProcessBean;
 import com.fdkankan.external.bean.LaserDownloadBean;
 import com.fdkankan.external.callback.ErrorCallback;
@@ -33,7 +29,6 @@ import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.web.response.Result;
-import com.fdkankan.web.response.ResultData;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.mybatisflex.spring.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
@@ -43,7 +38,6 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.io.File;
 import java.nio.charset.Charset;
 import java.util.*;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -371,7 +365,7 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
             params.put("zipType", zipType);
             params.put("file", FileUtil.file(zipDir.concat(file)));
             log.info("开发发送第{}个压缩包", index);
-            String post = HttpUtil.post(scenePushBean.getDestUrl(), params, 60 * 60 * 1000);
+            String post = HttpUtil.post(scenePushBean.getDestUrl() + "/historyrical/scene/deploy", params, 60 * 60 * 1000);
             log.info("第{}个场景推送成功,接收端返回结果:{}", index, post);
             ++index;
         }
@@ -389,7 +383,7 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
         params.put("zipType", zipType);
         params.put("version", scenePushBean.getVersion());
         params.put("calcTime", DateExtUtil.format(scenePlusExt.getAlgorithmTime(), DateExtUtil.dateStyle8));
-        String post = HttpUtil.post(scenePushBean.getDestUrl(), params, 60 * 60 * 1000);
+        String post = HttpUtil.post(scenePushBean.getDestUrl() + "/historyrical/scene/deploy", params, 60 * 60 * 1000);
         log.info("场景推送成功,接收端返回结果:{}", post);
     }
 

+ 44 - 28
src/main/java/com/fdkankan/external/service/impl/XinxizhongxinServiceImpl.java

@@ -1,23 +1,25 @@
 package com.fdkankan.external.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.lang.UUID;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.excel.EasyExcel;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.common.constant.CommonOperStatus;
-import com.fdkankan.common.constant.CommonStatus;
+import com.fdkankan.common.constant.CommonSuccessStatus;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.external.ScenePushBean;
+import com.fdkankan.common.util.DateExtUtil;
+import com.fdkankan.external.bean.ScenePushBean;
 import com.fdkankan.external.entity.Department;
 import com.fdkankan.external.entity.Scene;
-import com.fdkankan.external.entity.ScenePlus;
 import com.fdkankan.external.entity.ZgxxzxPushLog;
+import com.fdkankan.external.httpclient.XxzxClient;
 import com.fdkankan.external.request.TaskPageRequest;
 import com.fdkankan.external.response.PageInfo;
 import com.fdkankan.external.service.*;
+import com.fdkankan.web.response.ResultData;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
@@ -25,12 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -47,6 +47,8 @@ public class XinxizhongxinServiceImpl implements XinxizhongxinService {
     private ISceneOfflinePackagePushService sceneOfflinePackagePushService;
     @Autowired
     private IDepartmentService departmentService;
+    @Resource
+    private XxzxClient xxzxClient;
 
 
     @Override
@@ -60,23 +62,24 @@ public class XinxizhongxinServiceImpl implements XinxizhongxinService {
 
         // 这里 需要指定读用哪个class去读,然后读取第一个sheet 同步读取会自动finish
         List<ZgxxzxPushLog> list = EasyExcel.read(tempFile).head(ZgxxzxPushLog.class).sheet().doReadSync();
-        if(CollUtil.isEmpty(list)){
+        if (CollUtil.isEmpty(list)) {
             throw new BusinessException(ErrorCode.SYSTEM_ERROR.code(), "excel数据有误");
         }
         List<String> numList = list.stream().map(v -> v.getNum()).collect(Collectors.toList());
         List<Scene> sceneList = sceneService.list(QueryWrapper.create().in(Scene::getSceneCode, numList).eq(Scene::getStatus, 2));
-        Map<String, Scene> dbNumMap = sceneList.stream().collect(Collectors.toMap(v->v.getSceneCode(), v->v));
+        Map<String, Scene> dbNumMap = sceneList.stream().collect(Collectors.toMap(v -> v.getSceneCode(), v -> v));
         Set<String> errorNumList = numList.stream().filter(num -> !dbNumMap.keySet().contains(num)).collect(Collectors.toSet());
-        if(CollUtil.isNotEmpty(errorNumList)){
+        if (CollUtil.isNotEmpty(errorNumList)) {
             StringBuffer sb = new StringBuffer("以下场景不存在或错误:");
-            errorNumList.stream().forEach(v->sb.append(v).append("、"));
+            errorNumList.stream().forEach(v -> sb.append(v).append("、"));
             throw new BusinessException(ErrorCode.SYSTEM_ERROR.code(), sb.toString());
         }
 
-        list.stream().forEach(v->{
+        list.stream().forEach(v -> {
             Scene scene = dbNumMap.get(v.getNum());
             v.setTitle(scene.getTitle());
             v.setStatus(CommonOperStatus.WAITING.code());
+            v.setTaskId(UUID.fastUUID().toString());
         });
         zgxxzxPushLogService.saveBatch(list);
     }
@@ -84,17 +87,17 @@ public class XinxizhongxinServiceImpl implements XinxizhongxinService {
     @Override
     public PageInfo<ZgxxzxPushLog> taskList(TaskPageRequest request) {
         QueryWrapper queryWrapper = QueryWrapper.create().orderBy(ZgxxzxPushLog::getId, false);
-        if(StrUtil.isNotEmpty(request.getNum())){
+        if (StrUtil.isNotEmpty(request.getNum())) {
             queryWrapper.like(ZgxxzxPushLog::getNum, request.getNum());
         }
-        if(StrUtil.isNotEmpty(request.getTitle())){
+        if (StrUtil.isNotEmpty(request.getTitle())) {
             queryWrapper.like(ZgxxzxPushLog::getTitle, request.getTitle());
         }
-        if(request.getStatus() == 0){
-            queryWrapper.in(ZgxxzxPushLog::getStatus, 0,2);
+        if (request.getStatus() == 0) {
+            queryWrapper.in(ZgxxzxPushLog::getStatus, 0, 2);
         }
-        if(request.getStatus() == 1){
-            queryWrapper.in(ZgxxzxPushLog::getStatus, -1,1);
+        if (request.getStatus() == 1) {
+            queryWrapper.in(ZgxxzxPushLog::getStatus, -1, 1);
         }
         Page<ZgxxzxPushLog> page = zgxxzxPushLogService.page(new Page<>(request.getPageNum(), request.getPageSize()), queryWrapper);
         return PageInfo.PageInfo(page);
@@ -104,17 +107,17 @@ public class XinxizhongxinServiceImpl implements XinxizhongxinService {
     public void pushScene() {
         List<ZgxxzxPushLog> list = zgxxzxPushLogService.list(
                 QueryWrapper.create().eq(ZgxxzxPushLog::getStatus, CommonOperStatus.WAITING.code())
-                        .orderBy(ZgxxzxPushLog::getId,true));
-        if(CollUtil.isEmpty(list)){
+                        .orderBy(ZgxxzxPushLog::getId, true));
+        if (CollUtil.isEmpty(list)) {
             return;
         }
         Department zgwwxxzx = departmentService.getByCode("zgwwxxzx");
-        if(zgwwxxzx == null){
+        if (zgwwxxzx == null) {
             return;
         }
         for (ZgxxzxPushLog zgxxzxPushLog : list) {
             ScenePushBean pushBean = ScenePushBean.builder()
-                    .taskId(UUID.fastUUID().toString())
+                    .taskId(zgxxzxPushLog.getTaskId())
                     .num(zgxxzxPushLog.getNum()).zipType("laser")
                     .version(Calendar.getInstance().getTimeInMillis())
                     .destUrl(zgwwxxzx.getDestUrl()).build();
@@ -122,7 +125,7 @@ public class XinxizhongxinServiceImpl implements XinxizhongxinService {
             try {
                 zgxxzxPushLogService.updateById(zgxxzxPushLog);
                 sceneOfflinePackagePushService.scenePushHandler(pushBean);
-            }catch (Exception e){
+            } catch (Exception e) {
                 log.error("场景推送失败,num:{}", zgxxzxPushLog.getNum(), e);
                 zgxxzxPushLog.setStatus(CommonOperStatus.FAILD.code());
                 zgxxzxPushLogService.updateById(zgxxzxPushLog);
@@ -134,13 +137,26 @@ public class XinxizhongxinServiceImpl implements XinxizhongxinService {
     public void syncPushResult() {
         List<ZgxxzxPushLog> list = zgxxzxPushLogService.list(
                 QueryWrapper.create().eq(ZgxxzxPushLog::getStatus, 2)
-                        .orderBy(ZgxxzxPushLog::getId,true));
-        if(CollUtil.isEmpty(list)){
+                        .orderBy(ZgxxzxPushLog::getId, true));
+        if (CollUtil.isEmpty(list)) {
             return;
         }
+        Department zgwwxxzx = departmentService.getByCode("zgwwxxzx");
         for (ZgxxzxPushLog zgxxzxPushLog : list) {
-
+            ResultData<Integer> resultData = xxzxClient.getDeployStatus(zgwwxxzx.getDestUrl() + "/historyrical/scene/getDeployStatus");
+            Integer status = resultData.getData();
+            if(status == CommonSuccessStatus.WAITING.code()){
+                DateTime dateTime = DateExtUtil.offsetDay(new Date(), -7);
+                if(zgxxzxPushLog.getCreateTime().before(dateTime)){//7天都还没部署成功的,值为失败
+                    zgxxzxPushLog.setStatus(CommonSuccessStatus.FAIL.code());
+                }else{
+                    continue;
+                }
+            }else{
+                zgxxzxPushLog.setStatus(status);
+            }
+            zgxxzxPushLog.setUpdateTime(null);
         }
-
+        zgxxzxPushLogService.updateBatch(list);
     }
 }

+ 3 - 3
src/main/resources/bootstrap-dev.yml

@@ -3,10 +3,10 @@ spring:
     name: 4dkankan-center-external
   cloud:
     nacos:
-      server-addr: 172.18.156.39:8848
+      server-addr: 120.24.144.164:8848
       config:
         file-extension: yaml
-        namespace: 4dkankan-v4-test
+        namespace: 4dkankan-v4-dev
         extension-configs:
           - data-id: 4dkankan-center-external.yaml
             group: DEFAULT_GROUP
@@ -19,4 +19,4 @@ spring:
             group: DEFAULT_GROUP
             refresh: true
       discovery:
-        namespace: 4dkankan-v4-test
+        namespace: 4dkankan-v4-dev

+ 3 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,3 @@
+spring:
+  profiles:
+    active: dev

+ 3 - 0
src/main/resources/mapper/external/bootstrap.yml

@@ -0,0 +1,3 @@
+spring:
+  profiles:
+    active: dev