From 2c9dccaef6580c210bd4b095da10ec0d84219369 Mon Sep 17 00:00:00 2001 From: luyie Date: Thu, 22 Aug 2024 09:20:10 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=B7=A1=E6=A3=80=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=8C=E8=BF=94=E5=9B=9E=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=B7=A1=E6=A3=80=E5=86=85=E5=AE=B9=E6=96=B0=E5=8A=A0=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspect/obj/entity/ProjectContentEntity.java | 14 +++++++++++++ .../zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java | 24 +++++++++++----------- .../inspect/obj/mapper/ProjectContentMapper.xml | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ProjectContentEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ProjectContentEntity.java index 508c4f6..16b621a 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ProjectContentEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ProjectContentEntity.java @@ -65,6 +65,20 @@ public class ProjectContentEntity extends BaseEntity { private String checkTypeSon; /** + * 检测类型子类(多组) + */ + @ApiModelProperty(value = "检测类型子类(多组)") + @TableField(exist = false) + private String multiCheckTypeSon; + + /** + * ai识别分析方式,设备或大模型 + */ + @ApiModelProperty(value = "ai识别分析方式,设备或大模型") + @TableField(exist = false) + private String analyserType; + + /** * 表针识别,表盘ID */ @ApiModelProperty(value = "表针识别,表盘ID") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java index 7dae059..0f0925a 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.zhipuai.handler; +import cn.hutool.core.lang.Assert; import com.hnac.hzinfo.exception.HzServiceException; import com.zhipu.oapi.Constants; import com.zhipu.oapi.service.v4.model.ChatCompletionRequest; @@ -35,7 +36,7 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { @Override public ModelApiResponse sendRequest(String text, String url) { ChatCompletionRequest request = getRequest(text, url); - log.info("send zhipu ai request :{}", Optional.ofNullable(request).map(req -> JsonUtil.toJson(req)).orElse("null")); + log.info("send zhipu ai request :{}", Optional.ofNullable(request).map(JsonUtil::toJson).orElse("null")); return client.invokeModelApi(request); } @@ -70,19 +71,18 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { @Override public String getResult(String text, String url) { ModelApiResponse response = sendRequest(text, url); - log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(resp -> JsonUtil.toJson(resp)).orElse("null")); - if (response.isSuccess()) { - try { - String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString(); - resultJson = resultJson.substring(resultJson.indexOf("{"), resultJson.lastIndexOf("}") + 1).trim(); - return resultJson; - } catch (Exception e) { - log.info("get data from response error", e); - } - } else { + log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(JsonUtil::toJson).orElse("null")); + Assert.isTrue(Objects.nonNull(response) && response.isSuccess(), () -> { throw new HzServiceException(response.getMsg()); + }); + try { + String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString(); + resultJson = resultJson.substring(resultJson.indexOf("{"), resultJson.lastIndexOf("}") + 1).trim(); + return resultJson; + } catch (Exception e) { + log.info("get data from response error", e); + throw new HzServiceException("获取数据失败"); } - return null; } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.xml b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.xml index 9f9d5d5..517898c 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.xml +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.xml @@ -3,7 +3,7 @@