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.service.firstBranch.FirstBranchReceivingPushArchivesService;
import com.engine.custom.archives.service.firstBranch.FirstBranchSendingPushArchivesService;
import com.engine.custom.archives.service.firstBranch.FirstBranchSignReportPushArchivesService;
import com.engine.custom.archives.service.secondBranch.SecondBranchReceivingPushArchivesService;
import com.engine.custom.archives.service.secondBranch.SecondBranchSendingPushArchivesService;
import com.engine.custom.archives.service.signReport.OrgPersonPushArchivesService;
import com.engine.custom.archives.service.signReport.PetitionPushArchivesService;
import com.engine.custom.archives.util.ArchivesUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;


import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

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

public class PushArchivesCorn 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 endTime = "7";
    public String reqid = "";
    public static Logger log = LoggerFactory.getLogger("Archives");

    ReceivingPushArchivesService receivingservice = new ReceivingPushArchivesService();
    SendingPushArchivesService sendingservice = new SendingPushArchivesService();
    SignReportPushArchivesService signReportservice =new SignReportPushArchivesService();

    FirstBranchReceivingPushArchivesService firstBranchReceivingPushArchivesService =new FirstBranchReceivingPushArchivesService();
    FirstBranchSendingPushArchivesService firstBranchSendingPushArchivesService =new FirstBranchSendingPushArchivesService();
    FirstBranchSignReportPushArchivesService firstBranchSignReportPushArchivesService =new FirstBranchSignReportPushArchivesService();
    SecondBranchReceivingPushArchivesService secondBranchReceivingPushArchivesService =new SecondBranchReceivingPushArchivesService();
    SecondBranchSendingPushArchivesService secondBranchSendingPushArchivesService =new SecondBranchSendingPushArchivesService();
    OrgPersonPushArchivesService orgPersonPushArchivesService =  new OrgPersonPushArchivesService();
    PetitionPushArchivesService petitionPushArchivesService = new PetitionPushArchivesService();

    @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("endTime", endTime);
        // param.put("requestid",reqid);
        param.put("templatePath",templatePath);
        sendingservice.setProp(param);
        sendingservice.pushArchives(param);
        signReportservice.setProp(param);
        signReportservice.pushArchives(param);
        receivingservice.setProp(param);
        receivingservice.pushArchives(param);
        firstBranchReceivingPushArchivesService.setProp(param);
        firstBranchReceivingPushArchivesService.pushArchives(param);
        firstBranchSendingPushArchivesService.setProp(param);
        firstBranchSendingPushArchivesService.pushArchives(param);
        firstBranchSignReportPushArchivesService.setProp(param);
        firstBranchSignReportPushArchivesService.pushArchives(param);
        secondBranchReceivingPushArchivesService.setProp(param);
        secondBranchReceivingPushArchivesService.pushArchives(param);
        secondBranchSendingPushArchivesService.setProp(param);
        secondBranchSendingPushArchivesService.pushArchives(param);
        orgPersonPushArchivesService.setProp(param);
        orgPersonPushArchivesService.pushArchives(param);
        petitionPushArchivesService.setProp(param);
        petitionPushArchivesService.pushArchives(param);
    }
}
