if (StringUtils.isNotEmpty(idenResultArr)) {
75
				List<Map<String, String>> idenResultList = JSONArray.parseObject(idenResultArr, List.class);
76
				if (!CollectionUtils.isEmpty(idenResultList)) {
77
					dataMap.put("idenResult", idenResultList.get(0));
78
					//dataMap.putAll(idenResultList.get(0));
79
			String idenResultString = dataMap.get("idenResult") == null ? ""
80
					: String.valueOf(dataMap.get("idenResult"));
81
			if (StringUtils.isNotEmpty(idenResultString)) {
82
				Object idenResultObject = JSON.parse(idenResultString);
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
					}
79 100
				}
80 101
			}
81 102
@ -92,7 +113,7 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
92 113
					dataMap.put("employeeName", employeeResponse.getData().getName());
93 114
					dataMap.put("employeeCode", employeeResponse.getData().getCode());
94 115
95
					dataMap.put("companyName", employeeResponse.getData().getField4());
116
					dataMap.put("companyId", employeeResponse.getData().getField4());
96 117
					dataMap.put("organizationCode", employeeResponse.getData().getOrganizeCode());
97 118
					dataMap.put("organizationName", employeeResponse.getData().getOrgName());
98 119
@ -133,7 +154,7 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
133 154
			String pictureUrl = String.valueOf(dataMap.get("idenPictureUrl"));
134 155
			if (pictureUrl.length() > 20 && pictureUrl.lastIndexOf(".") > 18
135 156
					&& pictureUrl.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE) > 0) {
136
				
157
137 158
				int picturePrefixIndex = pictureUrl.lastIndexOf(EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE)
138 159
						+ EbcConstant.AI_MONITOR_FILE_PREFIX_PICTURE.length();
139 160
				String fileName = pictureUrl.substring(picturePrefixIndex, picturePrefixIndex + 4) + "-"
@ -165,11 +186,29 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
165 186
				new TypeReference<Map<String, String>>() {
166 187
				});
167 188
189
		aiIdenLogInfoMap.put("taskExecuteTime",
190
				DateUtil.formatDate(Long.valueOf(aiIdenLogInfoMap.get("taskExecuteTime"))));
191
168 192
		// 结果详情
169 193
		if (StringUtils.isNotEmpty(aiIdenLog.getIdenResult())) {
170
			List<Map<String, String>> idenResultList = JSONArray.parseObject(aiIdenLog.getIdenResult(), List.class);
171
			if (!CollectionUtils.isEmpty(idenResultList)) {
172
				aiIdenLogInfoMap.putAll(idenResultList.get(0));
194
			Object idenResultObject = JSON.parse(aiIdenLog.getIdenResult());
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
				}
173 212
			}
174 213
		}
175 214
@ -186,6 +225,10 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
186 225
				aiIdenLogInfoMap.put("employeeName", employeeResponse.getData().getName());
187 226
				aiIdenLogInfoMap.put("employeeCode", employeeResponse.getData().getCode());
188 227
228
				String headerImageName = employeeResponse.getData().getField1();
229
				String headerImage = uploadFileService.getFileUrl(headerImageName, minioConfig.getBucketHeaderImage());
230
				aiIdenLogInfoMap.put("headerImage", headerImage);
231
189 232
				/*
190 233
				String employeePosition = employeeResponse.getData().getMainJobPosition();
191 234
				aiIdenLogInfoMap.put("employeePosition", employeePosition);
@ -226,6 +269,73 @@ public class AiIdenLogManageServiceImpl implements AiIdenLogManageService {
226 269
	}
227 270
228 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
229 339
	public CommonResponse<AiIdenLog> createAiIdenLog(AiIdenLog aiIdenLog) throws Exception {
230 340
		CommonRequest<AiIdenLog> aiIdenLogRequest = new CommonRequest<AiIdenLog>(aiIdenLog);
231 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

+ 1 - 1
security-protection-service/src/main/java/com/ai/bss/security/protection/service/interfaces/ResourceToolManageService.java

@ -84,7 +84,7 @@ public interface ResourceToolManageService {
84 84
	Map<String, String> uploadResourceToolPicture(MultipartFile meFile, String pictureUrl) throws Exception;
85 85
	
86 86
	/**
87
	 * 根据设备CODE获取场景、AI任务等相关信息
87
	 * 根据设备CODE获取AI任务等相关信息
88 88
	 * @param resourceToolCode
89 89
	 * @return
90 90
	 */

+ 30 - 11
security-protection-service/src/main/java/com/ai/bss/security/protection/service/task/AiResultRecordKafkaTask.java

@ -14,8 +14,9 @@ import com.ai.abc.api.model.CommonRequest;
14 14
import com.ai.abc.api.model.CommonResponse;
15 15
import com.ai.abc.util.JsonUtils;
16 16
import com.ai.bss.security.protection.service.interfaces.AiIdenLogManageService;
17
import com.ai.bss.security.protection.service.interfaces.ResourceToolManageService;
18 17
import com.ai.bss.security.protection.utils.EbcConstant;
18
import com.ai.bss.user.dto.EmployeeDto;
19
import com.ai.bss.user.service.api.EmployeeService;
19 20
import com.ai.bss.work.safety.model.AiIdenLog;
20 21
import com.ai.bss.work.safety.service.api.AiTaskCommand;
21 22
import com.ai.bss.work.safety.service.api.MonitorSceneQuery;
@ -38,14 +39,14 @@ public class AiResultRecordKafkaTask {
38 39
	private AiTaskCommand aiTaskCommand;
39 40
40 41
	@Autowired
41
	private ResourceToolManageService resourceToolManageService;
42
43
	@Autowired
44 42
	private MonitorSceneQuery monitorSceneQuery;
45 43
46 44
	@Autowired
47 45
	private AiIdenLogManageService aiIdenLogManageService;
48 46
47
	@Autowired
48
	private EmployeeService employeeService;
49
49 50
	@KafkaListener(containerFactory = "kafkaBatchListener6", topics = "${kafka.topic.aitask:topic_ai_task}", groupId = "ai_group")
50 51
	public void AiResultRecordListener(ConsumerRecord<String, String> records, Acknowledgment ack) throws Throwable {
51 52
		try {
@ -54,11 +55,15 @@ public class AiResultRecordKafkaTask {
54 55
			String message = records.value();
55 56
			log.info("已接AI任务执行结果消息,消息为:" + message);
56 57
58
			AiIdenLog aiIdenLog = JSON.parseObject(message, new TypeReference<AiIdenLog>() {
59
			});
60
57 61
			JSONObject messageJson = JSONObject.parseObject(message);
58 62
			String resourceToolId = messageJson.getString("resourceToolId");
59 63
			String idenResultType = messageJson.getString("idenResultType");
64
			Long relateEmployeeRoleId = messageJson.getLong("relateEmployeeRoleId");
60 65
61
			// 查询相关数据
66
			// 关联场景信息
62 67
			CommonResponse<List<Map<String, Object>>> sceneTerminalRelResponse = monitorSceneQuery
63 68
					.selectSceneTerminalRel(new CommonRequest<Long>(Long.valueOf(resourceToolId)));
64 69
			if (sceneTerminalRelResponse == null || CollectionUtils.isEmpty(sceneTerminalRelResponse.getData())) {
@ -68,9 +73,6 @@ public class AiResultRecordKafkaTask {
68 73
69 74
			Map<String, Object> sceneTerminalRelMap = sceneTerminalRelResponse.getData().get(0);
70 75
71
			// 封装数据
72
			AiIdenLog aiIdenLog = JSON.parseObject(message, new TypeReference<AiIdenLog>() {
73
			});
74 76
			aiIdenLog.setMonitorSceneId(sceneTerminalRelMap.get("monitorSceneId") == null ? ""
75 77
					: String.valueOf(sceneTerminalRelMap.get("monitorSceneId")));
76 78
			aiIdenLog.setMonitorSceneName(sceneTerminalRelMap.get("monitorSceneName") == null ? ""
@ -82,9 +84,26 @@ public class AiResultRecordKafkaTask {
82 84
			aiIdenLog.setOrganizationId(
83 85
					sceneTerminalRelMap.get("orgId") == null ? "" : String.valueOf(sceneTerminalRelMap.get("orgId")));
84 86
85
			// TODO 人员信息暂时默认
86
			aiIdenLog.setRelateEmployeeRoleId("201613310867");
87
			aiIdenLog.setRelateEmployeeRoleName("王浩");
87
			// 关联员工信息
88
			EmployeeDto employeeDto = null;
89
			if (relateEmployeeRoleId != null) {
90
				employeeDto = new EmployeeDto();
91
				employeeDto.setId(relateEmployeeRoleId);
92
				CommonRequest<EmployeeDto> employeeDtoRequest = new CommonRequest<EmployeeDto>(employeeDto);
93
				CommonResponse<EmployeeDto> employeeDtoResponse = employeeService.queryEmployee(employeeDtoRequest);
94
				if (employeeDtoResponse == null || employeeDtoResponse.getData() == null) {
95
					employeeDto = null;
96
				} else {
97
					employeeDto = employeeDtoResponse.getData();
98
				}
99
			}
100
			if (employeeDto != null) {
101
				aiIdenLog.setRelateEmployeeRoleName(employeeDto.getName());
102
				aiIdenLog.setOrganizationId(String.valueOf(employeeDto.getOrganizeId()));
103
			} else {
104
				aiIdenLog.setRelateEmployeeRoleId("-1");
105
				aiIdenLog.setRelateEmployeeRoleName(null);
106
			}
88 107
89 108
			// 执行操作
90 109
			CommonResponse<AiIdenLog> aiIdenLogRunningResult = aiIdenLogManageService.createAiIdenLog(aiIdenLog);

[FE] 默认路由修改 · 383d94554d - Nuosi Git Service
Przeglądaj źródła

[FE] 默认路由修改

chenxr3 4 lat temu
rodzic
commit
383d94554d
1 zmienionych plików z 2 dodań i 1 usunięć
  1. 2 1
      security-protection-platform/src/routes.js

+ 2 - 1
security-protection-platform/src/routes.js

@ -14,12 +14,13 @@ export const constantRoutes = [
14 14
  {
15 15
    path: '/',
16 16
    component: Layout,
17
    redirect: '/attendance/report',
17
    redirect: '/dashboard',
18 18
    hidden: true
19 19
  },
20 20
  {
21 21
    name: 'dashboard',
22 22
    path: '/dashboard',
23
    redirect: '/',
23 24
    component: () => import(/* webpackChunkName: "dashboard" */ './modules/dashboard'),
24 25
    meta: { title: '首页', icon: 'home' },
25 26
    children: [