Merge pull request 'dev_lx' (#27) from dev_lx into main

Reviewed-on: #27
pull/28/head
刘鑫 3 months ago
commit f238150239
  1. 2
      WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj
  2. 401
      WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/ResponseDto/SunPalaceBoardResDto.cs
  3. 23
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Controllers/ShenZhouShengAn/SunPalaceBoardSafetyController.cs
  4. 7
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Program.cs
  5. 10
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.Application/ShenZhouShengAn/RequestDto/ThirdPartyProviderQueryDto.cs
  6. 18
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ISunPalaceBoardSafetyService.cs
  7. 129
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs

@ -7,7 +7,7 @@
</PropertyGroup>
<PropertyGroup>
<PackageId>Common.Shared.Application</PackageId>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<Authors>zrh-lx</Authors>
<Company>zrh-lx</Company> <!-- 可选 -->
<Description>包含所有公共使用的 DTO、契约、接口模型等,供微服务之间共享使用</Description>

@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Common.Shared.Application.SafetyFirePro.ResponseDto
{
@ -239,4 +240,402 @@ namespace Common.Shared.Application.SafetyFirePro.ResponseDto
}
#endregion 太阳宫看板-设备设施态势返回体
#region 太阳宫看板-风险管控可视化
// 1) 定义响应模型
public class FloorDto
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("floor_number")]
public int FloorNumber { get; set; }
[JsonPropertyName("sort")]
public int Sort { get; set; }
[JsonPropertyName("region_id")]
public int RegionId { get; set; }
[JsonPropertyName("is_3d")]
public int Is3d { get; set; }
[JsonPropertyName("jiaodu")]
public int Jiaodu { get; set; }
}
/// <summary>
/// 四色图图层列表
/// </summary>
public class FloorResDto
{
public List<FloorDto> Data { get; set; } = [];
}
#endregion 太阳宫看板-风险管控可视化
#region 太阳宫看板-隐患数据
/// <summary>
/// 根节点
/// </summary>
public class RootReqDto
{
/// <summary>
/// 地图缩放系数
/// </summary>
[JsonPropertyName("zoom")]
public string Zoom { get; set; }
/// <summary>
/// 地图中心坐标 [经度,纬度]
/// </summary>
[JsonPropertyName("center")]
[JsonConverter(typeof(FlexibleCenterConverter))]
public List<List<double>> Center { get; set; }
/// <summary>
/// 底图数据
/// </summary>
[JsonPropertyName("changquArr")]
public List<ChangquDto> ChangquArr { get; set; }
/// <summary>
/// 色块区域相关数据
/// </summary>
[JsonPropertyName("seKualArr")]
public List<SeKualDto> SeKualArr { get; set; }
}
public class ChangquDto
{
[JsonPropertyName("drawType")]
public string DrawType { get; set; }
[JsonPropertyName("center")]
[JsonConverter(typeof(FlexibleCenterConverter))]
public List<List<double>> Center { get; set; }
[JsonPropertyName("imgurl")]
public string ImgUrl { get; set; }
[JsonPropertyName("region_id")]
public int RegionId { get; set; }
[JsonPropertyName("parent_id")]
public int ParentId { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("point")]
public List<List<double>> Point { get; set; }
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("monitor")]
public List<MonitorDto> Monitor { get; set; }
}
public class MonitorDto
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("uid")]
public int Uid { get; set; }
[JsonPropertyName("ubpid")]
public int Ubpid { get; set; }
[JsonPropertyName("user_id")]
public string UserId { get; set; }
[JsonPropertyName("enterprise_region_id")]
public int EnterpriseRegionId { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("category_id")]
public int? CategoryId { get; set; }
[JsonPropertyName("channel")]
public string Channel { get; set; }
[JsonPropertyName("location")]
public string Location { get; set; }
[JsonPropertyName("status")]
public string Status { get; set; }
[JsonPropertyName("pull_url")]
public string PullUrl { get; set; }
[JsonPropertyName("push_url")]
public string PushUrl { get; set; }
[JsonPropertyName("content")]
public string Content { get; set; }
[JsonPropertyName("created_at")]
public string CreatedAt { get; set; }
[JsonPropertyName("updated_at")]
public string UpdatedAt { get; set; }
[JsonPropertyName("deleted_at")]
public string DeletedAt { get; set; }
}
/// <summary>
/// 色块区域相关数据
/// </summary>
public class SeKualDto
{
/// <summary>
///色块区域id
/// </summary>
[JsonPropertyName("region_id")]
public int RegionId { get; set; }
/// <summary>
/// 色块父区域id
/// </summary>
[JsonPropertyName("parent_id")]
public int ParentId { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
/// <summary>
/// 色块形状类型
/// </summary>
[JsonPropertyName("drawType")]
public string DrawType { get; set; }
/// <summary>
/// 色块名称坐标位置
/// </summary>
[JsonPropertyName("textPoint")]
public List<object> TextPoint { get; set; } // 有时是数字,有时是字符串
/// <summary>
/// 色块图像各顶点经纬度
/// </summary>
[JsonPropertyName("center")]
[JsonConverter(typeof(FlexibleCenterConverter))]
public List<List<double>> Center { get; set; }
[JsonPropertyName("gaodu_x")]
public int GaoduX { get; set; }
[JsonPropertyName("gaodu_y")]
public int GaoduY { get; set; }
/// <summary>
/// 色块id
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("monitor")]
public List<MonitorDto> Monitor { get; set; }
[JsonPropertyName("ristType")]
public RistTypeWrapper RistType { get; set; }
[JsonPropertyName("riskPointCount")]
public List<RiskPointCountDto> RiskPointCount { get; set; }
/// <summary>
/// 风险等级颜色
/// </summary>
[JsonPropertyName("color")]
public string Color { get; set; }
[JsonPropertyName("sumCount")]
public int SumCount { get; set; }
[JsonPropertyName("dangerStatistics")]
public DangerStatisticsDto DangerStatistics { get; set; }
/// <summary>
/// 相关危险作业数量
/// </summary>
[JsonPropertyName("ticket_do_count")]
public int TicketDoCount { get; set; }
/// <summary>
/// 相关应急物资数量
/// </summary>
[JsonPropertyName("contingency_material_count")]
public int ContingencyMaterialCount { get; set; }
/// <summary>
/// 相关消防设备数量
/// </summary>
[JsonPropertyName("fire_equipment_count")]
public int FireEquipmentCount { get; set; }
}
public class RistTypeWrapper
{
/// <summary>
/// 风险点总数
/// </summary>
[JsonPropertyName("sumCount")]
public int SumCount { get; set; }
/// <summary>
/// 各风险点类型数据
/// </summary>
[JsonPropertyName("ristType")]
public List<RistTypeDto> RistType { get; set; }
}
public class RistTypeDto
{
/// <summary>
/// 风险点类型id
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }
/// <summary>
/// 风险点类型名称
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }
/// <summary>
/// 风险点类型包含风险点数
/// </summary>
[JsonPropertyName("count")]
public int Count { get; set; }
}
/// <summary>
/// 风险
/// </summary>
public class RiskPointCountDto
{
/// <summary>
/// 风险类型
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }
/// <summary>
/// 风险统计数量
/// </summary>
[JsonPropertyName("count")]
public string Count { get; set; }
}
/// <summary>
/// 隐患统计
/// </summary>
public class DangerStatisticsDto
{
/// <summary>
/// 年度隐患总数
/// </summary>
[JsonPropertyName("sumDanger")]
public int SumDanger { get; set; }
/// <summary>
/// 年度重大隐患数
/// </summary>
[JsonPropertyName("majorDanger")]
public int MajorDanger { get; set; }
/// <summary>
/// 年度一般隐患数
/// </summary>
[JsonPropertyName("generalDanger")]
public int GeneralDanger { get; set; }
/// <summary>
/// 当前隐患未整改完毕数
/// </summary>
[JsonPropertyName("dangerNum")]
public int DangerNum { get; set; }
/// <summary>
/// 当前隐患逾期未整改完毕数
/// </summary>
[JsonPropertyName("delay")]
public int Delay { get; set; }
}
public sealed class FlexibleCenterConverter : JsonConverter<List<List<double>>>
{
public override List<List<double>> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
using var doc = JsonDocument.ParseValue(ref reader);
var root = doc.RootElement;
if (root.ValueKind != JsonValueKind.Array)
return new List<List<double>>();
// 空数组 -> []
if (root.GetArrayLength() == 0)
return new List<List<double>>();
// 判断第一项是数字还是数组
var first = root[0];
if (first.ValueKind == JsonValueKind.Number || first.ValueKind == JsonValueKind.String)
{
// 一维: [x, y] 或 ["116.1","39.9"] -> [[x, y]]
var list = new List<double>(root.GetArrayLength());
foreach (var e in root.EnumerateArray())
{
if (e.ValueKind == JsonValueKind.String)
{
if (double.TryParse(e.GetString(), out var v)) list.Add(v);
}
else if (e.ValueKind == JsonValueKind.Number)
{
list.Add(e.GetDouble());
}
}
return new List<List<double>> { list };
}
else if (first.ValueKind == JsonValueKind.Array)
{
// 二维: [[x1,y1],[x2,y2]]
var outer = new List<List<double>>(root.GetArrayLength());
foreach (var inner in root.EnumerateArray())
{
var pair = new List<double>(inner.GetArrayLength());
foreach (var e in inner.EnumerateArray())
{
if (e.ValueKind == JsonValueKind.String)
{
if (double.TryParse(e.GetString(), out var v)) pair.Add(v);
}
else if (e.ValueKind == JsonValueKind.Number)
{
pair.Add(e.GetDouble());
}
}
outer.Add(pair);
}
return outer;
}
return new List<List<double>>();
}
public override void Write(Utf8JsonWriter writer, List<List<double>> value, JsonSerializerOptions options)
=> JsonSerializer.Serialize(writer, value, options);
#endregion 太阳宫看板-隐患数据
}
}

@ -1,5 +1,6 @@
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
using ThirdPartyServices.DomainService.ShenZhouShengAn;
namespace ThirdPartyServices.API.Controllers.ShenZhouShengAn
@ -24,12 +25,32 @@ namespace ThirdPartyServices.API.Controllers.ShenZhouShengAn
/// <summary>
/// 生产风险识别(盾安云数据)智慧建筑的看板上使用
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpGet("productionRisk")]
public async Task<DangerRiskAreaResDto> GetProductionRiskEchart()
{
return await _secSituationService.GetProductionRiskEchart();
}
/// <summary>
///获得四色图图层列表
/// </summary>
/// <returns></returns>
[HttpGet("listFloor")]
public async Task<FloorResDto> GetListFloor()
{
return await _secSituationService.GetListFloor();
}
/// <summary>
/// 获得四色图区域列表
/// </summary>
/// <param name="floorId">图层id</param>
/// <returns></returns>
[HttpGet("getRiskMapInfo")]
public async Task<RootReqDto> GetRiskMapInfo(int floorId)
{
return await _secSituationService.GetRiskMapInfo(floorId);
}
}
}

@ -45,6 +45,13 @@ namespace ThirdPartyServices.API
#endregion Cors
//json大小写不敏感
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
});
#region SwaggerUI
builder.Services.AddEndpointsApiExplorer();

@ -65,4 +65,14 @@ namespace ThirdPartyServices.Application.ShenZhouShengAn.RequestDto
public string? End_time { get; set; }
}
/// <summary>
/// 获得四色图区域列表请求参数
/// </summary>
public class RiskFourcoMapReqDto
{
public int Floor { get; set; }
public int Ubpid { get; set; }
}
}

@ -1,5 +1,5 @@
using Common.Shared.Application.BaseModels;
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using System.Text.Json;
namespace ThirdPartyServices.DomainService.ShenZhouShengAn
{
@ -11,6 +11,20 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
Task<DangerRiskAreaResDto> GetProductionRiskEchart();
/// <summary>
/// 获得四色图图层列表
/// </summary>
/// <param name="ubpid">用户单位标记码</param>
/// <returns></returns>
Task<FloorResDto> GetListFloor();
/// <summary>
/// 获得四色图区域列表
/// </summary>
/// <param name="floorId">图层id</param>
/// <returns></returns>
Task<RootReqDto> GetRiskMapInfo(int floorId);
//Task<ApiResult<AlarmInfoResultPageModelV02>> GetUnAlarmInfoList(AlarmEventEchartQueryDto dto);
}
}

@ -1,7 +1,8 @@
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using MongoDB.Bson.IO;
using System.Text.Json;
using ThirdPartyServices.Application.ShenZhouShengAn.RequestDto;
using ThirdPartyServices.Application.ShenZhouShengAn.ResponseDto;
@ -20,6 +21,50 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
_configuration = configuration;
}
/// <summary>
/// 获得四色图图层列表
/// </summary>
/// <param name="ubpid">用户单位标记码</param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<FloorResDto> GetListFloor()
{
var result = new FloorResDto();
try
{
//获取token
var token = await _tokenProviderService.GetTokenAsync(_configuration["ThirdParty:SzdunanCode"]!);
if (string.IsNullOrWhiteSpace(token))
{
_logger.LogWarning("GetListFloor接口获取token失败");
return result;
}
//获取用户配置
HttpClientResult<LoginUsersConfiguration> loginUsers = await _tokenProviderService.GetUserConfiguration(token);
if (loginUsers.Code == "Error")
{
_logger.LogWarning("GetListFloor接口获取用户配置失败");
return result;
}
//生产风险识别
HttpClientResult<List<FloorDto>> riskResult = await _tokenProviderService
.SendAndParseAsync<int, HttpClientResult<List<FloorDto>>>(
"https://zrh.szdunan.cn/v1/api/riskFourcoloringMap/getlistFloor",
token, loginUsers.Data.Ubpid, HttpMethod.Post);
result = new FloorResDto { Data = riskResult.Data };
}
catch (Exception ex)
{
_logger.LogWarning(ex, "GetListFloor接口出错");
}
return result;
}
/// <summary>
/// 生产风险识别(盾安云数据)-智慧建筑的看板上使用
/// </summary>
@ -89,17 +134,19 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
// 1. 查该状态下的总数
string jsonResult = await _tokenProviderService.SendJsonAsync<DangerInfoQueryDto>("https://zrh.szdunan.cn/v1/api/danger/ledger/dangerInfo/new", token, new DangerInfoQueryDto { Ubpid = loginUsers.Data.Ubpid, Status = status }, HttpMethod.Post);
var jObj = JObject.Parse(jsonResult);
int total = jObj["data"]?["total"]?.Value<int>() ?? 0;
using JsonDocument doc = JsonDocument.Parse(jsonResult);
JsonElement root = doc.RootElement;
int total = 0;
if (root.TryGetProperty("data", out JsonElement dataElement))
{
if (dataElement.TryGetProperty("total", out JsonElement totalElement))
{
total = totalElement.GetInt32();
}
}
info.StatusCount = total;
//// 2. 查该状态 + 等级下的总数(只要一个等级的话可以直接取)
//jsonResult = await _tokenProviderService.SendJsonAsync<DangerInfoQueryDto>("https://zrh.szdunan.cn/v1/api/danger/ledger/dangerInfo/new", token, new DangerInfoQueryDto { Ubpid = loginUsers.Data.Ubpid, Status = status, Result = "3" }, HttpMethod.Post);
//jObj = JObject.Parse(jsonResult);
//int levelTotal = jObj["data"]?["total"]?.Value<int>() ?? 0;
//info.DangerLevelCount = levelTotal;
return info;
}));
}
@ -109,8 +156,19 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
DateTime startTime = new DateTime(DateTime.Today.Year, 1, 1);
dangerInfo = new DangerInfo();
var jsonBranch = await _tokenProviderService.SendJsonAsync("https://zrh.szdunan.cn/v1/api/danger/task/index_branch", token, new DangerInfoQueryDto { Status = "0", Branch_id = branchs.Data.BranchPermissionIds[0], Start_time = startTime.ToString("yyyy-MM-dd HH:mm:ss"), End_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }, HttpMethod.Post);
var jObj = JObject.Parse(jsonBranch);
int total = jObj["data"]?["total"]?.Value<int>() ?? 0;
using JsonDocument doc = JsonDocument.Parse(jsonBranch);
JsonElement root = doc.RootElement;
int total = 0;
if (root.TryGetProperty("data", out JsonElement dataElement))
{
// 如果"data"存在,再尝试获取"total"
if (dataElement.TryGetProperty("total", out JsonElement totalElement))
{
// 尝试转换为int(如果类型不匹配,也会返回默认值0)
total = totalElement.GetInt32();
}
}
dangerInfo.StatusCount = total;
dangerInfo.Status = "3"; //待排查
dangerInfoList.Add(dangerInfo);
@ -123,5 +181,52 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
}
return result;
}
/// <summary>
/// 获得四色图区域列表
/// </summary>
/// <param name="floorId"></param>
/// <returns></returns>
public async Task<RootReqDto> GetRiskMapInfo(int floorId)
{
var result = new RootReqDto();
try
{
//获取token
var token = await _tokenProviderService.GetTokenAsync(_configuration["ThirdParty:SzdunanCode"]!);
if (string.IsNullOrWhiteSpace(token))
{
_logger.LogWarning("GetRiskMapInfo接口获取token失败");
return result;
}
//获取用户配置
HttpClientResult<LoginUsersConfiguration> loginUsers = await _tokenProviderService.GetUserConfiguration(token);
if (loginUsers.Code == "Error")
{
_logger.LogWarning("GetRiskMapInfo接口获取用户配置失败");
return result;
}
//生产风险识别
HttpClientResult<RootReqDto> riskResult = await _tokenProviderService
.SendAndParseAsync<RiskFourcoMapReqDto, HttpClientResult<RootReqDto>>(
"https://zrh.szdunan.cn/v1/api/riskFourcoloringMap/getRiskFourColoringMapInfo",
token, new RiskFourcoMapReqDto
{
Floor = floorId,
Ubpid = loginUsers.Data.Ubpid
}, HttpMethod.Post);
result = riskResult.Data;
}
catch (Exception ex)
{
_logger.LogWarning(ex, "GetRiskMapInfo接口出错");
}
return result;
}
}
}
Loading…
Cancel
Save