|
|
|
@ -5,10 +5,10 @@ import com.github.pagehelper.util.StringUtil; |
|
|
|
import com.inspect.analysis.constant.AnalyseConstants; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
import com.inspect.base.core.constant.AlgConstants; |
|
|
|
import com.inspect.base.core.constant.RedisConst; |
|
|
|
import com.inspect.base.core.utils.HttpClientUtils; |
|
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
|
@ -16,16 +16,15 @@ import com.inspect.base.redis.service.RedisService; |
|
|
|
import com.inspect.partrolresult.domain.AnalyseReqItem; |
|
|
|
import com.inspect.partrolresult.domain.AnalyseRequest; |
|
|
|
import com.inspect.task.service.IPatrolTaskService; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
public class AnalyseRemoteService { |
|
|
|
private static final Logger log = LoggerFactory.getLogger(AnalyseRemoteService.class); |
|
|
|
@Resource |
|
|
|
private RedisService redisService; |
|
|
|
|
|
|
|
@ -83,22 +82,29 @@ public class AnalyseRemoteService { |
|
|
|
redisService.redisTemplate.opsForSet().add(requestSetKey, item.toResultValue(type)); |
|
|
|
} |
|
|
|
}); |
|
|
|
requestUrl = patrolTaskService.selectConfigByKey(AnalyseConstants.ANALYSIS_BIG_URL); |
|
|
|
|
|
|
|
if(checkInfraredType(typeList)) { |
|
|
|
requestUrl = patrolTaskService.selectConfigByKey(AnalyseConstants.ANALYSIS_BIG_URL_INFRARED); |
|
|
|
log.info("BIG_MODEL_INFRARED requestUrl: {}", requestUrl); |
|
|
|
} else { |
|
|
|
requestUrl = patrolTaskService.selectConfigByKey(AnalyseConstants.ANALYSIS_BIG_URL); |
|
|
|
log.info("BIG_MODEL_OTHER requestUrl: {}", requestUrl); |
|
|
|
} |
|
|
|
|
|
|
|
final String analyzeBigModelRequestIdRedisKey = AnalyseConstants.ANALYSE_AI_REQUEST.concat(requestId); |
|
|
|
log.info("[BIG_MODEL] sendRequest analyzeBigModelRequestIdRedisKey: {}, analyseReq: {}", analyzeBigModelRequestIdRedisKey, analyseReq); |
|
|
|
log.info("BIG_MODEL analyzeBigModelRequestIdRedisKey: {}, analyseReq: {}", analyzeBigModelRequestIdRedisKey, analyseReq); |
|
|
|
redisService.setCacheObject(analyzeBigModelRequestIdRedisKey, analyseReq.clone(), requestTimeout, TimeUnit.DAYS); |
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtil.isEmpty(requestUrl)) { |
|
|
|
requestUrl = "http://pleaseSetRemoteUrl:8080"; |
|
|
|
requestUrl = "http://localhost:8080"; |
|
|
|
} |
|
|
|
|
|
|
|
analyseReq.setFilter(isFilter); |
|
|
|
analyseReq.setRequestUrl(requestUrl.concat(AnalyseConstants.ANALYSE_URI)); |
|
|
|
|
|
|
|
try { |
|
|
|
retryDelegate.doCallRemoteAnalyseService(analyseReq); |
|
|
|
retryDelegate.callRemoteAnalyseService(analyseReq); |
|
|
|
} catch (IOException e) { |
|
|
|
log.info("FINALLY FAIL CALL REMOTE ANALYSE SERVICE, requestId: {}, taskPatrolId: {}, error: {}", |
|
|
|
analyseReq.getRequestId(), |
|
|
|
@ -113,6 +119,25 @@ public class AnalyseRemoteService { |
|
|
|
HttpClientUtils.sendPostAgain(defaultUrl, request.toErrorResultStr()); |
|
|
|
} |
|
|
|
|
|
|
|
private static final Set<String> INFRARED_TYPES = new HashSet<>(Arrays.asList( |
|
|
|
AlgConstants.INFRA_1800, |
|
|
|
AlgConstants.INFRA_YU3, |
|
|
|
AlgConstants.INFRA_CAMERA, |
|
|
|
AlgConstants.INFRA_CAMERA_REVERSE |
|
|
|
)); |
|
|
|
|
|
|
|
public static boolean checkInfraredType(String[] typeList) { |
|
|
|
if (typeList == null) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
for (String type : typeList) { |
|
|
|
if (INFRARED_TYPES.contains(type)) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
try { |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|