package com.sunda.spmsorder.schedule;

import com.sunda.spmsorder.service.IOrderTraceService;
import com.sunda.spmsorder.service.ISapProjectOaNumberService;
import com.sunda.spmsorder.service.IStorageInventoryOperationRecordService;
import com.sunda.spmswms.service.IWhsOperateLogService;
import com.sunda.spmswms.service.IWhsStorageInventoryLastMonthService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 *
 **/
@Component
//@EnableScheduling   // 1.开启定时任务
//@EnableAsync        // 2.开启多线程
public class OrderthreadScheduleTask {

//    @Autowired
//    IOrderTraceService orderTraceService;
//    
//    @Autowired
//    ISapProjectOaNumberService iSapProjectOaNumberService;
//    
//    @Autowired
//    IWhsOperateLogService iWhsOperateLogService;
//    
//    @Autowired
//    IStorageInventoryOperationRecordService iStorageInventoryOperationRecordService;
//    
//    @Autowired
//    IWhsStorageInventoryLastMonthService iWhsStorageInventoryLastMonthService;
//
//
//    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


//    @SuppressWarnings("static-access")
//	@Async
//    @Scheduled(cron = "0 */10 * * * ?")  //每15分钟执行一次
//    public void sendOrderTraceToSap() throws InterruptedException {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//        SimpleDateFormat sdf1=new SimpleDateFormat("yyyyMMdd");
//        Calendar calendar = new GregorianCalendar();
//        calendar.setTime(new Date());
//        calendar.add(calendar.DATE,-7);
//        String beginDate= sdf1.format(calendar.getTime());//往前走7天
//        String endDate = sdf.format(new Date());
//        orderTraceService.allTypeSyncSap("","",beginDate, endDate);
//    }
    
    /**
     * 获取SAP项目立项号定时任务
     * @throws InterruptedException
     */
//    @Async
//    @Scheduled(cron = "0 0 23 * * ?")  // 每天凌晨更新一次
//    public void getProjectOaNumberFromSap() throws InterruptedException {
//    	iSapProjectOaNumberService.getSapProjectOaNumberFromSap(null, null);
//    }
    
    /**
     * 每月底计算物料及交货单号的库存数量
     * @throws InterruptedException
     */
//    @Async
//    @Scheduled(cron = "0 55 23 L * ?")  // 每月底晚上23点55分执行一次
//    public void getWhsInventoryLastMonth() throws Exception {
//    	iWhsStorageInventoryLastMonthService.getWhsInventoryLastMonth();
//    }
    
    /**
     * 出入库明细同步EAM
     * @throws InterruptedException
     */
//    @Async
//    @Scheduled(cron = "0 59 11,23 * * ?")  // 每天中午11:59,晚上23:59执行一次
//    public void getOperateLogToEam() throws InterruptedException {
//    	iWhsOperateLogService.getOperateLogToEam();
//    }
    
    /**
     * 储位库存明细同步EAM
     * @throws InterruptedException
     */
//    @Async
//    @Scheduled(cron = "0 0/5 * * * ?")  // 每天五分钟执行一次
//    public void getStorageInventoryToEam() throws InterruptedException {
//    	iStorageInventoryOperationRecordService.getStorageInventoryListToEam();
//    }


}
