From eccff0a08c056c3e04866105d9a6846b5271d8f1 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 25 Sep 2024 19:37:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=A7=86=E9=A2=91=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B7=BB=E5=8A=A0=E8=AE=B0=E5=BD=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspect/task/schedule/VideoTaskSchedule.java | 64 +++++++++------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java index e9b1028..35db2c1 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java @@ -8,10 +8,8 @@ import com.google.common.collect.Lists; import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisRequestDTO; import com.hnac.gglm.bigmodel.api.dto.BigModelAnalysisResponseDTO; import com.hnac.gglm.bigmodel.api.feign.IBigModelAnalysisClient; -import com.hnac.hzims.common.utils.FileUtil; import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; -import com.hnac.hzinfo.exception.HzServiceException; import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity; import com.hnac.hzinfo.inspect.ai.service.ICameraInfoService; @@ -34,26 +32,25 @@ import com.hnac.hzinfo.inspect.task.service.impl.FileUploaderService; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; import org.springblade.core.oss.model.BladeFile; import org.springblade.core.tool.api.R; import org.springblade.core.tool.jackson.JsonUtil; -import org.springblade.core.tool.utils.*; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.message.MessageConstants; import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.fegin.IMessageClient; import org.springblade.resource.feign.IOssClient; -import org.springblade.system.feign.ISysClient; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Component; -import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.annotation.Transactional; -import java.io.IOException; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; @@ -174,13 +171,13 @@ public class VideoTaskSchedule { record.setCurrentStatus("1"); CameraInfoEntity camera = this.getCameraByProIdAndConId(project.getProjectId(), content.getContentId()); log.info("【taskId:" + task.getId() + "】视频巡检任务执行,获取视频巡检结果,camera:" + Optional.ofNullable(camera).map(JsonUtil::toJson).orElse("null")); + XxlJobHelper.log("【taskId:" + task.getId() + "】视频巡检任务执行,获取视频巡检结果,camera:" + Optional.ofNullable(camera).map(JsonUtil::toJson).orElse("null")); if (Func.isNotEmpty(camera)) { // 获取计划时间段内视频的告警信息设置是否异常 if (Func.isNotEmpty(camera.getEmCode())) { Result> deviceSoeR = soeClient.getDeviceCodeByTaosSoe(DateUtil.formatDateTime(task.getPlanStartTime()), DateUtil.formatDateTime(task.getPlanEndTime()), camera.getEmCode(), 0, String.valueOf(-1)); if (deviceSoeR.isSuccess() && CollectionUtil.isNotEmpty(deviceSoeR.getData().getRecords())) { record.setCurrentStatus("0"); - } } String picUrl = null; @@ -189,7 +186,7 @@ public class VideoTaskSchedule { try { picUrl = hikApiService.manualCapture(camera.getPointCode()); } catch (Exception e) { - log.error("get picture url fail", e); + XxlJobHelper.log("【taskId:" + task.getId() + "】 获取图片地址失败 {}", e.getMessage()); } } if (Func.isNotEmpty(picUrl)) { @@ -197,6 +194,7 @@ public class VideoTaskSchedule { record.setCurrentValue(picUrl); pictureHandle(picUrl, content.getContentId(), record, task); } else { + record.setCurrentStatus(TaskContants.CurrentStatusEnum.abnormal.getType()); record.setCurrentValue("获取视频地址失败"); } } @@ -251,35 +249,20 @@ public class VideoTaskSchedule { } private void pictureHandle(String url, Long contentId, EventRecordEntity record, TaskEntity task) { - -// FileUtil.ByteArrayMultipartFile multipartFile = null; -// try { -// multipartFile = FileUtil.getMultipartFileFromPureUrl(url); -// if (ObjectUtil.isEmpty(multipartFile.getContentType())) { -// multipartFile.setContentType(FileUtil.IMG); -// } -// } catch (IOException e) { -// log.error("获取截图文件失败", e); -// record.setCurrentValue("获取截图文件失败"); -// return; -// } - -// R fileResponse = ossClient.putFileByNameAndTenantId("file", multipartFile, task.getTenantId()); -// log.info("【taskId:{}}】视频巡检任务执行,上传minio结果,{}", task.getId(), Optional.ofNullable(fileResponse).map(JsonUtil::toJson).orElse("null")); -// if (fileResponse.isSuccess()) { -// record.setFileUrl(Optional.ofNullable(fileResponse.getData().getLink()).orElse(record.getFileUrl())); -// } - try { - BladeFile bladeFile = fileUploaderService.upload(url, UUID.randomUUID().toString()+".jpg"); - record.setFileUrl(Optional.ofNullable(bladeFile.getLink()).orElse(record.getFileUrl())); - } catch (Exception e) { - log.error("获取截图文件失败", e); - record.setCurrentValue("获取截图文件失败"); + XxlJobHelper.log("【taskId:{}}】视频巡检任务执行,上传minio url={}", task.getId(), url); + try { + BladeFile bladeFile = fileUploaderService.upload(url, UUID.randomUUID().toString() + ".jpg"); + record.setFileUrl(Optional.ofNullable(bladeFile.getLink()).orElse(record.getFileUrl())); + } catch (Exception e) { + XxlJobHelper.log("【taskId:{}}】视频巡检任务执行,上传minio失败", task.getId()); + record.setCurrentStatus(TaskContants.CurrentStatusEnum.abnormal.getType()); + record.setCurrentValue("截图文件上传失败"); return; - } + } ContentEntity content = contentService.getById(contentId); if (StringUtil.isBlank(content.getMultiCheckTypeSon())) { + record.setCurrentStatus(TaskContants.CurrentStatusEnum.abnormal.getType()); record.setCurrentValue("没有找到巡检内容"); return; } @@ -289,12 +272,19 @@ public class VideoTaskSchedule { BigModelAnalysisRequestDTO analysisRequest = new BigModelAnalysisRequestDTO(); analysisRequest.setCheckTypeSonList(checkTypeSonList); analysisRequest.setUrl(url); + log.info("【taskId:{}}】视频巡检任务执行,大模型分析请求,{}", task.getId(), Optional.ofNullable(analysisRequest).map(JsonUtil::toJson).orElse("null")); + XxlJobHelper.log("【taskId:{}}】视频巡检任务执行,大模型分析请求,{}", task.getId(), Optional.ofNullable(analysisRequest).map(JsonUtil::toJson).orElse("null")); + BigModelAnalysisResponseDTO analysisResponse = bigModelClient.analysis(analysisRequest); + log.info("【taskId:{}}】视频巡检任务执行,大模型分析结果,{}", task.getId(), Optional.ofNullable(analysisResponse).map(JsonUtil::toJson).orElse("null")); + XxlJobHelper.log("【taskId:{}}】视频巡检任务执行,大模型分析结果,{}", task.getId(), Optional.ofNullable(analysisResponse).map(JsonUtil::toJson).orElse("null")); if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { + record.setCurrentStatus(TaskContants.CurrentStatusEnum.abnormal.getType()); record.setCurrentValue("大模型分析失败"); - log.error("【taskId:{}}】,返回消息 : {}" , task.getId(),Optional.ofNullable(analysisResponse).map(JsonUtil::toJson).orElse("null")); + log.error("【taskId:{}}】,返回消息 : {}", task.getId(), Optional.ofNullable(analysisResponse).map(JsonUtil::toJson).orElse("null")); + XxlJobHelper.log("【taskId:{}}】,返回消息 : {}", task.getId(), Optional.ofNullable(analysisResponse).map(JsonUtil::toJson).orElse("null")); return; } List results = analysisResponse.getData(); @@ -308,7 +298,7 @@ public class VideoTaskSchedule { sendMessage(result.getMessage(), task, content); } } - record.setCurrentStatus(status ? "1" : "0"); + record.setCurrentStatus(status ? TaskContants.CurrentStatusEnum.normal.getType() : TaskContants.CurrentStatusEnum.abnormal.getType()); record.setCurrentValue(stringBuilder.toString()); }