diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/feign/IImageAnalysisClient.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/feign/IImageAnalysisClient.java index 8be314b..a3836a8 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/feign/IImageAnalysisClient.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/feign/IImageAnalysisClient.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; +import java.util.Map; /** * @Author: ypj @@ -18,5 +19,5 @@ public interface IImageAnalysisClient { String ANALYSIS_BY_STATION_ID = "/analysisByStationId"; @PostMapping(API_PREFIX + ANALYSIS_BY_STATION_ID) - List analysisByStationId(@RequestBody Long stationId); + List analysisByStationId(@RequestBody Map request); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java index 5b0f00e..cc43acf 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java @@ -90,19 +90,24 @@ public class WeaviateService { List> vector = this.splitVector(entities.size(), attrsMap, vectors); for(int i = 0; i < entities.size(); i++) { // log.info("vector:{}",JSON.toJSONString(vector.get(i))); - JSONObject object = JSONObject.parseObject(JSON.toJSONString(entities.get(i))); - Map properties = new HashMap<>(); - object.forEach((k,v) -> properties.put(k,v)); + Map properties = this.objectToMap(entities.get(i)); log.info("properties:{}",JSON.toJSONString(properties)); creator.withProperties(properties).withVectors(vector.get(i)).run(); } } else { - entities.forEach(entity -> creator.withProperties(BeanUtil.toMap(entity)).run()); + entities.forEach(entity -> creator.withProperties(this.objectToMap(entity)).run()); return true; } return false; } + private Map objectToMap(Object object) { + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object)); + Map properties = new HashMap<>(); + jsonObject.forEach((k,v) -> properties.put(k,v)); + return properties; + } + /** * 删除向量数据库(表名) * @param className 表名 @@ -204,16 +209,8 @@ public class WeaviateService { private String getFieldValue(String fields,Object object) { - Class clazz = object.getClass(); - return Func.toStrList(",", fields).stream().map(field -> { - try { - Field declaredField = clazz.getDeclaredField(field); - declaredField.setAccessible(true); - return declaredField.get(object).toString(); - } catch (NoSuchFieldException | IllegalAccessException e) { - return null; - } - }).collect(Collectors.joining(" ")); + JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object)); + return Func.toStrList(",", fields).stream().map(field -> jsonObject.getString(field)).collect(Collectors.joining(" ")); } /** diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java index 4005c37..097d57e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java @@ -24,7 +24,9 @@ public interface FunctionConstants { CHOOSE("4"), /**确认**/ CONFIRM("5"), - CHART("6"); + CHART("6"), + IMAGE_TEXT("7") + ; ; @Getter private String type; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java index cb7b02a..5032198 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java @@ -15,5 +15,9 @@ public interface ParamKeyConstants { String CANVAS_V4_PATH = "hzims:bigModel:canvas:v4:path"; /**实时画面云组态路径 hzinfo-data-scada/view/{projectId}/{id}?source=app**/ String CANVAS_YZT_PATH = "hzims:bigModel:canvas:yzt:path"; + /**视频巡检指令编号**/ + String VIDEO_INSPECTION_CODE = "gglm:bigModel:video:inspection:code"; + /**视频巡检识别url**/ + String VIDEO_INSPECTION_URL = "gglm:bigModel:video:inspection:url"; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java index 8037e44..2159025 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java @@ -1,13 +1,20 @@ package com.hnac.hzims.bigmodel.interactive.service.impl; +import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.cache.ParamCache; import org.springframework.stereotype.Service; +import com.hnac.hzims.bigmodel.interactive.constants.ParamKeyConstants; + +import java.util.HashMap; /** * @Author: huangxing @@ -26,7 +33,24 @@ public class ControlAnswerResolveServiceImpl implements IAnswerResolveService { @Override public ExtraVO getExtra(JSONObject originExtra) { - log.info("控制指令传参为:{}", JSON.toJSONString(originExtra)); - return null; + // 若extra中 itemId 为 spxj 则为视频巡检需特殊处理 + JSONObject params = originExtra.getJSONObject("params"); + if(Func.isNotEmpty(params) && Func.isNotEmpty(params.getString("itemId"))) { + String itemId = ParamCache.getValue(ParamKeyConstants.VIDEO_INSPECTION_CODE); + String url = ParamCache.getValue(ParamKeyConstants.VIDEO_INSPECTION_URL); + if(Func.isNotEmpty(itemId) && Func.isNotEmpty(url) + && itemId.equals(params.getString("itemId")) && Func.isNotEmpty(params.getString("stationId"))) { + log.info("控制指令传参为:{}", JSON.toJSONString(originExtra)); + String stationId = params.getString("stationId"); + HashMap param = new HashMap<>(1); + param.put("stationId",stationId); + String body = HttpRequest.post(url).body(JSON.toJSONString(param)).execute().body(); + params.put("data",body); + log.info("识别结果为:{}", body); + } + } + ExtraVO result = originExtra.toJavaObject(ExtraVO.class); + result.setType(FunctionConstants.TypeEnum.IMAGE_TEXT.getType()); + return result; } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/feign/ImageAnalysisClient.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/feign/ImageAnalysisClient.java index 816853d..83eb8d7 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/feign/ImageAnalysisClient.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/feign/ImageAnalysisClient.java @@ -4,10 +4,12 @@ import com.hnac.hzinfo.inspect.ai.service.IZhiPuBigModelService; import com.hnac.hzinfo.inspect.ai.vo.ZhiPuImageAnalysisDTO; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; /** * @Author: ypj @@ -21,7 +23,7 @@ public class ImageAnalysisClient implements IImageAnalysisClient { @Override @PostMapping(ANALYSIS_BY_STATION_ID) - public List analysisByStationId(Long stationId) { - return zhiPuBigModelService.analysisImgByStationId(stationId); + public List analysisByStationId(@RequestBody Map request) { + return zhiPuBigModelService.analysisImgByStationId(request.get("stationId")); } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IZhiPuBigModelService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IZhiPuBigModelService.java index 14b0801..f4b8125 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IZhiPuBigModelService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IZhiPuBigModelService.java @@ -9,7 +9,7 @@ import java.util.List; * @Date: 2024/8/29 13:58 */ public interface IZhiPuBigModelService { - List analysisImgByStationId(Long stationId); + List analysisImgByStationId(String stationId); List getZhiPuAnalysisType(String[] originalCode); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java index 37bb18f..d62d84c 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java @@ -45,9 +45,9 @@ public class ZhiPuBigModelServiceImpl implements IZhiPuBigModelService { private static final String CAMERA_TYPE_SPLIT = "\\^"; @Override - public List analysisImgByStationId(Long stationId) { + public List analysisImgByStationId(String stationId) { List result = new ArrayList<>(); - List videoList = stationVideoTypeClient.listByStationId(stationId.toString()); + List videoList = stationVideoTypeClient.listByStationId(stationId); if (CollectionUtil.isEmpty(videoList)) { return result; } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java index ebfa615..29280c2 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java @@ -129,5 +129,5 @@ public interface TaskMapper extends UserDataScopeBaseMapper { List getSameDayTask(@Param("taskIds") List taskIds, @Param("status") String status,@Param("startDate") String startDate,@Param("endDate") String endDate); - List getListByUserIdAndStatus(Long userId, String autoVideo, List taskStatus,String time); + List getListByUserIdAndStatus(@Param("userId") Long userId, @Param("autoVideo") String autoVideo, @Param("taskStatus") List taskStatus, @Param("time") String time); }