|
|
|
@ -36,6 +36,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
|
@ -168,12 +169,13 @@ public class AnalysisServiceImpl implements IAnalysisService { |
|
|
|
} |
|
|
|
|
|
|
|
public void handleAlgorithmResult(final String analyseResultJson) { |
|
|
|
String logLabel = UUID.randomUUID().toString().trim().replaceAll(StringUtils.DASH, StringUtils.EMPTY); |
|
|
|
AnalyseResult analyseResult = new Gson().fromJson(analyseResultJson, AnalyseResult.class); |
|
|
|
log.info(Color.CYAN + "###### 分析算法模块返回的表计识别结果 start, analyseResult:{} ######" + Color.END, analyseResult); |
|
|
|
log.info(Color.CYAN + "ALGO_RES_UUID: {}, ###### 分析算法模块返回的表计识别结果 start, analyseResult:{} ######" + Color.END, logLabel, analyseResult); |
|
|
|
String requestId = analyseResult.getRequestId(); |
|
|
|
String keyId = AnalyseConstants.ANALYSE_REQUEST_ID.concat(requestId); |
|
|
|
if (!redisService.hasKey(keyId)) { |
|
|
|
log.error("picAnalyseRetNotify isTest: {}, NO keyId={}, REQUEST_ID={} in REDIS!", analyseResult.isTest(), keyId, requestId); |
|
|
|
log.error("ALGO_RES_UUID: {}, picAnalyseRetNotify isTest: {}, NO keyId={}, REQUEST_ID={} in REDIS!", logLabel, analyseResult.isTest(), keyId, requestId); |
|
|
|
if (!analyseResult.isTest()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -181,25 +183,28 @@ public class AnalysisServiceImpl implements IAnalysisService { |
|
|
|
} |
|
|
|
|
|
|
|
String patrolTaskIdObj = redisService.getCacheObject(keyId); |
|
|
|
log.info("picAnalyseRetNotify keyId={}, requestId={}, patrolTaskIdObj={}", keyId, requestId, patrolTaskIdObj); |
|
|
|
log.info("ALGO_RES_UUID: {}, picAnalyseRetNotify keyId={}, requestId={}, patrolTaskIdObj={}", logLabel, keyId, requestId, patrolTaskIdObj); |
|
|
|
analyseResult.setTaskPatrolId(patrolTaskIdObj); |
|
|
|
String keyFilterRequest = AnalyseConstants.ANALYSE_FILTER_REQUEST + requestId; |
|
|
|
log.info("picAnalyseRetNotify keyFilterRequest={}", keyFilterRequest); |
|
|
|
final String filterRequestRedisKey = AnalyseConstants.ANALYSE_FILTER_REQUEST + requestId; |
|
|
|
final String bigModelRequestRedisKey = AnalyseConstants.ANALYSE_AI_REQUEST + requestId; |
|
|
|
log.info("ALGO_RES_UUID: {}, picAnalyseRetNotify filterRequestRedisKey={}, bigModelRequestRedisKey={}", logLabel, filterRequestRedisKey, bigModelRequestRedisKey); |
|
|
|
boolean bBigModelExecFlag = false; |
|
|
|
String[] algTypeList = {}; |
|
|
|
AnalyseRequest analyseRequest = null; |
|
|
|
if (redisService.hasKey(keyFilterRequest)) { // 初筛结果 |
|
|
|
if (redisService.hasKey(filterRequestRedisKey)) { // 初筛结果 |
|
|
|
analyseResult.setFilter("1"); // 设置初筛标志 |
|
|
|
analyseRequest = (AnalyseRequest) redisService.redisTemplate.opsForValue().getAndDelete(keyFilterRequest); |
|
|
|
log.info("FILTER_RESULT picAnalyseRetNotify analyseRequest IN REDIS: {}", analyseRequest); |
|
|
|
analyseRequest = (AnalyseRequest) redisService.redisTemplate.opsForValue().getAndDelete(filterRequestRedisKey); |
|
|
|
log.info("ALGO_RES_UUID: {}, FILTER_RESULT picAnalyseRetNotify analyseRequest IN REDIS: {}", logLabel, analyseRequest); |
|
|
|
AnalyseResPoint analyseResPoint = analyseResult.getResultList().get(0).getResults().get(0); |
|
|
|
if (analyseRequest != null && analyseRequest.getObjectList() != null && !analyseRequest.getObjectList().isEmpty()) { |
|
|
|
algTypeList = analyseRequest.getObjectList().get(0).getTypeList(); |
|
|
|
analyseResult.reloadReq(analyseRequest);//只有一个,analyseReq.getObjectList().get(0) |
|
|
|
log.info("ALGO_RES_UUID: {}, FILTER_RESULT picAnalyseRetNotify algTypeList: {}, analyseResult reload: {}", logLabel, algTypeList, analyseResult); |
|
|
|
} |
|
|
|
|
|
|
|
boolean bDefect = analyseResPoint.isDefect(); // code=2000代表初筛结果返回正常,value=1代表有缺陷 |
|
|
|
log.info("picAnalyseRetNotify FILTER bDefect={}, algorithmType={}", bDefect, analyseResPoint.getType()); |
|
|
|
analyseResult.reloadReq(analyseRequest);//只有一个,analyseReq.getObjectList().get(0) |
|
|
|
log.info("ALGO_RES_UUID: {}, picAnalyseRetNotify FILTER bDefect={}, algorithmType={}", logLabel, bDefect, analyseResPoint.getType()); |
|
|
|
|
|
|
|
/* |
|
|
|
*大致两种情况:1. 算法是表计(meter); 2. 算法不是表计(meter) |
|
|
|
* 1. 算法不是表计(meter) |
|
|
|
@ -209,7 +214,7 @@ public class AnalysisServiceImpl implements IAnalysisService { |
|
|
|
* 不论初筛结果有没有缺陷,都要继续调用大模型,因为大模型调用了表计(meter)识别算法 |
|
|
|
*/ |
|
|
|
final String algType = analyseRequest.getObjectList().get(0).getTypeList()[0]; |
|
|
|
log.info("picAnalyseRetNotify algType IN REDIS: {}", algType); |
|
|
|
log.info("ALGO_RES_UUID: {}, picAnalyseRetNotify algType IN REDIS: {}", logLabel, algType); |
|
|
|
if (bDefect || (AlgConstants.METER.equals(algType) |
|
|
|
|| AlgConstants.XB.equals(algType) |
|
|
|
|| AlgConstants.INFRA_1800.equals(algType) |
|
|
|
@ -227,12 +232,24 @@ public class AnalysisServiceImpl implements IAnalysisService { |
|
|
|
// ispAlgorithmRequestService.sendRequest(analyseRequest); |
|
|
|
} else { |
|
|
|
//初筛结果无缺陷并且非表计算法,不用调用大模型,流程就此结束 |
|
|
|
log.info("picAnalyseRetNotify NO BIG_MODEL WOULD CALLED REQUEST_ID={}", requestId); |
|
|
|
log.info("ALGO_RES_UUID: {}, picAnalyseRetNotify NO BIG_MODEL WOULD CALLED REQUEST_ID={}", logLabel, requestId); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 大模型结果 |
|
|
|
log.info("BIG_MODEL_RESULT CALLBACK picAnalyseRetNotify REQUEST_ID={}", requestId); |
|
|
|
} else if (redisService.hasKey(bigModelRequestRedisKey)) { // 大模型结果 |
|
|
|
analyseRequest = (AnalyseRequest) redisService.redisTemplate.opsForValue().getAndDelete(bigModelRequestRedisKey); |
|
|
|
log.info("ALGO_RES_UUID: {}, BIG_MODEL_RESULT picAnalyseRetNotify analyseRequest IN REDIS: {}", logLabel, analyseRequest); |
|
|
|
if(analyseRequest != null) { |
|
|
|
analyseResult.reloadReq(analyseRequest); |
|
|
|
log.info("ALGO_RES_UUID: {}, BIG_MODEL_RESULT picAnalyseRetNotify type: {}, analyseResult reload: {}", |
|
|
|
logLabel, |
|
|
|
analyseResult.getResultList().get(0).getResults().get(0).getType(), |
|
|
|
analyseResult |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
analyseResult.setFilter("0"); // 设置大模型标志为0 |
|
|
|
} else { |
|
|
|
log.info("ALGO_RES_UUID: {}, UNKNOWN_RESULT, OR TIMEOUT BEYOND A DAY FROM REMOTE ALGORITHM, requestId: {}, analyseResult: {}", |
|
|
|
logLabel, requestId, analyseResult); |
|
|
|
} |
|
|
|
|
|
|
|
//qinyl |
|
|
|
@ -244,12 +261,15 @@ public class AnalysisServiceImpl implements IAnalysisService { |
|
|
|
} |
|
|
|
//doAlgorithmAnalysis(analyseResult); |
|
|
|
//calculateProcess(analyseResult); |
|
|
|
log.info(Color.CYAN + "###### 分析算法模块返回的表计识别结果 end ######" + Color.END); |
|
|
|
log.info(Color.CYAN + "ALGO_RES_UUID: {}, ###### 分析算法模块返回的表计识别结果 end ######" + Color.END, logLabel); |
|
|
|
|
|
|
|
if (bBigModelExecFlag) { |
|
|
|
log.info("picAnalyseRetNotify CALL BIG_MODEL REQUEST_ID={}", requestId); |
|
|
|
// ispAlgorithmRequestService.sendRequest(analyseRequest); |
|
|
|
analyseRemoteService.sendRequest(analyseRequest, algTypeList, false); |
|
|
|
log.info("ALGO_RES_UUID: {}, picAnalyseRetNotify CALL BIG_MODEL REQUEST_ID={}", logLabel, requestId); |
|
|
|
// final long requestTimeout = 1L; |
|
|
|
// final String analyzeBigModelRequestIdRedisKey = AnalyseConstants.ANALYSE_AI_REQUEST.concat(requestId); |
|
|
|
// redisService.setCacheObject(analyzeBigModelRequestIdRedisKey, analyseRequest.clone(), requestTimeout, TimeUnit.DAYS); |
|
|
|
analyseRemoteService.sendRequest(analyseRequest, algTypeList, Boolean.FALSE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -877,7 +897,7 @@ public class AnalysisServiceImpl implements IAnalysisService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(algValue == null) { |
|
|
|
if (algValue == null) { |
|
|
|
Map<String, String> threshold = patrolResultService.selectPatrolPresetParam(devId); |
|
|
|
if (threshold != null) { |
|
|
|
log.info("selectAlgMap patrolpreset threshold: {}", JSONObject.toJSONString(threshold)); |
|
|
|
@ -885,7 +905,7 @@ public class AnalysisServiceImpl implements IAnalysisService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(algValue == null) { |
|
|
|
if (algValue == null) { |
|
|
|
log.info("selectAlgMap threshold is not set"); |
|
|
|
algValue = new AlgValue(); |
|
|
|
} |
|
|
|
|