Browse Source

feat: 缺陷记录添加算法筛选,按算法名精确匹配

yanyuan
wangguangyuan 2 days ago
parent
commit
8b7b8c340f
7 changed files with 42 additions and 102 deletions
  1. +32
    -36
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/controller/ResultAnalysisController.java
  2. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/DefectListQuery.java
  3. +0
    -22
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/DefectRecordQuery.java
  4. +1
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/DefectListAggregator.java
  5. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/PatrolData.java
  6. +4
    -43
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml
  7. +1
    -1
      inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/controller/PatrolPresetPosController.java

+ 32
- 36
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/controller/ResultAnalysisController.java View File

@ -647,21 +647,12 @@ public class ResultAnalysisController extends BaseController {
/**
* 缺陷记录将确认缺陷的数据展示在这
* @param query 查询条件点位名称缺陷描述下拉选项见 /defect/descOptions采集时间范围
* @param query 查询条件点位名称算法名称下拉选项见 /defect/algNameOptions采集时间范围
* @return
*/
@GetMapping({"/defect/list"})
public TableDataInfo defectList(DefectRecordQuery query) {
ResultAnalysis resultAnalysis = new ResultAnalysis();
resultAnalysis.setPointStatusList(Arrays.asList(PointStatusEnum.CONFIRMED.getCode(), PointStatusEnum.TRACKING.getCode()));
if (query != null) {
resultAnalysis.setPointName(query.getPointName());
// 采集时间即 patrol_result.create_time返回字段 patrolTime
resultAnalysis.setBeginTime(query.getPatrolTimeBegin());
resultAnalysis.setEndTime(query.getPatrolTimeEnd());
}
// 查出全部数据
List<PatrolData> allList = patrolResultService.selectPatrolDataResultByTaskCodeV2(resultAnalysis);
public TableDataInfo defectList(DefectListQuery query) {
List<PatrolData> allList = patrolResultService.selectDefectList(query);
Map<String, String> imageNormalMap = allList.parallelStream()
.filter(patrolData -> StringUtils.isNotEmpty(patrolData.getImageNormalUrlPath()))
@ -749,17 +740,14 @@ public class ResultAnalysisController extends BaseController {
patrolData.setResStatus(value.stream().map(item -> item.getResStatus() != null ? item.getResStatus() : "").distinct().findFirst().orElse(""));
patrolData.setSuggestion(value.stream().map(item -> item.getSuggestion() != null ? item.getSuggestion() : "").distinct().findFirst().orElse(""));
patrolData.setWarnStatus(value.stream().map(item -> item.getWarnStatus() != null ? item.getWarnStatus() : "").distinct().findFirst().orElse(""));
patrolData.setTaskName(value.stream().map(item -> item.getTaskName() != null ? item.getTaskName() : "").distinct().findFirst().orElse(""));
resultList.add(patrolData);
});
// 缺陷描述筛选按明细行的 desc 精确匹配确定命中的分组命中分组整条保留一条记录聚合的多条缺陷描述不会丢失
if (query != null && StringUtils.isNotEmpty(query.getDesc())) {
String selectedDesc = query.getDesc();
Set<String> matchedKeys = filterList.stream()
.filter(data -> selectedDesc.equals(data.getDesc()))
.map(data -> data.getTaskPatrolId() + "|" + data.getObjectId() + "|" + data.getAlgType())
.collect(Collectors.toSet());
resultList.removeIf(item -> !matchedKeys.contains(item.getTaskPatrolId() + "|" + item.getObjectId() + "|" + item.getAlgType()));
// 算法名称筛选algType 属于聚合分组维度按聚合记录的 algName 精确匹配命中记录整条保留多条缺陷描述不会丢失
if (query != null && StringUtils.isNotEmpty(query.getAlgName())) {
String selectedAlgName = query.getAlgName();
resultList.removeIf(item -> !selectedAlgName.equals(item.getAlgName()));
}
// null 的值按降序排列最新的时间在前,null的在最后面排列
resultList.sort(Comparator.comparing(PatrolData::getPatrolTime,
@ -781,29 +769,37 @@ public class ResultAnalysisController extends BaseController {
}
/**
* 缺陷记录-缺陷描述下拉选项返回去重后的 desc /defect/list 缺陷描述下拉筛选使用
* @param query 查询条件点位名称采集时间范围不含缺陷描述避免选项被自身过滤
* 缺陷记录-算法名称下拉选项返回去重后的 algName /defect/list 算法名称下拉筛选使用
* @param query 查询条件点位名称采集时间范围algName 不参与查询避免选项被自身过滤
* @return
*/
@GetMapping({"/defect/descOptions"})
public AjaxResult defectDescOptions(DefectRecordQuery query) {
ResultAnalysis resultAnalysis = new ResultAnalysis();
resultAnalysis.setPointStatusList(Arrays.asList(PointStatusEnum.CONFIRMED.getCode(), PointStatusEnum.TRACKING.getCode()));
if (query != null) {
resultAnalysis.setPointName(query.getPointName());
resultAnalysis.setBeginTime(query.getPatrolTimeBegin());
resultAnalysis.setEndTime(query.getPatrolTimeEnd());
}
List<PatrolData> allList = patrolResultService.selectPatrolDataResultByTaskCodeV2(resultAnalysis);
// 仅取缺陷数据 /defect/list 口径一致的非空 desc去重后按字典序返回
List<String> descOptions = allList.stream()
@GetMapping({"/defect/algNameOptions"})
public AjaxResult defectAlgNameOptions(DefectListQuery query) {
List<PatrolData> allList = patrolResultService.selectDefectList(query);
List<AlgInfo> algInfos = patrolResultService.selectAlgInfo(new PatrolResult());
// 仅取缺陷数据 /defect/list 口径一致 algType 解析出 algName 后去重按字典序返回
List<String> algNameOptions = allList.stream()
.filter(data -> "0".equals(data.getWarnStatus()))
.map(PatrolData::getDesc)
.map(data -> resolveAlgName(algInfos, data.getAlgType()))
.filter(StringUtils::isNotEmpty)
.distinct()
.sorted()
.collect(Collectors.toList());
return AjaxResult.success(descOptions);
return AjaxResult.success(algNameOptions);
}
/**
* 按算法类型解析算法名称口径与 /defect/list 明细行分配的 algName 一致未匹配到时返回空串
*/
private String resolveAlgName(List<AlgInfo> algInfos, String algType) {
if (algInfos == null) {
return "";
}
return algInfos.stream()
.filter(alg -> alg.getAlgSubtypeCode() != null && alg.getAlgSubtypeCode().equals(algType))
.map(AlgInfo::getAlgSubtypeName)
.findFirst()
.orElse("");
}
/**


+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/DefectListQuery.java View File

@ -21,6 +21,8 @@ public class DefectListQuery {
private String filter;
/** 算法类型。 */
private String algType;
/** 算法名称(前端下拉筛选,精确匹配聚合记录的 algName),选项见 /defect/algNameOptions。 */
private String algName;
/** 区域 ID。 */
private String areaId;
/** 主设备 ID。 */


+ 0
- 22
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/DefectRecordQuery.java View File

@ -1,22 +0,0 @@
package com.inspect.analysis.domain;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* 缺陷记录列表查询条件
*/
@Getter
@Setter
@ToString
public class DefectRecordQuery {
/** 点位名称(模糊匹配)。 */
private String pointName;
/** 采集开始时间(patrol_time 起始日期),格式 yyyy-MM-dd。 */
private String patrolTimeBegin;
/** 采集结束时间(patrol_time 截止日期),格式 yyyy-MM-dd。 */
private String patrolTimeEnd;
/** 缺陷描述(result_analysis.description),下拉筛选按缺陷描述精确匹配(选项见 /defect/descOptions),聚合记录整条保留。 */
private String desc;
}

+ 1
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/DefectListAggregator.java View File

@ -141,6 +141,7 @@ public final class DefectListAggregator {
result.setResStatus(firstNonEmpty(values, PatrolData::getResStatus));
result.setSuggestion(firstNonEmpty(values, PatrolData::getSuggestion));
result.setWarnStatus("0");
result.setTaskName(firstNonEmpty(values,PatrolData::getTaskName));
return result;
}


+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/PatrolData.java View File

@ -91,6 +91,8 @@ public class PatrolData implements Comparable<PatrolData> {
private String originalValue;
private String taskPatrolId;
private String taskName;
// 缺陷等级
private Integer defectLevel = DefectLevel.NONE.getCode();
@JsonInclude(JsonInclude.Include.NON_NULL)


+ 4
- 43
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml View File

@ -187,6 +187,7 @@
<result property="filePath" column="file_path"/>
<result property="originalValue" column="original_value"/>
<result property="taskPatrolId" column="task_patrol_id"/>
<result property="taskName" column="task_name"/>
</resultMap>
<select id="selectPatrolDataResultByTaskCode" parameterType="PatrolResult" resultMap="PatrolDataResult">
@ -375,17 +376,8 @@
b.objectId,
b.suggestion,
b.res_value,
b.task_patrol_id
<choose>
<when test="posType != null and posType != '' and posType == '0'.toString">
,g.channel_name,
g.device_source
</when>
<when test="posType != null and posType != '' and posType != '0'.toString">
,h.patrol_device_name as channel_name,
h.device_source
</when>
</choose>
b.task_patrol_id,
a.task_name
from patrol_result a
inner join result_analysis b
on a.line_id = b.business_id
@ -394,17 +386,7 @@
left join basedata_patrolpoint c on a.device_id = c.patrol_point_id
left join basedata_device d on c.device_id = d.device_id
left join basedata_area e on e.area_id = d.area_id
<choose>
<when test="posType != null and posType != '' and posType != '0'.toString">
left join basedata_patrolpoint_preset f on c.patrol_point_id = f.patrol_point_id
left join basedata_eqpbook h on f.eqp_book_id = h.eqp_book_id
</when>
<otherwise>
left join patrol_preset_pos f on c.patrol_point_id = f.patrol_point_id
left join basedata_eqpbook_channel g on f.channel_id = g.channel_id
left join basedata_eqpbook h on 1 = 0
</otherwise>
</choose>
<where>
<choose>
<when test="taskPatrolIds != null and !taskPatrolIds.isEmpty()">
@ -428,28 +410,7 @@
<if test="pointName != null and pointName != ''">and a.device_name like concat('%', #{pointName}, '%')</if>
<if test="taskName != null and taskName != ''">and a.task_name like concat('%', #{taskName}, '%')</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="channelName != null and channelName != ''">
<choose>
<when test="posType != null and posType != '' and posType == '0'.toString">
and g.channel_name like concat('%', #{channelName}, '%')
</when>
<when test="posType != null and posType != '' and posType != '0'.toString">
and h.patrol_device_name like concat('%', #{channelName}, '%')
</when>
</choose>
</if>
<if test="deviceSource != null and deviceSource != ''">
<choose>
<when test="posType != null and posType != '' and posType == '0'.toString">
and g.device_source like concat('%', #{deviceSource}, '%')
</when>
<when test="posType != null and posType != '' and posType != '0'.toString">
and h.device_source like concat('%', #{deviceSource}, '%')
</when>
</choose>
</if>
<if test="pointStatus != null and pointStatus != ''">and b.point_status = #{pointStatus}</if>
<if test="desc != null and desc != ''">and b.description like concat('%', #{desc}, '%')</if>
<if test="beginTime != null and beginTime != ''">and a.create_time &gt;= concat(#{beginTime}, ' 00:00:00')</if>
<if test="endTime != null and endTime != ''">and a.create_time &lt;= concat(#{endTime}, ' 23:59:59')</if>
</where>


+ 1
- 1
inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/controller/PatrolPresetPosController.java View File

@ -409,7 +409,7 @@ public class PatrolPresetPosController extends BaseController {
String resultCode = ivsPresetInfo.getString("resultCode");
if (null != resultCode && resultCode.equals("0")) {
JSONObject ptzPresetInfoListJson = ivsPresetInfo.getJSONObject("ptzPresetInfoList");
JSONArray ptzPresetInfoArray = ptzPresetInfoListJson.getJSONArray("ptzPresetInfo");
JSONArray ptzPresetInfoArray = ptzPresetInfoListJson != null ? ptzPresetInfoListJson.getJSONArray("ptzPresetInfo") : new JSONArray();
if (!ptzPresetInfoArray.isEmpty()) {
for (Object ivspresetObject : ptzPresetInfoArray) {
JSONObject ivsPresetJson = (JSONObject) JSONObject.toJSON(ivspresetObject);


Loading…
Cancel
Save