From 23a5ea20ee0dfd82433de287b569aa94f339331d Mon Sep 17 00:00:00 2001 From: xingheng Date: Tue, 21 Oct 2025 09:27:05 +0800 Subject: [PATCH] =?UTF-8?q?bug=20#10021=EF=BC=8C=E5=B9=B3=E8=A1=8C?= =?UTF-8?q?=E7=94=B5=E7=BC=86=E4=B8=8E=E5=85=B6=E4=BB=96=E4=BD=8D=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ec_CircuitBreaker/ec_CircuitBreakerBLL.cs | 5 +- .../ec_CircuitBreakerEntity.cs | 232 +++++++++--------- .../ec_drawing_file/ec_drawing_fileBLL.cs | 131 +++++----- .../ZZDT_EC/ec_enginedata/ec_enginedataBLL.cs | 27 +- .../ec_enginedata_propertyService.cs | 4 + .../Learun.Cache.Redis/CacheByRedis.cs | 4 +- 6 files changed, 210 insertions(+), 193 deletions(-) diff --git a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_CircuitBreaker/ec_CircuitBreakerBLL.cs b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_CircuitBreaker/ec_CircuitBreakerBLL.cs index 57f5d780..21e4cc7e 100644 --- a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_CircuitBreaker/ec_CircuitBreakerBLL.cs +++ b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_CircuitBreaker/ec_CircuitBreakerBLL.cs @@ -334,7 +334,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC addEnginedata.EngineDataID = BreakerID; addEnginedata.ObjectTypeID = ec_objtype.ObjectTypeID; - addEnginedata.TagNumber = entity.Name; + addEnginedata.TagNumber = entity.Name; //entity.Tag.TagNumber addEnginedata.CaseID = "0"; SqlSugarHelper.Db.Insertable(addEnginedata).AS(tagTbName).ExecuteCommand(); @@ -352,7 +352,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC #region prop var propBll = new ec_enginedata_propertyBLL(); //属性还是要去存enginedata_prop表 - var TagProps = propBll.ConvertPropToEngineProp(ProjectId, ec_objtype.ObjectTypeID, addEnginedata.EngineDataID, entity); + var TagProps = entity.Tag.EngineDataProperty; + //propBll.ConvertPropToEngineProp(ProjectId, ec_objtype.ObjectTypeID, addEnginedata.EngineDataID, entity); propBll.SaveEngineProp(ProjectId, TagProps); diff --git a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_CircuitBreaker/ec_CircuitBreakerEntity.cs b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_CircuitBreaker/ec_CircuitBreakerEntity.cs index 312a31cf..4b2e919c 100644 --- a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_CircuitBreaker/ec_CircuitBreakerEntity.cs +++ b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_CircuitBreaker/ec_CircuitBreakerEntity.cs @@ -15,31 +15,31 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC [SugarTable(TableName = "ec_CircuitBreaker")] public class ec_CircuitBreakerEntity { - /// - /// 生成需要的属性去存储到ec enginedata property - /// - /// - public static List InitEngProp(ec_CircuitBreakerEntity entity) - { - List res = new List(); - //entity.CB_Type - ec_enginedata_propertyEntity newProp = new ec_enginedata_propertyEntity() - { - //CaseID = "0", - EngineDataID = entity.EngineerDataID, - PropertyName = "输入/输出", - PropertyValue = entity.CB_Type, + ///// + ///// 生成需要的属性去存储到ec enginedata property + ///// + ///// + //public static List InitEngProp(ec_CircuitBreakerEntity entity) + //{ + // List res = new List(); + // //entity.CB_Type + // ec_enginedata_propertyEntity newProp = new ec_enginedata_propertyEntity() + // { + // //CaseID = "0", + // EngineDataID = entity.EngineerDataID, + // PropertyName = "输入/输出", + // PropertyValue = entity.CB_Type, - }; - res.Add(newProp); + // }; + // res.Add(newProp); - newProp.Create(); + // newProp.Create(); - return res; - } + // return res; + //} #region 实体成员 /// - /// 分电箱的Id(不在Enginedata_rel中存储) + /// 分电箱的enginedata Id /// /// public string PDBId { get; set; } @@ -77,7 +77,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC /// - /// 目前只有在本表里有,不会在表里出现对应的记录 + /// 因为开关也是在ec_enginedata里存一份的,所以这个是对应的ec_enginedata的ID /// /// [SugarColumn(IsPrimaryKey = true)] @@ -133,114 +133,114 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC #region 扩展字段 - /// - /// 是否需要起动器 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public int? NeedStarter { get; set; } - /// - /// 起动类型 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public string StartType { get; set; } - /// - /// 顺序起动分组结果 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public string SequentialStartGroup { get; set; } - /// - /// 是否带交流电流表 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public int? ACAmmeter { get; set; } - /// - /// 起动方式 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public string StartModel { get; set; } - /// - /// 可逆 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public int? REV { get; set; } - /// - /// 是否自动起动 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public int? AutoStart { get; set; } - /// - /// 是否带运行时间表 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public int? RHM { get; set; } - /// - /// 欠压方式 - /// - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public string UVMode { get; set; } + ///// + ///// 是否需要起动器 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public int? NeedStarter { get; set; } + ///// + ///// 起动类型 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public string StartType { get; set; } + ///// + ///// 顺序起动分组结果 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public string SequentialStartGroup { get; set; } + ///// + ///// 是否带交流电流表 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public int? ACAmmeter { get; set; } + ///// + ///// 起动方式 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public string StartModel { get; set; } + ///// + ///// 可逆 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public int? REV { get; set; } + ///// + ///// 是否自动起动 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public int? AutoStart { get; set; } + ///// + ///// 是否带运行时间表 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public int? RHM { get; set; } + ///// + ///// 欠压方式 + ///// + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public string UVMode { get; set; } - /// - /// GUFO里有 - /// - [SugarColumn(IsIgnore = true)] - public string Relay_Type { get; set; } = ""; - /// - /// GUFO里有 - /// - [SugarColumn(IsIgnore = true)] - public double? Delay_Time { get; set; } = 0.0; + ///// + ///// GUFO里有 + ///// + //[SugarColumn(IsIgnore = true)] + //public string Relay_Type { get; set; } = ""; + ///// + ///// GUFO里有 + ///// + //[SugarColumn(IsIgnore = true)] + //public double? Delay_Time { get; set; } = 0.0; - /// - /// GUFO里有 - /// - [SugarColumn(IsIgnore = true)] - public string Power_Opening { get; set; } = ""; + ///// + ///// GUFO里有 + ///// + //[SugarColumn(IsIgnore = true)] + //public string Power_Opening { get; set; } = ""; - /// - /// GUFO里有 - /// - [SugarColumn(IsIgnore = true)] - public string Power_Closing { get; set; } = ""; + ///// + ///// GUFO里有 + ///// + //[SugarColumn(IsIgnore = true)] + //public string Power_Closing { get; set; } = ""; - /// - /// 相数 - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public int Phase { get; set; } + ///// + ///// 相数 + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public int Phase { get; set; } - /// - /// 额定电压 - /// - [SugarColumn(IsIgnore = true)] - [AttrInEnginePropTable] - public string Rated_Voltage { get; set; } = ""; + ///// + ///// 额定电压 + ///// + //[SugarColumn(IsIgnore = true)] + //[AttrInEnginePropTable] + //public string Rated_Voltage { get; set; } = ""; /// diff --git a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_drawing_file/ec_drawing_fileBLL.cs b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_drawing_file/ec_drawing_fileBLL.cs index 23ac39a8..f2b156e9 100644 --- a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_drawing_file/ec_drawing_fileBLL.cs +++ b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_drawing_file/ec_drawing_fileBLL.cs @@ -813,13 +813,13 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC #region shared var allAnnexesFile = Db.Queryable().ToList(); #endregion - #region resource数据 - var resourceTypeAll = objectTypeBll.GetList("{ProjectId:\"" + sourceProject.ProjectId + "\"}").ToList(); - var sourceTags = ec_enginedataService.GetListSingleTable(sourceProject.ProjectId, null); - var sourceCables = Db.Queryable().AS($"ec_cable_{sourceProject.ProjectIndex}").ToList(); + #region source数据 + var sourceTypeAll = objectTypeBll.GetList("{ProjectId:\"" + sourceProject.ProjectId + "\"}").ToDictionary(x => x.ObjectTypeID, x => x); + var sourceTags = ec_enginedataService.GetListSingleTable(sourceProject.ProjectId, null).ToDictionary(x => x.EngineDataID, x => x); + var sourceCables = Db.Queryable().AS($"ec_cable_{sourceProject.ProjectIndex}").ToList().ToDictionary(x => x.EngineerDataID, x => x); var sourceCableSets = Db.Queryable().AS($"ec_Cable_Set_{sourceProject.ProjectIndex}").ToList(); var sourceCableWires = Db.Queryable().AS($"ec_Cable_Set_Wire_{sourceProject.ProjectIndex}").ToList(); - var sourcePanelAll = Db.Queryable().AS($"ec_Panel_{sourceProject.ProjectIndex}").ToList(); + var sourcePanelAll = Db.Queryable().AS($"ec_Panel_{sourceProject.ProjectIndex}").ToList().ToDictionary(x => x.EngineerDataID, x => x); var sourceStripAll = Db.Queryable().AS($"ec_Panel_Strip_{sourceProject.ProjectIndex}").ToList(); var sourceTermAll = Db.Queryable().AS($"ec_Panel_Strip_Term_{sourceProject.ProjectIndex}").ToList(); var sourceChAll = Db.Queryable().AS($"ec_Panel_Channel_{sourceProject.ProjectIndex}").ToList(); @@ -856,9 +856,9 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC var targetStageDropDown = targetDropDown.FirstOrDefault(x => x.DataItemCode == GlobalObject.enumlist_DrawingStage); var targetStages = targetDropDownDetail.Where(x => x.DataItemID == targetStageDropDown.DataItemID).OrderBy(x => x.OrderID).ToList(); - var targetTypeAll = objectTypeBll.GetList("{ProjectId:\"" + ProjectId + "\"}").ToList(); + var targetTypeAll = objectTypeBll.GetList("{ProjectId:\"" + ProjectId + "\"}").ToList().ToDictionary(x => x.FullPathCN, x => x); var TargetDrawingFile = drawingBll.GetList("{ProjectId:\"" + ProjectId + "\"}").ToList(); - var targetTags = ec_enginedataService.GetListSingleTable(ProjectId, null); + var targetTags = ec_enginedataService.GetListSingleTable(ProjectId, null).ToDictionary(x => x.TagNumber.ToUpper(), x => x); var targetConnRelType = Db.Queryable().AS($"ec_reltype_{targetProject.ProjectIndex}").ToList().FirstOrDefault(x => x.RelType == enum_RelType.设备_电缆); if (targetConnRelType == null) { @@ -990,36 +990,36 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC if (resourcePixelList != null && resourcePixelList.Count() > 0)//不包含deleteflg的 { //获取拷贝图纸所有的工程数据ID - List sourceTagsOnDrawing = resourcePixelList.Select(x => x.EngineDataID).Distinct().ToList(); + List sourceTagIdsOnDrawing = resourcePixelList.Select(x => x.EngineDataID).Distinct().ToList(); //提前处理下originID,免的rel里面有问题 foreach (var sourceTag in sourceTags) { - sourceTag.originId = sourceTag.EngineDataID; + sourceTag.Value.originId = sourceTag.Value.EngineDataID; } - foreach (var oldSourceTagId in sourceTagsOnDrawing) + foreach (var sourceTagIdOnDrawing in sourceTagIdsOnDrawing) { //获取拷贝图纸工程数据实体,由于EngineDataID经常会改变,这里用originid保险点 - var sourceTag = sourceTags.FirstOrDefault(x => x.originId == oldSourceTagId); + sourceTags.TryGetValue(sourceTagIdOnDrawing, out ec_enginedataEntity sourceTag); if (sourceTag == null) { - resourcePixelList.RemoveAll(x => x.EngineDataID == oldSourceTagId); + resourcePixelList.RemoveAll(x => x.EngineDataID == sourceTagIdOnDrawing); continue;//无效的pixel,下一个位号 } //sourceTag.originId = oldSourceTagId; //对象类型ID根据对象类型库的完整路径(中文)判断。 - ec_objecttypeEntity resourceType = resourceTypeAll.FirstOrDefault(x => x.ObjectTypeID == sourceTag.ObjectTypeID); - if (resourceType != null) + sourceTypeAll.TryGetValue(sourceTag.ObjectTypeID, out ec_objecttypeEntity sourceType); + if (sourceType != null) { //对象类型的匹配 - ec_objecttypeEntity curObjectTypeData = targetTypeAll.FirstOrDefault(x => x.FullPathCN == resourceType.FullPathCN); + targetTypeAll.TryGetValue(sourceType.FullPathCN, out ec_objecttypeEntity curObjectTypeData); if (curObjectTypeData != null) { sourceTag.ObjectTypeID = curObjectTypeData.ObjectTypeID;//新的对象类型ID //会影响sourceTags这个原始集合 #region enginedata //判断当前项目中工程数据是否存在 - ec_enginedataEntity targetTagWithSameName = targetTags.FirstOrDefault(x => x.TagNumber.ToUpper() == sourceTag.TagNumber.ToUpper()); + targetTags.TryGetValue(sourceTag.TagNumber.ToUpper(), out ec_enginedataEntity targetTagWithSameName); if (targetTagWithSameName != null) { //如果重复,位号 = 原来位号 + from + 原项目名称 @@ -1077,7 +1077,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC tagRel.RelTypeID = targetConnRelType.RelTypeID; //ID2 //这个时候的ID2无法从 targetTags 里查到,因为id可能已经变了 - var otherTag = sourceTags.FirstOrDefault(x => x.originId == tagRel.RelEngineData2ID);//非电缆的 + sourceTags.TryGetValue(tagRel.RelEngineData2ID, out var otherTag);//非电缆的 if (otherTag != null) { if (otherTag.originId != otherTag.EngineDataID) @@ -1086,7 +1086,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC } else { - var targetTagNumber = targetTags.FirstOrDefault(x => x.TagNumber.ToUpper() == otherTag.TagNumber.ToUpper()); + targetTags.TryGetValue(otherTag.TagNumber.ToUpper(), out var targetTagNumber); //只有目标项目里面没有这个设备才去新建,给新ID,不然还是给目标项目的ID if (targetTagNumber == null) { @@ -1116,7 +1116,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC tagRel.RelTypeID = targetConnRelType.RelTypeID; //ID2 //这个时候的ID2无法从 targetTags 里查到,因为id可能已经变了 - var otherTag = sourceTags.FirstOrDefault(x => x.originId == tagRel.RelEngineData1ID); + sourceTags.TryGetValue(tagRel.RelEngineData1ID, out var otherTag); if (otherTag != null) { if (otherTag.originId != otherTag.EngineDataID) @@ -1125,7 +1125,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC } else { - var targetTagNumber = targetTags.FirstOrDefault(x => x.TagNumber.ToUpper() == otherTag.TagNumber.ToUpper()); + targetTags.TryGetValue(otherTag.TagNumber.ToUpper(), out var targetTagNumber); //只有目标项目里面没有这个设备才去新建,给新ID,不然还是给目标项目的ID if (targetTagNumber == null) { @@ -1177,12 +1177,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC addPropertyList.Add(property); } } - #endregion + #endregion #region CABLE,SET,WIRE //cable //set //wire - var sourceCable = sourceCables.FirstOrDefault(x => x.EngineerDataID == sourceTag.originId); + sourceCables.TryGetValue(sourceTag.originId, out ec_CableEntity sourceCable); if (sourceCable != null) { @@ -1233,7 +1233,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC //STRIP //CHANNEL //TERM - var sourcePanel = sourcePanelAll.FirstOrDefault(x => x.EngineerDataID == sourceTag.originId); + sourcePanelAll.TryGetValue(sourceTag.originId, out var sourcePanel); if (sourcePanel != null) { @@ -1247,7 +1247,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC foreach (var sourceStrip in sourceStrips) { var sourceTerms = sourceTermAll.Where(x => x.StripID == sourceStrip.StripID).ToList(); - var sourceCHs = sourceChAll.Where(x => x.StripID == sourceStrip.StripID).ToList(); + var sourceCHs = sourceChAll.Where(x => x.StripID == sourceStrip.StripID).ToList().ToDictionary(x => x.ChannelID, x => x); sourceStrip.Create(); sourceStrip.PanelID = sourcePanel.PanelID; @@ -1257,9 +1257,9 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC { foreach (var ch in sourceCHs) { - ch.Create(); - ch.StripID = sourceStrip.StripID; - addChList.Add(ch); + ch.Value.Create(); + ch.Value.StripID = sourceStrip.StripID; + addChList.Add(ch.Value); } } if (sourceTerms != null) @@ -1271,7 +1271,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC if (term.ChannelID != "-1") { //有通道 - var existCh = sourceCHs.FirstOrDefault(x => x.ChannelID == term.ChannelID); + sourceCHs.TryGetValue(term.ChannelID, out var existCh); if (existCh != null) { term.ChannelID = existCh.ChannelID; @@ -1296,57 +1296,56 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC //已有的,单纯属性覆盖就行 #region property //获取对应的工程数据属性 - var sourceTagProps = PropServ.GetTagPropById(item.ProjectId, sourceTag.originId).ToList(); - var targetTagProps = PropServ.GetTagPropById(ProjectId, sourceTag.EngineDataID).ToList(); + var sourceTagProps = PropServ.GetTagPropById(item.ProjectId, sourceTag.originId); + var targetTagProps = PropServ.GetTagPropById(ProjectId, sourceTag.EngineDataID).ToDictionary(x => x.PropertyName, x => x); var updateList = new List(); var hisInsertList = new List(); - if (sourceTagProps != null && sourceTagProps.Count > 0) + foreach (var property in sourceTagProps) { - foreach (var property in sourceTagProps) + targetTagProps.TryGetValue(property.PropertyName, out var tarProp); + if (tarProp != null) { - var tarProp = targetTagProps.FirstOrDefault(x => x.PropertyName == property.PropertyName); - if (tarProp != null) + + + var propHis = new ec_enginedata_propertyhisEntity { + PropertyName = tarProp.PropertyName, + PropertyValue = tarProp.PropertyValue, // 老值 + EngineDataID = tarProp.EngineDataID + }; + propHis.Create(); + hisInsertList.Add(propHis); + //已有属性 + tarProp.PropertyValue = property.PropertyValue; //新值 + tarProp.MeasuringUnit = property.MeasuringUnit; + tarProp.UpdateTime = System.DateTime.Now; + tarProp.UpdateUserID = userInfo.userId; - - var propHis = new ec_enginedata_propertyhisEntity - { - PropertyName = tarProp.PropertyName, - PropertyValue = tarProp.PropertyValue, // 老值 - EngineDataID = tarProp.EngineDataID - }; - propHis.Create(); - hisInsertList.Add(propHis); - //已有属性 - tarProp.PropertyValue = property.PropertyValue; //新值 - tarProp.MeasuringUnit = property.MeasuringUnit; - tarProp.UpdateTime = System.DateTime.Now; - tarProp.UpdateUserID = userInfo.userId; - - updateList.Add(tarProp); - //Db.Updateable(tarProp).AS($"ec_enginedata_property_{targetProject.ProjectIndex}").ExecuteCommand(); - //Db.Insertable(propHis).AS($"ec_enginedata_propertyhis_{targetProject.ProjectIndex}").ExecuteCommand(); - } - else - { - property.EngineDataID = sourceTag.EngineDataID;//target里的已经存在的id了 - property.Create(); - property.UpdateTime = null; - property.UpdateUserID = null; - addPropertyList.Add(property); - } - - - //要和现有的比一下,没有的就插入,有的就更新 + updateList.Add(tarProp); + //Db.Updateable(tarProp).AS($"ec_enginedata_property_{targetProject.ProjectIndex}").ExecuteCommand(); + //Db.Insertable(propHis).AS($"ec_enginedata_propertyhis_{targetProject.ProjectIndex}").ExecuteCommand(); } + else + { + property.EngineDataID = sourceTag.EngineDataID;//target里的已经存在的id了 + property.Create(); + property.UpdateTime = null; + property.UpdateUserID = null; + addPropertyList.Add(property); + } + + + //要和现有的比一下,没有的就插入,有的就更新 } + if (updateList.Count > 0) { Db.Updateable(updateList) .AS($"ec_enginedata_property_{targetProject.ProjectIndex}") - .UpdateColumns(x => new { + .UpdateColumns(x => new + { x.PropertyValue, x.MeasuringUnit, x.UpdateTime, @@ -1385,7 +1384,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC else { - msg = sourceTag.TagNumber + $"对象类型不匹配!。老项目为{resourceType.FullPathCN},新项目则没有该类型。"; + msg = sourceTag.TagNumber + $"对象类型不匹配!。老项目为{sourceType.FullPathCN},新项目则没有该类型。"; log.Error(msg); } diff --git a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_enginedata/ec_enginedataBLL.cs b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_enginedata/ec_enginedataBLL.cs index 210cdc43..c9cdf47f 100644 --- a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_enginedata/ec_enginedataBLL.cs +++ b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_enginedata/ec_enginedataBLL.cs @@ -1485,7 +1485,6 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC /// 工程数据实体 public void UpdatePixelAndProp(string projectId, ec_enginedataEntity entity) { - var caseID = "0";//entity.CaseID; var ec_relDataBLL = new ec_enginedata_relBLL(); Db.BeginTran(); try @@ -1511,8 +1510,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC var reldataTableName = TableName(ProjectEntity.ProjectIndex.ToString()); var lookupBll = new ec_REFLOOKUPTABLEBLL(); - - var curEnginedata = GetList(("{\"ProjectId\":\"" + projectId + "\",\"TagNumber\":\"" + entity.TagNumber + "\"}")).FirstOrDefault(); + var allTags = Db.Queryable().AS(TableName(projectId)).ToList(); + var curEnginedata = allTags.FirstOrDefault(x => x.TagNumber == entity.TagNumber); string engineDataID = ""; @@ -1575,7 +1574,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC var cableSystemObj = entity.EngineDataProperty.FirstOrDefault(x => x.PropertyName == GlobalObject.propName_System); string systemNameAfterDealWith = string.Empty; - var cableSystem =string.Empty; + var cableSystem = string.Empty; var topDataItemDetailIDofDwg = string.Empty; var topDataItemDetailIDofEng = string.Empty; if (cableSystemObj != null) @@ -1586,7 +1585,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC //获取图纸系统的最上级ID topDataItemDetailIDofDwg = GetTopParentDataItemDetailByID(dataitemdetailTableName, dwgObj.DrawingSystem); //获取位号系统的最上级ID - topDataItemDetailIDofEng= GetTopParentDataItemDetailByID(dataitemdetailTableName, cableSystem); + topDataItemDetailIDofEng = GetTopParentDataItemDetailByID(dataitemdetailTableName, cableSystem); if (topDataItemDetailIDofDwg == topDataItemDetailIDofEng && !string.IsNullOrEmpty(dwgObj.DrawingSystem)) { //可以修改 @@ -1620,8 +1619,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC //var cableSystem = cableSystemObj == null ? "" : systems.FirstOrDefault(x => x.DataItemName == cableSystemObj.PropertyValue)?.DataItemDetailID; //if (cableSystem != null) //{ - - + + //} } else @@ -1659,6 +1658,20 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC { entity.EngineDataProperty = new List(); } + else + { + var parallelCable = entity.EngineDataProperty.FirstOrDefault(X => X.PropertyName == GlobalObject.propName_parallelCableList && !string.IsNullOrEmpty(X.PropertyValue)); + if (parallelCable != null) + { + var parallelCableNames = parallelCable.PropertyValue.ToUpper().Split(','); + var duplicatedTag = allTags.Where(x => parallelCableNames.Contains(x.TagNumber.ToUpper())).ToList(); + if (duplicatedTag != null || duplicatedTag.Count > 0) + { + throw new Exception("平行电缆中存在和已有其他电缆的名字重复。" + string.Join(",", duplicatedTag.Select(x => x.TagNumber))); + } + + } + } entity = lookupBll.ApplyLookup(projectId, entity, true); foreach (var prop in entity.EngineDataProperty. diff --git a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_enginedata_property/ec_enginedata_propertyService.cs b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_enginedata_property/ec_enginedata_propertyService.cs index 1583f1cf..249541d6 100644 --- a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_enginedata_property/ec_enginedata_propertyService.cs +++ b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ZZDT_EC/ec_enginedata_property/ec_enginedata_propertyService.cs @@ -45,6 +45,10 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC //.WhereIF(!string.IsNullOrEmpty(CaseID), (a, b) => a.CaseID == CaseID) .WhereIF(EngineDataIDs != null && EngineDataIDs.Length > 0, (a, b) => EngineDataIDs.Contains(a.EngineDataID) && a.PropertyName != "HKSK_POSITION_NUM").ToList(); + if (list == null) + { + list = new List(); + } return list; } catch (Exception ex) diff --git a/Learun.Framework.Module/Learun.Cache/Learun.Cache.Redis/CacheByRedis.cs b/Learun.Framework.Module/Learun.Cache/Learun.Cache.Redis/CacheByRedis.cs index 826accc9..210a624a 100644 --- a/Learun.Framework.Module/Learun.Cache/Learun.Cache.Redis/CacheByRedis.cs +++ b/Learun.Framework.Module/Learun.Cache/Learun.Cache.Redis/CacheByRedis.cs @@ -21,8 +21,8 @@ namespace Learun.Cache.Redis /// 24 9 4新增。 /// /// - /// - /// + /// redis的缓存key + /// 委托,一般是key里没有的时候,去执行一次db查询 /// /// ///