diff --git a/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/RequestDto/SunPlaceBoardWorkOrderReqDto.cs b/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/RequestDto/SunPlaceBoardWorkOrderReqDto.cs index e9a1787..e0d27f4 100644 --- a/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/RequestDto/SunPlaceBoardWorkOrderReqDto.cs +++ b/WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/RequestDto/SunPlaceBoardWorkOrderReqDto.cs @@ -157,4 +157,20 @@ namespace Common.Shared.Application.SafetyFirePro.RequestDto /// public string Name { get; set; } } + + /// + /// 获得本月隐患数据 + /// + public class DangerHomeResDto + { + /// + /// 统计 + /// + public int Total { get; set; } + + /// + /// + /// + public string Name { get; set; } + } } \ No newline at end of file diff --git a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Controllers/ShenZhouShengAn/SunPalaceBoardSafetyController.cs b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Controllers/ShenZhouShengAn/SunPalaceBoardSafetyController.cs index b445c40..7259f6c 100644 --- a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Controllers/ShenZhouShengAn/SunPalaceBoardSafetyController.cs +++ b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Controllers/ShenZhouShengAn/SunPalaceBoardSafetyController.cs @@ -122,5 +122,16 @@ namespace ThirdPartyServices.API.Controllers.ShenZhouShengAn { return await _secSituationService.GetStatistics(dto); } + + /// + /// 获得本月隐患数据 + /// + /// + /// + [HttpGet] + public async Task>> GetDangerHome() + { + return await _secSituationService.GetDangerHome(); + } } } \ No newline at end of file diff --git a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/RequestDto/ThirdPartyProviderQueryDto.cs b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/RequestDto/ThirdPartyProviderQueryDto.cs index 112f89f..498ea69 100644 --- a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/RequestDto/ThirdPartyProviderQueryDto.cs +++ b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/RequestDto/ThirdPartyProviderQueryDto.cs @@ -80,7 +80,6 @@ namespace ThirdPartyServices.Application.ShenZhouShengAn.RequestDto public int Ubpid { get; set; } } - /// /// 危害辨识项目数据请求参数 /// @@ -91,5 +90,15 @@ namespace ThirdPartyServices.Application.ShenZhouShengAn.RequestDto public int Uid { get; set; } } - + /// + /// 包含ubpid参数的请求实体类 + /// + public class Params + { + /// + /// 机构ID(必填) + /// + [JsonPropertyName("ubpid")] + public int Ubpid { get; set; } + } } \ No newline at end of file diff --git a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/ResponseDto/ThirdPartyProviderResDto.cs b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/ResponseDto/ThirdPartyProviderResDto.cs index 006897e..545ad09 100644 --- a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/ResponseDto/ThirdPartyProviderResDto.cs +++ b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/ResponseDto/ThirdPartyProviderResDto.cs @@ -40,6 +40,36 @@ namespace ThirdPartyServices.Application.ShenZhouShengAn.ResponseDto public T Data { get; set; } } + /// + /// 原始JSON反序列化的根实体类 + /// + public class DangerStatsRootResDto + { + /// + /// 风险等级数量统计(暂不使用) + /// + [JsonPropertyName("dangerLevelCount")] + public List? DangerLevelCount { get; set; } + + /// + /// 隐患状态数量统计(按顺序对应:待核查、待整改、待验收、整改完毕) + /// + [JsonPropertyName("dangerStatusCount")] + public List? DangerStatusCount { get; set; } + + /// + /// 当前总数(暂不使用) + /// + [JsonPropertyName("nowTotal")] + public int NowTotal { get; set; } + + /// + /// 比率(暂不使用) + /// + [JsonPropertyName("rRate")] + public string RRate { get; set; } = string.Empty; + } + public class HttpClientResultConverter : JsonConverter> { public override HttpClientResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) diff --git a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ISunPalaceBoardSafetyService.cs b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ISunPalaceBoardSafetyService.cs index 1db1643..c222557 100644 --- a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ISunPalaceBoardSafetyService.cs +++ b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ISunPalaceBoardSafetyService.cs @@ -41,5 +41,7 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn ); Task>> GetStatistics(WorkTaskQueryParamsDto dto); + + Task>> GetDangerHome(); } } \ No newline at end of file diff --git a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs index cf43c97..c603db1 100644 --- a/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs +++ b/WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs @@ -650,5 +650,72 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn new() { Name = "已超时", Total = timeoutTotal } ]; } + + public async Task>> GetDangerHome() + { + ApiResult> result = new ApiResult>() { 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>.IsFail("GetRegionRootInfo接口获取token失败"); + } + + //获取用户配置 + HttpClientResult loginUsers = await _tokenProviderService.GetUserConfiguration(token); + if (loginUsers.Code == "Error") + { + _logger.LogWarning("GetRegionRootInfo接口获取用户配置失败"); + return ApiResult>.IsFail("GetRegionRootInfo接口获取用户配置失败"); + } + Params dto = new(); + dto.Ubpid = loginUsers.Data.Ubpid; + + HttpClientResult riskResult = await _tokenProviderService + .SendAndParseAsync>( + "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(riskResult.Data.ToString()!)!; + if (httpClientResult != null) + { + // 定义固定的状态名称(顺序必须与dangerStatusCount数组一致) + var statusNames = new List + { + "待核查隐患数", + "待整改隐患数", + "待验收隐患数", + "整改完毕隐患数" + }; + + // 构建结果集合(处理数组长度不匹配的情况) + var resultItem = new List(); + 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>.IsFail($"GetRegionRootInfo接口出错{ex.Message}"); + } + + return result; + } } } \ No newline at end of file