Browse Source

add:视频巡检,大模型识别,存记录,推送消息

zhongwei
luyie 3 months ago
parent
commit
5203b73053
  1. 5
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java
  2. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java
  3. 8
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java
  4. 56
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java

5
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java

@ -46,8 +46,11 @@ public class BigModelAnalysisResponseDTO implements Serializable {
@ApiModelProperty(value = "结果描述") @ApiModelProperty(value = "结果描述")
private String description; private String description;
@ApiModelProperty(value = "结果描述") @ApiModelProperty(value = "巡检识别子类型")
private String checkTypeSon; private String checkTypeSon;
@ApiModelProperty(value = "消息")
private String message;
} }
public Boolean getSuccess() { public Boolean getSuccess() {

3
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java

@ -69,4 +69,7 @@ public class ZhipuAnalysisInfoEntity extends TenantEntity {
@TableField("RESULT_JUDGE_MODEL") @TableField("RESULT_JUDGE_MODEL")
private String resultJudgeModel; private String resultJudgeModel;
@ApiModelProperty(value = "消息")
@TableField("MESSAGE")
private String message;
} }

8
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java

@ -46,7 +46,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
private final String multiQuestionConstrains = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n"; private final String multiQuestionConstrains = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n";
private final String multiQuestionConstrainsList = "'问题{}'代表第{}个问题,"; private final String multiQuestionConstrainsList = "'{}'代表第{}个问题,";
@Override @Override
public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) { public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) {
@ -164,7 +164,11 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
if (ObjectUtil.isEmpty(strategyType)) { if (ObjectUtil.isEmpty(strategyType)) {
continue; continue;
} }
result.setResult(strategyType.getStrategy().getResult(infoEntity, resultObj)); Object conclusionObj = strategyType.getStrategy().getResult(infoEntity, resultObj);
result.setResult(conclusionObj);
if (conclusionObj instanceof Boolean && !(Boolean) conclusionObj) {
result.setMessage(infoEntity.getMessage());
}
} }
response.setData(results); response.setData(results);
response.setCode(ResultCode.SUCCESS.getCode()); response.setCode(ResultCode.SUCCESS.getCode());

56
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java

@ -36,13 +36,18 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.oss.model.BladeFile; import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil; 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.resource.feign.IOssClient;
import org.springblade.system.feign.ISysClient;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
@ -78,6 +83,8 @@ public class VideoTaskSchedule {
private final IOssClient ossClient; private final IOssClient ossClient;
private final ContentService contentService; private final ContentService contentService;
private final IBigModelAnalysisClient bigModelClient; private final IBigModelAnalysisClient bigModelClient;
private final IMessageClient messageClient;
private final ISysClient sysClient;
/** /**
* 视频巡检任务执行 * 视频巡检任务执行
@ -180,7 +187,7 @@ public class VideoTaskSchedule {
String picUrl = hikApiService.manualCapture(camera.getPointCode()); String picUrl = hikApiService.manualCapture(camera.getPointCode());
record.setFileUrl(picUrl); record.setFileUrl(picUrl);
record.setCurrentValue(picUrl); record.setCurrentValue(picUrl);
pictureHandle(picUrl, content.getContentId(), record); pictureHandle(picUrl, content.getContentId(), record, task);
} }
} }
return record; return record;
@ -233,7 +240,7 @@ public class VideoTaskSchedule {
return null; return null;
} }
private void pictureHandle(String url, Long contentId, EventRecordEntity record) { private void pictureHandle(String url, Long contentId, EventRecordEntity record, TaskEntity task) {
MultipartFile multipartFile = FileUtil.getMultipartFileFromUrl(url); MultipartFile multipartFile = FileUtil.getMultipartFileFromUrl(url);
R<BladeFile> fileResponse = ossClient.putFile(multipartFile); R<BladeFile> fileResponse = ossClient.putFile(multipartFile);
if (fileResponse.isSuccess()) { if (fileResponse.isSuccess()) {
@ -256,12 +263,51 @@ public class VideoTaskSchedule {
if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) {
return; return;
} }
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);
}
}
record.setCurrentStatus(status ? "1" : "0");
record.setCurrentValue(stringBuilder.toString());
} catch (Exception e) { } catch (Exception e) {
log.error("video task get big model analysis result fail", e); log.error("video task get big model analysis result fail", e);
} }
} }
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("推送成功~");
}
} }

Loading…
Cancel
Save