package com.sifang.modules.task;

import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.customer.Service.CustomerEntryService;
import com.sifang.modules.customer.Service.HuaRongBankCardService;
import com.sifang.modules.customer.dao.CustomerEntryDao;
import com.sifang.modules.customer.entity.CustomerEntry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * @title: HRTask
 * @Author Tan
 * @Date: 2024/7/11 13:56
 * @Version 1.0
 */
@Component
public class HRTask {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private HuaRongBankCardService huaRongBankCardService;


    @Autowired
    CustomerEntryService customerEntryService;

    @Autowired
    CustomerEntryDao customerEntryDao;

    // 每十分钟定时获取华润开卡结果
    @Scheduled(cron = "0 0/10 * * * ?")
    void getRongHuaOpenCardStatus() {
        logger.info("getRongHuaOpenCardStatus 获取开卡状态");
        long begin = System.currentTimeMillis();
        String partnerId = "04";//华融资方id
        huaRongBankCardService.activityGetOpenCardStatus(partnerId);
        long end = System.currentTimeMillis();
        logger.info("getRongHuaOpenCardStatus 定时任务结束，共耗时：[" + (end-begin) / 1000 + "]秒");
    }

   @Scheduled(cron = "0 0/10 * * * ?")
   public void getPreAuditResult(){
       logger.info("getPreAuditResult 获取预审查询结果");
       long begin = System.currentTimeMillis();
       List<Record> customerEntries = customerEntryDao.getCustomerEntryBypartnerId("04");
       if(customerEntries.size()>0){
           for (Record customerEntry : customerEntries) {
               customerEntryService.findPreauditStatus(customerEntry.getStr("id"));
           }
       }
       long end = System.currentTimeMillis();
       logger.info("getPreAuditResult 定时任务结束，共耗时：[" + (end-begin) / 1000 + "]秒");

   }


}
