d"> 43
44
			CommonResponse runningResult = aiTaskCommand.aiIdenLogTriggerEvent(aiIdenLogRequest);
45
			log.info("runningResult: \n{}", JsonUtils.toJSONStringByDateFormat(runningResult, true));
46
			Assert.assertTrue(runningResult.isSuccess());
47
48
		} catch (Exception e) {
49
			log.error("kafka消费异常" + e.getMessage(), e);
50
		} finally {
51
			ack.acknowledge();// 手动提交偏移量
52
		}
53
	}
54
}

+ 0 - 54
security-protection-service/src/main/java/com/ai/bss/security/protection/service/task/AIAttendanceKafkaTask.java

@ -1,54 +0,0 @@
1
package com.ai.bss.security.protection.service.task;
2
3
import org.apache.kafka.clients.consumer.ConsumerRecord;
4
import org.junit.Assert;
5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.kafka.annotation.KafkaListener;
7
import org.springframework.kafka.support.Acknowledgment;
8
import org.springframework.stereotype.Component;
9
10
import com.ai.abc.api.model.CommonRequest;
11
import com.ai.abc.api.model.CommonResponse;
12
import com.ai.abc.util.JsonUtils;
13
import com.ai.bss.work.safety.model.AiIdenLog;
14
import com.ai.bss.work.safety.service.api.AiTaskCommand;
15
import com.alibaba.fastjson.JSON;
16
import com.alibaba.fastjson.TypeReference;
17
18
import lombok.extern.slf4j.Slf4j;
19
20
/**
21
 * 人脸识别事件触发考勤
22
 * @author konghl@asiainfo.com
23
 * 2020-12-14
24
 */
25
@Component
26
@Slf4j
27
public class AIAttendanceKafkaTask {
28
29
	@Autowired
30
	private AiTaskCommand aiTaskCommand;
31
32
	@KafkaListener(containerFactory = "kafkaBatchListener3", topics = "${kafka.topic.alarm:Topic_IoT_IndividualAlarm}", groupId = "alarm_group")
33
	public void alarmListener(ConsumerRecord<String, String> records, Acknowledgment ack) throws Throwable {
34
		try {
35
			log.info("----------------AI人脸识别触发考勤信息消费开始---------------------------");
36
37
			String message = records.value();
38
			log.info("已接AI考勤信息,消息为:" + message);
39
40
			CommonRequest<AiIdenLog> aiIdenLogRequest = JSON.parseObject(message,
41
					new TypeReference<CommonRequest<AiIdenLog>>() {
42
					});
43
44
			CommonResponse runningResult = aiTaskCommand.aiIdenLogTriggerEvent(aiIdenLogRequest);
45
			log.info("runningResult: \n{}", JsonUtils.toJSONStringByDateFormat(runningResult, true));
46
			Assert.assertTrue(runningResult.isSuccess());
47
48
		} catch (Exception e) {
49
			log.error("kafka消费异常" + e.getMessage(), e);
50
		} finally {
51
			ack.acknowledge();// 手动提交偏移量
52
		}
53
	}
54
}

+ 50 - 6
security-protection-service/src/main/java/com/ai/bss/security/protection/service/task/AIResultRecordKafkaTask.java

@ -1,24 +1,31 @@
1 1
package com.ai.bss.security.protection.service.task;
2 2
3
import java.util.List;
4
import java.util.Map;
5
3 6
import org.apache.kafka.clients.consumer.ConsumerRecord;
4 7
import org.junit.Assert;
5 8
import org.springframework.beans.factory.annotation.Autowired;
6 9
import org.springframework.kafka.annotation.KafkaListener;
7 10
import org.springframework.kafka.support.Acknowledgment;
8 11
import org.springframework.stereotype.Component;
12
import org.springframework.util.CollectionUtils;
9 13
10 14
import com.ai.abc.api.model.CommonRequest;
11 15
import com.ai.abc.api.model.CommonResponse;
12 16
import com.ai.abc.util.JsonUtils;
17
import com.ai.bss.security.protection.service.interfaces.ResourceToolManageService;
13 18
import com.ai.bss.work.safety.model.AiIdenLog;
14 19
import com.ai.bss.work.safety.service.api.AiTaskCommand;
20
import com.ai.bss.work.safety.service.api.MonitorSceneQuery;
15 21
import com.alibaba.fastjson.JSON;
22
import com.alibaba.fastjson.JSONObject;
16 23
import com.alibaba.fastjson.TypeReference;
17 24
18 25
import lombok.extern.slf4j.Slf4j;
19 26
20 27
/**
21
 * AI任务执行结果日志创建
28
 * 创建AI任务执行结果日志
22 29
 * @author konghl@asiainfo.com
23 30
 * 2020-12-14
24 31
 */
@ -29,7 +36,13 @@ public class AIResultRecordKafkaTask {
29 36
	@Autowired
30 37
	private AiTaskCommand aiTaskCommand;
31 38
32
	@KafkaListener(containerFactory = "kafkaBatchListener6", topics = "${kafka.topic.alarm:Topic_IoT_IndividualAlarm}", groupId = "alarm_group")
39
	@Autowired
40
	private ResourceToolManageService resourceToolManageService;
41
	
42
	@Autowired
43
	private MonitorSceneQuery monitorSceneQuery;
44
45
	@KafkaListener(containerFactory = "kafkaBatchListener6", topics = "${kafka.topic.aitask:topic_ai_task}", groupId = "ai_group")
33 46
	public void alarmListener(ConsumerRecord<String, String> records, Acknowledgment ack) throws Throwable {
34 47
		try {
35 48
			log.info("----------------AI任务执行结果信息消费开始---------------------------");
@ -37,11 +50,41 @@ public class AIResultRecordKafkaTask {
37 50
			String message = records.value();
38 51
			log.info("已接AI任务执行结果消息,消息为:" + message);
39 52
40
			CommonRequest<AiIdenLog> aiIdenLogRequest = JSON.parseObject(message,
41
					new TypeReference<CommonRequest<AiIdenLog>>() {
42
					});
53
			JSONObject messageJson = JSONObject.parseObject(message);
54
			Map<String, Object> resourceToolMap = resourceToolManageService
55
					.queryResourceToolByCode(messageJson.getString("resourceToolCode"));
43 56
44
			CommonResponse<AiIdenLog> runningResult = aiTaskCommand.createAiIdenLog(aiIdenLogRequest);
57
			if (resourceToolMap == null) {
58
				log.error("AI任务执行结果的设备CODE不存在:  resourceToolCode=" + messageJson.getString("resourceToolCode"));
59
				throw new NullPointerException("resourceToolCode not exist");
60
			}
61
			
62
			String resourceToolId=String.valueOf(resourceToolMap.get("resourceToolId"));
63
			
64
			CommonResponse<List<Map<String, Object>>> sceneTerminalRelResponse =monitorSceneQuery.selectSceneTerminalRel(new CommonRequest<Long>(Long.valueOf(resourceToolId)));
65
66
			if (sceneTerminalRelResponse == null||CollectionUtils.isEmpty(sceneTerminalRelResponse.getData())) {
67
				log.error("AI任务执行结果的关联场景不存在:  resourceToolId=" + resourceToolId);
68
				throw new NullPointerException("sceneTerminalRel not exist");
69
			}
70
			Map<String,Object> sceneTerminalRelMap=sceneTerminalRelResponse.getData().get(0);
71
			
72
			
73
			AiIdenLog aiIdenLog = JSON.parseObject(message, new TypeReference<AiIdenLog>() {
74
			});
75
			aiIdenLog.setResourceToolId(resourceToolId);
76
			aiIdenLog.setResourceToolName(String.valueOf(resourceToolMap.get("resourceToolName")));
77
			aiIdenLog.setMonitorSceneId(String.valueOf(sceneTerminalRelMap.get("monitorSceneId")));
78
			aiIdenLog.setMonitorSceneName(String.valueOf(sceneTerminalRelMap.get("monitorSceneName")));
79
			aiIdenLog.setEffectType(String.valueOf(sceneTerminalRelMap.get("effectType")));
80
			aiIdenLog.setTerminalPosition(String.valueOf(sceneTerminalRelMap.get("place")));
81
			
82
			
83
			
84
			
85
			
86
87
			CommonResponse<AiIdenLog> runningResult = aiTaskCommand.createAiIdenLog(new CommonRequest<AiIdenLog>(aiIdenLog));
45 88
			log.info("runningResult: \n{}", JsonUtils.toJSONStringByDateFormat(runningResult, true));
46 89
			Assert.assertTrue(runningResult.isSuccess());
47 90
@ -51,4 +94,5 @@ public class AIResultRecordKafkaTask {
51 94
			ack.acknowledge();// 手动提交偏移量
52 95
		}
53 96
	}
97
54 98
}

+ 70 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/service/task/AIVideoKafkaTask.java

@ -0,0 +1,70 @@
1
package com.ai.bss.security.protection.service.task;
2
3
import java.util.Map;
4
5
import org.apache.kafka.clients.consumer.ConsumerRecord;
6
import org.junit.Assert;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.kafka.annotation.KafkaListener;
9
import org.springframework.kafka.support.Acknowledgment;
10
import org.springframework.stereotype.Component;
11
12
import com.ai.abc.api.model.CommonResponse;
13
import com.ai.abc.util.JsonUtils;
14
import com.ai.bss.security.protection.service.interfaces.MonitorVideoLogManageService;
15
import com.ai.bss.security.protection.service.interfaces.ResourceToolManageService;
16
import com.ai.bss.work.safety.model.MonitorVideoLog;
17
import com.alibaba.fastjson.JSON;
18
import com.alibaba.fastjson.JSONObject;
19
import com.alibaba.fastjson.TypeReference;
20
21
import lombok.extern.slf4j.Slf4j;
22
23
/**
24
 * 创建AI监控视频日志
25
 * @author konghl@asiainfo.com
26
 * 2020-12-14
27
 */
28
@Component
29
@Slf4j
30
public class AIVideoKafkaTask {
31
32
	@Autowired
33
	private MonitorVideoLogManageService monitorVideoLogManageService;
34
35
	@Autowired
36
	private ResourceToolManageService resourceToolManageService;
37
38
	@KafkaListener(containerFactory = "kafkaBatchListener6", topics = "${kafka.topic.aivideo:topic_ai_video}", groupId = "ai_group")
39
	public void alarmListener(ConsumerRecord<String, String> records, Acknowledgment ack) throws Throwable {
40
		try {
41
			log.info("----------------AI监控视频日志消费开始---------------------------");
42
43
			String message = records.value();
44
			log.info("已接AI监控视频日志消息,消息为:" + message);
45
46
			JSONObject messageJson = JSONObject.parseObject(message);
47
			Map<String, Object> resourceToolMap = resourceToolManageService
48
					.queryResourceToolByCode(messageJson.getString("resourceToolCode"));
49
50
			if (resourceToolMap==null) {
51
				log.error("AI监控视频日志的设备CODE不存在: " + messageJson.getString("resourceToolCode"));
52
				throw new NullPointerException("resourceToolCode not exist");
53
			}
54
			
55
			MonitorVideoLog monitorVideoLog = JSON.parseObject(message, new TypeReference<MonitorVideoLog>() {
56
			});
57
			monitorVideoLog.setResourceToolId(String.valueOf(resourceToolMap.get("resourceToolId")));
58
59
			CommonResponse<MonitorVideoLog> runningResult = monitorVideoLogManageService
60
					.createMonitorVideoLog(monitorVideoLog);
61
			log.info("kafka aivideo runningResult: \n{}", JsonUtils.toJSONStringByDateFormat(runningResult, true));
62
			Assert.assertTrue(runningResult.isSuccess());
63
64
		} catch (Exception e) {
65
			log.error("AI监控视频日志消息的kafka消费异常: " + e.getMessage(), e);
66
		} finally {
67
			ack.acknowledge();// 手动提交偏移量
68
		}
69
	}
70
}

+ 15 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/utils/EbcConstant.java

@ -39,6 +39,12 @@ public class EbcConstant {
39 39
	// 考勤查询:月
40 40
	public static final String AREA_IN_OUT_RECORD_MONTH = "month";
41 41
42
	//AI识别结果:违规
43
	public static final String AI_IDENTIFY_RESULT_ALARM= "AI_IDENTIFY_RESULT_ALARM";
44
	
45
	//AI识别结果:考勤
46
	public static final String AI_IDENTIFY_RESULT_ATTENDANCE= "AI_IDENTIFY_RESULT_ATTENDANCE";
47
	
42 48
	// 静态常量: 工单类型
43 49
	public static final String BUSINESS_SPEC_WORK_ORDER_TYPE = "WORK_ORDER_TYPE";
44 50
	
@ -47,6 +53,15 @@ public class EbcConstant {
47 53
	
48 54
	// 静态常量: 监控场景类型
49 55
	public static final String BUSINESS_SPEC_MONITOR_SCENE_TYPE = "MONITOR_SCENE_TYPE";
56
	
57
	// 静态常量: AI报警类型
58
	public static final String BUSINESS_SPEC_AI_ALARM_TYPE = "AI_ALARM_TYPE";
59
	
60
	// 静态常量: AI任务状态
61
	public static final String BUSINESS_SPEC_AI_TASK_STATUS = "AI_TASK_STATUS";
62
	
63
	// 静态常量: AI匹配模型
64
	public static final String BUSINESS_SPEC_AI_MATCHER_MODE = "AI_MATCHER_MODE";
50 65
51 66
	
52 67
	// 当前登录者的STAFF_ID

+ 11 - 5
security-protection-service/src/main/resources/application.properties

@ -28,8 +28,7 @@ spring.main.allow-bean-definition-overriding=true
28 28
#kafka.bootstrap-servers=47.105.160.21:9090
29 29
kafka.bootstrap-servers=10.19.90.34:9090
30 30
kafka.topic.aitask=topic_ai_task
31
kafka.topic.aialarm=topic_ai_alarm
32
kafka.topic.aiattendance=topic_ai_attendance
31
kafka.topic.aivideo=topic_ai_video
33 32
kafka.producer.batch-size=16785
34 33
kafka.producer.retries=1
35 34
kafka.producer.buffer-memory=33554432
@ -51,13 +50,20 @@ minio.port=19000
51 50
minio.accessKey=minioadmin
52 51
minio.secretKey=minioadmin
53 52
minio.secure=false
54
minio.bucketHeaderImage=prod-dev
55 53
minio.faceAddServiceUrl=http://10.21.10.28:9018/api/face/add
56 54
minio.face-del-service-url=http://10.21.10.28:9018/api/face/del
57 55
minio.face-recog-service-url=http://10.21.10.28:9018/api/face/recog
58 56
59
myminio.bucketWorkToolImage=tool-image
60
myminio.bucketWorkToolView=tool-view
57
# \u4eba\u8138\u8bc6\u522b
58
minio.bucketHeaderImage=prod-dev
59
60
# \u8bbe\u5907\u9ed8\u8ba4\u7167\u7247
61
spminio.bucketToolImage=tool-image
62
# \u76d1\u63a7\u89c6\u9891
63
spminio.bucketAiVideo=ai-video
64
# \u76d1\u63a7\u89c6\u9891\u622a\u56fe
65
spminio.bucketAiImage=ai-image
66
61 67
62 68
# CACHE
63 69
#spring.cache.type=ehcache

ebc - Nuosi Git Service

ebc

liuwenxun 5b51d9d4bd [FE]处理videoInfo为空时,详情页面无法点击的问题 4 vuotta sitten
ebc-middle-platform d78b7bdffa 删除debugger 4 vuotta sitten
ebc-mock-service 70d83d67f8 增加指定topic功能 4 vuotta sitten
ebc-sea-platform 36d3e28af0 ebc-sea-platform工程恢复1.0版本(回滚到2020.11.22) 4 vuotta sitten
location-rescue-service 77826c0759 更改打包的包名方式 4 vuotta sitten
monitor-manage-service 0c298d1922 修改AI识别处理服务 4 vuotta sitten
security-protection-platform 5b51d9d4bd [FE]处理videoInfo为空时,详情页面无法点击的问题 4 vuotta sitten
security-protection-service a909c80b50 ai报警bug修改 4 vuotta sitten