bug #10021,平行电缆与其他位号重复

This commit is contained in:
xingheng 2025-10-21 09:27:05 +08:00
parent 9ea7efaeb7
commit 23a5ea20ee
6 changed files with 210 additions and 193 deletions

View File

@ -334,7 +334,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
addEnginedata.EngineDataID = BreakerID; addEnginedata.EngineDataID = BreakerID;
addEnginedata.ObjectTypeID = ec_objtype.ObjectTypeID; addEnginedata.ObjectTypeID = ec_objtype.ObjectTypeID;
addEnginedata.TagNumber = entity.Name; addEnginedata.TagNumber = entity.Name; //entity.Tag.TagNumber
addEnginedata.CaseID = "0"; addEnginedata.CaseID = "0";
SqlSugarHelper.Db.Insertable(addEnginedata).AS(tagTbName).ExecuteCommand(); SqlSugarHelper.Db.Insertable(addEnginedata).AS(tagTbName).ExecuteCommand();
@ -352,7 +352,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#region prop #region prop
var propBll = new ec_enginedata_propertyBLL(); var propBll = new ec_enginedata_propertyBLL();
//属性还是要去存enginedata_prop表 //属性还是要去存enginedata_prop表
var TagProps = propBll.ConvertPropToEngineProp<ec_CircuitBreakerEntity>(ProjectId, ec_objtype.ObjectTypeID, addEnginedata.EngineDataID, entity); var TagProps = entity.Tag.EngineDataProperty;
//propBll.ConvertPropToEngineProp<ec_CircuitBreakerEntity>(ProjectId, ec_objtype.ObjectTypeID, addEnginedata.EngineDataID, entity);
propBll.SaveEngineProp(ProjectId, TagProps); propBll.SaveEngineProp(ProjectId, TagProps);

View File

@ -15,31 +15,31 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
[SugarTable(TableName = "ec_CircuitBreaker")] [SugarTable(TableName = "ec_CircuitBreaker")]
public class ec_CircuitBreakerEntity public class ec_CircuitBreakerEntity
{ {
/// <summary> ///// <summary>
/// 生成需要的属性去存储到ec enginedata property ///// 生成需要的属性去存储到ec enginedata property
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
public static List<ec_enginedata_propertyEntity> InitEngProp(ec_CircuitBreakerEntity entity) //public static List<ec_enginedata_propertyEntity> InitEngProp(ec_CircuitBreakerEntity entity)
{ //{
List<ec_enginedata_propertyEntity> res = new List<ec_enginedata_propertyEntity>(); // List<ec_enginedata_propertyEntity> res = new List<ec_enginedata_propertyEntity>();
//entity.CB_Type // //entity.CB_Type
ec_enginedata_propertyEntity newProp = new ec_enginedata_propertyEntity() // ec_enginedata_propertyEntity newProp = new ec_enginedata_propertyEntity()
{ // {
//CaseID = "0", // //CaseID = "0",
EngineDataID = entity.EngineerDataID, // EngineDataID = entity.EngineerDataID,
PropertyName = "输入/输出", // PropertyName = "输入/输出",
PropertyValue = entity.CB_Type, // PropertyValue = entity.CB_Type,
}; // };
res.Add(newProp); // res.Add(newProp);
newProp.Create(); // newProp.Create();
return res; // return res;
} //}
#region #region
/// <summary> /// <summary>
/// 分电箱的Id(不在Enginedata_rel中存储) /// 分电箱的enginedata Id
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public string PDBId { get; set; } public string PDBId { get; set; }
@ -77,7 +77,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// <summary> /// <summary>
/// 目前只有在本表里有,不会在<see cref="ec_Archive_enginedata"/>表里出现对应的记录 /// 因为开关也是在ec_enginedata里存一份的所以这个是对应的ec_enginedata的ID
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[SugarColumn(IsPrimaryKey = true)] [SugarColumn(IsPrimaryKey = true)]
@ -133,114 +133,114 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#region #region
/// <summary> ///// <summary>
/// 是否需要起动器 ///// 是否需要起动器
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public int? NeedStarter { get; set; } //public int? NeedStarter { get; set; }
/// <summary> ///// <summary>
/// 起动类型 ///// 起动类型
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public string StartType { get; set; } //public string StartType { get; set; }
/// <summary> ///// <summary>
/// 顺序起动分组结果 ///// 顺序起动分组结果
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public string SequentialStartGroup { get; set; } //public string SequentialStartGroup { get; set; }
/// <summary> ///// <summary>
/// 是否带交流电流表 ///// 是否带交流电流表
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public int? ACAmmeter { get; set; } //public int? ACAmmeter { get; set; }
/// <summary> ///// <summary>
/// 起动方式 ///// 起动方式
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public string StartModel { get; set; } //public string StartModel { get; set; }
/// <summary> ///// <summary>
/// 可逆 ///// 可逆
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public int? REV { get; set; } //public int? REV { get; set; }
/// <summary> ///// <summary>
/// 是否自动起动 ///// 是否自动起动
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public int? AutoStart { get; set; } //public int? AutoStart { get; set; }
/// <summary> ///// <summary>
/// 是否带运行时间表 ///// 是否带运行时间表
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public int? RHM { get; set; } //public int? RHM { get; set; }
/// <summary> ///// <summary>
/// 欠压方式 ///// 欠压方式
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public string UVMode { get; set; } //public string UVMode { get; set; }
/// <summary> ///// <summary>
/// GUFO里有 ///// GUFO里有
/// </summary> ///// </summary>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
public string Relay_Type { get; set; } = ""; //public string Relay_Type { get; set; } = "";
/// <summary> ///// <summary>
/// GUFO里有 ///// GUFO里有
/// </summary> ///// </summary>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
public double? Delay_Time { get; set; } = 0.0; //public double? Delay_Time { get; set; } = 0.0;
/// <summary> ///// <summary>
/// GUFO里有 ///// GUFO里有
/// </summary> ///// </summary>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
public string Power_Opening { get; set; } = ""; //public string Power_Opening { get; set; } = "";
/// <summary> ///// <summary>
/// GUFO里有 ///// GUFO里有
/// </summary> ///// </summary>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
public string Power_Closing { get; set; } = ""; //public string Power_Closing { get; set; } = "";
/// <summary> ///// <summary>
/// 相数 ///// 相数
/// </summary> ///// </summary>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public int Phase { get; set; } //public int Phase { get; set; }
/// <summary> ///// <summary>
/// 额定电压 ///// 额定电压
/// </summary> ///// </summary>
[SugarColumn(IsIgnore = true)] //[SugarColumn(IsIgnore = true)]
[AttrInEnginePropTable] //[AttrInEnginePropTable]
public string Rated_Voltage { get; set; } = ""; //public string Rated_Voltage { get; set; } = "";
/// <summary> /// <summary>

View File

@ -813,13 +813,13 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#region shared #region shared
var allAnnexesFile = Db.Queryable<AnnexesFileEntity>().ToList(); var allAnnexesFile = Db.Queryable<AnnexesFileEntity>().ToList();
#endregion #endregion
#region resource数据 #region source数据
var resourceTypeAll = objectTypeBll.GetList("{ProjectId:\"" + sourceProject.ProjectId + "\"}").ToList(); var sourceTypeAll = objectTypeBll.GetList("{ProjectId:\"" + sourceProject.ProjectId + "\"}").ToDictionary(x => x.ObjectTypeID, x => x);
var sourceTags = ec_enginedataService.GetListSingleTable(sourceProject.ProjectId, null); var sourceTags = ec_enginedataService.GetListSingleTable(sourceProject.ProjectId, null).ToDictionary(x => x.EngineDataID, x => x);
var sourceCables = Db.Queryable<ec_CableEntity>().AS($"ec_cable_{sourceProject.ProjectIndex}").ToList(); var sourceCables = Db.Queryable<ec_CableEntity>().AS($"ec_cable_{sourceProject.ProjectIndex}").ToList().ToDictionary(x => x.EngineerDataID, x => x);
var sourceCableSets = Db.Queryable<ec_CableSetEntity>().AS($"ec_Cable_Set_{sourceProject.ProjectIndex}").ToList(); var sourceCableSets = Db.Queryable<ec_CableSetEntity>().AS($"ec_Cable_Set_{sourceProject.ProjectIndex}").ToList();
var sourceCableWires = Db.Queryable<ec_CableSetWireEntity>().AS($"ec_Cable_Set_Wire_{sourceProject.ProjectIndex}").ToList(); var sourceCableWires = Db.Queryable<ec_CableSetWireEntity>().AS($"ec_Cable_Set_Wire_{sourceProject.ProjectIndex}").ToList();
var sourcePanelAll = Db.Queryable<ec_PanelEntity>().AS($"ec_Panel_{sourceProject.ProjectIndex}").ToList(); var sourcePanelAll = Db.Queryable<ec_PanelEntity>().AS($"ec_Panel_{sourceProject.ProjectIndex}").ToList().ToDictionary(x => x.EngineerDataID, x => x);
var sourceStripAll = Db.Queryable<ec_PanelStripEntity>().AS($"ec_Panel_Strip_{sourceProject.ProjectIndex}").ToList(); var sourceStripAll = Db.Queryable<ec_PanelStripEntity>().AS($"ec_Panel_Strip_{sourceProject.ProjectIndex}").ToList();
var sourceTermAll = Db.Queryable<ec_PanelStripTermEntity>().AS($"ec_Panel_Strip_Term_{sourceProject.ProjectIndex}").ToList(); var sourceTermAll = Db.Queryable<ec_PanelStripTermEntity>().AS($"ec_Panel_Strip_Term_{sourceProject.ProjectIndex}").ToList();
var sourceChAll = Db.Queryable<ec_PanelChannelEntity>().AS($"ec_Panel_Channel_{sourceProject.ProjectIndex}").ToList(); var sourceChAll = Db.Queryable<ec_PanelChannelEntity>().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 targetStageDropDown = targetDropDown.FirstOrDefault(x => x.DataItemCode == GlobalObject.enumlist_DrawingStage);
var targetStages = targetDropDownDetail.Where(x => x.DataItemID == targetStageDropDown.DataItemID).OrderBy(x => x.OrderID).ToList(); 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 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<ec_reltypeEntity>().AS($"ec_reltype_{targetProject.ProjectIndex}").ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆); var targetConnRelType = Db.Queryable<ec_reltypeEntity>().AS($"ec_reltype_{targetProject.ProjectIndex}").ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
if (targetConnRelType == null) if (targetConnRelType == null)
{ {
@ -990,36 +990,36 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
if (resourcePixelList != null && resourcePixelList.Count() > 0)//不包含deleteflg的 if (resourcePixelList != null && resourcePixelList.Count() > 0)//不包含deleteflg的
{ {
//获取拷贝图纸所有的工程数据ID //获取拷贝图纸所有的工程数据ID
List<string> sourceTagsOnDrawing = resourcePixelList.Select(x => x.EngineDataID).Distinct().ToList(); List<string> sourceTagIdsOnDrawing = resourcePixelList.Select(x => x.EngineDataID).Distinct().ToList();
//提前处理下originID,免的rel里面有问题 //提前处理下originID,免的rel里面有问题
foreach (var sourceTag in sourceTags) 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保险点 //获取拷贝图纸工程数据实体,由于EngineDataID经常会改变,这里用originid保险点
var sourceTag = sourceTags.FirstOrDefault(x => x.originId == oldSourceTagId); sourceTags.TryGetValue(sourceTagIdOnDrawing, out ec_enginedataEntity sourceTag);
if (sourceTag == null) if (sourceTag == null)
{ {
resourcePixelList.RemoveAll(x => x.EngineDataID == oldSourceTagId); resourcePixelList.RemoveAll(x => x.EngineDataID == sourceTagIdOnDrawing);
continue;//无效的pixel下一个位号 continue;//无效的pixel下一个位号
} }
//sourceTag.originId = oldSourceTagId; //sourceTag.originId = oldSourceTagId;
//对象类型ID根据对象类型库的完整路径(中文)判断。 //对象类型ID根据对象类型库的完整路径(中文)判断。
ec_objecttypeEntity resourceType = resourceTypeAll.FirstOrDefault(x => x.ObjectTypeID == sourceTag.ObjectTypeID); sourceTypeAll.TryGetValue(sourceTag.ObjectTypeID, out ec_objecttypeEntity sourceType);
if (resourceType != null) if (sourceType != null)
{ {
//对象类型的匹配 //对象类型的匹配
ec_objecttypeEntity curObjectTypeData = targetTypeAll.FirstOrDefault(x => x.FullPathCN == resourceType.FullPathCN); targetTypeAll.TryGetValue(sourceType.FullPathCN, out ec_objecttypeEntity curObjectTypeData);
if (curObjectTypeData != null) if (curObjectTypeData != null)
{ {
sourceTag.ObjectTypeID = curObjectTypeData.ObjectTypeID;//新的对象类型ID //会影响sourceTags这个原始集合 sourceTag.ObjectTypeID = curObjectTypeData.ObjectTypeID;//新的对象类型ID //会影响sourceTags这个原始集合
#region enginedata #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) if (targetTagWithSameName != null)
{ {
//如果重复,位号 = 原来位号 + from + 原项目名称 //如果重复,位号 = 原来位号 + from + 原项目名称
@ -1077,7 +1077,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
tagRel.RelTypeID = targetConnRelType.RelTypeID; tagRel.RelTypeID = targetConnRelType.RelTypeID;
//ID2 //ID2
//这个时候的ID2无法从 targetTags 里查到因为id可能已经变了 //这个时候的ID2无法从 targetTags 里查到因为id可能已经变了
var otherTag = sourceTags.FirstOrDefault(x => x.originId == tagRel.RelEngineData2ID);//非电缆的 sourceTags.TryGetValue(tagRel.RelEngineData2ID, out var otherTag);//非电缆的
if (otherTag != null) if (otherTag != null)
{ {
if (otherTag.originId != otherTag.EngineDataID) if (otherTag.originId != otherTag.EngineDataID)
@ -1086,7 +1086,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
else else
{ {
var targetTagNumber = targetTags.FirstOrDefault(x => x.TagNumber.ToUpper() == otherTag.TagNumber.ToUpper()); targetTags.TryGetValue(otherTag.TagNumber.ToUpper(), out var targetTagNumber);
//只有目标项目里面没有这个设备才去新建给新ID不然还是给目标项目的ID //只有目标项目里面没有这个设备才去新建给新ID不然还是给目标项目的ID
if (targetTagNumber == null) if (targetTagNumber == null)
{ {
@ -1116,7 +1116,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
tagRel.RelTypeID = targetConnRelType.RelTypeID; tagRel.RelTypeID = targetConnRelType.RelTypeID;
//ID2 //ID2
//这个时候的ID2无法从 targetTags 里查到因为id可能已经变了 //这个时候的ID2无法从 targetTags 里查到因为id可能已经变了
var otherTag = sourceTags.FirstOrDefault(x => x.originId == tagRel.RelEngineData1ID); sourceTags.TryGetValue(tagRel.RelEngineData1ID, out var otherTag);
if (otherTag != null) if (otherTag != null)
{ {
if (otherTag.originId != otherTag.EngineDataID) if (otherTag.originId != otherTag.EngineDataID)
@ -1125,7 +1125,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
else else
{ {
var targetTagNumber = targetTags.FirstOrDefault(x => x.TagNumber.ToUpper() == otherTag.TagNumber.ToUpper()); targetTags.TryGetValue(otherTag.TagNumber.ToUpper(), out var targetTagNumber);
//只有目标项目里面没有这个设备才去新建给新ID不然还是给目标项目的ID //只有目标项目里面没有这个设备才去新建给新ID不然还是给目标项目的ID
if (targetTagNumber == null) if (targetTagNumber == null)
{ {
@ -1177,12 +1177,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
addPropertyList.Add(property); addPropertyList.Add(property);
} }
} }
#endregion #endregion
#region CABLE,SET,WIRE #region CABLE,SET,WIRE
//cable //cable
//set //set
//wire //wire
var sourceCable = sourceCables.FirstOrDefault(x => x.EngineerDataID == sourceTag.originId); sourceCables.TryGetValue(sourceTag.originId, out ec_CableEntity sourceCable);
if (sourceCable != null) if (sourceCable != null)
{ {
@ -1233,7 +1233,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
//STRIP //STRIP
//CHANNEL //CHANNEL
//TERM //TERM
var sourcePanel = sourcePanelAll.FirstOrDefault(x => x.EngineerDataID == sourceTag.originId); sourcePanelAll.TryGetValue(sourceTag.originId, out var sourcePanel);
if (sourcePanel != null) if (sourcePanel != null)
{ {
@ -1247,7 +1247,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
foreach (var sourceStrip in sourceStrips) foreach (var sourceStrip in sourceStrips)
{ {
var sourceTerms = sourceTermAll.Where(x => x.StripID == sourceStrip.StripID).ToList(); 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.Create();
sourceStrip.PanelID = sourcePanel.PanelID; sourceStrip.PanelID = sourcePanel.PanelID;
@ -1257,9 +1257,9 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
foreach (var ch in sourceCHs) foreach (var ch in sourceCHs)
{ {
ch.Create(); ch.Value.Create();
ch.StripID = sourceStrip.StripID; ch.Value.StripID = sourceStrip.StripID;
addChList.Add(ch); addChList.Add(ch.Value);
} }
} }
if (sourceTerms != null) if (sourceTerms != null)
@ -1271,7 +1271,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
if (term.ChannelID != "-1") if (term.ChannelID != "-1")
{ {
//有通道 //有通道
var existCh = sourceCHs.FirstOrDefault(x => x.ChannelID == term.ChannelID); sourceCHs.TryGetValue(term.ChannelID, out var existCh);
if (existCh != null) if (existCh != null)
{ {
term.ChannelID = existCh.ChannelID; term.ChannelID = existCh.ChannelID;
@ -1296,57 +1296,56 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
//已有的,单纯属性覆盖就行 //已有的,单纯属性覆盖就行
#region property #region property
//获取对应的工程数据属性 //获取对应的工程数据属性
var sourceTagProps = PropServ.GetTagPropById(item.ProjectId, sourceTag.originId).ToList(); var sourceTagProps = PropServ.GetTagPropById(item.ProjectId, sourceTag.originId);
var targetTagProps = PropServ.GetTagPropById(ProjectId, sourceTag.EngineDataID).ToList(); var targetTagProps = PropServ.GetTagPropById(ProjectId, sourceTag.EngineDataID).ToDictionary(x => x.PropertyName, x => x);
var updateList = new List<ec_enginedata_propertyEntity>(); var updateList = new List<ec_enginedata_propertyEntity>();
var hisInsertList = new List<ec_enginedata_propertyhisEntity>(); var hisInsertList = new List<ec_enginedata_propertyhisEntity>();
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;
updateList.Add(tarProp);
var propHis = new ec_enginedata_propertyhisEntity //Db.Updateable(tarProp).AS($"ec_enginedata_property_{targetProject.ProjectIndex}").ExecuteCommand();
{ //Db.Insertable(propHis).AS($"ec_enginedata_propertyhis_{targetProject.ProjectIndex}").ExecuteCommand();
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);
}
//要和现有的比一下,没有的就插入,有的就更新
} }
else
{
property.EngineDataID = sourceTag.EngineDataID;//target里的已经存在的id了
property.Create();
property.UpdateTime = null;
property.UpdateUserID = null;
addPropertyList.Add(property);
}
//要和现有的比一下,没有的就插入,有的就更新
} }
if (updateList.Count > 0) if (updateList.Count > 0)
{ {
Db.Updateable(updateList) Db.Updateable(updateList)
.AS($"ec_enginedata_property_{targetProject.ProjectIndex}") .AS($"ec_enginedata_property_{targetProject.ProjectIndex}")
.UpdateColumns(x => new { .UpdateColumns(x => new
{
x.PropertyValue, x.PropertyValue,
x.MeasuringUnit, x.MeasuringUnit,
x.UpdateTime, x.UpdateTime,
@ -1385,7 +1384,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
else else
{ {
msg = sourceTag.TagNumber + $"对象类型不匹配!。老项目为{resourceType.FullPathCN},新项目则没有该类型。"; msg = sourceTag.TagNumber + $"对象类型不匹配!。老项目为{sourceType.FullPathCN},新项目则没有该类型。";
log.Error(msg); log.Error(msg);
} }

View File

@ -1485,7 +1485,6 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// <param name="caseID">工程数据实体</param> /// <param name="caseID">工程数据实体</param>
public void UpdatePixelAndProp(string projectId, ec_enginedataEntity entity) public void UpdatePixelAndProp(string projectId, ec_enginedataEntity entity)
{ {
var caseID = "0";//entity.CaseID;
var ec_relDataBLL = new ec_enginedata_relBLL(); var ec_relDataBLL = new ec_enginedata_relBLL();
Db.BeginTran(); Db.BeginTran();
try try
@ -1511,8 +1510,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var reldataTableName = TableName<ec_enginedata_relEntity>(ProjectEntity.ProjectIndex.ToString()); var reldataTableName = TableName<ec_enginedata_relEntity>(ProjectEntity.ProjectIndex.ToString());
var lookupBll = new ec_REFLOOKUPTABLEBLL(); var lookupBll = new ec_REFLOOKUPTABLEBLL();
var allTags = Db.Queryable<ec_enginedataEntity>().AS(TableName<ec_enginedataEntity>(projectId)).ToList();
var curEnginedata = GetList(("{\"ProjectId\":\"" + projectId + "\",\"TagNumber\":\"" + entity.TagNumber + "\"}")).FirstOrDefault(); var curEnginedata = allTags.FirstOrDefault(x => x.TagNumber == entity.TagNumber);
string engineDataID = ""; string engineDataID = "";
@ -1575,7 +1574,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var cableSystemObj = entity.EngineDataProperty.FirstOrDefault(x => x.PropertyName == GlobalObject.propName_System); var cableSystemObj = entity.EngineDataProperty.FirstOrDefault(x => x.PropertyName == GlobalObject.propName_System);
string systemNameAfterDealWith = string.Empty; string systemNameAfterDealWith = string.Empty;
var cableSystem =string.Empty; var cableSystem = string.Empty;
var topDataItemDetailIDofDwg = string.Empty; var topDataItemDetailIDofDwg = string.Empty;
var topDataItemDetailIDofEng = string.Empty; var topDataItemDetailIDofEng = string.Empty;
if (cableSystemObj != null) if (cableSystemObj != null)
@ -1586,7 +1585,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
//获取图纸系统的最上级ID //获取图纸系统的最上级ID
topDataItemDetailIDofDwg = GetTopParentDataItemDetailByID(dataitemdetailTableName, dwgObj.DrawingSystem); topDataItemDetailIDofDwg = GetTopParentDataItemDetailByID(dataitemdetailTableName, dwgObj.DrawingSystem);
//获取位号系统的最上级ID //获取位号系统的最上级ID
topDataItemDetailIDofEng= GetTopParentDataItemDetailByID(dataitemdetailTableName, cableSystem); topDataItemDetailIDofEng = GetTopParentDataItemDetailByID(dataitemdetailTableName, cableSystem);
if (topDataItemDetailIDofDwg == topDataItemDetailIDofEng && !string.IsNullOrEmpty(dwgObj.DrawingSystem)) 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; //var cableSystem = cableSystemObj == null ? "" : systems.FirstOrDefault(x => x.DataItemName == cableSystemObj.PropertyValue)?.DataItemDetailID;
//if (cableSystem != null) //if (cableSystem != null)
//{ //{
//} //}
} }
else else
@ -1659,6 +1658,20 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
entity.EngineDataProperty = new List<ec_enginedata_propertyEntity>(); entity.EngineDataProperty = new List<ec_enginedata_propertyEntity>();
} }
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); entity = lookupBll.ApplyLookup(projectId, entity, true);
foreach (var prop in entity.EngineDataProperty. foreach (var prop in entity.EngineDataProperty.

View File

@ -45,6 +45,10 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
//.WhereIF(!string.IsNullOrEmpty(CaseID), (a, b) => a.CaseID == CaseID) //.WhereIF(!string.IsNullOrEmpty(CaseID), (a, b) => a.CaseID == CaseID)
.WhereIF(EngineDataIDs != null && EngineDataIDs.Length > 0, (a, b) => EngineDataIDs.Contains(a.EngineDataID) .WhereIF(EngineDataIDs != null && EngineDataIDs.Length > 0, (a, b) => EngineDataIDs.Contains(a.EngineDataID)
&& a.PropertyName != "HKSK_POSITION_NUM").ToList(); && a.PropertyName != "HKSK_POSITION_NUM").ToList();
if (list == null)
{
list = new List<ec_enginedata_propertyEntity>();
}
return list; return list;
} }
catch (Exception ex) catch (Exception ex)

View File

@ -21,8 +21,8 @@ namespace Learun.Cache.Redis
/// 24 9 4新增。 /// 24 9 4新增。
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="cacheKey"></param> /// <param name="cacheKey">redis的缓存key</param>
/// <param name="dbQuery"></param> /// <param name="dbQuery">委托一般是key里没有的时候去执行一次db查询</param>
/// <param name="expireTime"></param> /// <param name="expireTime"></param>
/// <param name="dbId"></param> /// <param name="dbId"></param>
/// <returns></returns> /// <returns></returns>