package com.zzsn.common.poi;

import com.zzsn.modules.kgj.entity.BaseDataImage;
import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class DownloadService {

    // 临时文件夹路径
    private static final String TEMPDIRECTORY = Constants.USER_HOME+Constants.FSP+"brap"+Constants.FSP
            + "download" + Constants.FSP;

    /**
     * 下载数据
     * @return
     * @throws
     * @throws
     */
    public static  String downloadArticleWordUtils( Map<String,String> mapEntity,Map<String, String> parameter,
                                                    List<BaseDataImage> baseDataImages) throws Exception {
        String fileName =  parameter.get("fileName");
        // 创建临时目录
        // System.out.println("tempDirectory = " + TEMPDIRECTORY);
        File directory = new File(TEMPDIRECTORY);
        FileUtils.forceMkdir(directory);
        String fileAbsolutePath = TEMPDIRECTORY + fileName;
//        DownloadFileUtil.exportArticleWordByPoi(mapEntity, fileAbsolutePath);
        DownloadFileUtil.exportArticleWordByPoiNew(mapEntity, fileAbsolutePath,baseDataImages);
        return fileAbsolutePath;

    }

}
