admin
2024-02-21 2272213fea7ab9ea6250eefad55bb113ce2b1837
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package com.ruoyi.task;
 
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.activeMQ.vo.CameraControlVO;
import com.ruoyi.aibrain.domain.AiAlarmInfo;
import com.ruoyi.aibrain.domain.AiCamera;
import com.ruoyi.aibrain.domain.Point;
import com.ruoyi.aibrain.service.IAiAlarmInfoService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.Threads;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.config.ActiveManager;
import com.ruoyi.framework.websocket.WebSocketUsers;
import com.ruoyi.utils.Base64Util;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import javax.jms.Destination;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
/**
 * 定时任务调度测试
 *
 * @author ruoyi
 */
@EnableScheduling
@Component("aiBrainTask")
public class AiBrainTask {
 
    private static final Logger logger = LoggerFactory.getLogger(Threads.class);
 
    private static BeanCopier copier = BeanCopier.create(AiCamera.class, CameraControlVO.class, false);
 
    @Autowired
    private static ActiveManager activeManager;
 
    @Autowired
    private IAiAlarmInfoService aiAlarmInfoService;
 
    public void indexWebSocket() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        AiAlarmInfo aiAlarmInfo = new AiAlarmInfo();
        Map<String, Object> params = aiAlarmInfo.getParams();
        params.put("beginTime", format.format(DateUtils.getFistDayInYear(Calendar.getInstance().get(Calendar.YEAR))));
        params.put("endTime",format.format(new Date()));
        aiAlarmInfo.setParams(params);
        int alarmSanWei = aiAlarmInfoService.countSanWeiAlarm(aiAlarmInfo);//三违
        int alarmYinHuan = aiAlarmInfoService.countYinHuanAlarm(aiAlarmInfo);//隐患
        int alarmAll = aiAlarmInfoService.countAllAlarm(aiAlarmInfo);//智能识别仪
        int alarmYear = aiAlarmInfoService.countAlarmInYear();//年度报警
        int alarmMonth = aiAlarmInfoService.countAlarmInMonth();//月度报警
        List<Map<String,Object>> alarmTop = aiAlarmInfoService.selectCountAlarmByRegion();//本年区域报警Top排序
        List<Map<String,Object>> alarmSmall = aiAlarmInfoService.selectCountAlarmBySmall();//本年报警类型统计
        List<AiAlarmInfo> aiAlarmInfos = aiAlarmInfoService.selectAlarmInfoNew();//实时报警:未处理的最新十条
 
        JSONObject indexJson = new JSONObject();
        indexJson.put("alarmSanWei",alarmSanWei);
        indexJson.put("alarmYinHuan",alarmYinHuan);
        indexJson.put("alarmAll",alarmAll);
        indexJson.put("alarmYear",alarmYear);
        indexJson.put("alarmMonth",alarmMonth);
        indexJson.put("alarmTop",alarmTop);
        indexJson.put("alarmSmall",alarmSmall);
        indexJson.put("aiAlarmInfos",aiAlarmInfos);
        WebSocketUsers.sendMessageToUsersByText(indexJson.toJSONString());
    }
 
//    /**
//     * 启动AI识别设备
//     */
//    @Scheduled(fixedDelay = 50)
//    public static void startCamera1() {
//        activeManager = SpringUtils.getBean(ActiveManager.class);
//        ActiveMQTopic videoRealTopic19216820271 = new ActiveMQTopic("VideoRealTopic1921683036");//P2P模式单个消费者
//        Point point=new Point();
//        try {
//            String s = Base64Util.fileToBase64("C:\\Users\\Administrator\\Desktop\\a.png");
//            point.setCameraId("1");
//            point.setName("大倾角皮带机头");
//            point.setPictureBase64(s);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        activeManager.send(videoRealTopic19216820271, JSON.toJSONString(point));
////        logger.info("cameraControlQueue队列:"+JSON.toJSONString(point));
//    }
//
//    /**
//     * 启动AI识别设备
//     */
//    @Scheduled(fixedDelay = 50)
//    public static void startCamera2() {
//        activeManager = SpringUtils.getBean(ActiveManager.class);
//        ActiveMQTopic videoRealTopic19216820271 = new ActiveMQTopic("VideoRealTopic1921683036");//P2P模式单个消费者
//        Point point=new Point();
//        try {
//            String s = Base64Util.fileToBase64("C:\\Users\\Administrator\\Desktop\\b.png");
//            point.setCameraId("1");
//            point.setName("大倾角皮带机头");
//            point.setPictureBase64(s);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        activeManager.send(videoRealTopic19216820271, JSON.toJSONString(point));
////        logger.info("cameraControlQueue队列:"+JSON.toJSONString(point));
//    }
//
//    /**
//     * 启动AI识别设备
//     */
//    @Scheduled(fixedDelay = 50)
//    public static void startCamera3() {
//        activeManager = SpringUtils.getBean(ActiveManager.class);
//        ActiveMQTopic videoRealTopic19216820271 = new ActiveMQTopic("VideoRealTopic1921683041");//P2P模式单个消费者
//        Point point=new Point();
//        try {
//            String s = Base64Util.fileToBase64("C:\\Users\\Administrator\\Desktop\\1.png");
//            point.setCameraId("2");
//            point.setName("大倾角皮带机尾");
//            point.setPictureBase64(s);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        activeManager.send(videoRealTopic19216820271, JSON.toJSONString(point));
////        logger.info("cameraControlQueue队列:"+JSON.toJSONString(point));
//    }
//
//    /**
//     * 启动AI识别设备
//     */
//    @Scheduled(fixedDelay = 50)
//    public static void startCamera4() {
//        activeManager = SpringUtils.getBean(ActiveManager.class);
//        ActiveMQTopic videoRealTopic19216820271 = new ActiveMQTopic("VideoRealTopic1921683041");//P2P模式单个消费者
//        Point point=new Point();
//        try {
//            String s = Base64Util.fileToBase64("C:\\Users\\Administrator\\Desktop\\2.png");
//            point.setCameraId("2");
//            point.setName("大倾角皮带机尾");
//            point.setPictureBase64(s);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        activeManager.send(videoRealTopic19216820271, JSON.toJSONString(point));
////        logger.info("cameraControlQueue队列:"+JSON.toJSONString(point));
//    }
 
 
}