修改风险接口

pull/38/head
刘鑫 1 month ago
parent ac304ea759
commit 02d80061f9
  1. 4
      WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/RequestDto/SunPlaceBoardWorkOrderReqDto.cs
  2. 6
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Controllers/ShenZhouShengAn/SunPalaceBoardSafetyController.cs
  3. 2
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ISunPalaceBoardSafetyService.cs
  4. 83
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs
  5. 2
      WeiCloud.Fusion/VideoService/Video.API/Controllers/DaHua/VideoManageController.cs

@ -169,8 +169,8 @@ namespace Common.Shared.Application.SafetyFirePro.RequestDto
public int Total { get; set; }
/// <summary>
///
/// 类型名:0待核查,1待整改,2待验收,3治理完毕,4不是隐患,
/// </summary>
public string Name { get; set; }
public required string Name { get; set; }
}
}

@ -132,10 +132,10 @@ namespace ThirdPartyServices.API.Controllers.ShenZhouShengAn
/// 获得本月隐患数据
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome()
[HttpPost]
public async Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome(DangerInfoQueryDto dto)
{
return await _secSituationService.GetDangerHome();
return await _secSituationService.GetDangerHome(dto);
}
}
}

@ -42,6 +42,6 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
Task<ApiResult<List<StatisticsInfoDto>>> GetStatistics(WorkTaskQueryParamsDto dto);
Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome();
Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome(DangerInfoQueryDto regionId);
}
}

@ -1,6 +1,7 @@
using Common.Shared.Application.BaseModels;
using Common.Shared.Application.SafetyFirePro.RequestDto;
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Text.Json;
@ -211,13 +212,6 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
return ApiResult<DangerInfoRootResDto>.IsFail("GetDangerInfos接口获取用户配置失败");
}
//获取单位信息
HttpClientResult<BranchResDto> branchs = await _tokenProviderService.GetBranchPermissions(token, loginUsers.Data.Uid);
if (branchs.Code == "Error")
{
_logger.LogWarning("GetDangerInfos接口获取单位信息失败");
return ApiResult<DangerInfoRootResDto>.IsFail("GetDangerInfos接口获取单位信息失败");
}
dto.Ubpid = loginUsers.Data.Ubpid;
// dto.Branch_id = branchs.Data.BranchPermissionIds[0];
@ -651,68 +645,43 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
];
}
public async Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome()
/// <summary>
/// 获取
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome(DangerInfoQueryDto dto)
{
ApiResult<List<DangerHomeResDto>> result = new ApiResult<List<DangerHomeResDto>>() { Code = 200, Msg = "接口调用成功", Data = [] };
ApiResult<List<DangerHomeResDto>> result = new ApiResult<List<DangerHomeResDto>>() { Code = 200, Msg = "接口调用成功", Data = new List<DangerHomeResDto>() };
try
Dictionary<string, int> statusTotal = new Dictionary<string, int>
{
//获取token
var token = await _tokenProviderService.GetTokenAsync(_configuration["ThirdParty:SzdunanCode"]!);
if (string.IsNullOrWhiteSpace(token))
{
_logger.LogWarning("GetRegionRootInfo接口获取token失败");
return ApiResult<List<DangerHomeResDto>>.IsFail("GetRegionRootInfo接口获取token失败");
}
//获取用户配置
HttpClientResult<LoginUsersConfiguration> loginUsers = await _tokenProviderService.GetUserConfiguration(token);
if (loginUsers.Code == "Error")
{
_logger.LogWarning("GetRegionRootInfo接口获取用户配置失败");
return ApiResult<List<DangerHomeResDto>>.IsFail("GetRegionRootInfo接口获取用户配置失败");
}
Params dto = new();
dto.Ubpid = loginUsers.Data.Ubpid;
HttpClientResult<object> riskResult = await _tokenProviderService
.SendAndParseAsync<Params, HttpClientResult<object>>(
"https://zrh.szdunan.cn/v1/api/home/danger",
token, dto, HttpMethod.Get);
{ "待核查隐患数", 0 },
{ "待整改隐患数", 0 },
{ "待验收隐患数", 0 },
{ "整改完毕隐患数", 0 }
};
if (riskResult != null && riskResult.Data != null && riskResult.Data.ToString()!.Length > 10)
foreach (var item in statusTotal)
{
DangerStatsRootResDto httpClientResult = JsonSerializer.Deserialize<DangerStatsRootResDto>(riskResult.Data.ToString()!)!;
if (httpClientResult != null)
{
// 定义固定的状态名称(顺序必须与dangerStatusCount数组一致)
var statusNames = new List<string>
dto.Status = item.Key switch
{
"待核查隐患数",
"待整改隐患数",
"待验收隐患数",
"整改完毕隐患数"
"待核查隐患数" => "0",
"待整改隐患数" => "1",
"待验收隐患数" => "2",
"整改完毕隐患数" => "3",
_ => ""
};
var dangerInfo = await this.GetDangerInfos(dto);
// 构建结果集合(处理数组长度不匹配的情况)
var resultItem = new List<DangerHomeResDto>();
for (int i = 0; i < statusNames.Count; i++)
if (dangerInfo.Data != null)
{
resultItem.Add(new DangerHomeResDto
result.Data.Add(new DangerHomeResDto
{
Name = statusNames[i],
Total = httpClientResult?.DangerStatusCount?.ElementAtOrDefault(i) ?? 0
Name = item.Key,
Total = dangerInfo.Data.Total
});
}
result.Data = resultItem;
}
}
}
catch (Exception ex)
{
_logger.LogWarning(ex, "GetRegionRootInfo接口出错");
return ApiResult<List<DangerHomeResDto>>.IsFail($"GetRegionRootInfo接口出错{ex.Message}");
}
return result;

@ -179,7 +179,7 @@ namespace Video.API.Controllers.DaHua
/// <param name="channelId">视频id</param>
/// <returns></returns>
[HttpGet("dh/snapshot")]
public async Task<DaHApiResult<SnapshotResDto>> InvokeSnapshot(string deviceCode, long id, int channelId)
public async Task<DaHApiResult<SnapshotResDto>> InvokeSnapshot(string deviceCode, long id, int channelId = 0)
{
return await _dahGeneralCtlService.InvokeSnapshot(deviceCode, id, channelId);
}

Loading…
Cancel
Save