|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastService; | 
|---|
|  |  |  | import com.zy.asrs.task.core.ReturnT; | 
|---|
|  |  |  | import com.zy.asrs.task.handler.WorkLogHandler; | 
|---|
|  |  |  | import org.slf4j.Logger; | 
|---|
|  |  |  | import org.slf4j.LoggerFactory; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 2020/7/7 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class WorkLogScheduler { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final Logger log = LoggerFactory.getLogger(WorkLogScheduler.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WorkLogHandler workLogHandler; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/3 * * * * ? ") | 
|---|
|  |  |  | private void execute(){ | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectToBeHistoryData(); | 
|---|
|  |  |  | if (null == wrkMast) { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectToBeHistoryData(); | 
|---|
|  |  |  | if (wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ReturnT<String> result = workLogHandler.start(wrkMast); | 
|---|
|  |  |  | if (!result.isSuccess()) { | 
|---|
|  |  |  | log.error("工作档[workNo={}]历史档处理失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | for (WrkMast wrkMast : wrkMasts) { | 
|---|
|  |  |  | ReturnT<String> result = workLogHandler.start(wrkMast); | 
|---|
|  |  |  | if (!result.isSuccess()) { | 
|---|
|  |  |  | log.error("工作档[workNo={}]历史档处理失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|