securityService.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package service
  2. import (
  3. "iot_manager_service/app/device/service"
  4. "iot_manager_service/app/security/model"
  5. "iot_manager_service/util/cache"
  6. "iot_manager_service/util/common"
  7. )
  8. var SecurityService = new(securityService)
  9. type securityService struct{}
  10. func (s *securityService) GetCameraLiveList(tenantId int) ([]model.CameraLiveDetail, *common.Errors) {
  11. groups, err := service.LampPoleGroupService.GetList(tenantId)
  12. if err != nil {
  13. return nil, nil
  14. }
  15. var rsp []model.CameraLiveDetail
  16. for _, group := range groups {
  17. cameraDevices := service.CameraService.GetByLampPoleGroup(group.ID)
  18. var cameraList []model.CameraLive
  19. for _, cameraDevice := range cameraDevices {
  20. _, state := cache.GetDeviceState(cameraDevice.DeviceSN)
  21. poleGroupName := cameraDevice.DeviceName + "(离线)"
  22. if state == "1" {
  23. poleGroupName = cameraDevice.DeviceName + "在线"
  24. }
  25. cameraList = append(cameraList, model.CameraLive{
  26. Id: cameraDevice.ID,
  27. DeviceName: cameraDevice.DeviceName,
  28. DeviceSn: cameraDevice.DeviceSN,
  29. PoleGroupName: poleGroupName,
  30. MonitorAddress: cameraDevice.MonitorAddress,
  31. StreamId: cameraDevice.StreamId,
  32. RunState: state,
  33. CameraType: cameraDevice.CameraType,
  34. LampPoleLocation: cameraDevice.LampPoleLocation,
  35. })
  36. }
  37. rsp = append(rsp, model.CameraLiveDetail{
  38. PoleGroupName: group.PoleGroupName,
  39. CameraList: cameraList,
  40. })
  41. }
  42. return rsp, nil
  43. }