浏览代码

Merge branch 'project-jmga-2.2.0-2.0.1' into project-jmga-dev

dengsixing 3 周之前
父节点
当前提交
55ecaec23f

+ 6 - 0
pom.xml

@@ -147,6 +147,12 @@
     </dependency>
 
     <dependency>
+      <groupId>com.fdkankan</groupId>
+      <artifactId>4dkankan-utils-rubber-sheeting</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
       <groupId>net.lingala.zip4j</groupId>
       <artifactId>zip4j</artifactId>
       <version>1.3.2</version>

+ 58 - 9
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;
@@ -37,10 +38,12 @@ import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.redis.util.RedisUtil;
+import com.fdkankan.rubbersheeting.ScalingService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpHeaders;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
@@ -49,6 +52,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 import java.util.Map.Entry;
 import java.util.stream.Collectors;
@@ -81,6 +85,9 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     @Value("#{'${model.3dtiles.sceneSource:}'.split(',')}")
     private List<Integer> sdTilesSceneSourceList;
 
+    @Value("#{'${elastic:userIds:}'.split(',')}")
+    private List<Long> elasticUserIds;
+
     @Value("${env:gn}")
     private String env;
 
@@ -146,6 +153,10 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private ILinkPanService linkPanService;
     @Autowired
     private IJmgaService jmgaService;
+    @Autowired(required = false)
+    private ScalingService scalingService;
+    @Autowired
+    private RabbitTemplate rabbitTemplate;
 
 
     @Override
@@ -265,7 +276,25 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 log.info("推送事件失败,param:{}", param);
             }
 
-            mqProducer.sendByWorkQueue(queueModelingCall, message);
+            boolean elastic = false;
+            if(CollUtil.isNotEmpty(elasticUserIds)){
+                ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+                if(elasticUserIds.contains(scenePlus.getUserId())){
+                    elastic = true;
+                }
+            }
+            if(elastic){
+                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);
+            }
 
             if(StrUtil.isNotEmpty(batchIds)){
                 origFileUploadBatchService.update(new LambdaUpdateWrapper<OrigFileUploadBatch>().set(OrigFileUploadBatch::getStatus, 1).in(OrigFileUploadBatch::getBatchId, batchIds.split(",")));
@@ -447,6 +476,12 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
                     this.sendFailToLaser(sceneCode);
 
+                    String statusJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, sceneCode) + "status.json";
+                    String fileContent = fYunFileService.getFileContent(statusJsonKey);
+                    JSONObject statusJson = JSON.parseObject(fileContent);
+                    statusJson.put("status", -1);
+                    fYunFileService.uploadFile(statusJson.toJSONString().getBytes(StandardCharsets.UTF_8), statusJsonKey);
+
                     Map<String, Object> param = new HashMap<>();
                     try {
                         JyUser jyUser = scenePlusService.getJyUserByNum(sceneCode);
@@ -1174,14 +1209,28 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 //            System.out.println(s + ":" + detFloorplanObj.getBoolean(s));
 //
 //        }
-        try {
-           throw new BusinessException(345, "哈哈哈");
-        }catch (Exception e){
-            if(e instanceof  BusinessException){
-                System.out.println(((BusinessException) e).getCode());
-                System.out.println(((BusinessException) e).getMessage());
-            }
-        }
+//        try {
+//           throw new BusinessException(345, "哈哈哈");
+//        }catch (Exception e){
+//            if(e instanceof  BusinessException){
+//                System.out.println(((BusinessException) e).getCode());
+//                System.out.println(((BusinessException) e).getMessage());
+//            }
+//        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("count", 5);
+        params.put("ackmode", "ack_requeue_true");
+        params.put("encoding", "auto");
+        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);