|
@@ -496,7 +496,7 @@ namespace SAGA.MBI.DataArrange
|
|
|
//设置初始状态
|
|
|
cloudContext.SetState(DocumentChangedOperator.None);
|
|
|
localContext.SetState(DocumentChangedOperator.None);
|
|
|
- #region Modify
|
|
|
+ #region Modify Add
|
|
|
foreach (var lduty in localContext.GetAllDutys())
|
|
|
{
|
|
|
string bimId = lduty.BimID;
|
|
@@ -516,28 +516,33 @@ namespace SAGA.MBI.DataArrange
|
|
|
}
|
|
|
cduty = cdutys.FirstOrDefault();
|
|
|
}
|
|
|
+
|
|
|
if (cduty == null)
|
|
|
- continue;
|
|
|
- //判断族编码是否更改
|
|
|
- if (EquipmentCodeMap.GetOriginCode(lduty.EquipClassCode) !=
|
|
|
- EquipmentCodeMap.GetOriginCode(cduty.EquipClassCode))
|
|
|
- {
|
|
|
- //族编码更改。删除旧岗位,创建新岗位
|
|
|
- cduty.Operator = DocumentChangedOperator.Delete;
|
|
|
+ {//找不到物理世界对应的岗位,即为添加
|
|
|
lduty.Operator = DocumentChangedOperator.Add;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- lduty.Id = cduty.Id;
|
|
|
- lduty.Operator = DocumentChangedOperator.Modified;
|
|
|
- cduty.Operator = DocumentChangedOperator.Modified;
|
|
|
+ //判断族编码是否更改
|
|
|
+ if (EquipmentCodeMap.GetOriginCode(lduty.EquipClassCode) !=
|
|
|
+ EquipmentCodeMap.GetOriginCode(cduty.EquipClassCode))
|
|
|
+ {
|
|
|
+ //族编码更改。删除旧岗位,创建新岗位
|
|
|
+ cduty.Operator = DocumentChangedOperator.Delete;
|
|
|
+ lduty.Operator = DocumentChangedOperator.Add;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lduty.Id = cduty.Id;
|
|
|
+ lduty.Operator = DocumentChangedOperator.Modified;
|
|
|
+ //后续物理世界Modified转化为None
|
|
|
+ cduty.Operator = DocumentChangedOperator.Modified;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
//处理设备所在空间的关系
|
|
|
- //??删除重建??没错
|
|
|
- var equipInSpace = localContext.RltEquipInSpaces.FirstOrDefault(t => t.MEquipment.BimID == bimId);
|
|
|
- if (equipInSpace == null) continue;
|
|
|
- equipInSpace.Operator = DocumentChangedOperator.Delete;
|
|
|
- localContext.RltEquipInSpaces.Add(new RltEquipInSpace(equipInSpace.MSpace, equipInSpace.MEquipment) { Operator = DocumentChangedOperator.Add });
|
|
|
+ OperateBaseRelation(localContext, lduty);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -553,25 +558,94 @@ namespace SAGA.MBI.DataArrange
|
|
|
continue;
|
|
|
}
|
|
|
duty.Operator = DocumentChangedOperator.Delete;
|
|
|
+ DelServiceRelation(cloudContext, duty);
|
|
|
//删除时,会删除所在空间和所在楼层的关系
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 处理基本关系
|
|
|
+ /// </summary>
|
|
|
+ private static void DelServiceRelation(CalcContext localContext, MRevitEquipBase mode)
|
|
|
+ {
|
|
|
+ if (mode.Operator != DocumentChangedOperator.Delete) return;
|
|
|
+ #region EquipInSpace,Beacon
|
|
|
|
|
|
- #region Add
|
|
|
+ var equiprelations = localContext.RltEquipInSpaces;
|
|
|
+ var beaconrelations = localContext.RltBeaconinElementSps;
|
|
|
+ if (mode is MBSpace)
|
|
|
+ {
|
|
|
+ var equipRelation=new RltEquipInSpace(null,mode.Id){Operator = DocumentChangedOperator.Delete};
|
|
|
+ equiprelations.Add(equipRelation);
|
|
|
+ var beaconRelation = new RltBeaconinElementSp(null, mode.Id) { Operator = DocumentChangedOperator.Delete };
|
|
|
+ beaconrelations.Add(beaconRelation);
|
|
|
+ }
|
|
|
+ else if (mode is MBeacon)
|
|
|
+ {
|
|
|
+ var beaconRelation = new RltBeaconinElementSp(mode.Id, null) { Operator = DocumentChangedOperator.Delete };
|
|
|
+ beaconrelations.Add(beaconRelation);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var equipRelation = new RltEquipInSpace(mode.Id, null) { Operator = DocumentChangedOperator.Delete };
|
|
|
+ equiprelations.Add(equipRelation);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 处理基本关系
|
|
|
+ /// </summary>
|
|
|
+ private static void OperateBaseRelation(CalcContext localContext, MRevitEquipBase mode)
|
|
|
+ {
|
|
|
+ string bimid = mode.BimID;
|
|
|
+
|
|
|
+ #region EquipInSpace,Beacon
|
|
|
+
|
|
|
+ var equiprelations = localContext.RltEquipInSpaces;
|
|
|
+ var beaconrelations = localContext.RltBeaconinElementSps;
|
|
|
+ List<RltEquipInSpace> tempEquipRelations = new List<RltEquipInSpace>();
|
|
|
+ List<RltBeaconinElementSp> tempBeaconRelations = new List<RltBeaconinElementSp>();
|
|
|
+ if (mode is MBSpace)
|
|
|
+ {
|
|
|
+ tempEquipRelations = equiprelations.Where(t => t.MSpace.BimID == bimid).ToList();
|
|
|
+ tempBeaconRelations = beaconrelations.Where(t => t.MSpace.BimID == bimid).ToList();
|
|
|
+ }
|
|
|
+ else if (mode is MBeacon)
|
|
|
+ {
|
|
|
+ tempBeaconRelations = beaconrelations.Where(t => t.MBeacon.BimID == bimid).ToList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempEquipRelations = equiprelations.Where(t => t.MEquipment.BimID == bimid).ToList();
|
|
|
+ }
|
|
|
|
|
|
- //LocalDuty,有两种操作,更新和增加。除Modify以外的全部为添加
|
|
|
- foreach (var duty in localDutys)
|
|
|
+ switch (mode.Operator)
|
|
|
{
|
|
|
- if (duty.Operator == DocumentChangedOperator.Modified) continue;
|
|
|
- duty.Operator = DocumentChangedOperator.Add;
|
|
|
- //添加时,添加设备所在元空间关系
|
|
|
- localContext.RltEquipInSpaces.Where(t => t.MEquipment.BimID == duty.BimID).ToList()
|
|
|
- .ForEach(t => t.Operator = DocumentChangedOperator.Add);
|
|
|
+ case DocumentChangedOperator.Add:
|
|
|
+ tempEquipRelations.ForEach(t => t.Operator = DocumentChangedOperator.Add);
|
|
|
+ tempBeaconRelations.ForEach(t => t.Operator = DocumentChangedOperator.Add);
|
|
|
+ break;
|
|
|
+ case DocumentChangedOperator.Delete:
|
|
|
+ tempEquipRelations.ForEach(t => t.Operator = DocumentChangedOperator.Delete);
|
|
|
+ tempBeaconRelations.ForEach(t => t.Operator = DocumentChangedOperator.Delete);
|
|
|
+ break;
|
|
|
+ case DocumentChangedOperator.Modified:
|
|
|
+ tempEquipRelations.ForEach(t => t.Operator = DocumentChangedOperator.Delete);
|
|
|
+ tempEquipRelations.ForEach(t => equiprelations.Add(new RltEquipInSpace(t.MSpace, t.MEquipment) { Operator = DocumentChangedOperator.Add }));
|
|
|
+
|
|
|
+ tempBeaconRelations.ForEach(t => t.Operator = DocumentChangedOperator.Delete);
|
|
|
+ tempBeaconRelations.ForEach(t => beaconrelations.Add(new RltBeaconinElementSp(t.MSpace, t.MBeacon) { Operator = DocumentChangedOperator.Add }));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|