摄像头
This commit is contained in:
parent
56ebd3a2df
commit
11a0bee83b
@ -10,4 +10,6 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
*/
|
||||
public interface ErrorCodeConstants {
|
||||
ErrorCode FACTORY_INFO_NOT_EXISTS = new ErrorCode(1_000_000_001, "工厂信息不存在");
|
||||
|
||||
ErrorCode CAMERA_DEVICE_NOT_EXISTS = new ErrorCode(1_000_000_002, "监控摄像头不存在");
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.device.controller.admin.cameradevice;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.device.controller.admin.cameradevice.vo.*;
|
||||
import cn.iocoder.yudao.module.device.dal.dataobject.cameradevice.CameraDeviceDO;
|
||||
import cn.iocoder.yudao.module.device.service.cameradevice.CameraDeviceService;
|
||||
|
||||
@Tag(name = "管理后台 - 设备-监控摄像头")
|
||||
@RestController
|
||||
@RequestMapping("/device/camera-device")
|
||||
@Validated
|
||||
public class CameraDeviceController {
|
||||
|
||||
@Resource
|
||||
private CameraDeviceService cameraDeviceService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建设备-监控摄像头")
|
||||
@PreAuthorize("@ss.hasPermission('device:camera-device:create')")
|
||||
public CommonResult<Long> createCameraDevice(@Valid @RequestBody CameraDeviceSaveReqVO createReqVO) {
|
||||
return success(cameraDeviceService.createCameraDevice(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新设备-监控摄像头")
|
||||
@PreAuthorize("@ss.hasPermission('device:camera-device:update')")
|
||||
public CommonResult<Boolean> updateCameraDevice(@Valid @RequestBody CameraDeviceSaveReqVO updateReqVO) {
|
||||
cameraDeviceService.updateCameraDevice(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除设备-监控摄像头")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('device:camera-device:delete')")
|
||||
public CommonResult<Boolean> deleteCameraDevice(@RequestParam("id") Long id) {
|
||||
cameraDeviceService.deleteCameraDevice(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得设备-监控摄像头")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('device:camera-device:query')")
|
||||
public CommonResult<CameraDeviceRespVO> getCameraDevice(@RequestParam("id") Long id) {
|
||||
CameraDeviceDO cameraDevice = cameraDeviceService.getCameraDevice(id);
|
||||
return success(BeanUtils.toBean(cameraDevice, CameraDeviceRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得设备-监控摄像头分页")
|
||||
@PreAuthorize("@ss.hasPermission('device:camera-device:query')")
|
||||
public CommonResult<PageResult<CameraDeviceRespVO>> getCameraDevicePage(@Valid CameraDevicePageReqVO pageReqVO) {
|
||||
PageResult<CameraDeviceDO> pageResult = cameraDeviceService.getCameraDevicePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, CameraDeviceRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出设备-监控摄像头 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('device:camera-device:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportCameraDeviceExcel(@Valid CameraDevicePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<CameraDeviceDO> list = cameraDeviceService.getCameraDevicePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "设备-监控摄像头.xls", "数据", CameraDeviceRespVO.class,
|
||||
BeanUtils.toBean(list, CameraDeviceRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cn.iocoder.yudao.module.device.controller.admin.cameradevice.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 设备-监控摄像头分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CameraDevicePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "工厂id", example = "32023")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "设备名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "设备编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "类型(1 枪机 2半球 3球机 4云台枪机)", example = "2")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", example = "1")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "实时抓图地址", example = "https://www.iocoder.cn")
|
||||
private String iconUrl;
|
||||
|
||||
@Schema(description = "录像机地址", example = "https://www.iocoder.cn")
|
||||
private String videoUrl;
|
||||
|
||||
@Schema(description = "流媒体地址", example = "https://www.iocoder.cn")
|
||||
private String streamUrl;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "是否在大屏显示 0否 1是")
|
||||
private Integer isShow;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.device.controller.admin.cameradevice.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 设备-监控摄像头 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CameraDeviceRespVO {
|
||||
|
||||
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20473")
|
||||
@ExcelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工厂id", requiredMode = Schema.RequiredMode.REQUIRED, example = "32023")
|
||||
@ExcelProperty("工厂id")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@ExcelProperty("设备名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("设备编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "类型(1 枪机 2半球 3球机 4云台枪机)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("类型(1 枪机 2半球 3球机 4云台枪机)")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("状态(0正常 1停用)")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "实时抓图地址", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("实时抓图地址")
|
||||
private String iconUrl;
|
||||
|
||||
@Schema(description = "录像机地址", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("录像机地址")
|
||||
private String videoUrl;
|
||||
|
||||
@Schema(description = "流媒体地址", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("流媒体地址")
|
||||
private String streamUrl;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "是否在大屏显示 0否 1是", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("是否在大屏显示 0否 1是")
|
||||
private Integer isShow;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.device.controller.admin.cameradevice.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.*;
|
||||
|
||||
@Schema(description = "管理后台 - 设备-监控摄像头新增/修改 Request VO")
|
||||
@Data
|
||||
public class CameraDeviceSaveReqVO {
|
||||
|
||||
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20473")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工厂id", requiredMode = Schema.RequiredMode.REQUIRED, example = "32023")
|
||||
@NotNull(message = "工厂id不能为空")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@NotEmpty(message = "设备名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "设备编号不能为空")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "类型(1 枪机 2半球 3球机 4云台枪机)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotEmpty(message = "类型(1 枪机 2半球 3球机 4云台枪机)不能为空")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "状态(0正常 1停用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "状态(0正常 1停用)不能为空")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "实时抓图地址", example = "https://www.iocoder.cn")
|
||||
private String iconUrl;
|
||||
|
||||
@Schema(description = "录像机地址", example = "https://www.iocoder.cn")
|
||||
private String videoUrl;
|
||||
|
||||
@Schema(description = "流媒体地址", example = "https://www.iocoder.cn")
|
||||
private String streamUrl;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "是否在大屏显示 0否 1是", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否在大屏显示 0否 1是不能为空")
|
||||
private Integer isShow;
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.device.dal.dataobject.cameradevice;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 设备-监控摄像头 DO
|
||||
*
|
||||
* @author 艾楷
|
||||
*/
|
||||
@TableName("sf_camera_device")
|
||||
@KeySequence("sf_camera_device_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CameraDeviceDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 工厂id
|
||||
*/
|
||||
private Long factoryId;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 设备编号
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 类型(1 枪机 2半球 3球机 4云台枪机)
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 实时抓图地址
|
||||
*/
|
||||
private String iconUrl;
|
||||
/**
|
||||
* 录像机地址
|
||||
*/
|
||||
private String videoUrl;
|
||||
/**
|
||||
* 流媒体地址
|
||||
*/
|
||||
private String streamUrl;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 是否在大屏显示 0否 1是
|
||||
*/
|
||||
private Integer isShow;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.device.dal.mysql.cameradevice;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.device.dal.dataobject.cameradevice.CameraDeviceDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.device.controller.admin.cameradevice.vo.*;
|
||||
|
||||
/**
|
||||
* 设备-监控摄像头 Mapper
|
||||
*
|
||||
* @author 艾楷
|
||||
*/
|
||||
@Mapper
|
||||
public interface CameraDeviceMapper extends BaseMapperX<CameraDeviceDO> {
|
||||
|
||||
default PageResult<CameraDeviceDO> selectPage(CameraDevicePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CameraDeviceDO>()
|
||||
.eqIfPresent(CameraDeviceDO::getFactoryId, reqVO.getFactoryId())
|
||||
.likeIfPresent(CameraDeviceDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CameraDeviceDO::getCode, reqVO.getCode())
|
||||
.eqIfPresent(CameraDeviceDO::getType, reqVO.getType())
|
||||
.eqIfPresent(CameraDeviceDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(CameraDeviceDO::getIconUrl, reqVO.getIconUrl())
|
||||
.eqIfPresent(CameraDeviceDO::getVideoUrl, reqVO.getVideoUrl())
|
||||
.eqIfPresent(CameraDeviceDO::getStreamUrl, reqVO.getStreamUrl())
|
||||
.eqIfPresent(CameraDeviceDO::getSort, reqVO.getSort())
|
||||
.eqIfPresent(CameraDeviceDO::getIsShow, reqVO.getIsShow())
|
||||
.betweenIfPresent(CameraDeviceDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(CameraDeviceDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.device.service.cameradevice;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.device.controller.admin.cameradevice.vo.*;
|
||||
import cn.iocoder.yudao.module.device.dal.dataobject.cameradevice.CameraDeviceDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 设备-监控摄像头 Service 接口
|
||||
*
|
||||
* @author 艾楷
|
||||
*/
|
||||
public interface CameraDeviceService {
|
||||
|
||||
/**
|
||||
* 创建设备-监控摄像头
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createCameraDevice(@Valid CameraDeviceSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新设备-监控摄像头
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateCameraDevice(@Valid CameraDeviceSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除设备-监控摄像头
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteCameraDevice(Long id);
|
||||
|
||||
/**
|
||||
* 获得设备-监控摄像头
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 设备-监控摄像头
|
||||
*/
|
||||
CameraDeviceDO getCameraDevice(Long id);
|
||||
|
||||
/**
|
||||
* 获得设备-监控摄像头分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 设备-监控摄像头分页
|
||||
*/
|
||||
PageResult<CameraDeviceDO> getCameraDevicePage(CameraDevicePageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.device.service.cameradevice;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.device.controller.admin.cameradevice.vo.CameraDevicePageReqVO;
|
||||
import cn.iocoder.yudao.module.device.controller.admin.cameradevice.vo.CameraDeviceSaveReqVO;
|
||||
import cn.iocoder.yudao.module.device.dal.dataobject.cameradevice.CameraDeviceDO;
|
||||
import cn.iocoder.yudao.module.device.dal.mysql.cameradevice.CameraDeviceMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.CAMERA_DEVICE_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 设备-监控摄像头 Service 实现类
|
||||
*
|
||||
* @author 艾楷
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CameraDeviceServiceImpl implements CameraDeviceService {
|
||||
|
||||
@Resource
|
||||
private CameraDeviceMapper cameraDeviceMapper;
|
||||
|
||||
@Override
|
||||
public Long createCameraDevice(CameraDeviceSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
CameraDeviceDO cameraDevice = BeanUtils.toBean(createReqVO, CameraDeviceDO.class);
|
||||
cameraDeviceMapper.insert(cameraDevice);
|
||||
// 返回
|
||||
return cameraDevice.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCameraDevice(CameraDeviceSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateCameraDeviceExists(updateReqVO.getId());
|
||||
// 更新
|
||||
CameraDeviceDO updateObj = BeanUtils.toBean(updateReqVO, CameraDeviceDO.class);
|
||||
cameraDeviceMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCameraDevice(Long id) {
|
||||
// 校验存在
|
||||
validateCameraDeviceExists(id);
|
||||
// 删除
|
||||
cameraDeviceMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateCameraDeviceExists(Long id) {
|
||||
if (cameraDeviceMapper.selectById(id) == null) {
|
||||
throw exception(CAMERA_DEVICE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CameraDeviceDO getCameraDevice(Long id) {
|
||||
return cameraDeviceMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CameraDeviceDO> getCameraDevicePage(CameraDevicePageReqVO pageReqVO) {
|
||||
return cameraDeviceMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.smartfactory.controller.admin.hik;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.hik.vo.CameraOperateDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.hik.vo.CameraReplayDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.hik.HikService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -39,11 +40,11 @@ public class HikController {
|
||||
return CommonResult.success(replayUrl);
|
||||
}
|
||||
|
||||
// @GetMapping("/operate")
|
||||
// @Operation(summary = "视频->云台操作")
|
||||
// public CommonResult<String> operate(CameraOperateDTO dto) {
|
||||
// //判断操作权限
|
||||
// Long cameraFactoryId = dto.getFactoryId();
|
||||
@GetMapping("/operate")
|
||||
@Operation(summary = "视频->云台操作")
|
||||
public CommonResult<String> operate(CameraOperateDTO dto) {
|
||||
//判断操作权限
|
||||
Long cameraFactoryId = dto.getFactoryId();
|
||||
// Long userFactoryId = SecurityUtils.getFactoryId();
|
||||
// if (cameraFactoryId == null || userFactoryId == null) {
|
||||
// throw new ServiceException("没有权限操控该摄像头,请联系管理员");
|
||||
@ -51,9 +52,9 @@ public class HikController {
|
||||
// if (SystemConfig.getFactoryCenterId() != userFactoryId && userFactoryId.longValue() != cameraFactoryId) {
|
||||
// throw new ServiceException("没有权限操控该摄像头,请联系管理员");
|
||||
// }
|
||||
// String msg = hikService.operateCamera(dto);
|
||||
// return CommonResult.success(msg);
|
||||
// }
|
||||
String msg = hikService.operateCamera(dto);
|
||||
return CommonResult.success(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public interface FactoryDataService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<FactoryDataDO> getTodayInboundAndOutboundOverview();
|
||||
List<FactoryDataDO> getTodayInboundAndOutboundOverview(Date time);
|
||||
|
||||
/**
|
||||
* 根据日期和工厂过滤
|
||||
|
@ -61,9 +61,13 @@ public class FactoryDataServiceImpl implements FactoryDataService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FactoryDataDO> getTodayInboundAndOutboundOverview() {
|
||||
public List<FactoryDataDO> getTodayInboundAndOutboundOverview(Date time) {
|
||||
String timeStr = null;
|
||||
if (time != null) {
|
||||
timeStr = DateUtils.dateFormat(time, "yyyy-MM-dd");
|
||||
}
|
||||
return dataMapper.selectList(new LambdaQueryWrapperX<FactoryDataDO>()
|
||||
.eq(FactoryDataDO::getDate, DateUtils.dateFormat(new Date(), "yyyy-MM-dd")));
|
||||
.eq(timeStr != null, FactoryDataDO::getDate, timeStr));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.service.hik;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.hik.vo.CameraOperateDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.hik.vo.CameraReplayDTO;
|
||||
|
||||
/**
|
||||
@ -26,4 +27,11 @@ public interface HikService {
|
||||
* @return
|
||||
*/
|
||||
JSONObject getReplayUrl(CameraReplayDTO cameraReplayDTO);
|
||||
|
||||
/**
|
||||
* 获取回放URL
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
String operateCamera(CameraOperateDTO dto);
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.service.hik;
|
||||
|
||||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.module.smartfactory.constant.ArtemisApiConstant;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.hik.vo.CameraOperateDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.hik.vo.CameraReplayDTO;
|
||||
import com.alibaba.cloud.commons.lang.StringUtils;
|
||||
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
||||
@ -36,7 +38,7 @@ public class HikServiceImpl implements HikService {
|
||||
};
|
||||
JSONObject body = new JSONObject();
|
||||
body.set("cameraIndexCode", cameraCode);
|
||||
body.set("streamType", streamType);
|
||||
body.set("streamType", 0);
|
||||
body.set("protocol", "ws");
|
||||
body.set("transmode", 1);
|
||||
body.set("expand", "streamform=ps");
|
||||
@ -85,4 +87,33 @@ public class HikServiceImpl implements HikService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String operateCamera(CameraOperateDTO dto) {
|
||||
final String operateUrlApi = ArtemisApiConstant.operateUrlApi;
|
||||
Map<String, String> path = new HashMap<String, String>(1) {
|
||||
{
|
||||
put("https://", operateUrlApi);
|
||||
}
|
||||
};
|
||||
// String speedStr = configService.selectConfigByKey(CONFIG_SPEED);
|
||||
String speedStr = "";
|
||||
|
||||
JSONObject body = new JSONObject();
|
||||
body.set("cameraIndexCode", dto.getCameraIndexCode());
|
||||
body.set("action", dto.getAction());
|
||||
body.set("command", dto.getCommand());
|
||||
body.set("speed", StringUtils.isNotBlank(speedStr) ? Integer.parseInt(speedStr) : 30);
|
||||
body.set("presetIndex", 50);
|
||||
try {
|
||||
String result = ArtemisHttpUtil.doPostStringArtemis(path, JSONUtil.toJsonStr(body), null, null, "application/json");
|
||||
log.info("云台操作:{},返回结果:{}", JSONUtil.toJsonStr(dto), result);
|
||||
JSONObject json = JSONUtil.parseObj(result);
|
||||
String msg = json.getStr("msg");
|
||||
return msg;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -199,7 +199,7 @@ public class ScreenDataServiceImpl implements ScreenDataService {
|
||||
vo.setTpNum(list.stream().mapToInt(FactoryDataOverviewDO::getTpNum).sum());
|
||||
vo.setBdNum(list.stream().mapToInt(FactoryDataOverviewDO::getBdNum).sum());
|
||||
|
||||
List<FactoryDataDO> factoryDataDOS = factoryDataService.getTodayInboundAndOutboundOverview();
|
||||
List<FactoryDataDO> factoryDataDOS = factoryDataService.getTodayInboundAndOutboundOverview(null);
|
||||
Integer outTotalNum = factoryDataDOS.stream().filter(a -> a.getDataType() == 1).mapToInt(FactoryDataDO::getTotalNum).sum();
|
||||
Integer inTotalNum = factoryDataDOS.stream().filter(a -> a.getDataType() == 2).mapToInt(FactoryDataDO::getTotalNum).sum();
|
||||
vo.setOutTotalNum(outTotalNum);
|
||||
@ -211,7 +211,7 @@ public class ScreenDataServiceImpl implements ScreenDataService {
|
||||
public List<InboundAndOutboundOverviewVO> getInboundAndOutboundOverview() {
|
||||
List<InboundAndOutboundOverviewVO> vos = new ArrayList<>();
|
||||
//获取当天的所有数据
|
||||
List<FactoryDataDO> list = factoryDataService.getTodayInboundAndOutboundOverview();
|
||||
List<FactoryDataDO> list = factoryDataService.getTodayInboundAndOutboundOverview(new Date());
|
||||
//根据工厂分组
|
||||
Map<Long, List<FactoryDataDO>> map = list.stream().collect(Collectors.groupingBy(FactoryDataDO::getFactoryId));
|
||||
List<FactoryInfoDO> factoryInfos = factoryInfoService.list();
|
||||
|
@ -40,7 +40,7 @@ spring:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
name: smart_factory
|
||||
name: ruoyi-vue-pro
|
||||
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
|
||||
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
|
||||
@ -129,4 +129,17 @@ yudao:
|
||||
error-code: # 错误码相关配置项
|
||||
enable: false
|
||||
constantsClassList: []
|
||||
demo: false # 关闭演示模式
|
||||
demo: false # 关闭演示模式
|
||||
#海康威视的相关配置
|
||||
isc:
|
||||
previewUrl: https://api.znkj.ispt.com.cn
|
||||
host: 111.75.51.123:10443
|
||||
appKey: 24991430
|
||||
appSecret: jQd4pIYZBzwW8cnuI9IN
|
||||
#视频资源
|
||||
resource:
|
||||
cameras: /artemis/api/resource/v1/cameras
|
||||
#视频能力
|
||||
video:
|
||||
previewUrls: /artemis/api/video/v2/cameras/previewURLs
|
||||
replayUrlApi: /artemis/api/video/v2/cameras/playbackURLs
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.device.dal.mysql.cameradevice.CameraDeviceMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user