Browse Source

perf:优化报告详情列表展示和缺陷汇总备注字段不展示问题

master
wangguangyuan 2 months ago
parent
commit
7ea58af7d4
7 changed files with 55 additions and 33 deletions
  1. +3
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/img/mapper/InspectionReportImgMapper.java
  2. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/img/service/IInspectionReportImgService.java
  3. +5
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/img/service/impl/InspectionReportImgServiceImpl.java
  4. +36
    -13
      inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/controller/InspectionReportController.java
  5. +0
    -20
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java
  6. +8
    -0
      inspect-main/inspect-main-task/src/main/resources/mapper/task/InspectionReportImgMapper.xml
  7. +1
    -0
      inspect-main/inspect-main-task/src/main/resources/mapper/task/ResultAnalysisMapper.xml

+ 3
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/img/mapper/InspectionReportImgMapper.java View File

@ -2,6 +2,7 @@ package com.inspect.img.mapper;
import com.inspect.img.domain.InspectionReportImg;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -20,4 +21,6 @@ public interface InspectionReportImgMapper {
int deleteInspectionReportImgByLineIds(Long[] lineIds);
int batchInsertInspectionReportImg(List<InspectionReportImg> reportImgList);
List<InspectionReportImg> selectByReportInfoIds(@Param("lineIds") List<String> lineIds);
}

+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/img/service/IInspectionReportImgService.java View File

@ -18,4 +18,6 @@ public interface IInspectionReportImgService {
int deleteInspectionReportImgByLineId(Long lineId);
int batchInsertInspectionReportImg(List<InspectionReportImg> reportImgList);
List<InspectionReportImg> selectByReportInfoIds(List<String> lineIds);
}

+ 5
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/img/service/impl/InspectionReportImgServiceImpl.java View File

@ -46,4 +46,9 @@ public class InspectionReportImgServiceImpl implements IInspectionReportImgServi
public int batchInsertInspectionReportImg(List<InspectionReportImg> list) {
return this.inspectionReportImgMapper.batchInsertInspectionReportImg(list);
}
@Override
public List<InspectionReportImg> selectByReportInfoIds(List<String> lineIds) {
return this.inspectionReportImgMapper.selectByReportInfoIds(lineIds);
}
}

+ 36
- 13
inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/controller/InspectionReportController.java View File

@ -33,12 +33,7 @@ import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.Adler32;
import java.util.zip.CheckedOutputStream;
@ -127,7 +122,6 @@ public class InspectionReportController extends BaseController {
@GetMapping({"/{lineId}/{filter}"})
public AjaxResult getInfo(@PathVariable("lineId") Long lineId, @PathVariable(value = "filter",required = false) String filter) {
Map<String, String> map = getImgMap();
InspectionReport inspectionReport = inspectionReportService.selectInspectionReportByLineId(lineId);
if(inspectionReport == null) {
// 暂时这么处理进度条报告入口lineId传的是patrolTaskStatus的lineId
@ -149,16 +143,45 @@ public class InspectionReportController extends BaseController {
inspectionReportData.setReportId(String.valueOf(lineId));
List<InspectionReportData> inspectionReportDataList =
inspectionReportDataService.selectInspectionReportDataList(inspectionReportData);
// 收集所有需要查询的lineId
List<String> lineIds = inspectionReportDataList.stream()
.map(InspectionReportData::getLineId)
.filter(StringUtils::isNotBlank)
.distinct()
.collect(Collectors.toList());
// 批量查询图片数据
Map<String, String> imageMap = Collections.emptyMap();
if (!lineIds.isEmpty()) {
// 批量查询
List<InspectionReportImg> allImages = inspectionReportImgService.selectByReportInfoIds(lineIds);
// 按reportInfoId分组拼接图片URL
imageMap = allImages.stream()
.filter(img -> StringUtils.isNotBlank(img.getReportInfoId()))
.filter(img -> StringUtils.isNotBlank(img.getImg()))
.collect(Collectors.groupingBy(
InspectionReportImg::getReportInfoId,
Collectors.mapping(
InspectionReportImg::getImg,
Collectors.joining(StringUtils.COMMA)
)
));
}
// 设置图片数据
for (InspectionReportData reportData : inspectionReportDataList) {
logger.info("reportData: {}", reportData);
if(reportData == null || StringUtils.isEmpty(reportData.getReportId())) {
return AjaxResult.error("报告已损坏: " + lineId);
}
if (map != null && map.get((reportData.getLineId()).trim()) != null) {
reportData.setInspectionImg(map.get((reportData.getLineId()).trim()));
// 记录日志根据实际情况调整日志级别避免生产环境过多日志
logger.debug("reportData: {}", reportData);
// 从缓存中获取图片URL
String imgUrls = imageMap.get(reportData.getLineId());
if (StringUtils.isNotBlank(imgUrls)) {
reportData.setInspectionImg(imgUrls);
}
}
inspectionReport.setInfo(inspectionReportDataList);
return AjaxResult.success(inspectionReport);
}


+ 0
- 20
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java View File

@ -364,27 +364,7 @@ public class PatrolTaskResultMainController extends BaseController {
logger.error("[归档]失败, 数据采集中...");
return AjaxResult.error("数据采集中请稍后....");
}
// startTime = System.currentTimeMillis();
// ResultAnalysis resultAnalysis = new ResultAnalysis();
// int csQxNum = 0, aiQxNum = 0;
// List<String> taskPatrolledIds = resultList.stream().map(PatrolResult::getTaskPatrolledId).distinct().collect(Collectors.toList());
// for (String taskPatrolledId : taskPatrolledIds) {
// resultAnalysis.setTaskPatrolledId(taskPatrolledId);
// ResultAnalysis ras = patrolResultService.selectTaskAbnormalData(resultAnalysis);
// csQxNum += ras.getCsQxNum();
// aiQxNum += ras.getAiQxNum();
// }
// if ("0".equals(exportReportFlag) && 0 == aiQxNum && 0 == csQxNum) {
// logger.error("[归档]没有缺陷数据, 无需归档!");
// return AjaxResult.error("没有缺陷数据, 无需归档!");
// }
// PrintUtil.useTime("查询统计缺陷数据", startTime);
startTime = System.currentTimeMillis();
// 使用CompletableFuture异步执行saveReport
// int finalAiQxNum = aiQxNum;
// int finalCsQxNum = csQxNum;
List<Long> finalLineIds = lineIds;
CompletableFuture<List<Long>> saveReportFuture = CompletableFuture.supplyAsync(() -> {
logger.info("[ARCHIVE] Start saving reports");


+ 8
- 0
inspect-main/inspect-main-task/src/main/resources/mapper/task/InspectionReportImgMapper.xml View File

@ -35,6 +35,14 @@
where line_id = #{lineId}
</select>
<select id="selectByReportInfoIds" resultMap="InspectionReportImgResult">
<include refid="selectInspectionReportImgVo"/>
where report_info_id in
<foreach collection="lineIds" item="lineId" open="(" separator="," close=")">
#{lineId}
</foreach>
</select>
<insert id="insertInspectionReportImg" parameterType="InspectionReportImg" useGeneratedKeys="true"
keyProperty="lineId">
insert into inspection_report_img


+ 1
- 0
inspect-main/inspect-main-task/src/main/resources/mapper/task/ResultAnalysisMapper.xml View File

@ -664,6 +664,7 @@
<result property="requestId" column="request_id"/>
<result property="resStatus" column="res_status"/>
<result property="imageNormalUrlPath" column="image_normal_url_path"/>
<result property="suggestion" column="suggestion"/>
</resultMap>
<select id="selectResultAnalysisListForAlarm" parameterType="com.inspect.analysis.domain.AnalyseSummaryAlarmModel"


Loading…
Cancel
Save