diff --git a/src/main/java/com/inspect/simulator/service/impl/AlgorithmServiceImpl.java b/src/main/java/com/inspect/simulator/service/impl/AlgorithmServiceImpl.java index 60adcf5..33be96a 100644 --- a/src/main/java/com/inspect/simulator/service/impl/AlgorithmServiceImpl.java +++ b/src/main/java/com/inspect/simulator/service/impl/AlgorithmServiceImpl.java @@ -44,6 +44,9 @@ public class AlgorithmServiceImpl implements AlgorithmService { @Value("${file.infraredPath:null}") private String infraredPath; + @Value("${test-mode:false}") + private boolean testMode; + @Resource private AnalysisRemoteService analysisRemoteService; @@ -61,8 +64,10 @@ public class AlgorithmServiceImpl implements AlgorithmService { @Override public String filterPicAnalyse(String analyseRequestStr) { - log.info(Color.MAGENTA + "[FILTER] filterPicAnalyse: analyseRequestStr={}" + Color.END, analyseRequestStr); AnalyseRequest analyseRequest = new Gson().fromJson(analyseRequestStr, AnalyseRequest.class); + log.info(Color.MAGENTA + "FILTER_PIC_ANALYZE patrolPointId: {}, PARAMS: {}" + Color.END, + analyseRequest.getTaskPatrolId(), + analyseRequestStr); String[] typeList = analyseRequest.getObjectList().get(0).getTypeList(); String typeListStr = String.join(",", typeList); @@ -73,6 +78,8 @@ public class AlgorithmServiceImpl implements AlgorithmService { analyseResPoint.setValue("0"); analyseResPoint.setConf("0.85"); analyseResPoint.setCode("2000"); + analyseResult.setTaskPatrolId(analyseRequest.getTaskPatrolId()); + analyseResult.setFilter("1"); analyseResPoint.setType(typeListStr); analyseResPoint.setResImageUrl(analyseRequest.getObjectList().get(0).getImageUrlList()[0]); List analyseResPoints = new ArrayList<>(); @@ -85,13 +92,11 @@ public class AlgorithmServiceImpl implements AlgorithmService { List analyseResItems = new ArrayList<>(); analyseResItems.add(analyseResItem); analyseResult.setResultList(analyseResItems); - - log.info(Color.MAGENTA + "[FILTER] filterPicAnalyse: analyseResult={}" + Color.END, new Gson().toJson(analyseResult)); try { Call call = analysisRemoteService.picAnalyseRetNotify(analyseResult); Response response = call.execute(); Object result = response.body(); - System.out.println("result: " + result); + log.info(Color.MAGENTA + "FILTER_PIC_ANALYZE_FEEDBACK patrolPointId: {}, result: {}" + Color.END, analyseRequest.getTaskPatrolId(), result); } catch (Exception e) { e.printStackTrace(); } @@ -115,6 +120,8 @@ public class AlgorithmServiceImpl implements AlgorithmService { analyseResPoint.setValue("1"); analyseResPoint.setConf("0.95"); analyseResPoint.setCode("2000"); + analyseResult.setTaskPatrolId(analyseRequest.getTaskPatrolId()); + analyseResult.setFilter("0"); analyseResPoint.setType(typeListStr); analyseResPoint.setResImageUrl(analyseRequest.getObjectList().get(0).getImageUrlList()[0]); List analyseResPoints = new ArrayList<>(); @@ -127,22 +134,34 @@ public class AlgorithmServiceImpl implements AlgorithmService { analyseResItems.add(analyseResItem); analyseResult.setResultList(analyseResItems); if (MiscUtils.checkInfraredType(typeList) && !"null".equals(infraredPath)) { - try { - log.info(Color.MAGENTA + "BIG_MODEL_INFRARED filterPicAnalyse: continue to call infrared, infraredPath: {}, analyseRequestStr={}" + Color.END, infraredPath, analyseRequestStr); - // 将请求红外的发起方地址改为大模型的地址 - analyseRequest.setRequestHostIp("199.199.199.210"); - analyseRequest.setRequestHostPort("18530"); - final String analyseRequestStrNew = new Gson().toJson(analyseRequest); - String infraredResult = HttpClientUtils.sendPostAgain(infraredPath, analyseRequestStrNew); - log.info(Color.MAGENTA + "BIG_MODEL_INFRARED RESULT: {}" + Color.END, infraredResult); - // 返回给智巡服务器 - AnalyseResult analyseResultFromInfrared = new Gson().fromJson(infraredResult, AnalyseResult.class); - Call call = analysisRemoteService.picAnalyseRetNotify(analyseResultFromInfrared); - Response response = call.execute(); - Object objectFromPatrolMain = response.body(); - log.info(Color.MAGENTA + "[BIG MODEL] FROM PATROL-MAIN: {}", objectFromPatrolMain); - } catch (Exception e) { - log.error("BIG_MODEL_INFRARED continue to call infrared EXCEPTION: {}", e.getMessage()); + if(testMode) { + try { + log.info(Color.MAGENTA + "BIG_MODEL_INFRA_TEST analyseResult={}" + Color.END, new Gson().toJson(analyseResult)); + Call call = analysisRemoteService.picAnalyseRetNotify(analyseResult); + Response response = call.execute(); + Object result = response.body(); + System.out.println("result: " + result); + } catch (Exception e) { + log.error("BIG_MODEL_INFRA_TEST EXCEPTION: {}", e.getMessage()); + } + } else { + try { + log.info(Color.MAGENTA + "BIG_MODEL_INFRARED filterPicAnalyse: continue to call infrared, infraredPath: {}, analyseRequestStr={}" + Color.END, infraredPath, analyseRequestStr); + // 将请求红外的发起方地址改为大模型的地址 + analyseRequest.setRequestHostIp("199.199.199.210"); + analyseRequest.setRequestHostPort("18530"); + final String analyseRequestStrNew = new Gson().toJson(analyseRequest); + String infraredResult = HttpClientUtils.sendPostAgain(infraredPath, analyseRequestStrNew); + log.info(Color.MAGENTA + "BIG_MODEL_INFRARED RESULT: {}" + Color.END, infraredResult); + // 返回给智巡服务器 + AnalyseResult analyseResultFromInfrared = new Gson().fromJson(infraredResult, AnalyseResult.class); + Call call = analysisRemoteService.picAnalyseRetNotify(analyseResultFromInfrared); + Response response = call.execute(); + Object objectFromPatrolMain = response.body(); + log.info(Color.MAGENTA + "[BIG MODEL] FROM PATROL-MAIN: {}", objectFromPatrolMain); + } catch (Exception e) { + log.error("BIG_MODEL_INFRARED continue to call infrared EXCEPTION: {}", e.getMessage()); + } } } else { try {