package com.engine.custom.archives.corn;

import com.engine.custom.archives.service.ReceivingPushArchivesService;
import com.engine.custom.archives.service.SendingPushArchivesService;
import com.engine.custom.archives.service.SignReportPushArchivesService;
import com.engine.custom.archives.util.ArchivesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.interfaces.schedule.BaseCronJob;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/***
 * 推送档案系统定时任务
 * @author rengp
 * @date 2024/4/7
 */

public class PushArchivesCornMultiThread extends BaseCronJob {
    public String filePath = "/opt/weaver/archivesFile";
    public String Url = "http://14.1.206.240:18080/fcscloud/composite/upload";
    public String templatePath = "/opt/weaver/archivesFile/template/";
    public String reqid = "";
    public static Logger log = LoggerFactory.getLogger("Archives");


    @Override
    public void execute() {
        log.info("PushArchivesCorn====Begin========");
        Date date = ArchivesUtil.getDate();
        String dateStr = new SimpleDateFormat("yyyyMMdd").format(date);
        HashMap<String, String> param = new HashMap<>();
        param.put("filePath",filePath+ File.separator+dateStr);
        param.put("Url",Url);
        // param.put("requestid",reqid);
        param.put("templatePath",templatePath);
        ExecutorService executor = Executors.newFixedThreadPool(3);
        executor.submit(new Thread(() -> {
            ReceivingPushArchivesService receivingservice = new ReceivingPushArchivesService();
            receivingservice.setProp(param);
            receivingservice.pushArchives(param);
        }));

        executor.submit(new Thread(() -> {
            ReceivingPushArchivesService receivingservice = new ReceivingPushArchivesService();
            receivingservice.setProp(param);
            receivingservice.pushArchives(param);
        }));


        executor.submit(new Thread(() -> {
            SignReportPushArchivesService signReportservice =new SignReportPushArchivesService();
            signReportservice.setProp(param);
            signReportservice.pushArchives(param);
        }));

    }
}
