| | |
| | | using static PdmSwPlugin.PDM.Event.PdmEvent; |
| | | using System.Windows.Interop; |
| | | using PdmSwPlugin.Commmon.Control; |
| | | using PdmSwPlugin.Common.Entity.System; |
| | | |
| | | namespace PdmSwPlugin.PDM |
| | | { |
| | |
| | | List<PdmBom> treeBoms = model.bomTreeReader.TreeList.ToList(); |
| | | if (treeBoms == null || treeBoms.Count <= 0) return; |
| | | treeBoms[0].selected = cb.IsChecked.Value; |
| | | model.RefreshSelectedBomCount(); |
| | | } |
| | | |
| | | private void SingleCheckBox_Event(object sender, RoutedEventArgs e) |
| | | { |
| | | model.RefreshSelectedBomCount(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 处理质量,保留6位小数 |
| | | /// </summary> |
| | | /// <param name="number"></param> |
| | | /// <returns></returns> |
| | | public static string HandleMass(double number) |
| | | { |
| | | return Math.Round(number, 6).ToString("0.000000"); |
| | |
| | | allProperties["文件后缀"] = Path.GetExtension(filepath); |
| | | // 文件路径 |
| | | allProperties["文件路径"] = filepath; |
| | | allProperties["历史图纸"] = drawInfo.HistoryData.ToString(); |
| | | string drawFilePath = filepath.Replace(Path.GetExtension(filepath), ".slddrw"); |
| | | bool drawExists = File.Exists(drawFilePath); |
| | | // 工程图一致性检查 |
| | |
| | | return drawInfo; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取全部属性 |
| | | /// </summary> |
| | | /// <param name="param"></param> |
| | | public void GetAll(object param) |
| | | { |
| | | object[] datas = param as object[]; |
| | |
| | | Dictionary<string, DrawInfo> checkResult = result.HandleResult(); |
| | | foreach (string key in properties.Keys) |
| | | { |
| | | if (!checkResult[key].checkRuleOk) |
| | | { |
| | | allSuccess = false; |
| | | } |
| | | properties[key].checkRuleResult = checkResult[key].checkRuleResult; |
| | | properties[key].errMessages = checkResult[key].errMessages; |
| | | var msgs = checkResult[key].errMessages; |
| | | if (msgs != null && msgs.Count > 0) |
| | | if (!properties[key].HistoryData && !checkResult[key].checkRuleOk) |
| | | { |
| | | // 不是历史数据并且有未通过的,标记为false |
| | | allSuccess = false; |
| | | } |
| | | |
| | | if (!properties[key].HistoryData && msgs != null && msgs.Count > 0) |
| | | { |
| | | foreach (string msg in msgs) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | // 对所有的BOM做规则检查 |
| | | bool allSuccess = DoCheckRule(out _); |
| | | // 先获取所有的BOM |
| | | HashSet<string> cache = new HashSet<string>(); |
| | | // 然后筛选选中的BOM |
| | |
| | | { // 如果没有选中的BOM,那就是所有BOM |
| | | boms = model.bomTreeReader.CacheList.ToList(); |
| | | } |
| | | // 筛选有图纸的,未提交的,零件体加工件进行上传 |
| | | // 筛选有图纸的,在物料明细中,未提交的,在物料明细表中的零件体加工件进行上传 |
| | | boms = boms.Where(b => |
| | | { |
| | | 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 != "completed" || b.auditedMd5Changed); |
| | | return b.NeedAudit; |
| | | } |
| | | return false; |
| | | }).ToList(); |
| | |
| | | this.Warning("只有未提交过或发生变更的加工件图纸可以进行审核"); |
| | | return; |
| | | } |
| | | // 对所有的BOM做规则检查 |
| | | bool allSuccess = DoCheckRule(out _); |
| | | |
| | | if (!allSuccess) |
| | | { |
| | | // 如果有未通过的图纸,需要提示 |
| | | var err = boms.Where(b => !b.checkRuleOk).ToList(); |
| | | var err = boms.Where(b => !b.IsHistoryData && !b.checkRuleOk).ToList(); |
| | | if (err != null && err.Count > 0) |
| | | { |
| | | List<string> msgs = new List<string>(); |
| | |
| | | { |
| | | if (ee.drawInfo.errMessages == null) |
| | | { |
| | | msgs.Add($"物料【{ee.partNo}】未通过规则检查!"); |
| | | continue; |
| | | } |
| | | foreach (string msg in ee.drawInfo.errMessages) |
| | |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // 不相关的规则检查不通过就无所谓了 |
| | | /*int res = SwApp.SendMsgToUser2("有未通过规则检查的图纸,是否继续?", (int)swMessageBoxIcon_e.swMbWarning, |
| | | (int)swMessageBoxBtn_e.swMbOkCancel); |
| | | |
| | | if (res == (int)swMessageBoxResult_e.swMbHitCancel) |
| | | { |
| | | return; |
| | | }*/ |
| | | } |
| | | |
| | | // 都通过了,再进行审批 |
| | | |
| | | // 先申请单号 |
| | | DrawAuditOrder daOrder = new DrawAuditOrder |
| | | { |
| | | requestUserId = PdmUser.LoginUser.id, |
| | | requestUser = PdmUser.LoginUser.realname |
| | | }; |
| | | try |
| | | { |
| | | Result<DrawAuditOrder> res = Client.PostSyncAction<DrawAuditOrder>(daOrder, "drawAudit/order/create"); |
| | | daOrder = res.HandleResult(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Logger.Error($"请求审批单号失败", ex); |
| | | this.Error($"请求审批单号失败! {ex.Message}"); |
| | | return; |
| | | } |
| | | |
| | | ConcurrentQueue<string> errs = new ConcurrentQueue<string>(); |
| | | CountdownEvent counter = new CountdownEvent(boms.Count); |
| | | foreach (PdmBom bom in boms) |
| | |
| | | MultipartFormDataContent httpContent = new MultipartFormDataContent(); |
| | | httpContent.Add(new StringContent(bom.partNo), "materialCode"); |
| | | httpContent.Add(new StringContent(bom.partNo), "materialModel"); |
| | | httpContent.Add(new StringContent(daOrder.id), "orderId"); |
| | | fileInfo = new FileInfo(d3FilePath); |
| | | FileInfo file2Info = new FileInfo(d2FilePath); |
| | | httpContent.Add(new ByteArrayContent(FileUtil.toByteArray(d3FilePath)), "d3File", fileInfo.Name); |
| | |
| | | if (bom.checkRuleResult == 3) |
| | | { |
| | | string title = string.Empty; |
| | | if (bom.historyData) |
| | | if (bom.IsHistoryData) |
| | | { |
| | | title = "历史图纸无需检查"; |
| | | } |
| | | else if (bom.inBom) |
| | | else if (bom.ExcludeFromBOM) |
| | | { |
| | | title = "不在物料明细表中的物料无需检查"; |
| | | } |
| | |
| | | if (bom.produceWay == "模组" || bom.produceWay == "标准件") |
| | | { |
| | | this.Info($"{bom.produceWay}无需审核"); |
| | | return; |
| | | } |
| | | if (bom.IsHistoryData && !bom.localDocChanged) |
| | | { |
| | | this.Info("历史图纸无需审核"); |
| | | return; |
| | | } |
| | | if (bom.IsHistoryData && bom.localDocChanged) |
| | | { |
| | | this.Info("历史图纸一致性变更,需审核"); |
| | | return; |
| | | } |
| | | this.Warning("该图纸未审核"); |
| | |
| | | RefreshBomList(SwApp.IActiveDoc2); |
| | | DoCheckRule(out _); |
| | | // 筛选所有在物料明细表中,不跳过检查并且检查未通过的,类型是加工件的未通过审核的,加工件审核通过的但图纸变更的 |
| | | List<string> errs = model.bomTreeReader.CacheList.Where(b => |
| | | !b.inBom |
| | | && ( |
| | | (!b.skipCheck && !b.checkRuleOk) |
| | | || (b.produceWay == "加工件" && b.drawStatus != "completed") |
| | | || (b.produceWay == "加工件" && b.drawStatus == "completed" && b.auditedMd5Changed) |
| | | ) |
| | | ).Select(b => |
| | | { |
| | | string msg = $"【{b.partModel}】"; |
| | | if (!b.skipCheck && !b.checkRuleOk) |
| | | { |
| | | msg += "未通过规则检查;"; |
| | | } |
| | | if (b.produceWay == "加工件" && b.drawStatus != "completed") |
| | | { |
| | | msg += "未通过审核;"; |
| | | } |
| | | if (b.produceWay == "加工件" && b.drawStatus == "completed" && b.auditedMd5Changed) |
| | | { |
| | | msg += "图纸变更后未重新审核"; |
| | | } |
| | | return msg; |
| | | } |
| | | ).ToList(); |
| | | List<string> errs = model.bomTreeReader.CacheList.Select(b => b.NeedStopCheckIn()) |
| | | .Where(s => s != null).ToList(); |
| | | |
| | | if (errs != null && errs.Count > 0) |
| | | { |