package com.tofly.dzfp.task;

import com.tofly.dzfp.common.DzfpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
public class dzfpkpTask {

    long kp = 0, cx = 0;

    boolean tf = true;//统一控制是否执行
    @Autowired
    private DzfpService dzfpService;

    /**
     * 发票开票
     */
    @Scheduled(cron = "${fpkp.cron_expression:-}")
    //@Scheduled(cron = "${cron_expression:*/10 * * * * ?}")
    public void fpkpTask() {
        if (tf) {
            if (kp == 0) {
                dzfpService.dlztTask();
                kp++;
            }
            dzfpService.fpkpTask();
        }
    }

    /**
     * 发票开票查询
     */
    @Scheduled(cron = "${fpcx.cron_expression:-}")
    //@Scheduled(cron = "${cron_expression:0 */1 * * * ?}")
    public void fpcxTask() {
        if (tf) {
            dzfpService.fpcxTask();
        }
    }

    /**
     * 发票重推
     */
    @Scheduled(cron = "${fpct.cron_expression:-}")
    public void fpctTask() {
        if (tf) {
            dzfpService.fpctTask();
        }
    }

    /**
     * 发票重新交付
     */
    //@Scheduled(cron = "${fpcxjf.cron_expression:-}")
    public void fpcxjfTask() {
        if (tf) {
            dzfpService.fpcxjfTask();
        }
    }


    /**
     * 发票删除
     */
    @Scheduled(cron = "${fpsc.cron_expression:-}")
    public void fpscTask() {
        if (tf) {
            dzfpService.fpscTask();
        }
    }

    /**
     * 登录状态
     */
    @Scheduled(cron = "${dlzt.cron_expression:-}")
    public void dlztTask() {
        dzfpService.dlztTask();
    }

    //以下都是测试方法

    /**
     * 测试查询
     */
    //@Scheduled(cron = "${cron_expression:*/10 * * * * ?}")
    //@Scheduled(cron = "${cron_expression:00 32 16 * * ?}")
    public void fpcx() {
        if (kp == 0) {
            dzfpService.dlztTask();
            kp++;
            dzfpService.fpcx();
        }
    }

    //@Scheduled(cron = "${cron_expression:*/10 * * * * ?}")
    //@Scheduled(cron = "${cron_expression:00 34 14 * * ?}")
    public void fpsc() {
        if (kp == 0) {
            dzfpService.dlztTask();
            kp++;
            dzfpService.fpsc();
        }
    }

    // @Scheduled(cron = "${cron_expression:*/10 * * * * ?}")
    public void hzqrdcx() {
        if (kp == 0) {
            dzfpService.dlztTask();
            kp++;
            dzfpService.hzqrdcx("1399698051501002752");
            dzfpService.hzqrdcx("1399698177724383232");
            dzfpService.hzqrdcx("1399698260838834176");

            dzfpService.hzqrdcx("1399698386567168000");
            dzfpService.hzqrdcx("1399698303893245952");
            dzfpService.hzqrdcx("1399698472663646208");
            dzfpService.hzqrdcx("1399698555203354624");

            dzfpService.hzqrdcx("1399698679937884160");
            dzfpService.hzqrdcx("1399698805674610688");
        }
    }
}
