智慧建筑第三方功能集成微服务,目的是聚集所有涉及到第三方厂商调用的功能,按照业务功能划分不同微服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

197 lines
7.1 KiB

using Common.Shared.Application.BaseModels;
using Common.Shared.Application.SafetyFirePro.RequestDto;
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using Microsoft.Extensions.Logging;
namespace ThirdPartyServices.DomainService.PuTianSuYuan
{
public class SunPalaceBoardFacilityService : ISunPalaceBoardFacilityService
{
private readonly ILogger<SunPalaceBoardFacilityService> _logger;
private readonly IAssetWebService _assetWebService;
public SunPalaceBoardFacilityService(ILogger<SunPalaceBoardFacilityService> logger, IAssetWebService assetWebService)
{
_logger = logger;
_assetWebService = assetWebService;
}
public async Task<ApiResult<List<AssetOverviewResDto>>> GetAssetDashboardEchart(SecSituationQueryDto dto)
{
ApiResult<List<AssetOverviewResDto>> result = new ApiResult<List<AssetOverviewResDto>>() { Code = 200, Msg = "接口调用成功" };
DateTime start = DateTime.Now;
DateTime end = DateTime.Now;
////时间范围
switch (dto.QueryTimeType)
{
case (int)QueryTimeEnum.Custom:
start = dto.StartTime.Value;
end = dto.EndTime.Value;
break;
case (int)QueryTimeEnum.Monthly:
// 本月从 1号 00:00 到现在
start = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
break;
default:
return result;
}
try
{
List<AssetOverviewResDto> resDtos = [];
//总资产数
var assetCount = await _assetWebService.Client.assetCountAsync(null, null);
AssetOverviewResDto assetOverviewRes = new()
{
TotalAssetCount = assetCount.@return,
OrderBy = 1,
Name = "总资产数",
TotalAssetCountGrowthRate = 5.2
};
resDtos.Add(assetOverviewRes);
//总资产价值
var assetTotalPrice = await _assetWebService.Client.assetTotalPriceAsync(null, null);
AssetOverviewResDto assetPriceRes = new AssetOverviewResDto
{
TotalAssetCount = assetTotalPrice.@return,
OrderBy = 2,
Name = "总资产价值",
TotalAssetCountGrowthRate = 0.052
};
resDtos.Add(assetPriceRes);
//资产盘点
AssetOverviewResDto assetReviewRes = new AssetOverviewResDto
{
TotalAssetCount = 0.92,
OrderBy = 3,
Name = "资产盘点",
};
resDtos.Add(assetReviewRes);
//资产分布
AssetOverviewResDto assetDistributeRes = new AssetOverviewResDto
{
TotalAssetCount = 6,
OrderBy = 4,
Name = "资产分布",
};
resDtos.Add(assetDistributeRes);
//在保资产
AssetOverviewResDto assetInRes = new AssetOverviewResDto
{
TotalAssetCount = 876,
OrderBy = 5,
Name = "在保资产",
TotalAssetCountGrowthRate = 0.021
};
resDtos.Add(assetInRes);
//待维修资产
var awaitRepair = await _assetWebService.Client.assetAwaitRepairAsync();
AssetOverviewResDto assetRepairRes = new AssetOverviewResDto
{
TotalAssetCount = awaitRepair.@return != null ? awaitRepair.@return.Length : 0,
OrderBy = 6,
Name = "待维修资产",
TotalAssetCountGrowthRate = 0.083
};
resDtos.Add(assetRepairRes);
//本月折旧
AssetOverviewResDto assetDepreciationRes = new AssetOverviewResDto
{
TotalAssetCount = 245678.5,
OrderBy = 7,
Name = "本月折旧",
TotalAssetCountGrowthRate = 0.035
};
resDtos.Add(assetDepreciationRes);
//今日报警
var todayAlarm = await _assetWebService.Client.todayAlarmAsync();
AssetOverviewResDto assetAlarmRes = new AssetOverviewResDto
{
TotalAssetCount = todayAlarm.@return,
OrderBy = 8,
Name = "今日报警",
};
resDtos.Add(assetAlarmRes);
result.Data = resDtos;
}
catch (Exception ex)
{
_logger.LogWarning(ex, "GetAssetDashboardEchart接口出错");
return ApiResult<List<AssetOverviewResDto>>.IsFail($"GetAssetDashboardEchart接口出错{ex.Message}");
}
return result;
}
/// <summary>
/// 资产类型图
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<ApiResult<List<AssetTypeResDto>>> GetAssetTypeEchart(SecSituationQueryDto dto)
{
ApiResult<List<AssetTypeResDto>> result = new ApiResult<List<AssetTypeResDto>>() { Code = 200, Msg = "接口调用成功" };
DateTime start = DateTime.Now;
DateTime end = DateTime.Now;
////时间范围
switch (dto.QueryTimeType)
{
case (int)QueryTimeEnum.Custom:
start = dto.StartTime.Value;
end = dto.EndTime.Value;
break;
case (int)QueryTimeEnum.Monthly:
// 本月从 1号 00:00 到现在
start = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
break;
default:
return result;
}
try
{
List<AssetTypeResDto> assetTypes = [];
var assetType = await _assetWebService.Client.assetTypeStatisticsAsync("", "");
if (assetType?.@return != null && assetType.@return.Length > 0)
{
foreach (var item in assetType.@return)
{
assetTypes.Add(new AssetTypeResDto
{
AssetType = item.name,
AssetCount = item.count,
});
}
}
result.Data = assetTypes;
}
catch (Exception ex)
{
_logger.LogWarning(ex, "GetAssetTypeEchart接口出错");
return ApiResult<List<AssetTypeResDto>>.IsFail($"GetAssetTypeEchart接口出错{ex.Message}");
}
return result;
}
}
}