2024-11-26 13:45:28 +08:00
|
|
|
|
using Abp;
|
|
|
|
|
using Abp.Authorization;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
using Abp.Domain.Repositories;
|
|
|
|
|
using Abp.Domain.Uow;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using Amazon.Runtime.Internal.Transform;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using MySqlX.XDevAPI.Common;
|
|
|
|
|
using Newtonsoft.Json;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Linq.Dynamic.Core;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using System.Text.Json;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using ToolLibrary.LogHelper;
|
|
|
|
|
using YunDa.ISAS.Application.Core;
|
|
|
|
|
using YunDa.ISAS.Application.Core.Session;
|
|
|
|
|
using YunDa.ISAS.Application.Core.SwaggerHelper;
|
|
|
|
|
using YunDa.ISAS.DataTransferObject;
|
|
|
|
|
using YunDa.ISAS.DataTransferObject.Account;
|
|
|
|
|
using YunDa.ISAS.DataTransferObject.EquipmentLiveData;
|
|
|
|
|
using YunDa.ISAS.DataTransferObject.GeneralInformation.EquipmentInfoDto;
|
|
|
|
|
using YunDa.ISAS.DataTransferObject.GeneralInformation.EquipmentInfoDto.SearchCondition;
|
|
|
|
|
using YunDa.ISAS.Entities.ClientConfiguration.ThreeDimension;
|
|
|
|
|
using YunDa.ISAS.Entities.DataMonitoring;
|
|
|
|
|
using YunDa.ISAS.Entities.GeneralInformation;
|
|
|
|
|
using YunDa.ISAS.Entities.MySQL.DataMonitoring;
|
|
|
|
|
using YunDa.ISAS.Entities.VideoSurveillance;
|
|
|
|
|
using YunDa.ISAS.Redis.Repositories;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using YunDa.SOMS.DataTransferObject.EquipmentLiveData;
|
|
|
|
|
using YunDa.SOMS.DataTransferObject.ThirdPartyData.NJJW;
|
|
|
|
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
|
|
|
|
|
namespace YunDa.ISAS.Application.GeneralInformation
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Description("设备信息管理服务")]
|
|
|
|
|
public class EquipmentLiveDataAppService : ISASAppServiceBase, IEquipmentLiveDataAppService
|
|
|
|
|
{
|
|
|
|
|
private LoginUserOutput _currentUser;
|
|
|
|
|
private readonly IRepository<EquipmentInfo, Guid> _equipmentInfoRepository;
|
|
|
|
|
private readonly IRepository<VideoDev, Guid> _videoDevRepository;
|
|
|
|
|
private readonly IRepository<LinkageStrategy, Guid> _linkageStrategyRepository;
|
|
|
|
|
private readonly IRepository<MeasureTemperaturePoint, Guid> _measureTemperaturePointRepository;
|
|
|
|
|
|
|
|
|
|
private readonly IRepository<EquipmentType, Guid> _equipmentTypeRepository;
|
|
|
|
|
private readonly IRepository<PresetPoint, Guid> _presetPointRepository;
|
|
|
|
|
private readonly IRepository<TelemeteringConfiguration, Guid> _telemeteringConfigurationResitory;
|
|
|
|
|
private readonly IRepository<TelesignalisationConfiguration, Guid> _telesignalisationConfigurationResitory;
|
|
|
|
|
private readonly IRepository<TelecommandConfiguration, Guid> _telecommandConfigurationResitory;
|
|
|
|
|
private readonly IRepository<TelemeteringAlarmStrategy, Guid> _telemeteringAlarmStrategyResitory;
|
|
|
|
|
private readonly IRepository<TelemeteringTemplate, Guid> _telemeteringTemplateResitory;
|
|
|
|
|
private readonly IRedisRepository<object, string> _redisRepository;
|
|
|
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|
|
|
|
private readonly IRedisRepository<EquipmentDataModel, string> _equipmentDataModelDicRedis;
|
|
|
|
|
private readonly IRepository<CCThreeDimension, Guid> _threeDimensionResitory;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
private readonly string _telemeteringModelListRediskey = "telemeteringModelList";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 遥测数据实时库
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly IRedisRepository<TelemeteringModel, string> _telemeteringModelListRedis;
|
|
|
|
|
private readonly string _telesignalisationModelListRediskey = "telesignalisationModelList";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 遥信数据实时库
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly IRedisRepository<TelesignalisationModel, string> _telesignalisationModelListRedis;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
|
2024-11-26 13:45:28 +08:00
|
|
|
|
private readonly RedisRepository<EquipmentInfoDiagnoseResult, string> _equipmentInfoDiagnoseResult;
|
|
|
|
|
private readonly RedisRepository<EquipmentInfoSearchRecord, string> _equipmentInfoDetailRedis;
|
|
|
|
|
private readonly string _equipmentInfoDetailRedisChannel = "equipmentInfoDetailRedisChannel";
|
|
|
|
|
|
|
|
|
|
private readonly string _equipmentInfoDiagnoseResultChanel = "equipmentInfoDiagnoseResultChanel";
|
|
|
|
|
private readonly EquipmentInfoExAppService _equipmentInfoExAppService;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
public EquipmentLiveDataAppService(
|
|
|
|
|
IRepository<EquipmentInfo, Guid> repositoryEquipmentInfo
|
|
|
|
|
, IRepository<EquipmentType, Guid> repositoryEquipmentType
|
|
|
|
|
, IRepository<TelemeteringConfiguration, Guid> telemeteringConfigurationResitory
|
|
|
|
|
, IRepository<TelesignalisationConfiguration, Guid> telesignalisationConfigurationResitory
|
|
|
|
|
, IRepository<TelecommandConfiguration, Guid> telecommandConfigurationResitory
|
|
|
|
|
, IRepository<PresetPoint, Guid> presetPointRepository
|
|
|
|
|
, IRepository<TelemeteringAlarmStrategy, Guid> telemeteringAlarmStrategyResitory
|
|
|
|
|
, IRepository<TelemeteringTemplate, Guid> telemeteringTemplateResitory
|
|
|
|
|
, IRepository<VideoDev, Guid> videoDevRepository
|
|
|
|
|
, IRepository<LinkageStrategy, Guid> linkageStrategyRepository
|
|
|
|
|
, IRepository<MeasureTemperaturePoint, Guid> measureTemperaturePointRepository
|
|
|
|
|
, IRedisRepository<object, string> redisRepository
|
|
|
|
|
, IRedisRepository<EquipmentDataModel, string> equipmentDataModelDicRedis
|
|
|
|
|
, IRepository<CCThreeDimension, Guid> threeDimensionResitory
|
|
|
|
|
, IUnitOfWorkManager unitOfWorkManager
|
2024-11-26 13:45:28 +08:00
|
|
|
|
, IRedisRepository<TelemeteringModel, string> telemeteringModelListRedis
|
|
|
|
|
, IRedisRepository<TelesignalisationModel, string> telesignalisationModelListRedis
|
|
|
|
|
, RedisRepository<EquipmentInfoDiagnoseResult, string> equipmentInfoDiagnoseResult
|
|
|
|
|
, RedisRepository<EquipmentInfoSearchRecord, string> equipmentInfoDetailRedis
|
|
|
|
|
, EquipmentInfoExAppService equipmentInfoExAppService
|
2024-07-15 10:31:26 +08:00
|
|
|
|
, ISessionAppService sessionAppService) : base(sessionAppService)
|
|
|
|
|
{
|
|
|
|
|
_equipmentInfoRepository = repositoryEquipmentInfo;
|
|
|
|
|
_equipmentTypeRepository = repositoryEquipmentType;
|
|
|
|
|
_telemeteringConfigurationResitory = telemeteringConfigurationResitory;
|
|
|
|
|
_telesignalisationConfigurationResitory = telesignalisationConfigurationResitory;
|
|
|
|
|
_telecommandConfigurationResitory = telecommandConfigurationResitory;
|
|
|
|
|
_telemeteringAlarmStrategyResitory = telemeteringAlarmStrategyResitory;
|
|
|
|
|
_presetPointRepository = presetPointRepository;
|
|
|
|
|
_telemeteringTemplateResitory = telemeteringTemplateResitory;
|
|
|
|
|
_currentUser = base.GetCurrentUser();
|
|
|
|
|
_unitOfWorkManager = unitOfWorkManager;
|
|
|
|
|
_redisRepository = redisRepository;
|
|
|
|
|
_equipmentDataModelDicRedis = equipmentDataModelDicRedis;
|
|
|
|
|
_threeDimensionResitory = threeDimensionResitory;
|
|
|
|
|
_videoDevRepository = videoDevRepository;
|
|
|
|
|
_linkageStrategyRepository = linkageStrategyRepository;
|
|
|
|
|
_measureTemperaturePointRepository = measureTemperaturePointRepository;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
_telemeteringModelListRedis = telemeteringModelListRedis;
|
|
|
|
|
_telesignalisationModelListRedis = telesignalisationModelListRedis;
|
|
|
|
|
_equipmentInfoDiagnoseResult = equipmentInfoDiagnoseResult;
|
|
|
|
|
_equipmentInfoDetailRedis = equipmentInfoDetailRedis;
|
|
|
|
|
_equipmentInfoExAppService = equipmentInfoExAppService;
|
2024-07-15 10:31:26 +08:00
|
|
|
|
}
|
|
|
|
|
#region 基础接口
|
|
|
|
|
public RequestPageResult<EquipmentInfoOutput> FindDatas(PageSearchCondition<EquipmentInfoSearchConditionInput> searchCondition)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<RequestResult<EquipmentInfoOutput>> CreateOrUpdateAsync(EditEquipmentInfoInput input)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<RequestEasyResult> DeleteByIdsAsync(List<Guid> ids)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<RequestEasyResult> DeleteByIdAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据设备id获取设备实时运行数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[ShowApi]
|
|
|
|
|
public async Task<RequestResult<EquipmentDataModel>> GetEquipmentLiveStateByEquipmentId(Guid id)
|
|
|
|
|
{
|
|
|
|
|
RequestResult<EquipmentDataModel> rst = new RequestResult<EquipmentDataModel>();
|
|
|
|
|
if (id == default)
|
|
|
|
|
{
|
|
|
|
|
rst.Message = "设备id为空";
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var dic = await _equipmentDataModelDicRedis.HashSetGetAllAsync(ConstantModel.EquipmentDataModelDicRedisKey);
|
|
|
|
|
if (dic.Any(t=>t.EquipmentInfoId == id))
|
|
|
|
|
{
|
|
|
|
|
var equipmentdata = dic.FirstOrDefault(t=> t.EquipmentInfoId == id);
|
|
|
|
|
var cfgs = _threeDimensionResitory.GetAll().Where(t => t.EquipmentInfoId == id);
|
|
|
|
|
equipmentdata.Telemeterings = equipmentdata.Telemeterings.Where(t => cfgs.Any(x => x.TelemeteringConfigurationId == t.Id)).ToList();
|
|
|
|
|
equipmentdata.Telesignalisations = equipmentdata.Telesignalisations.Where(t => cfgs.Any(x => x.TelesignalisationConfigurationId == t.Id)).ToList();
|
|
|
|
|
rst.Flag = true;
|
|
|
|
|
rst.ResultData = equipmentdata;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "根据设备id获取设备实时运行数据出错", ex);
|
|
|
|
|
}
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据模型id获取设备实时运行数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="modelId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[ShowApi]
|
|
|
|
|
public async Task<RequestResult<EquipmentDataModel>> GetEquipmentLiveStateByModelId(int modelId)
|
|
|
|
|
{
|
|
|
|
|
RequestResult<EquipmentDataModel> rst = new RequestResult<EquipmentDataModel>();
|
|
|
|
|
if (modelId == 0)
|
|
|
|
|
{
|
|
|
|
|
rst.Message = "模型id为0";
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var ccDatas = _threeDimensionResitory.GetAll().ToList();
|
|
|
|
|
var dic = await _equipmentDataModelDicRedis.HashSetGetAllAsync(ConstantModel.EquipmentDataModelDicRedisKey);
|
|
|
|
|
var cc = ccDatas.FirstOrDefault(t => t.ModelId == modelId);
|
|
|
|
|
if (dic!=null&&cc != null&& cc.EquipmentInfoId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
Guid id = cc.EquipmentInfoId.Value;
|
|
|
|
|
if (dic.Any(t => t.EquipmentInfoId == id))
|
|
|
|
|
{
|
|
|
|
|
var equipmentdata = dic.FirstOrDefault(t => t.EquipmentInfoId == id);
|
|
|
|
|
var cfgs = ccDatas.Where(t => t.EquipmentInfoId == id);
|
|
|
|
|
equipmentdata.Telemeterings = equipmentdata.Telemeterings.Where(t => cfgs.Any(x => x.TelemeteringConfigurationId == t.Id)).ToList();
|
|
|
|
|
equipmentdata.Telesignalisations = equipmentdata.Telesignalisations.Where(t => cfgs.Any(x => x.TelesignalisationConfigurationId == t.Id)).ToList();
|
|
|
|
|
rst.Flag = true;
|
|
|
|
|
rst.ResultData = equipmentdata;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "根据设备id获取设备实时运行数据出错", ex);
|
|
|
|
|
}
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备总览信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="stationId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[ShowApi]
|
|
|
|
|
public async Task<RequestResult<List<EquimentOverviewOutput>>> GetEquipmentOverviewAsync(Guid stationId)
|
|
|
|
|
{
|
|
|
|
|
RequestResult<List<EquimentOverviewOutput>> rst = new();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (stationId == default)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "传入id为空");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<EquimentOverviewOutput> datas = new List<EquimentOverviewOutput>();
|
|
|
|
|
var equipmentTypesRepo = _equipmentTypeRepository.GetAllIncluding(t=>t.EquipmentInfos).OrderBy(t=>t.SeqNo).ToList();
|
|
|
|
|
|
|
|
|
|
var typesRepo = equipmentTypesRepo.Where(x => x.EquipmentTypeLevel == EquipmentTypeLevelEnum.Type);
|
|
|
|
|
var equipmentTypeRepo = equipmentTypesRepo.Where(x => x.EquipmentTypeLevel == EquipmentTypeLevelEnum.Equipment);
|
|
|
|
|
var dic = await _equipmentDataModelDicRedis.HashSetGetAllAsync(ConstantModel.EquipmentDataModelDicRedisKey);
|
|
|
|
|
foreach (var item in typesRepo)
|
|
|
|
|
{
|
|
|
|
|
var equipments = equipmentTypeRepo.Where(t => t.EquipmentTypeId == item.Id).SelectMany(t => t.EquipmentInfos);
|
|
|
|
|
var query = from equip in equipments
|
|
|
|
|
join dataModel in dic on equip.Id equals dataModel.EquipmentInfoId
|
|
|
|
|
where dataModel.Telemeterings!=null
|
|
|
|
|
from telemetry in dataModel.Telemeterings
|
|
|
|
|
where telemetry.ResultValue != -99999
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
EquipmentId = equip.Id,
|
|
|
|
|
|
|
|
|
|
// Include other properties as needed
|
|
|
|
|
};
|
|
|
|
|
var query1 = from equip in equipments
|
|
|
|
|
join dataModel in dic on equip.Id equals dataModel.EquipmentInfoId
|
|
|
|
|
where dataModel.Telesignalisations != null
|
|
|
|
|
from telemetry in dataModel.Telesignalisations
|
|
|
|
|
where telemetry.ResultValue != -99999
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
EquipmentId = equip.Id,
|
|
|
|
|
|
|
|
|
|
// Include other properties as needed
|
|
|
|
|
};
|
|
|
|
|
int lineCount = query.Concat(query1).Distinct().Count();
|
|
|
|
|
datas.Add(new EquimentOverviewOutput
|
|
|
|
|
{
|
|
|
|
|
Id = item.Id,
|
|
|
|
|
SeqNo = datas.Count + 1,
|
|
|
|
|
Count = equipments.Count(),
|
|
|
|
|
LineCount = lineCount,
|
|
|
|
|
IsVisable = true,
|
|
|
|
|
TypeName = item.Name
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
var video = _videoDevRepository.GetAllIncluding(t=>t.PresetPoints).OrderBy(t=>t.SeqNo).ToList();
|
|
|
|
|
var nvr = video.Where(t => t.VideoDevId == null);
|
|
|
|
|
int nvrOnlineCount = 0;
|
|
|
|
|
//CameraOnlineInfo.GetDeviceConnected( nvr.Select(t=>t.IP).ToList()).Where(t=>t.Value).Count();
|
|
|
|
|
|
|
|
|
|
datas.Add(new EquimentOverviewOutput
|
|
|
|
|
{
|
|
|
|
|
Id = default,
|
|
|
|
|
SeqNo = datas.Count + 1,
|
|
|
|
|
Count = nvr.Count(),
|
|
|
|
|
LineCount = nvrOnlineCount,
|
|
|
|
|
IsVisable = true,
|
|
|
|
|
TypeName = "NVR",
|
|
|
|
|
Description = ""
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var camera = video.Where(t => t.VideoDevId != null);
|
|
|
|
|
int cameraOnlineCount = 0;//
|
|
|
|
|
//CameraOnlineInfo.GetDeviceConnected(camera.Where(x=> !string.IsNullOrWhiteSpace(x.IP)).Select(t => t.IP).ToList()).Where(t => t.Value).Count();
|
|
|
|
|
|
|
|
|
|
datas.Add(new EquimentOverviewOutput
|
|
|
|
|
{
|
|
|
|
|
Id = default,
|
|
|
|
|
SeqNo = datas.Count + 1,
|
|
|
|
|
Count = camera.Count(),
|
|
|
|
|
LineCount = cameraOnlineCount,
|
|
|
|
|
IsVisable = true,
|
|
|
|
|
TypeName = "摄像头",
|
|
|
|
|
Description = ""
|
|
|
|
|
});
|
|
|
|
|
var presetsCount = _presetPointRepository.Count();
|
|
|
|
|
datas.Add(new EquimentOverviewOutput
|
|
|
|
|
{
|
|
|
|
|
Id = default,
|
|
|
|
|
SeqNo = datas.Count + 1,
|
|
|
|
|
Count = presetsCount,
|
|
|
|
|
LineCount = -1,
|
|
|
|
|
IsVisable = true,
|
|
|
|
|
TypeName = "预置位"
|
|
|
|
|
});
|
|
|
|
|
var linkageCount = _linkageStrategyRepository.Count();
|
|
|
|
|
datas.Add(new EquimentOverviewOutput
|
|
|
|
|
{
|
|
|
|
|
Id = default,
|
|
|
|
|
SeqNo = datas.Count+1,
|
|
|
|
|
Count = linkageCount,
|
|
|
|
|
LineCount = -1,
|
|
|
|
|
IsVisable = true,
|
|
|
|
|
TypeName = "联动"
|
|
|
|
|
});
|
|
|
|
|
var measureTempCount = _measureTemperaturePointRepository.Count();
|
|
|
|
|
datas.Add(new EquimentOverviewOutput
|
|
|
|
|
{
|
|
|
|
|
Id = default,
|
|
|
|
|
SeqNo = datas.Count + 1,
|
|
|
|
|
Count = measureTempCount,
|
|
|
|
|
LineCount = -1,
|
|
|
|
|
IsVisable = true,
|
|
|
|
|
TypeName = "测温点"
|
|
|
|
|
});
|
|
|
|
|
rst.ResultData = datas;
|
|
|
|
|
rst.Flag = true;
|
|
|
|
|
//_equipmentInfoRepository.GetAllIncluding(t => t.EquipmentType);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "根据设备id获取设备实时运行数据出错", ex);
|
|
|
|
|
}
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
2024-11-26 13:45:28 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据设备id获取设备遥测实时数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[ShowApi]
|
|
|
|
|
public async Task<RequestResult<List<TelemeteringModel>>> GetEquipmentTelemeteringByEquipmentId(Guid equipmentId,int dataSourceCategory)
|
|
|
|
|
{
|
|
|
|
|
RequestResult<List<TelemeteringModel>> rst = new ();
|
|
|
|
|
if (equipmentId == default)
|
|
|
|
|
{
|
|
|
|
|
rst.Message = "设备id为空";
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var telemeterings = await _telemeteringModelListRedis.HashSetGetAllAsync(_telemeteringModelListRediskey + "_" + ((DataSourceCategoryEnum)dataSourceCategory).ToString());
|
|
|
|
|
|
|
|
|
|
if (telemeterings == null || telemeterings.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
rst.ResultData = new List<TelemeteringModel>();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var datas = telemeterings
|
|
|
|
|
.Where(t => t.EquipmentInfoId == equipmentId && t.DataSourceCategory == (DataSourceCategoryEnum)dataSourceCategory)
|
|
|
|
|
.Where(t => t.Name != "未用" || !t.Name.Contains("预留"))
|
|
|
|
|
.OrderBy(t => t.DispatcherAddress)
|
|
|
|
|
.ToList();
|
|
|
|
|
rst.ResultData = datas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rst.Flag = true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "根据设备id获取设备遥测实时数据", ex);
|
|
|
|
|
}
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[ShowApi]
|
|
|
|
|
public RequestResult<DateTime> TestTimeFormat()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return new RequestResult<DateTime> { ResultData = DateTime.Now };
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据设备id获取设备遥信实时数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="equipmentId"></param>
|
|
|
|
|
/// <param name="dataSourceCategory"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[ShowApi]
|
|
|
|
|
public async Task<RequestResult<List<TelesignalisationModel>>> GetEquipmentTelesignalisationByEquipmentId(Guid equipmentId, int dataSourceCategory)
|
|
|
|
|
{
|
|
|
|
|
RequestResult<List<TelesignalisationModel>> rst = new();
|
|
|
|
|
if (equipmentId == default)
|
|
|
|
|
{
|
|
|
|
|
rst.Message = "设备id为空";
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var telemeterings = await _telesignalisationModelListRedis.HashSetGetAllAsync(_telesignalisationModelListRediskey + "_" + ((DataSourceCategoryEnum)dataSourceCategory).ToString());
|
|
|
|
|
if (telemeterings == null|| telemeterings.Count==0)
|
|
|
|
|
{
|
|
|
|
|
rst.ResultData = new List<TelesignalisationModel>();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var datas = telemeterings
|
|
|
|
|
.Where(t => t.EquipmentInfoId == equipmentId && t.DataSourceCategory == (DataSourceCategoryEnum)dataSourceCategory)
|
|
|
|
|
.Where(t => t.Name != "未用" || !t.Name.Contains("预留"))
|
|
|
|
|
.OrderBy(t => t.DispatcherAddress)
|
|
|
|
|
.ToList();
|
|
|
|
|
rst.ResultData = datas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rst.Flag = true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "根据设备id获取设备遥测实时数据", ex);
|
|
|
|
|
}
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[ShowApi]
|
|
|
|
|
[DisableRequestSizeLimit]
|
|
|
|
|
[Route("/soms/api/uploadEquipmentDiagnosis")] // 指定完整路径
|
|
|
|
|
public async Task<RequestEasyResult> UploadEquipmentDiagnosisAsync(object input)
|
|
|
|
|
{
|
|
|
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Info(this.GetType(), $"九维数据:{input.ToString()}");
|
|
|
|
|
var options = new JsonSerializerOptions
|
|
|
|
|
{
|
|
|
|
|
PropertyNameCaseInsensitive = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var diagnostic = JsonSerializer.Deserialize<IntelligentDiagnostic>(input.ToString(), options);
|
|
|
|
|
Console.WriteLine($"SaveTime: {diagnostic.SaveTime}");
|
|
|
|
|
|
|
|
|
|
List<NJJWPP> nJJWPPs = GetNJJWPP();
|
|
|
|
|
var equipmentDic = _equipmentInfoRepository.GetAll().ToList();
|
|
|
|
|
|
|
|
|
|
//Join DiagnoseResult with Device by UID
|
|
|
|
|
var joinedResults = from dr in diagnostic.DiagnoseResult
|
|
|
|
|
join d in nJJWPPs on dr.Uid equals d.UID.ToString() into gj
|
|
|
|
|
from subDevice in gj.DefaultIfEmpty()
|
|
|
|
|
select new DiagnoseResult
|
|
|
|
|
{
|
|
|
|
|
EquipmentInfoName = subDevice != null ? subDevice.DeviceName : null,
|
|
|
|
|
Uid = dr.Uid,
|
|
|
|
|
Station = dr.Station,
|
|
|
|
|
Device = dr.Device,
|
|
|
|
|
Name = dr.Name,
|
|
|
|
|
Score = dr.Score,
|
|
|
|
|
DiaStatus = dr.DiaStatus,
|
|
|
|
|
ErrorCode = dr.ErrorCode,
|
|
|
|
|
ErrorType = dr.ErrorType,
|
|
|
|
|
SuggestCode = dr.SuggestCode,
|
|
|
|
|
Suggest = dr.Suggest
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Group by EquipmentInfoId and fill EquipmentInfoDiagnoseContents
|
|
|
|
|
var groupedResults = joinedResults
|
|
|
|
|
.GroupBy(jr => jr.EquipmentInfoName)
|
|
|
|
|
.Select(g => new EquipmentInfoDiagnoseResult
|
|
|
|
|
{
|
|
|
|
|
EquipmentInfoId = equipmentDic.FirstOrDefault(ei => ei.Name == g.Key)?.Id,
|
|
|
|
|
EquipmentInfoName = g.Key,
|
|
|
|
|
EquipmentInfoDiagnoseContents = g.Select(jr => new EquipmentInfoDiagnoseContent
|
|
|
|
|
{
|
|
|
|
|
Name = jr.Name,
|
|
|
|
|
Score = jr.Score,
|
|
|
|
|
DiaStatus = jr.DiaStatus,
|
|
|
|
|
ErrorCode = jr.ErrorCode,
|
|
|
|
|
ErrorType = jr.ErrorType,
|
|
|
|
|
SuggestCode = jr.SuggestCode,
|
|
|
|
|
Suggest = jr.Suggest
|
|
|
|
|
}).ToList()
|
|
|
|
|
});
|
|
|
|
|
foreach (var result in groupedResults)
|
|
|
|
|
{
|
|
|
|
|
if (result != null) {
|
|
|
|
|
if (result.EquipmentInfoId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
await _equipmentInfoDiagnoseResult.PublishAsync(_equipmentInfoDiagnoseResultChanel, result);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 保存或处理 jsonString
|
|
|
|
|
rst.Flag = true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "获取实时环境数据出错", ex);
|
|
|
|
|
}
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导航到客户端详细页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="equipemntInfoId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[ShowApi]
|
|
|
|
|
[DisableRequestSizeLimit]
|
|
|
|
|
public async Task<RequestEasyResult> NavigateToClientEquipmentDetailAsync(string equipemntInfoId)
|
|
|
|
|
{
|
|
|
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (equipemntInfoId!=default)
|
|
|
|
|
{
|
|
|
|
|
var tempData = await _equipmentInfoExAppService.FindEquipmentSearchRecordAsync(default);
|
|
|
|
|
var equipmentInfo = tempData.ResultData.FirstOrDefault(t => t.Id == Guid.Parse( equipemntInfoId));
|
|
|
|
|
await _equipmentInfoDetailRedis.PublishAsync(_equipmentInfoDetailRedisChannel, equipmentInfo);
|
|
|
|
|
rst.Flag = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "导航到客户端详细页面:设备ID为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "导航到客户端详细页面", ex);
|
|
|
|
|
}
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
|
|
|
|
private List<NJJWPP> GetNJJWPP()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string jsonFilePath = ".\\Resources\\Data\\NJJWPZ.json"; // JSON file path
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(jsonFilePath))
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine("JSON file not found!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// Read JSON data from file
|
|
|
|
|
string jsonData = File.ReadAllText(jsonFilePath);
|
|
|
|
|
return JsonConvert.DeserializeObject<List<NJJWPP>>(jsonData);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log4Helper.Error(this.GetType(), "读取配置文件", ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-07-15 10:31:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|