ningshuxia
2022-11-22 4efe844d9bcc03435cbbeb1aedbda5bf6ebf5912
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using Microsoft.AspNetCore.Authorization;
 
namespace IStation.Application
{
    /// <summary>
    /// Camera
    /// </summary>
    [AllowAnonymous]
    [Route("Camera/Video")]
    [ApiDescriptionSettings("Product", Name = "视频监控", Order = 781)]
    public class Camera_Controller : IDynamicApiController
    {
 
        /// <summary>
        /// 通过 StationID 获取海康列表
        /// </summary>
        [Route("GetHikListByStationID@V1.0")]
        [HttpGet]
        public List<CameraHikLogicDto> GetHikListByStationID(long CorpID, long StationID)
        {
            var corpId = CorpID;
            var stationId = StationID;
            var cacheKey = $"Camera_GetHikListByStationID_{corpId}_{stationId}";
            var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
            {
                var cameralList = new Service.Product().GetCameraListByBelongTypeAndBelongID(corpId, ObjectType.Station, stationId);
                cameralList = cameralList?.Where(x => x.RatedParas.ProviderType == Model.Camera.eProviderType.Hik).ToList();
                if (cameralList == null || cameralList.Count < 1)
                    return default;
                var manufacturerList = new Service.Manufacturer().GetByCorpID(corpId);
                var vmCacheList = new List<CameraHikLogicDto>();
                foreach (var camera in cameralList)
                {
                    var manufacturer = manufacturerList.Find(x => x.ID == camera.ManufacturerID);
                    var vm = new CameraHikLogicDto(camera, manufacturer?.Name);
                    vmCacheList.Add(vm);
                }
                return vmCacheList;
            }, CacheHelper.CacheLevel3);
            return vm_list;
        }
 
 
    }
}