package com.sz.admin.monitor.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

public class ImageNameUtils {

    private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");

    /**
     * 生成标准图片文件名
     *
     * @param type     业务类型 (如: ALARM, CAPTURE)
     * @param deviceId 设备ID
     * @return 文件名 (不含路径)
     */
    public static String generateFileName(String type, Long deviceId) {
        String timeStr = LocalDateTime.now().format(TIME_FORMAT);
        String uuid = UUID.randomUUID().toString().replace("-", "").substring(0, 8);
        return String.format("%s_%d_%s_%s.jpg", type, deviceId, timeStr, uuid);
    }
    public static String generateFileName(String type, String suffix) {
        String timeStr = LocalDateTime.now().format(TIME_FORMAT);
        String uuid = UUID.randomUUID().toString().replace("-", "").substring(0, 8);
        return String.format("%s_%s_%s%s", type, timeStr, uuid, suffix);
    }
    public static void main(String[] args) {
        System.out.println(generateFileName("ALARM", 10086L));
    }
}