package com.thhy.staff.modules.biz.face.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.thhy.general.utils.SpringContextUtils;
|
import com.thhy.staff.config.EmqxConfig;
|
import com.thhy.staff.modules.biz.face.mapper.FaceDeviceMapper;
|
import com.thhy.staff.utils.MqUtils;
|
import java.util.List;
|
import java.util.TimerTask;
|
|
public class GetUserTask extends TimerTask {
|
|
private String prefix;
|
|
private FaceDeviceMapper faceDeviceMapper;
|
|
public FaceDeviceMapper getFaceDeviceMapper() {
|
return SpringContextUtils.getBean(FaceDeviceMapper.class);
|
}
|
|
private EmqxConfig emqxConfig;
|
|
public EmqxConfig getEmqxConfig() {
|
return SpringContextUtils.getBean(EmqxConfig.class);
|
}
|
|
public GetUserTask(String urlPrefix) {
|
this.prefix = urlPrefix;
|
}
|
|
@Override
|
public void run() {
|
JSONObject jsonObject = new JSONObject();
|
jsonObject.put("method","get_person_all");
|
|
JSONObject dataJson = new JSONObject();
|
dataJson.put("path",prefix+"allPerson");
|
jsonObject.put("data",dataJson);
|
jsonObject.put("params",new JSONObject());
|
EmqxConfig emqxConfig = getEmqxConfig();
|
FaceDeviceMapper faceDeviceMapper = getFaceDeviceMapper();
|
List<String> sns = faceDeviceMapper.queryDevSn();
|
MqUtils.createClient(emqxConfig,sns,jsonObject.toJSONString());
|
}
|
}
|