From e5af46f9897120eac4752210ddbeda7b523f2908 Mon Sep 17 00:00:00 2001 From: htjcAdmin Date: Wed, 23 Apr 2025 11:38:33 +0800 Subject: [PATCH] =?UTF-8?q?/*callRemoteAlgorithm=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=A2=B3=E7=90=86*/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PatrolResultController.java | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java b/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java index eeda9fb..30308ca 100644 --- a/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java +++ b/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java @@ -705,59 +705,61 @@ public class PatrolResultController extends BaseController { logger.info("callRemoteAlgorithm ftpInfo: {}, 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 = ""; for (PatrolResult patrolResult : patrolResultList) { - List filterList = new ArrayList<>(); - List bigList = new ArrayList<>(); - List firList = new ArrayList<>(); + List filterList = new ArrayList<>(); //初筛 + List bigModelList = new ArrayList<>(); //大模型 + List infraredList = new ArrayList<>();//红外 根据最新做法,红外要归到大模型里面,由大模型来调用(需要调整如下逻辑)-20250423 String image = patrolResult.getFilePath().replace(ftp.getFtpPath() + "/", StringUtils.EMPTY); String imageType = patrolResult.getFileType(); AnalyseReqItem analyseReqItem = new AnalyseReqItem(); analyseReqItem.setObjectId(patrolResult.getDeviceId()); - Map map = patrolResultService.selectAlgorithmType(patrolResult.getDeviceId()); - String[] strings = new String[1]; - List 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 algSubtypeIdMap = patrolResultService.selectAlgorithmType(patrolResult.getDeviceId()); + List algSubtypeIdList = new ArrayList<>(); + logger.info("callRemoteAlgorithm algorithmTypeMap: {}", algSubtypeIdMap); + if (algSubtypeIdMap != null) { + String subIdStr = algSubtypeIdMap.get("alg_subtype_ids"); if (subIdStr.contains(StringUtils.COMMA)) { String[] subIds = subIdStr.split(StringUtils.COMMA); for (String subId : subIds) { if (StringUtils.isNotEmpty(subId)) { - algIds.add(subId); + algSubtypeIdList.add(subId); } } } else { - algIds.add(subIdStr); + algSubtypeIdList.add(subIdStr); } } PatrolResult patrolResultTemp = new PatrolResult(); - if (!algIds.isEmpty()) { - patrolResultTemp.setAlgId(algIds); + if (!algSubtypeIdList.isEmpty()) { + patrolResultTemp.setAlgId(algSubtypeIdList); } List algInfoList = new ArrayList<>(); if (patrolResultTemp.getAlgId() != null && !patrolResultTemp.getAlgId().isEmpty()) { algInfoList = patrolResultService.selectAlgInfo(patrolResultTemp); } + logger.info("callRemoteAlgorithm algInfoList: {}", algInfoList); - logger.info("callRemoteAlgorithm algInfoList start: {}", algInfoList); analyseReqItem.setImageUrlList(image.split(StringUtils.COMMA)); String pictureFrame = patrolTaskService.selectConfigByKey("PICTURE_FRAME"); logger.info("callRemoteAlgorithm pictureFrame: {}", pictureFrame); + String[] strings = new String[1]; String type; if (!algInfoList.isEmpty()) { - List infraredList = algInfoList.stream().filter((item) -> { - logger.info("callRemoteAlgorithm item.getAlgSubtypeCode(): " + item.getAlgSubtypeCode()); + // 处理红外请求,目前讨论的结果以及方案要归到大模型逻辑,本接口这部分处理后续要废掉 + List infraredAlgInfoList = algInfoList.stream().filter((item) -> { return "infrared".equals(item.getAlgSubtypeCode()); }).collect(Collectors.toList()); + logger.info("callRemoteAlgorithm infraredList: {}", infraredAlgInfoList); String[] typeArr; - if (!infraredList.isEmpty() && "true".equals(pictureFrame)) { + if (!infraredAlgInfoList.isEmpty() && "true".equals(pictureFrame)) { Map device = resultAnalysisService.selectEqInfoByCode(patrolResult.getPatrolDeviceCode()); if (device != null && device.get("type") != null) { type = device.get("type") + ""; @@ -778,10 +780,10 @@ public class PatrolResultController extends BaseController { ids = patrolResult.getLineId() + ""; analyseReqItem.setImageUrlList(typeArr); analyseReqItem.setTypeList(strings); - firList.add(analyseReqItem.clone()); + infraredList.add(analyseReqItem.clone()); } - algInfoList.removeAll(infraredList); + algInfoList.removeAll(infraredAlgInfoList); List imagelist = new ArrayList<>(); if (image.contains(StringUtils.COMMA)) { typeArr = imageType.split(StringUtils.COMMA); @@ -798,9 +800,9 @@ public class PatrolResultController extends BaseController { } Map judgeMap = resultAnalysisService.selectPointInfoById(patrolResult.getDeviceId()); - logger.info("callRemoteAlgorithm judgeMap: " + judgeMap.toString()); + logger.info("callRemoteAlgorithm judgeMap: {}", judgeMap.toString()); 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"); } @@ -819,7 +821,7 @@ public class PatrolResultController extends BaseController { analyseReqItem.setImageUrlList(images); } - bigList.add(analyseReqItem.clone()); + bigModelList.add(analyseReqItem.clone()); } algInfoList.removeAll(judgeList); @@ -837,32 +839,32 @@ public class PatrolResultController extends BaseController { }).collect(Collectors.toList()); if (!defectList.isEmpty()) { analyseReqItem.setTypeList(defectList.stream().map(AlgInfo::getAlgSubtypeCode).toArray(String[]::new)); - bigList.add(analyseReqItem.clone()); + bigModelList.add(analyseReqItem.clone()); } algInfoList.removeAll(defectList); if (!algInfoList.isEmpty()) { 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); redisService.setCacheObject(RedisConst.REQUEST_UUID + uuid, patrolResultList.get(0).getTaskPatrolledId(), 1L, TimeUnit.DAYS); AnalyseRequest sendData = new AnalyseRequest(); - sendData.setObjectList(firList); + sendData.setObjectList(infraredList); sendData.setRequestHostIp(MAJOR_URL); sendData.setRequestHostPort(TASK_PORT); sendData.setRequestId(uuid); type = JSONObject.toJSONString(sendData); try { - logger.info("callRemoteAlgorithm infraredRequest: " + type); + logger.info("callRemoteAlgorithm infraredRequest: {}", type); InfraredRequestParam infraredRequestParam = JSONObject.parseObject(type, InfraredRequestParam.class); InfraredResponse infraredResponse = infraredImageParser.parse(infraredRequestParam); - logger.info("callRemoteAlgorithm infraredResponse: " + infraredResponse); + logger.info("callRemoteAlgorithm infraredResponse: {}", infraredResponse); if (infraredResponse != null) { ResultAnalysis resultAnalysis = new ResultAnalysis(); 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; + //qinyl 初筛 if (!filterList.isEmpty()) { analyseReq = new AnalyseRequest(); analyseReq.setTaskPatrolId(patrolResultList.get(0).getTaskPatrolledId()); analyseReq.setObjectList(filterList); analyseReq.setRequestHostIp(MAJOR_URL); analyseReq.setRequestHostPort(TASK_PORT); - //qinyl if (filterList.get(0).getImageUrlList() != null && filterList.get(0).getImageUrlList().length > 0) { String meterFilter = patrolTaskService.selectConfigByKey("ANALYSE_IS_METER_FILTER"); analyseRemoteService.sendRequest(analyseReq, filterList.get(0).getTypeList(), "1".equals(meterFilter)); } } - //qinyl - if (!bigList.isEmpty()) { + //qinyl 大模型 + if (!bigModelList.isEmpty()) { analyseReq = new AnalyseRequest(); analyseReq.setTaskPatrolId(patrolResultList.get(0).getTaskPatrolledId()); - analyseReq.setObjectList(bigList); + analyseReq.setObjectList(bigModelList); analyseReq.setRequestHostIp(MAJOR_URL); 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; - } public void sendWebsocket(PatrolTaskStatus patrolTaskStatus) {