修改部分接口

pull/28/head
刘鑫 2 months ago
parent 0a514c21e0
commit 3fde17e668
  1. 52
      WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/RequestDto/SunPlaceBoardWorkOrderReqDto.cs
  2. 76
      WeiCloud.Fusion/Common.SharedService/Common.Shared.Application/SafetyFirePro/ResponseDto/SunPalaceBoardResDto.cs
  3. 14
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.API/Controllers/ShenZhouShengAn/SunPalaceBoardSafetyController.cs
  4. 9
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/ISunPalaceBoardSafetyService.cs
  5. 65
      WeiCloud.Fusion/ThirdPartyServices/ThirdPartyServices.DomainService/ShenZhouShengAn/SunPalaceBoardSafetyService.cs

@ -66,4 +66,56 @@ namespace Common.Shared.Application.SafetyFirePro.RequestDto
/// </summary> /// </summary>
public string? BxDeptCode { get; set; } public string? BxDeptCode { get; set; }
} }
/// <summary>
/// 作业任务查询参数实体类
/// </summary>
public class WorkTaskQueryParamsDto
{
/// <summary>
/// 页数
/// </summary>
/// <example>1</example>
/// <remarks>必填项</remarks>
[JsonPropertyName("page")]
public int? Page { get; set; }
/// <summary>
/// 每页数据数量
/// </summary>
/// <example>10</example>
/// <remarks>不传则默认为10</remarks>
[JsonPropertyName("page_size")]
public int? PageSize { get; set; }
/// <summary>
/// 作业状态
/// </summary>
/// <example>3</example>
/// <remarks>1:待审批, 2:待作业前检查, 3:作业中, 4:抽作业前检查, 6:作业结束, 7:延期结束, 8:超时结束, 11:审批不通过, 12:作业中止, 13:强行结束</remarks>
[JsonPropertyName("status")]
public string? Status { get; set; }
/// <summary>
/// 作业单位部门id
/// </summary>
/// <example>8888</example>
[JsonPropertyName("branch_id")]
public int? BranchId { get; set; }
/// <summary>
/// 作业活动所在区域id
/// </summary>
/// <example>8888</example>
[JsonPropertyName("region_id")]
public int? RegionId { get; set; }
/// <summary>
/// ubpid参数
/// </summary>
/// <example>"ubpid"</example>
/// <remarks>必填项</remarks>
[JsonPropertyName("ubpid")]
public string Ubpid { get; set; }
}
} }

@ -433,11 +433,14 @@ namespace Common.Shared.Application.SafetyFirePro.ResponseDto
[JsonConverter(typeof(FlexibleCenterConverter))] [JsonConverter(typeof(FlexibleCenterConverter))]
public List<List<double>> Center { get; set; } public List<List<double>> Center { get; set; }
[JsonPropertyName("gaodu_x")] //[JsonPropertyName("gaodu_x")]
public int GaoduX { get; set; } //public int? GaoduX { get; set; }
[JsonPropertyName("gaodu_y")] //[JsonPropertyName("gaodu_y")]
public int GaoduY { get; set; } //public int? GaoduY { get; set; }
[JsonPropertyName("gaodu")]
public int? Gaodu { get; set; }
/// <summary> /// <summary>
/// 色块id /// 色块id
@ -815,21 +818,76 @@ namespace Common.Shared.Application.SafetyFirePro.ResponseDto
public sealed class FlexiblePointConverter : JsonConverter<PointDto> public sealed class FlexiblePointConverter : JsonConverter<PointDto>
{ {
public override PointDto Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override PointDto Read(
ref Utf8JsonReader reader,
Type typeToConvert,
JsonSerializerOptions options)
{ {
// 解析JSON节点,避免直接操作reader导致位置偏移
using var doc = JsonDocument.ParseValue(ref reader); using var doc = JsonDocument.ParseValue(ref reader);
var root = doc.RootElement; var root = doc.RootElement;
// 1. 处理「对象格式」(如 {"x":609.5,"y":309.703125})
if (root.ValueKind == JsonValueKind.Object) if (root.ValueKind == JsonValueKind.Object)
return new PointDto { X = root.GetProperty("x").GetDouble(), Y = root.GetProperty("y").GetDouble() }; {
// 兼容属性缺失的异常场景(避免崩溃,返回默认值)
bool hasX = root.TryGetProperty("x", out var xElement);
bool hasY = root.TryGetProperty("y", out var yElement);
if (hasX && hasY && TryParseDouble(xElement, out var x) && TryParseDouble(yElement, out var y))
{
return new PointDto { X = x, Y = y };
}
return default;
}
// 2. 处理「数组格式」(含数字数组[338,129.203125]和字符串数组["116.079126","39.927465"])
if (root.ValueKind == JsonValueKind.Array && root.GetArrayLength() >= 2) if (root.ValueKind == JsonValueKind.Array && root.GetArrayLength() >= 2)
return new PointDto { X = root[0].GetDouble(), Y = root[1].GetDouble() }; {
var xElement = root[0]; // 数组第一个元素(x值)
var yElement = root[1]; // 数组第二个元素(y值)
// 解析x和y(兼容数字/字符串类型)
if (TryParseDouble(xElement, out var x) && TryParseDouble(yElement, out var y))
{
return new PointDto { X = x, Y = y };
}
return default; return default;
} }
public override void Write(Utf8JsonWriter writer, PointDto value, JsonSerializerOptions options) // 3. 其他未定义格式(返回默认PointDto)
=> writer.WriteStartObject(); // 如需写回再实现 return default;
}
public override void Write(
Utf8JsonWriter writer,
PointDto value,
JsonSerializerOptions options)
{
// 序列化时统一按「对象格式」输出(与实体类定义一致,便于后续使用)
writer.WriteStartObject();
writer.WriteNumber("x", value.X);
writer.WriteNumber("y", value.Y);
writer.WriteEndObject();
}
#region 私有辅助方法:统一处理JsonElement(数字/字符串)转double
/// <summary>
/// 兼容「数字类型」和「字符串类型」的JsonElement,解析为double
/// 例:116.079126 → 116.079126;"116.079126" → 116.079126
/// </summary>
private bool TryParseDouble(JsonElement element, out double result)
{
return element.ValueKind switch
{
// 若元素是数字,直接获取double
JsonValueKind.Number => element.TryGetDouble(out result),
// 若元素是字符串,尝试解析为double
JsonValueKind.String => double.TryParse(element.GetString(), out result),
// 其他类型(如布尔值),解析失败
_ => (result = 0, false).Item2
};
}
#endregion
} }
} }

@ -1,4 +1,5 @@
using Common.Shared.Application.SafetyFirePro.ResponseDto; using Common.Shared.Application.SafetyFirePro.RequestDto;
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Text.Json; using System.Text.Json;
@ -65,5 +66,16 @@ namespace ThirdPartyServices.API.Controllers.ShenZhouShengAn
{ {
return await _secSituationService.GetRiskMapInfo(floorId); return await _secSituationService.GetRiskMapInfo(floorId);
} }
/// <summary>
/// 获得危险作业(施工)数据
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("ledger")]
public async Task<object> GetLedger(WorkTaskQueryParamsDto dto)
{
return await _secSituationService.GetLedger(dto);
}
} }
} }

@ -1,14 +1,11 @@
using Common.Shared.Application.SafetyFirePro.ResponseDto; using Common.Shared.Application.SafetyFirePro.RequestDto;
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using System.Text.Json; using System.Text.Json;
namespace ThirdPartyServices.DomainService.ShenZhouShengAn namespace ThirdPartyServices.DomainService.ShenZhouShengAn
{ {
public interface ISunPalaceBoardSafetyService public interface ISunPalaceBoardSafetyService
{ {
//Task<ApiResult<List<SecurityHiddenDangerHighRiskAreaResDto>>> GetHiddenDangerTrend(SecSituationQueryDto dto);
//Task<ApiResult<List<IdCardAlarmResDto>>> GetIdCardAlarmEchart();
Task<DangerRiskAreaResDto> GetProductionRiskEchart(); Task<DangerRiskAreaResDto> GetProductionRiskEchart();
/// <summary> /// <summary>
@ -27,6 +24,6 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
Task<DangerInfoRootResDto> GetDangerInfos(string? regionId, string? pRegionId); Task<DangerInfoRootResDto> GetDangerInfos(string? regionId, string? pRegionId);
//Task<ApiResult<AlarmInfoResultPageModelV02>> GetUnAlarmInfoList(AlarmEventEchartQueryDto dto); Task<object> GetLedger(WorkTaskQueryParamsDto dto);
} }
} }

@ -1,4 +1,5 @@
using Common.Shared.Application.SafetyFirePro.ResponseDto; using Common.Shared.Application.SafetyFirePro.RequestDto;
using Common.Shared.Application.SafetyFirePro.ResponseDto;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using MongoDB.Bson.IO; using MongoDB.Bson.IO;
@ -297,5 +298,67 @@ namespace ThirdPartyServices.DomainService.ShenZhouShengAn
return result; return result;
} }
/// <summary>
/// 获得危险作业(施工)数据
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<object> GetLedger(WorkTaskQueryParamsDto dto)
{
var result = new RootReqDto();
try
{
//获取token
var token = await _tokenProviderService.GetTokenAsync(_configuration["ThirdParty:SzdunanCode"]!);
if (string.IsNullOrWhiteSpace(token))
{
_logger.LogWarning("GetProductionRiskEchart接口获取token失败");
return result;
}
//获取用户配置
HttpClientResult<LoginUsersConfiguration> loginUsers = await _tokenProviderService.GetUserConfiguration(token);
if (loginUsers.Code == "Error")
{
_logger.LogWarning("GetProductionRiskEchart接口获取用户配置失败");
return result;
}
//获取单位信息
HttpClientResult<BranchResDto> branchs = await _tokenProviderService.GetBranchPermissions(token, loginUsers.Data.Uid);
if (branchs.Code == "Error")
{
_logger.LogWarning("GetProductionRiskEchart接口获取单位信息失败");
return result;
}
dto.Ubpid = loginUsers.Data.Ubpid.ToString();
dto.BranchId = branchs.Data.BranchPermissionIds[0];
HttpClientResult<object> riskResult = await _tokenProviderService
.SendAndParseAsync<WorkTaskQueryParamsDto, HttpClientResult<object>>(
"https://zrh.szdunan.cn/v1/api/ticket/safe/ledger",
token, dto, HttpMethod.Post);
if (riskResult != null && riskResult.Data != null && riskResult.Data.ToString()!.Length > 10)
{
RootReqDto httpClientResult = JsonSerializer.Deserialize<RootReqDto>(riskResult.Data.ToString()!)!;
if (httpClientResult != null)
{
result = httpClientResult;
}
}
}
catch (Exception ex)
{
_logger.LogWarning(ex, $"GetRiskMapInfo接口出错");
}
return result;
}
} }
} }
Loading…
Cancel
Save