2025-08-15 16:44:13 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
using System.Windows.Controls;
|
2025-08-15 16:44:13 +08:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Windows.Input;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
using System.Windows.Interop;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Media3D;
|
|
|
|
|
using Bricscad.EditorInput;
|
|
|
|
|
using Newtonsoft.Json;
|
2025-08-15 16:44:13 +08:00
|
|
|
|
using Prism.Services.Dialogs;
|
|
|
|
|
using SWS.CAD.Base;
|
|
|
|
|
using SWS.Commons;
|
|
|
|
|
using SWS.Electrical.Models;
|
|
|
|
|
using SWS.Model;
|
|
|
|
|
using SWS.Service;
|
|
|
|
|
using SWS.WPF.ViewModels;
|
|
|
|
|
using Teigha.DatabaseServices;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
using Teigha.Geometry;
|
|
|
|
|
using Teigha.GraphicsSystem;
|
2025-08-15 16:44:13 +08:00
|
|
|
|
using Telerik.Windows.Controls;
|
|
|
|
|
using Unity;
|
|
|
|
|
using Visibility = System.Windows.Visibility;
|
|
|
|
|
|
|
|
|
|
namespace SWS.Electrical.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class DialogAutoArrangeLayoutViewModel : DialogBase, IDialogAware
|
|
|
|
|
{
|
|
|
|
|
private ObservableCollection<DtoDrawing> _listDrawings;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 布置图列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<DtoDrawing> listDrawings
|
|
|
|
|
{
|
|
|
|
|
get { return this._listDrawings; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._listDrawings)
|
|
|
|
|
{
|
|
|
|
|
this._listDrawings = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listDrawings));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
private ObservableCollection<DtoAutoPlotLayout> _listBasePoint;
|
|
|
|
|
/// <summary>
|
2025-09-22 14:28:19 +08:00
|
|
|
|
/// 正常基点元件列表
|
2025-09-02 11:21:40 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<DtoAutoPlotLayout> listBasePoint
|
|
|
|
|
{
|
|
|
|
|
get { return this._listBasePoint; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._listBasePoint)
|
|
|
|
|
{
|
|
|
|
|
this._listBasePoint = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listBasePoint));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-22 14:28:19 +08:00
|
|
|
|
private ObservableCollection<DtoAutoPlotLayout> _listErrBasePoint;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异常基点元件列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<DtoAutoPlotLayout> listErrBasePoint
|
|
|
|
|
{
|
|
|
|
|
get { return this._listErrBasePoint; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._listErrBasePoint)
|
|
|
|
|
{
|
|
|
|
|
this._listErrBasePoint = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listErrBasePoint));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
private DtoAutoPlotLayout _SelectedTag;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 基点元件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DtoAutoPlotLayout SelectedTag
|
|
|
|
|
{
|
|
|
|
|
get { return this._SelectedTag; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._SelectedTag = value;
|
|
|
|
|
RaisePropertyChanged(nameof(SelectedTag));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _IsSelectAll = false;
|
|
|
|
|
public bool IsSelectAll
|
|
|
|
|
{
|
|
|
|
|
get { return _IsSelectAll; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_IsSelectAll = value;
|
|
|
|
|
RaisePropertyChanged(nameof(IsSelectAll));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private ObservableCollection<TextBlock> _listMsg;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 信息列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<TextBlock> listMsg
|
|
|
|
|
{
|
|
|
|
|
get { return this._listMsg; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._listMsg)
|
|
|
|
|
{
|
|
|
|
|
this._listMsg = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listMsg));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-15 16:44:13 +08:00
|
|
|
|
private ObservableCollection<KeyValueModel> _listRange;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 范围
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<KeyValueModel> listRange
|
|
|
|
|
{
|
|
|
|
|
get { return this._listRange; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._listRange)
|
|
|
|
|
{
|
|
|
|
|
this._listRange = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listRange));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private KeyValueModel _selectRange;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选中范围
|
|
|
|
|
/// </summary>
|
|
|
|
|
public KeyValueModel selectRange
|
|
|
|
|
{
|
|
|
|
|
get { return this._selectRange; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._selectRange)
|
|
|
|
|
{
|
|
|
|
|
this._selectRange = value;
|
2025-09-10 10:57:20 +08:00
|
|
|
|
RangeChange(value);
|
2025-08-15 16:44:13 +08:00
|
|
|
|
RaisePropertyChanged(nameof(selectRange));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<KeyValueModel> _listOperator;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 判断
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<KeyValueModel> listOperator
|
|
|
|
|
{
|
|
|
|
|
get { return this._listOperator; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._listOperator)
|
|
|
|
|
{
|
|
|
|
|
this._listOperator = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listOperator));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private KeyValueModel _selectOperator;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选中判断
|
|
|
|
|
/// </summary>
|
|
|
|
|
public KeyValueModel selectOperator
|
|
|
|
|
{
|
|
|
|
|
get { return this._selectOperator; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._selectOperator)
|
|
|
|
|
{
|
|
|
|
|
this._selectOperator = value;
|
|
|
|
|
RaisePropertyChanged(nameof(selectOperator));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-10 10:57:20 +08:00
|
|
|
|
private ObservableCollection<KeyValueModel> _listValue;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 输入值 列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<KeyValueModel> listValue
|
|
|
|
|
{
|
|
|
|
|
get { return this._listValue; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._listValue)
|
|
|
|
|
{
|
|
|
|
|
this._listValue = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listValue));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-15 16:44:13 +08:00
|
|
|
|
private string _inputValue = "";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 输入值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string inputValue
|
|
|
|
|
{
|
|
|
|
|
get { return _inputValue; }
|
|
|
|
|
set { _inputValue = value; OnPropertyChanged(nameof(inputValue)); }
|
|
|
|
|
}
|
2025-09-22 14:28:19 +08:00
|
|
|
|
private string _NormalTagCount = "正常元件";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 正常位号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string NormalTagCount
|
|
|
|
|
{
|
|
|
|
|
get { return _NormalTagCount; }
|
|
|
|
|
set { _NormalTagCount = value; OnPropertyChanged(nameof(NormalTagCount)); }
|
|
|
|
|
}
|
|
|
|
|
private string _ErrTagCount = "异常元件";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异常位号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ErrTagCount
|
|
|
|
|
{
|
|
|
|
|
get { return _ErrTagCount; }
|
|
|
|
|
set { _ErrTagCount = value; OnPropertyChanged(nameof(ErrTagCount)); }
|
|
|
|
|
}
|
2025-08-15 16:44:13 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 命令事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand Command_StartDrawing { get; set; }
|
2025-09-02 11:21:40 +08:00
|
|
|
|
public ICommand Command_GetBasePoint { get; set; }
|
|
|
|
|
|
|
|
|
|
public ICommand Command_SelectedTag { get; set; }
|
|
|
|
|
|
|
|
|
|
public ICommand Command_SelectedAll { get; set; }
|
2025-08-15 16:44:13 +08:00
|
|
|
|
|
|
|
|
|
PlotLayoutService _ServicePlotLayout;
|
|
|
|
|
DrawingServce _ServiceDrawing;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
AnnexesService _ServiceAnnexes;
|
|
|
|
|
LibraryFileService _ServiceLibraryFile;
|
|
|
|
|
DrawingCatalogueService _ServiceDrawingCatalogue;
|
|
|
|
|
EnginedataService _ServiceEnginedata;
|
|
|
|
|
ObjectTypeService _ServiceObjectType;
|
|
|
|
|
ProjectSettingsService _ServiceProjectSettings;
|
2025-09-10 10:57:20 +08:00
|
|
|
|
DataItemService _ServiceDataItem;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
List<string> listTagNumberSucc = new List<string>();
|
|
|
|
|
private bool isDrawing = false;//是否正在画图
|
|
|
|
|
private string dwgName = string.Empty;
|
|
|
|
|
private List<string> listLibraryTagName = new List<string>();//元件图纸上的位号属性名称,
|
2025-09-22 09:21:04 +08:00
|
|
|
|
private List<KeyValueModel> listDeck = new List<KeyValueModel>();//甲板号值列表
|
2025-09-10 10:57:20 +08:00
|
|
|
|
private List<KeyValueModel> listArea = new List<KeyValueModel>();//区域值列表
|
|
|
|
|
private List<KeyValueModel> listSystem = new List<KeyValueModel>();//所属系统值列表
|
2025-08-15 16:44:13 +08:00
|
|
|
|
public DialogAutoArrangeLayoutViewModel()
|
|
|
|
|
{
|
|
|
|
|
Command_StartDrawing = new DelegateCommand(onStartDrawing);
|
2025-09-02 11:21:40 +08:00
|
|
|
|
Command_GetBasePoint = new DelegateCommand(onGetBasePoint);
|
|
|
|
|
Command_SelectedTag = new DelegateCommand(onSelectedTag);
|
|
|
|
|
Command_SelectedAll = new DelegateCommand(onSelectedAll);
|
2025-08-15 16:44:13 +08:00
|
|
|
|
title = "布置图自动绘制";
|
|
|
|
|
_ServicePlotLayout = GlobalObject.container.Resolve<PlotLayoutService>();
|
|
|
|
|
_ServiceDrawing = GlobalObject.container.Resolve<DrawingServce>();
|
2025-09-02 11:21:40 +08:00
|
|
|
|
_ServiceAnnexes = GlobalObject.container.Resolve<AnnexesService>();
|
|
|
|
|
_ServiceLibraryFile = GlobalObject.container.Resolve<LibraryFileService>();
|
|
|
|
|
_ServiceDrawingCatalogue = GlobalObject.container.Resolve<DrawingCatalogueService>();
|
|
|
|
|
_ServiceEnginedata = GlobalObject.container.Resolve<EnginedataService>();
|
|
|
|
|
_ServiceObjectType = GlobalObject.container.Resolve<ObjectTypeService>();
|
|
|
|
|
_ServiceProjectSettings = GlobalObject.container.Resolve<ProjectSettingsService>();
|
2025-09-22 09:21:04 +08:00
|
|
|
|
_ServiceDataItem = GlobalObject.container.Resolve<DataItemService>();
|
2025-08-15 16:44:13 +08:00
|
|
|
|
listDrawings = new ObservableCollection<DtoDrawing>();
|
2025-09-02 11:21:40 +08:00
|
|
|
|
listBasePoint = new ObservableCollection<DtoAutoPlotLayout>();
|
2025-09-22 14:28:19 +08:00
|
|
|
|
listErrBasePoint = new ObservableCollection<DtoAutoPlotLayout>();
|
2025-09-02 11:21:40 +08:00
|
|
|
|
listMsg = new ObservableCollection<TextBlock>();
|
2025-08-15 16:44:13 +08:00
|
|
|
|
var list = new ObservableCollection<KeyValueModel>();
|
|
|
|
|
list.Add(new KeyValueModel { Key = "甲板号", Value = "甲板号" });
|
2025-09-22 09:21:04 +08:00
|
|
|
|
//list.Add(new KeyValueModel { Key = "区域", Value = "区域" });
|
2025-09-02 11:21:40 +08:00
|
|
|
|
list.Add(new KeyValueModel { Key = "所属系统", Value = "所属系统" });
|
2025-08-15 16:44:13 +08:00
|
|
|
|
listRange = new ObservableCollection<KeyValueModel>(list);
|
|
|
|
|
listOperator = new ObservableCollection<KeyValueModel>()
|
2025-09-02 11:21:40 +08:00
|
|
|
|
{ new KeyValueModel { Key = "等于", Value = "=" }
|
2025-08-15 16:44:13 +08:00
|
|
|
|
};
|
|
|
|
|
selectOperator = listOperator[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Title => "";
|
|
|
|
|
|
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
|
|
|
|
|
|
|
|
public bool CanCloseDialog()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnDialogClosed()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2025-09-10 10:57:20 +08:00
|
|
|
|
private List<TreeModel> GetChildNodes(TreeModel treeModel)
|
|
|
|
|
{
|
|
|
|
|
List<TreeModel> listModel = new List<TreeModel>();
|
|
|
|
|
if (treeModel.ChildNodes != null && treeModel.ChildNodes.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in treeModel.ChildNodes)
|
|
|
|
|
{
|
|
|
|
|
if (item.NodeType == "1")
|
|
|
|
|
{
|
|
|
|
|
listModel.Add(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var list = GetChildNodes(item);
|
|
|
|
|
if (list.Any())
|
|
|
|
|
{
|
|
|
|
|
listModel.AddRange(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return listModel;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return listModel;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
public async void OnDialogOpened(IDialogParameters parameters)
|
2025-08-15 16:44:13 +08:00
|
|
|
|
{
|
2025-09-02 11:21:40 +08:00
|
|
|
|
try
|
2025-08-15 16:44:13 +08:00
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
//if (GlobalObj.treeDrawings.Any())
|
|
|
|
|
//{
|
|
|
|
|
// foreach (var model in GlobalObj.treeDrawings)
|
|
|
|
|
// {
|
|
|
|
|
// if (model.Text == "布置图")
|
|
|
|
|
// {
|
|
|
|
|
// foreach (var item in model.ChildNodes)
|
|
|
|
|
// {
|
|
|
|
|
// if (item.NodeType == "1")
|
|
|
|
|
// {
|
|
|
|
|
// listDrawings.Add(new DtoDrawing() { DrawingFileID = item.ID, DrawingFileName = item.Text });
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// if (item.Text == "封面、目录、设计说明" || item.Text == "材料表")
|
|
|
|
|
// { continue; }
|
|
|
|
|
// var list = GetChildNodes(item);
|
|
|
|
|
// if (list.Any())
|
|
|
|
|
// {
|
|
|
|
|
// foreach (var dto in list)
|
|
|
|
|
// {
|
|
|
|
|
// listDrawings.Add(new DtoDrawing() { DrawingFileID = dto.ID, DrawingFileName = dto.Text });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
IsBusy = true;
|
|
|
|
|
BusyContent = "数据加载中...";
|
2025-09-02 11:21:40 +08:00
|
|
|
|
if (!listDrawings.Any())
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"布置图列表加载中...");
|
|
|
|
|
var listDwg = await _ServiceDrawing.GetDrawingCatalogue();
|
|
|
|
|
if (listDwg == null)
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"布置图列表没有数据!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
foreach (var model in listDwg)
|
|
|
|
|
{
|
|
|
|
|
if (model.Text == "布置图")
|
|
|
|
|
{
|
|
|
|
|
if (model.ChildNodes == null)
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"布置图列表没有数据!");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in model.ChildNodes)
|
|
|
|
|
{
|
|
|
|
|
if (item.NodeType == "1")
|
|
|
|
|
{
|
|
|
|
|
listDrawings.Add(new DtoDrawing() { DrawingFileID = item.ID, DrawingFileName = item.Text });
|
2025-09-10 10:57:20 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (item.Text == "封面、目录、设计说明" || item.Text == "材料表")
|
|
|
|
|
{ continue; }
|
|
|
|
|
var list = GetChildNodes(item);
|
|
|
|
|
if (list.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var dto in list)
|
|
|
|
|
{
|
|
|
|
|
listDrawings.Add(new DtoDrawing() { DrawingFileID = dto.ID, DrawingFileName = dto.Text });
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AddMsg($"布置图列表加载完成!");
|
|
|
|
|
}
|
|
|
|
|
var settingModel = await _ServiceProjectSettings.GetEntity("布置图图例显示位号名称");
|
|
|
|
|
if (settingModel == null)
|
|
|
|
|
{
|
|
|
|
|
listLibraryTagName.Add("位号");//默认
|
|
|
|
|
}
|
|
|
|
|
else { listLibraryTagName = settingModel.SettingValue.Split(',').ToList(); }
|
2025-09-10 10:57:20 +08:00
|
|
|
|
//区域下拉框对应值列表
|
|
|
|
|
var listDetail = await _ServiceDataItem.GetDetails("Area");
|
|
|
|
|
if (listDetail != null && listDetail.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in listDetail)
|
2025-09-22 09:21:04 +08:00
|
|
|
|
{ listArea.Add(new KeyValueModel() { Key = item.DataItemName, Value = item.DataItemName }); }
|
2025-09-10 10:57:20 +08:00
|
|
|
|
}
|
|
|
|
|
//甲板号下拉框对应值列表
|
|
|
|
|
listDetail = await _ServiceDataItem.GetDetails("甲板号");
|
|
|
|
|
if (listDetail != null && listDetail.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in listDetail)
|
|
|
|
|
{ listDeck.Add(new KeyValueModel() { Key = item.DataItemName, Value = item.DataItemName }); }
|
|
|
|
|
}
|
|
|
|
|
//所属系统下拉框对应值列表
|
|
|
|
|
listDetail = await _ServiceDataItem.GetDetails("Be_DrawingSystem");
|
|
|
|
|
if (listDetail != null && listDetail.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in listDetail)
|
|
|
|
|
{ listSystem.Add(new KeyValueModel() { Key = item.DataItemName, Value = item.DataItemName }); }
|
|
|
|
|
}
|
|
|
|
|
selectRange = listRange[0];
|
2025-09-22 09:21:04 +08:00
|
|
|
|
IsBusy = false;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
IsBusy = false;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
MessageBox.Show("DialogOpened异常:" + ex.Message);
|
|
|
|
|
}
|
2025-08-15 16:44:13 +08:00
|
|
|
|
}
|
2025-09-10 10:57:20 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下拉值列表绑定
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
private void RangeChange(KeyValueModel model)
|
|
|
|
|
{
|
|
|
|
|
inputValue = "";
|
|
|
|
|
if (model.Value == "甲板号")
|
|
|
|
|
{ listValue = new ObservableCollection<KeyValueModel>(listDeck); }
|
2025-09-22 09:21:04 +08:00
|
|
|
|
//else if (model.Value == "区域")
|
|
|
|
|
//{ listValue = new ObservableCollection<KeyValueModel>(listArea); }
|
2025-09-10 10:57:20 +08:00
|
|
|
|
else if (model.Value == "所属系统")
|
|
|
|
|
{ listValue = new ObservableCollection<KeyValueModel>(listSystem); }
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取基点信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="o"></param>
|
|
|
|
|
public async void onGetBasePoint(object o)
|
2025-08-15 16:44:13 +08:00
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
if (isDrawing)
|
2025-09-02 11:21:40 +08:00
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
MessageBox.Show("正在自动绘制元件中,请勿操作...");
|
2025-09-02 11:21:40 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var listSelDwg = listDrawings.Where(a => a.IsSelected == true).ToList();
|
2025-08-15 16:44:13 +08:00
|
|
|
|
if (!listSelDwg.Any())
|
|
|
|
|
{
|
2025-09-02 11:21:40 +08:00
|
|
|
|
AddMsg("请先选择布置图!");
|
2025-08-15 16:44:13 +08:00
|
|
|
|
MessageBox.Show("请先选择布置图!");
|
2025-09-02 11:21:40 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
IsBusy = true;
|
|
|
|
|
BusyContent = "数据加载中...";
|
2025-09-02 11:21:40 +08:00
|
|
|
|
AddMsg("开始查询布置图基点元件信息...");
|
|
|
|
|
List<DtoAutoPlotLayout> listDto = new List<DtoAutoPlotLayout>();
|
2025-09-22 14:28:19 +08:00
|
|
|
|
List<DtoAutoPlotLayout> listErrDto = new List<DtoAutoPlotLayout>();
|
|
|
|
|
bool isBasePointErr = false;
|
|
|
|
|
bool isTagErr = false;
|
|
|
|
|
int index = 1;
|
|
|
|
|
int count = listSelDwg.Count;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
foreach (var dwg in listSelDwg)
|
|
|
|
|
{
|
2025-09-22 14:28:19 +08:00
|
|
|
|
BusyContent = $"数据加载中......{index}/{count}";
|
2025-09-02 11:21:40 +08:00
|
|
|
|
var list = await _ServicePlotLayout.GetBasePointByDwg(selectRange.Value, selectOperator.Value, inputValue, dwg.DrawingFileID);
|
2025-09-22 14:28:19 +08:00
|
|
|
|
index++;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
if (list == null)
|
|
|
|
|
{ continue; }
|
|
|
|
|
foreach (var basePoint in list)
|
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
if (basePoint.area != null && basePoint.area.ToLower() == "err")
|
2025-09-22 14:28:19 +08:00
|
|
|
|
{ isBasePointErr = true; }
|
|
|
|
|
else { isBasePointErr = false; }
|
2025-09-02 11:21:40 +08:00
|
|
|
|
if (basePoint.Tags.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var tag in basePoint.Tags)
|
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
if (tag.area != null && tag.area.ToLower() == "err")
|
2025-09-22 14:28:19 +08:00
|
|
|
|
{ isTagErr = true; }
|
|
|
|
|
else { isTagErr = false; }
|
|
|
|
|
if (isBasePointErr || isTagErr)
|
2025-09-02 11:21:40 +08:00
|
|
|
|
{
|
2025-09-22 14:28:19 +08:00
|
|
|
|
string strErr = isBasePointErr ? "基点异常;" : "";
|
|
|
|
|
strErr += isTagErr ? "元件异常" : "";
|
|
|
|
|
strErr = strErr.Replace(";","");
|
|
|
|
|
listErrDto.Add(new DtoAutoPlotLayout()
|
|
|
|
|
{
|
|
|
|
|
IsSelected = true,
|
|
|
|
|
DrawingFileID = dwg.DrawingFileID,
|
|
|
|
|
DrawingFileName = dwg.DrawingFileName,
|
|
|
|
|
EngineDataID = basePoint.EngineDataID,
|
|
|
|
|
BasePointTagNumber = basePoint.TagNumber,
|
|
|
|
|
Scale = basePoint.Scale,
|
|
|
|
|
FileId = basePoint.FileId,
|
|
|
|
|
PixelOnDwg = basePoint.PixelOnDwg,
|
|
|
|
|
IsNotDefaultSymbol = basePoint.IsNotDefaultSymbol,
|
|
|
|
|
X = basePoint.X,
|
|
|
|
|
XOff = basePoint.XOff,
|
|
|
|
|
YOff = basePoint.YOff,
|
|
|
|
|
deck = basePoint.deck,
|
|
|
|
|
area = basePoint.area,
|
|
|
|
|
AutoDrawing = strErr,
|
|
|
|
|
TagNumber = tag.TagNumber,
|
|
|
|
|
TagNumber_Upper = basePoint.TagNumber_Upper,
|
|
|
|
|
TagNumber_Lower = basePoint.TagNumber_Lower,
|
|
|
|
|
Tag = tag
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
listDto.Add(new DtoAutoPlotLayout()
|
|
|
|
|
{
|
|
|
|
|
IsSelected = true,
|
|
|
|
|
DrawingFileID = dwg.DrawingFileID,
|
|
|
|
|
DrawingFileName = dwg.DrawingFileName,
|
|
|
|
|
EngineDataID = basePoint.EngineDataID,
|
|
|
|
|
BasePointTagNumber = basePoint.TagNumber,
|
|
|
|
|
Scale = basePoint.Scale,
|
|
|
|
|
FileId = basePoint.FileId,
|
|
|
|
|
PixelOnDwg = basePoint.PixelOnDwg,
|
|
|
|
|
IsNotDefaultSymbol = basePoint.IsNotDefaultSymbol,
|
|
|
|
|
X = basePoint.X,
|
|
|
|
|
XOff = basePoint.XOff,
|
|
|
|
|
YOff = basePoint.YOff,
|
|
|
|
|
deck = basePoint.deck,
|
|
|
|
|
area = basePoint.area,
|
|
|
|
|
AutoDrawing = "未绘制",
|
|
|
|
|
TagNumber = tag.TagNumber,
|
|
|
|
|
TagNumber_Upper = basePoint.TagNumber_Upper,
|
|
|
|
|
TagNumber_Lower = basePoint.TagNumber_Lower,
|
|
|
|
|
Tag = tag
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
listBasePoint = new ObservableCollection<DtoAutoPlotLayout>(listDto);
|
2025-09-22 14:28:19 +08:00
|
|
|
|
listErrBasePoint = new ObservableCollection<DtoAutoPlotLayout>(listErrDto);
|
|
|
|
|
NormalTagCount = $"正常元件({listBasePoint.Count}个)";
|
|
|
|
|
ErrTagCount = $"异常元件({listErrBasePoint.Count}个)";
|
2025-09-02 11:21:40 +08:00
|
|
|
|
IsSelectAll = listBasePoint.Any() ? true : false;
|
|
|
|
|
AddMsg("布置图基点元件信息查询完成!");
|
2025-09-22 09:21:04 +08:00
|
|
|
|
IsBusy = false;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
AddMsg("基点元件信息查询异常:" + ex.Message);
|
2025-09-22 09:21:04 +08:00
|
|
|
|
IsBusy = false;
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public async void onStartDrawing(object o)
|
|
|
|
|
{
|
|
|
|
|
if (isDrawing)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("正在自动绘制元件中,请勿操作...");
|
|
|
|
|
return;
|
2025-08-15 16:44:13 +08:00
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
|
|
|
|
|
var msg = string.Empty;
|
|
|
|
|
var filePath = string.Empty;
|
|
|
|
|
var listDto = listBasePoint.Where(a => a.IsSelected == true).ToList();
|
|
|
|
|
if (!listDto.Any())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请先勾选基点元件信息!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
isDrawing = true;
|
|
|
|
|
listMsg.Clear();
|
2025-09-22 09:21:04 +08:00
|
|
|
|
for (int i = 0; i < listDto.Count; i++)
|
|
|
|
|
//foreach (var basePoint in listDto)
|
2025-09-02 11:21:40 +08:00
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
var basePoint = listDto[i];
|
2025-09-02 11:21:40 +08:00
|
|
|
|
if (basePoint.AutoDrawing == "已绘制")
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{basePoint.TagNumber}]已绘制,跳至下一个元件");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (basePoint.AutoDrawing == "已存在")
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{basePoint.TagNumber}]已存在,跳至下一个元件");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msg = await OpenDwg(basePoint.DrawingFileID);
|
|
|
|
|
if (!string.IsNullOrEmpty(msg))
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"图纸打开失败:{msg}", false);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AddMsg($"打开图纸:{basePoint.DrawingFileName} ");
|
|
|
|
|
var listEntitys = General.GetAllEntity();//获取图纸所有实体
|
|
|
|
|
var entity = listEntitys.FirstOrDefault(a => a.Handle.ToString() == basePoint.PixelOnDwg);
|
|
|
|
|
if (entity == null)
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"当前基点:{basePoint.BasePointTagNumber} 在图上找不到,不添加此元件,跳至下一个元件", false);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tag = basePoint.Tag;
|
|
|
|
|
var tagDto = listEntitys.FirstOrDefault(a => a.TagNumber == basePoint.TagNumber);
|
|
|
|
|
if (tagDto != null)
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"当前元件:{basePoint.TagNumber} 在图上已存在,句柄:{tagDto.Handle},不添加此元件,跳至下一个元件", false);
|
|
|
|
|
basePoint.AutoDrawing = "已存在";
|
|
|
|
|
basePoint.TagPixelOnDwg = tagDto.Handle;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2025-09-22 09:21:04 +08:00
|
|
|
|
//var flag = basePoint.deck == tag.deck && basePoint.area == tag.area;
|
|
|
|
|
//if (!flag)
|
|
|
|
|
//{
|
|
|
|
|
// AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{tag.TagNumber}] 的deck和area不一致,不添加此元件,跳至下一个元件", false);
|
|
|
|
|
// continue;
|
|
|
|
|
//}
|
|
|
|
|
filePath = Path.Combine(GlobalObject.GetCacheFolder(), $"{tag.TagNumber}.dwg");
|
|
|
|
|
string blockName = string.Empty;
|
|
|
|
|
if (string.IsNullOrEmpty(tag.FileId))
|
2025-09-02 11:21:40 +08:00
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
//元件ID为空 用本地默认图块图纸
|
|
|
|
|
if (!string.IsNullOrEmpty(tag.TagNumber_Lower))
|
|
|
|
|
{
|
|
|
|
|
var blockDwgPath = Path.Combine(GlobalObject.GetDllPath(), "Template\\常规矩形两行图块.dwg");
|
|
|
|
|
if (!File.Exists(blockDwgPath))
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"默认图块找不到:{blockDwgPath}", false);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//默认上下图块
|
|
|
|
|
blockName = "常规矩形两行图块";
|
|
|
|
|
File.Copy(blockDwgPath, filePath, true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var blockDwgPath = Path.Combine(GlobalObject.GetDllPath(), "Template\\常规矩形单行图块.dwg");
|
|
|
|
|
if (!File.Exists(blockDwgPath))
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"默认图块找不到:{blockDwgPath}", false);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//默认图块,只有中间部分
|
|
|
|
|
blockName = "常规矩形单行图块";
|
|
|
|
|
File.Copy(blockDwgPath, filePath, true);
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
2025-09-22 09:21:04 +08:00
|
|
|
|
else
|
2025-09-02 11:21:40 +08:00
|
|
|
|
{
|
2025-09-22 09:21:04 +08:00
|
|
|
|
//下载元件图纸文件
|
|
|
|
|
var obj = await _ServiceLibraryFile.GetEntity(tag.FileId);
|
|
|
|
|
blockName = obj.LibraryFileName;
|
|
|
|
|
AddMsg($"元件图纸:{tag.TagNumber}, 开始下载...");
|
|
|
|
|
msg = await _ServiceAnnexes.DownloadFile(filePath, obj.FolderId);
|
|
|
|
|
if (!string.IsNullOrEmpty(msg))
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"元件图纸下载失败,信息:" + msg, false);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
AddMsg($"元件图纸:{tag.TagNumber}, 下载成功");
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
|
|
|
|
//filePath = "D:\\BricsCAD\\Temp\\测试11.dwg";
|
|
|
|
|
//把元件的位号属性改成要绘制的位号值
|
2025-09-22 09:21:04 +08:00
|
|
|
|
var flag = General.UpdateCableNo(filePath, listLibraryTagName, tag.TagNumber, tag.IsNotDefaultSymbol, tag.TagNumber_Upper, tag.TagNumber_Lower);
|
2025-09-02 11:21:40 +08:00
|
|
|
|
|
|
|
|
|
//X轴:图上基点的坐标X +(接口数据元件的X + 接口数据元件的XOFF -接口数据基点的X-接口数据基点的Xoff)*比例系数
|
|
|
|
|
//Y轴:图上基点的坐标Y +(接口数据元件的Yoff-接口数据基点的Yoff)*比例系数
|
|
|
|
|
double scale = 1;//比例系数
|
|
|
|
|
double x = entity.X + (tag.X + double.Parse(tag.XOff) - basePoint.X - double.Parse(basePoint.XOff)) * scale;
|
|
|
|
|
double y = entity.Y + (double.Parse(tag.YOff) - double.Parse(basePoint.XOff)) * scale;
|
|
|
|
|
double z = entity.Z;
|
|
|
|
|
Point3d tagPoint = new Point3d(x, y, z);
|
|
|
|
|
AddMsg($"元件图纸:{tag.TagNumber}, 开始添加进布置图中...");
|
2025-09-22 09:21:04 +08:00
|
|
|
|
msg = await AddBlock(basePoint, blockName, filePath, tagPoint);
|
2025-09-02 11:21:40 +08:00
|
|
|
|
if (string.IsNullOrEmpty(msg))
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"布置图:{basePoint.DrawingFileName},成功插入元件:" + tag.TagNumber);
|
|
|
|
|
basePoint.AutoDrawing = "已绘制";
|
2025-09-22 09:21:04 +08:00
|
|
|
|
//当下一个要画元件的图纸和当前图纸不一样时,保存图纸
|
|
|
|
|
if (i + 1 >= listDto.Count)
|
|
|
|
|
{ General.SetDrawingReadOnly(dwgName, false); }
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var nextTag = listDto[i + 1];
|
|
|
|
|
if (basePoint.DrawingFileID != nextTag.DrawingFileID)
|
|
|
|
|
{ General.SetDrawingReadOnly(dwgName, false); }
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
|
|
|
|
else { AddMsg($"元件:{tag.TagNumber},绘制异常:{msg}"); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
AddMsg("操作已完成!");
|
|
|
|
|
isDrawing = false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
2025-08-15 16:44:13 +08:00
|
|
|
|
{
|
2025-09-02 11:21:40 +08:00
|
|
|
|
MessageBox.Show("绘图异常:" + ex.Message);
|
|
|
|
|
isDrawing = false;
|
2025-08-15 16:44:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 打开图纸
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private async Task<string> OpenDwg(string dwgId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string res = string.Empty;
|
|
|
|
|
string fullpath = string.Empty;
|
|
|
|
|
var dwgObj = await _ServiceDrawing.GetDrawingFile(dwgId);
|
|
|
|
|
var cate = await _ServiceDrawingCatalogue.GetEntity(dwgObj.DrawingCatalogueID);
|
|
|
|
|
if (cate.FullPath != cate.DrawingCatalogueID)
|
|
|
|
|
{
|
|
|
|
|
foreach (var id in cate.FullPath.Split(',').ToList())
|
|
|
|
|
{
|
|
|
|
|
cate = await _ServiceDrawingCatalogue.GetEntity(id);
|
|
|
|
|
fullpath += $"{cate.DrawingCatalogueName}\\";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { fullpath = $"{cate.DrawingCatalogueName}\\"; }
|
|
|
|
|
fullpath += dwgObj.DrawingFileName;
|
|
|
|
|
fullpath = Path.Combine(GlobalObj.LocalWorkDir, GlobalObject.curProject.ProjectName, fullpath);
|
|
|
|
|
if (!File.Exists(fullpath))
|
|
|
|
|
{
|
|
|
|
|
return dwgObj.DrawingFileName + ",图纸文件不存在,请先检出到本地!";
|
|
|
|
|
}
|
2025-09-22 09:21:04 +08:00
|
|
|
|
if (dwgObj.DrawingFileName == General.GetDwgName())
|
|
|
|
|
{
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2025-09-02 11:21:40 +08:00
|
|
|
|
var listName = General.GetAllOpenDrawingNames();
|
|
|
|
|
if (!listName.Contains(fullpath))
|
|
|
|
|
{
|
|
|
|
|
General.OpenDwg(fullpath);
|
|
|
|
|
dwgName = fullpath;
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
General.SwitchToDocument(fullpath);
|
|
|
|
|
dwgName = fullpath;
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2025-08-15 16:44:13 +08:00
|
|
|
|
|
2025-09-02 11:21:40 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return ex.Message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<string> AddBlock(DtoAutoPlotLayout basePoint, string tagName, string blockDwg, Point3d tagPoint)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string dwgId = basePoint.DrawingFileID;
|
|
|
|
|
string enginedataId = basePoint.Tag.EngineDataID;
|
|
|
|
|
string blockDwgId = basePoint.Tag.FileId;
|
|
|
|
|
string tagNumber = basePoint.Tag.TagNumber;
|
|
|
|
|
double scale = basePoint.Scale;
|
|
|
|
|
string msg = string.Empty;
|
|
|
|
|
string tagNum = string.Empty;
|
|
|
|
|
var lsitEnginedata = await _ServiceObjectType.GetEngineDataListByTags(tagNumber);
|
|
|
|
|
if (!lsitEnginedata.Any())
|
|
|
|
|
{
|
|
|
|
|
msg = $"元件位号:{tagNumber},属性未绑定,ServiceEnginedata.GetTagPixelsById({enginedataId})接口无数据";
|
|
|
|
|
AddMsg(msg, false);
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
string objTypeId = lsitEnginedata[0].ObjectTypeID;
|
|
|
|
|
string objTypeName = lsitEnginedata[0].ObjectTypeName;
|
|
|
|
|
var objId = General.AddTagDWG(blockDwg, tagName, tagNumber, objTypeId, scale, tagPoint);
|
|
|
|
|
#region 图纸上保存图元属性
|
|
|
|
|
if (!objId.IsNull)
|
|
|
|
|
{
|
|
|
|
|
AddMsg($"元件已添加至图纸,句柄:{objId.Handle.ToString()}");
|
|
|
|
|
AddMsg("开始关联元件属性至图纸...");
|
|
|
|
|
var dwgLibrary = await _ServiceLibraryFile.GetEntity(blockDwgId);
|
|
|
|
|
List<ec_enginedata_property> listPro = new List<ec_enginedata_property>();
|
|
|
|
|
var handlid = objId.Handle.ToString();//添加图元返回的句柄
|
|
|
|
|
ec_enginedata item = new ec_enginedata();
|
|
|
|
|
item.TagNumber = tagNumber;
|
|
|
|
|
item.ObjectTypeID = objTypeId;
|
|
|
|
|
item.Layout_Block_File = dwgLibrary;
|
|
|
|
|
//var result = await _ServiceObjectType.GetObjectTypePById(objTypeId);//添加属性
|
|
|
|
|
var res = await _ServiceObjectType.GetTagInfosByTags(tagNumber);
|
|
|
|
|
if (res.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var dto in res[0].tags[0].EngineDataProperty)
|
|
|
|
|
{
|
|
|
|
|
listPro.Add(new ec_enginedata_property()
|
|
|
|
|
{
|
|
|
|
|
EngineDataPropertyID = dto.PropertyID,
|
|
|
|
|
PropertyName = dto.PropertyName,
|
|
|
|
|
PropertyNameEN = dto.PropertyNameEN,
|
|
|
|
|
PropertyValue = dto.PropertyValue,
|
|
|
|
|
MeasuringUnit = dto.MeasuringUnit,
|
|
|
|
|
PropertyGID = dto.PropertyGID,
|
|
|
|
|
PropertyGroupName = dto.PropertyGroupName
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
item.EngineDataProperty = listPro;
|
|
|
|
|
List<ec_enginedata_pixel> listPixel = new List<ec_enginedata_pixel>();
|
|
|
|
|
var pixelDto = new ec_enginedata_pixel()
|
|
|
|
|
{
|
|
|
|
|
TagNumber = tagNumber,
|
|
|
|
|
DrawingFileID = dwgId,
|
2025-09-22 09:21:04 +08:00
|
|
|
|
LibraryFileID = dwgLibrary == null ? "" : dwgLibrary.LibraryFileID,
|
2025-09-02 11:21:40 +08:00
|
|
|
|
PixelCode = handlid,
|
|
|
|
|
ObjectTypeID = objTypeId,
|
|
|
|
|
ObjectTypeName = objTypeName,
|
|
|
|
|
EngineDataProperty = listPro
|
|
|
|
|
};
|
|
|
|
|
listPixel.Add(pixelDto);
|
|
|
|
|
item.EngineDataPixel = listPixel;
|
|
|
|
|
|
|
|
|
|
msg = await _ServiceObjectType.UpdatePixelAndProp(item);
|
|
|
|
|
if (msg != string.Empty)
|
|
|
|
|
{
|
|
|
|
|
msg = "保存元件属性至图纸异常:" + msg;
|
|
|
|
|
AddMsg(msg, false);
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
basePoint.TagPixelOnDwg = handlid;
|
|
|
|
|
AddMsg("添加元件属性至图纸成功!");
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
msg = $"元件:{blockDwg} ,添加失败";
|
|
|
|
|
AddMsg(msg, false);
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return ex.Message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void onSelectedTag(object o)
|
|
|
|
|
{
|
|
|
|
|
var dto = listBasePoint.Where(p => p.TagNumber == o.ToString()).FirstOrDefault();
|
|
|
|
|
if (dto != null)
|
|
|
|
|
{
|
|
|
|
|
if (!dto.IsSelected && IsSelectAll)
|
|
|
|
|
{
|
|
|
|
|
IsSelectAll = false;
|
|
|
|
|
}
|
|
|
|
|
else if (dto.IsSelected && !IsSelectAll)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in listBasePoint)
|
|
|
|
|
{
|
|
|
|
|
if (!item.IsSelected) return;
|
|
|
|
|
}
|
|
|
|
|
IsSelectAll = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void onSelectedAll(object o)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in listBasePoint)
|
|
|
|
|
{
|
|
|
|
|
item.IsSelected = IsSelectAll;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加提示信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="msg">信息</param>
|
|
|
|
|
/// <param name="isSucc">是否成功</param>
|
|
|
|
|
private void AddMsg(string msg, bool isSucc = true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TextBlock tb = new TextBlock();
|
|
|
|
|
tb.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "==>> " + msg;
|
|
|
|
|
tb.Foreground = isSucc ? Brushes.LightSeaGreen : Brushes.Red;
|
|
|
|
|
listMsg.Add(tb);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("添加提示信息异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-15 16:44:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|