瀏覽代碼

四维深巡

dengsixing 4 月之前
父節點
當前提交
53a10bd6f0
共有 2 個文件被更改,包括 33 次插入17 次删除
  1. 6 0
      pom.xml
  2. 27 17
      src/main/java/com/fdkankan/modeling/ModelingApplication.java

+ 6 - 0
pom.xml

@@ -129,6 +129,12 @@
 			<version>1.5.0</version>
 		</dependency>
 
+		<dependency>
+			<groupId>com.fdkankan</groupId>
+			<artifactId>4dkankan-utils-fyun-oss</artifactId>
+			<version>3.0.0-SNAPSHOT</version>
+		</dependency>
+
 	</dependencies>
 
 	<build>

+ 27 - 17
src/main/java/com/fdkankan/modeling/ModelingApplication.java

@@ -4,10 +4,13 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.utils.CreateObjUtil;
 import com.fdkankan.modeling.constants.SysConstants;
 import com.fdkankan.modeling.entity.BuildLog;
 import com.fdkankan.modeling.service.IBuildLogService;
+import com.fdkankan.redis.util.RedisLockUtil;
+import com.fdkankan.redis.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,8 +20,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.scheduling.annotation.EnableScheduling;
+import sun.applet.Main;
 
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
 import java.util.List;
+import java.util.Optional;
 
 import javax.annotation.Resource;
 
@@ -30,8 +38,11 @@ import javax.annotation.Resource;
 @Slf4j
 public class ModelingApplication implements CommandLineRunner {
 
-	@Autowired
-	private IBuildLogService buildLogService;
+	@Resource
+	private RedisLockUtil redisLockUtil;
+
+	@Autowired(required = false)
+	private Optional<FYunFileServiceInterface> fYunFileService;
 
 	public static void main(String[] args) {
 
@@ -45,20 +56,19 @@ public class ModelingApplication implements CommandLineRunner {
 	@Override
 	public void run(String... args) throws Exception {
 
-//		String lockPath = null;
-//		try {
-//			if(StrUtil.isNotEmpty(SysConstants.hostName)){
-//				List<BuildLog> list = buildLogService.list(new LambdaQueryWrapper<BuildLog>().eq(BuildLog::getHostName, SysConstants.hostName).eq(BuildLog::getStatus, 0).orderByDesc(BuildLog::getId));
-//				if(CollUtil.isNotEmpty(list)){
-//					BuildLog buildLog = list.get(0);
-//					lockPath = buildLog.getDataSource() + "/.lockdirectory";
-//					if(FileUtil.exist(lockPath)){
-//						FileUtil.del(lockPath);
-//					}
-//				}
-//			}
-//		}catch (Exception e){
-//			log.warn("删除上一计算中场景文件锁失败,logPath:{}", lockPath, e);
-//		}
+		log.info("fYunFileService.isPresent():{}", fYunFileService.isPresent());
+		if(fYunFileService.isPresent()){
+			//更新弹性伸缩jar包
+			boolean lock = redisLockUtil.lock("uploadModelingJar", 300);
+			if(lock){
+//				fYunFileService.get().uploadFile()
+				ProtectionDomain domain = Main.class.getProtectionDomain();
+				CodeSource codeSource = domain.getCodeSource();
+				URL location = codeSource.getLocation();
+				String jarPath = location.getPath();
+				System.out.println("Jar file path: " + jarPath);
+			}
+		}
+
 	}
 }