|
|
|
@ -1,134 +0,0 @@ |
|
|
|
package com.inspect.simulator.controller; |
|
|
|
|
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.inspect.simulator.domain.algorithm.in.AnalyseRequest; |
|
|
|
import com.inspect.simulator.domain.algorithm.out.AnalyseResItem; |
|
|
|
import com.inspect.simulator.domain.algorithm.out.AnalyseResPoint; |
|
|
|
import com.inspect.simulator.domain.algorithm.out.AnalyseResult; |
|
|
|
import com.inspect.simulator.service.AlgorithmService; |
|
|
|
import com.inspect.simulator.service.remote.AnalysisRemoteService; |
|
|
|
import com.inspect.simulator.utils.HttpClientUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import retrofit2.Call; |
|
|
|
import retrofit2.Response; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@RestController |
|
|
|
public class AlgorithmController { |
|
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AlgorithmService algorithmService; |
|
|
|
|
|
|
|
@PostMapping("/simu/filter/picAnalyse") |
|
|
|
public ResponseEntity<String> filterPicAnalyse(@RequestBody final String analyseRequestStr) { |
|
|
|
// log.info("[FILTER] filterPicAnalyse: analyseRequestStr={}", analyseRequestStr); |
|
|
|
// AnalyseRequest analyseRequest = new Gson().fromJson(analyseRequestStr, AnalyseRequest.class); |
|
|
|
// log.info("[FILTER] filterPicAnalyse: analyseRequest={}", new Gson().toJson(analyseRequest)); |
|
|
|
// |
|
|
|
// AnalyseResult analyseResult = new AnalyseResult(); |
|
|
|
// analyseResult.setRequestId(analyseRequest.getRequestId()); |
|
|
|
// AnalyseResPoint analyseResPoint = new AnalyseResPoint(); |
|
|
|
// analyseResPoint.setValue("0"); |
|
|
|
// analyseResPoint.setConf("0.85"); |
|
|
|
// analyseResPoint.setCode("2000"); |
|
|
|
// analyseResPoint.setResImageUrl(analyseRequest.getObjectList().get(0).getImageUrlList()[0]); |
|
|
|
// List<AnalyseResPoint> analyseResPoints = new ArrayList<>(); |
|
|
|
// analyseResPoints.add(analyseResPoint); |
|
|
|
// AnalyseResItem analyseResItem = new AnalyseResItem(); |
|
|
|
// analyseResItem.setObjectId(analyseRequest.getObjectList().get(0).getObjectId()); |
|
|
|
// analyseResItem.setAlgFactory("yd"); |
|
|
|
// analyseResItem.setResults(analyseResPoints); |
|
|
|
// List<AnalyseResItem> analyseResItems = new ArrayList<>(); |
|
|
|
// analyseResItems.add(analyseResItem); |
|
|
|
// analyseResult.setResultList(analyseResItems); |
|
|
|
// |
|
|
|
// log.info("[FILTER] filterPicAnalyse: analyseResult={}", 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); |
|
|
|
// } catch (Exception e) { |
|
|
|
// e.printStackTrace(); |
|
|
|
// } |
|
|
|
// |
|
|
|
// return ResponseEntity.ok().body("{\"code\":\"200\"}"); |
|
|
|
return ResponseEntity.ok().body(algorithmService.filterPicAnalyse(analyseRequestStr)); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/simu/bigModel/picAnalyse") |
|
|
|
public ResponseEntity<String> bigModelPicAnalyse(@RequestBody final String analyseRequestStr) { |
|
|
|
// log.info("[FILTER] bigModelPicAnalyse: analyseRequestStr={}", analyseRequestStr); |
|
|
|
// AnalyseRequest analyseRequest = new Gson().fromJson(analyseRequestStr, AnalyseRequest.class); |
|
|
|
// log.info("[FILTER] bigModelPicAnalyse: analyseRequest={}", new Gson().toJson(analyseRequest)); |
|
|
|
// |
|
|
|
// AnalyseResult analyseResult = new AnalyseResult(); |
|
|
|
// analyseResult.setRequestId(analyseRequest.getRequestId()); |
|
|
|
// AnalyseResPoint analyseResPoint = new AnalyseResPoint(); |
|
|
|
// analyseResPoint.setValue("1"); |
|
|
|
// analyseResPoint.setConf("0.95"); |
|
|
|
// analyseResPoint.setCode("2000"); |
|
|
|
// analyseResPoint.setResImageUrl(analyseRequest.getObjectList().get(0).getImageUrlList()[0]); |
|
|
|
// List<AnalyseResPoint> analyseResPoints = new ArrayList<>(); |
|
|
|
// analyseResPoints.add(analyseResPoint); |
|
|
|
// AnalyseResItem analyseResItem = new AnalyseResItem(); |
|
|
|
// analyseResItem.setObjectId(analyseRequest.getObjectList().get(0).getObjectId()); |
|
|
|
// analyseResItem.setAlgFactory("yd"); |
|
|
|
// analyseResItem.setResults(analyseResPoints); |
|
|
|
// List<AnalyseResItem> analyseResItems = new ArrayList<>(); |
|
|
|
// analyseResItems.add(analyseResItem); |
|
|
|
// analyseResult.setResultList(analyseResItems); |
|
|
|
// |
|
|
|
// |
|
|
|
// if(infraredPath.equals("null")) { |
|
|
|
// // 如果nacos中没有配置红外路径,则将结果返回调用方 |
|
|
|
// try { |
|
|
|
// log.info("[BIG MODEL] filterPicAnalyse: nacos file.infraredPath not config, feedback to caller, analyseResult={}", 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) { |
|
|
|
// e.printStackTrace(); |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// // 如果nacos中配置了红外路径,则继续调用红外模块 |
|
|
|
// try { |
|
|
|
// log.info("[BIG MODEL] filterPicAnalyse: continue to call infrared, infraredPath: {}, analyseRequestStr={}", infraredPath, analyseRequestStr); |
|
|
|
// String result = HttpClientUtils.sendPostAgain(infraredPath, analyseRequestStr); |
|
|
|
// log.info("[BIG MODEL] continue to call infrared RESULT: {}", result); |
|
|
|
// } catch (Exception e) { |
|
|
|
// log.info("[BIG MODEL] continue to call infrared EXCEPTION: {}", e.getMessage()); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// return ResponseEntity |
|
|
|
// .ok() |
|
|
|
// .body("{\"code\":\"200\"}"); |
|
|
|
return ResponseEntity.ok().body(algorithmService.bigModelPicAnalyse(analyseRequestStr)); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/simu/infrared/picAnalyse") |
|
|
|
public ResponseEntity<String> infraredPicAnalyse(@RequestBody final String analyseRequestStr) { |
|
|
|
return ResponseEntity |
|
|
|
.ok() |
|
|
|
.body(algorithmService.infraredPicAnalyse(analyseRequestStr)); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/simu/bigModel/picAnalyseRetNotify") |
|
|
|
public ResponseEntity<String> bigModelPicAnalyseRetNotify(@RequestBody String picAnalyseResult) { |
|
|
|
return ResponseEntity |
|
|
|
.ok() |
|
|
|
.body(algorithmService.bigModelPicAnalyseRetNotify(picAnalyseResult)); |
|
|
|
} |
|
|
|
} |