securityService.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. })
  35. }
  36. rsp = append(rsp, model.CameraLiveDetail{
  37. PoleGroupName: group.PoleGroupName,
  38. CameraList: cameraList,
  39. })
  40. }
  41. return rsp, nil
  42. }