diff --git a/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordBusbarAlarmController.java b/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordBusbarAlarmController.java index 3525718..7330332 100644 --- a/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordBusbarAlarmController.java +++ b/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordBusbarAlarmController.java @@ -23,7 +23,7 @@ import com.ruoyi.common.core.page.TableDataInfo; /** * 巡检报警记录Controller - * + * * @author zangch * @date 2024-12-03 */ @@ -101,4 +101,18 @@ public class RecordBusbarAlarmController extends BaseController { return toAjax(recordBusbarAlarmService.deleteRecordBusbarAlarmByObjIds(objIds)); } + + + /** + * 获取巡检报警记录列表。 + * @param recordBusbarAlarm 需要查询的配电网故障报警记录信息。 + * @return 返回包含所有符合条件的配电网故障报警记录的列表,如果没有找到任何记录,则返回空列表。 + */ + @PreAuthorize("@ss.hasPermi('record:recordBusbarAlarm:list')") + @PostMapping("/recordBusbarAlarmList") + public AjaxResult recordBusbarAlarmList(RecordBusbarAlarm recordBusbarAlarm) + { + List list = recordBusbarAlarmService.selectRecordBusbarAlarmList(recordBusbarAlarm); + return success(list); + } } diff --git a/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordBusbarTempController.java b/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordBusbarTempController.java index b6eb212..62689bc 100644 --- a/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordBusbarTempController.java +++ b/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordBusbarTempController.java @@ -119,43 +119,7 @@ public class RecordBusbarTempController extends BaseController */ @GetMapping("/getVisiblePhoto/{filePath}") public ResponseEntity getVisiblePhoto(@PathVariable String filePath) { - // 获取配置文件中的路径application.yml的profile - String myPath = RuoYiConfig.getMyPath(); - // 构建文件的完整路径 - String fileUrl = myPath + "/日志信息/可见光图像/" + filePath; - // 创建文件对象 - File file = new File(fileUrl); - // 检查文件是否存在 - if (file.exists()) { - // 创建文件系统资源对象,包装文件,http头不能使用file,所以使用FileSystemResource - FileSystemResource resource = new FileSystemResource(file); - // 创建HttpHeaders对象,用于设置响应头 - HttpHeaders headers = new HttpHeaders(); - // 设置文件长度 - headers.setContentLength(file.length()); - // 动态检测文件的MIME类型 - try { - // 尝试获取文件的内容类型 - String contentType = Files.probeContentType(file.toPath()); - if (contentType != null) { - // 如果内容类型不为空,则设置到HTTP响应头中 - headers.setContentType(MediaType.parseMediaType(contentType)); - } else { - // 如果内容类型为空,则默认设置为图像类型 - headers.setContentType(MediaType.parseMediaType("image/*")); - } - } catch (IOException e) { - // 如果发生IO异常,则默认设置内容类型为图像类型 - headers.setContentType(MediaType.parseMediaType("image/*")); - } - // 返回包含文件资源的响应实体 - return ResponseEntity.ok() - .headers(headers) - .body(resource); - } else { - // 如果文件不存在,返回404状态 - return ResponseEntity.notFound().build(); - } + return recordBusbarTempService.getVisiblePhoto(filePath); } /** @@ -165,45 +129,14 @@ public class RecordBusbarTempController extends BaseController */ @GetMapping("/getThermalPhoto/{filePath}") public ResponseEntity getThermalPhoto (@PathVariable String filePath) { - // 获取配置文件中的路径application.yml的profile - String myPath = RuoYiConfig.getMyPath(); - // 构建完整的文件路径 - String fileUrl = myPath + "/日志信息/红外热成像/" + filePath; - // 创建文件对象 - File file = new File(fileUrl); - // 检查文件是否存在 - if (file.exists()) { - // 创建文件系统资源对象,包装文件,http头不能使用file,所以使用FileSystemResource - FileSystemResource resource = new FileSystemResource(file); - // 创建HTTP头对象 - HttpHeaders headers = new HttpHeaders(); - // 设置文件长度 - headers.setContentLength(file.length()); - // 动态检测文件的MIME类型 - try { - // 尝试获取文件的内容类型 - String contentType = Files.probeContentType(file.toPath()); - if (contentType != null) { - // 如果内容类型不为空,则设置到HTTP响应头中 - headers.setContentType(MediaType.parseMediaType(contentType)); - } else { - // 如果内容类型为空,则默认设置为图像类型 - headers.setContentType(MediaType.parseMediaType("image/*")); - } - } catch (IOException e) { - // 如果发生IO异常,则默认设置内容类型为图像类型 - headers.setContentType(MediaType.parseMediaType("image/*")); - } - // 返回包含文件资源的响应实体 - return ResponseEntity.ok() - .headers(headers) - .body(resource); - } else { - // 如果文件不存在,返回404状态 - return ResponseEntity.notFound().build(); - } + return recordBusbarTempService.getThermalPhoto(filePath); } + /** + * 获取母排测温曲线。 + * @param recordBusbarTemp 需要查询的母线温度记录。 + * @return 返回一个AjaxResult对象,其中包含查询到的母线温度记录列表。 + */ @GetMapping("/busbarTempCurve") public AjaxResult busbarTempCurve (RecordBusbarTemp recordBusbarTemp){ List recordBusbarTempList = recordBusbarTempService @@ -212,4 +145,17 @@ public class RecordBusbarTempController extends BaseController } + /** + * 获取母排测温记录列表。 + * @param recordBusbarTemp 母线温度记录对象,用于封装查询条件。 + * @return 返回一个AjaxResult对象,其中包含查询到的母线温度记录列表。 + */ + @PreAuthorize("@ss.hasPermi('record:recordBusbarTemp:list')") + @PostMapping("/recordBusbarTempList") + public AjaxResult recordBusbarTempList(RecordBusbarTemp recordBusbarTemp) + { + List list = recordBusbarTempService.selectRecordBusbarTempList(recordBusbarTemp); + return success(list); + } + } diff --git a/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordInspectionCabinetController.java b/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordInspectionCabinetController.java index ec0f237..71eb220 100644 --- a/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordInspectionCabinetController.java +++ b/ruoyi-module/src/main/java/com/ruoyi/record/controller/RecordInspectionCabinetController.java @@ -41,7 +41,7 @@ import java.util.RandomAccess; /** * 电柜巡检记录Controller - * + * * @author zangch * @date 2024-11-07 */ @@ -121,7 +121,6 @@ public class RecordInspectionCabinetController extends BaseController } - /** * 处理热成像视频文件的HTTP GET请求。 * @param filePath 热成像视频文件的路径 @@ -129,39 +128,8 @@ public class RecordInspectionCabinetController extends BaseController */ @GetMapping("/getThermalVideo/{filePath}") public ResponseEntity getThermalVideo(@PathVariable String filePath) { - // 获取配置文件中的路径application.yml的profile - String myPath = RuoYiConfig.getMyPath(); - // 构建完整的文件路径 - String fileUrl = myPath + "/日志信息/巡检录像/热成像/" + filePath; - // 创建文件对象 - File file = new File(fileUrl); - // 检查文件是否存在 - if (file.exists()) { - // 创建文件系统资源对象,包装文件,http头不能使用file,所以使用FileSystemResource - FileSystemResource resource = new FileSystemResource(file); - // 设置响应头,指定内容类型为视频格式 - HttpHeaders headers = new HttpHeaders(); - // 设置文件长度的内容类型 - headers.setContentLength(file.length()); - // 动态检测文件的MIME类型 - try { - String contentType = Files.probeContentType(file.toPath()); - if (contentType != null) { - headers.setContentType(MediaType.parseMediaType(contentType)); - } else { - headers.setContentType(MediaType.parseMediaType("video/*")); - } - } catch (IOException e) { - headers.setContentType(MediaType.parseMediaType("video/*")); - } - // 返回包含文件资源的响应实体 - return ResponseEntity.ok() - .headers(headers) - .body(resource); - } else { - // 如果文件不存在,返回404状态 - return ResponseEntity.notFound().build(); - } + + return recordInspectionCabinetService.getThermalVideo(filePath); } /** @@ -171,39 +139,7 @@ public class RecordInspectionCabinetController extends BaseController */ @GetMapping("/getVisibleVideo/{filePath}") public ResponseEntity getVisibleVideo(@PathVariable String filePath) { - // 获取配置文件中的路径application.yml的profile - String myPath = RuoYiConfig.getMyPath(); - // 构建完整的文件路径 - String fileUrl = myPath + "/日志信息/巡检录像/可见光/" + filePath; - // 创建文件对象 - File file = new File(fileUrl); - // 检查文件是否存在 - if (file.exists()) { - // 创建文件系统资源对象,包装文件,http头不能使用file,所以使用FileSystemResource - FileSystemResource resource = new FileSystemResource(file); - // 设置HTTP头信息 - HttpHeaders headers = new HttpHeaders(); - // 设置文件长度 - headers.setContentLength(file.length()); - // 动态检测文件的MIME类型 - try { - String contentType = Files.probeContentType(file.toPath()); - if (contentType != null) { - headers.setContentType(MediaType.parseMediaType(contentType)); - } else { - headers.setContentType(MediaType.parseMediaType("video/*")); - } - } catch (IOException e) { - headers.setContentType(MediaType.parseMediaType("video/*")); - } - // 返回包含文件资源的响应实体 - return ResponseEntity.ok() - .headers(headers) - .body(resource); - } else { - // 如果文件不存在,返回404状态 - return ResponseEntity.notFound().build(); - } + return recordInspectionCabinetService.getVisibleVideo(filePath); } } diff --git a/ruoyi-module/src/main/java/com/ruoyi/record/service/IRecordBusbarTempService.java b/ruoyi-module/src/main/java/com/ruoyi/record/service/IRecordBusbarTempService.java index 46e9990..d755c3a 100644 --- a/ruoyi-module/src/main/java/com/ruoyi/record/service/IRecordBusbarTempService.java +++ b/ruoyi-module/src/main/java/com/ruoyi/record/service/IRecordBusbarTempService.java @@ -1,19 +1,28 @@ package com.ruoyi.record.service; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import java.util.List; + +import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.record.domain.RecordBusbarTemp; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; /** * 母排测温信息Service接口 - * + * * @author zangch * @date 2024-11-07 */ -public interface IRecordBusbarTempService +public interface IRecordBusbarTempService { /** * 查询母排测温信息 - * + * * @param objId 母排测温信息主键 * @return 母排测温信息 */ @@ -21,7 +30,7 @@ public interface IRecordBusbarTempService /** * 查询母排测温信息列表 - * + * * @param recordBusbarTemp 母排测温信息 * @return 母排测温信息集合 */ @@ -29,7 +38,7 @@ public interface IRecordBusbarTempService /** * 新增母排测温信息 - * + * * @param recordBusbarTemp 母排测温信息 * @return 结果 */ @@ -37,7 +46,7 @@ public interface IRecordBusbarTempService /** * 修改母排测温信息 - * + * * @param recordBusbarTemp 母排测温信息 * @return 结果 */ @@ -45,7 +54,7 @@ public interface IRecordBusbarTempService /** * 批量删除母排测温信息 - * + * * @param objIds 需要删除的母排测温信息主键集合 * @return 结果 */ @@ -53,9 +62,23 @@ public interface IRecordBusbarTempService /** * 删除母排测温信息信息 - * + * * @param objId 母排测温信息主键 * @return 结果 */ public int deleteRecordBusbarTempByObjId(Long objId); + + /** + * 获取红外热成像照片。 + * @param filePath 需要获取的红外热成像照片的文件路径。 + * @return 如果文件存在,返回包含文件资源的响应实体;如果文件不存在,返回404状态。 + */ + public ResponseEntity getThermalPhoto(String filePath); + + /** + * 获取可见光图像。 + * @param filePath 需要获取的图像文件的路径。 + * @return 如果文件存在,返回包含文件资源的响应实体;如果文件不存在,返回404状态。 + */ + public ResponseEntity getVisiblePhoto(String filePath); } diff --git a/ruoyi-module/src/main/java/com/ruoyi/record/service/IRecordInspectionCabinetService.java b/ruoyi-module/src/main/java/com/ruoyi/record/service/IRecordInspectionCabinetService.java index 7b6bab4..9061a94 100644 --- a/ruoyi-module/src/main/java/com/ruoyi/record/service/IRecordInspectionCabinetService.java +++ b/ruoyi-module/src/main/java/com/ruoyi/record/service/IRecordInspectionCabinetService.java @@ -2,18 +2,20 @@ package com.ruoyi.record.service; import java.util.List; import com.ruoyi.record.domain.RecordInspectionCabinet; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.ResponseEntity; /** * 电柜巡检记录Service接口 - * + * * @author zangch * @date 2024-11-07 */ -public interface IRecordInspectionCabinetService +public interface IRecordInspectionCabinetService { /** * 查询电柜巡检记录 - * + * * @param objId 电柜巡检记录主键 * @return 电柜巡检记录 */ @@ -21,7 +23,7 @@ public interface IRecordInspectionCabinetService /** * 查询电柜巡检记录列表 - * + * * @param recordInspectionCabinet 电柜巡检记录 * @return 电柜巡检记录集合 */ @@ -29,7 +31,7 @@ public interface IRecordInspectionCabinetService /** * 新增电柜巡检记录 - * + * * @param recordInspectionCabinet 电柜巡检记录 * @return 结果 */ @@ -37,7 +39,7 @@ public interface IRecordInspectionCabinetService /** * 修改电柜巡检记录 - * + * * @param recordInspectionCabinet 电柜巡检记录 * @return 结果 */ @@ -45,7 +47,7 @@ public interface IRecordInspectionCabinetService /** * 批量删除电柜巡检记录 - * + * * @param objIds 需要删除的电柜巡检记录主键集合 * @return 结果 */ @@ -53,9 +55,23 @@ public interface IRecordInspectionCabinetService /** * 删除电柜巡检记录信息 - * + * * @param objId 电柜巡检记录主键 * @return 结果 */ public int deleteRecordInspectionCabinetByObjId(Long objId); + + /** + * 获取热成像视频文件。 + * @param filePath 需要获取的视频文件的路径。 + * @return 如果文件存在,返回包含文件资源的响应实体;如果文件不存在,返回404状态。 + */ + public ResponseEntity getThermalVideo(String filePath); + + /** + * 获取热成像视频文件。 + * @param filePath 需要获取的视频文件的路径。 + * @return 如果文件存在,返回包含文件资源的响应实体;如果文件不存在,返回404状态。 + */ + public ResponseEntity getVisibleVideo(String filePath); } diff --git a/ruoyi-module/src/main/java/com/ruoyi/record/service/impl/RecordBusbarTempServiceImpl.java b/ruoyi-module/src/main/java/com/ruoyi/record/service/impl/RecordBusbarTempServiceImpl.java index a800f97..6d1398f 100644 --- a/ruoyi-module/src/main/java/com/ruoyi/record/service/impl/RecordBusbarTempServiceImpl.java +++ b/ruoyi-module/src/main/java/com/ruoyi/record/service/impl/RecordBusbarTempServiceImpl.java @@ -1,13 +1,24 @@ package com.ruoyi.record.service.impl; +import java.io.File; import java.util.List; +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; +import javax.servlet.http.HttpServletResponse; + import com.ruoyi.base.domain.BaseBusbarInfo; import com.ruoyi.base.domain.BaseCabinetInfo; import com.ruoyi.base.mapper.BaseBusbarInfoMapper; import com.ruoyi.base.mapper.BaseCabinetInfoMapper; +import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.exception.ServiceException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import com.ruoyi.record.mapper.RecordBusbarTempMapper; import com.ruoyi.record.domain.RecordBusbarTemp; @@ -15,12 +26,12 @@ import com.ruoyi.record.service.IRecordBusbarTempService; /** * 母排测温信息Service业务层处理 - * + * * @author zangch * @date 2024-11-07 */ @Service -public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService +public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService { @Autowired private RecordBusbarTempMapper recordBusbarTempMapper; @@ -31,7 +42,7 @@ public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService /** * 查询母排测温信息 - * + * * @param objId 母排测温信息主键 * @return 母排测温信息 */ @@ -43,7 +54,7 @@ public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService /** * 查询母排测温信息列表 - * + * * @param recordBusbarTemp 母排测温信息 * @return 母排测温信息 */ @@ -55,7 +66,7 @@ public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService /** * 新增母排测温信息 - * + * * @param recordBusbarTemp 母排测温信息 * @return 结果 */ @@ -83,7 +94,7 @@ public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService /** * 修改母排测温信息 - * + * * @param recordBusbarTemp 母排测温信息 * @return 结果 */ @@ -111,7 +122,7 @@ public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService /** * 批量删除母排测温信息 - * + * * @param objIds 需要删除的母排测温信息主键 * @return 结果 */ @@ -123,7 +134,7 @@ public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService /** * 删除母排测温信息信息 - * + * * @param objId 母排测温信息主键 * @return 结果 */ @@ -132,4 +143,97 @@ public class RecordBusbarTempServiceImpl implements IRecordBusbarTempService { return recordBusbarTempMapper.deleteRecordBusbarTempByObjId(objId); } + + /** + * 获取红外热成像照片。 + * @param filePath 需要获取的红外热成像照片的文件路径。 + * @return 如果文件存在,返回包含文件资源的响应实体;如果文件不存在,返回404状态。 + */ + @Override + public ResponseEntity getThermalPhoto(String filePath){ + // 获取配置文件中的路径application.yml的profile + String myPath = RuoYiConfig.getMyPath(); + // 构建完整的文件路径 + String fileUrl = myPath + "/日志信息/红外热成像/" + filePath; + // 创建文件对象 + File file = new File(fileUrl); + // 检查文件是否存在 + if (file.exists()) { + // 创建文件系统资源对象,包装文件,http头不能使用file,所以使用FileSystemResource + FileSystemResource resource = new FileSystemResource(file); + // 创建HTTP头对象 + HttpHeaders headers = new HttpHeaders(); + // 设置文件长度 + headers.setContentLength(file.length()); + // 动态检测文件的MIME类型 + try { + // 尝试获取文件的内容类型 + String contentType = Files.probeContentType(file.toPath()); + if (contentType != null) { + // 如果内容类型不为空,则设置到HTTP响应头中 + headers.setContentType(MediaType.parseMediaType(contentType)); + } else { + // 如果内容类型为空,则默认设置为图像类型 + headers.setContentType(MediaType.parseMediaType("image/*")); + } + } catch (IOException e) { + // 如果发生IO异常,则默认设置内容类型为图像类型 + headers.setContentType(MediaType.parseMediaType("image/*")); + } + // 返回包含文件资源的响应实体 + return ResponseEntity.ok() + .headers(headers) + .body(resource); + } else { + // 如果文件不存在,返回404状态 + return ResponseEntity.notFound().build(); + } + + } + + /** + * 获取可见光图像。 + * @param filePath 需要获取的图像文件的路径。 + * @return 如果文件存在,返回包含文件资源的响应实体;如果文件不存在,返回404状态。 + */ + @Override + public ResponseEntity getVisiblePhoto(String filePath){ + // 获取配置文件中的路径application.yml的profile + String myPath = RuoYiConfig.getMyPath(); + // 构建文件的完整路径 + String fileUrl = myPath + "/日志信息/可见光图像/" + filePath; + // 创建文件对象 + File file = new File(fileUrl); + // 检查文件是否存在 + if (file.exists()) { + // 创建文件系统资源对象,包装文件,http头不能使用file,所以使用FileSystemResource + FileSystemResource resource = new FileSystemResource(file); + // 创建HttpHeaders对象,用于设置响应头 + HttpHeaders headers = new HttpHeaders(); + // 设置文件长度 + headers.setContentLength(file.length()); + // 动态检测文件的MIME类型 + try { + // 尝试获取文件的内容类型 + String contentType = Files.probeContentType(file.toPath()); + if (contentType != null) { + // 如果内容类型不为空,则设置到HTTP响应头中 + headers.setContentType(MediaType.parseMediaType(contentType)); + } else { + // 如果内容类型为空,则默认设置为图像类型 + headers.setContentType(MediaType.parseMediaType("image/*")); + } + } catch (IOException e) { + // 如果发生IO异常,则默认设置内容类型为图像类型 + headers.setContentType(MediaType.parseMediaType("image/*")); + } + // 返回包含文件资源的响应实体 + return ResponseEntity.ok() + .headers(headers) + .body(resource); + } else { + // 如果文件不存在,返回404状态 + return ResponseEntity.notFound().build(); + } + } } diff --git a/ruoyi-module/src/main/java/com/ruoyi/record/service/impl/RecordInspectionCabinetServiceImpl.java b/ruoyi-module/src/main/java/com/ruoyi/record/service/impl/RecordInspectionCabinetServiceImpl.java index d7758e0..9b040d7 100644 --- a/ruoyi-module/src/main/java/com/ruoyi/record/service/impl/RecordInspectionCabinetServiceImpl.java +++ b/ruoyi-module/src/main/java/com/ruoyi/record/service/impl/RecordInspectionCabinetServiceImpl.java @@ -1,7 +1,21 @@ package com.ruoyi.record.service.impl; +import java.io.File; import java.util.List; + +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.file.Files; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.config.RuoYiConfig; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import com.ruoyi.record.mapper.RecordInspectionCabinetMapper; import com.ruoyi.record.domain.RecordInspectionCabinet; @@ -9,19 +23,19 @@ import com.ruoyi.record.service.IRecordInspectionCabinetService; /** * 电柜巡检记录Service业务层处理 - * + * * @author zangch * @date 2024-11-07 */ @Service -public class RecordInspectionCabinetServiceImpl implements IRecordInspectionCabinetService +public class RecordInspectionCabinetServiceImpl implements IRecordInspectionCabinetService { @Autowired private RecordInspectionCabinetMapper recordInspectionCabinetMapper; /** * 查询电柜巡检记录 - * + * * @param objId 电柜巡检记录主键 * @return 电柜巡检记录 */ @@ -33,7 +47,7 @@ public class RecordInspectionCabinetServiceImpl implements IRecordInspectionCabi /** * 查询电柜巡检记录列表 - * + * * @param recordInspectionCabinet 电柜巡检记录 * @return 电柜巡检记录 */ @@ -45,7 +59,7 @@ public class RecordInspectionCabinetServiceImpl implements IRecordInspectionCabi /** * 新增电柜巡检记录 - * + * * @param recordInspectionCabinet 电柜巡检记录 * @return 结果 */ @@ -57,7 +71,7 @@ public class RecordInspectionCabinetServiceImpl implements IRecordInspectionCabi /** * 修改电柜巡检记录 - * + * * @param recordInspectionCabinet 电柜巡检记录 * @return 结果 */ @@ -69,7 +83,7 @@ public class RecordInspectionCabinetServiceImpl implements IRecordInspectionCabi /** * 批量删除电柜巡检记录 - * + * * @param objIds 需要删除的电柜巡检记录主键 * @return 结果 */ @@ -81,7 +95,7 @@ public class RecordInspectionCabinetServiceImpl implements IRecordInspectionCabi /** * 删除电柜巡检记录信息 - * + * * @param objId 电柜巡检记录主键 * @return 结果 */ @@ -90,4 +104,89 @@ public class RecordInspectionCabinetServiceImpl implements IRecordInspectionCabi { return recordInspectionCabinetMapper.deleteRecordInspectionCabinetByObjId(objId); } + + /** + * 获取热成像视频文件。 + * @param filePath 需要获取的视频文件的路径。 + * @return 如果文件存在,返回包含文件资源的响应实体;如果文件不存在,返回404状态。 + */ + @Override + public ResponseEntity getThermalVideo(String filePath){ + // 获取配置文件中的路径application.yml的profile + String myPath = RuoYiConfig.getMyPath(); + // 构建完整的文件路径 + String fileUrl = myPath + "/日志信息/巡检录像/热成像/" + filePath; + // 创建文件对象 + File file = new File(fileUrl); + // 检查文件是否存在 + if (file.exists()) { + // 创建文件系统资源对象,包装文件,http头不能使用file,所以使用FileSystemResource + FileSystemResource resource = new FileSystemResource(file); + // 设置响应头,指定内容类型为视频格式 + HttpHeaders headers = new HttpHeaders(); + // 设置文件长度的内容类型 + headers.setContentLength(file.length()); + // 动态检测文件的MIME类型 + try { + String contentType = Files.probeContentType(file.toPath()); + if (contentType != null) { + headers.setContentType(MediaType.parseMediaType(contentType)); + } else { + headers.setContentType(MediaType.parseMediaType("video/*")); + } + } catch (IOException e) { + headers.setContentType(MediaType.parseMediaType("video/*")); + } + // 返回包含文件资源的响应实体 + return ResponseEntity.ok() + .headers(headers) + .body(resource); + } else { + // 如果文件不存在,返回404状态 + return ResponseEntity.notFound().build(); + } + } + + /** + * 获取可见光视频文件。 + * @param filePath 需要获取的视频文件的路径。 + * @return 如果文件存在,返回包含文件资源的响应实体;如果文件不存在,返回404状态。 + */ + @Override + public ResponseEntity getVisibleVideo(String filePath){ + // 获取配置文件中的路径application.yml的profile + String myPath = RuoYiConfig.getMyPath(); + // 构建完整的文件路径 + String fileUrl = myPath + "/日志信息/巡检录像/可见光/" + filePath; + // 创建文件对象 + File file = new File(fileUrl); + // 检查文件是否存在 + if (file.exists()) { + // 创建文件系统资源对象,包装文件,http头不能使用file,所以使用FileSystemResource + FileSystemResource resource = new FileSystemResource(file); + // 设置HTTP头信息 + HttpHeaders headers = new HttpHeaders(); + // 设置文件长度 + headers.setContentLength(file.length()); + // 动态检测文件的MIME类型 + try { + String contentType = Files.probeContentType(file.toPath()); + if (contentType != null) { + headers.setContentType(MediaType.parseMediaType(contentType)); + } else { + headers.setContentType(MediaType.parseMediaType("video/*")); + } + } catch (IOException e) { + headers.setContentType(MediaType.parseMediaType("video/*")); + } + // 返回包含文件资源的响应实体 + return ResponseEntity.ok() + .headers(headers) + .body(resource); + } else { + // 如果文件不存在,返回404状态 + return ResponseEntity.notFound().build(); + } + } + }