Browse Source

/*红外测试环境修改*/

master
htjcAdmin 5 months ago
parent
commit
0edeb3fbb1
1 changed files with 39 additions and 20 deletions
  1. +39
    -20
      src/main/java/com/inspect/simulator/service/impl/AlgorithmServiceImpl.java

+ 39
- 20
src/main/java/com/inspect/simulator/service/impl/AlgorithmServiceImpl.java View File

@ -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<AnalyseResPoint> analyseResPoints = new ArrayList<>();
@ -85,13 +92,11 @@ public class AlgorithmServiceImpl implements AlgorithmService {
List<AnalyseResItem> analyseResItems = new ArrayList<>();
analyseResItems.add(analyseResItem);
analyseResult.setResultList(analyseResItems);
log.info(Color.MAGENTA + "[FILTER] filterPicAnalyse: analyseResult={}" + Color.END, new Gson().toJson(analyseResult));
try {
Call<Object> call = analysisRemoteService.picAnalyseRetNotify(analyseResult);
Response<Object> 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<AnalyseResPoint> 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<Object> call = analysisRemoteService.picAnalyseRetNotify(analyseResultFromInfrared);
Response<Object> 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<Object> call = analysisRemoteService.picAnalyseRetNotify(analyseResult);
Response<Object> 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<Object> call = analysisRemoteService.picAnalyseRetNotify(analyseResultFromInfrared);
Response<Object> 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 {


Loading…
Cancel
Save