|
@@ -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);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|