|
|
|
|
@ -650,5 +650,72 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn |
|
|
|
|
new() { Name = "已超时", Total = timeoutTotal } |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome() |
|
|
|
|
{ |
|
|
|
|
ApiResult<List<DangerHomeResDto>> result = new ApiResult<List<DangerHomeResDto>>() { Code = 200, Msg = "接口调用成功", Data = null }; |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
//获取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); |
|
|
|
|
|
|
|
|
|
if (riskResult != null && riskResult.Data != null && riskResult.Data.ToString()!.Length > 10) |
|
|
|
|
{ |
|
|
|
|
DangerStatsRootResDto httpClientResult = JsonSerializer.Deserialize<DangerStatsRootResDto>(riskResult.Data.ToString()!)!; |
|
|
|
|
if (httpClientResult != null) |
|
|
|
|
{ |
|
|
|
|
// 定义固定的状态名称(顺序必须与dangerStatusCount数组一致) |
|
|
|
|
var statusNames = new List<string> |
|
|
|
|
{ |
|
|
|
|
"待核查隐患数", |
|
|
|
|
"待整改隐患数", |
|
|
|
|
"待验收隐患数", |
|
|
|
|
"整改完毕隐患数" |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 构建结果集合(处理数组长度不匹配的情况) |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |