161 lines
7.1 KiB
C#
161 lines
7.1 KiB
C#
|
|
using Abp.Application.Services;
|
|||
|
|
using Abp.Authorization;
|
|||
|
|
using Abp.Domain.Repositories;
|
|||
|
|
using Abp.Domain.Uow;
|
|||
|
|
using Abp.Web.Models;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
|||
|
|
using Newtonsoft.Json;
|
|||
|
|
using Newtonsoft.Json.Linq;
|
|||
|
|
using Newtonsoft.Json.Serialization;
|
|||
|
|
using NPOI.OpenXmlFormats.Dml.Diagram;
|
|||
|
|
using System;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Diagnostics;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Linq.Dynamic.Core;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using ToolLibrary.LogHelper;
|
|||
|
|
using YunDa.ISAS.Application.Core;
|
|||
|
|
using YunDa.ISAS.Application.Core.Configuration;
|
|||
|
|
using YunDa.ISAS.Application.Core.SwaggerHelper;
|
|||
|
|
using YunDa.ISAS.DataTransferObject;
|
|||
|
|
using YunDa.ISAS.DataTransferObject.GeneralInformation.EquipmentInfoDto;
|
|||
|
|
using YunDa.ISAS.DataTransferObject.PatternRecognition;
|
|||
|
|
using YunDa.ISAS.DataTransferObject.VideoSurveillance.PresetPointDto;
|
|||
|
|
using YunDa.ISAS.DataTransferObject.VideoSurveillance.VideoDevDto;
|
|||
|
|
using YunDa.ISAS.Entities.GeneralInformation;
|
|||
|
|
using YunDa.ISAS.Entities.VideoSurveillance;
|
|||
|
|
using YunDa.ISAS.ExternalInteraction.DataTransferObject;
|
|||
|
|
using YunDa.ISAS.ExternalInteraction.DataTransferObject.Other;
|
|||
|
|
|
|||
|
|
namespace YunDa.ISAS.ExternalInteraction.Application.PatternRecognition
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
https://ip:port/项目路径/api/other/updatetemperature;
|
|||
|
|
*/
|
|||
|
|
/// <summary>
|
|||
|
|
/// 对外通信-主站额外需求
|
|||
|
|
/// </summary>
|
|||
|
|
[DontWrapResult, AbpAllowAnonymous, Description("对外通信-主站额外需求")]
|
|||
|
|
[ISAS.Application.Core.ExtensionAttribute.ApiPageLog]
|
|||
|
|
public class MainstationGetTempService : ApplicationService, IMainstationGetTempService
|
|||
|
|
{
|
|||
|
|
private readonly IAppServiceConfiguration _appServiceConfiguration;
|
|||
|
|
private readonly IRepository<MasterStation, Guid> _masterStationRepository;
|
|||
|
|
private readonly IRepository<VideoDev, Guid> _videoDevRepository;
|
|||
|
|
private readonly IRepository<PresetPoint, Guid> _presetPointRepository;
|
|||
|
|
private readonly IRepository<EquipmentInfo, Guid> _equipmentInfoRepository;
|
|||
|
|
private readonly IRepository<EquipmentType, Guid> _equipmentTypeRepository;
|
|||
|
|
private readonly IActionContextAccessor _actionContextAccessor;
|
|||
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|||
|
|
private readonly IRepository<TransformerSubstation, Guid> _transformerSubstationRepository;
|
|||
|
|
private readonly IRepository<MeasureTemperaturePoint, Guid> _mtpRepository;
|
|||
|
|
|
|||
|
|
public MainstationGetTempService(IRepository<MasterStation, Guid> masterStationRepository
|
|||
|
|
, IRepository<VideoDev, Guid> videoDevRepository
|
|||
|
|
, IRepository<PresetPoint, Guid> presetPointRepository
|
|||
|
|
, IRepository<EquipmentInfo, Guid> equipmentInfoRepository
|
|||
|
|
, IRepository<EquipmentType, Guid> equipmentTypeRepository
|
|||
|
|
, IActionContextAccessor actionContextAccessor
|
|||
|
|
, IUnitOfWorkManager unitOfWorkManager
|
|||
|
|
, IRepository<TransformerSubstation, Guid> transformerSubstationRepository
|
|||
|
|
, IRepository<MeasureTemperaturePoint, Guid> mtpRepository
|
|||
|
|
, IAppServiceConfiguration appServiceConfiguration)
|
|||
|
|
{
|
|||
|
|
_videoDevRepository = videoDevRepository;
|
|||
|
|
_presetPointRepository = presetPointRepository;
|
|||
|
|
_equipmentInfoRepository = equipmentInfoRepository;
|
|||
|
|
_equipmentTypeRepository = equipmentTypeRepository;
|
|||
|
|
_masterStationRepository = masterStationRepository;
|
|||
|
|
_appServiceConfiguration = appServiceConfiguration;
|
|||
|
|
_actionContextAccessor = actionContextAccessor;
|
|||
|
|
_unitOfWorkManager = unitOfWorkManager;
|
|||
|
|
_transformerSubstationRepository = transformerSubstationRepository;
|
|||
|
|
_mtpRepository = mtpRepository;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 图像识别复核 主站--->子站
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="input"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
[ShowApi]
|
|||
|
|
[Route("isas/api/other/updatetemperature")]
|
|||
|
|
public ExternalRequestEasyResult UpdateTemperature(UpdateTemperatureInput input)
|
|||
|
|
{
|
|||
|
|
ExternalRequestEasyResult rst = new ExternalRequestEasyResult()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
Message = "成功",
|
|||
|
|
Status = 0
|
|||
|
|
};
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var masterStationIp = _actionContextAccessor.ActionContext.HttpContext.Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();
|
|||
|
|
var masterStationRepo = _masterStationRepository.GetAll().ToList();
|
|||
|
|
var masterStation = masterStationRepo.FirstOrDefault(t => t.MasterStationIp == masterStationIp);
|
|||
|
|
var substation = _transformerSubstationRepository.GetAll().FirstOrDefault(t => t.SubstationName == input.SubName);
|
|||
|
|
if (masterStation == null)
|
|||
|
|
{
|
|||
|
|
masterStation = masterStationRepo.FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
if (substation == null)
|
|||
|
|
{
|
|||
|
|
rst.Status = 1;
|
|||
|
|
rst.Message = "子站未找到";
|
|||
|
|
return rst;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var videoRepo = _videoDevRepository.GetAllIncluding(t => t.ManufacturerInfo).ToList();
|
|||
|
|
var camera = videoRepo.FirstOrDefault(t => t.DevName == input.CamName);
|
|||
|
|
if (camera == null)
|
|||
|
|
{
|
|||
|
|
rst.Status = 1;
|
|||
|
|
rst.Message = "摄像机未找到";
|
|||
|
|
return rst;
|
|||
|
|
}
|
|||
|
|
if (!int.TryParse(input.PresetCode, out _))
|
|||
|
|
{
|
|||
|
|
rst.Status = 1;
|
|||
|
|
rst.Message = "摄像机预置位必须是整数";
|
|||
|
|
return rst;
|
|||
|
|
}
|
|||
|
|
var preset = _presetPointRepository.GetAllIncluding(t => t.VideoDev, t => t.VideoDev.ManufacturerInfo).FirstOrDefault(t => t.VideoDevId == camera.Id && t.Number == int.Parse(input.PresetCode));
|
|||
|
|
if (preset == null)
|
|||
|
|
{
|
|||
|
|
rst.Status = 1;
|
|||
|
|
rst.Message = "预置位未找到";
|
|||
|
|
return rst;
|
|||
|
|
}
|
|||
|
|
var tempRepo = _mtpRepository.GetAll().Where(t => t.PresetPointId == preset.Id);
|
|||
|
|
if (tempRepo == null || tempRepo.Count()==0)
|
|||
|
|
{
|
|||
|
|
rst.Status = 1;
|
|||
|
|
rst.Message = "该预置位下没有测温点";
|
|||
|
|
return rst;
|
|||
|
|
}
|
|||
|
|
string url = "http://localhost:35701/isas/api/dataMonitoringService/home/ExcuteTemperature";
|
|||
|
|
JObject rstDataJObject = ToolLibrary.HttpHelper.HttpGetRequest<JObject>(url+"?"+ $"camName={input.CamName}&presetNum={input.PresetCode}");
|
|||
|
|
if (rstDataJObject!=null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Log4Helper.Error(this.GetType(), " 对外通信-主站额外需求", ex);
|
|||
|
|
rst.Status = 1;
|
|||
|
|
rst.Message = "内部错误";
|
|||
|
|
return rst;
|
|||
|
|
}
|
|||
|
|
rst.Message = "已经通测温程序处理";
|
|||
|
|
return rst;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|