package task

import (
	"github.com/robfig/cron"
)

/******************************************************************************
 *
 * @Struct Name              : Start
 *-----------------------------------------------------------------------------
 *
 * @Description              : 启动定时任务
 *
 * @Author                   : zhangxin
 *
 * @Date                     : 2021-05-12
 *
 ******************************************************************************/
func Start() error {
	c := cron.New()
	var err error
	// 传递demand数据到阿里云
	//err = c.AddFunc("0 */5 * * * ?", TransferArtDemandToPortal)
	//if err != nil {
	//	return err
	//}
	// 传递demand cache数据到阿里云
	//err = c.AddFunc("0 */5 * * * ?", TransferArtDemandCacheToPortal)
	//if err != nil {
	//	return err
	//}
	//
	//err = c.AddFunc("0 0,30 * * * ?", CreateParseFromDBByTimeTask)
	//if err != nil {
	//	return err
	//}
	//
	//err = c.AddFunc("0 4,36 * * * ?", CreateParseFromDBByDayTask)
	//if err != nil {
	//	return err
	//}
	//
	//err = c.AddFunc("*/5 * * * * ?", ParseWorkOrderFromDB)
	//if err != nil {
	//	return err
	//}


	// 添加派工
	err = c.AddFunc("*/3 * * * * ?", StartApsRelease)
	if err != nil {
		return err
	}

	// 添加解析订单excel的定时任务
	//err = c.AddFunc("*/5 * * * * ?", ParseWorkOrderFromFile)
	//if err != nil {
	//	return err
	//}


	// 添加传输workOrder到Mes的定时任务
	//err = c.AddFunc("*/2 * * * * ?", TransferWorkOrderToMes)
	//if err != nil {
	//	return err
	//}
	// 添加传输serialOrder到Mes的定时任务
	//err = c.AddFunc("*/2 * * * * ?", TransferSerialOrderToMes)
	//if err != nil {
	//	return err
	//}
	//err = c.AddFunc("*/5 * * * * ?",  FeedbackFromMes)
	//if err != nil {
	//	return err
	//}
	c.Start()
	select {}
}
