Browse Source

/*callRemoteAlgorithm接口梳理*/

master
htjcAdmin 8 months ago
parent
commit
e5af46f989
1 changed files with 41 additions and 41 deletions
  1. +41
    -41
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java

+ 41
- 41
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java View File

@ -705,59 +705,61 @@ public class PatrolResultController extends BaseController {
logger.info("callRemoteAlgorithm ftpInfo: {}, ANALYSIS_URL: {}, BIG_ANALYSIS_URL: {}, MAJOR_URL: {}, TASK_PORT: {}", logger.info("callRemoteAlgorithm ftpInfo: {}, ANALYSIS_URL: {}, BIG_ANALYSIS_URL: {}, MAJOR_URL: {}, TASK_PORT: {}",
ftp, ANALYSIS_URL, BIG_ANALYSIS_URL, MAJOR_URL, TASK_PORT); ftp, ANALYSIS_URL, BIG_ANALYSIS_URL, MAJOR_URL, TASK_PORT);
logger.info("callRemoteAlgorithm patrolResultList: " + patrolResultList);
logger.info("callRemoteAlgorithm patrolResultList: {}", patrolResultList);
String ids = ""; String ids = "";
for (PatrolResult patrolResult : patrolResultList) { for (PatrolResult patrolResult : patrolResultList) {
List<AnalyseReqItem> filterList = new ArrayList<>();
List<AnalyseReqItem> bigList = new ArrayList<>();
List<AnalyseReqItem> firList = new ArrayList<>();
List<AnalyseReqItem> filterList = new ArrayList<>(); //初筛
List<AnalyseReqItem> bigModelList = new ArrayList<>(); //大模型
List<AnalyseReqItem> infraredList = new ArrayList<>();//红外 根据最新做法红外要归到大模型里面由大模型来调用需要调整如下逻辑-20250423
String image = patrolResult.getFilePath().replace(ftp.getFtpPath() + "/", StringUtils.EMPTY); String image = patrolResult.getFilePath().replace(ftp.getFtpPath() + "/", StringUtils.EMPTY);
String imageType = patrolResult.getFileType(); String imageType = patrolResult.getFileType();
AnalyseReqItem analyseReqItem = new AnalyseReqItem(); AnalyseReqItem analyseReqItem = new AnalyseReqItem();
analyseReqItem.setObjectId(patrolResult.getDeviceId()); analyseReqItem.setObjectId(patrolResult.getDeviceId());
Map<String, String> map = patrolResultService.selectAlgorithmType(patrolResult.getDeviceId());
String[] strings = new String[1];
List<String> algIds = new ArrayList<>();
logger.info("callRemoteAlgorithm algorithmTypeMap: " + map);
if (map != null) {
String subIdStr = map.get("alg_subtype_ids");
//根据basedata_patrolpoint中的patrol_type_id(对应patrol_result表中的device_id)查询该预置位配置的算法列表
Map<String, String> algSubtypeIdMap = patrolResultService.selectAlgorithmType(patrolResult.getDeviceId());
List<String> algSubtypeIdList = new ArrayList<>();
logger.info("callRemoteAlgorithm algorithmTypeMap: {}", algSubtypeIdMap);
if (algSubtypeIdMap != null) {
String subIdStr = algSubtypeIdMap.get("alg_subtype_ids");
if (subIdStr.contains(StringUtils.COMMA)) { if (subIdStr.contains(StringUtils.COMMA)) {
String[] subIds = subIdStr.split(StringUtils.COMMA); String[] subIds = subIdStr.split(StringUtils.COMMA);
for (String subId : subIds) { for (String subId : subIds) {
if (StringUtils.isNotEmpty(subId)) { if (StringUtils.isNotEmpty(subId)) {
algIds.add(subId);
algSubtypeIdList.add(subId);
} }
} }
} else { } else {
algIds.add(subIdStr);
algSubtypeIdList.add(subIdStr);
} }
} }
PatrolResult patrolResultTemp = new PatrolResult(); PatrolResult patrolResultTemp = new PatrolResult();
if (!algIds.isEmpty()) {
patrolResultTemp.setAlgId(algIds);
if (!algSubtypeIdList.isEmpty()) {
patrolResultTemp.setAlgId(algSubtypeIdList);
} }
List<AlgInfo> algInfoList = new ArrayList<>(); List<AlgInfo> algInfoList = new ArrayList<>();
if (patrolResultTemp.getAlgId() != null && !patrolResultTemp.getAlgId().isEmpty()) { if (patrolResultTemp.getAlgId() != null && !patrolResultTemp.getAlgId().isEmpty()) {
algInfoList = patrolResultService.selectAlgInfo(patrolResultTemp); algInfoList = patrolResultService.selectAlgInfo(patrolResultTemp);
} }
logger.info("callRemoteAlgorithm algInfoList: {}", algInfoList);
logger.info("callRemoteAlgorithm algInfoList start: {}", algInfoList);
analyseReqItem.setImageUrlList(image.split(StringUtils.COMMA)); analyseReqItem.setImageUrlList(image.split(StringUtils.COMMA));
String pictureFrame = patrolTaskService.selectConfigByKey("PICTURE_FRAME"); String pictureFrame = patrolTaskService.selectConfigByKey("PICTURE_FRAME");
logger.info("callRemoteAlgorithm pictureFrame: {}", pictureFrame); logger.info("callRemoteAlgorithm pictureFrame: {}", pictureFrame);
String[] strings = new String[1];
String type; String type;
if (!algInfoList.isEmpty()) { if (!algInfoList.isEmpty()) {
List<AlgInfo> infraredList = algInfoList.stream().filter((item) -> {
logger.info("callRemoteAlgorithm item.getAlgSubtypeCode(): " + item.getAlgSubtypeCode());
// 处理红外请求目前讨论的结果以及方案要归到大模型逻辑本接口这部分处理后续要废掉
List<AlgInfo> infraredAlgInfoList = algInfoList.stream().filter((item) -> {
return "infrared".equals(item.getAlgSubtypeCode()); return "infrared".equals(item.getAlgSubtypeCode());
}).collect(Collectors.toList()); }).collect(Collectors.toList());
logger.info("callRemoteAlgorithm infraredList: {}", infraredAlgInfoList);
String[] typeArr; String[] typeArr;
if (!infraredList.isEmpty() && "true".equals(pictureFrame)) {
if (!infraredAlgInfoList.isEmpty() && "true".equals(pictureFrame)) {
Map<String, Object> device = resultAnalysisService.selectEqInfoByCode(patrolResult.getPatrolDeviceCode()); Map<String, Object> device = resultAnalysisService.selectEqInfoByCode(patrolResult.getPatrolDeviceCode());
if (device != null && device.get("type") != null) { if (device != null && device.get("type") != null) {
type = device.get("type") + ""; type = device.get("type") + "";
@ -778,10 +780,10 @@ public class PatrolResultController extends BaseController {
ids = patrolResult.getLineId() + ""; ids = patrolResult.getLineId() + "";
analyseReqItem.setImageUrlList(typeArr); analyseReqItem.setImageUrlList(typeArr);
analyseReqItem.setTypeList(strings); analyseReqItem.setTypeList(strings);
firList.add(analyseReqItem.clone());
infraredList.add(analyseReqItem.clone());
} }
algInfoList.removeAll(infraredList);
algInfoList.removeAll(infraredAlgInfoList);
List<String> imagelist = new ArrayList<>(); List<String> imagelist = new ArrayList<>();
if (image.contains(StringUtils.COMMA)) { if (image.contains(StringUtils.COMMA)) {
typeArr = imageType.split(StringUtils.COMMA); typeArr = imageType.split(StringUtils.COMMA);
@ -798,9 +800,9 @@ public class PatrolResultController extends BaseController {
} }
Map<String, String> judgeMap = resultAnalysisService.selectPointInfoById(patrolResult.getDeviceId()); Map<String, String> judgeMap = resultAnalysisService.selectPointInfoById(patrolResult.getDeviceId());
logger.info("callRemoteAlgorithm judgeMap: " + judgeMap.toString());
logger.info("callRemoteAlgorithm judgeMap: {}", judgeMap.toString());
String filePanpath = ""; String filePanpath = "";
if (judgeMap != null && StringUtils.isNotEmpty(judgeMap.get("dis_ref_picture_path"))) {
if (StringUtils.isNotEmpty(judgeMap.get("dis_ref_picture_path"))) {
filePanpath = judgeMap.get("dis_ref_picture_path"); filePanpath = judgeMap.get("dis_ref_picture_path");
} }
@ -819,7 +821,7 @@ public class PatrolResultController extends BaseController {
analyseReqItem.setImageUrlList(images); analyseReqItem.setImageUrlList(images);
} }
bigList.add(analyseReqItem.clone());
bigModelList.add(analyseReqItem.clone());
} }
algInfoList.removeAll(judgeList); algInfoList.removeAll(judgeList);
@ -837,32 +839,32 @@ public class PatrolResultController extends BaseController {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (!defectList.isEmpty()) { if (!defectList.isEmpty()) {
analyseReqItem.setTypeList(defectList.stream().map(AlgInfo::getAlgSubtypeCode).toArray(String[]::new)); analyseReqItem.setTypeList(defectList.stream().map(AlgInfo::getAlgSubtypeCode).toArray(String[]::new));
bigList.add(analyseReqItem.clone());
bigModelList.add(analyseReqItem.clone());
} }
algInfoList.removeAll(defectList); algInfoList.removeAll(defectList);
if (!algInfoList.isEmpty()) { if (!algInfoList.isEmpty()) {
analyseReqItem.setTypeList(algInfoList.stream().map(AlgInfo::getAlgSubtypeCode).toArray(String[]::new)); analyseReqItem.setTypeList(algInfoList.stream().map(AlgInfo::getAlgSubtypeCode).toArray(String[]::new));
bigList.add(analyseReqItem.clone());
bigModelList.add(analyseReqItem.clone());
} }
} }
logger.info("callRemoteAlgorithm firList.isEmpty(): {}", firList.isEmpty());
if (!firList.isEmpty() && "true".equals(pictureFrame)) {
logger.info("callRemoteAlgorithm infraredList.isEmpty(): {}", infraredList.isEmpty());
if (!infraredList.isEmpty() && "true".equals(pictureFrame)) {
String uuid = UUID.randomUUID().toString().trim().replaceAll(StringUtils.DASH, StringUtils.EMPTY); String uuid = UUID.randomUUID().toString().trim().replaceAll(StringUtils.DASH, StringUtils.EMPTY);
redisService.setCacheObject(RedisConst.REQUEST_UUID + uuid, patrolResultList.get(0).getTaskPatrolledId(), 1L, TimeUnit.DAYS); redisService.setCacheObject(RedisConst.REQUEST_UUID + uuid, patrolResultList.get(0).getTaskPatrolledId(), 1L, TimeUnit.DAYS);
AnalyseRequest sendData = new AnalyseRequest(); AnalyseRequest sendData = new AnalyseRequest();
sendData.setObjectList(firList);
sendData.setObjectList(infraredList);
sendData.setRequestHostIp(MAJOR_URL); sendData.setRequestHostIp(MAJOR_URL);
sendData.setRequestHostPort(TASK_PORT); sendData.setRequestHostPort(TASK_PORT);
sendData.setRequestId(uuid); sendData.setRequestId(uuid);
type = JSONObject.toJSONString(sendData); type = JSONObject.toJSONString(sendData);
try { try {
logger.info("callRemoteAlgorithm infraredRequest: " + type);
logger.info("callRemoteAlgorithm infraredRequest: {}", type);
InfraredRequestParam infraredRequestParam = JSONObject.parseObject(type, InfraredRequestParam.class); InfraredRequestParam infraredRequestParam = JSONObject.parseObject(type, InfraredRequestParam.class);
InfraredResponse infraredResponse = infraredImageParser.parse(infraredRequestParam); InfraredResponse infraredResponse = infraredImageParser.parse(infraredRequestParam);
logger.info("callRemoteAlgorithm infraredResponse: " + infraredResponse);
logger.info("callRemoteAlgorithm infraredResponse: {}", infraredResponse);
if (infraredResponse != null) { if (infraredResponse != null) {
ResultAnalysis resultAnalysis = new ResultAnalysis(); ResultAnalysis resultAnalysis = new ResultAnalysis();
if (infraredResponse.getResultList() != null && !infraredResponse.getResultList().isEmpty()) { if (infraredResponse.getResultList() != null && !infraredResponse.getResultList().isEmpty()) {
@ -916,39 +918,37 @@ public class PatrolResultController extends BaseController {
} }
} }
logger.info("callRemoteAlgorithm algInfoList end: " + algInfoList);
logger.info("callRemoteAlgorithm filterList: " + filterList);
logger.info("callRemoteAlgorithm bigList: " + bigList);
logger.info("callRemoteAlgorithm algInfoList2: {}", algInfoList);
logger.info("callRemoteAlgorithm filterList: {}", filterList);
logger.info("callRemoteAlgorithm bigModelList: {}", bigModelList);
AnalyseRequest analyseReq; AnalyseRequest analyseReq;
//qinyl 初筛
if (!filterList.isEmpty()) { if (!filterList.isEmpty()) {
analyseReq = new AnalyseRequest(); analyseReq = new AnalyseRequest();
analyseReq.setTaskPatrolId(patrolResultList.get(0).getTaskPatrolledId()); analyseReq.setTaskPatrolId(patrolResultList.get(0).getTaskPatrolledId());
analyseReq.setObjectList(filterList); analyseReq.setObjectList(filterList);
analyseReq.setRequestHostIp(MAJOR_URL); analyseReq.setRequestHostIp(MAJOR_URL);
analyseReq.setRequestHostPort(TASK_PORT); analyseReq.setRequestHostPort(TASK_PORT);
//qinyl
if (filterList.get(0).getImageUrlList() != null && filterList.get(0).getImageUrlList().length > 0) { if (filterList.get(0).getImageUrlList() != null && filterList.get(0).getImageUrlList().length > 0) {
String meterFilter = patrolTaskService.selectConfigByKey("ANALYSE_IS_METER_FILTER"); String meterFilter = patrolTaskService.selectConfigByKey("ANALYSE_IS_METER_FILTER");
analyseRemoteService.sendRequest(analyseReq, filterList.get(0).getTypeList(), "1".equals(meterFilter)); analyseRemoteService.sendRequest(analyseReq, filterList.get(0).getTypeList(), "1".equals(meterFilter));
} }
} }
//qinyl
if (!bigList.isEmpty()) {
//qinyl 大模型
if (!bigModelList.isEmpty()) {
analyseReq = new AnalyseRequest(); analyseReq = new AnalyseRequest();
analyseReq.setTaskPatrolId(patrolResultList.get(0).getTaskPatrolledId()); analyseReq.setTaskPatrolId(patrolResultList.get(0).getTaskPatrolledId());
analyseReq.setObjectList(bigList);
analyseReq.setObjectList(bigModelList);
analyseReq.setRequestHostIp(MAJOR_URL); analyseReq.setRequestHostIp(MAJOR_URL);
analyseReq.setRequestHostPort(TASK_PORT); analyseReq.setRequestHostPort(TASK_PORT);
if (bigList.get(0).getImageUrlList() != null && bigList.get(0).getImageUrlList().length > 0) {
analyseRemoteService.sendRequest(analyseReq, bigList.get(0).getTypeList(), true);
if (bigModelList.get(0).getImageUrlList() != null && bigModelList.get(0).getImageUrlList().length > 0) {
analyseRemoteService.sendRequest(analyseReq, bigModelList.get(0).getTypeList(), true);
} }
} }
} }
return result; return result;
} }
public void sendWebsocket(PatrolTaskStatus patrolTaskStatus) { public void sendWebsocket(PatrolTaskStatus patrolTaskStatus) {


Loading…
Cancel
Save