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