package cn.wizzer.app.task.commons.ext.quartz.job;
import cn.wizzer.app.sys.modules.services.SysTaskService;
import cn.wizzer.app.web.commons.mqtt.HeartbeatServerMQTT;
import cn.wizzer.app.web.commons.mqtt.PushCallback;
import com.alibaba.fastjson.JSON;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.util.HashMap;
import java.util.Map;
@IocBean
public class IntellindustJob implements Job {
private static final Log log = Logs.get();
@Inject
protected SysTaskService sysTaskService;
@Inject
protected HeartbeatServerMQTT heartbeatServerMQTT;
public void execute(JobExecutionContext context) throws JobExecutionException {
log.info("执行发送心跳接口-start");
String taskId = context.getJobDetail().getKey().getName();
heartbeatServerMQTT.sendMessageData();
sysTaskService.update(Chain.make("exeAt", (int) (System.currentTimeMillis() / 1000)).add("exeResult", "执行成功"), Cnd.where("id", "=", taskId));
}
}
@IocBean
public class HeartbeatServerMQTT {
HeartbeatServerMQTT 的IocBean注入进来后连sysTaskService也变成空的了
之前注入
@Inject
protected PropertiesProxy conf;
在定时任务里依赖注入也都会变空的