瀏覽代碼

上传updown结果到编辑目录mapping

dengsixing 3 年之前
父節點
當前提交
98112a0801

+ 13 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantFilePath.java

@@ -13,7 +13,7 @@ public class ConstantFilePath {
     // 场景
     public static final String SCENE_PATH = "/mnt/4Dkankan/scene/";
     // 场景
-    public static final String SCENE_v4_PATH = "/mnt/4Dkankan/scene_v4/";
+    public static final String SCENE_V4_PATH = "/mnt/4Dkankan/scene_v4/";
     // 代理商
     public static final String AGENT_PATH = "/mnt/4Dkankan/agent/";
     //电子发票
@@ -75,7 +75,7 @@ public class ConstantFilePath {
     /**
      * scenejson文件本地路径 V4
      */
-    public static final String SCENE_JSON_V4_PATH = SCENE_v4_PATH + "data/data%s/" + ConstantFileName.SCENE_JSON;
+    public static final String SCENE_JSON_V4_PATH = SCENE_V4_PATH + "data/data%s/" + ConstantFileName.SCENE_JSON;
 
     public static final String MEDIAINFO_PATH_FORMAT = DATABUFFER_FORMAT + ConstantFileName.MEDIA_DATAFILE;
 
@@ -124,6 +124,17 @@ public class ConstantFilePath {
 
     public static final String SCENE_CACHE = SCENE_PATH + "%s/caches/";
 
+    public static final String SCENE_DATA_PATH_V4 = SCENE_V4_PATH + "%S/data/";
+
+    public static final String SCENE_IMAGES_PATH_V4 = SCENE_V4_PATH + "%S/images/";
+
+    public static final String SCENE_VIDEOS_PATH_V4 = SCENE_V4_PATH + "%S/videos/";
+
+    public static final String SCENE_VOICES_PATH_V4 = SCENE_V4_PATH + "%S/voices/";
+
+    public static final String SCENE_USER_PATH_V4 = SCENE_V4_PATH + "%S/user/";
+
+
 
 
     public static void main(String[] args) {

+ 6 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ErrorCode.java

@@ -10,6 +10,7 @@ public enum ErrorCode {
 
     HAVE_NO_RIGHT(1001, "无权访问!"),
 
+
     AUTH_FAIL(4000, "鉴权失败!"),
     NON_TOKEN(4001, "无token,请重新登录"),
     TOKEN_ILLEGAL(4002, "token不合法"),
@@ -167,6 +168,11 @@ public enum ErrorCode {
     FAILURE_CODE_7021(7021, "场景升级失败,请稍后重试!"),
 
 
+    FAILURE_CODE_8001(8001, "订单不存在"),
+    FAILURE_CODE_8002(8002, "支付失败"),
+    FAILURE_CODE_8003(8003, "开票金额超过范围"),
+    FAILURE_CODE_8004(8004, "支付方式异常"),
+
 
 
 

+ 27 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/InternationalType.java

@@ -0,0 +1,27 @@
+package com.fdkankan.common.constant;
+
+/**
+ * 标识系统部署环境是国内服还是国际服
+ */
+public enum InternationalType {
+
+    CN("cn", "中国"),
+    ABROAD("abroad", "海外");
+
+    private String code;
+    private String message;
+
+    private InternationalType(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+}

+ 0 - 17
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/OrderConstant.java

@@ -1,17 +0,0 @@
-package com.fdkankan.common.constant;
-
-// 8001-9000 订单状态码
-public class OrderConstant {
-    public static final int FAILURE_CODE_8001 = 8001;
-    public static final String FAILURE_MSG_8001 = "订单不存在";
-
-
-    public static final int FAILURE_CODE_8002 = 8002;
-    public static final String FAILURE_MSG_8002 = "支付失败";
-
-    public static final int FAILURE_CODE_8003 = 8003;
-    public static final String FAILURE_MSG_8003 = "开票金额超过范围";
-
-    public static final int FAILURE_CODE_8004 = 8004;
-    public static final String FAILURE_MSG_8004 = "支付方式异常";
-}

+ 0 - 6
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ServerCode.java

@@ -9,12 +9,6 @@ public enum ServerCode {
 	FEIGN_REQUEST_FAILD(-4, "跨服务请求失败"),
 	SERVER_CLOSING(-5, "服务正在关闭!"),
 
-	AUTH_FAIL(3000, "鉴权失败!"),
-	NON_TOKEN(3001, "无token,请重新登录"),
-	TOKEN_ILLEGAL(3002, "token不合法"),
-	TOKEN_NOT_FOUND(3003, "用户未登录"),
-
-
 	APP_ID_ILLEGAL(3100, "非法的APP ID");
 
 	private Integer code;

+ 2 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/UploadFilePath.java

@@ -35,8 +35,8 @@ public class UploadFilePath {
     /**
      * 场景音频
      */
-    public static final String VOICE_EDIT_PATH =  "scene_edit_data/%s/voice/";
-    public static final String VOICE_VIEW_PATH =  "scene_view_data/%s/voice/";
+    public static final String VOICE_EDIT_PATH =  "scene_edit_data/%s/voices/";
+    public static final String VOICE_VIEW_PATH =  "scene_view_data/%s/voices/";
 
     public static final String SCENE_NUM_PATH = "scene/%s";
     public static final String IMG_CACHES_PATH =  "scene/%s/caches/images/";

+ 96 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/response/Result.java

@@ -0,0 +1,96 @@
+package com.fdkankan.common.response;
+
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 通用返回类,此类是V3版本的,v3版本停了后要删除
+ *
+ * @author
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Result<T> implements Serializable {
+    private static final long serialVersionUID = -1491499610244557029L;
+    public static final String SUCCESS_MSG = "操作成功";
+    public static int CODE_SUCCESS = 0;
+    public static int CODE_FAILURE = -1;
+    public static String[] NOOP = new String[]{};
+
+    /**
+     * 处理状态:0: 成功, 1: 失败
+     */
+    private int code;
+    /**
+     * 消息
+     */
+    private String msg;
+    /**
+     * 返回数据
+     */
+    private T data;
+    /**
+     * 处理成功,并返回数据
+     *
+     * @param data 数据对象
+     * @return data
+     */
+    public static Result success(Object data) {
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, data);
+    }
+    /**
+     * 处理成功
+     *
+     * @return data
+     */
+    public static Result success() {
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, NOOP);
+    }
+    /**
+     * 处理成功
+     *
+     * @param msg 消息
+     * @return data
+     */
+    public static Result success(String msg) {
+        return new Result(CODE_SUCCESS, msg, NOOP);
+    }
+    /**
+     * 处理成功
+     *
+     * @param msg  消息
+     * @param data 数据对象
+     * @return data
+     */
+    public static Result success(String msg, Object data) {
+        return new Result(CODE_SUCCESS, msg, data);
+    }
+    /**
+     * 处理失败,并返回数据(一般为错误信息)
+     *
+     * @param code 错误代码
+     * @param msg  消息
+     * @return data
+     */
+    public static Result failure(int code, String msg) {
+        return new Result(code, msg, NOOP);
+    }
+    /**
+     * 处理失败
+     *
+     * @param msg 消息
+     * @return data
+     */
+    public static Result failure(String msg) {
+        return failure(CODE_FAILURE, msg);
+    }
+
+    @Override
+    public String toString() {
+        return "JsonResult [code=" + code + ", msg=" + msg + ", data="
+                + data + "]";
+    }
+}

+ 6 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ComputerUtil.java

@@ -120,10 +120,16 @@ public class ComputerUtil {
 
             //updown文件复制一份到ecs中并去掉换行符
             if(fileJson.getIntValue("clazz") == 10){
+                // TODO: 2022/5/6 v3停机后需要删除-----------------------------------------------------------------------start
                 String updown = FileUtils.readFile(path + File.separator + "results" +File.separator+ fileName);
                 JSONObject updownJson = JSONObject.parseObject(updown);
                 FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + projectNum +
                         File.separator + fileName.replace("updown", "mapping"), updownJson.toString());
+                // TODO: 2022/5/6 v3停机后需要删除-----------------------------------------------------------------------end
+
+                String mappingOssPath = String.format(UploadFilePath.DATA_EDIT_PATH, projectNum) + fileName.replace("updown", "mapping");
+                map.put(path + File.separator + "results" + File.separator+ fileName, mappingOssPath);
+
                 continue;
             }
 

+ 80 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/DateExtUtil.java

@@ -1,7 +1,17 @@
 package com.fdkankan.common.util;
 
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
+import java.util.Set;
+import java.util.TimeZone;
+import lombok.SneakyThrows;
 
 public class DateExtUtil {
 
@@ -30,4 +40,74 @@ public class DateExtUtil {
         return gc.getTime();
     }
 
+    @SneakyThrows
+    public static void main(String[] args) {
+//        DateExtUtil.testInstant();
+        DateExtUtil.testTransferBetweenZones();
+
+
+
+
+
+
+
+
+    }
+
+    //同一时刻,不同的时区的时间展现形式不一样,但是时刻一样,也就是时间戳是一样的
+
+    public static void testOldDate(){
+        Date currDate = new Date();
+        //国际统一时间字符串格式  Wed Apr 27 16:17:30 CST 2022    CST (china standar time)
+        System.out.println(currDate.toString());
+        //本地时间字符串格式  2022-4-27 16:17:30
+        System.out.println(currDate.toLocaleString());
+        //国际统一GMT(格林威治标准时间)字符串格式  27 Apr 2022 08:17:30 GMT
+        System.out.println(currDate.toGMTString());
+
+        String[] availableIDs = TimeZone.getAvailableIDs();
+        for (String availableID : availableIDs) {
+            System.out.println(availableID);
+        }
+
+        Date bjDate = new Date();
+        System.out.println("时间戳:" + bjDate.getTime());
+        //得到纽约的时区
+        TimeZone newYorkTimeZone = TimeZone.getTimeZone("America/New_York");
+        DateFormat newYorkDateFormat = new SimpleDateFormat(dateStyle);
+        newYorkDateFormat.setTimeZone(newYorkTimeZone);
+        //纽约时间
+        System.out.println("纽约时间:" + newYorkDateFormat.format(bjDate));
+        //背景时间
+        System.out.println("北京时间:" + new SimpleDateFormat(dateStyle).format(bjDate));
+
+    }
+
+    public static void testInstant(){
+        Instant instant = Instant.ofEpochMilli(new Date().getTime());
+        Date from = Date.from(instant);
+        System.out.println(instant.toEpochMilli());
+        System.out.println(from.getTime());
+        System.out.println(instant);
+        System.out.println(from);
+
+    }
+
+    public static void testTransferBetweenZones(){
+        //获取所有时区的id
+        Set<String> availableZoneIds = ZoneId.getAvailableZoneIds();
+
+        //模拟数据库查询出来的时间
+        Instant fromdb = Instant.now();
+
+        ZonedDateTime sydney = ZonedDateTime.ofInstant(fromdb, ZoneId.of("Australia/Sydney"));
+        ZonedDateTime beijing = ZonedDateTime.ofInstant(fromdb, ZoneId.systemDefault());
+        System.out.println(sydney.format(DateTimeFormatter.ofPattern("dd-MM-yy HH:mm:ss")));
+        System.out.println(beijing.format(DateTimeFormatter.ofPattern(dateStyle)));
+        for (String availableZoneId : availableZoneIds) {
+            System.out.println(availableZoneId);
+        }
+
+    }
+
 }

+ 72 - 4
4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/oss/UploadToOssUtil.java

@@ -681,7 +681,7 @@ public class UploadToOssUtil {
 
 	/**
 	 * <p>
-	        拷贝
+	        拷贝目录
 	 * </p>
 	 * @author dengsixing
 	 * @date 2022/1/18
@@ -691,14 +691,61 @@ public class UploadToOssUtil {
 	public void copyFiles(String sourcePath, String targetPath) throws IOException {
 		StorageType storageType = StorageType.get(type);
 		switch (storageType){
-			case OSS: this.copyFilesFromAli(sourcePath, targetPath);
-			case AWS: this.copyFilesFromAws(sourcePath, targetPath);
+			case OSS:
+				this.copyFilesFromAli(sourcePath, targetPath);
+				break;
+			case AWS:
+				this.copyFilesFromAws(sourcePath, targetPath);
+				break;
 			case LOCAL: this.copyFilesFromLocal(sourcePath, targetPath);
 		}
 	}
 
 	/**
 	 * <p>
+	 拷贝文件
+	 * </p>
+	 * @author dengsixing
+	 * @date 2022/1/18
+	 * @param sourceKey
+	 * @param targetKey
+	 **/
+	public void copyObject(String sourceKey, String targetKey) throws IOException {
+		StorageType storageType = StorageType.get(type);
+		switch (storageType){
+			case OSS:
+				this.copyObjectFromAli(sourceKey, targetKey);
+				break;
+			case AWS:
+				this.copyObjectFromAws(sourceKey, targetKey);
+				break;
+		}
+	}
+
+	/**
+	 * <p>
+	 拷贝-阿里云
+	 * </p>
+	 * @author dengsixing
+	 * @date 2022/1/18
+	 * @param sourcePath
+	 * @param targetPath
+	 **/
+	public void copyObjectFromAli(String sourcePath, String targetPath) throws IOException {
+
+		// 创建OSSClient实例。
+		OSSClient ossClient = new OSSClient(point, key, secrey);
+		// 复制文件
+		log.info("开始复制:" + sourcePath);
+		ossClient.copyObject(this.bucket, sourcePath, this.bucket, targetPath);
+		log.info("复制成功:" + sourcePath);
+		ossClient.shutdown();
+	}
+
+
+
+	/**
+	 * <p>
 	 拷贝-阿里云
 	 * </p>
 	 * @author dengsixing
@@ -762,6 +809,28 @@ public class UploadToOssUtil {
 
 	/**
 	 * <p>
+	 拷贝-亚马逊
+	 * </p>
+	 * @author dengsixing
+	 * @date 2022/1/18
+	 * @param sourceKey
+	 * @param targetKey
+	 **/
+	public void copyObjectFromAws(String sourceKey, String targetKey){
+			BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrey);
+			AmazonS3 s3 = AmazonS3ClientBuilder.standard()
+				.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
+				.withRegion(Regions.EU_WEST_2)//s3 地区位置
+				.build();
+			// 复制文件
+			log.info("开始复制:" + sourceKey);
+			s3.copyObject(this.bucket, sourceKey, this.bucket, targetKey);
+			log.info("复制成功:" + sourceKey);
+			s3.shutdown();
+	}
+
+	/**
+	 * <p>
 	 拷贝-本地
 	 * </p>
 	 * @author dengsixing
@@ -882,7 +951,6 @@ public class UploadToOssUtil {
 
 	/**
 	 * 获取文件内容-亚马逊
-	 * @param bucketName
 	 * @param objectName
 	 * @return
 	 */

+ 5 - 0
4dkankan-utils-redis/src/main/java/com/fdkankan/redis/constant/RedisKey.java

@@ -114,6 +114,11 @@ public class RedisKey {
      */
     public static final String scene_upgrade_progress_num = "scene:upgrade:progress:num:%s";
 
+    /**
+     * v3版本user类型token
+     */
+    public static final String TOKEN_V3 = "token#%s";
+