|
@@ -1,5 +1,9 @@
|
|
|
package com.fdkankan.modeling.receiver;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.io.watch.WatchMonitor;
|
|
|
+import cn.hutool.core.io.watch.Watcher;
|
|
|
+import cn.hutool.core.lang.Console;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.constant.ModelingBuildStatus;
|
|
@@ -29,6 +33,8 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.WatchEvent;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
@@ -53,6 +59,8 @@ public class RabbitMqListener {
|
|
|
private String queueModelingCall;
|
|
|
@Value("${queue.modeling.modeling-post}")
|
|
|
private String queueModelingPost;
|
|
|
+ @Value("${queue.modeling.modeling-progress-notice}")
|
|
|
+ private String modelingProgressNotice;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
@@ -222,6 +230,10 @@ public class RabbitMqListener {
|
|
|
String skyboxType = dataMap.get("skyboxType");
|
|
|
|
|
|
ComputerUtil.createProjectAndDataFile(path,num, splitType, skyboxType,null,null);
|
|
|
+
|
|
|
+ //开始计算前发送mq消息,监听project.json文件的变化以更新进度条
|
|
|
+ rabbitMqProducer.sendByWorkQueue(modelingProgressNotice, message);
|
|
|
+
|
|
|
//计算模型并返回需要上传oss的文件集合
|
|
|
ComputerUtil.computer(num, path, buildType);
|
|
|
|
|
@@ -230,6 +242,42 @@ public class RabbitMqListener {
|
|
|
return ModelingBuildStatus.SUCCESS;
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ File file = FileUtil.file("D:\\test\\111.txt");
|
|
|
+//这里只监听文件或目录的修改事件
|
|
|
+ WatchMonitor watchMonitor = WatchMonitor.create(file);
|
|
|
+ watchMonitor.setWatcher(new Watcher(){
|
|
|
+ @Override
|
|
|
+ public void onCreate(WatchEvent<?> event, Path currentPath) {
|
|
|
+ Object obj = event.context();
|
|
|
+ Console.log("创建:{}-> {}", currentPath, obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onModify(WatchEvent<?> event, Path currentPath) {
|
|
|
+ Object obj = event.context();
|
|
|
+ Console.log("修改:{}-> {}", currentPath, obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDelete(WatchEvent<?> event, Path currentPath) {
|
|
|
+ Object obj = event.context();
|
|
|
+ Console.log("删除:{}-> {}", currentPath, obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onOverflow(WatchEvent<?> event, Path currentPath) {
|
|
|
+ Object obj = event.context();
|
|
|
+ Console.log("Overflow:{}-> {}", currentPath, obj);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ watchMonitor.start();
|
|
|
+ for (int i= 0; i< 10; i++ ){
|
|
|
+ System.out.println(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void afterBuild(BuildSceneCallMessage message, BuildSceneResultBean buildSceneResult, BuildLog buildLog){
|
|
|
ModelingBuildStatus buildStatus = null;
|
|
|
try {
|
|
@@ -303,6 +351,7 @@ public class RabbitMqListener {
|
|
|
.hostName(SysConstants.hostName)
|
|
|
.build();
|
|
|
buildResult.setBuildContext(message.getBuildContext());
|
|
|
+ buildResult.setExt(message.getExt());
|
|
|
rabbitMqProducer.sendByWorkQueue(buildSceneResult.getResultQueueName(),buildResult);
|
|
|
}
|
|
|
|