|
|
@@ -1,18 +1,96 @@
|
|
|
package com.fdkankan.task;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.task.config.SendMessage;
|
|
|
+import com.fdkankan.task.entity.TbScenePro;
|
|
|
+import com.fdkankan.task.service.TbSceneProService;
|
|
|
+import com.mybatisflex.annotation.UseDataSource;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
|
|
|
+@SpringBootTest
|
|
|
public class TestZfb {
|
|
|
|
|
|
-
|
|
|
static String dataFmt = "yyyyMMddHHmmssSSSS";
|
|
|
+ @Autowired
|
|
|
+ TbSceneProService tbSceneProService;
|
|
|
+ @Autowired
|
|
|
+ FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
+ @Autowired
|
|
|
+ SendMessage sendMessage;
|
|
|
+ /*
|
|
|
+ 5838794f37f8_(null):;/home/ubuntu/data/5838794f37f8_(null):;https://zfb-4dkankan.oss-cn-shenzhen.aliyuncs.com/appData/5838794f37f8_(null):;5838794f37f8_(null).zip:;zfb-XX3iSDdxY:;0:;THETAYP41149405.OSC:;6:;slam:;:;THETAYP41149405.OSC:;0:;V3
|
|
|
+ */
|
|
|
@Test
|
|
|
- void test2(){
|
|
|
- System.out.println(DateUtil.format(new Date(),dataFmt));
|
|
|
-// /home/ubuntu/data/5838794f37f8_(null)
|
|
|
- //202403052050160067
|
|
|
+ @UseDataSource("new-zfb")
|
|
|
+ void test2() throws Exception {
|
|
|
+ String mqMsg =
|
|
|
+ "5838794f37f8_(null):;/home/ubuntu/data/5838794f37f8_(null):;https://zfb-4dkankan.oss-cn-shenzhen.aliyuncs.com/appData/5838794f37f8_(null):;5838794f37f8_(null).zip:;zfb-XX3iSDdxY:;0:;THETAYP41149405.OSC:;6:;slam:;:;THETAYP41149405.OSC:;0:;V3";
|
|
|
+ test3(mqMsg);
|
|
|
}
|
|
|
+
|
|
|
+ private void test3(String mqMsg) throws Exception {
|
|
|
+ String dateStr = DateUtil.format(new Date(), dataFmt);
|
|
|
+ String num = null;
|
|
|
+ if(mqMsg.contains(":;")){
|
|
|
+ String[] strs = mqMsg.split(":;");
|
|
|
+ num = strs[4];
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(num)){
|
|
|
+ System.out.println("场景不存在:"+num);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ TbScenePro tbScenePro = tbSceneProService.getByNum(num);
|
|
|
+ if(tbScenePro == null){
|
|
|
+ System.out.println("场景不存在:"+num);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String oldDataSource = tbScenePro.getDataSource();
|
|
|
+ if(!oldDataSource.contains("(null)")){
|
|
|
+ System.out.println("场景路径无错,无需处理:"+num);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String oldOssPath = oldDataSource.replace("/home/ubuntu/data/","appData/");
|
|
|
+
|
|
|
+ String newDataSource = oldDataSource.replace("(null)",dateStr);
|
|
|
+ String newOssPath = oldOssPath.replace("(null)",dateStr);
|
|
|
+
|
|
|
+ String oldFileName = tbScenePro.getFilesName();
|
|
|
+ String newFileName = oldFileName.replace("(null)",dateStr);
|
|
|
+
|
|
|
+ System.out.println("oldDataSource:"+oldDataSource);
|
|
|
+ System.out.println("oldOssPath:"+oldOssPath);
|
|
|
+ System.out.println("oldFileName:"+oldFileName);
|
|
|
+ System.out.println("newDataSource:"+newDataSource);
|
|
|
+ System.out.println("newOssPath:"+newOssPath);
|
|
|
+ System.out.println("newFileName:"+newFileName);
|
|
|
+
|
|
|
+ if(fYunFileServiceInterface.fileExist(oldOssPath+"/"+oldFileName)){
|
|
|
+ System.out.println("复制旧资源");
|
|
|
+ fYunFileServiceInterface.copyFileInBucket(oldOssPath,newOssPath);
|
|
|
+ fYunFileServiceInterface.copyFileInBucket(newOssPath+"/"+oldFileName,newOssPath+"/"+newFileName);
|
|
|
+ System.out.println("删除旧资源");
|
|
|
+ fYunFileServiceInterface.deleteFolder(oldOssPath);
|
|
|
+ fYunFileServiceInterface.deleteFile(newOssPath+"/"+oldFileName);
|
|
|
+ }
|
|
|
+
|
|
|
+ tbScenePro.setDataSource(newDataSource);
|
|
|
+ tbScenePro.setFilesName(newFileName);
|
|
|
+ tbSceneProService.updateById(tbScenePro);
|
|
|
+ mqMsg = mqMsg.replace("(null)",dateStr);
|
|
|
+ System.out.println(mqMsg);
|
|
|
+ sendMessage.sendTov3Message(mqMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|