|
|
|
@ -12,10 +12,12 @@ import com.inspect.analysis.service.IAnalyseLogService; |
|
|
|
import com.inspect.analysis.service.IAnalyseResponseService; |
|
|
|
import com.inspect.analysis.service.IResultAnalysisService; |
|
|
|
import com.inspect.analysis.utils.ResultAnalysisUtils; |
|
|
|
import com.inspect.api.service.AlarmPublisher; |
|
|
|
import com.inspect.base.core.constant.AlgConstants; |
|
|
|
import com.inspect.base.core.constant.Color; |
|
|
|
import com.inspect.base.core.constant.RedisConst; |
|
|
|
import com.inspect.base.core.constant.Tags; |
|
|
|
import com.inspect.base.core.enums.AnalysisType; |
|
|
|
import com.inspect.base.core.enums.TaskStatus; |
|
|
|
import com.inspect.base.core.utils.BigDecimalUtil; |
|
|
|
import com.inspect.base.core.utils.DateUtils; |
|
|
|
@ -31,6 +33,7 @@ import com.inspect.partrolresult.service.IPatrolResultService; |
|
|
|
import com.inspect.resultmain.domain.PatrolTaskResultMain; |
|
|
|
import com.inspect.resultmain.service.IPatrolTaskResultMainService; |
|
|
|
import com.inspect.system.base.domain.SysDictData; |
|
|
|
import com.inspect.task.domain.PatrolData; |
|
|
|
import com.inspect.taskinfo.domain.PatrolTaskInfo; |
|
|
|
import com.inspect.taskinfo.service.IPatrolTaskInfoService; |
|
|
|
import com.inspect.taskstatus.domain.PatrolTaskStatus; |
|
|
|
@ -41,6 +44,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -81,6 +85,28 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private DelayQueueService<String> delayQueueService; |
|
|
|
@Resource |
|
|
|
private AlarmPublisher alarmPublisher; |
|
|
|
|
|
|
|
public static List<AnalyseResPoint> mergeAnalyseResItem(List<AnalyseResPoint> analyseResPointList) { |
|
|
|
String mergedValue = analyseResPointList.stream() |
|
|
|
.map(AnalyseResPoint::getValue) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.joining(StringUtils.COMMA)); |
|
|
|
AnalyseResPoint first = analyseResPointList.get(0); |
|
|
|
|
|
|
|
AnalyseResPoint mergedPoint = new AnalyseResPoint(); |
|
|
|
mergedPoint.setType(first.getType()); |
|
|
|
mergedPoint.setCode(first.getCode()); |
|
|
|
mergedPoint.setResImageUrl(first.getResImageUrl()); |
|
|
|
mergedPoint.setImageNormalUrlPath(first.getImageNormalUrlPath()); |
|
|
|
mergedPoint.setConf(first.getConf()); |
|
|
|
mergedPoint.setDesc(first.getDesc()); |
|
|
|
mergedPoint.setPos(first.getPos()); |
|
|
|
mergedPoint.setValue(mergedValue); |
|
|
|
|
|
|
|
return Collections.singletonList(mergedPoint); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void picAnalyseRetNotify(AnalyseResult analyseResult) { |
|
|
|
@ -258,7 +284,6 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService { |
|
|
|
requestId); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized void doAlgorithmAnalysis(AnalyseResult analyseResult) { |
|
|
|
log.info("doAlgorithmAnalysis analyseResult: {}", analyseResult); |
|
|
|
int size = 0; |
|
|
|
@ -829,6 +854,9 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("error", e); |
|
|
|
} |
|
|
|
|
|
|
|
// ws |
|
|
|
uploadResultWS(resultAnalysis); |
|
|
|
} |
|
|
|
|
|
|
|
patrolResult.setValue(valueJoiner.toString()); |
|
|
|
@ -871,6 +899,41 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService { |
|
|
|
//this.senWebsocket(websocketDataList); |
|
|
|
} |
|
|
|
|
|
|
|
private void uploadResultWS(ResultAnalysis resultAnalysis) { |
|
|
|
String requestId = resultAnalysis.getRequestId(); |
|
|
|
String redisKey = AnalyseConstants.ANALYSE_AI_REQUEST.concat(requestId); |
|
|
|
boolean hasKey = redisService.hasKey(redisKey); |
|
|
|
log.info("uploadResultWS requestId:{}, hasKey:{}", redisKey, hasKey); |
|
|
|
if (AnalysisType.LargeModel.getCode().equals(resultAnalysis.getFilter())) { |
|
|
|
PatrolData patrolData = patrolResultService.selectPatrolData(resultAnalysis); |
|
|
|
if (patrolData != null) { |
|
|
|
if (AlgConstants.ALG_INFRARED_LIST.contains(resultAnalysis.getAlgType())) { |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(resultAnalysis.getResultContent()); |
|
|
|
JSONObject extraObject = jsonObject == null ? null : jsonObject.getJSONObject("extra"); |
|
|
|
if (extraObject != null) { |
|
|
|
BigDecimal maxValue = extraObject.getBigDecimal("maxValue"); |
|
|
|
if (maxValue != null) { |
|
|
|
patrolData.setMaxValue(maxValue.setScale(1, RoundingMode.HALF_UP).toPlainString()); |
|
|
|
} |
|
|
|
|
|
|
|
BigDecimal minValue = extraObject.getBigDecimal("minValue"); |
|
|
|
if (minValue != null) { |
|
|
|
patrolData.setMinValue(minValue.setScale(1, RoundingMode.HALF_UP).toPlainString()); |
|
|
|
} |
|
|
|
|
|
|
|
BigDecimal avgValue = extraObject.getBigDecimal("avgValue"); |
|
|
|
if (avgValue != null) { |
|
|
|
String formattedAvgValue = avgValue.setScale(1, RoundingMode.HALF_UP).toPlainString(); |
|
|
|
patrolData.setAvgValue(formattedAvgValue); |
|
|
|
patrolData.setResValue(formattedAvgValue); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
alarmPublisher.publish(patrolData); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private ResultAnalysis combineAnalyse( |
|
|
|
AnalyseResult analyseResult, |
|
|
|
String patrolResultId, |
|
|
|
@ -905,7 +968,7 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService { |
|
|
|
// 处理正常结果、以及兼容处理无机人表计gis_meter2、纠偏correction的异常结果 |
|
|
|
if (resultAnalysisUtils.checkCode(analyseResPoint.getCode(), analyseResPoint.getDesc(), resultAnalysis) |
|
|
|
|| (AlgConstants.GIS_METER_2.equals(analyseResPoint.getType())) |
|
|
|
|| (AlgConstants.CORRECTION.equals(analyseResPoint.getType()) && Arrays.asList("2001", "2002", "2003").contains(analyseResPoint.getCode()) )) { |
|
|
|
|| (AlgConstants.CORRECTION.equals(analyseResPoint.getType()) && Arrays.asList("2001", "2002", "2003").contains(analyseResPoint.getCode()))) { |
|
|
|
AlgValue algValue = selectAlgMap(objectId, analyseResPoint.getType()); |
|
|
|
resultAnalysisUtils.parseAlg(analyseResPoint.getType(), algValue, value, analyseResPoint.getDesc(), resultAnalysis); |
|
|
|
// 合并辅助值字段 |
|
|
|
@ -1019,100 +1082,4 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService { |
|
|
|
return algValue; |
|
|
|
} |
|
|
|
|
|
|
|
public static final String mergeString = "{\n" + |
|
|
|
"\t\"requestId\": \"b00f2fbd1fcc49c6a47ed2b3a77e5028\",\n" + |
|
|
|
"\t\"resultsList\": [{\n" + |
|
|
|
"\t\t\"objectId\": \"2079991\",\n" + |
|
|
|
"\t\t\"results\": [{\n" + |
|
|
|
"\t\t\t\"type\": \"switch\",\n" + |
|
|
|
"\t\t\t\"value\": \"和\",\n" + |
|
|
|
"\t\t\t\"code\": \"2000\",\n" + |
|
|
|
"\t\t\t\"resImageUrl\": \"2/2025/12/12/1531/CCD/3038_R100-001_20251212140756.jpg\",\n" + |
|
|
|
"\t\t\t\"pos\": [],\n" + |
|
|
|
"\t\t\t\"conf\": 0.99,\n" + |
|
|
|
"\t\t\t\"desc\": \"\",\n" + |
|
|
|
"\t\t\t\"imageNormalUrlPath\": \"1/2025/08/29/1584/CCD/3038_R100-001_20250829123953.jpg\"\n" + |
|
|
|
"\t\t}, {\n" + |
|
|
|
"\t\t\t\"type\": \"switch\",\n" + |
|
|
|
"\t\t\t\"value\": \"和\",\n" + |
|
|
|
"\t\t\t\"code\": \"2000\",\n" + |
|
|
|
"\t\t\t\"resImageUrl\": \"2/2025/12/12/1531/CCD/3038_R100-001_20251212140756.jpg\",\n" + |
|
|
|
"\t\t\t\"pos\": [],\n" + |
|
|
|
"\t\t\t\"conf\": 0.99,\n" + |
|
|
|
"\t\t\t\"desc\": \"\",\n" + |
|
|
|
"\t\t\t\"imageNormalUrlPath\": \"1/2025/08/29/1584/CCD/3038_R100-001_20250829123953.jpg\"\n" + |
|
|
|
"\t\t}, {\n" + |
|
|
|
"\t\t\t\"type\": \"switch\",\n" + |
|
|
|
"\t\t\t\"value\": \"分\",\n" + |
|
|
|
"\t\t\t\"code\": \"2000\",\n" + |
|
|
|
"\t\t\t\"resImageUrl\": \"2/2025/12/12/1531/CCD/3038_R100-001_20251212140756.jpg\",\n" + |
|
|
|
"\t\t\t\"pos\": [],\n" + |
|
|
|
"\t\t\t\"conf\": 0.99,\n" + |
|
|
|
"\t\t\t\"desc\": \"\",\n" + |
|
|
|
"\t\t\t\"imageNormalUrlPath\": \"1/2025/08/29/1584/CCD/3038_R100-001_20250829123953.jpg\"\n" + |
|
|
|
"\t\t}, {\n" + |
|
|
|
"\t\t\t\"type\": \"switch\",\n" + |
|
|
|
"\t\t\t\"value\": \"和\",\n" + |
|
|
|
"\t\t\t\"code\": \"2000\",\n" + |
|
|
|
"\t\t\t\"resImageUrl\": \"2/2025/12/12/1531/CCD/3038_R100-001_20251212140756.jpg\",\n" + |
|
|
|
"\t\t\t\"pos\": [],\n" + |
|
|
|
"\t\t\t\"conf\": 0.99,\n" + |
|
|
|
"\t\t\t\"desc\": \"\",\n" + |
|
|
|
"\t\t\t\"imageNormalUrlPath\": \"1/2025/08/29/1584/CCD/3038_R100-001_20250829123953.jpg\"\n" + |
|
|
|
"\t\t}, {\n" + |
|
|
|
"\t\t\t\"type\": \"switch\",\n" + |
|
|
|
"\t\t\t\"value\": \"分\",\n" + |
|
|
|
"\t\t\t\"code\": \"2000\",\n" + |
|
|
|
"\t\t\t\"resImageUrl\": \"2/2025/12/12/1531/CCD/3038_R100-001_20251212140756.jpg\",\n" + |
|
|
|
"\t\t\t\"pos\": [],\n" + |
|
|
|
"\t\t\t\"conf\": 0.99,\n" + |
|
|
|
"\t\t\t\"desc\": \"\",\n" + |
|
|
|
"\t\t\t\"imageNormalUrlPath\": \"1/2025/08/29/1584/CCD/3038_R100-001_20250829123953.jpg\"\n" + |
|
|
|
"\t\t}, {\n" + |
|
|
|
"\t\t\t\"type\": \"switch\",\n" + |
|
|
|
"\t\t\t\"value\": \"分\",\n" + |
|
|
|
"\t\t\t\"code\": \"2000\",\n" + |
|
|
|
"\t\t\t\"resImageUrl\": \"2/2025/12/12/1531/CCD/3038_R100-001_20251212140756.jpg\",\n" + |
|
|
|
"\t\t\t\"pos\": [],\n" + |
|
|
|
"\t\t\t\"conf\": 0.99,\n" + |
|
|
|
"\t\t\t\"desc\": \"\",\n" + |
|
|
|
"\t\t\t\"imageNormalUrlPath\": \"1/2025/08/29/1584/CCD/3038_R100-001_20250829123953.jpg\"\n" + |
|
|
|
"\t\t}],\n" + |
|
|
|
"\t\t\"algFactory\": \"yd\"\n" + |
|
|
|
"\t}]\n" + |
|
|
|
"}"; |
|
|
|
|
|
|
|
public static List<AnalyseResPoint> mergeAnalyseResItem(List<AnalyseResPoint> analyseResPointList) { |
|
|
|
String mergedValue = analyseResPointList.stream() |
|
|
|
.map(AnalyseResPoint::getValue) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.joining(StringUtils.COMMA)); |
|
|
|
AnalyseResPoint first = analyseResPointList.get(0); |
|
|
|
|
|
|
|
AnalyseResPoint mergedPoint = new AnalyseResPoint(); |
|
|
|
mergedPoint.setType(first.getType()); |
|
|
|
mergedPoint.setCode(first.getCode()); |
|
|
|
mergedPoint.setResImageUrl(first.getResImageUrl()); |
|
|
|
mergedPoint.setImageNormalUrlPath(first.getImageNormalUrlPath()); |
|
|
|
mergedPoint.setConf(first.getConf()); |
|
|
|
mergedPoint.setDesc(first.getDesc()); |
|
|
|
mergedPoint.setPos(first.getPos()); |
|
|
|
mergedPoint.setValue(mergedValue); |
|
|
|
|
|
|
|
return Collections.singletonList(mergedPoint); |
|
|
|
} |
|
|
|
public static void main(String[] args) { |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
AnalyseResult analyseResult; |
|
|
|
try { |
|
|
|
analyseResult = mapper.readValue(mergeString, new TypeReference<AnalyseResult>() { |
|
|
|
}); |
|
|
|
log.info("mergeAnalyseResItem analyseResult: {}", analyseResult); |
|
|
|
List<AnalyseResPoint> result = mergeAnalyseResItem(analyseResult.getResultsList().get(0).getResults()); |
|
|
|
log.info("mergeAnalyseResItem result: {}", result); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("mergeAnalyseResItem exception", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |