diff --git a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db index 8ed632ad..21d4a1b9 100644 Binary files a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db and b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db differ diff --git a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db-shm b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db-shm index 181ea008..102b32a1 100644 Binary files a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db-shm and b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db-shm differ diff --git a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db-wal b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db-wal index c53fe8aa..b5621dc0 100644 Binary files a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db-wal and b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/CodeChunks.db-wal differ diff --git a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db index 567217bf..813c8ff6 100644 Binary files a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db and b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db differ diff --git a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db-shm b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db-shm index d8b8326a..e10c4d70 100644 Binary files a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db-shm and b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db-shm differ diff --git a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db-wal b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db-wal index e8003a29..795a6651 100644 Binary files a/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db-wal and b/newFront/c#前端/.vs/SWS.CAD/CopilotIndices/17.13.444.19527/SemanticSymbols.db-wal differ diff --git a/newFront/c#前端/SWS.CAD/Commands.cs b/newFront/c#前端/SWS.CAD/Commands.cs index 2dd0253d..a28f2dcd 100644 --- a/newFront/c#前端/SWS.CAD/Commands.cs +++ b/newFront/c#前端/SWS.CAD/Commands.cs @@ -24,6 +24,7 @@ using Panel = Bricscad.Windows.Panel; using GlobalObject = SWS.Commons.GlobalObject; using SWS.Model; using SWS.Service; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Information; [assembly: CommandClass(typeof(Commands))] @@ -540,6 +541,8 @@ namespace SWS.CAD //选择的元素返回的属性信息 var ResTagInfosByPixels = new Model.ec_objecttype(); var listPropertys = new List(); + var _objectTypeService = GlobalObject.container.Resolve(); + var _iOModuleService = GlobalObject.container.Resolve(); // 持续选择直到获取有效电缆 bool isValidCable = false; @@ -564,7 +567,7 @@ namespace SWS.CAD { // 获取句柄(Handle 是字符串类型) var handId = (cable.Handle.ToString()); - var _objectTypeService = GlobalObject.container.Resolve(); + _objectTypeService = GlobalObject.container.Resolve(); var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId); if (res != null) { @@ -600,8 +603,20 @@ namespace SWS.CAD //Thread.Sleep(2000); if (isValidCable) { - var _iOModuleService = GlobalObject.container.Resolve(); + var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID); + var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID); + string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault(); + CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1); + var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID); + //获取位号的电缆属性,判断是否设置电缆规格 + var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber); + var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault(); + if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) + //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) + { + System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return; + } var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID); //如果配置不存在 if (ResCableEngID == null) @@ -636,6 +651,7 @@ namespace SWS.CAD ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID; ec_Cable.Sets = new List(); int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; + int n = 0; for (int i = 0; i < CableSetCount; i++) { ec_CableSet ec_CableSet = new ec_CableSet(); @@ -645,6 +661,7 @@ namespace SWS.CAD int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; for (int j = 0; j < WireCount; j++) { + n++; ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.SetLevel = j + 1; @@ -653,6 +670,20 @@ namespace SWS.CAD switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) { case "按电缆编号": + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = n.ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + (n - 1)); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i + 1) + "-" + n.ToString(); + } + break; + case "按电缆对编号": if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) { Tag = (j + 1).ToString(); @@ -663,12 +694,9 @@ namespace SWS.CAD } else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) { - Tag = (i + 1).ToString(); + Tag = (i + 1) + "-" + (j + 1).ToString(); } break; - case "按电缆对编号": - a = ResTagInfosByPixels.tags.FirstOrDefault().TagNumber; - break; } ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSet.Wires.Add(ec_CableSetWire); @@ -705,6 +733,7 @@ namespace SWS.CAD ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID; ec_Cable.Sets = new List(); int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; + int n = 0; for (int i = 0; i < CableSetCount; i++) { ec_CableSet ec_CableSet = new ec_CableSet(); @@ -714,6 +743,7 @@ namespace SWS.CAD int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; for (int j = 0; j < WireCount; j++) { + n++; ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.SetLevel = j + 1; @@ -722,6 +752,20 @@ namespace SWS.CAD switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) { case "按电缆编号": + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = n.ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + (n - 1)); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i + 1) + "-" + n.ToString(); + } + break; + case "按电缆对编号": if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) { Tag = (j + 1).ToString(); @@ -732,12 +776,9 @@ namespace SWS.CAD } else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) { - Tag = (i + 1).ToString(); + Tag = (i + 1) + "-" + (j + 1).ToString(); } break; - case "按电缆对编号": - a = ResTagInfosByPixels.tags.FirstOrDefault().TagNumber; - break; } ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSet.Wires.Add(ec_CableSetWire); @@ -849,20 +890,305 @@ namespace SWS.CAD btnCableSinal.ToolTip = "信号预分配"; btnCableSinal.Text = "信号预分配"; btnCableSinal.ButtonStyle = RibbonButtonStyle.SmallWithText; - btnCableSinal.CommandHandler = new DelegateCommand(x => + btnCableSinal.CommandHandler = new DelegateCommand(async x => { - //打开窗体 - var para = new Prism.Services.Dialogs.DialogParameters(); - var _dialogService = GlobalObject._prismContainer.Resolve(); - _dialogService.ShowDialog(nameof(DialogSignalPredistribution), para, (RES) => + if (GlobalObject.userInfo == null || GlobalObject.curProject == null) { - if (RES.Result == ButtonResult.Yes) + MessageBox.Show("请先登录系统并选择项目!"); + return; + } + + //在SWS系统内打开且不是只读的图纸才可 + var dwgName = General.GetDwgName(); + var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false); + if (dwgFile == null) + { return; } + Document doc = Application.DocumentManager.MdiActiveDocument; + Database db = doc.Database; + Editor ed = doc.Editor; + //选择的元素返回的属性信息 + var ResTagInfosByPixels = new Model.ec_objecttype(); + var listPropertys = new List(); + var _objectTypeService = GlobalObject.container.Resolve(); + var _iOModuleService = GlobalObject.container.Resolve(); + // 持续选择直到获取有效电缆 + bool isValidCable = false; + + try + { + #region 选择电缆 + // 创建选择选项(禁用回车确认) + PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: "); + options.AllowNone = false; // 禁止空选 + + // 执行选择(直接单击生效) + PromptEntityResult resultEntity = ed.GetEntity(options); + //WindowVisibility = System.Windows.Visibility.Hidden; + + while (resultEntity.Status == PromptStatus.OK) { + using (Transaction tr = db.TransactionManager.StartTransaction()) + { + // 获取选中的电缆实体 + Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity; + //if (cable != null&&cable.XData != null) + if (cable != null) + { + // 获取句柄(Handle 是字符串类型) + var handId = (cable.Handle.ToString()); + var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId); + if (res != null) + { + if (res.Count == 1) + { + var item = res[0]; + var objTypeName = item.ObjectTypeName; + if (objTypeName.Contains("电缆")) + { + ResTagInfosByPixels = item; + isValidCable = true; // 校验通过 + ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}"); + } + + } + } + + } + tr.Commit(); + } + if (isValidCable) + { + break; + } + else + { + ed.WriteMessage($"\n已选择电缆:"); + resultEntity = ed.GetEntity(options); + } } - else if (RES.Result == ButtonResult.No) - { } - }); + #endregion + + + //Thread.Sleep(2000); + if (isValidCable) + { + var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID); + var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID); + string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault(); + CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1); + var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID); + //获取位号的电缆属性,判断是否设置电缆规格 + var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber); + var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault(); + if(string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) + //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) + { + System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return; + + } + var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID); + //如果配置不存在 + if (ResCableEngID == null) + { + listPropertys = new List(); + System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question); + if (result == System.Windows.MessageBoxResult.OK) + { + listPropertys = new List(); + Dictionary pulldownlist; + + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, }); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, }); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, }); + pulldownlist = new Dictionary(); + pulldownlist.Add("数字", "数字"); + pulldownlist.Add("字母", "字母"); + pulldownlist.Add("电缆对序号", "电缆对序号"); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, }); + pulldownlist = new Dictionary(); + pulldownlist.Add("按电缆编号", "按电缆编号"); + pulldownlist.Add("按电缆对编号", "按电缆对编号"); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, }); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, }); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, }); + //显示属性弹窗 + var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys); + if (ReslistPro == null || ReslistPro.Count() == 0) return; + ec_Cable ec_Cable = new ec_Cable(); + ec_Cable.CableClass = "homerun";//母线 + ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault(); + ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID; + ec_Cable.Sets = new List(); + int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; + int n = 0; + for (int i = 0; i < CableSetCount; i++) + { + ec_CableSet ec_CableSet = new ec_CableSet(); + ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1); + ec_CableSet.CableSetSeq = i + 1; + ec_CableSet.Wires = new List(); + int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; + for (int j = 0; j < WireCount; j++) + { + n++; + ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); + ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; + ec_CableSetWire.SetLevel = j + 1; + string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀 + string Tag = "";//线号名的中间部分 + switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) + { + case "按电缆编号": + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = n.ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + (n - 1)); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i + 1) + "-" + n.ToString(); + } + break; + case "按电缆对编号": + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = (j + 1).ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + j); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i + 1) + "-" + (j + 1).ToString(); + } + break; + } + ec_CableSetWire.Wire_Tag = a + Tag; + ec_CableSet.Wires.Add(ec_CableSetWire); + } + ec_Cable.Sets.Add(ec_CableSet); + } + var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable); + ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID); + } + else + { + listPropertys = new List(); + Dictionary pulldownlist; + + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, }); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, }); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, }); + pulldownlist = new Dictionary(); + pulldownlist.Add("数字", "数字"); + pulldownlist.Add("字母", "字母"); + pulldownlist.Add("电缆对序号", "电缆对序号"); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, }); + pulldownlist = new Dictionary(); + pulldownlist.Add("按电缆编号", "按电缆编号"); + pulldownlist.Add("按电缆对编号", "按电缆对编号"); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, }); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, }); + listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, }); + //显示属性弹窗 + var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys); + if (ReslistPro == null || ReslistPro.Count() == 0) return; + ec_Cable ec_Cable = new ec_Cable(); + ec_Cable.CableClass = "conventional";//常规电缆 + ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID; + ec_Cable.Sets = new List(); + int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; + int n = 0; + for (int i = 0; i < CableSetCount; i++) + { + ec_CableSet ec_CableSet = new ec_CableSet(); + ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1); + ec_CableSet.CableSetSeq = i + 1; + ec_CableSet.Wires = new List(); + int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; + for (int j = 0; j < WireCount; j++) + { + n++; + ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); + ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; + ec_CableSetWire.SetLevel = j + 1; + string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀 + string Tag = "";//线号名的中间部分 + switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) + { + case "按电缆编号"://所有的电缆对中的电芯一起编号 + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = n.ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + (n-1)); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i+1)+"-"+ n.ToString(); + } + break; + case "按电缆对编号"://一个电缆对中线号按顺序编号,另一个电缆对中线号重新从1开始编号 + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = (j + 1).ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + j); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i+1) + "-" + (j+1).ToString(); + } + break; + } + ec_CableSetWire.Wire_Tag = a + Tag; + ec_CableSet.Wires.Add(ec_CableSetWire); + } + ec_Cable.Sets.Add(ec_CableSet); + } + var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable); + ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID); + } + } + if (ResCableEngID != null) + { + + IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle; + //打开窗体 + var para = new Prism.Services.Dialogs.DialogParameters(); + //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb"); + para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle); + + para.Add(GlobalObject.dialogPar.para1.ToString(), ResCableEngID); + para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber); + var _dialogService = GlobalObject._prismContainer.Resolve(); + _dialogService.ShowDialog(nameof(DialogSignalPredistribution), para, (RES) => + { + if (RES.Result == ButtonResult.Yes) + { + + } + else if (RES.Result == ButtonResult.No) + { } + }); + } + + } + + } + catch (System.Exception ex) + { + ed.WriteMessage($"\n错误: {ex.Message}"); + } }); btnCableSinal.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableSinal.png"); btnCableSinal.Id = "信号预分配"; diff --git a/newFront/c#前端/SWS.CAD/Event/ScrollToItemEvent.cs b/newFront/c#前端/SWS.CAD/Event/ScrollToItemEvent.cs new file mode 100644 index 00000000..be965b2d --- /dev/null +++ b/newFront/c#前端/SWS.CAD/Event/ScrollToItemEvent.cs @@ -0,0 +1,9 @@ +using Newtonsoft.Json.Linq; +using Prism.Events; + +namespace SWS.CAD.Event +{ + public class ScrollToItemEvent: PubSubEvent + { + } +} diff --git a/newFront/c#前端/SWS.CAD/GlobalObje.cs b/newFront/c#前端/SWS.CAD/GlobalObje.cs index d235b2e6..de4a2900 100644 --- a/newFront/c#前端/SWS.CAD/GlobalObje.cs +++ b/newFront/c#前端/SWS.CAD/GlobalObje.cs @@ -1,5 +1,6 @@ using IniParser; using Prism.Ioc; +using SWS.Commons; using SWS.Model; using SWS.Service; using System; @@ -59,7 +60,7 @@ namespace SWS.CAD if (_dwgType == null) { - var serv = GlobalObje.container.Resolve(); + var serv = GlobalObject.container.Resolve(); var res = Task.Run(() => serv.GetDetails(DBConst.Be_DrawingType.ToString())); var res2 = res.Result; return res2; @@ -83,7 +84,7 @@ namespace SWS.CAD if (_dwgMaterialRange == null) { - var serv = GlobalObje.container.Resolve(); + var serv = GlobalObject.container.Resolve(); var res = Task.Run(() => serv.GetDetails(DBConst.Be_MaterialRange.ToString())); var res2 = res.Result; return res2; @@ -107,7 +108,7 @@ namespace SWS.CAD if (_dwgMaterialCensus == null) { - var serv = GlobalObje.container.Resolve(); + var serv = GlobalObject.container.Resolve(); var res = Task.Run(() => serv.GetDetails(DBConst.Be_MaterialCensus.ToString())); var res2 = res.Result; return res2; @@ -131,7 +132,7 @@ namespace SWS.CAD if (_dwgStage == null) { - var serv = GlobalObje.container.Resolve(); + var serv =GlobalObject.container.Resolve(); var res = Task.Run(() => serv.GetDetails(DBConst.Be_DrawingStage.ToString())); var res2 = res.Result; return res2; @@ -155,7 +156,7 @@ namespace SWS.CAD if (_dwgSystem == null) { - var serv = GlobalObje.container.Resolve(); + var serv = GlobalObject.container.Resolve(); var res = Task.Run(() => serv.GetDetails(DBConst.Be_DrawingSystem.ToString())); var res2 = res.Result; var res3 = DataItemDetailsToTree(res2); @@ -243,11 +244,11 @@ namespace SWS.CAD para1, para2 } - public static IUnityContainer container; - public static IContainerExtension _prismContainer; - public static HttpClient client; - public static loginRes userInfo; - public static List Users; + //public static IUnityContainer container; + //public static IContainerExtension _prismContainer; + //public static HttpClient client; + //public static loginRes userInfo; + //public static List Users; public static bool isConfigIniCreateBySys = true; //public static string drawingFileId; @@ -321,27 +322,27 @@ namespace SWS.CAD } #endregion - #region 根据ID获取用户名称 - /// - /// 根据ID获取用户名称 - /// - /// - /// - public static string GetUserNameById(string id) - { - if (string.IsNullOrEmpty(id)) - { return ""; } - var user = Users.FirstOrDefault(a => a.F_UserId == id || a.F_Account == id); - if (user != null) - { return user.F_RealName; } - else - { - return ""; - //user = GlobalObject.Users.FirstOrDefault(a => a.F_Account == id); - //return user != null ? user.F_RealName : ""; - } - } - #endregion + //#region 根据ID获取用户名称 + ///// + ///// 根据ID获取用户名称 + ///// + ///// + ///// + //public static string GetUserNameById(string id) + //{ + // if (string.IsNullOrEmpty(id)) + // { return ""; } + // var user = Users.FirstOrDefault(a => a.F_UserId == id || a.F_Account == id); + // if (user != null) + // { return user.F_RealName; } + // else + // { + // return ""; + // //user = GlobalObject.Users.FirstOrDefault(a => a.F_Account == id); + // //return user != null ? user.F_RealName : ""; + // } + //} + //#endregion #region 查找子控件 diff --git a/newFront/c#前端/SWS.CAD/SWS.CAD.csproj b/newFront/c#前端/SWS.CAD/SWS.CAD.csproj index 865e319d..1419120f 100644 --- a/newFront/c#前端/SWS.CAD/SWS.CAD.csproj +++ b/newFront/c#前端/SWS.CAD/SWS.CAD.csproj @@ -167,6 +167,7 @@ + diff --git a/newFront/c#前端/SWS.CAD/ViewModels/DialogIODistributionVM/DialogIODistributionViewModel.cs b/newFront/c#前端/SWS.CAD/ViewModels/DialogIODistributionVM/DialogIODistributionViewModel.cs index 5a78706a..fe8399c7 100644 --- a/newFront/c#前端/SWS.CAD/ViewModels/DialogIODistributionVM/DialogIODistributionViewModel.cs +++ b/newFront/c#前端/SWS.CAD/ViewModels/DialogIODistributionVM/DialogIODistributionViewModel.cs @@ -10,6 +10,7 @@ using System.Windows.Threading; using Bricscad.ApplicationServices; using Bricscad.EditorInput; using OfficeOpenXml; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Information; using Prism.Events; using Prism.Ioc; using Prism.Services.Dialogs; @@ -56,6 +57,8 @@ namespace SWS.CAD.ViewModels RaisePropertyChanged(nameof(SelectedTreeNode)); UpdateChannelInfos(); + var path = FindNodePath(PanelTreels, _SelectedTreeNode); + _eventAggregator.GetEvent().Publish(path); } } @@ -279,7 +282,7 @@ namespace SWS.CAD.ViewModels { ChannelInfo c = new ChannelInfo(); //电缆位号,电缆对,电缆线号,极性 - foreach (var Term in child.Terms) + foreach (var Term in child.Terms.OrderBy(p => p.Term_Seq).ToList()) { index++; c.Index.Add(index.ToString()); @@ -302,7 +305,8 @@ namespace SWS.CAD.ViewModels c.Polaritys.Add(new ec_WireTerminal()); } } - c.Terms.AddRange(child.Terms); + //端子号 + c.Terms.AddRange(child.Terms.OrderBy(p => p.Term_Seq).ToList()); //关联信号 c.Signal = child.Signal; if (child.Signal != null) @@ -333,14 +337,14 @@ namespace SWS.CAD.ViewModels } catch (Exception ex) { - System.Windows.MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error); + System.Windows.MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error); } finally { IsBusy = false; } - - + + } #endregion @@ -523,6 +527,44 @@ namespace SWS.CAD.ViewModels } #endregion + #region 查找节点路径 + public List FindNodePath(ObservableCollection nodes, TreeModel targetNode) + { + List path = new List(); + FindNodePathRecursive(nodes, targetNode, path); + return path; + } + + private bool FindNodePathRecursive(IEnumerable nodes, TreeModel targetNode, List currentPath) + { + foreach (var node in nodes) + { + currentPath.Add(node.Text); + if (node == targetNode) return true; // 找到目标节点,返回True并结束搜索 + if (node.ChildNodes.Count > 0 && FindNodePathRecursive(node.ChildNodes, targetNode, currentPath)) + return true; // 在子节点中继续搜索并找到目标节点,返回True并结束搜索 + currentPath.RemoveAt(currentPath.Count - 1); // 回溯,尝试下一个兄弟节点或父节点的其他兄弟节点 + } + return false; // 没有找到目标节点,返回False + } + #endregion + + #region 通过id查找项 + private TreeModel FindTreeModelById(IEnumerable TreeModels, string id) + { + foreach (var Tree in TreeModels) + { + if (Tree.ID == id) + return Tree; + + var foundInChildren = FindTreeModelById(Tree.ChildNodes, id); + if (foundInChildren != null) + return foundInChildren; + } + + return null; + } + #endregion #region 树形结构右键点击事件 public ICommand MouseRightCmd => new DelegateCommand(MouseRight_Click); @@ -685,13 +727,14 @@ namespace SWS.CAD.ViewModels DataItemName = listPro.Where(p => p.DisplayText.Equals("位置名称")).Select(p => p.PropertyValue).FirstOrDefault(), OrderID = int.Parse(listPro.Where(p => p.DisplayText.Equals("排序号")).Select(p => p.PropertyValue).FirstOrDefault()), }; - var httpres = await _dataItemService.SaveDetailForm(ent); - if (httpres != null) + var httpres = await _dataItemService.SaveDetailForm(ent) as learunHttpRes; + if (httpres.code != 200) { - System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; + System.Windows.MessageBox.Show(httpres.info.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; } PanelTreels.Clear(); PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); + SelectedTreeNode = FindNodeByNodeId(PanelTreels, httpres.data.DataItemID); } else if (RES.Result == ButtonResult.No) { } @@ -881,13 +924,15 @@ namespace SWS.CAD.ViewModels } #endregion - var httpres = await _iOModuleService.CreatePanelStripByProfile(e); - if (httpres != null) + var httpres = await _iOModuleService.CreatePanelStripByProfile(e) as learunHttpRes; + if (httpres.code != 200) { - System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; + System.Windows.MessageBox.Show(httpres.info.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; } PanelTreels.Clear(); PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); + SelectedTreeNode = FindTreeModelById(PanelTreels, httpres.data.StripID); + } else if (RES.Result == ButtonResult.No) { } @@ -940,13 +985,14 @@ namespace SWS.CAD.ViewModels DataItemName = listPro.Where(p => p.DisplayText.Equals("位置名称")).Select(p => p.PropertyValue).FirstOrDefault(), OrderID = int.Parse(listPro.Where(p => p.DisplayText.Equals("排序号")).Select(p => p.PropertyValue).FirstOrDefault()), }; - var httpres = await _dataItemService.SaveDetailForm(ent); - if (httpres != null) + var httpres = await _dataItemService.SaveDetailForm(ent) as learunHttpRes; + if (httpres.code != 200) { - System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; + System.Windows.MessageBox.Show(httpres.info.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; } PanelTreels.Clear(); PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); + SelectedTreeNode = FindNodeByNodeId(PanelTreels, httpres.info); } else if (RES.Result == ButtonResult.No) { } @@ -974,6 +1020,7 @@ namespace SWS.CAD.ViewModels { if (RES.Result == ButtonResult.Yes) { + var tempID = SelectedTreeNode.ID; var listPro = RES.Parameters.GetValue>(GlobalObject.dialogPar.para1.ToString()); ec_PanelStrip ent = new ec_PanelStrip() @@ -985,12 +1032,13 @@ namespace SWS.CAD.ViewModels StripID = StripIDValue, }; var httpres = await _iOModuleService.SavePanelStrip(ent); - if (httpres != null) + if (httpres!= null) { System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; } PanelTreels.Clear(); PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); + SelectedTreeNode = FindNodeByNodeId(PanelTreels, tempID); } else if (RES.Result == ButtonResult.No) { } @@ -1017,7 +1065,15 @@ namespace SWS.CAD.ViewModels MessageBoxResult result = System.Windows.MessageBox.Show($"确定删除[{SelectedTreeNode.Text}]节点以及子节点吗", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (result == MessageBoxResult.OK) { + var tempParentId = SelectedTreeNode.parentId; var httpres = await _iOModuleService.DeletePanelStrip(SelectedTreeNode.ID); + if (httpres!=null) + { + System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; + } + PanelTreels.Clear(); + PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); + SelectedTreeNode = FindTreeModelById(PanelTreels, tempParentId); } } return; @@ -1069,7 +1125,8 @@ namespace SWS.CAD.ViewModels //获取位号的电缆属性,判断是否设置电缆规格 var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(selectTagNumberOB.TagNumber); var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(selectTagNumberOB.TagNumber)).FirstOrDefault(); - if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) + if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) + //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) { System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; @@ -1108,6 +1165,7 @@ namespace SWS.CAD.ViewModels ec_Cable.EngineerDataID = selectTagNumberOB.EngineDataID; ec_Cable.Sets = new List(); int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; + int n = 0; for (int i = 0; i < CableSetCount; i++) { ec_CableSet ec_CableSet = new ec_CableSet(); @@ -1117,6 +1175,7 @@ namespace SWS.CAD.ViewModels int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; for (int j = 0; j < WireCount; j++) { + n++; ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.SetLevel = j + 1; @@ -1125,6 +1184,20 @@ namespace SWS.CAD.ViewModels switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) { case "按电缆编号": + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = n.ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + (n - 1)); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i + 1) + "-" + n.ToString(); + } + break; + case "按电缆对编号": if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) { Tag = (j + 1).ToString(); @@ -1135,12 +1208,9 @@ namespace SWS.CAD.ViewModels } else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) { - Tag = (i + 1).ToString(); + Tag = (i + 1) + "-" + (j + 1).ToString(); } break; - case "按电缆对编号": - a = selectTagNumberOB.TagNumber; - break; } ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSet.Wires.Add(ec_CableSetWire); @@ -1177,6 +1247,7 @@ namespace SWS.CAD.ViewModels ec_Cable.EngineerDataID = selectTagNumberOB.EngineDataID; ec_Cable.Sets = new List(); int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; + int n = 0; for (int i = 0; i < CableSetCount; i++) { ec_CableSet ec_CableSet = new ec_CableSet(); @@ -1186,6 +1257,7 @@ namespace SWS.CAD.ViewModels int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; for (int j = 0; j < WireCount; j++) { + n++; ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.SetLevel = j + 1; @@ -1194,6 +1266,20 @@ namespace SWS.CAD.ViewModels switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) { case "按电缆编号": + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = n.ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + (n - 1)); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i + 1) + "-" + n.ToString(); + } + break; + case "按电缆对编号": if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) { Tag = (j + 1).ToString(); @@ -1204,12 +1290,9 @@ namespace SWS.CAD.ViewModels } else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) { - Tag = (i + 1).ToString(); + Tag = (i + 1) + "-" + (j + 1).ToString(); } break; - case "按电缆对编号": - a = selectTagNumberOB.TagNumber; - break; } ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSet.Wires.Add(ec_CableSetWire); @@ -1502,11 +1585,12 @@ namespace SWS.CAD.ViewModels //获取位号的电缆属性,判断是否设置电缆规格 var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(resTagNumberListByPixels.TagNumber); var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(resTagNumberListByPixels.TagNumber)).FirstOrDefault(); + if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) - //{ - // System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; + { + System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return; - //} + } //获取电缆的配置,没有则创建新配置 var CableBy = await _iOModuleService.GetCableByEngID(resTagNumberListByPixels?.EngineDataID); if (CableBy == null) @@ -1540,6 +1624,7 @@ namespace SWS.CAD.ViewModels ec_Cable.EngineerDataID = resTagNumberListByPixels.EngineDataID; ec_Cable.Sets = new List(); int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; + int n = 0; for (int i = 0; i < CableSetCount; i++) { ec_CableSet ec_CableSet = new ec_CableSet(); @@ -1549,6 +1634,7 @@ namespace SWS.CAD.ViewModels int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; for (int j = 0; j < WireCount; j++) { + n++; ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.SetLevel = j + 1; @@ -1557,6 +1643,20 @@ namespace SWS.CAD.ViewModels switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) { case "按电缆编号": + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = n.ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + (n - 1)); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i + 1) + "-" + n.ToString(); + } + break; + case "按电缆对编号": if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) { Tag = (j + 1).ToString(); @@ -1567,12 +1667,9 @@ namespace SWS.CAD.ViewModels } else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) { - Tag = (i + 1).ToString(); + Tag = (i + 1) + "-" + (j + 1).ToString(); } break; - case "按电缆对编号": - a = resTagNumberListByPixels.TagNumber; - break; } ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSet.Wires.Add(ec_CableSetWire); @@ -1609,6 +1706,7 @@ namespace SWS.CAD.ViewModels ec_Cable.EngineerDataID = resTagNumberListByPixels.EngineDataID; ec_Cable.Sets = new List(); int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; + int n = 0; for (int i = 0; i < CableSetCount; i++) { ec_CableSet ec_CableSet = new ec_CableSet(); @@ -1618,6 +1716,7 @@ namespace SWS.CAD.ViewModels int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; for (int j = 0; j < WireCount; j++) { + n++; ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.SetLevel = j + 1; @@ -1626,6 +1725,20 @@ namespace SWS.CAD.ViewModels switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) { case "按电缆编号": + if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) + { + Tag = n.ToString(); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母")) + { + Tag = Tag + (char)('A' + (n - 1)); + } + else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) + { + Tag = (i + 1) + "-" + n.ToString(); + } + break; + case "按电缆对编号": if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) { Tag = (j + 1).ToString(); @@ -1636,12 +1749,9 @@ namespace SWS.CAD.ViewModels } else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) { - Tag = (i + 1).ToString(); + Tag = (i + 1) + "-" + (j + 1).ToString(); } break; - case "按电缆对编号": - a = resTagNumberListByPixels.TagNumber; - break; } ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSet.Wires.Add(ec_CableSetWire); @@ -2055,7 +2165,7 @@ namespace SWS.CAD.ViewModels if (result == MessageBoxResult.OK) { var httpres = await _iOModuleService.DeletePanelChannel(SelectedChannelInfo.ChannelID); - if (httpres!=null) + if (httpres != null) { System.Windows.MessageBox.Show(httpres, "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; @@ -2531,8 +2641,8 @@ namespace SWS.CAD.ViewModels ent.Signals = new List(); ent.Signals.Add(SelectedChannelInfo.Signal); //解除信号 - var data = await _wireGroupService.SaveSignals(ent); - if (data != null) + var data = await _wireGroupService.SaveSignals(ent) as learunHttpRes>; + if (data.code ==200) { ChannelInfos.Clear(); UpdateChannelInfos(); diff --git a/newFront/c#前端/SWS.CAD/ViewModels/DialogSignalPredistributionViewModel.cs b/newFront/c#前端/SWS.CAD/ViewModels/DialogSignalPredistributionViewModel.cs index f571491f..8f100e4e 100644 --- a/newFront/c#前端/SWS.CAD/ViewModels/DialogSignalPredistributionViewModel.cs +++ b/newFront/c#前端/SWS.CAD/ViewModels/DialogSignalPredistributionViewModel.cs @@ -1,29 +1,208 @@  +using Prism.Events; using Prism.Ioc; using Prism.Services.Dialogs; +using SWS.CAD.Event; using SWS.CAD.ViewModels.myViewModelBase; using SWS.CAD.Views; using SWS.CAD.Views.CustomControl; using SWS.Commons; +using SWS.Model; +using SWS.Service; using System; +using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; using System.Windows.Input; +using Telerik.Windows.Controls; using Unity; -using DelegateCommand = Prism.Commands.DelegateCommand; namespace SWS.CAD.ViewModels { public class DialogSignalPredistributionViewModel : DialogBase, IDialogAware { - private string objectTypeId; + #region 字段 + private ObservableCollection _PanelTreels = new ObservableCollection(); /// - /// 新建位号 + /// 页面左侧树形结构数据 /// - public ICommand Command_NewTagNumber { get; set; } + public ObservableCollection PanelTreels + { + get { return _PanelTreels; } + set { _PanelTreels = value; RaisePropertyChanged(nameof(PanelTreels)); } + } + + private Model.TreeModel _SelectedTreeNode; + /// + /// 当前选中的树形节点 + /// + public Model.TreeModel SelectedTreeNode + { + get { return _SelectedTreeNode; } + set + { + _SelectedTreeNode = value; + RaisePropertyChanged(nameof(SelectedTreeNode)); + var path= FindNodePath(PanelTreels, _SelectedTreeNode); + _eventAggregator.GetEvent().Publish(path); + } + } + + private ObservableCollection _SignalPredistributionInfos = new ObservableCollection(); + /// + /// 表格数据 + /// + public ObservableCollection SignalPredistributionInfos + { + get { return _SignalPredistributionInfos; } + set + { + _SignalPredistributionInfos = value; + RaisePropertyChanged(nameof(SignalPredistributionInfos)); + } + } + + + private string _SelectedOption1; + /// + /// 是否通讯母线 + /// + public string SelectedOption1 + { + get { return _SelectedOption1; } + set + { + _SelectedOption1 = value; + RaisePropertyChanged(nameof(SelectedOption1)); + } + } + + private string _SelectedOption2; + /// + /// 选择的信号类型 + /// + public string SelectedOption2 + { + get { return _SelectedOption2; } + set + { + _SelectedOption2 = value; + SignalColumnName = value; + RaisePropertyChanged(nameof(SelectedOption2)); + } + } + + private string _SignalColumnName; + /// + /// 信号类型列的列名 + /// + public string SignalColumnName + { + get { return _SignalColumnName; } + set + { + _SignalColumnName = value; + RaisePropertyChanged(nameof(SignalColumnName)); + if (value.Equals("Digital")) + { + SignalTypeColumn = new ObservableCollection() { "无公共端接线(断开报警NC)", "无公共端接线(闭合报警NO)", "带公共端接线(断开报警NC)", "带公共端接线(闭合报警NO)" }; + } + else if (value.Equals("4-20mA")) + { + SignalTypeColumn = new ObservableCollection() { "无源", "有源" }; + } + else if (value.Equals("-10V-10V")) + { + SignalTypeColumn = new ObservableCollection() { "无源", "有源" }; + } + else if (value.Equals("PT100")) + { + SignalTypeColumn = new ObservableCollection() { "量程100", "量程150", "量程200", "量程600" }; + } + else if (value.Equals("Pulse")) + { + SignalTypeColumn = new ObservableCollection() { "脉冲信号" }; + } + } + } + + + + private List _CommunicationFormats = new List() { "RS485", "RS482", "TCP/IP", "MQTT" }; + /// + /// 通讯格式集合 + /// + public List CommunicationFormats + { + get { return _CommunicationFormats; } + set + { + _CommunicationFormats = value; + RaisePropertyChanged(nameof(CommunicationFormats)); + } + } + + private string _CommunicationFormat = "RS485"; + /// + /// 通讯格式 + /// + public string CommunicationFormat + { + get { return _CommunicationFormat; } + set + { + _CommunicationFormat = value; + RaisePropertyChanged(nameof(CommunicationFormat)); + } + } + + private ObservableCollection _SignalTypeColumn; + /// + /// 信号类型列的下拉列表 + /// + public ObservableCollection SignalTypeColumn + { + get { return _SignalTypeColumn; } + set + { + _SignalTypeColumn = value; + RaisePropertyChanged(nameof(SignalTypeColumn)); + if (SignalPredistributionInfos != null) + { + foreach (var item in SignalPredistributionInfos) + { + item.SignalType = _SignalTypeColumn.FirstOrDefault(); + } + } + } + } + private List _InorOuts = new List() { "输出", "输入" }; + /// + /// 输入/输出列的下拉列表 + /// + public List InorOuts + { + get { return _InorOuts; } + set + { + _InorOuts = value; + RaisePropertyChanged(nameof(InorOuts)); + } + } + + #endregion + + IOModuleService _iOModuleService; + IEventAggregator _eventAggregator; + public DialogSignalPredistributionViewModel() { - title = "电缆信号预分配"; + _iOModuleService = GlobalObject.container.Resolve(); + _eventAggregator = GlobalObject.container.Resolve(); + } public string Title => ""; @@ -38,16 +217,157 @@ namespace SWS.CAD.ViewModels { } - - - public void OnDialogOpened(IDialogParameters parameters) + + private ec_Cable CableBy; + public async void OnDialogOpened(IDialogParameters parameters) { - //listTags = parameters.GetValue>(GlobalObject.dialogPar.info.ToString()); - objectTypeId = parameters.GetValue(GlobalObject.dialogPar.id.ToString()); + title = $"电缆信号({parameters.GetValue(GlobalObject.dialogPar.para2.ToString())})预分配"; + //树形结构数据 + PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); + //电缆信息 + CableBy = parameters.GetValue(GlobalObject.dialogPar.para1.ToString()); + //是否母线 + if (CableBy.CableClass.Equals("homerun")) + { + SelectedOption1 = "是"; + } + else if (CableBy.CableClass.Equals("conventional") || CableBy.CableClass.Equals("")) + { + SelectedOption1 = "否"; + + } + //设置默认信号类型 + if (string.IsNullOrEmpty(CableBy.PreAssignIOType)) + { + SelectedOption2 = "Digital"; + } + else + { + SelectedOption2 = CableBy.PreAssignIOType; + } + + //设置表格数据 + int index = 0; + foreach (var Set in CableBy.Sets) + { + SignalPredistributionInfo predistributionInfo = new SignalPredistributionInfo(); + predistributionInfo.CablePair = Set.CableSetName; + foreach (var Wire in Set.Wires) + { + index++; + predistributionInfo.Index.Add(index.ToString()); + predistributionInfo.CableWires.Add(Wire); + predistributionInfo.Polaritys.Add(Wire); + } + if (string.IsNullOrEmpty(Set.PreAssignIOTypeDetail)) + { + predistributionInfo.SignalType = SignalTypeColumn.FirstOrDefault(); + } + else + { + predistributionInfo.SignalType = Set.PreAssignIOTypeDetail; + } + predistributionInfo.ChineseDescription = Set.PreAssignGroup_Desc; + predistributionInfo.EnglishDescription = Set.PreAssignGroup_Desc_EN; + + if (string.IsNullOrEmpty(Set.PreAssignInOrOut)) + { + predistributionInfo.InorOut = InorOuts.FirstOrDefault(); + } + else + { + predistributionInfo.InorOut = Set.PreAssignInOrOut; + } + predistributionInfo.SensorCode = Set.PreAssignSensorCode; + + + SignalPredistributionInfos.Add(predistributionInfo); + } + //是否预关联,有则选中节点 + foreach (var Panel in PanelTreels) + { + if (!string.IsNullOrEmpty(Panel.ID)) + { + if (Panel.ID.Equals(CableBy.PanelID)) + { + SelectedTreeNode = Panel; + break; + } + } + foreach (var Child in Panel.ChildNodes) + { + if (!string.IsNullOrEmpty(Child.ID)) + { + if (Child.ID.Equals(CableBy.PanelID)) + { + SelectedTreeNode = Child; + break; + } + } + } + } + + } - public override void ExecuteOKCommandAsync(object para) + public override async void ExecuteOKCommandAsync(object para) { + //创建SaveCable接口实例 + ec_Cable newCable = new ec_Cable(); + if (SelectedOption1.Equals("是")) + { + newCable.CableClass = "homerun"; + newCable.PreAssignIOType = CommunicationFormat; + } + else + { + newCable.CableClass = "conventional"; + newCable.PreAssignIOType = SelectedOption2; + } + + newCable.CableID = CableBy.CableID; + newCable.EngineerDataID = CableBy.EngineerDataID; + if (SelectedTreeNode != null) + { + newCable.PanelID = SelectedTreeNode.ID; + } + else + { + MessageBox.Show("请选择系统柜!", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + newCable.UpdateUserID = GlobalObject.userInfo.userId; + newCable.Sets = new List(); + foreach (var CableBySet in CableBy.Sets) + { + ec_CableSet newCableSet = new ec_CableSet(); + newCableSet.CableSetID = CableBySet.CableSetID; + newCableSet.CableSetName = CableBySet.CableSetName; + newCableSet.CableSetSeq = CableBySet.CableSetSeq; + newCableSet.IsConned = CableBySet.IsConned; + newCableSet.PreAssignGroup_Desc = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).ChineseDescription; + newCableSet.PreAssignGroup_Desc_EN = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).EnglishDescription; + newCableSet.PreAssignIOTypeDetail = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).SignalType; + newCableSet.PreAssignInOrOut = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).InorOut; + newCableSet.PreAssignSensorCode = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).SensorCode; + newCableSet.Wires = new List(); + foreach (var wire in CableBySet.Wires) + { + ec_CableSetWire newWire = new ec_CableSetWire(); + newWire.Polarity = wire.Polarity; + newWire.SetLevel = 0; + newWire.WireID = wire.WireID; + newWire.Wire_Tag = wire.Wire_Tag; + newWire.Wire_Color_ID = wire.Wire_Color_ID; + newWire.PreAssignChannelTermNo = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).CableWires.FirstOrDefault(c => c.Wire_Tag.Equals(wire.Wire_Tag)).PreAssignChannelTermNo; + + newCableSet.Wires.Add(newWire); + } + newCable.Sets.Add(newCableSet); + } + + var httpres = await _iOModuleService.SaveCable(newCable); + IDialogParameters res = new Prism.Services.Dialogs.DialogParameters(); //res.Add(GlobalObject.dialogPar.info.ToString(), TagNumber); RequestClose.Invoke(new DialogResult(ButtonResult.Yes, res)); @@ -65,8 +385,199 @@ namespace SWS.CAD.ViewModels } this.Dispose(); } + #region 方法 + public ICommand ButtonCmd => new DelegateCommand(Button_Click); + /// + /// 页面左侧按钮 + /// + /// + public virtual async void Button_Click(object parameter) + { + #region 清除配置 + if (parameter.ToString().Equals("清除配置")) + { + + MessageBoxResult result = MessageBox.Show($"确定删除“{ CableBy.TagNumber}”电缆配置?", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question); + if (result == MessageBoxResult.OK) + { + var httpres = await _iOModuleService.DeleteCableProfile(CableBy.CableID); + if (httpres == null) + { + RequestClose.Invoke(new DialogResult(ButtonResult.Cancel)); + this.Dispose(); + } + } + return; + } + #endregion + + #region 指定中英文 + if (parameter.ToString().Equals("指定中英文")) + { + //SelectedTreeNode = PanelTreels[2].ChildNodes.LastOrDefault(); + return; + } + #endregion + } + + + #region 查找节点路径 + public List FindNodePath(ObservableCollection nodes, TreeModel targetNode) + { + List path = new List(); + FindNodePathRecursive(nodes, targetNode, path); + return path; + } + + private bool FindNodePathRecursive(IEnumerable nodes, TreeModel targetNode, List currentPath) + { + foreach (var node in nodes) + { + currentPath.Add(node.Text); + if (node == targetNode) return true; // 找到目标节点,返回True并结束搜索 + if (node.ChildNodes.Count > 0 && FindNodePathRecursive(node.ChildNodes, targetNode, currentPath)) + return true; // 在子节点中继续搜索并找到目标节点,返回True并结束搜索 + currentPath.RemoveAt(currentPath.Count - 1); // 回溯,尝试下一个兄弟节点或父节点的其他兄弟节点 + } + return false; // 没有找到目标节点,返回False + } + #endregion + + + + #endregion } + public class SignalPredistributionInfo : DialogBase + { + #region 字段 + private ObservableCollection _Index = new ObservableCollection(); + /// + /// 序号集合 + /// + public ObservableCollection Index + { + get { return _Index; } + set { _Index = value; } + } + + private string _CablePair; + /// + /// 电缆对 + /// + public string CablePair + { + get { return _CablePair; } + set { _CablePair = value; } + } + + private ObservableCollection _CableWires = new ObservableCollection(); + /// + /// 电缆线号 + /// + public ObservableCollection CableWires + { + get { return _CableWires; } + set { _CableWires = value; } + } + + private ObservableCollection _Polaritys = new ObservableCollection(); + /// + /// 极性 + /// + public ObservableCollection Polaritys + { + get { return _Polaritys; } + set + { + _Polaritys = value; + RaisePropertyChanged(nameof(Polaritys)); + } + } + + private string _SignalType; + /// + /// 信号类型 + /// + public string SignalType + { + get { return _SignalType; } + set + { + _SignalType = value; + RaisePropertyChanged(nameof(SignalType)); + } + } + + + private string _ChineseDescription; + /// + /// 中文描述 + /// + public string ChineseDescription + { + get { return _ChineseDescription; } + set + { + _ChineseDescription = value; + RaisePropertyChanged(nameof(ChineseDescription)); + } + } + + private string _EnglishDescription; + /// + /// 英文描述 + /// + public string EnglishDescription + { + get { return _EnglishDescription; } + set + { + _EnglishDescription = value; + RaisePropertyChanged(nameof(EnglishDescription)); + } + } + + private string _InorOut; + /// + /// 输入/输出 + /// + public string InorOut + { + get { return _InorOut; } + set + { + _InorOut = value; + RaisePropertyChanged(nameof(InorOut)); + } + } + + private string _SensorCode; + /// + /// 传感器编号 + /// + public string SensorCode + { + get { return _SensorCode; } + set + { + _SensorCode = value; + RaisePropertyChanged(nameof(SensorCode)); + } + } + + + private ObservableCollection _Terms = new ObservableCollection(); + /// + /// 端子号集合 + /// + public ObservableCollection Terms + { + get { return _Terms; } + set { _Terms = value; } + } + #endregion + } } diff --git a/newFront/c#前端/SWS.CAD/Views/Dialog/DialogIODistributions/DialogIODistribution.xaml b/newFront/c#前端/SWS.CAD/Views/Dialog/DialogIODistributions/DialogIODistribution.xaml index 6e8fb602..d9d29926 100644 --- a/newFront/c#前端/SWS.CAD/Views/Dialog/DialogIODistributions/DialogIODistribution.xaml +++ b/newFront/c#前端/SWS.CAD/Views/Dialog/DialogIODistributions/DialogIODistribution.xaml @@ -248,7 +248,6 @@ - @@ -265,7 +264,6 @@ - @@ -283,7 +281,6 @@ - @@ -503,6 +500,7 @@ Margin="5" telerik:StyleManager.Theme="Office_Blue" AllowDrop="True" AutoScrollToSelectedItem="True" IsVirtualizing="True" + telerik:TextSearch.TextPath="Text" > diff --git a/newFront/c#前端/SWS.CAD/Views/Dialog/DialogIODistributions/DialogIODistribution.xaml.cs b/newFront/c#前端/SWS.CAD/Views/Dialog/DialogIODistributions/DialogIODistribution.xaml.cs index 6e56e1e7..16f301ee 100644 --- a/newFront/c#前端/SWS.CAD/Views/Dialog/DialogIODistributions/DialogIODistribution.xaml.cs +++ b/newFront/c#前端/SWS.CAD/Views/Dialog/DialogIODistributions/DialogIODistribution.xaml.cs @@ -1,12 +1,17 @@  using System; +using System.Collections.Generic; using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using Prism.Events; +using SWS.CAD.Event; using SWS.CAD.ViewModels; +using SWS.Commons; using Telerik.Windows.Controls; +using Unity; namespace SWS.CAD.Views.Dialog { @@ -15,10 +20,14 @@ namespace SWS.CAD.Views.Dialog /// public partial class DialogIODistribution : UserControl { + IEventAggregator _eventAggregator; + public DialogIODistribution() { InitializeComponent(); DataContext = new DialogIODistributionViewModel(); + _eventAggregator = GlobalObject.container.Resolve(); + _eventAggregator.GetEvent().Subscribe(ScrollToSelectedItem, ThreadOption.UIThread, true); } private void RadTreeView_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) @@ -83,5 +92,13 @@ namespace SWS.CAD.Views.Dialog return source as T; } + // 滚动到选中项 + private void ScrollToSelectedItem(object path) + { + var pathls = path as List; + var ph = string.Join("\\", pathls); + treeView1.BringPathIntoView(ph); + } + } } diff --git a/newFront/c#前端/SWS.CAD/Views/Dialog/DialogSignalPredistribution.xaml b/newFront/c#前端/SWS.CAD/Views/Dialog/DialogSignalPredistribution.xaml index 6cb5dd6b..7b74df44 100644 --- a/newFront/c#前端/SWS.CAD/Views/Dialog/DialogSignalPredistribution.xaml +++ b/newFront/c#前端/SWS.CAD/Views/Dialog/DialogSignalPredistribution.xaml @@ -6,8 +6,9 @@ xmlns:prism="http://prismlibrary.com/" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:local="clr-namespace:SWS.CAD.Views.Dialog" + xmlns:cvt="clr-namespace:SWS.Commons.Helper.Converter;assembly=SWS.Commons" xmlns:CustomControl="clr-namespace:SWS.CustomControl;assembly=SWS.CustomControl" - Width="1000" Height="800" + Width="1000" Height="790" mc:Ignorable="d" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - - - - + + + + + - @@ -67,23 +303,26 @@ - - + + @@ -109,8 +348,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/newFront/c#前端/SWS.CAD/Views/Dialog/DialogSignalPredistribution.xaml.cs b/newFront/c#前端/SWS.CAD/Views/Dialog/DialogSignalPredistribution.xaml.cs index 7330e671..c38053d8 100644 --- a/newFront/c#前端/SWS.CAD/Views/Dialog/DialogSignalPredistribution.xaml.cs +++ b/newFront/c#前端/SWS.CAD/Views/Dialog/DialogSignalPredistribution.xaml.cs @@ -12,6 +12,13 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using System.Windows.Threading; +using Prism.Events; +using SWS.CAD.Event; +using SWS.Commons; +using SWS.Model; +using Telerik.Windows.Controls; +using Unity; namespace SWS.CAD.Views.Dialog { @@ -20,9 +27,23 @@ namespace SWS.CAD.Views.Dialog /// public partial class DialogSignalPredistribution : UserControl { + IEventAggregator _eventAggregator; + public DialogSignalPredistribution() { InitializeComponent(); + _eventAggregator = GlobalObject.container.Resolve(); + _eventAggregator.GetEvent().Subscribe(ScrollToSelectedItem, ThreadOption.UIThread, true); + } + + // 滚动到选中项 + private void ScrollToSelectedItem(object path) + { + var pathls = path as List; + var ph = string.Join("\\", pathls); + treeView1.BringPathIntoView(ph); } } + + } diff --git a/newFront/c#前端/SWS.Commons/GlobalObject.cs b/newFront/c#前端/SWS.Commons/GlobalObject.cs index 98d8e17e..283ecf04 100644 --- a/newFront/c#前端/SWS.Commons/GlobalObject.cs +++ b/newFront/c#前端/SWS.Commons/GlobalObject.cs @@ -84,6 +84,7 @@ namespace SWS.Commons public static List designTree = new List(); #endregion + public enum DBConst { /// diff --git a/newFront/c#前端/SWS.Commons/Helper/Converter/RadioButtonValueConverter.cs b/newFront/c#前端/SWS.Commons/Helper/Converter/RadioButtonValueConverter.cs new file mode 100644 index 00000000..fa72d695 --- /dev/null +++ b/newFront/c#前端/SWS.Commons/Helper/Converter/RadioButtonValueConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using SWS.Model; + +namespace SWS.Commons.Helper.Converter +{ + public class RadioButtonValueConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is string isChecked) + { + if (isChecked.Equals(parameter.ToString())) + { + return true; + } + else + { + return false; + } + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is bool isChecked) + { + return parameter.ToString(); + } + return parameter.ToString(); + } + } +} diff --git a/newFront/c#前端/SWS.Commons/SWS.Commons.csproj b/newFront/c#前端/SWS.Commons/SWS.Commons.csproj index 64cae859..41dac945 100644 --- a/newFront/c#前端/SWS.Commons/SWS.Commons.csproj +++ b/newFront/c#前端/SWS.Commons/SWS.Commons.csproj @@ -106,6 +106,7 @@ + diff --git a/newFront/c#前端/SWS.Service/DataItemService.cs b/newFront/c#前端/SWS.Service/DataItemService.cs index 0cd7fb75..eb9459e2 100644 --- a/newFront/c#前端/SWS.Service/DataItemService.cs +++ b/newFront/c#前端/SWS.Service/DataItemService.cs @@ -50,16 +50,16 @@ namespace SWS.Service public async Task SaveDetailForm(ec_dataitemdetail entity) { var res = await this.PostBodyAsync($"DataItemApi/SaveDetailForm?ProjectId={GlobalObject.curProject?.ProjectId}", entity); - if (res.code == 200) - { - //return res.info; - return null; - } - else - { - return res.info; // 返回错误信息 - } - + //if (res.code == 200) + //{ + // //return res.info; + // return null; + //} + //else + //{ + // return res.info; // 返回错误信息 + //} + return res; } } } diff --git a/newFront/c#前端/SWS.Service/IOModuleService.cs b/newFront/c#前端/SWS.Service/IOModuleService.cs index aa1eab8f..7fc4aff5 100644 --- a/newFront/c#前端/SWS.Service/IOModuleService.cs +++ b/newFront/c#前端/SWS.Service/IOModuleService.cs @@ -139,16 +139,16 @@ namespace SWS.Service public async Task CreatePanelStripByProfile(ec_PanelStrip entity) { var res = await this.PostBodyAsync($"IOModuleApi/CreatePanelStripByProfile?projId={GlobalObject.curProject?.ProjectId}", entity); - if (res.code == 200) - { - //return res.info; - return null; - } - else - { - return res.info; // 返回错误信息 - } - + //if (res.code == 200) + //{ + // //return res.info; + // return null; + //} + //else + //{ + // return res.info; // 返回错误信息 + //} + return res; } public async Task DeletePanel(string PanelID) diff --git a/newFront/c#前端/SWS.WPF/ViewModels/DialogSignalManagementVM/DialogSignalManagementViewModel.cs b/newFront/c#前端/SWS.WPF/ViewModels/DialogSignalManagementVM/DialogSignalManagementViewModel.cs index 786fe771..db5a0ee5 100644 --- a/newFront/c#前端/SWS.WPF/ViewModels/DialogSignalManagementVM/DialogSignalManagementViewModel.cs +++ b/newFront/c#前端/SWS.WPF/ViewModels/DialogSignalManagementVM/DialogSignalManagementViewModel.cs @@ -423,6 +423,10 @@ namespace SWS.WPF.ViewModels //DateTime startTime = DateTime.Now; //设置信号源 signals = await _wireGroupService.GetSignals(GlobalObject.curProject.ProjectId, false); + if (signals == null) + { + signals = new List(); + } //TimeSpan duration = DateTime.Now - startTime; //System.Windows.MessageBox.Show($"Time taken: {duration.Seconds} milliseconds"); count = signals.Count().ToString();