75 lines
2.6 KiB
Java
Raw Normal View History

2023-02-16 14:17:36 +08:00
package com.zhgd.xmgl.async;
2023-04-13 18:26:27 +08:00
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
2023-02-16 14:17:36 +08:00
import com.zhgd.xmgl.push.service.UniPushService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
2023-04-13 18:26:27 +08:00
import java.util.List;
import java.util.stream.Collectors;
2023-02-16 14:17:36 +08:00
/**
* @program: wisdomSite
* @description: 异步通知到前端的代码处理
* @author: Mr.Peng
* @create: 2022-04-20 14:09
**/
@Slf4j
@Component
public class AsyncAiAnalyse {
@Autowired
private UniPushService uniPushService;
2023-04-13 18:26:27 +08:00
@Autowired
private ISystemUserService systemUserService;
2023-02-16 14:17:36 +08:00
@Value("${mqtt-scope}")
private String scope;
@Async("taskExecutor")
public String getTitleByAlarmType(Integer alarmType) {
//1-烟感、2-明火、3-人员倒地、4-未戴安全帽、5-区域入侵、6-越界入侵、7-人员聚集衣 8-反光衣、9-裸土覆盖,13口罩识别,14徘徊预警,15物体滞留监测,16绊线监测
String title = "";
if (alarmType == 1) {
title = "烟感报警";
} else if (alarmType == 2) {
title = "明火报警";
} else if (alarmType == 3) {
title = "人员倒地报警";
} else if (alarmType == 4) {
title = "未戴安全帽报警";
} else if (alarmType == 5) {
title = "区域入侵报警";
} else if (alarmType == 6) {
title = "越界入侵报警";
} else if (alarmType == 7) {
title = "人员聚集衣报警";
} else if (alarmType == 8) {
title = "反光衣报警";
} else if (alarmType == 9) {
title = "裸土覆盖报警";
} else if (alarmType == 13) {
title = "口罩识别报警";
} else if (alarmType == 14) {
title = "徘徊预警";
} else if (alarmType == 15) {
title = "物体滞留监测";
} else if (alarmType == 16) {
title = "绊线监测";
}
return title;
}
2023-04-13 18:26:27 +08:00
@Async("taskExecutor")
public void pushNotice(List<String> sn, String title, String content, String payload) {
List<String> alias = systemUserService.list(Wrappers.<SystemUser>lambdaQuery().in(SystemUser::getSn, sn)).stream().map(u -> u.getUserId()).collect(Collectors.toList());
uniPushService.pushToSingleByAlias(alias, title, content, payload);
}
2023-02-16 14:17:36 +08:00
}