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