Parcourir la Source

新增报警详情的接口

konghl 4 ans auparavant
Parent
commit
e31740f33e

+ 18 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/controller/AiAlarmManageController.java

@ -5,6 +5,7 @@ import com.ai.abc.api.model.CommonResponse;
5 5
import com.ai.bss.components.common.model.PageBean;
6 6
import com.ai.bss.security.protection.model.AiQuery;
7 7
import com.ai.bss.security.protection.model.AttendanceReport;
8
import com.ai.bss.security.protection.model.EbcMonitorVideoLog;
8 9
import com.ai.bss.security.protection.service.interfaces.AiAlarmManageService;
9 10
import com.ai.bss.security.protection.utils.EbcConstant;
10 11
import com.ai.bss.work.safety.model.AiModel;
@ -106,6 +107,23 @@ public class AiAlarmManageController {
106 107
	}
107 108
	
108 109
	/**
110
	 * 查询单个AI告警信息
111
	 * @param workTaskId
112
	 * @return
113
	 * @throws Exception
114
	 */
115
	@ResponseBody
116
	@RequestMapping("/queryOneAiAlarmInfo")
117
	public CommonResponse<Map<String,Object>> queryOneAiAlarmInfo(@RequestParam String workTaskId)
118
			throws Exception {
119
		if (StringUtils.isEmpty(workTaskId)) {
120
			return CommonResponse.fail("500", "操作失败");
121
		}
122
123
		return aiAlarmManageService.queryOneAiAlarmInfo(workTaskId);
124
	}
125
	
126
	/**
109 127
	 * AI任务模型匹配下拉列表
110 128
	 *
111 129
	 * @return

+ 18 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/controller/MonitorVideoLogManageController.java

@ -65,6 +65,24 @@ public class MonitorVideoLogManageController {
65 65
66 66
		return monitorVideoLogManageService.queryMonitorVideoLogById(Long.valueOf(monitorVideoLogId));
67 67
	}
68
	
69
	/**
70
	 * 根据设备图片时间查询视频日志
71
	 * @param imageTime
72
	 * @param resourceToolId
73
	 * @return
74
	 * @throws Exception
75
	 */
76
	@ResponseBody
77
	@RequestMapping("/getMonitorVideoLogByPictureTime")
78
	public CommonResponse<List<EbcMonitorVideoLog>> getMonitorVideoLogByPictureTime(@RequestParam String imageTime,@RequestParam String resourceToolId)
79
			throws Exception {
80
		if (StringUtils.isEmpty(imageTime)||StringUtils.isEmpty(resourceToolId)) {
81
			return CommonResponse.fail("500", "获取视频失败");
82
		}
83
84
		return monitorVideoLogManageService.getMonitorVideoLogByPictureTime(imageTime,resourceToolId);
85
	}
68 86
69 87
	/**
70 88
	 * 创建监控视频日志

+ 3 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/model/EbcMonitorVideoLog.java

@ -16,4 +16,7 @@ public class EbcMonitorVideoLog extends MonitorVideoLog {
16 16
	
17 17
	private String endTimeStr;
18 18
	
19
	private String fileDateTimeStr;
20
	
21
	private String videoFileUrl;
19 22
}

+ 67 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/service/impl/AiAlarmManageServiceImpl.java

@ -4,19 +4,25 @@ import java.util.HashMap;
4 4
import java.util.List;
5 5
import java.util.Map;
6 6
7
import org.apache.commons.lang.StringUtils;
7 8
import org.springframework.beans.factory.annotation.Autowired;
8 9
import org.springframework.stereotype.Service;
10
import org.springframework.util.CollectionUtils;
9 11
10 12
import com.ai.abc.api.model.CommonRequest;
11 13
import com.ai.abc.api.model.CommonResponse;
12 14
import com.ai.bss.characteristic.spec.model.CharacteristicSpecValue;
13 15
import com.ai.bss.components.common.model.PageBean;
16
import com.ai.bss.security.protection.model.EbcMonitorVideoLog;
14 17
import com.ai.bss.security.protection.service.interfaces.AiAlarmManageService;
15 18
import com.ai.bss.security.protection.service.interfaces.CharSpecService;
19
import com.ai.bss.security.protection.service.interfaces.MonitorVideoLogManageService;
20
import com.ai.bss.security.protection.service.interfaces.UploadFileService;
16 21
import com.ai.bss.security.protection.utils.EbcConstant;
17 22
import com.ai.bss.user.dto.EmployeeDto;
18 23
import com.ai.bss.user.service.api.EmployeeService;
19 24
import com.ai.bss.work.safety.model.AiModel;
25
import com.ai.bss.work.safety.model.WorkTaskSafetyAlarm;
20 26
import com.ai.bss.work.safety.service.api.AiTaskQuery;
21 27
import com.ai.bss.work.service.api.WorkTaskCommand;
22 28
import com.ai.bss.work.task.model.common.WorkTask;
@ -39,6 +45,11 @@ public class AiAlarmManageServiceImpl implements AiAlarmManageService {
39 45
    @Autowired
40 46
    EmployeeService employeeService;
41 47
48
    @Autowired
49
	private UploadFileService uploadFileService;
50
    
51
	@Autowired
52
	private MonitorVideoLogManageService monitorVideoLogManageService;
42 53
43 54
    @Override
44 55
    public CommonResponse<PageBean<Map<String, Object>>> queryPageAiAlarm(Map<String, Object> params, int pageNumber, int pageSize) {
@ -97,4 +108,60 @@ public class AiAlarmManageServiceImpl implements AiAlarmManageService {
97 108
        CommonRequest<Map<String, Object>> request=new CommonRequest<Map<String, Object>>(conditionMap);
98 109
        return aiTaskQuery.selectAiTaskDevice(request);
99 110
	}
111
112
	@Override
113
	public CommonResponse<Map<String, Object>> queryOneAiAlarmInfo(String workTaskId) throws Exception {
114
		CommonRequest<String> request = new CommonRequest<String>(workTaskId);
115
		CommonResponse<WorkTaskSafetyAlarm> response = aiTaskQuery.queryWorkTaskSafetyAlarmById(request);
116
		
117
		if (response==null||response.getData()==null) {
118
			return CommonResponse.fail("504", "获取失败");
119
		}
120
		
121
		WorkTaskSafetyAlarm workTaskSafetyAlarm=response.getData();
122
		
123
		List<CharacteristicSpecValue> aiAlarmTypeList = charSpecService.getCharSpecList(EbcConstant.BUSINESS_SPEC_AI_ALARM_TYPE);
124
		for (CharacteristicSpecValue characteristicSpecValue : aiAlarmTypeList) {
125
			if (characteristicSpecValue.getCode().equals(workTaskSafetyAlarm.getAlarmTypeCode())) {
126
				workTaskSafetyAlarm.setAlarmTypeCode(characteristicSpecValue.getValue());
127
				break;
128
			}
129
		}
130
		List<CharacteristicSpecValue> aiAlarmStatusList = charSpecService.getCharSpecList(EbcConstant.BUSINESS_SPEC_AI_TASK_STATUS);
131
		for (CharacteristicSpecValue characteristicSpecValue : aiAlarmStatusList) {
132
			if (characteristicSpecValue.getCode().equals(workTaskSafetyAlarm.getStatus())) {
133
				workTaskSafetyAlarm.setStatus(characteristicSpecValue.getValue());
134
				break;
135
			}
136
		}
137
		
138
		if(StringUtils.isEmpty(workTaskSafetyAlarm.getWorkEmployeeRoleId())){
139
            long relateEmployeeRoleId = Long.parseLong(workTaskSafetyAlarm.getWorkEmployeeRoleId());
140
141
            EmployeeDto employeeDto = new EmployeeDto();
142
            employeeDto.setId(relateEmployeeRoleId);
143
            CommonRequest<EmployeeDto> employeeDtoRequest = new CommonRequest<EmployeeDto>(employeeDto);
144
            CommonResponse<EmployeeDto> employeeDtoResponse = employeeService.queryEmployee(employeeDtoRequest);
145
            if (employeeDtoResponse==null||employeeDtoResponse.getData()==null) {
146
            	workTaskSafetyAlarm.setWorkEmployeeRoleName("--");
147
			}else {
148
				workTaskSafetyAlarm.setWorkEmployeeRoleName(employeeDtoResponse.getData().getName());
149
			}
150
        }
151
		
152
		Map<String, String> pictureMap= uploadFileService.getFileUrlToMap(workTaskSafetyAlarm.getIdenPictureUrl());
153
		
154
		List<EbcMonitorVideoLog> logsList=monitorVideoLogManageService.getMonitorVideoLogByPictureTime(pictureMap.get("fileDateTimeStr"), workTaskSafetyAlarm.getResourceToolId()).getData();
155
		EbcMonitorVideoLog ebcMonitorVideoLog=null;
156
		if (!CollectionUtils.isEmpty(logsList)) {
157
			ebcMonitorVideoLog=logsList.get(0);
158
			ebcMonitorVideoLog.setVideoFileUrl(uploadFileService.getFileUrl(ebcMonitorVideoLog.getVideoUrl()));
159
		}
160
		
161
		Map<String,Object> resultMap= new HashMap<String, Object>();
162
		resultMap.put("alarmInfo", workTaskSafetyAlarm);
163
		resultMap.put("pictureInfo", pictureMap);
164
		resultMap.put("videoInfo", ebcMonitorVideoLog);
165
		return CommonResponse.ok(resultMap);
166
	}
100 167
}

+ 50 - 38
security-protection-service/src/main/java/com/ai/bss/security/protection/service/impl/MonitorVideoLogManageServiceImpl.java

@ -1,7 +1,10 @@
1 1
package com.ai.bss.security.protection.service.impl;
2 2
3 3
import java.util.ArrayList;
4
import java.util.Date;
5
import java.util.HashMap;
4 6
import java.util.List;
7
import java.util.Map;
5 8
6 9
import org.apache.commons.lang.StringUtils;
7 10
import org.springframework.beans.factory.annotation.Autowired;
@ -40,32 +43,7 @@ public class MonitorVideoLogManageServiceImpl implements MonitorVideoLogManageSe
40 43
		}
41 44
42 45
		for (MonitorVideoLog monitorVideoLog : response.getData()) {
43
			EbcMonitorVideoLog ebcMonitorVideoLog = new EbcMonitorVideoLog();
44
			ComponentReflectionUtils.copyAttributeFromParent(monitorVideoLog, ebcMonitorVideoLog);
45
46
			String videoUrl = monitorVideoLog.getVideoUrl();
47
			if (StringUtils.isBlank(videoUrl) || videoUrl.length() < 18 || videoUrl.lastIndexOf(".") < 14) {
48
				ebcMonitorVideoLog.setFileType("");
49
				ebcMonitorVideoLog.setFileName(videoUrl);
50
				list.add(ebcMonitorVideoLog);
51
			}
52
53
			String fileType = videoUrl.substring(videoUrl.lastIndexOf(".")+1);
54
			
55
			String newFileName = videoUrl.substring(videoUrl.lastIndexOf("_")+1);
56
			int videoPrefixIndex = newFileName.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_VIDEO);
57
			String fileNameData = newFileName.substring(
58
					videoPrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_VIDEO.length(),
59
					videoPrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_VIDEO.length() + 14);
60
			
61
			String newFileNameData = DateUtil
62
					.formatDate(DateUtil.convertDate(fileNameData, DateUtil.PURE_DATETIME_PATTERN), "MM月dd日 HH:mm");
63
64
			ebcMonitorVideoLog.setFileType(fileType);
65
			ebcMonitorVideoLog.setFileName(newFileNameData);
66
			ebcMonitorVideoLog.setBeginTimeStr(DateUtil.formatDate(monitorVideoLog.getBeginTime()));
67
			ebcMonitorVideoLog.setEndTimeStr(DateUtil.formatDate(monitorVideoLog.getEndTime()));
68
			
46
			EbcMonitorVideoLog ebcMonitorVideoLog = getEbcMonitorVideoLog(monitorVideoLog);
69 47
			list.add(ebcMonitorVideoLog);
70 48
		}
71 49
@ -81,33 +59,67 @@ public class MonitorVideoLogManageServiceImpl implements MonitorVideoLogManageSe
81 59
			return CommonResponse.fail("504", "监控视频不存在");
82 60
		}
83 61
62
		EbcMonitorVideoLog ebcMonitorVideoLog = getEbcMonitorVideoLog(response.getData());
63
		return CommonResponse.ok(ebcMonitorVideoLog);
64
	}
65
66
	@Override
67
	public CommonResponse<List<EbcMonitorVideoLog>> getMonitorVideoLogByPictureTime(String imageTime,
68
			String resourceToolId) throws Exception {
69
		Map<String, Object> conditionMap = new HashMap<String, Object>();
70
		conditionMap.put("resourceToolId", resourceToolId);
71
		conditionMap.put("imageTime", imageTime);
72
		CommonRequest<Map<String, Object>> conditionMapRequest = new CommonRequest<Map<String, Object>>(conditionMap);
73
		CommonResponse<List<MonitorVideoLog>> response = monitorSceneQuery.selectMonitorVideoLog(conditionMapRequest);
74
75
		List<EbcMonitorVideoLog> list = new ArrayList<EbcMonitorVideoLog>();
76
		if (response == null || CollectionUtils.isEmpty(response.getData())) {
77
			return CommonResponse.ok(list);
78
		}
79
80
		for (MonitorVideoLog monitorVideoLog : response.getData()) {
81
			EbcMonitorVideoLog ebcMonitorVideoLog = getEbcMonitorVideoLog(monitorVideoLog);
82
			list.add(ebcMonitorVideoLog);
83
		}
84
85
		return CommonResponse.ok(list);
86
	}
87
88
	/**
89
	 * 根据MonitorVideoLog获取EbcMonitorVideoLog
90
	 * @param monitorVideoLog
91
	 * @return
92
	 * @throws Exception 
93
	 */
94
	private EbcMonitorVideoLog getEbcMonitorVideoLog(MonitorVideoLog monitorVideoLog) throws Exception {
84 95
		EbcMonitorVideoLog ebcMonitorVideoLog = new EbcMonitorVideoLog();
85
		ComponentReflectionUtils.copyAttributeFromParent(response.getData(), ebcMonitorVideoLog);
96
		ComponentReflectionUtils.copyAttributeFromParent(monitorVideoLog, ebcMonitorVideoLog);
86 97
87
		String videoUrl = response.getData().getVideoUrl();
98
		String videoUrl = monitorVideoLog.getVideoUrl();
88 99
		if (StringUtils.isBlank(videoUrl) || videoUrl.length() < 18 || videoUrl.lastIndexOf(".") < 14) {
89 100
			ebcMonitorVideoLog.setFileType("");
90 101
			ebcMonitorVideoLog.setFileName(videoUrl);
91
			return CommonResponse.ok(ebcMonitorVideoLog);
102
			return ebcMonitorVideoLog;
92 103
		}
93 104
94
		
95
		String fileType = videoUrl.substring(videoUrl.lastIndexOf(".")+1);
96
		
97
		String newFileName = videoUrl.substring(videoUrl.lastIndexOf("_")+1);
105
		String fileType = videoUrl.substring(videoUrl.lastIndexOf(".") + 1);
106
107
		String newFileName = videoUrl.substring(videoUrl.lastIndexOf("_") + 1);
98 108
		int videoPrefixIndex = newFileName.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_VIDEO);
99 109
		String fileNameData = newFileName.substring(
100 110
				videoPrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_VIDEO.length(),
101 111
				videoPrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_VIDEO.length() + 14);
102
		String newFileNameData = DateUtil.formatDate(DateUtil.convertDate(fileNameData, DateUtil.PURE_DATETIME_PATTERN),
103
				"MM月dd日 HH:mm");
112
		Date fileDateTime = DateUtil.convertDate(fileNameData, DateUtil.PURE_DATETIME_PATTERN);
113
		String newFileNameData = DateUtil.formatDate(fileDateTime, "MM月dd日 HH:mm");
114
		String fileDateTimeStr = DateUtil.formatDate(fileDateTime);
104 115
105 116
		ebcMonitorVideoLog.setFileType(fileType);
106 117
		ebcMonitorVideoLog.setFileName(newFileNameData);
107
		ebcMonitorVideoLog.setBeginTimeStr(DateUtil.formatDate(response.getData().getBeginTime()));
108
		ebcMonitorVideoLog.setEndTimeStr(DateUtil.formatDate(response.getData().getEndTime()));
118
		ebcMonitorVideoLog.setBeginTimeStr(DateUtil.formatDate(monitorVideoLog.getBeginTime()));
119
		ebcMonitorVideoLog.setEndTimeStr(DateUtil.formatDate(monitorVideoLog.getEndTime()));
120
		ebcMonitorVideoLog.setFileDateTimeStr(fileDateTimeStr);
109 121
110
		return CommonResponse.ok(ebcMonitorVideoLog);
122
		return ebcMonitorVideoLog;
111 123
	}
112 124
113 125
	@Override

+ 9 - 5
security-protection-service/src/main/java/com/ai/bss/security/protection/service/impl/UploadFileServiceImpl.java

@ -1,5 +1,6 @@
1 1
package com.ai.bss.security.protection.service.impl;
2 2
3
import java.util.Date;
3 4
import java.util.HashMap;
4 5
import java.util.List;
5 6
import java.util.Map;
@ -170,7 +171,7 @@ public class UploadFileServiceImpl implements UploadFileService {
170 171
		}
171 172
		resultMap.put("fileUrl", minioFileUrl);
172 173
173
		String newFileName = fileName.substring(fileName.lastIndexOf(SPLIT_CHAR)+1);
174
		String newFileName = fileName.substring(fileName.lastIndexOf(SPLIT_CHAR) + 1);
174 175
		int fileNameIndex = newFileName.lastIndexOf(".");
175 176
		if (newFileName.length() < 18 || fileNameIndex < 14) {
176 177
			return resultMap;
@ -184,9 +185,10 @@ public class UploadFileServiceImpl implements UploadFileService {
184 185
			String fileNameData = newFileName.substring(
185 186
					videoPrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_VIDEO.length(),
186 187
					videoPrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_VIDEO.length() + 14);
187
			String newFileNameData = DateUtil
188
					.formatDate(DateUtil.convertDate(fileNameData, DateUtil.PURE_DATETIME_PATTERN), "MM月dd日 HH:mm");
188
			Date fileDataTime = DateUtil.convertDate(fileNameData, DateUtil.PURE_DATETIME_PATTERN);
189
			String newFileNameData = DateUtil.formatDate(fileDataTime, "MM月dd日 HH:mm");
189 190
			resultMap.put("fileName", newFileNameData);
191
			resultMap.put("fileDataTimeStr", DateUtil.formatDate(fileDataTime));
190 192
191 193
		} else if (newFileName.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE) > 0) {
192 194
			int picturePrefixIndex = newFileName.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE);
@ -194,15 +196,17 @@ public class UploadFileServiceImpl implements UploadFileService {
194 196
			String fileNameData = newFileName.substring(
195 197
					picturePrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE.length(),
196 198
					picturePrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE.length() + 14);
197
			String newFileNameData = DateUtil
198
					.formatDate(DateUtil.convertDate(fileNameData, DateUtil.PURE_DATETIME_PATTERN), "MM月dd日 HH:mm:ss");
199
			Date fileDataTime = DateUtil.convertDate(fileNameData, DateUtil.PURE_DATETIME_PATTERN);
200
			String newFileNameData = DateUtil.formatDate(fileDataTime, "MM月dd日 HH:mm:ss");
199 201
			String pictureSerialNum = newFileName.substring(
200 202
					picturePrefixIndex + EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE.length() + 14, fileNameIndex);
201 203
			resultMap.put("fileName", newFileNameData + " " + pictureSerialNum);
204
			resultMap.put("fileDataTimeStr", DateUtil.formatDate(fileDataTime));
202 205
203 206
		} else {
204 207
			resultMap.put("fileType", "");
205 208
			resultMap.put("fileName", newFileName);
209
			resultMap.put("fileDateTimeStr", "");
206 210
		}
207 211
208 212
		return resultMap;

+ 10 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/service/interfaces/AiAlarmManageService.java

@ -9,6 +9,8 @@ import com.ai.bss.work.task.model.common.WorkTask;
9 9
import java.util.List;
10 10
import java.util.Map;
11 11
12
import org.springframework.web.bind.annotation.RequestParam;
13
12 14
public interface AiAlarmManageService {
13 15
	CommonResponse<PageBean<Map<String, Object>>> queryPageAiAlarm(Map<String, Object> params, int pageNumber,
14 16
			int pageSize);
@ -16,6 +18,14 @@ public interface AiAlarmManageService {
16 18
	CommonResponse<WorkTask> changeTaskStatus(CommonRequest<WorkTask> workTaskRequest);
17 19
18 20
	/**
21
	 * 查询单个AI告警信息
22
	 * @param workTaskId
23
	 * @return
24
	 * @throws Exception
25
	 */
26
	CommonResponse<Map<String,Object>> queryOneAiAlarmInfo(@RequestParam String workTaskId) throws Exception;
27
	
28
	/**
19 29
	 * AI任务模型匹配下拉列表
20 30
	 * @return
21 31
	 */

+ 9 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/service/interfaces/MonitorVideoLogManageService.java

@ -31,6 +31,15 @@ public interface MonitorVideoLogManageService {
31 31
	CommonResponse<EbcMonitorVideoLog> queryMonitorVideoLogById(Long monitorVideoLogId) throws Exception;
32 32
33 33
	/**
34
	 * 根据设备图片时间查询视频日志
35
	 * @param imageTime
36
	 * @param resourceToolId
37
	 * @return
38
	 * @throws Exception
39
	 */
40
	CommonResponse<List<EbcMonitorVideoLog>> getMonitorVideoLogByPictureTime(String imageTime,String resourceToolId) throws Exception;
41
	
42
	/**
34 43
	 * 创建监控视频日志
35 44
	 * @param monitorVideoLog
36 45
	 * @return