Sfoglia il codice sorgente

新增首页AI识别进出记录

konghl 4 anni fa
parent
commit
1eaee71703

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

@ -133,7 +133,7 @@ public class EmployeeManagementController {
133 133
	@ResponseBody
134 134
	@RequestMapping("/uploadEmployeePicture")
135 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 137
			throws Exception {
138 138
		if (meFile == null || StringUtils.isEmpty(meFile.getOriginalFilename())) {
139 139
			return CommonResponse.fail("500", "上传失败");

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

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestParam;
19 19
import org.springframework.web.bind.annotation.ResponseBody;
20 20
21 21
import java.util.HashMap;
22
import java.util.List;
22 23
import java.util.Map;
23 24
24 25
/**
@ -72,5 +73,19 @@ public class InAndOutRecordController {
72 73
73 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,7 +154,7 @@ public class ResourceToolManageController {
154 154
	@ResponseBody
155 155
	@RequestMapping("/uploadResourceToolPicture")
156 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 158
			throws Exception {
159 159
		if (meFile == null || StringUtils.isEmpty(meFile.getOriginalFilename())) {
160 160
			return CommonResponse.fail("500", "上传失败");

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

@ -1,5 +1,6 @@
1 1
package com.ai.bss.security.protection.service.impl;
2 2
3
import java.math.BigDecimal;
3 4
import java.util.ArrayList;
4 5
import java.util.HashMap;
5 6
import java.util.List;
@ -13,6 +14,7 @@ import org.springframework.util.CollectionUtils;
13 14
import com.ai.abc.api.model.CommonRequest;
14 15
import com.ai.abc.api.model.CommonResponse;
15 16
import com.ai.bss.components.common.model.PageBean;
17
import com.ai.bss.components.minio.config.MinioConfig;
16 18
import com.ai.bss.security.protection.model.EbcMonitorVideoLog;
17 19
import com.ai.bss.security.protection.service.interfaces.AiIdenLogManageService;
18 20
import com.ai.bss.security.protection.service.interfaces.CharSpecService;
@ -51,6 +53,9 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
51 53
	@Autowired
52 54
	private MonitorVideoLogManageService monitorVideoLogManageService;
53 55
56
	@Autowired
57
	private MinioConfig minioConfig;
58
54 59
	@Override
55 60
	public CommonResponse<PageBean<Map<String, Object>>> queryPageAiIdenLog(Map<String, Object> params, int pageNumber,
56 61
			int pageSize) throws Exception {
@ -69,24 +74,34 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
69 74
		for (Map<String, Object> dataMap : response.getData().getData()) {
70 75
			dataMap.put("taskExecuteTime", DateUtil.formatObjectToDate(dataMap.get("taskExecuteTime")));
71 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 81
			if (StringUtils.isNotEmpty(idenResultString)) {
76 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 105
				long relateEmployeeRoleId = Long.parseLong(String.valueOf(dataMap.get("relateEmployeeRoleId")));
91 106
92 107
				EmployeeDto employeeDto = new EmployeeDto();
@ -98,7 +113,7 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
98 113
					dataMap.put("employeeName", employeeResponse.getData().getName());
99 114
					dataMap.put("employeeCode", employeeResponse.getData().getCode());
100 115
101
					dataMap.put("companyName", employeeResponse.getData().getField4());
116
					dataMap.put("companyId", employeeResponse.getData().getField4());
102 117
					dataMap.put("organizationCode", employeeResponse.getData().getOrganizeCode());
103 118
					dataMap.put("organizationName", employeeResponse.getData().getOrgName());
104 119
@ -139,7 +154,7 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
139 154
			String pictureUrl = String.valueOf(dataMap.get("idenPictureUrl"));
140 155
			if (pictureUrl.length() > 20 && pictureUrl.lastIndexOf(".") > 18
141 156
					&& pictureUrl.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE) > 0) {
142
				
157
143 158
				int picturePrefixIndex = pictureUrl.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE)
144 159
						+ EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE.length();
145 160
				String fileName = pictureUrl.substring(picturePrefixIndex, picturePrefixIndex + 4) + "-"
@ -171,18 +186,30 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
171 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 193
		if (StringUtils.isNotEmpty(aiIdenLog.getIdenResult())) {
176 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,6 +225,10 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
198 225
				aiIdenLogInfoMap.put("employeeName", employeeResponse.getData().getName());
199 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 233
				String employeePosition = employeeResponse.getData().getMainJobPosition();
203 234
				aiIdenLogInfoMap.put("employeePosition", employeePosition);
@ -238,6 +269,73 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
238 269
	}
239 270
240 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 339
	public CommonResponse<AiIdenLog> createAiIdenLog(AiIdenLog aiIdenLog) throws Exception {
242 340
		CommonRequest<AiIdenLog> aiIdenLogRequest = new CommonRequest<AiIdenLog>(aiIdenLog);
243 341
		return aiTaskCommand.createAiIdenLog(aiIdenLogRequest);

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

@ -45,6 +45,14 @@ public interface AiIdenLogManageService {
45 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 56
	 * 创建AI执行结果
49 57
	 * @param aiIdenLog
50 58
	 * @return