From 1f645778ae80a3a8801b8bb4d0fcf8feb244ad43 Mon Sep 17 00:00:00 2001 From: chr <chr@mailcom> Date: 星期三, 09 十月 2024 11:51:23 +0800 Subject: [PATCH] 完善项目,新增插件启用检测; --- PdmSwPlugin.Common/Entity/Pdm/PdmBom.cs | 127 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 116 insertions(+), 11 deletions(-) diff --git a/PdmSwPlugin.Common/Entity/Pdm/PdmBom.cs b/PdmSwPlugin.Common/Entity/Pdm/PdmBom.cs index 654ff5b..d8f53e0 100644 --- a/PdmSwPlugin.Common/Entity/Pdm/PdmBom.cs +++ b/PdmSwPlugin.Common/Entity/Pdm/PdmBom.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; +using System.Windows.Interop; namespace PdmSwPlugin.Common.Entity.Pdm { @@ -35,6 +36,8 @@ public string filePath { get; set; } public int level { get; set; } public int drawingType { get; set; } + + public bool HistoryData = false; public ModelDoc2 doc { get; set; } public Component2 component { get; set; } @@ -152,6 +155,14 @@ public bool checkRuleOk => checkRuleResult == 1 || checkRuleResult == 3; + private bool _HistoryData = false; + public bool HistoryData + { + get => _HistoryData; + set => RaiseAndSetIfChanged(ref _HistoryData, value); + } + + public List<string> errMessages { get; set; } public Dictionary<string, string> allProperties { get; set; } @@ -216,15 +227,112 @@ public string auditUserId => BomInfo?.auditUserId; public string auditUser => BomInfo?.auditUser; - public bool inBom + /// <summary> + /// 鏄惁鏄巻鍙插浘绾� + /// </summary> + public bool IsHistoryData => _drawInfo?.HistoryData == true; + /// <summary> + /// 鏄惁璺宠繃瑙勫垯妫�鏌� + /// </summary> + public bool skipCheck => produceWay == "妯$粍" || ExcludeFromBOM || component?.IsVirtual == true; + /// <summary> + /// 鍥剧焊鏄惁鍙戠敓鍙樻洿 闈炲巻鍙插浘绾哥湅2D鍥綧D5 鍘嗗彶鍥剧焊鐪嬩竴鑷存�ф鏌ユ病閫氳繃 + /// </summary> + public bool localDocChanged => (!IsHistoryData && localD2Md5 != _drawInfo?.d2Md5) + || (IsHistoryData && _drawInfo?.checkRuleResult == 2); //localD3Md5 != _drawInfo?.d3Md5; + /// <summary> + /// 瑙勫垯妫�鏌ョ粨鏋� + /// </summary> + public int? checkRuleResult => (IsHistoryData || skipCheck) ? 3 : _drawInfo?.checkRuleResult; + /// <summary> + /// 妫�鏌ユ槸鍚K + /// </summary> + public bool checkRuleOk => _drawInfo != null && _drawInfo.checkRuleOk; + /// <summary> + /// 鏄惁涓嶅湪鐗╂枡鏄庣粏琛ㄤ腑 + /// </summary> + public bool ExcludeFromBOM { get => component == null ? false : component.ExcludeFromBOM; set { InBomChanged?.Invoke(this, value); - // RaiseAndSetIfChanged(ref _inBom, value); } } + + /// <summary> + /// 鏄惁闇�瑕佸鏍� + /// </summary> + public bool NeedAudit + { + get + { + // 鎵句笉鍒版枃妗g殑涓嶅鏍� + if (lost) return false; + // 涓嶅湪鐗╂枡鏄庣粏琛ㄤ腑涓嶅鏍� + if (ExcludeFromBOM) return false; + // 妯$粍涓嶅鏍� + if (produceWay == "妯$粍") return false; + // 寰呭鏍哥殑涓嶅啿绐佹彁浜� + if (drawStatus == "submitted" || drawStatus == "resubmitted") return false; + if (IsHistoryData) + { + // 鍘嗗彶鍥剧焊鍙鏍镐竴鑷存�т笉閫氳繃鐨� 鍜岃椹冲洖鐨� + return _drawInfo.checkRuleResult == 2 || drawStatus == "rejected"; + } + else + { + // 闈炲巻鍙插浘绾稿彧瀹℃牳 鍏佽瀹℃牳鐨勫姞宸ヤ欢 + return produceWay == "鍔犲伐浠�" + && (drawStatus != "submitted" && drawStatus != "resubmitted") + && (drawStatus != "completed" || localDocChanged); + } + } + } + + /// <summary> + /// 鏄惁闇�瑕佺粓姝㈡鍏�/瀵煎叆 + /// </summary> + /// <returns></returns> + public string NeedStopCheckIn() + { + if (produceWay == "妯$粍") return null; + if (ExcludeFromBOM) return null; + if (IsHistoryData) + { + if (localDocChanged) + { + return $"鍘嗗彶鍥剧焊銆恵partModel}銆戝彉鏇村悗鏈噸鏂板鏍�"; + } + else if (drawStatus == "rejected" || drawStatus == "submitted" || drawStatus == "resubmitted") + { + return $"鍘嗗彶鍥剧焊銆恵partModel}銆戞湭閫氳繃瀹℃牳"; + } + } + if (!IsHistoryData) + { + bool error = false; + string msg = $"銆恵partModel}銆�"; + if (!skipCheck && !checkRuleOk) + { + error = true; + msg += "鏈�氳繃瑙勫垯妫�鏌�"; + } + if (produceWay == "鍔犲伐浠�" && drawStatus != "completed") + { + error = true; + msg += "鏈�氳繃瀹℃牳;"; + } + if (produceWay == "鍔犲伐浠�" && drawStatus == "completed" && localDocChanged) + { + error = true; + msg += "鍥剧焊鍙樻洿鍚庢湭閲嶆柊瀹℃牳"; + } + return error ? msg : null; + } + return null; + } + public void UpdateInBom(bool value) { @@ -430,15 +538,13 @@ if (e.PropertyName == "checkRuleResult") { RaisePropertyChanged("checkRuleResult"); + RaisePropertyChanged("localDocChanged"); + } + else if (e.PropertyName == "HistoryData") + { + RaisePropertyChanged("IsHistoryData"); } } - - // 妯$粍 涓嶅湪鐗╂枡鏄庣粏琛� 宸℃璺宠繃妫�鏌� - public bool historyData { get; set; } = false; - public bool skipCheck => historyData || produceWay == "妯$粍" || inBom || component?.IsVirtual == true; - public int? checkRuleResult => skipCheck ? 3 : _drawInfo?.checkRuleResult; - - public bool checkRuleOk => _drawInfo != null && _drawInfo.checkRuleOk; public string d3Md5 => _drawInfo == null ? null : _drawInfo.d3Md5; public string d2Md5 => _drawInfo == null ? null : _drawInfo.d2Md5; @@ -459,14 +565,13 @@ public bool checkBoxEnabled => !(xcChild || (lost == true) || produceWay == "鏍囧噯浠�" || (produceWay == "妯$粍" && drawingType == (int)swDocumentTypes_e.swDocPART) - || (inBom && drawingType == (int)swDocumentTypes_e.swDocPART) + || (ExcludeFromBOM && drawingType == (int)swDocumentTypes_e.swDocPART) // BomInfo.jgj == "鏍囧噯浠�" //|| component?.IsVirtual == true ); public bool d3Changed => localD3Md5 != _drawInfo?.d3Md5; - public bool auditedMd5Changed => localD2Md5 != _drawInfo?.d2Md5; //localD3Md5 != _drawInfo?.d3Md5; public int order { get; set; } -- Gitblit v1.9.1