| package com.zy.asrs.task; | 
|   | 
| import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
| import com.zy.asrs.entity.WrkMast; | 
| import com.zy.asrs.service.WrkMastLogService; | 
| import com.zy.asrs.service.WrkMastService; | 
| import com.zy.core.enums.WrkStsType; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.scheduling.annotation.Scheduled; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import java.util.List; | 
|   | 
|   | 
| @Component | 
| @Slf4j | 
| public class WrkMastScheduler { | 
|   | 
|     @Autowired | 
|     private WrkMastService wrkMastService; | 
|     @Autowired | 
|     private WrkMastLogService wrkMastLogService; | 
|   | 
|     @Scheduled(cron = "0/1 * * * * ? ") | 
|     private void executeMove(){ | 
|         List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_MOVE.sts)); | 
|         if (wrkMasts.isEmpty()) { | 
|             return; | 
|         } | 
|   | 
|         for (WrkMast wrkMast : wrkMasts) { | 
|             // 保存工作主档历史档 | 
|             if (!wrkMastLogService.save(wrkMast.getWrkNo())) { | 
|                 log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo()); | 
|             } | 
|             // 删除工作主档 | 
|             if (!wrkMastService.deleteById(wrkMast)) { | 
|                 log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo()); | 
|             } | 
|         } | 
|     } | 
|   | 
|     @Scheduled(cron = "0/1 * * * * ? ") | 
|     private void executeCharge(){ | 
|         List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_CHARGE.sts)); | 
|         if (wrkMasts.isEmpty()) { | 
|             return; | 
|         } | 
|   | 
|         for (WrkMast wrkMast : wrkMasts) { | 
|             // 保存工作主档历史档 | 
|             if (!wrkMastLogService.save(wrkMast.getWrkNo())) { | 
|                 log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo()); | 
|             } | 
|             // 删除工作主档 | 
|             if (!wrkMastService.deleteById(wrkMast)) { | 
|                 log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo()); | 
|             } | 
|         } | 
|     } | 
|   | 
| } |