|
|
|
|
@ -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<FileSystemResource> 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<FileSystemResource> 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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|