package com.hk.NumericalCollection.task; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import com.hk.NumericalCollection.entity.DevMacBycl; import com.hk.NumericalCollection.entity.DevMachine; import com.hk.NumericalCollection.entity.MesOrderSelect; import com.hk.NumericalCollection.entity.Womdaa; import com.hk.NumericalCollection.service.*; import lombok.RequiredArgsConstructor; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.io.IOException; import java.util.ArrayList; import java.util.Date; import java.util.List; @Component @RequiredArgsConstructor public class ScheduledTasks { // private final INumericalService numericalService; // // private final DevMachineService devMachineService; // // private final DevMacByclService devMacByclService; // // private final WomdaaService womdaaService; // // private final MesOrderSelectService orderSelectService; // // private final MesNumericalService mesNumericalService; // // // /** // * 每天0点执行一次 // * 同步设备信息 // * // * @return void // * @author tjx // * @description TODO // * @date 2024/9/27 21:48 // */ // @Scheduled(cron = "0 0 0 * * SUN") // public void SoDeviceList() { // mesNumericalService.cleanWeekAgoData(); // } // // //0 0 1 * * ? * // @Scheduled(cron = "0 0 1 1/1 * ?") // public void GetMinusDaa001() { // String format = DateUtil.format(new Date(), "yyyy-MM-dd"); // List minusDaa001 = womdaaService.getMinusDaa001(format); // List list = new ArrayList<>(); // // minusDaa001.forEach(womdaa -> { // MesOrderSelect womdaaSelect = new MesOrderSelect(); // womdaaSelect.setOrderId(womdaa.getId()); // womdaaSelect.setOrderNo(womdaa.getDaa001()); // womdaaSelect.setEditDate(format); // womdaaSelect.setMachineNo(womdaa.getMachineNo()); // womdaaSelect.setIsShow(0); // womdaaSelect.setTjCount(0); // womdaaSelect.setTjTime(0.0); // list.add(womdaaSelect); // }); // // orderSelectService.saveBatch(list); // } // // @Scheduled(cron = "0 0 2 1/1 * ?") // public void getDeviceDayCount() { // DateTime oneWeekAgo = DateUtil.offsetDay(DateUtil.date(), -1); // String format = DateUtil.format(oneWeekAgo, "yyyy-MM-dd"); // try { // List list = devMachineService.list(); // for (DevMachine s : list) { // numericalService.getDeviceDayCount(s.getDevNo(), format); // } // } catch (IOException e) { // throw new RuntimeException(e); // } // } // // // /** // * 每五分钟执行一次 // * 获取设备最近的一条记录 // * // * @return void // * @author tjx // * @description TODO // * @date 2024/9/27 21:48 // */ // @Scheduled(cron = "0 0/2 * * * ?") // public void getDeviceRealTimeData() { // List list = devMachineService.list(); // list.forEach(s -> { // try { // numericalService.getDeviceRealTimeData(s.getDevNo()); // } catch (Exception e) { // throw new RuntimeException(e); // } // }); // } // // /** // * 每五分钟执行一次(与主任务错开一分钟) // * 获取设备最近的一条记录写入BYCL表 // */ // @Scheduled(cron = "30 0/2 * * * ?") // public void getDeviceRealTimeDataBycl() { // List list = devMacByclService.list(); // list.forEach(s -> { // try { // numericalService.getDeviceRealTimeDataBycl(s.getDevNo()); // } catch (Exception e) { // throw new RuntimeException(e); // } // }); // } }