CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.ld.igds.timer;
 
import com.ld.igds.constant.Constant;
import com.ld.igds.grain.view.SysGrainManager;
import com.ld.igds.models.Depot;
import com.ld.igds.models.TimingDepot;
import com.ld.igds.timer.service.ITimerService;
import com.ld.igds.view.service.HDepotService;
 
import lombok.extern.slf4j.Slf4j;
 
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * 粮情定时检测执行
 */
@Slf4j
@Service(Constant.JOB_BEAN_GRAIN)
public class JobGrainService implements Job {
 
    @Autowired
    private ITimerService timerService;
    @Autowired
    private HDepotService depotService;
    @Autowired
    private SysGrainManager sysGrainManager;
 
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("=======================开始执行定时粮情检测=============================");
 
        // 获取JOB的ID
        String key = context.getTrigger().getKey().getName();
        String jobId = key.substring(7);
 
        //根据当前JOB获取设备列表
        List<TimingDepot> list = timerService.getDepotByTimerId(jobId);
        if (null == list || list.isEmpty()) {
            log.info(context.getJobDetail().getDescription() + "该方案下没有配置需要执行的仓库,定时检测失败……");
            return;
        }
 
        // 获取到需要操作的仓库列表
        List<Depot> depots = depotService.getDepotByTimer(list);
        if (null == depots || depots.isEmpty()) {
            log.info(context.getJobDetail().getDescription() + "该方案下没有获取到仓库信息,定时检测失败……");
            return;
        }
 
        String msg  = sysGrainManager.batchCheck(depots);
 
        log.info("=======================定时检测结束,结果============================{}",msg);
    }
 
}