package com.pqs9900.task;

import com.pqs9900.pojo.DataInfo.TranslateState;
import com.pqs9900.service.configuration.ManaDeviceService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

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

public class JudgeTranslate implements Job {
    @Autowired
    private ManaDeviceService manaDeviceService;

    public void judgetranslate() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 2);
        Date time = calendar.getTime();
        List<TranslateState> list = manaDeviceService.judgetranslate(time);

        for (TranslateState translateState : list) {
            manaDeviceService.updateOFFlog(null, null, null, 2, translateState.getFileName(),
                    translateState.getLineindex(), new Date(), 0, 0, null);
        }
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        judgetranslate();
    }
}
