增加一个接口

pull/31/head
刘鑫 2 months ago
parent 7940f5c329
commit e551238062
  1. 16
      WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/RequestDto/SunPlaceBoardWorkOrderReqDto.cs
  2. 11
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Controllers/ShenZhouShengAn/SunPalaceBoardSafetyController.cs
  3. 13
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/RequestDto/ThirdPartyProviderQueryDto.cs
  4. 30
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/ResponseDto/ThirdPartyProviderResDto.cs
  5. 2
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ISunPalaceBoardSafetyService.cs
  6. 67
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs

@ -157,4 +157,20 @@ namespace Common.Shared.Application.SafetyFirePro.RequestDto
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
} }
/// <summary>
/// 获得本月隐患数据
/// </summary>
public class DangerHomeResDto
{
/// <summary>
/// 统计
/// </summary>
public int Total { get; set; }
/// <summary>
///
/// </summary>
public string Name { get; set; }
}
} }

@ -122,5 +122,16 @@ namespace ThirdPartyServices.API.Controllers.ShenZhouShengAn
{ {
return await _secSituationService.GetStatistics(dto); return await _secSituationService.GetStatistics(dto);
} }
/// <summary>
/// 获得本月隐患数据
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpGet]
public async Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome()
{
return await _secSituationService.GetDangerHome();
}
} }
} }

@ -80,7 +80,6 @@ namespace ThirdPartyServices.Application.ShenZhouShengAn.RequestDto
public int Ubpid { get; set; } public int Ubpid { get; set; }
} }
/// <summary> /// <summary>
/// 危害辨识项目数据请求参数 /// 危害辨识项目数据请求参数
/// </summary> /// </summary>
@ -91,5 +90,15 @@ namespace ThirdPartyServices.Application.ShenZhouShengAn.RequestDto
public int Uid { get; set; } public int Uid { get; set; }
} }
/// <summary>
/// 包含ubpid参数的请求实体类
/// </summary>
public class Params
{
/// <summary>
/// 机构ID(必填)
/// </summary>
[JsonPropertyName("ubpid")]
public int Ubpid { get; set; }
}
} }

@ -40,6 +40,36 @@ namespace ThirdPartyServices.Application.ShenZhouShengAn.ResponseDto
public T Data { get; set; } public T Data { get; set; }
} }
/// <summary>
/// 原始JSON反序列化的根实体类
/// </summary>
public class DangerStatsRootResDto
{
/// <summary>
/// 风险等级数量统计(暂不使用)
/// </summary>
[JsonPropertyName("dangerLevelCount")]
public List<int>? DangerLevelCount { get; set; }
/// <summary>
/// 隐患状态数量统计(按顺序对应:待核查、待整改、待验收、整改完毕)
/// </summary>
[JsonPropertyName("dangerStatusCount")]
public List<int>? DangerStatusCount { get; set; }
/// <summary>
/// 当前总数(暂不使用)
/// </summary>
[JsonPropertyName("nowTotal")]
public int NowTotal { get; set; }
/// <summary>
/// 比率(暂不使用)
/// </summary>
[JsonPropertyName("rRate")]
public string RRate { get; set; } = string.Empty;
}
public class HttpClientResultConverter<T> : JsonConverter<HttpClientResult<T>> public class HttpClientResultConverter<T> : JsonConverter<HttpClientResult<T>>
{ {
public override HttpClientResult<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override HttpClientResult<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

@ -41,5 +41,7 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
); );
Task<ApiResult<List<StatisticsInfoDto>>> GetStatistics(WorkTaskQueryParamsDto dto); Task<ApiResult<List<StatisticsInfoDto>>> GetStatistics(WorkTaskQueryParamsDto dto);
Task<ApiResult<List<DangerHomeResDto>>> GetDangerHome();
} }
} }

@ -650,5 +650,72 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
new() { Name = "已超时", Total = timeoutTotal } 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;
}
} }
} }
Loading…
Cancel
Save