Parcourir la Source

新增首页AI识别进出记录

konghl 4 ans auparavant
Parent
commit
1eaee71703

+ 1 - 1
security-protection-service/src/main/java/com/ai/bss/security/protection/controller/EmployeeManagementController.java

133
	@ResponseBody
133
	@ResponseBody
134
	@RequestMapping("/uploadEmployeePicture")
134
	@RequestMapping("/uploadEmployeePicture")
135
	public CommonResponse<Map<String, String>> uploadEmployeePicture(
135
	public CommonResponse<Map<String, String>> uploadEmployeePicture(
136
			@RequestParam(value = "picture") MultipartFile meFile, @RequestParam(required = false) String pictureUrl)
136
			@RequestParam(value = "file") MultipartFile meFile, @RequestParam(required = false) String pictureUrl)
137
			throws Exception {
137
			throws Exception {
138
		if (meFile == null || StringUtils.isEmpty(meFile.getOriginalFilename())) {
138
		if (meFile == null || StringUtils.isEmpty(meFile.getOriginalFilename())) {
139
			return CommonResponse.fail("500", "上传失败");
139
			return CommonResponse.fail("500", "上传失败");

+ 16 - 1
security-protection-service/src/main/java/com/ai/bss/security/protection/controller/InAndOutRecordController.java

19
import org.springframework.web.bind.annotation.ResponseBody;
19
import org.springframework.web.bind.annotation.ResponseBody;
20
20
21
import java.util.HashMap;
21
import java.util.HashMap;
22
import java.util.List;
22
import java.util.Map;
23
import java.util.Map;
23
24
24
/**
25
/**
72
73
73
		return aiIdenLogManageService.queryOneAiIdenLog(aiIdenLogId);
74
		return aiIdenLogManageService.queryOneAiIdenLog(aiIdenLogId);
74
	}
75
	}
75
76
	
77
	/**
78
	 * 首页查询进出记录
79
	 * @return
80
	 * @throws Exception
81
	 */
82
	@ResponseBody
83
	@RequestMapping("/queryHomeLastInAndOutRecord")
84
	public CommonResponse<List<Map<String, Object>>> queryHomeLastInAndOutRecord(@RequestParam String monitorSceneId) throws Exception {
85
		Map<String, String> params=new HashMap<String, String>();
86
		params.put("sceneId", monitorSceneId);
87
		params.put("aiIdenModel", EbcConstant.AI_MODEL_FACE);
88
		
89
		return aiIdenLogManageService.selectLastAiIdenLog(params);
90
	}
76
}
91
}

+ 1 - 1
security-protection-service/src/main/java/com/ai/bss/security/protection/controller/ResourceToolManageController.java

154
	@ResponseBody
154
	@ResponseBody
155
	@RequestMapping("/uploadResourceToolPicture")
155
	@RequestMapping("/uploadResourceToolPicture")
156
	public CommonResponse<Map<String, String>> uploadResourceToolPicture(
156
	public CommonResponse<Map<String, String>> uploadResourceToolPicture(
157
			@RequestParam(value = "picture") MultipartFile meFile, @RequestParam(required = false) String pictureUrl)
157
			@RequestParam(value = "file") MultipartFile meFile, @RequestParam(required = false) String pictureUrl)
158
			throws Exception {
158
			throws Exception {
159
		if (meFile == null || StringUtils.isEmpty(meFile.getOriginalFilename())) {
159
		if (meFile == null || StringUtils.isEmpty(meFile.getOriginalFilename())) {
160
			return CommonResponse.fail("500", "上传失败");
160
			return CommonResponse.fail("500", "上传失败");

+ 121 - 23
security-protection-service/src/main/java/com/ai/bss/security/protection/service/impl/AiIdenLogManageServiceImpl.java

1
package com.ai.bss.security.protection.service.impl;
1
package com.ai.bss.security.protection.service.impl;
2
2
3
import java.math.BigDecimal;
3
import java.util.ArrayList;
4
import java.util.ArrayList;
4
import java.util.HashMap;
5
import java.util.HashMap;
5
import java.util.List;
6
import java.util.List;
13
import com.ai.abc.api.model.CommonRequest;
14
import com.ai.abc.api.model.CommonRequest;
14
import com.ai.abc.api.model.CommonResponse;
15
import com.ai.abc.api.model.CommonResponse;
15
import com.ai.bss.components.common.model.PageBean;
16
import com.ai.bss.components.common.model.PageBean;
17
import com.ai.bss.components.minio.config.MinioConfig;
16
import com.ai.bss.security.protection.model.EbcMonitorVideoLog;
18
import com.ai.bss.security.protection.model.EbcMonitorVideoLog;
17
import com.ai.bss.security.protection.service.interfaces.AiIdenLogManageService;
19
import com.ai.bss.security.protection.service.interfaces.AiIdenLogManageService;
18
import com.ai.bss.security.protection.service.interfaces.CharSpecService;
20
import com.ai.bss.security.protection.service.interfaces.CharSpecService;
51
	@Autowired
53
	@Autowired
52
	private MonitorVideoLogManageService monitorVideoLogManageService;
54
	private MonitorVideoLogManageService monitorVideoLogManageService;
53
55
56
	@Autowired
57
	private MinioConfig minioConfig;
58
54
	@Override
59
	@Override
55
	public CommonResponse<PageBean<Map<String, Object>>> queryPageAiIdenLog(Map<String, Object> params, int pageNumber,
60
	public CommonResponse<PageBean<Map<String, Object>>> queryPageAiIdenLog(Map<String, Object> params, int pageNumber,
56
			int pageSize) throws Exception {
61
			int pageSize) throws Exception {
69
		for (Map<String, Object> dataMap : response.getData().getData()) {
74
		for (Map<String, Object> dataMap : response.getData().getData()) {
70
			dataMap.put("taskExecuteTime", DateUtil.formatObjectToDate(dataMap.get("taskExecuteTime")));
75
			dataMap.put("taskExecuteTime", DateUtil.formatObjectToDate(dataMap.get("taskExecuteTime")));
71
			dataMap.put("idenPictureSnapDate", DateUtil.formatObjectToDate(dataMap.get("idenPictureSnapDate")));
76
			dataMap.put("idenPictureSnapDate", DateUtil.formatObjectToDate(dataMap.get("idenPictureSnapDate")));
72
			
77
73
			// 结果详情
78
			// 结果详情
74
			String idenResultString = dataMap.get("idenResult") == null ? "" : String.valueOf(dataMap.get("idenResult"));
79
			String idenResultString = dataMap.get("idenResult") == null ? ""
80
					: String.valueOf(dataMap.get("idenResult"));
75
			if (StringUtils.isNotEmpty(idenResultString)) {
81
			if (StringUtils.isNotEmpty(idenResultString)) {
76
				Object idenResultObject = JSON.parse(idenResultString);
82
				Object idenResultObject = JSON.parse(idenResultString);
77
				 if (idenResultObject instanceof JSONObject) {
78
					 Map<String, String> idenResultMap=JSON.parseObject(idenResultString, Map.class);
79
					 dataMap.putAll(idenResultMap);
80
				 }else if (idenResultObject instanceof JSONArray) {
81
					 List<Map<String, String>> idenResultList = JSONArray.parseObject(idenResultString, List.class);
82
						if (!CollectionUtils.isEmpty(idenResultList)) {
83
							dataMap.putAll(idenResultList.get(0));
84
						}
85
				 }
83
				if (idenResultObject instanceof JSONObject) {
84
					Map<String, String> idenResultMap = JSON.parseObject(idenResultString, Map.class);
85
					dataMap.putAll(idenResultMap);
86
87
					if (idenResultMap.get("simi") != null) {
88
						Object simiObject = idenResultMap.get("simi");
89
						BigDecimal simiBigDecimal = new BigDecimal(String.valueOf(simiObject));
90
						float simi = simiBigDecimal.multiply(new BigDecimal("100"))
91
								.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
92
						dataMap.put("simi", simi + "%");
93
					}
94
95
				} else if (idenResultObject instanceof JSONArray) {
96
					List<Map<String, String>> idenResultList = JSONArray.parseObject(idenResultString, List.class);
97
					if (!CollectionUtils.isEmpty(idenResultList)) {
98
						dataMap.putAll(idenResultList.get(0));
99
					}
100
				}
86
			}
101
			}
87
102
88
			// 员工信息
103
			// 员工信息
89
			if (dataMap.get("relateEmployeeRoleId") == null) {
104
			if (dataMap.get("relateEmployeeRoleId") != null) {
90
				long relateEmployeeRoleId = Long.parseLong(String.valueOf(dataMap.get("relateEmployeeRoleId")));
105
				long relateEmployeeRoleId = Long.parseLong(String.valueOf(dataMap.get("relateEmployeeRoleId")));
91
106
92
				EmployeeDto employeeDto = new EmployeeDto();
107
				EmployeeDto employeeDto = new EmployeeDto();
98
					dataMap.put("employeeName", employeeResponse.getData().getName());
113
					dataMap.put("employeeName", employeeResponse.getData().getName());
99
					dataMap.put("employeeCode", employeeResponse.getData().getCode());
114
					dataMap.put("employeeCode", employeeResponse.getData().getCode());
100
115
101
					dataMap.put("companyName", employeeResponse.getData().getField4());
116
					dataMap.put("companyId", employeeResponse.getData().getField4());
102
					dataMap.put("organizationCode", employeeResponse.getData().getOrganizeCode());
117
					dataMap.put("organizationCode", employeeResponse.getData().getOrganizeCode());
103
					dataMap.put("organizationName", employeeResponse.getData().getOrgName());
118
					dataMap.put("organizationName", employeeResponse.getData().getOrgName());
104
119
139
			String pictureUrl = String.valueOf(dataMap.get("idenPictureUrl"));
154
			String pictureUrl = String.valueOf(dataMap.get("idenPictureUrl"));
140
			if (pictureUrl.length() > 20 && pictureUrl.lastIndexOf(".") > 18
155
			if (pictureUrl.length() > 20 && pictureUrl.lastIndexOf(".") > 18
141
					&& pictureUrl.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE) > 0) {
156
					&& pictureUrl.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE) > 0) {
142
				
157
143
				int picturePrefixIndex = pictureUrl.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE)
158
				int picturePrefixIndex = pictureUrl.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE)
144
						+ EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE.length();
159
						+ EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE.length();
145
				String fileName = pictureUrl.substring(picturePrefixIndex, picturePrefixIndex + 4) + "-"
160
				String fileName = pictureUrl.substring(picturePrefixIndex, picturePrefixIndex + 4) + "-"
171
				new TypeReference<Map<String, String>>() {
186
				new TypeReference<Map<String, String>>() {
172
				});
187
				});
173
188
189
		aiIdenLogInfoMap.put("taskExecuteTime",
190
				DateUtil.formatDate(Long.valueOf(aiIdenLogInfoMap.get("taskExecuteTime"))));
191
174
		// 结果详情
192
		// 结果详情
175
		if (StringUtils.isNotEmpty(aiIdenLog.getIdenResult())) {
193
		if (StringUtils.isNotEmpty(aiIdenLog.getIdenResult())) {
176
			Object idenResultObject = JSON.parse(aiIdenLog.getIdenResult());
194
			Object idenResultObject = JSON.parse(aiIdenLog.getIdenResult());
177
			 if (idenResultObject instanceof JSONObject) {
178
				 Map<String, String> idenResultMap=JSON.parseObject(aiIdenLog.getIdenResult(), Map.class);
179
				 aiIdenLogInfoMap.putAll(idenResultMap);
180
			 }else if (idenResultObject instanceof JSONArray) {
181
				 List<Map<String, String>> idenResultList = JSONArray.parseObject(aiIdenLog.getIdenResult(), List.class);
182
					if (!CollectionUtils.isEmpty(idenResultList)) {
183
						aiIdenLogInfoMap.putAll(idenResultList.get(0));
184
					}
185
			 }
195
			if (idenResultObject instanceof JSONObject) {
196
				Map<String, String> idenResultMap = JSON.parseObject(aiIdenLog.getIdenResult(), Map.class);
197
				aiIdenLogInfoMap.putAll(idenResultMap);
198
199
				if (idenResultMap.get("simi") != null) {
200
					Object simiObject = idenResultMap.get("simi");
201
					BigDecimal simiBigDecimal = new BigDecimal(String.valueOf(simiObject));
202
					float simi = simiBigDecimal.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP)
203
							.floatValue();
204
					aiIdenLogInfoMap.put("simi", simi + "%");
205
				}
206
207
			} else if (idenResultObject instanceof JSONArray) {
208
				List<Map<String, String>> idenResultList = JSONArray.parseObject(aiIdenLog.getIdenResult(), List.class);
209
				if (!CollectionUtils.isEmpty(idenResultList)) {
210
					aiIdenLogInfoMap.putAll(idenResultList.get(0));
211
				}
212
			}
186
		}
213
		}
187
214
188
		// 员工信息
215
		// 员工信息
198
				aiIdenLogInfoMap.put("employeeName", employeeResponse.getData().getName());
225
				aiIdenLogInfoMap.put("employeeName", employeeResponse.getData().getName());
199
				aiIdenLogInfoMap.put("employeeCode", employeeResponse.getData().getCode());
226
				aiIdenLogInfoMap.put("employeeCode", employeeResponse.getData().getCode());
200
227
228
				String headerImageName = employeeResponse.getData().getField1();
229
				String headerImage = uploadFileService.getFileUrl(headerImageName, minioConfig.getBucketHeaderImage());
230
				aiIdenLogInfoMap.put("headerImage", headerImage);
231
201
				/*
232
				/*
202
				String employeePosition = employeeResponse.getData().getMainJobPosition();
233
				String employeePosition = employeeResponse.getData().getMainJobPosition();
203
				aiIdenLogInfoMap.put("employeePosition", employeePosition);
234
				aiIdenLogInfoMap.put("employeePosition", employeePosition);
238
	}
269
	}
239
270
240
	@Override
271
	@Override
272
	public CommonResponse<List<Map<String, Object>>> selectLastAiIdenLog(Map<String, String> params) throws Exception {
273
		CommonRequest<Map<String, String>> request = new CommonRequest<Map<String, String>>(params);
274
		CommonResponse<List<Map<String, Object>>> response = aiTaskQuery
275
				.selectAiIdenLogBySceneIdAndAiIdenModel(request);
276
277
		if (response == null || response.getData() == null || CollectionUtils.isEmpty(response.getData())) {
278
			return response;
279
		}
280
281
		for (Map<String, Object> dataMap : response.getData()) {
282
			dataMap.put("taskExecuteTime", DateUtil.formatObjectToDate(dataMap.get("taskExecuteTime")));
283
284
			String idenPictureName = String.valueOf(dataMap.get("idenPictureUrl"));
285
			String idenPictureUrl = uploadFileService.getFileUrl(idenPictureName);
286
			dataMap.put("idenPictureUrl", idenPictureUrl);
287
			
288
			// 结果详情
289
			String idenResultString = dataMap.get("idenResult") == null ? ""
290
					: String.valueOf(dataMap.get("idenResult"));
291
			if (StringUtils.isNotEmpty(idenResultString)) {
292
				Object idenResultObject = JSON.parse(idenResultString);
293
				if (idenResultObject instanceof JSONObject) {
294
					Map<String, String> idenResultMap = JSON.parseObject(idenResultString, Map.class);
295
					dataMap.putAll(idenResultMap);
296
297
					if (idenResultMap.get("simi") != null) {
298
						Object simiObject = idenResultMap.get("simi");
299
						BigDecimal simiBigDecimal = new BigDecimal(String.valueOf(simiObject));
300
						float simi = simiBigDecimal.multiply(new BigDecimal("100"))
301
								.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
302
						dataMap.put("simi", simi + "%");
303
					}
304
305
				} else if (idenResultObject instanceof JSONArray) {
306
					List<Map<String, String>> idenResultList = JSONArray.parseObject(idenResultString, List.class);
307
					if (!CollectionUtils.isEmpty(idenResultList)) {
308
						dataMap.putAll(idenResultList.get(0));
309
					}
310
				}
311
			}
312
313
			// 员工信息
314
			if (dataMap.get("relateEmployeeRoleId") != null) {
315
				long relateEmployeeRoleId = Long.parseLong(String.valueOf(dataMap.get("relateEmployeeRoleId")));
316
317
				EmployeeDto employeeDto = new EmployeeDto();
318
				employeeDto.setId(relateEmployeeRoleId);
319
				CommonRequest<EmployeeDto> requestEmployeeDto = CommonRequest.<EmployeeDto>builder().data(employeeDto)
320
						.build();
321
				CommonResponse<EmployeeDto> employeeResponse = employeeService.queryEmployee(requestEmployeeDto);
322
323
				if (employeeResponse.getData() != null) {
324
					dataMap.put("employeeName", employeeResponse.getData().getName());
325
					dataMap.put("employeeCode", employeeResponse.getData().getCode());
326
327
					String headerImageName = employeeResponse.getData().getField1();
328
					String headerImage = uploadFileService.getFileUrl(headerImageName,
329
							minioConfig.getBucketHeaderImage());
330
					dataMap.put("headerImage", headerImage);
331
				}
332
			}
333
		}
334
335
		return response;
336
	}
337
338
	@Override
241
	public CommonResponse<AiIdenLog> createAiIdenLog(AiIdenLog aiIdenLog) throws Exception {
339
	public CommonResponse<AiIdenLog> createAiIdenLog(AiIdenLog aiIdenLog) throws Exception {
242
		CommonRequest<AiIdenLog> aiIdenLogRequest = new CommonRequest<AiIdenLog>(aiIdenLog);
340
		CommonRequest<AiIdenLog> aiIdenLogRequest = new CommonRequest<AiIdenLog>(aiIdenLog);
243
		return aiTaskCommand.createAiIdenLog(aiIdenLogRequest);
341
		return aiTaskCommand.createAiIdenLog(aiIdenLogRequest);

+ 8 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/service/interfaces/AiIdenLogManageService.java

45
	CommonResponse<Map<String, Object>> queryOneAiIdenLog(Long aiIdenLogId) throws Exception;
45
	CommonResponse<Map<String, Object>> queryOneAiIdenLog(Long aiIdenLogId) throws Exception;
46
46
47
	/**
47
	/**
48
	 * 查询所有设备最后一个识别记录
49
	 * @param params
50
	 * @return
51
	 * @throws Exception
52
	 */
53
	CommonResponse<List<Map<String, Object>>> selectLastAiIdenLog(Map<String, String> params) throws Exception;
54
	
55
	/**
48
	 * 创建AI执行结果
56
	 * 创建AI执行结果
49
	 * @param aiIdenLog
57
	 * @param aiIdenLog
50
	 * @return
58
	 * @return