From 284ccebf741c7d182cc54be40a846e24f3e00b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E7=9D=BF?= <774114798@qq.com> Date: Mon, 9 Dec 2024 14:44:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E5=80=BC=E4=BF=A1=E6=81=AF=E8=A7=A3?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IProtectionSettingAppService.cs | 7 ++++ .../ProtectionSettingAppService.cs | 41 +++++++++++++++++-- .../ProtectionSettingDto/ImDeviceDzOutput.cs | 1 + 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionSettingInfo/IProtectionSettingAppService.cs b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionSettingInfo/IProtectionSettingAppService.cs index 4e44d62..bae8989 100644 --- a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionSettingInfo/IProtectionSettingAppService.cs +++ b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionSettingInfo/IProtectionSettingAppService.cs @@ -18,5 +18,12 @@ namespace YunDa.ISAS.Application.GeneralInformation.SecondaryCircuitInfo /// /// Task>> FindDZDataByEquipmentInfoId(Guid? equipmentInfoId, string dzType); + /// + /// 根据装置获取定值 + /// + /// + /// + /// + RequestResult> GetDzByDeviceAddr(int deviceAddr, int cpuIndex); } } \ No newline at end of file diff --git a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionSettingInfo/ProtectionSettingAppService.cs b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionSettingInfo/ProtectionSettingAppService.cs index 09578ad..dca2f67 100644 --- a/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionSettingInfo/ProtectionSettingAppService.cs +++ b/src/YunDa.Application/YunDa.ISAS.Application/GeneralInformation/ProtectionSettingInfo/ProtectionSettingAppService.cs @@ -134,8 +134,7 @@ namespace YunDa.ISAS.Application.GeneralInformation.ProtectionSettingInfo { var data = _imDeviceDzRepository.GetAllIncluding(t => t.Device,t=>t.DzTypeNavigation).Where(t => t.Device.DeviceAddr == deviceAddr) .Where(t => t.CpuIndex == cpuIndex).OrderBy(t=>t.DzIndex); - - rst.ResultData =ObjectMapper.Map>(data); + rst.ResultData = MapDzPutput(data); rst.Flag = true; } catch (Exception ex) @@ -362,7 +361,8 @@ namespace YunDa.ISAS.Application.GeneralInformation.ProtectionSettingInfo if (true) { var list = dz.Where(t => t.CpuIndex == 9).OrderBy(t=>t.DzIndex); - List imDeviceDzOutputs = ObjectMapper.Map>(list); + // 手动转换为 ImDeviceDzOutput 列表 + List imDeviceDzOutputs = MapDzPutput(list); List redisSystems = imDeviceDzOutputs.Select(t => t.Id).ToList(); await _imDeviceDzRedis.HashSetUpdateManyAsync($"DZ_{dz.Key.ToString("X2")}_System", redisSystems, imDeviceDzOutputs); @@ -370,7 +370,7 @@ namespace YunDa.ISAS.Application.GeneralInformation.ProtectionSettingInfo if (true) { var list = dz.Where(t => t.CpuIndex == 1).OrderBy(t => t.DzIndex); - List imDeviceDzOutputs = ObjectMapper.Map>(list); + List imDeviceDzOutputs = MapDzPutput(list); List redisSystems = imDeviceDzOutputs.Select(t => t.Id).ToList(); await _imDeviceDzRedis.HashSetUpdateManyAsync($"DZ_{dz.Key.ToString("X2")}_User", redisSystems, imDeviceDzOutputs); } @@ -385,5 +385,38 @@ namespace YunDa.ISAS.Application.GeneralInformation.ProtectionSettingInfo } return rst; } + + private List MapDzPutput(IEnumerable list) + { + return list.Select(t => new ImDeviceDzOutput + { + Id = t.Id, + DeviceId = t.DeviceId, + CpuIndex = t.CpuIndex, + DzIndex = t.DzIndex, + DzName = t.DzName, + DzComment = t.DzComment, + DzRange = t.DzRange, + DzMin = t.DzMin, + DzMax = t.DzMax, + DzUnit = t.DzUnit, + DzCoeff = t.DzCoeff, + DzPrecise = t.DzPrecise, + DzUnit1 = t.DzUnit1, + DzCoeff1 = t.DzCoeff1, + DzPrecise1 = t.DzPrecise1, + CtrlWordTypeId = t.CtrlWordTypeId, + DzType = t.DzType, + PUCtgyCode = t.Device.PuctgyCode, // 假设这个字段由某些条件决定 + EnumTypeId = t.EnumTypeId, + DzUnitCvtCoeff = t.DzUnitCvtCoeff, + RelatePtId = t.RelatePtId, + RelateCtId = t.RelateCtId, + ReadOnly = t.ReadOnly, + Hidden = t.Hidden, + DzTypeNavigation = new ImDztypeOutput { /* 映射 ImDztype 到 ImDztypeOutput 的属性 */ }, + Value = (new Random().Next(0, 10)).ToString() // 随机值 + }).ToList(); + } } } diff --git a/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionSettingDto/ImDeviceDzOutput.cs b/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionSettingDto/ImDeviceDzOutput.cs index c2f24c6..1530287 100644 --- a/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionSettingDto/ImDeviceDzOutput.cs +++ b/src/YunDa.Application/YunDa.ISAS.DataTransferObject/GeneralInformation/ProtectionSettingDto/ImDeviceDzOutput.cs @@ -29,6 +29,7 @@ namespace YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionSettingDto public int? DzPrecise1 { get; set; } public int? CtrlWordTypeId { get; set; } public int DzType { get; set; } + public int PUCtgyCode { get; set; } public int? EnumTypeId { get; set; } public double? DzUnitCvtCoeff { get; set; } public string? RelatePtId { get; set; }