yangys
2024-09-27 26f8e5990686bdba2119024a260d986266506757
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
package com.qianwen.mdc.collect.job;
 
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
 
import java.util.Collections;
 
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.mdc.collect.service.DeviceStateFixPointService;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/*
 * xxlJob 构建工位状态明日固定点(每小时一个点),外加根据班制和生产日历的时间加入固定点
 */
@Component
public class StateFixPointJob {
    private static final Logger log = LoggerFactory.getLogger(StateFixPointJob.class);
    @Autowired
    private DeviceStateFixPointService stateFixPointService;
 
    @XxlJob("stateFixPointJobHandler")
    public ReturnT<String> stateFixPointJobHandler(String param) throws Exception {
        DateTime dateTime = DateTime.now().offset(DateField.DAY_OF_MONTH, 1);//+1天,即明天的数据
        if (Func.isNotEmpty(param)) {
            dateTime = new DateTime(DateUtil.parse(param));
        }
        try {
            XxlJobLogger.log("设置固定点开始", new Object[]{dateTime.toString()});
            this.stateFixPointService.deviceStateFixPoint(dateTime, Collections.emptyList());
            XxlJobLogger.log("设置固定点结束", new Object[]{dateTime.toString()});
        } catch (Exception ex) {
            log.info("固定打点发生异常" + ex);
        }
        return ReturnT.SUCCESS;
    }
}