|
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.base.util.FileUtil;
|
|
import com.fdkankan.base.util.FileUtil;
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
import com.fdkankan.common.constant.ConstantUrl;
|
|
import com.fdkankan.common.constant.ConstantUrl;
|
|
-import com.fdkankan.common.jedis.JedisUtil;
|
|
|
|
import com.fdkankan.common.jedis.KeyConsts;
|
|
import com.fdkankan.common.jedis.KeyConsts;
|
|
import com.fdkankan.common.push.Demo;
|
|
import com.fdkankan.common.push.Demo;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.common.util.FileUtils;
|
|
@@ -24,6 +23,7 @@ import com.fdkankan.scene.util.CreateObjUtil;
|
|
import com.fdkankan.user.entity.UserEntity;
|
|
import com.fdkankan.user.entity.UserEntity;
|
|
import com.fdkankan.user.service.IUserService;
|
|
import com.fdkankan.user.service.IUserService;
|
|
import com.fdkankan.utils.DingDingUtils;
|
|
import com.fdkankan.utils.DingDingUtils;
|
|
|
|
+import com.fdkankan.utils.GYUploadToOssUtil;
|
|
import com.rabbitmq.client.Channel;
|
|
import com.rabbitmq.client.Channel;
|
|
import com.taobao.api.ApiException;
|
|
import com.taobao.api.ApiException;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import lombok.extern.log4j.Log4j2;
|
|
@@ -57,6 +57,12 @@ public class BuildSceneReceiver {
|
|
@Autowired
|
|
@Autowired
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private GYUploadToOssUtil gYUploadToOssUtil;
|
|
|
|
+
|
|
|
|
+ @Value("${gy.company.id}")
|
|
|
|
+ private String gyCompanyId;
|
|
|
|
+
|
|
@Value("${oss.type}")
|
|
@Value("${oss.type}")
|
|
private String ossType;
|
|
private String ossType;
|
|
|
|
|
|
@@ -76,6 +82,7 @@ public class BuildSceneReceiver {
|
|
SysConstants.SYSTEM_BUILDING = false;
|
|
SysConstants.SYSTEM_BUILDING = false;
|
|
channel.basicNack(deliveryTag, true, true);
|
|
channel.basicNack(deliveryTag, true, true);
|
|
log.error("服务实例:{} 正在关闭,退出构建!", SysConstants.hostName);
|
|
log.error("服务实例:{} 正在关闭,退出构建!", SysConstants.hostName);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if (ObjectUtils.isEmpty(content)) {
|
|
if (ObjectUtils.isEmpty(content)) {
|
|
SysConstants.SYSTEM_BUILDING = false;
|
|
SysConstants.SYSTEM_BUILDING = false;
|
|
@@ -129,21 +136,16 @@ public class BuildSceneReceiver {
|
|
|
|
|
|
// 初始化日志参数
|
|
// 初始化日志参数
|
|
logRecord.setSceneNum(strs[4]);
|
|
logRecord.setSceneNum(strs[4]);
|
|
- String dataSource = strs[1];
|
|
|
|
|
|
+ String dataSource;
|
|
|
|
+ if (strs[2].contains("https:")) {
|
|
|
|
+ dataSource = strs[1];
|
|
|
|
+ } else {
|
|
|
|
+ dataSource = strs[1].substring(0, strs[1].lastIndexOf("/") + 1).concat(strs[2]);
|
|
|
|
+ }
|
|
logRecord.setDataSource(dataSource);
|
|
logRecord.setDataSource(dataSource);
|
|
|
|
|
|
- // 设置缓存锁
|
|
|
|
- String key = KeyConsts.SCENE_BUILDING + strs[4];
|
|
|
|
- // 获取缓存锁,防止重复消费
|
|
|
|
- Long building = JedisUtil.incrBy(key, 1);
|
|
|
|
// 记录入库
|
|
// 记录入库
|
|
modelingLogService.insert(logRecord);
|
|
modelingLogService.insert(logRecord);
|
|
- if (building.compareTo(1L) != 0) {
|
|
|
|
- log.error("服务:{},重复构建:{}",SysConstants.hostName,logRecord.getSceneNum());
|
|
|
|
- throw new BuildException(BuildStatusEnum.REPEAT);
|
|
|
|
- }else{
|
|
|
|
- JedisUtil.expire(key,SysConstants.modelTimeOut);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void buildScene(String content, BuildLog logRecord) throws Exception {
|
|
private void buildScene(String content, BuildLog logRecord) throws Exception {
|
|
@@ -456,8 +458,16 @@ public class BuildSceneReceiver {
|
|
} else {
|
|
} else {
|
|
userService.updateUserUsedSpaceBySceneNum(userEntity.getId(), projectNum);
|
|
userService.updateUserUsedSpaceBySceneNum(userEntity.getId(), projectNum);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ // 上传公元数据
|
|
|
|
+ if (!ObjectUtils.isEmpty(scene.getUserId())) {
|
|
|
|
+ UserEntity sceneUser = userService.findById(scene.getUserId());
|
|
|
|
+ if (!ObjectUtils.isEmpty(sceneUser.getCompanyId()) && gyCompanyId.equals(sceneUser.getCompanyId()+"")) {
|
|
|
|
+ gYUploadToOssUtil.uploadMulFiles(map);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
|
|
CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -466,8 +476,6 @@ public class BuildSceneReceiver {
|
|
log.info("服务{} 计算结束:{},计算状态:{}", SysConstants.hostName, buildLog.getSceneNum(),buildStatusEnum.getDesc());
|
|
log.info("服务{} 计算结束:{},计算状态:{}", SysConstants.hostName, buildLog.getSceneNum(),buildStatusEnum.getDesc());
|
|
// 释放缓存锁
|
|
// 释放缓存锁
|
|
if(!buildStatusEnum.equals(BuildStatusEnum.REPEAT)){
|
|
if(!buildStatusEnum.equals(BuildStatusEnum.REPEAT)){
|
|
- JedisUtil.del(KeyConsts.SCENE_BUILDING + buildLog.getSceneNum());
|
|
|
|
-
|
|
|
|
SceneProEntity scene = sceneProService.findBySceneNum(buildLog.getSceneNum());
|
|
SceneProEntity scene = sceneProService.findBySceneNum(buildLog.getSceneNum());
|
|
if(scene != null){
|
|
if(scene != null){
|
|
JSONObject statusJson = new JSONObject();
|
|
JSONObject statusJson = new JSONObject();
|