刘力
2 years ago
14 changed files with 370 additions and 40 deletions
-
51storeroom/src/main/java/com/storeroom/modules/device/controller/CameraController.java
-
28storeroom/src/main/java/com/storeroom/modules/device/controller/VideoMonitoringController.java
-
9storeroom/src/main/java/com/storeroom/modules/device/domain/DeviceCamerBind.java
-
67storeroom/src/main/java/com/storeroom/modules/device/domain/VideoMonitoring.java
-
17storeroom/src/main/java/com/storeroom/modules/device/repository/DeviceCamerBindRepository.java
-
8storeroom/src/main/java/com/storeroom/modules/device/repository/VideoMonitoringRepository.java
-
39storeroom/src/main/java/com/storeroom/modules/device/service/DeviceCamerBindService.java
-
19storeroom/src/main/java/com/storeroom/modules/device/service/VideoMonitoringService.java
-
20storeroom/src/main/java/com/storeroom/modules/device/service/dto/DeviceCamerBindCrieria.java
-
20storeroom/src/main/java/com/storeroom/modules/device/service/dto/VideoMonitoringCrieria.java
-
71storeroom/src/main/java/com/storeroom/modules/device/service/impl/DeviceCamerBindImpl.java
-
27storeroom/src/main/java/com/storeroom/modules/device/service/impl/VideoMonitoringImpl.java
-
12storeroom/src/main/java/com/storeroom/modules/storeroom3d/service/DeviceCamerBindService.java
-
22storeroom/src/main/java/com/storeroom/modules/storeroom3d/service/impl/DeviceCamerBindImpl.java
@ -0,0 +1,28 @@ |
|||
package com.storeroom.modules.device.controller; |
|||
|
|||
|
|||
import com.storeroom.annotaion.rest.AnonymousGetMapping; |
|||
import com.storeroom.modules.device.service.VideoMonitoringService; |
|||
import com.storeroom.modules.device.service.dto.VideoMonitoringCrieria; |
|||
import com.storeroom.utils.ApiResponse; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "视频监控") |
|||
@RequestMapping("/api/videomonitorng/") |
|||
public class VideoMonitoringController { |
|||
|
|||
private final VideoMonitoringService videoMonitoringService; |
|||
|
|||
@ApiOperation("视频监控列表") |
|||
@AnonymousGetMapping("list") |
|||
public ApiResponse<Object> getList(VideoMonitoringCrieria crieria, Pageable pageable) { |
|||
return ApiResponse.success(videoMonitoringService.queryAll(crieria, pageable)); |
|||
} |
|||
} |
@ -0,0 +1,67 @@ |
|||
package com.storeroom.modules.device.domain; |
|||
|
|||
|
|||
import com.storeroom.base.BaseEntity; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
import javax.persistence.Column; |
|||
import javax.persistence.Entity; |
|||
import javax.persistence.Id; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
import java.util.Objects; |
|||
|
|||
@Entity |
|||
@Getter |
|||
@Setter |
|||
public class VideoMonitoring extends BaseEntity implements Serializable { |
|||
|
|||
@Id |
|||
@Column(name = "id") |
|||
@NotNull(groups = BaseEntity.Update.class) |
|||
@ApiModelProperty(value = "ID", hidden = true) |
|||
private String id; |
|||
|
|||
@Column(name = "download_state") |
|||
@ApiModelProperty(value = "下载状态") |
|||
private Boolean downloadState; |
|||
|
|||
@Column(name = "storeroom_name") |
|||
@ApiModelProperty(value = "库房名称") |
|||
private String storeroomName; |
|||
|
|||
@Column(name = "device_name") |
|||
@ApiModelProperty(value = "设备名称") |
|||
private String deviceName; |
|||
|
|||
@Column(name = "camer_name") |
|||
@ApiModelProperty(value = "摄像头名称") |
|||
private String camerName; |
|||
|
|||
@Column(name = "alarm_event") |
|||
@ApiModelProperty(value = "报警事件") |
|||
private String alarmEvent; |
|||
|
|||
@Column(name = "video_url") |
|||
@ApiModelProperty(value = "下载视频地址") |
|||
private String videoUrl; |
|||
|
|||
@Column(name = "description") |
|||
@ApiModelProperty(value = "描述") |
|||
private String description; |
|||
|
|||
@Override |
|||
public boolean equals(Object o) { |
|||
if (this == o) return true; |
|||
if (o == null || getClass() != o.getClass()) return false; |
|||
VideoMonitoring that = (VideoMonitoring) o; |
|||
return Objects.equals(id, that.id) && Objects.equals(downloadState, that.downloadState) && Objects.equals(storeroomName, that.storeroomName) && Objects.equals(deviceName, that.deviceName) && Objects.equals(camerName, that.camerName); |
|||
} |
|||
|
|||
@Override |
|||
public int hashCode() { |
|||
return Objects.hash(id, downloadState, storeroomName, deviceName, camerName); |
|||
} |
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.storeroom.modules.device.repository; |
|||
|
|||
import com.storeroom.modules.device.domain.VideoMonitoring; |
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
|||
|
|||
public interface VideoMonitoringRepository extends JpaRepository<VideoMonitoring,String> , JpaSpecificationExecutor<VideoMonitoring> { |
|||
} |
@ -0,0 +1,39 @@ |
|||
package com.storeroom.modules.device.service; |
|||
|
|||
import com.storeroom.modules.device.domain.DeviceCamerBind; |
|||
import com.storeroom.modules.device.domain.DeviceInfo; |
|||
import com.storeroom.modules.device.service.dto.DeviceCamerBindCrieria; |
|||
import org.springframework.data.domain.Pageable; |
|||
|
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
public interface DeviceCamerBindService { |
|||
|
|||
|
|||
/** |
|||
* 设备摄像头绑定 |
|||
*/ |
|||
void bind(List<DeviceCamerBind> deviceCamerBind); |
|||
|
|||
|
|||
/** |
|||
* 查询摄像头绑定列表 |
|||
* |
|||
* @return / |
|||
*/ |
|||
Object queryAll(DeviceCamerBindCrieria crieria, Pageable pageable); |
|||
|
|||
/** |
|||
* 绑定设备下拉列表 |
|||
* @return |
|||
*/ |
|||
List<DeviceInfo> deviceBindList(); |
|||
|
|||
|
|||
/** |
|||
* 删除绑定 |
|||
* @param id |
|||
*/ |
|||
void deleteBind(Set<String> id); |
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.storeroom.modules.device.service; |
|||
|
|||
|
|||
import com.storeroom.modules.device.service.dto.VideoMonitoringCrieria; |
|||
import org.springframework.data.domain.Pageable; |
|||
|
|||
public interface VideoMonitoringService { |
|||
|
|||
|
|||
/** |
|||
* 获取视频监控列表 |
|||
* @param crieria |
|||
* @param pageable |
|||
* @return |
|||
*/ |
|||
Object queryAll(VideoMonitoringCrieria crieria, Pageable pageable); |
|||
|
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.storeroom.modules.device.service.dto; |
|||
|
|||
import com.storeroom.annotaion.Query; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.sql.Timestamp; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class DeviceCamerBindCrieria implements Serializable { |
|||
|
|||
|
|||
@Query(blurry = "storeroomName,timeSize,deviceName") |
|||
private String blurry; |
|||
|
|||
|
|||
@Query(type = Query.Type.BETWEEN) |
|||
private List<Timestamp> createTime; |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.storeroom.modules.device.service.dto; |
|||
|
|||
|
|||
import com.storeroom.annotaion.Query; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.sql.Timestamp; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class VideoMonitoringCrieria implements Serializable { |
|||
|
|||
@Query |
|||
private String alarmEvent; |
|||
|
|||
|
|||
@Query(type = Query.Type.BETWEEN) |
|||
private List<Timestamp> createTime; |
|||
} |
@ -0,0 +1,71 @@ |
|||
package com.storeroom.modules.device.service.impl; |
|||
|
|||
import com.storeroom.exception.BaseException; |
|||
import com.storeroom.modules.device.domain.DeviceCamerBind; |
|||
import com.storeroom.modules.device.domain.DeviceInfo; |
|||
import com.storeroom.modules.device.repository.DeviceCamerBindRepository; |
|||
import com.storeroom.modules.device.repository.DeviceInfoRepository; |
|||
import com.storeroom.modules.device.service.DeviceCamerBindService; |
|||
import com.storeroom.modules.device.service.dto.DeviceCamerBindCrieria; |
|||
import com.storeroom.utils.NanoIdUtils; |
|||
import com.storeroom.utils.PageUtil; |
|||
import com.storeroom.utils.QueryHelp; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.ObjectUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class DeviceCamerBindImpl implements DeviceCamerBindService { |
|||
|
|||
private final DeviceCamerBindRepository deviceCamerBindRepository; |
|||
private final DeviceInfoRepository deviceInfoRepository; |
|||
|
|||
|
|||
@Override |
|||
public void bind(List<DeviceCamerBind> deviceCamerBind) { |
|||
|
|||
for (DeviceCamerBind d : deviceCamerBind) { |
|||
Integer num = deviceCamerBindRepository.countByDeviceInfoId(d.getDeviceInfoId()); |
|||
if (num > 4) { |
|||
throw new BaseException("同一种设备不能绑定超过四个以上的摄像头"); |
|||
} |
|||
d.setId(NanoIdUtils.randomNanoId()); |
|||
} |
|||
deviceCamerBindRepository.saveAll(deviceCamerBind); |
|||
} |
|||
|
|||
@Override |
|||
public Object queryAll(DeviceCamerBindCrieria crieria, Pageable pageable) { |
|||
Page<DeviceCamerBind> page = deviceCamerBindRepository.findAll((root, query, criteriaBuilder) -> QueryHelp.getPredicate(root, crieria, criteriaBuilder), pageable); |
|||
return PageUtil.toPage(page); |
|||
} |
|||
|
|||
@Override |
|||
public List<DeviceInfo> deviceBindList() { |
|||
List<DeviceInfo> deviceInfoList = deviceInfoRepository.findByDeviceTypeId("65D1886B0F864291766421"); |
|||
List<DeviceInfo> deviceInfoList1 = deviceInfoRepository.findByDeviceTypeId("DD656054BE3D1DF1E2F1FC"); |
|||
List<DeviceInfo> deviceinfoAll = new ArrayList<>(); |
|||
deviceinfoAll.addAll(deviceInfoList); |
|||
deviceinfoAll.addAll(deviceInfoList1); |
|||
|
|||
for (DeviceInfo d : deviceinfoAll) { |
|||
DeviceCamerBind deviceCamerBind = deviceCamerBindRepository.findByDeviceInfoId(d.getDeviceTypeId().getId()); |
|||
if (ObjectUtils.isEmpty(deviceCamerBind)) { |
|||
deviceinfoAll.remove(d); |
|||
} |
|||
} |
|||
return deviceinfoAll; |
|||
} |
|||
|
|||
@Override |
|||
public void deleteBind(Set<String> id) { |
|||
deviceCamerBindRepository.deleteAllById(id); |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.storeroom.modules.device.service.impl; |
|||
|
|||
import com.storeroom.modules.device.domain.VideoMonitoring; |
|||
import com.storeroom.modules.device.repository.VideoMonitoringRepository; |
|||
import com.storeroom.modules.device.service.VideoMonitoringService; |
|||
import com.storeroom.modules.device.service.dto.VideoMonitoringCrieria; |
|||
import com.storeroom.utils.PageUtil; |
|||
import com.storeroom.utils.QueryHelp; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class VideoMonitoringImpl implements VideoMonitoringService { |
|||
|
|||
private final VideoMonitoringRepository videoMonitoringRepository; |
|||
|
|||
|
|||
@Override |
|||
public Object queryAll(VideoMonitoringCrieria crieria, Pageable pageable) { |
|||
Page<VideoMonitoring> page = videoMonitoringRepository.findAll((root, query, criteriaBuilder) -> QueryHelp.getPredicate(root, crieria, criteriaBuilder), pageable); |
|||
return PageUtil.toPage(page); |
|||
} |
|||
} |
@ -1,12 +0,0 @@ |
|||
package com.storeroom.modules.storeroom3d.service; |
|||
|
|||
import com.storeroom.modules.device.domain.DeviceCamerBind; |
|||
|
|||
public interface DeviceCamerBindService { |
|||
|
|||
|
|||
/** |
|||
* 设备摄像头绑定 |
|||
*/ |
|||
void bind(DeviceCamerBind deviceCamerBind); |
|||
} |
@ -1,22 +0,0 @@ |
|||
package com.storeroom.modules.storeroom3d.service.impl; |
|||
|
|||
import com.storeroom.modules.device.domain.DeviceCamerBind; |
|||
import com.storeroom.modules.device.repository.DeviceCamerBindRepository; |
|||
import com.storeroom.modules.storeroom3d.service.DeviceCamerBindService; |
|||
import com.storeroom.utils.NanoIdUtils; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class DeviceCamerBindImpl implements DeviceCamerBindService { |
|||
|
|||
private final DeviceCamerBindRepository deviceCamerBindRepository; |
|||
|
|||
|
|||
@Override |
|||
public void bind(DeviceCamerBind deviceCamerBind) { |
|||
deviceCamerBind.setId(NanoIdUtils.randomNanoId()); |
|||
deviceCamerBindRepository.save(deviceCamerBind); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue