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 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; } }