소스 검색

增加弹性伸缩

dengsixing 3 주 전
부모
커밋
70e9e73312

+ 14 - 5
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
 import cn.hutool.http.ContentType;
+import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -151,7 +152,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private ILinkPanService linkPanService;
     @Autowired
     private IJmgaService jmgaService;
-    @Autowired
+    @Autowired(required = false)
     private ScalingService scalingService;
     @Autowired
     private RabbitTemplate rabbitTemplate;
@@ -285,8 +286,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 mqProducer.sendByWorkQueue("modeling-call-C", message);
                 Thread.sleep(10000L);
                 //查询队列是否存在堆积(未消费数>0)
-
+                Long count = rabbitTemplate.execute(channel -> channel.messageCount("modeling-call-C"));
                 //开启弹性伸缩
+                if(Objects.nonNull(count) && count > 0){
+                    scalingService.createEcs();
+                }
             }else{
                 mqProducer.sendByWorkQueue(queueModelingCall, message);
             }
@@ -1207,9 +1211,14 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         params.put("count", 5);
         params.put("ackmode", "ack_requeue_true");
         params.put("encoding", "auto");
-        String url = "http://119.23.182.50:15672/api/queues/vhost/name/get";
-        String s = HttpUtil.get(url, params);
-        System.out.println(s);
+        String url = "http://119.23.182.50:15672/api/queues/4dkankan/modeling-call-C/get";
+//        String s = HttpUtil.post(url, params);
+//        System.out.println(s);
+        Map<String, String> map = new HashMap<>();
+        map.put("authorization", "Basic cm9vdDo0ZGtrMjAyM2N1aWt1YW4l");
+        HttpResponse execute = HttpUtil.createPost(url).addHeaders(map).body(JSON.toJSONString(params)).execute();
+        String body = execute.body();
+        System.out.println(body);
 
     }
 

+ 1 - 3
src/main/java/com/fdkankan/contro/service/impl/CommonServiceImpl.java

@@ -14,10 +14,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.PayStatus;
 import com.fdkankan.common.constant.SpaceType;
-import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.bean.SceneJsonBean;
-import com.fdkankan.contro.constant.ModelingControlRespCode;
 import com.fdkankan.contro.constant.RedisKeyExt;
 import com.fdkankan.contro.controller.DetectType;
 import com.fdkankan.contro.entity.*;
@@ -690,7 +688,7 @@ public class CommonServiceImpl implements ICommonService {
         if("local".equals(type)){//局域网版
             String fileUploadedOpKey = new StringBuilder( ConstantFilePath.OSS_PREFIX).append(sn).append(File.separator).append(fileId).append(File.separator).append(unicode).append(File.separator).append(fileUploadedOpName).toString();
             if(!fYunFileService.fileExist(fileUploadedOpKey)){
-                throw new BusinessException(ModelingControlRespCode.FILE_EMPTY_UPLOADEDOP.code(), ModelingControlRespCode.FILE_EMPTY_UPLOADEDOP.message());
+                return null;
             }
             String fileUploadedOpPath = "/oss/4dkankan/" + fileUploadedOpKey;
             List<String> fileList = FileUtil.readUtf8Lines(fileUploadedOpPath);

+ 17 - 9
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -725,12 +725,17 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         String buildType = "V2";
         Long cameraType = 10L;
 
-        Set<String> notExistsFiles = commonService.checkUploadFile(mac, fileId, folderName, fYunFileConfig.getFyunType());
-        if(CollUtil.isNotEmpty(notExistsFiles)){
-            log.error("文件缺失, unicode:{}, 缺失文件:{}", folderName, notExistsFiles);
-            throw new BusinessException(ModelingControlRespCode.FILE_EMPTY.code(), ModelingControlRespCode.FILE_EMPTY.message());
+        String fileUploadedOpName = "fileUploadedOp.cam";
+        String fileUploadedOpKey = new StringBuilder( ConstantFilePath.OSS_PREFIX).append(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append(fileUploadedOpName).toString();
+        if(fYunFileService.fileExist(fileUploadedOpKey)){
+            Set<String> notExistsFiles = commonService.checkUploadFile(mac, fileId, folderName, fYunFileConfig.getFyunType());
+            if(CollUtil.isNotEmpty(notExistsFiles)){
+                log.error("文件缺失, unicode:{}, 缺失文件:{}", folderName, notExistsFiles);
+                throw new BusinessException(ModelingControlRespCode.FILE_EMPTY.code(), ModelingControlRespCode.FILE_EMPTY.message());
+            }
         }
 
+
         if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
             log.error("data.fdage文件不存在");
             throw new BusinessException(CameraConstant.FAILURE_6009);
@@ -883,13 +888,16 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         //云目录
         StringBuilder prefixBuffer = new StringBuilder(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator);
 
-        Set<String> notExistsFiles = commonService.checkUploadFile(mac, fileId, folderName, fYunFileConfig.getFyunType());
-        if(CollUtil.isNotEmpty(notExistsFiles)){
-            log.error("文件缺失, unicode:{}, 缺失文件:{}", folderName, notExistsFiles);
-            throw new BusinessException(ModelingControlRespCode.FILE_EMPTY.code(), ModelingControlRespCode.FILE_EMPTY.message());
+        String fileUploadedOpName = "fileUploadedOp.cam";
+        String fileUploadedOpKey = new StringBuilder( ConstantFilePath.OSS_PREFIX).append(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append(fileUploadedOpName).toString();
+        if(fYunFileService.fileExist(fileUploadedOpKey)){
+            Set<String> notExistsFiles = commonService.checkUploadFile(mac, fileId, folderName, fYunFileConfig.getFyunType());
+            if(CollUtil.isNotEmpty(notExistsFiles)){
+                log.error("文件缺失, unicode:{}, 缺失文件:{}", folderName, notExistsFiles);
+                throw new BusinessException(ModelingControlRespCode.FILE_EMPTY.code(), ModelingControlRespCode.FILE_EMPTY.message());
+            }
         }
 
-
         if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
             log.error("data.fdage文件不存在");
             throw new BusinessException(CameraConstant.FAILURE_6009);