Browse Source

fix: 视频巡检功能

zhongwei
haungxing 3 months ago
parent
commit
ae8fd586a2
  1. 3
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/feign/IImageAnalysisClient.java
  2. 13
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java
  3. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java
  4. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/ParamKeyConstants.java
  5. 26
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java
  6. 5
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/feign/ImageAnalysisClient.java
  7. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IZhiPuBigModelService.java
  8. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/ZhiPuBigModelServiceImpl.java

3
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 org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Author: ypj * @Author: ypj
@ -18,5 +19,5 @@ public interface IImageAnalysisClient {
String ANALYSIS_BY_STATION_ID = "/analysisByStationId"; String ANALYSIS_BY_STATION_ID = "/analysisByStationId";
@PostMapping(API_PREFIX + ANALYSIS_BY_STATION_ID) @PostMapping(API_PREFIX + ANALYSIS_BY_STATION_ID)
List<ZhiPuImageAnalysisDTO> analysisByStationId(@RequestBody Long stationId); List<ZhiPuImageAnalysisDTO> analysisByStationId(@RequestBody Map<String,String> request);
} }

13
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/database/service/WeaviateService.java

@ -90,19 +90,24 @@ public class WeaviateService {
List<Map<String, Float[]>> vector = this.splitVector(entities.size(), attrsMap, vectors); List<Map<String, Float[]>> vector = this.splitVector(entities.size(), attrsMap, vectors);
for(int i = 0; i < entities.size(); i++) { for(int i = 0; i < entities.size(); i++) {
// log.info("vector:{}",JSON.toJSONString(vector.get(i))); // log.info("vector:{}",JSON.toJSONString(vector.get(i)));
JSONObject object = JSONObject.parseObject(JSON.toJSONString(entities.get(i))); Map<String, Object> properties = this.objectToMap(entities.get(i));
Map<String,Object> properties = new HashMap<>();
object.forEach((k,v) -> properties.put(k,v));
log.info("properties:{}",JSON.toJSONString(properties)); log.info("properties:{}",JSON.toJSONString(properties));
creator.withProperties(properties).withVectors(vector.get(i)).run(); creator.withProperties(properties).withVectors(vector.get(i)).run();
} }
} else { } else {
entities.forEach(entity -> creator.withProperties(BeanUtil.toMap(entity)).run()); entities.forEach(entity -> creator.withProperties(this.objectToMap(entity)).run());
return true; return true;
} }
return false; return false;
} }
private Map<String,Object> objectToMap(Object object) {
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(object));
Map<String,Object> properties = new HashMap<>();
jsonObject.forEach((k,v) -> properties.put(k,v));
return properties;
}
/** /**
* 删除向量数据库表名 * 删除向量数据库表名
* @param className 表名 * @param className 表名

4
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"), CHOOSE("4"),
/**确认**/ /**确认**/
CONFIRM("5"), CONFIRM("5"),
CHART("6"); CHART("6"),
IMAGE_TEXT("7")
;
; ;
@Getter @Getter
private String type; private String type;

4
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"; String CANVAS_V4_PATH = "hzims:bigModel:canvas:v4:path";
/**实时画面云组态路径 hzinfo-data-scada/view/{projectId}/{id}?source=app**/ /**实时画面云组态路径 hzinfo-data-scada/view/{projectId}/{id}?source=app**/
String CANVAS_YZT_PATH = "hzims:bigModel:canvas:yzt:path"; 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";
} }

26
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; package com.hnac.hzims.bigmodel.interactive.service.impl;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.factory.AnswerResolveFactory;
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.ParamCache;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.hnac.hzims.bigmodel.interactive.constants.ParamKeyConstants;
import java.util.HashMap;
/** /**
* @Author: huangxing * @Author: huangxing
@ -26,7 +33,24 @@ public class ControlAnswerResolveServiceImpl implements IAnswerResolveService {
@Override @Override
public ExtraVO getExtra(JSONObject originExtra) { public ExtraVO getExtra(JSONObject originExtra) {
// 若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)); log.info("控制指令传参为:{}", JSON.toJSONString(originExtra));
return null; String stationId = params.getString("stationId");
HashMap<String, String> 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;
} }
} }

5
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/feign/ImageAnalysisClient.java

@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Author: ypj * @Author: ypj
@ -22,7 +23,7 @@ public class ImageAnalysisClient implements IImageAnalysisClient {
@Override @Override
@PostMapping(ANALYSIS_BY_STATION_ID) @PostMapping(ANALYSIS_BY_STATION_ID)
public List<ZhiPuImageAnalysisDTO> analysisByStationId(@RequestBody Long stationId) { public List<ZhiPuImageAnalysisDTO> analysisByStationId(@RequestBody Map<String,String> request) {
return zhiPuBigModelService.analysisImgByStationId(stationId); return zhiPuBigModelService.analysisImgByStationId(request.get("stationId"));
} }
} }

2
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 * @Date: 2024/8/29 13:58
*/ */
public interface IZhiPuBigModelService { public interface IZhiPuBigModelService {
List<ZhiPuImageAnalysisDTO> analysisImgByStationId(Long stationId); List<ZhiPuImageAnalysisDTO> analysisImgByStationId(String stationId);
List<String> getZhiPuAnalysisType(String[] originalCode); List<String> getZhiPuAnalysisType(String[] originalCode);
} }

4
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 = "\\^"; private static final String CAMERA_TYPE_SPLIT = "\\^";
@Override @Override
public List<ZhiPuImageAnalysisDTO> analysisImgByStationId(Long stationId) { public List<ZhiPuImageAnalysisDTO> analysisImgByStationId(String stationId) {
List<ZhiPuImageAnalysisDTO> result = new ArrayList<>(); List<ZhiPuImageAnalysisDTO> result = new ArrayList<>();
List<StationVideoTypeEntity> videoList = stationVideoTypeClient.listByStationId(stationId.toString()); List<StationVideoTypeEntity> videoList = stationVideoTypeClient.listByStationId(stationId);
if (CollectionUtil.isEmpty(videoList)) { if (CollectionUtil.isEmpty(videoList)) {
return result; return result;
} }

Loading…
Cancel
Save