#
Junjie
9 小时以前 14cc8925be94a6c07e8e48278afc8f2d4aa284f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.zy.core.utils;
 
import com.zy.asrs.entity.DeviceDataLog;
import com.zy.core.enums.RedisKeyType;
 
import java.util.UUID;
 
public class DeviceLogRedisKeyBuilder {
 
    public static String build(DeviceDataLog deviceDataLog) {
        String type = deviceDataLog == null || deviceDataLog.getType() == null
                ? "unknown"
                : deviceDataLog.getType();
        String deviceNo = deviceDataLog == null || deviceDataLog.getDeviceNo() == null
                ? "unknown"
                : String.valueOf(deviceDataLog.getDeviceNo());
        long millis = deviceDataLog != null && deviceDataLog.getCreateTime() != null
                ? deviceDataLog.getCreateTime().getTime()
                : System.currentTimeMillis();
        String uuid = UUID.randomUUID().toString().replace("-", "");
        return RedisKeyType.DEVICE_LOG_KEY.key + type + ":" + deviceNo + ":" + millis + ":" + uuid;
    }
}