using SafeCampus.Application.Services.Business.CameraGroupService;
using SafeCampus.Application.Services.Business.PersonInfoService;
using SafeCampus.Application.Services.Business.Warn.Dto;
using SafeCampus.Application.Services.Business.Warn.Service;
using SafeCampus.Core.Extension;
using MoYu.FriendlyException;
using SafeCampus.Application.Services.Business.AttendanceService;
using SafeCampus.Application.Services.Business.BuildingService;
using SafeCampus.Application.Services.Business.ClassRoomCallService;
using SafeCampus.Application.Services.Business.ClassRoomCallTaskService;
using SafeCampus.Application.Services.Business.DormitoryService;
using SafeCampus.Web.Core.Controllers.Application.Business;
using MoYu.RemoteRequest.Extensions;
using Newtonsoft.Json.Linq;
using SafeCampus.Application.Manager.DeepelephManager;
using SafeCampus.Application.Services.Business.DepartmentService;
using SafeCampus.Application.Services.Business.MajorService;
using SafeCampus.Application.Services.Business.PersonSetInfoService;
namespace SafeCampus.Web.Core.Controllers.Application.LargeScreen;
///
/// 大屏控制器
///
[ApiDescriptionSettings(ApiGroupConsts.SYSTEM_Business, Tag = "大屏接口", Order = 84)]
[Route("large/screen")]
[AllowAnonymous]
public class LargeScreenController
{
private readonly IPersonInfoService _personInfoService;
private readonly ICameraGroupService _cameraGroupService;
private readonly IWarnInfoService _warnInfoService;
private readonly ISimpleCacheService _simpleCacheService;
private readonly IAttendanceService _attendanceService;
private readonly IBuildingService _buildingService;
private readonly IDormitoryService _dormitoryService;
private readonly IConfigService _configService;
private readonly IClassRoomCallTaskService _classRoomCallTaskService;
private readonly IClassRoomCallService _classRoomCallService;
private readonly IDeepelephManager _deepelephManager;
private readonly IPersonSetInfoService _personSetInfoService;
private readonly IMajorService _majorService;
private readonly IDepartmentService _departmentService;
public LargeScreenController(IPersonInfoService personInfoService, ICameraGroupService cameraGroupService, IWarnInfoService warnInfoService, ISimpleCacheService simpleCacheService, IAttendanceService attendanceService, IBuildingService buildingService, IDormitoryService dormitoryService, IConfigService configService, IClassRoomCallTaskService classRoomCallTaskService, IClassRoomCallService classRoomCallService, IDeepelephManager deepelephManager, IPersonSetInfoService personSetInfoService, IMajorService majorService, IDepartmentService departmentService)
{
_personInfoService = personInfoService;
_cameraGroupService = cameraGroupService;
_warnInfoService = warnInfoService;
_simpleCacheService = simpleCacheService;
_attendanceService = attendanceService;
_buildingService = buildingService;
_dormitoryService = dormitoryService;
_configService = configService;
_classRoomCallTaskService = classRoomCallTaskService;
_classRoomCallService = classRoomCallService;
_deepelephManager = deepelephManager;
_personSetInfoService = personSetInfoService;
_majorService = majorService;
_departmentService = departmentService;
}
///
/// 获取大屏首页数据
///
///
public async Task GetHomeData()
{
var startTime = DateTime.Now.Date;
var entTime = DateTime.Now;
//学生人数
//总人数
var ZRS = await _personInfoService.GetCount(null);
//男生
var nan = await _personInfoService.GetCount("GENDER_MALE");
//女生
var nv = await _personInfoService.GetCount("GENDER_FEMALE");
//按设备分组统计设备数量
var SheBei = await _cameraGroupService.GetBIList();
//今日告警列表
var warnlist = await _warnInfoService.GetListNoPage(new WarnInfoSearch
{
StartTick = startTime,
EndTick = entTime
});
//今日告警统计按告警类型
var warnType = typeof(AlarmType).EnumToEnumModel();
var alarmStatistics = warnType.Select(x => new
{
Name = x.Description,
//Code = x.Name,
Value = warnlist.Count(xx => xx.AlarmType == x.Name)
}).Where(x => x.Value > 0).ToList();
//按场景统计告警类型
var warnGroup= _simpleCacheService.Get>(SafeCampusConst.WarnGroup);
foreach (var item in warnGroup)
{
foreach (var warnGroupSubset in item.Subset)
{
warnGroupSubset.Value = warnlist.Count(x => x.AlarmType == warnGroupSubset.Code);
}
item.Value = item.Subset.Sum(x => x.Value);
}
var list = new List