package com.sunxung.factoring.job.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.sunxung.factoring.component.util.CollectionUtil;
import com.sunxung.factoring.component.util.ElectronicSignatureUtil;
import com.sunxung.factoring.component.util.StringUtil;
import com.sunxung.factoring.entity.financing.contract.ContractElectronicInfo;
import com.sunxung.factoring.entity.financing.contract.SysCustomer;
import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractElectronicInfo;
import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractSupplementElectronicInfo;
import com.sunxung.factoring.service.customerinformation.IElectronicSignaturePersonalService;
import com.sunxung.factoring.service.entprise.IEnterpriseService;
import com.sunxung.factoring.service.financing.contract.IContractElectronicCustomerInfoService;
import com.sunxung.factoring.service.financing.contract.IContractElectronicInfoService;
import com.sunxung.factoring.service.financing.contract.ISysCustomerService;
import com.sunxung.factoring.service.purchcontractmanagement.IPurchContractSupplementElectronicInfoService;
import com.sunxung.factoring.service.purchcontractmanagement.PurchContractElectronicInfoService;
import com.sunxung.factoring.service.salescontractmanagement.ICSalesSignConfirmationService;
import com.sunxung.factoring.service.salescontractmanagement.ICSalesSupplementSignConfirmationService;
import com.sunxung.factoring.service.tradingPlatform.PlatformService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @Description : 电子签短连接失效重置任务
 * @Author : liutao
 * @Date: 2024-3-14
 */
@Component
@EnableScheduling
public class ShortLinkTaskJob {

    private static Logger log = LogManager.getLogger(ShortLinkTaskJob.class);

    @Autowired
    private ISysCustomerService sysCustomerService;

    @Autowired
    private IContractElectronicCustomerInfoService contractElectronicCustomerInfoService;

    @Autowired
    private IElectronicSignaturePersonalService electronicSignaturePersonalService;

    @Autowired
    private ICSalesSignConfirmationService salesSignConfirmationService;

    @Autowired
    private ICSalesSupplementSignConfirmationService salesSupplementSignConfirmationService;

    @Autowired
    private PurchContractElectronicInfoService purchContractElectronicInfoService;

    @Autowired
    private IPurchContractSupplementElectronicInfoService purchContractSupplementElectronicInfoService;

    @Autowired
    private IEnterpriseService enterpriseService;

    @Autowired
    private PlatformService platformService;

    /**
     * 短连接失效处理任务
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void batchProcess() {
        log.info("短链接失效重置任务执行开始...");
        sysCustomerService.urlJob();
        contractElectronicCustomerInfoService.urlJob();
        electronicSignaturePersonalService.urlJob();
        salesSignConfirmationService.urlJob();
        salesSupplementSignConfirmationService.urlJob();
        purchContractElectronicInfoService.updateShortUrl(new Date());
        purchContractSupplementElectronicInfoService.updateShortUrl(new Date());
        enterpriseService.urlJob();
        platformService.updateShortUrl(new Date());
        log.info("短链接失效重置任务执行结束...");
    }

}
