chr
2024-08-20 b62a2f5ad99995ec01da71b9f93be7284023171b
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,101 @@
        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图MD5 历史图纸看一致性检查没通过
        /// </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>
        /// 检查是否OK
        /// </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
            {
                // 找不到文档的不审核
                if (lost) return false;
                // 不在物料明细表中不审核
                if (ExcludeFromBOM) return false;
                if (IsHistoryData)
                {
                    // 历史图纸只审核一致性不通过的
                    return _drawInfo.checkRuleResult == 2;
                }
                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 && localDocChanged)
            {
                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 +527,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 +554,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; }