|
|
|
@ -11,6 +11,7 @@ import com.hnac.hzims.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; |
|
|
|
@ -36,19 +37,25 @@ 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.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 org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
@ -78,6 +85,8 @@ public class VideoTaskSchedule {
|
|
|
|
|
private final IOssClient ossClient; |
|
|
|
|
private final ContentService contentService; |
|
|
|
|
private final IBigModelAnalysisClient bigModelClient; |
|
|
|
|
private final IMessageClient messageClient; |
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 视频巡检任务执行 |
|
|
|
@ -180,7 +189,7 @@ public class VideoTaskSchedule {
|
|
|
|
|
String picUrl = hikApiService.manualCapture(camera.getPointCode()); |
|
|
|
|
record.setFileUrl(picUrl); |
|
|
|
|
record.setCurrentValue(picUrl); |
|
|
|
|
pictureHandle(picUrl, content.getContentId(), record); |
|
|
|
|
pictureHandle(picUrl, content.getContentId(), record, task); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return record; |
|
|
|
@ -233,8 +242,15 @@ public class VideoTaskSchedule {
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void pictureHandle(String url, Long contentId, EventRecordEntity record) { |
|
|
|
|
MultipartFile multipartFile = FileUtil.getMultipartFileFromUrl(url); |
|
|
|
|
private void pictureHandle(String url, Long contentId, EventRecordEntity record, TaskEntity task) { |
|
|
|
|
|
|
|
|
|
MultipartFile multipartFile = null; |
|
|
|
|
try { |
|
|
|
|
multipartFile = FileUtil.getMultipartFileFromUrl(url); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
log.error("获取截图文件失败", e); |
|
|
|
|
throw new HzServiceException("获取截图文件失败"); |
|
|
|
|
} |
|
|
|
|
R<BladeFile> fileResponse = ossClient.putFile(multipartFile); |
|
|
|
|
if (fileResponse.isSuccess()) { |
|
|
|
|
record.setFileUrl(Optional.ofNullable(fileResponse.getData().getLink()).orElse(record.getFileUrl())); |
|
|
|
@ -245,23 +261,64 @@ public class VideoTaskSchedule {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String[] typeArray = content.getMultiCheckTypeSon().split(","); |
|
|
|
|
List<String> checkTypeSonList = Arrays.asList(typeArray); |
|
|
|
|
String text = null; |
|
|
|
|
try { |
|
|
|
|
String[] typeArray = content.getMultiCheckTypeSon().split(","); |
|
|
|
|
List<String> checkTypeSonList = Arrays.asList(typeArray); |
|
|
|
|
String text = FileUtil.getBase64(multipartFile.getBytes()); |
|
|
|
|
BigModelAnalysisRequestDTO analysisRequest = new BigModelAnalysisRequestDTO(); |
|
|
|
|
analysisRequest.setCheckTypeSonList(checkTypeSonList); |
|
|
|
|
analysisRequest.setUrl(text); |
|
|
|
|
BigModelAnalysisResponseDTO analysisResponse = bigModelClient.analysis(analysisRequest); |
|
|
|
|
if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { |
|
|
|
|
return; |
|
|
|
|
text = FileUtil.getBase64(multipartFile.getBytes()); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
log.error("转换截图文件内容失败", e); |
|
|
|
|
throw new HzServiceException("转换截图文件内容失败"); |
|
|
|
|
} |
|
|
|
|
BigModelAnalysisRequestDTO analysisRequest = new BigModelAnalysisRequestDTO(); |
|
|
|
|
analysisRequest.setCheckTypeSonList(checkTypeSonList); |
|
|
|
|
analysisRequest.setUrl(text); |
|
|
|
|
BigModelAnalysisResponseDTO analysisResponse = bigModelClient.analysis(analysisRequest); |
|
|
|
|
if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { |
|
|
|
|
throw new HzServiceException("大模型识别失败"); |
|
|
|
|
} |
|
|
|
|
List<BigModelAnalysisResponseDTO.BigModelAnalysisResult> results = analysisResponse.getData(); |
|
|
|
|
StringBuilder stringBuilder = new StringBuilder(); |
|
|
|
|
Boolean status = Boolean.TRUE; |
|
|
|
|
for (BigModelAnalysisResponseDTO.BigModelAnalysisResult result : results) { |
|
|
|
|
stringBuilder.append(result.getDescription()).append("\n"); |
|
|
|
|
Boolean isGood = (Boolean) result.getResult(); |
|
|
|
|
status = status && isGood; |
|
|
|
|
if (!isGood) { |
|
|
|
|
sendMessage(result.getMessage(), task, content); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("video task get big model analysis result fail", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
record.setCurrentStatus(status ? "1" : "0"); |
|
|
|
|
record.setCurrentValue(stringBuilder.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void sendMessage(String messageText, TaskEntity task, ContentEntity content) { |
|
|
|
|
BusinessMessageDTO messageDTO = new BusinessMessageDTO(); |
|
|
|
|
messageDTO.setBusinessClassify("inspect"); |
|
|
|
|
messageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.INSPECT.getKey()); |
|
|
|
|
messageDTO.setSubject(MessageConstants.BusinessClassifyEnum.INSPECT.getDescription()); |
|
|
|
|
messageDTO.setTaskId(task.getId()); |
|
|
|
|
messageDTO.setTenantId(task.getTenantId()); |
|
|
|
|
messageDTO.setDeptId(task.getCreateDept()); |
|
|
|
|
messageDTO.setUserIds(String.valueOf(task.getUserId())); |
|
|
|
|
messageDTO.setCreateUser(task.getCreateUser()); |
|
|
|
|
StringBuilder textBuilder = new StringBuilder(); |
|
|
|
|
textBuilder.append(task.getPlanName()); |
|
|
|
|
if (StringUtil.isNotBlank(task.getBatchNumber())) { |
|
|
|
|
textBuilder.append(",").append(task.getBatchNumber()); |
|
|
|
|
} |
|
|
|
|
if (StringUtil.isNotBlank(task.getRouteName())) { |
|
|
|
|
textBuilder.append(",").append(task.getRouteName()); |
|
|
|
|
} |
|
|
|
|
if (StringUtil.isNotBlank(content.getName())) { |
|
|
|
|
textBuilder.append(",").append(content.getName()); |
|
|
|
|
} |
|
|
|
|
textBuilder.append(",").append(messageText); |
|
|
|
|
messageDTO.setContent(textBuilder.toString()); |
|
|
|
|
R booleanR = messageClient.sendAppAndWsMsgByUsers(messageDTO); |
|
|
|
|
if (!booleanR.isSuccess()) { |
|
|
|
|
throw new ServiceException("消息推送失败"); |
|
|
|
|
} |
|
|
|
|
log.info("推送成功~"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|