1.技术监督试运行评估-试运行结束后生成试运行报告接线图片调整有则展示,没有则默认

This commit is contained in:
wr
2024-07-02 18:23:20 +08:00
parent 50cd5d3895
commit 8502421b91
3 changed files with 43 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
package com.njcn.supervision.pojo.vo.device;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
@@ -84,7 +85,19 @@ public class SupervisionTempLineRunTestVO extends BaseEntity{
/**
* 试运行成功报告地址
*/
@ApiModelProperty(value = "试运行成功报告地址")
private String testRunReport;
public void setTestRunReport(String testRunReport) {
if (StrUtil.isNotBlank(testRunReport)) {
this.testRunReport = "/" + testRunReport;
} else {
this.testRunReport = testRunReport;
}
}
}

View File

@@ -19,7 +19,8 @@
supervision_temp_line_run_test.test_run_time,
supervision_temp_line_run_test.`online_rate` `onlineRate`,
supervision_temp_line_run_test.`integrity_rate` `integrityRate`,
supervision_temp_line_run_test.`suit_rate` `suitRate`
supervision_temp_line_run_test.`suit_rate` `suitRate`,
supervision_temp_line_run_test.`test_run_report` as testRunReport
FROM
supervision_temp_line_debug
inner JOIN supervision_temp_line_report ON supervision_temp_line_report.id = supervision_temp_line_debug.id

View File

@@ -24,6 +24,7 @@ import com.njcn.device.pq.api.LineIntegrityClient;
import com.njcn.device.pq.pojo.dto.LineDataQualityDTO;
import com.njcn.device.pq.pojo.param.LineDataQualityParam;
import com.njcn.harmonic.api.ReportFeignClient;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.supervision.enums.SupervisionKeyEnum;
import com.njcn.supervision.enums.SupervisionUserStatusEnum;
import com.njcn.supervision.mapper.device.SupervisionTempLineReportMapper;
@@ -42,6 +43,7 @@ import com.njcn.supervision.utils.InstanceUtil;
import com.njcn.web.utils.RequestUtil;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -50,6 +52,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -70,20 +73,16 @@ import javax.servlet.http.HttpServletResponse;
public class SupervisionTempLineRunTestServiceImpl extends ServiceImpl<SupervisionTempLineRunTestMapper, SupervisionTempLineRunTestPO> implements ISupervisionTempLineRunTestService {
private final CommLineClient commLineClient;
private final SupervisionTempLineReportMapper supervisionTempLineReportMapper;
private final LineIntegrityClient lineIntegrityClient;
private final BpmProcessFeignClient bpmProcessFeignClient;
private final UserReportPOService userReportPOService;
private final UserReportProjectPOService userReportProjectPOService;
private final UserReportSubstationPOService userReportSubstationPOService;
private final UserReportSensitivePOService userReportSensitivePOService;
private final IUserReportNormalService iUserReportNormalService;
private final ReportFeignClient reportFeignClient;
private final FileStorageUtil fileStorageUtil;
@Override
@@ -209,6 +208,9 @@ public class SupervisionTempLineRunTestServiceImpl extends ServiceImpl<Supervisi
}
if (CollUtil.isNotEmpty(usePoList)) {
List<String> lineRunTestIds = usePoList.stream().map(SupervisionTempLineRunTestPO::getId).collect(Collectors.toList());
List<SupervisionTempLineReport> supervisionTempLineReports = supervisionTempLineReportMapper.selectBatchIds(lineRunTestIds);
Map<String, String> lineReportMap = supervisionTempLineReports.stream().collect(Collectors.toMap(SupervisionTempLineReport::getId, SupervisionTempLineReport::getMainWiringDiagram));
Map<String, List<SupervisionTempLineRunTestPO>> map = usePoList.stream().collect(Collectors.groupingBy(SupervisionTempLineRunTestPO::getTestRunTime));
map.forEach((key, val) -> {
String startTime = key.split("--")[0];
@@ -237,6 +239,26 @@ public class SupervisionTempLineRunTestServiceImpl extends ServiceImpl<Supervisi
po.setOnlineRate(dto.getOnlineRate());
po.setIntegrityRate(dto.getIntegrityRate());
po.setSuitRate(dto.getSuitRate());
MockMultipartFile file;
if(lineReportMap.containsKey(supervisionTempLineRunTestPO.getId())){
String url = lineReportMap.get(supervisionTempLineRunTestPO.getId());
InputStream fileStream = fileStorageUtil.getFileStream(url.substring(url.indexOf("/")));
try {
file = new MockMultipartFile("file",url.substring(url.lastIndexOf("/")+1), MediaType.IMAGE_PNG_VALUE, fileStream);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (fileStream != null) {
fileStream.close(); // 关闭InputStream
}
} catch (Exception e) {
e.printStackTrace();
}
}
}else{
file= new MockMultipartFile("file", new byte[0]);
}
try {
startTime = DateUtil.beginOfDay(DateUtil.parse(startTime)).toString();
endTime = DateUtil.endOfDay(DateUtil.parse(endTime)).toString();
@@ -248,7 +270,7 @@ public class SupervisionTempLineRunTestServiceImpl extends ServiceImpl<Supervisi
dto.getLineName(),
"",
"",
true, new MockMultipartFile("file", new byte[0])).getData();
true, file).getData();
po.setTestRunReport(fileUrl);
} catch (IOException e) {
throw new RuntimeException(e);