From a3d274cc185968709ff240cd77a11a31df045183 Mon Sep 17 00:00:00 2001 From: zhangnaisong <2434969829@qq.com> Date: 星期一, 27 五月 2024 14:25:29 +0800 Subject: [PATCH] 设备健康获取某油井一段时间的测量趋势修改提交 --- ard-work/src/main/java/com/ruoyi/media/controller/VtduController.java | 294 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 179 insertions(+), 115 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/media/controller/VtduController.java b/ard-work/src/main/java/com/ruoyi/media/controller/VtduController.java index 5ea0a2d..d61b746 100644 --- a/ard-work/src/main/java/com/ruoyi/media/controller/VtduController.java +++ b/ard-work/src/main/java/com/ruoyi/media/controller/VtduController.java @@ -1,115 +1,179 @@ -package com.ruoyi.media.controller; - -import java.util.List; -import java.util.Map; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; - -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.media.service.IMediaService; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.media.domain.Vtdu; -import com.ruoyi.media.service.IVtduService; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.common.core.page.TableDataInfo; - -/** - * 娴佸獟浣撶鐞咰ontroller - * - * @author ard - * @date 2023-08-29 - */ -@RestController -@RequestMapping("/vtdu/media") -public class VtduController extends BaseController -{ - @Autowired - private IVtduService vtduService; - - /** - * 鏌ヨ娴佸獟浣撶鐞嗗垪琛� - */ - @PreAuthorize("@ss.hasPermi('vtdu:media:list')") - @GetMapping("/list") - public TableDataInfo list(Vtdu vtdu) - { - startPage(); - List<Vtdu> list = vtduService.selectVtduList(vtdu); - return getDataTable(list); - } - - /** - * 瀵煎嚭娴佸獟浣撶鐞嗗垪琛� - */ - @PreAuthorize("@ss.hasPermi('vtdu:media:export')") - @Log(title = "娴佸獟浣撶鐞�", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, Vtdu vtdu) - { - List<Vtdu> list = vtduService.selectVtduList(vtdu); - ExcelUtil<Vtdu> util = new ExcelUtil<Vtdu>(Vtdu.class); - util.exportExcel(response, list, "娴佸獟浣撶鐞嗘暟鎹�"); - } - - /** - * 鑾峰彇娴佸獟浣撶鐞嗚缁嗕俊鎭� - */ - @PreAuthorize("@ss.hasPermi('vtdu:media:query')") - @GetMapping(value = "/{name}") - public AjaxResult getInfo(@PathVariable("name") String name) - { - return success(vtduService.selectVtduByName(name)); - } - - /** - * 鏂板娴佸獟浣撶鐞� - */ - @PreAuthorize("@ss.hasPermi('vtdu:media:add')") - @Log(title = "娴佸獟浣撶鐞�", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody Vtdu vtdu) - { - if (StringUtils.isEmpty(vtdu.getName())) { - return AjaxResult.error("閫氶亾鍚嶇О涓嶈兘涓虹┖"); - } - if (StringUtils.isEmpty(vtdu.getRtspSource())) { - return AjaxResult.error("rtsp鍦板潃涓嶈兘涓虹┖"); - } - return toAjax(vtduService.insertVtdu(vtdu)); - } - - /** - * 淇敼娴佸獟浣撶鐞� - */ - @PreAuthorize("@ss.hasPermi('vtdu:media:edit')") - @Log(title = "娴佸獟浣撶鐞�", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody Vtdu vtdu) - { - return toAjax(vtduService.updateVtdu(vtdu)); - } - - /** - * 鍒犻櫎娴佸獟浣撶鐞� - */ - @PreAuthorize("@ss.hasPermi('vtdu:media:remove')") - @Log(title = "娴佸獟浣撶鐞�", businessType = BusinessType.DELETE) - @DeleteMapping("/{names}") - public AjaxResult remove(@PathVariable String[] names) - { - return toAjax(vtduService.deleteVtduByNames(names)); - } -} +package com.ruoyi.media.controller; + +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.device.camera.domain.CameraCmd; +import com.ruoyi.device.camera.service.ICameraSdkService; +import com.ruoyi.media.service.IMediaService; +import com.ruoyi.media.service.impl.MediaServiceImpl; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.media.domain.Vtdu; +import com.ruoyi.media.service.IVtduService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 娴佸獟浣撶鐞咰ontroller + * + * @author ard + * @date 2023-08-29 + */ +@RestController +@RequestMapping("/vtdu/media") +public class VtduController extends BaseController { + @Autowired + private IVtduService vtduService; + @Resource + private IMediaService mediaService; + @Resource + private ICameraSdkService cameraSdkService; + + /** + * 鏌ヨ娴佸獟浣撶鐞嗗垪琛� + */ + @PreAuthorize("@ss.hasPermi('vtdu:media:list')") + @GetMapping("/list") + public TableDataInfo list(Vtdu vtdu) { + startPage(); + List<Vtdu> list = vtduService.selectVtduList(vtdu); + return getDataTable(list); + } + /** + * 鏌ヨ娴佸獟浣撶鐞嗗垪琛紙涓嶆牎楠屾潈闄愶級 + */ + @GetMapping("/list/noPerm") + public TableDataInfo listNoPerm(Vtdu vtdu) { + startPage(); + List<Vtdu> list = vtduService.selectVtduList(vtdu); + return getDataTable(list); + } + /** + * 瀵煎嚭娴佸獟浣撶鐞嗗垪琛� + */ + @PreAuthorize("@ss.hasPermi('vtdu:media:export')") + @Log(title = "娴佸獟浣撶鐞�", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Vtdu vtdu) { + List<Vtdu> list = vtduService.selectVtduList(vtdu); + ExcelUtil<Vtdu> util = new ExcelUtil<Vtdu>(Vtdu.class); + util.exportExcel(response, list, "娴佸獟浣撶鐞嗘暟鎹�"); + } + + /** + * 鑾峰彇娴佸獟浣撶鐞嗚缁嗕俊鎭� + */ + @PreAuthorize("@ss.hasPermi('vtdu:media:query')") + @GetMapping(value = "/{name}") + public AjaxResult getInfo(@PathVariable("name") String name) { + Vtdu vtdu = vtduService.selectVtduByName(name); + if (vtdu != null) { + String cameraId = name.split("_")[0]; + Integer chanNo = Integer.valueOf(name.split("_")[1]); + CameraCmd cmd = new CameraCmd(cameraId, chanNo); + Map<String, Object> videoCompressionCfg = cameraSdkService.getVideoCompressionCfg(cmd); + String videoEncType = (String) videoCompressionCfg.get("videoEncType"); + if (videoEncType != null) { + if (!videoEncType.equals("鏍囧噯h264")) { + vtdu.setIsCode("1"); + } else { + vtdu.setIsCode("0"); + } + } + else + { + vtdu.setIsCode("0"); + } + //娴佸獟浣撲笉瀛樺湪鏂板锛屽瓨鍦ㄦ洿鏂� + if (!mediaService.checkNameExist(name)) { + mediaService.addPath(name, vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode()); + } else { + vtduService.updateVtdu(vtdu); + } + } + return success(vtdu); + } + /** + * 鑾峰彇娴佸獟浣撶鐞嗚缁嗕俊鎭紙涓嶆牎楠屾潈闄愶級 + */ + @GetMapping(value = "/{name}/noPerm") + public AjaxResult getInfoNoPerm(@PathVariable("name") String name) { + Vtdu vtdu = vtduService.selectVtduByName(name); + if (vtdu != null) { + String cameraId = name.split("_")[0]; + Integer chanNo = Integer.valueOf(name.split("_")[1]); + CameraCmd cmd = new CameraCmd(cameraId, chanNo); + Map<String, Object> videoCompressionCfg = cameraSdkService.getVideoCompressionCfg(cmd); + String videoEncType = (String) videoCompressionCfg.get("videoEncType"); + if (videoEncType != null) { + if (!videoEncType.equals("鏍囧噯h264")) { + vtdu.setIsCode("1"); + } else { + vtdu.setIsCode("0"); + } + } + else + { + vtdu.setIsCode("0"); + } + //娴佸獟浣撲笉瀛樺湪鏂板锛屽瓨鍦ㄦ洿鏂� + if (!mediaService.checkNameExist(name)) { + mediaService.addPath(name, vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode()); + } else { + vtduService.updateVtdu(vtdu); + } + } + return success(vtdu); + } + /** + * 鏂板娴佸獟浣撶鐞� + */ + @PreAuthorize("@ss.hasPermi('vtdu:media:add')") + @Log(title = "娴佸獟浣撶鐞�", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Vtdu vtdu) { + if (StringUtils.isEmpty(vtdu.getName())) { + return AjaxResult.error("閫氶亾鍚嶇О涓嶈兘涓虹┖"); + } + if (StringUtils.isEmpty(vtdu.getRtspSource())) { + return AjaxResult.error("rtsp鍦板潃涓嶈兘涓虹┖"); + } + return toAjax(vtduService.insertVtdu(vtdu)); + } + + /** + * 淇敼娴佸獟浣撶鐞� + */ + @PreAuthorize("@ss.hasPermi('vtdu:media:edit')") + @Log(title = "娴佸獟浣撶鐞�", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Vtdu vtdu) { + return toAjax(vtduService.updateVtdu(vtdu)); + } + + /** + * 鍒犻櫎娴佸獟浣撶鐞� + */ + @PreAuthorize("@ss.hasPermi('vtdu:media:remove')") + @Log(title = "娴佸獟浣撶鐞�", businessType = BusinessType.DELETE) + @DeleteMapping("/{names}") + public AjaxResult remove(@PathVariable String[] names) { + return toAjax(vtduService.deleteVtduByNames(names)); + } +} -- Gitblit v1.9.3