|
|
|
@ -84,6 +84,7 @@ public class EquBaseController extends BaseController |
|
|
|
// 调用职责单一的 Service 方法
|
|
|
|
// 调用职责单一的 Service 方法
|
|
|
|
return success(equBaseService.selectLatestEquMonitorInfo(id)); |
|
|
|
return success(equBaseService.selectLatestEquMonitorInfo(id)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取设备指定时间段内的历史监控信息 |
|
|
|
* 获取设备指定时间段内的历史监控信息 |
|
|
|
* @param equBaseQueryDto 查询对象,包含设备ID、开始时间和结束时间 |
|
|
|
* @param equBaseQueryDto 查询对象,包含设备ID、开始时间和结束时间 |
|
|
|
@ -120,34 +121,35 @@ public class EquBaseController extends BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
// /**
|
|
|
|
* 根据设备ID返回图片流 |
|
|
|
// * 根据设备ID返回图片流
|
|
|
|
* 前端直接 <img src="/equBase/image/{id}"> |
|
|
|
// * 前端直接 <img src="/equBase/image/{id}">
|
|
|
|
*/ |
|
|
|
// */
|
|
|
|
|
|
|
|
//
|
|
|
|
@PreAuthorize("@ss.hasPermi('device:files:queryimage')") |
|
|
|
// @PreAuthorize("@ss.hasPermi('device:files:queryimage')")
|
|
|
|
@GetMapping(value = "/queryimage/{id}") |
|
|
|
// @GetMapping(value = "/queryimage/{id}")
|
|
|
|
@ApiOperation("查询单个设备图片") |
|
|
|
// @ApiOperation("查询单个设备图片")
|
|
|
|
public void getImage(@PathVariable String id, HttpServletResponse response) throws IOException { |
|
|
|
// public void getImage(@PathVariable String id, HttpServletResponse response) throws IOException {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// byte[] imgBytes = equBaseService.selectEquBaseImageById(id).getEquImage();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (imgBytes != null && imgBytes.length > 0) {
|
|
|
|
|
|
|
|
// // 设置响应类型,可根据实际图片类型动态修改
|
|
|
|
|
|
|
|
// response.setContentType("image/png");
|
|
|
|
|
|
|
|
// // 可选:缓存图片
|
|
|
|
|
|
|
|
// response.setHeader("Cache-Control", "max-age=3600");
|
|
|
|
|
|
|
|
// // 输出流写入响应
|
|
|
|
|
|
|
|
// ServletOutputStream os = response.getOutputStream();
|
|
|
|
|
|
|
|
// os.write(imgBytes);
|
|
|
|
|
|
|
|
// os.flush();
|
|
|
|
|
|
|
|
// os.close();
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// // 图片不存在
|
|
|
|
|
|
|
|
// response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
byte[] imgBytes = equBaseService.selectEquBaseImageById(id).getEquImage(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (imgBytes != null && imgBytes.length > 0) { |
|
|
|
|
|
|
|
// 设置响应类型,可根据实际图片类型动态修改
|
|
|
|
|
|
|
|
response.setContentType("image/png"); |
|
|
|
|
|
|
|
// 可选:缓存图片
|
|
|
|
|
|
|
|
response.setHeader("Cache-Control", "max-age=3600"); |
|
|
|
|
|
|
|
// 输出流写入响应
|
|
|
|
|
|
|
|
ServletOutputStream os = response.getOutputStream(); |
|
|
|
|
|
|
|
os.write(imgBytes); |
|
|
|
|
|
|
|
os.flush(); |
|
|
|
|
|
|
|
os.close(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 图片不存在
|
|
|
|
|
|
|
|
response.sendError(HttpServletResponse.SC_NOT_FOUND); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//厂商下拉表
|
|
|
|
//厂商下拉表
|
|
|
|
@PreAuthorize("@ss.hasPermi('device:files:queryManufacture')") |
|
|
|
@PreAuthorize("@ss.hasPermi('device:files:queryManufacture')") |
|
|
|
@GetMapping( "/manufacture") |
|
|
|
@GetMapping( "/manufacture") |
|
|
|
@ -181,46 +183,44 @@ public class EquBaseController extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 新增设备基本信息 |
|
|
|
* 新增设备基本信息 |
|
|
|
|
|
|
|
* @ModelAttribute equBase, |
|
|
|
|
|
|
|
* @RequestPart(value = "file", required = false) // 使用 @RequestPart
|
|
|
|
|
|
|
|
* @ApiParam(value = "设备图片文件", type = "file") |
|
|
|
|
|
|
|
* MultipartFile file |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@PreAuthorize("@ss.hasPermi('device:files:add')") |
|
|
|
@PreAuthorize("@ss.hasPermi('device:files:add')") |
|
|
|
@Log(title = "设备基本信息", businessType = BusinessType.INSERT) |
|
|
|
@Log(title = "设备基本信息", businessType = BusinessType.INSERT) |
|
|
|
@PostMapping(value = "/add") |
|
|
|
@PostMapping(value = "/add") |
|
|
|
@ApiOperation("增加设备档案信息") |
|
|
|
@ApiOperation("增加设备档案信息") |
|
|
|
public AjaxResult add( |
|
|
|
public AjaxResult add( @RequestBody EquBase equBase |
|
|
|
@ModelAttribute EquBase equBase, |
|
|
|
) { |
|
|
|
@RequestPart(value = "file", required = false) // 使用 @RequestPart
|
|
|
|
|
|
|
|
@ApiParam(value = "设备图片文件", type = "file") |
|
|
|
|
|
|
|
MultipartFile file |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) throws IOException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理图片
|
|
|
|
// // 处理图片
|
|
|
|
if (file != null && !file.isEmpty()) { |
|
|
|
// if (file != null && !file.isEmpty()) {
|
|
|
|
equBase.setEquImage(file.getBytes()); |
|
|
|
// equBase.setEquImage(file.getBytes());
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 调用 Service 插入数据库
|
|
|
|
// 调用 Service 插入数据库
|
|
|
|
return toAjax(equBaseService.insertEquBase(equBase)); |
|
|
|
return toAjax(equBaseService.insertEquBase(equBase)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* @ModelAttribute EquBase equBase, // 自动绑定表单字段
|
|
|
|
|
|
|
|
* @RequestPart(value = "file", required = false) // 使用 @RequestPart
|
|
|
|
|
|
|
|
* @ApiParam(value = "设备图片文件", type = "file") |
|
|
|
|
|
|
|
* MultipartFile file |
|
|
|
* 修改设备基本信息 |
|
|
|
* 修改设备基本信息 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@PreAuthorize("@ss.hasPermi('device:files:edit')") |
|
|
|
@PreAuthorize("@ss.hasPermi('device:files:edit')") |
|
|
|
@Log(title = "设备基本信息", businessType = BusinessType.UPDATE) |
|
|
|
@Log(title = "设备基本信息", businessType = BusinessType.UPDATE) |
|
|
|
@PutMapping("/modify") |
|
|
|
@PutMapping("/modify") |
|
|
|
@ApiOperation("修改设备档案信息") |
|
|
|
@ApiOperation("修改设备档案信息") |
|
|
|
public AjaxResult edit( |
|
|
|
public AjaxResult edit(@RequestBody EquBase equBase){ |
|
|
|
@ModelAttribute EquBase equBase, // 自动绑定表单字段
|
|
|
|
|
|
|
|
@RequestPart(value = "file", required = false) // 使用 @RequestPart
|
|
|
|
// // 处理图片
|
|
|
|
@ApiParam(value = "设备图片文件", type = "file") |
|
|
|
// if (file != null && !file.isEmpty()) {
|
|
|
|
MultipartFile file |
|
|
|
// equBase.setEquImage(file.getBytes()); // 存数据库 Blob
|
|
|
|
) throws IOException { |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 处理图片
|
|
|
|
|
|
|
|
if (file != null && !file.isEmpty()) { |
|
|
|
|
|
|
|
equBase.setEquImage(file.getBytes()); // 存数据库 Blob
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用 Service 插入数据库
|
|
|
|
// 调用 Service 插入数据库
|
|
|
|
return toAjax(equBaseService.updateEquBase(equBase)); |
|
|
|
return toAjax(equBaseService.updateEquBase(equBase)); |
|
|
|
|