李旭东
2023-11-03 a07b4b6ff1c98dcf81338bb45d59308db7c058a9
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
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());
    }
}