using Newtonsoft.Json;
|
using PdmSwPlugin.Util.Util;
|
using SolidWorks.Interop.sldworks;
|
using SolidWorks.Interop.swconst;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.IO;
|
|
namespace PdmSwPlugin.Entity
|
{
|
public class PdmBomParam
|
{
|
public string topPartModel { get; set; }
|
|
public HashSet<string> allModels { get; set; }
|
|
public Dictionary<string, DrawInfo> needCheckProperties { get; set; }
|
}
|
|
public class BomInfo
|
{
|
public string id { get; set; }
|
public string name { get; set; }
|
public string partNo { get; set; }
|
public string partName { get; set; }
|
public string partModel { get; set; }
|
public string partBrandName { get; set; }
|
public string filePath { get; set; }
|
public int level { get; set; }
|
public int drawingType { get; set; }
|
|
public ModelDoc2 doc { get; set; }
|
|
public bool lost { get; set; } = false;
|
public Dictionary<string, string> param { get; set; }
|
|
public string bomVersion { get; set; }
|
public int checkStatus { get; set; }
|
|
public string checkUserId { get; set; }
|
public string checkUserName { get; set; }
|
|
public string d3FilePath { get; set; }
|
public string d2FilePath { get; set; }
|
public string pdfFilePath { get; set; }
|
|
public string d3Md5 { get; set; }
|
public string d2Md5 { get; set; }
|
public string pdfMd5 { get; set; }
|
|
public string d3FileId { get; set; }
|
public string d2FileId { get; set; }
|
public string pdfFileId { get; set; }
|
}
|
|
/// <summary>
|
/// 这些信息要根据web更新,单独抽出来管理
|
/// </summary>
|
public class DrawInfo : NotifyBase
|
{
|
/// <summary>
|
/// 3Dmd5
|
/// </summary>
|
public string d3Md5 { get; set; }
|
|
/// <summary>
|
/// 2Dmd5
|
/// </summary>
|
public string d2Md5 { get; set; }
|
|
/// <summary>
|
/// pdfMd5
|
/// </summary>
|
public string pdfMd5 { get; set; }
|
|
/// <summary>
|
/// 3D图纸FileId
|
/// </summary>
|
public string d3FileId { get; set; }
|
|
/// <summary>
|
/// 2D图纸FileId
|
/// </summary>
|
public string d2FileId { get; set; }
|
|
/// <summary>
|
/// PDF图纸FileId
|
/// </summary>
|
public string pdfFileId { get; set; }
|
|
private int? _checkRuleResult = 0;
|
|
public int? checkRuleResult
|
{
|
get => _checkRuleResult;
|
set => RaiseAndSetIfChanged(ref _checkRuleResult, value);
|
}
|
public Dictionary<string, string> originProperties { get; set; }
|
public Dictionary<string, string> customProperties { get; set; }
|
}
|
|
[Serializable]
|
public class PdmBom : NotifyBase, ICloneable
|
{
|
/// <summary>
|
/// 是否级联选中
|
/// </summary>
|
private static bool cascade = true;
|
|
public bool Is_Xc()
|
{
|
return ModelUtil.Is_Xc(partModel);
|
}
|
|
public bool Is_Mn()
|
{
|
return ModelUtil.Is_Mn(partModel);
|
}
|
|
/// <summary>
|
/// 判断型号是否特殊,主要是为了分辨Bom是不是自制件或加工件
|
/// </summary>
|
/// <returns>是/否</returns>
|
public bool Is_Special_Model()
|
{
|
return ModelUtil.Is_Special(partModel);
|
}
|
|
/// <summary>
|
/// 文档
|
/// </summary>
|
public ModelDoc2 doc { get; set; }
|
|
/// <summary>
|
/// 文件是不是丢了
|
/// </summary>
|
public bool _lost = false;
|
public bool lost
|
{
|
get => _lost;
|
set => RaiseAndSetIfChanged(ref _lost, value);
|
}
|
|
public string _name;
|
public string name
|
{
|
get => _name;
|
set => RaiseAndSetIfChanged(ref _name, value);
|
}
|
|
public int _level;
|
public int level
|
{
|
get => _level;
|
set => RaiseAndSetIfChanged(ref _level, value);
|
}
|
|
public int _drawingType;
|
public int drawingType
|
{
|
get => _drawingType;
|
set => RaiseAndSetIfChanged(ref _drawingType, value);
|
}
|
|
public bool _selected = false;
|
public bool selected
|
{
|
get => _selected;
|
set
|
{
|
RaiseAndSetIfChanged(ref _selected, value);
|
if (cascade && modules != null && modules.Count > 0)
|
{
|
foreach (var m in modules)
|
{
|
m.selected = value;
|
}
|
}
|
}
|
}
|
|
public string _id;
|
public string id
|
{
|
get => _id;
|
set => RaiseAndSetIfChanged(ref _id, value);
|
}
|
|
public string _treeId;
|
public string treeId
|
{
|
get => _treeId;
|
set => RaiseAndSetIfChanged(ref _treeId, value);
|
}
|
|
public string _parentTreeId => parent == null ? null : parent.treeId;
|
|
public string _partNo;
|
public string partNo
|
{
|
get => _partNo;
|
set => RaiseAndSetIfChanged(ref _partNo, value);
|
}
|
|
public string _partModel;
|
public string partModel
|
{
|
get => _partModel;
|
set => RaiseAndSetIfChanged(ref _partModel, value);
|
}
|
|
public string _partName;
|
public string partName
|
{
|
get => _partName;
|
set => RaiseAndSetIfChanged(ref _partName, value);
|
}
|
|
public string _partBrand;
|
public string partBrand
|
{
|
get => _partBrand;
|
set => RaiseAndSetIfChanged(ref _partBrand, value);
|
}
|
|
public string _partBrandName;
|
public string partBrandName
|
{
|
get => _partBrandName;
|
set => RaiseAndSetIfChanged(ref _partBrandName, value);
|
}
|
|
public string _produceWay;
|
public string produceWay
|
{
|
get => _produceWay;
|
set => RaiseAndSetIfChanged(ref _produceWay, value);
|
}
|
|
public double? _quantity;
|
public double? quantity
|
{
|
get => _quantity;
|
set => RaiseAndSetIfChanged(ref _quantity, value);
|
}
|
|
public string _bomVersion;
|
public string bomVersion
|
{
|
get => _bomVersion;
|
set => RaiseAndSetIfChanged(ref _bomVersion, value);
|
}
|
|
[JsonIgnore]
|
public PdmBom _parent;
|
[JsonIgnore]
|
public PdmBom parent
|
{
|
get => _parent;
|
set => RaiseAndSetIfChanged(ref _parent, value);
|
}
|
|
public string parentId
|
{
|
get => parent == null ? null : parent.id;
|
}
|
|
/// <summary>
|
/// 加工件
|
/// </summary>
|
public bool? _jgj;
|
public bool? jgj
|
{
|
get => _jgj;
|
set => RaiseAndSetIfChanged(ref _jgj, value);
|
}
|
|
/// <summary>
|
/// 模拟件
|
/// </summary>
|
public bool? _mn;
|
public bool? mn
|
{
|
get => _mn;
|
set => RaiseAndSetIfChanged(ref _mn, value);
|
}
|
|
/// <summary>
|
/// 是否是型材
|
/// </summary>
|
public bool? _xc;
|
public bool? xc
|
{
|
get => _xc;
|
set => RaiseAndSetIfChanged(ref _xc, value);
|
}
|
|
/// <summary>
|
/// 是否是型材子料
|
/// </summary>
|
public bool _xcChild = false;
|
public bool xcChild
|
{
|
get => _xcChild;
|
set => RaiseAndSetIfChanged(ref _xcChild, value);
|
}
|
|
/// <summary>
|
/// 是否建料
|
/// </summary>
|
public bool? _inDb;
|
public bool? inDb
|
{
|
get => _inDb;
|
set => RaiseAndSetIfChanged(ref _inDb, value);
|
}
|
|
/// <summary>
|
/// 是否可检入
|
/// </summary>
|
public bool? _canCheckIn;
|
public bool? canCheckIn
|
{
|
get => _canCheckIn;
|
set => RaiseAndSetIfChanged(ref _canCheckIn, value);
|
}
|
|
/// <summary>
|
/// 检入检出状态
|
/// </summary>
|
public int? _checkStatus = null;
|
public int? checkStatus
|
{
|
get => _checkStatus;
|
set => RaiseAndSetIfChanged(ref _checkStatus, value);
|
}
|
|
/// <summary>
|
/// 检入检出状态
|
/// </summary>
|
public int? _drawStatus = 0;
|
public int? drawStatus
|
{
|
get => _drawStatus;
|
set => RaiseAndSetIfChanged(ref _drawStatus, value);
|
}
|
|
/// <summary>
|
/// 检出人
|
/// </summary>
|
public string _checkUserId;
|
public string checkUserId
|
{
|
get => _checkUserId;
|
set => RaiseAndSetIfChanged(ref _checkUserId, value);
|
}
|
|
/// <summary>
|
/// 检出人
|
/// </summary>
|
public string _checkUserName;
|
public string checkUserName
|
{
|
get => _checkUserName;
|
set => RaiseAndSetIfChanged(ref _checkUserName, value);
|
}
|
|
/// <summary>
|
/// 变更相关的检入检出状态
|
/// </summary>
|
private void ChangeCheckStatus()
|
{
|
}
|
|
/// <summary>
|
/// 也是子模组,这里对应的是WEB服务器中存贮的结构,整合了数量信息
|
/// </summary>
|
public ObservableCollection<PdmBom> _children;
|
public ObservableCollection<PdmBom> children
|
{
|
get => _children;
|
set => RaiseAndSetIfChanged(ref _children, value);
|
}
|
|
/// <summary>
|
/// 子模组,这个属性反映了图纸真实的结构
|
/// </summary>
|
public ObservableCollection<PdmBom> _modules;
|
public ObservableCollection<PdmBom> modules
|
{
|
get => _modules;
|
set => RaiseAndSetIfChanged(ref _modules, value);
|
}
|
|
public Dictionary<string, string> _param;
|
public Dictionary<string, string> param
|
{
|
get => _param;
|
set => RaiseAndSetIfChanged(ref _param, value);
|
}
|
|
public void Init()
|
{
|
InitParent();
|
InitProduceWay();
|
InitFilePath();
|
}
|
|
public void InitParent()
|
{
|
if (parent != null)
|
{
|
xcChild = parent.xc == true || parent.xcChild == true;
|
}
|
}
|
|
/// <summary>
|
/// 填充生产方式
|
/// </summary>
|
public void InitProduceWay()
|
{
|
/// 型材件
|
xc = Is_Xc();
|
/// 模拟件
|
mn = Is_Mn();
|
if (drawingType == (int)swDocumentTypes_e.swDocPART || xc == true)
|
{
|
// 零件体、加工件、型材件都属于原材料
|
produceWay = "原材料";
|
// 型号特殊的话,就属于加工件
|
jgj = Is_Special_Model();
|
|
return;
|
}
|
else if (Is_Special_Model())
|
{
|
produceWay = "自制";
|
}
|
else
|
{
|
produceWay = "自制";
|
}
|
}
|
|
/// <summary>
|
/// 判断BOM是否需要下单
|
/// </summary>
|
public bool needOrdered => produceWay == "原材料" && (xcChild == false || jgj != true);
|
|
public DrawInfo _drawInfo;
|
public DrawInfo drawInfo
|
{
|
get => _drawInfo;
|
set => RaiseAndSetIfChanged(ref _drawInfo, value);
|
}
|
|
public int? checkRuleResult => _drawInfo == null ? null : _drawInfo.checkRuleResult;
|
|
|
public string d3Md5 => _drawInfo == null ? null : _drawInfo.d3Md5;
|
public string d2Md5 => _drawInfo == null ? null : _drawInfo.d2Md5;
|
public string pdfMd5 => _drawInfo == null ? null : _drawInfo.pdfMd5;
|
|
public string d3FileId => _drawInfo == null ? null : _drawInfo.d3FileId;
|
public string d2FileId => _drawInfo == null ? null : _drawInfo.d2FileId;
|
public string pdfFileId => _drawInfo == null ? null : _drawInfo.pdfFileId;
|
|
public string filePath { get; set; }
|
public string d3FilePath { get; set; }
|
public string d2FilePath { get; set; }
|
public string pdfFilePath { get; set; }
|
|
public string localD3Md5 { get; set; }
|
public string localD2Md5 { get; set; }
|
public string localPdfMd5 { get; set; }
|
|
public bool checkBoxEnabled => !(xcChild || lost);
|
|
public bool d3Changed => localD3Md5 != null && (_drawInfo == null || localD3Md5 != _drawInfo.d3Md5);
|
|
/// <summary>
|
/// 填充生产方式
|
/// </summary>
|
public void InitFilePath()
|
{
|
if (string.IsNullOrEmpty(d3FilePath))
|
{
|
return;
|
}
|
if ("自制" == produceWay)
|
{
|
localD3Md5 = MD5Util.Get(d3FilePath);
|
return;
|
}
|
if (jgj == true)
|
{
|
d2FilePath = d3FilePath.Substring(0, d3FilePath.Length - 3) + "DRW";
|
pdfFilePath = Path.GetFileNameWithoutExtension(d3FilePath) + ".PDF";
|
}
|
|
localD3Md5 = MD5Util.Get(d3FilePath);
|
localD2Md5 = MD5Util.Get(d2FilePath);
|
localPdfMd5 = MD5Util.Get(pdfFilePath);
|
}
|
|
|
/// <summary>
|
/// 浅拷贝
|
/// </summary>
|
/// <returns></returns>
|
public PdmBom ShallowCopy()
|
{
|
return (PdmBom)MemberwiseClone();
|
}
|
|
public object Clone()
|
{
|
return ShallowCopy();
|
}
|
}
|
}
|