From bf1dcb8558130a552724ffb49cf03c84107c9e56 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 1 Feb 2024 20:14:47 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E8=AE=BE=E5=A4=87=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/equipment/dto/EmVideoBandingSaveDTO.java | 37 +++++++++++++++ .../com/hnac/hzims/equipment/dto/VideoDTO.java | 39 ++++++++++++++++ .../equipment/entity/EmVideoBandingEntity.java | 44 ++++++++++++++++++ .../controller/EmVideoBandingController.java | 53 ++++++++++++++++++++++ .../equipment/mapper/EmVideoBandingMapper.java | 8 ++++ .../equipment/service/IEmVideoBandingService.java | 27 +++++++++++ .../service/impl/EmVideoBandingServiceImpl.java | 52 +++++++++++++++++++++ .../equipment/src/main/resources/db/1.0.1.sql | 22 +++++++++ 8 files changed, 282 insertions(+) create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/dto/EmVideoBandingSaveDTO.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/dto/VideoDTO.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmVideoBandingEntity.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmVideoBandingController.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmVideoBandingMapper.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmVideoBandingService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmVideoBandingServiceImpl.java diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/dto/EmVideoBandingSaveDTO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/dto/EmVideoBandingSaveDTO.java new file mode 100644 index 0000000..b4a98fb --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/dto/EmVideoBandingSaveDTO.java @@ -0,0 +1,37 @@ +package com.hnac.hzims.equipment.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.validator.constraints.Length; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.util.List; + +@EqualsAndHashCode +@Data +@ApiModel(value = "设备-视频点位绑定关系保存对象",description = "设备-视频点位绑定关系保存对象") +public class EmVideoBandingSaveDTO implements Serializable { + + @ApiModelProperty("设备编号") + @NotBlank + @Length(min = 1,max = 50) + private String emCode; + + @ApiModelProperty("设备名称") + @Length(min = 1,max = 80) + @NotBlank + private String emName; + + @Valid + @ApiModelProperty("视频点位列表") + @NotEmpty + @Size(min = 1) + private List videoList; + +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/dto/VideoDTO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/dto/VideoDTO.java new file mode 100644 index 0000000..6f27ae4 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/dto/VideoDTO.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.equipment.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; + +@ApiModel(value = "海康视频点位DTO对象",description = "海康视频点位DTO对象") +@Data +@EqualsAndHashCode +public class VideoDTO implements Serializable { + + @ApiModelProperty("视频设备编码") + @NotBlank + @Length(min = 1,max = 100) + private String pointCode; + + @ApiModelProperty("视频名称") + @NotBlank + private String videoName; + + @ApiModelProperty("视频服务器host") + @NotBlank + private String videoHost; + + @ApiModelProperty("运管中心appSecret") + @NotBlank + private String videoAppSecret; + + @ApiModelProperty("运管中心appKey") + @NotBlank + private String videoAppKey; + +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmVideoBandingEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmVideoBandingEntity.java new file mode 100644 index 0000000..60eb027 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmVideoBandingEntity.java @@ -0,0 +1,44 @@ +package com.hnac.hzims.equipment.entity; + + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + +@ApiModel("设备视频绑定关系实体类") +@Data +@EqualsAndHashCode +@TableName("hzims_em_video_banding") +public class EmVideoBandingEntity extends TenantEntity implements Serializable { + + @ApiModelProperty("设备编号") + @QueryField(condition = SqlCondition.EQUAL) + private String emCode; + + @ApiModelProperty("设备名称") + private String emName; + + @ApiModelProperty("视频设备编码") + private String pointCode; + + @ApiModelProperty("视频名称") + @QueryField(condition = SqlCondition.LIKE) + private String videoName; + + @ApiModelProperty("视频服务器host") + private String videoHost; + + @ApiModelProperty("运管中心appSecret") + private String videoAppSecret; + + @ApiModelProperty("运管中心appKey") + private String videoAppKey; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmVideoBandingController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmVideoBandingController.java new file mode 100644 index 0000000..335b2d0 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmVideoBandingController.java @@ -0,0 +1,53 @@ +package com.hnac.hzims.equipment.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.equipment.dto.EmVideoBandingSaveDTO; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; +import com.hnac.hzims.equipment.service.IEmVideoBandingService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.util.List; + +@RestController +@RequestMapping("/em/video") +@Api(value = "设备视频绑定关系管理",tags = "设备视频绑定关系管理") +@AllArgsConstructor +@Validated +public class EmVideoBandingController extends BladeController { + private final IEmVideoBandingService emVideoBandingService; + + @GetMapping("/getListByEmCode") + @ApiOperation("根据设备编号获取绑定的视频点位列表") + @ApiOperationSupport(order = 1) + public R> getListByEmCode(@RequestParam @ApiParam(value = "设备编号",required = true) @NotBlank String emCode) { + LambdaQueryWrapper wq = Wrappers.lambdaQuery().eq(EmVideoBandingEntity::getEmCode, emCode); + return R.data(emVideoBandingService.list(wq)); + } + + @PostMapping("/banding") + @ApiOperation("设备绑定视频点位") + @ApiOperationSupport(order = 2) + public R banding(@Valid @RequestBody EmVideoBandingSaveDTO req) { + return R.status(emVideoBandingService.banding(req)); + } + + @DeleteMapping("/removeByEmCode") + @ApiOperation("删除设备编号下的绑定视频设备") + @ApiOperationSupport(order = 3) + public R removeByEmCode(@RequestParam @ApiParam(value = "设备编号",required = true) @NotBlank String emCode) { + return R.status(emVideoBandingService.removeByEmCode(emCode)); + } + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmVideoBandingMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmVideoBandingMapper.java new file mode 100644 index 0000000..a7616db --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmVideoBandingMapper.java @@ -0,0 +1,8 @@ +package com.hnac.hzims.equipment.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; + +public interface EmVideoBandingMapper extends BaseMapper { + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmVideoBandingService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmVideoBandingService.java new file mode 100644 index 0000000..3522ab7 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmVideoBandingService.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.equipment.service; + +import com.hnac.hzims.equipment.dto.EmVideoBandingSaveDTO; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; +import io.swagger.annotations.ApiParam; +import org.springblade.core.mp.base.BaseService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +public interface IEmVideoBandingService extends BaseService { + + /** + * 设备绑定视频点位 + * @param req 绑定请求数据 + * @return 绑定结果 + */ + Boolean banding(EmVideoBandingSaveDTO req); + + /** + * 删除设备编号下的绑定视频设备 + * @param emCode 设备编号 + * @return 删除结果 + */ + Boolean removeByEmCode(String emCode); + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmVideoBandingServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmVideoBandingServiceImpl.java new file mode 100644 index 0000000..bdc92f5 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmVideoBandingServiceImpl.java @@ -0,0 +1,52 @@ +package com.hnac.hzims.equipment.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.dto.EmVideoBandingSaveDTO; +import com.hnac.hzims.equipment.dto.VideoDTO; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; +import com.hnac.hzims.equipment.mapper.EmVideoBandingMapper; +import com.hnac.hzims.equipment.service.IEmVideoBandingService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.tool.utils.BeanUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +@AllArgsConstructor +@Slf4j +public class EmVideoBandingServiceImpl extends BaseServiceImpl implements IEmVideoBandingService { + + @Override + @Transactional + public Boolean banding(EmVideoBandingSaveDTO req) { + List videoList = req.getVideoList(); + // 删除掉所有点位 + LambdaQueryWrapper removeQuery = Wrappers.lambdaQuery() + .eq(EmVideoBandingEntity::getEmCode, req.getEmCode()); + this.remove(removeQuery); + List saveBandingList = videoList.stream().map(video -> { + EmVideoBandingEntity banding = BeanUtil.copy(video, EmVideoBandingEntity.class); + banding.setEmCode(req.getEmCode()); + banding.setEmName(req.getEmName()); + return banding; + }).collect(Collectors.toList()); + return this.saveBatch(saveBandingList); + } + + @Override + public Boolean removeByEmCode(String emCode) { + Map params = new HashMap() {{ + put("emCode", emCode); + }}; + QueryWrapper queryWrapper = Condition.getQueryWrapper(params, EmVideoBandingEntity.class); + return this.remove(queryWrapper); + } +} diff --git a/hzims-service/equipment/src/main/resources/db/1.0.1.sql b/hzims-service/equipment/src/main/resources/db/1.0.1.sql index 1f41725..e6d4742 100644 --- a/hzims-service/equipment/src/main/resources/db/1.0.1.sql +++ b/hzims-service/equipment/src/main/resources/db/1.0.1.sql @@ -48,3 +48,25 @@ CREATE TABLE `hzims_param_backups_detail` ( alter table `HZIMS_PARAM_BACKUPS_DETAIL` add COLUMN `KEEP_FIGURES` INT(11) COMMENT '小数点位数'; alter table `HZIMS_PARAM_BACKUPS_DETAIL` add COLUMN `DESCS` VARCHAR(255) COMMENT '描述'; +-- 设备视频绑定关系表 +CREATE TABLE `hzims_em_video_banding` ( + `ID` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `EM_CODE` varchar(50) NOT NULL COMMENT '设备编号', + `EM_NAME` varchar(80) NOT NULL COMMENT '设备名称', + `POINT_CODE` varchar(100) NOT NULL COMMENT '视频设备编码', + `VIDEO_NAME` varchar(255) NOT NULL COMMENT '视频名称', + `VIDEO_HOST` varchar(100) NOT NULL COMMENT '视频服务器host', + `VIDEO_APP_SECRET` varchar(100) NOT NULL COMMENT '运管中心appSecret', + `VIDEO_APP_KEY` varchar(100) NOT NULL COMMENT '运管中心appKey', + `TENANT_ID` varchar(12) NOT NULL COMMENT '租户ID', + `CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建单位', + `CREATE_USER` bigint(20) NOT NULL COMMENT '创建人', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '修改人', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '修改时间', + `STATUS` tinyint(4) DEFAULT NULL COMMENT '业务状态', + `IS_DELETED` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除 0-正常 1-删除', + `DURATION` mediumint(9) DEFAULT NULL COMMENT '多长时间内的推送', + `TIME_UNIT` varchar(50) DEFAULT NULL COMMENT '时间单位', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1533708371949543427 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;