chr
2024-08-12 e9d7a5ef4c17e4804fb988dd193ff7d1fa36d52b
PdmSwPlugin.PDM/PdmControl.xaml.cs
@@ -30,13 +30,10 @@
using PdmSwPlugin.Common.Setting;
using PdmSwPlugin.PDM.Model;
using System.Diagnostics;
using SolidWorks.Interop.gtswutilities;
using PdmSwPlugin.PDM.Constant;
using static PdmSwPlugin.PDM.Event.PdmEvent;
using NPOI.SS.Formula.PTG;
using PdmSwPlugin.Common.Entity.System;
using System.Windows.Input;
using System.Windows.Interop;
using PdmSwPlugin.Commmon.Control;
namespace PdmSwPlugin.PDM
{
@@ -1165,17 +1162,21 @@
                        if (!cache.Contains(b.partModel))
                        {
                            cache.Add(b.partModel);
                            // 文档存在的
                            return b.lost != true
                            // && b.drawingType == (int)swDocumentTypes_e.swDocPART
                            // 是加工件的
                            && b.produceWay == "加工件"
                            && (b.drawStatus != "submitted" && b.drawStatus != "resubmitted");
                            // 未被提交的
                            && (b.drawStatus != "submitted" && b.drawStatus != "resubmitted")
                            && (b.drawStatus != "completed" || b.auditedMd5Changed);
                        }
                        return false;
                    }).ToList();
                    if (boms == null || boms.Count <= 0)
                    {
                        this.Warning("只有未提交的加工件图纸可以进行审核");
                        this.Warning("只有未提交过或发生变更的加工件图纸可以进行审核");
                        return;
                    }
                    // 对所有的BOM做规则检查
@@ -1386,7 +1387,11 @@
                if (bom.checkRuleResult == 3)
                {
                    string title = string.Empty;
                    if (bom.inBom)
                    if (bom.historyData)
                    {
                        title = "历史图纸无需检查";
                    }
                    else if (bom.inBom)
                    {
                        title = "不在物料明细表中的物料无需检查";
                    }
@@ -1574,79 +1579,6 @@
            }
        }
        private void PtrHandler(IntPtr ptr, Action callback, Action<List<string>, Exception> reject)
        {
            if (workStatus == PdmStatus.FREE)
            {
                WindowIntPtrUtil.ShowWindow(ptr, 6);
                // 执行规则检查并获取结果
                MaskAdorner.ShowMask(content, "检查中,请稍后...");
                Task.Run(() =>
                {
                    try
                    {
                        RefreshBomList(SwApp.IActiveDoc2);
                        DoCheckRule(out _);
                        List<string> errs = model.bomTreeReader.CacheList.Where(b =>
                            !b.inBom
                            && (!b.checkRuleOk || (b.produceWay == "加工件" && b.drawStatus != "completed"))
                        ).Select(b =>
                        {
                            string msg = $"【{b.partModel}】";
                            if (!b.checkRuleOk)
                            {
                                msg += "未通过规则检查;";
                            }
                            if (b.produceWay == "加工件" && b.drawStatus != "completed")
                            {
                                msg += "未通过审核;";
                            }
                            return msg;
                        }
                        ).ToList();
                        if (errs != null && errs.Count > 0)
                        {
                            reject(errs, null);
                            Dispatcher.Invoke(() =>
                            {
                                MultiExWindow exWin = new MultiExWindow(this, "检入停止", errs);
                                exWin.ShowDialog();
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        reject(null, ex);
                        Logger.Error("PDM check rule failed.", ex);
                        this.Show($"图纸检查执行失败:{ex.Message}", true);
                    }
                    finally
                    {
                        workStatus = PdmStatus.FREE;
                        MaskAdorner.HideMask(content);
                    }
                });
            }
            else
            {
                reject(null, null);
                if (workStatus == PdmStatus.CHECKING)
                {
                    this.Info("正在进行规则检查,请勿检入");
                }
                else if (workStatus == PdmStatus.READING)
                {
                    this.Info("正在加载,请勿检入");
                }
                else if (workStatus == PdmStatus.UPLOADING)
                {
                    this.Info("正在上传图纸,请勿检入");
                }
            }
        }
        private async Task PtrHandler2()
        {
            if (workStatus == PdmStatus.FREE)
@@ -1660,17 +1592,18 @@
                        // 执行规则检查并获取结果
                        RefreshBomList(SwApp.IActiveDoc2);
                        DoCheckRule(out _);
                        // 筛选所有在物料明细表中,不跳过检查并且检查未通过的,类型是加工件的未通过审核的,加工件审核通过的但图纸变更的
                        List<string> errs = model.bomTreeReader.CacheList.Where(b =>
                            !b.inBom
                            && (
                                !b.checkRuleOk
                                (!b.skipCheck && !b.checkRuleOk)
                                || (b.produceWay == "加工件" && b.drawStatus != "completed")
                                || (b.produceWay == "加工件" && b.drawStatus == "completed" && b.auditedMd5Changed)
                            )
                        ).Select(b =>
                        {
                            string msg = $"【{b.partModel}】";
                            if (!b.checkRuleOk)
                            if (!b.skipCheck && !b.checkRuleOk)
                            {
                                msg += "未通过规则检查;";
                            }
@@ -1678,6 +1611,10 @@
                            {
                                msg += "未通过审核;";
                            }
                            if (b.produceWay == "加工件" && b.drawStatus == "completed" && b.auditedMd5Changed)
                            {
                                msg += "图纸变更后未重新审核";
                            }
                            return msg;
                        }
                        ).ToList();