wangguangyuan 1 month ago
parent
commit
abfe553b68
3 changed files with 124 additions and 6 deletions
  1. +113
    -2
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/impl/AnalyseResponseServiceImpl.java
  2. +4
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java
  3. +7
    -4
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java

+ 113
- 2
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/impl/AnalyseResponseServiceImpl.java View File

@ -188,6 +188,7 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
|| "isolator".equals(algType) || "isolator".equals(algType)
|| "gis_meter".equals(algType) || "gis_meter".equals(algType)
|| "correction".equals(algType) || "correction".equals(algType)
|| "switch".equals(algType)
) )
) { ) {
/* /*
@ -789,7 +790,19 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
List<ResultAnalysis> resultAnalysisList = new ArrayList<>(); List<ResultAnalysis> resultAnalysisList = new ArrayList<>();
StringJoiner valueJoiner = new StringJoiner(StringUtils.COMMA); StringJoiner valueJoiner = new StringJoiner(StringUtils.COMMA);
StringJoiner validJoiner = new StringJoiner(StringUtils.COMMA); StringJoiner validJoiner = new StringJoiner(StringUtils.COMMA);
for (AnalyseResPoint analyseResPoint : resItem.getResults()) {
List<AnalyseResPoint> analyseResPointList = resItem.getResults();
if(!resItem.getResults().isEmpty()) {
AnalyseResPoint analyseResPoint = resItem.getResults().get(0);
String algType = analyseResPoint.getType();
log.info("RESULT_MERGE algType: {}, analyseResPoint: {}", algType, analyseResPoint);
if("switch".equals(algType)) {
analyseResPointList = mergeAnalyseResItem(analyseResPointList);
log.info("RESULT_MERGE algType: {}, analyseResPointList: {}", algType, analyseResPointList);
}
}
for (AnalyseResPoint analyseResPoint : analyseResPointList) {
ResultAnalysis resultAnalysis = combineAnalyse(analyseResult, ResultAnalysis resultAnalysis = combineAnalyse(analyseResult,
String.valueOf(patrolResult.getLineId()), String.valueOf(patrolResult.getLineId()),
resItem.getObjectId(), resItem.getObjectId(),
@ -898,7 +911,8 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
// AlgValue algValue = selectAlgMap(objectId, analyseResPoint.getType()); // AlgValue algValue = selectAlgMap(objectId, analyseResPoint.getType());
// resultAnalysis.parseAlg(analyseResPoint.getType(), algValue, value, analyseResPoint.getDesc()); // resultAnalysis.parseAlg(analyseResPoint.getType(), algValue, value, analyseResPoint.getDesc());
// } // }
if (resultAnalysisUtils.checkCode(analyseResPoint.getCode(), analyseResPoint.getDesc(), resultAnalysis)) {
if (resultAnalysisUtils.checkCode(analyseResPoint.getCode(), analyseResPoint.getDesc(), resultAnalysis)
|| "2001".equals(analyseResPoint.getCode()) && "correction".equals(analyseResPoint.getType())) {
AlgValue algValue = selectAlgMap(objectId, analyseResPoint.getType()); AlgValue algValue = selectAlgMap(objectId, analyseResPoint.getType());
resultAnalysisUtils.parseAlg(analyseResPoint.getType(), algValue, value, analyseResPoint.getDesc(), resultAnalysis); resultAnalysisUtils.parseAlg(analyseResPoint.getType(), algValue, value, analyseResPoint.getDesc(), resultAnalysis);
} }
@ -1007,4 +1021,101 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
return algValue; 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);
}
}
} }

+ 4
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java View File

@ -2226,13 +2226,17 @@ public class PatrolResultController extends BaseController {
PatrolResult patrolResult = new PatrolResult(); PatrolResult patrolResult = new PatrolResult();
patrolResult.setCreateTime(newTime); patrolResult.setCreateTime(newTime);
List<ResultValue> list = new ArrayList<>(); List<ResultValue> list = new ArrayList<>();
long start = System.currentTimeMillis();
if ("1".equals(type)) { if ("1".equals(type)) {
list = patrolResultService.selectOilResultValue(patrolResult); list = patrolResultService.selectOilResultValue(patrolResult);
} }
logger.info("openApi selectOilResultValue cost: {}ms", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
if ("2".equals(type)) { if ("2".equals(type)) {
list = patrolResultService.select6FsResultValue(patrolResult); list = patrolResultService.select6FsResultValue(patrolResult);
} }
logger.info("openApi select6FsResultValue cost: {}ms", System.currentTimeMillis() - start);
for (ResultValue object : list) { for (ResultValue object : list) {
object.setValue(object.formatValue(object.getValue())); object.setValue(object.formatValue(object.getValue()));


+ 7
- 4
inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java View File

@ -54,6 +54,8 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -2684,6 +2686,9 @@ public class PatrolTaskController extends BaseController {
private void exportExcelV2(HttpServletResponse response, List<PatrolData> dataList) throws Exception { private void exportExcelV2(HttpServletResponse response, List<PatrolData> dataList) throws Exception {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=\"task_export_" + System.currentTimeMillis() + ".xlsx\""); response.setHeader("Content-Disposition", "attachment; filename=\"task_export_" + System.currentTimeMillis() + ".xlsx\"");
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "0");
logger.info("[EXCEL]开始导出"); logger.info("[EXCEL]开始导出");
printMemoryInfo("开始导出"); printMemoryInfo("开始导出");
@ -2733,17 +2738,15 @@ public class PatrolTaskController extends BaseController {
pathMap = null; pathMap = null;
} }
response.setHeader("Transfer-Encoding", "chunked");
workbook.write(out); workbook.write(out);
// 清理临时文件
workbook.dispose();
printMemoryInfo("结束导出");
} catch (IOException e) { } catch (IOException e) {
logger.error("导出异常:{}", e); logger.error("导出异常:{}", e);
printMemoryInfo("导出异常"); printMemoryInfo("导出异常");
} finally { } finally {
Path start = Paths.get(TEMP_DIR); Path start = Paths.get(TEMP_DIR);
Files.walk(start) Files.walk(start)
.filter(Files::isRegularFile)
.sorted(Comparator.reverseOrder())
.forEach(path -> { .forEach(path -> {
try { try {
Files.deleteIfExists(path); Files.deleteIfExists(path);


Loading…
Cancel
Save