package com.chushang.inspection.ins;

import cn.hutool.core.util.StrUtil;
import com.chushang.inspection.work.vo.InspectionConfigVO;
import com.chushang.inspection.work.vo.WrkInfoDetailsVO;
import com.chushang.oss.feign.RemoteOssService;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

/**
 * 生成 模板
 * @auther: zhao
 * @date: 2024/6/29 14:37
 */
public interface GeneratedIns {
    /**
     * 生成 word 文档所需
     */
    String SUFFIX_NAME = ".docx";
    /**
     * 应当为 Map<Long, WrkInfoDetailsVO> map 结构
     */
    List<CompletableFuture<Void>> generated(Map<Long, WrkInfoDetailsVO> wrkMaps, InspectionConfigVO insConfig, String basePath,
                                            RemoteOssService remoteOssService,
                                            TemplateService templateService,
                                            Executor executor);

    default String generateAFileName(String path, String... value) {
        StringBuilder fileName = new StringBuilder(path);
        fileName.append(File.separator);
        for (String v : value) {
            if (StrUtil.isNotEmpty(v) && v.equals(value[0])) {
                fileName.append(v);
            } else if (StrUtil.isNotEmpty(v)) {
                fileName.append("-").append(v);
            }
        }
        return fileName.append(SUFFIX_NAME).toString();
    }
}
