ty
12 months ago
12 changed files with 298 additions and 6 deletions
@ -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<VideoDTO> videoList; |
||||
|
||||
} |
@ -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; |
||||
|
||||
} |
@ -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; |
||||
|
||||
} |
@ -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<List<EmVideoBandingEntity>> getListByEmCode(@RequestParam @ApiParam(value = "设备编号",required = true) @NotBlank String emCode) { |
||||
LambdaQueryWrapper<EmVideoBandingEntity> wq = Wrappers.<EmVideoBandingEntity>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)); |
||||
} |
||||
|
||||
} |
@ -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<EmVideoBandingEntity> { |
||||
|
||||
} |
@ -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<EmVideoBandingEntity> { |
||||
|
||||
/** |
||||
* 设备绑定视频点位 |
||||
* @param req 绑定请求数据 |
||||
* @return 绑定结果 |
||||
*/ |
||||
Boolean banding(EmVideoBandingSaveDTO req); |
||||
|
||||
/** |
||||
* 删除设备编号下的绑定视频设备 |
||||
* @param emCode 设备编号 |
||||
* @return 删除结果 |
||||
*/ |
||||
Boolean removeByEmCode(String emCode); |
||||
|
||||
} |
@ -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<EmVideoBandingMapper, EmVideoBandingEntity> implements IEmVideoBandingService { |
||||
|
||||
@Override |
||||
@Transactional |
||||
public Boolean banding(EmVideoBandingSaveDTO req) { |
||||
List<VideoDTO> videoList = req.getVideoList(); |
||||
// 删除掉所有点位
|
||||
LambdaQueryWrapper<EmVideoBandingEntity> removeQuery = Wrappers.<EmVideoBandingEntity>lambdaQuery() |
||||
.eq(EmVideoBandingEntity::getEmCode, req.getEmCode()); |
||||
this.remove(removeQuery); |
||||
List<EmVideoBandingEntity> 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<String, Object> params = new HashMap<String, Object>() {{ |
||||
put("emCode", emCode); |
||||
}}; |
||||
QueryWrapper<EmVideoBandingEntity> queryWrapper = Condition.getQueryWrapper(params, EmVideoBandingEntity.class); |
||||
return this.remove(queryWrapper); |
||||
} |
||||
} |
Loading…
Reference in new issue