| | |
| | | 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 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; |
| | | |
| | | /** |
| | | * 流媒体管理Controller |
| | | * |
| | | * @author ard |
| | | * @date 2023-08-29 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/vtdu/media") |
| | | public class VtduController extends BaseController |
| | | { |
| | | @Autowired |
| | | private IVtduService vtduService; |
| | | @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); |
| | | } |
| | | |
| | | /** |
| | | * 导出流媒体管理列表 |
| | | */ |
| | | @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) |
| | | { |
| | | //region 自动转码 |
| | | String[] nameArray = name.split("_"); |
| | | String cameraId=nameArray[0]; |
| | | Integer chanNo=Integer.valueOf(nameArray[1]); |
| | | CameraCmd cmd=new CameraCmd(); |
| | | cmd.setCameraId(cameraId); |
| | | cmd.setChanNo(chanNo); |
| | | Map<String, Object> videoCompressionCfg = cameraSdkService.getVideoCompressionCfg(cmd); |
| | | String videoEncType = (String)videoCompressionCfg.get("videoEncType"); |
| | | Vtdu vtdu = vtduService.selectVtduByName(name); |
| | | if(!videoEncType.equals("标准h264")) |
| | | { |
| | | vtdu.setIsCode("1"); |
| | | } |
| | | else |
| | | { |
| | | vtdu.setIsCode("0"); |
| | | } |
| | | vtduService.deleteVtduByName(name); |
| | | vtduService.insertVtdu(vtdu); |
| | | //endregion |
| | | 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;
|
| | |
|
| | | /**
|
| | | * 流媒体管理Controller
|
| | | *
|
| | | * @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) {
|
| | | 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));
|
| | | }
|
| | | }
|