From 00d996f6b1720f302563944e9d156ed98e142ec4 Mon Sep 17 00:00:00 2001 From: "songnan.zhang" Date: Thu, 23 Jun 2022 14:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APPQ5/QMAPP.WinForm/App.config | 2 +- APPQ5/QMAPP.WinForm/Dictionary.xml | 6 +- .../SlushMoldingPrintForOldNewForm.cs | 26 ++++- .../Forms/Operation/OperationForm_316.cs | 108 ++++++++++++++---- .../QMAPP.WinForm/Properties/AssemblyInfo.cs | 4 +- 5 files changed, 114 insertions(+), 32 deletions(-) diff --git a/APPQ5/QMAPP.WinForm/App.config b/APPQ5/QMAPP.WinForm/App.config index 300e794..4f27906 100644 --- a/APPQ5/QMAPP.WinForm/App.config +++ b/APPQ5/QMAPP.WinForm/App.config @@ -211,7 +211,7 @@ - + diff --git a/APPQ5/QMAPP.WinForm/Dictionary.xml b/APPQ5/QMAPP.WinForm/Dictionary.xml index 0ba869b..c89dff4 100644 --- a/APPQ5/QMAPP.WinForm/Dictionary.xml +++ b/APPQ5/QMAPP.WinForm/Dictionary.xml @@ -141,9 +141,11 @@ + - - + + + diff --git a/APPQ5/QMAPP.WinForm/Forms/Injection/SlushMoldingPrintForOldNewForm.cs b/APPQ5/QMAPP.WinForm/Forms/Injection/SlushMoldingPrintForOldNewForm.cs index 921bea7..c92f087 100644 --- a/APPQ5/QMAPP.WinForm/Forms/Injection/SlushMoldingPrintForOldNewForm.cs +++ b/APPQ5/QMAPP.WinForm/Forms/Injection/SlushMoldingPrintForOldNewForm.cs @@ -52,6 +52,7 @@ namespace QMAPP.WinForm.Forms.Injection private string _cfgSlushMoldingVW3712 = null;// 预警区间 private string _cfgSlushMoldingVW371PA = null;// 称重区间 private string _cfgSlushMoldingVW371PA2 = null;// 预警区间 + private string _SetFistColor = null;// 设置首选颜色 /// /// 新建 @@ -69,6 +70,7 @@ namespace QMAPP.WinForm.Forms.Injection _cfgSlushMoldingVW3712 = GetAppConfigValue("SLUSHMOLDING2"); _cfgSlushMoldingVW371PA = GetAppConfigValue("SLUSHMOLDINGPA"); _cfgSlushMoldingVW371PA2 = GetAppConfigValue("SLUSHMOLDINGPA2"); + _SetFistColor = GetAppConfigValue("SetFistColor"); btnCommSend.Enabled = true; serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived); @@ -141,6 +143,10 @@ namespace QMAPP.WinForm.Forms.Injection this.comColor.SelectedValue = "1"; //this.comColor.Enabled = false; + if (!string.IsNullOrEmpty(_SetFistColor)) + { + this.comColor.SelectedValue = _SetFistColor; + } ColorPrint = this.comColor.SelectedValue.ToString(); ////AB腔 @@ -1067,20 +1073,28 @@ namespace QMAPP.WinForm.Forms.Injection { if (!string.IsNullOrEmpty(ColorPrint) && ColorPrint != this.comColor.SelectedValue.ToString()) { - UpdatePasswordForm psd = new UpdatePasswordForm(); - var color = this.comColor.SelectedValue.ToString(); - var result = psd.ShowDialog(); - if (result.ToString() != "OK") + if (this.comColor.SelectedValue.ToString() != "4") { - if (color != ColorPrint) + UpdatePasswordForm psd = new UpdatePasswordForm(); + var color = this.comColor.SelectedValue.ToString(); + var result = psd.ShowDialog(); + if (result.ToString() != "OK") + { + if (color != ColorPrint) + { + this.comColor.SelectedValue = ColorPrint; + } + } + else { - this.comColor.SelectedValue = ColorPrint; + ColorPrint = this.comColor.SelectedValue.ToString(); } } else { ColorPrint = this.comColor.SelectedValue.ToString(); } + } } diff --git a/APPQ5/QMAPP.WinForm/Forms/Operation/OperationForm_316.cs b/APPQ5/QMAPP.WinForm/Forms/Operation/OperationForm_316.cs index 56be50e..50a561f 100644 --- a/APPQ5/QMAPP.WinForm/Forms/Operation/OperationForm_316.cs +++ b/APPQ5/QMAPP.WinForm/Forms/Operation/OperationForm_316.cs @@ -30,6 +30,7 @@ using gregn6Lib; using System.Data; using QMAPP.FJC.Entity.BZD; using QMAPP.BoraUpgrade.BLL; +using System.Text; namespace QMAPP.WinForm.Forms.Operation { @@ -1913,6 +1914,8 @@ namespace QMAPP.WinForm.Forms.Operation { try { + WriteFile("ZSN, Print052QRCODE 开始", @"D:\MES\Log"); + if (!cBoxVANstr || "IP_ASSEMBLING,GWASSEMBLE_VW371PA".Contains(_operationServiceParam.machineInfo.WORKLOC_CODE)) cBoxVAN.Visible = false; @@ -1927,20 +1930,24 @@ namespace QMAPP.WinForm.Forms.Operation //数据填充 Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReadFetchRecordBox); + WriteFile("ZSN, Print052QRCODE reportPath:" + reportPath, @"D:\MES\Log"); + Report.LoadFromFile(reportPath); //rep.Printer.PrinterName = "默认打印机";//调取不同的打印机 Report.Print(false); + + WriteFile("ZSN, Print052QRCODE 结束", @"D:\MES\Log"); } - catch (Exception) + catch (Exception ex) { - + WriteFile("ZSN, Print052QRCODE catch " + ex.Message, @"D:\MES\Log"); throw; } finally { - + WriteFile("ZSN, Print052QRCODE finally", @"D:\MES\Log"); Report = new GridppReport(); } @@ -1964,36 +1971,47 @@ namespace QMAPP.WinForm.Forms.Operation private BZD getBZDCode() { BZD bzd = new BZD(); - List list = new List(); - List paramList = new List(); - //张松男 20210207 总成工位打印052 缺少物料号 重新查找填充 start - if (string.IsNullOrEmpty(planMATERIAL_CODE)) + try { - var MaterialCodes = ""; - var dataSrouce = _agent.InvokeServiceFunction(B9IPCService.BZDConfigBLL_GetMaterialCode.ToString(), processMainCode); - foreach (DataRow dataRow in dataSrouce.Rows) + List list = new List(); + List paramList = new List(); + + WriteFile("ZSN,planMATERIAL_CODE =1= " + planMATERIAL_CODE, @"D:\MES\Log"); + WriteFile("ZSN,processMainCode =1= " + processMainCode, @"D:\MES\Log"); + + //张松男 20210207 总成工位打印052 缺少物料号 重新查找填充 start + if (string.IsNullOrEmpty(planMATERIAL_CODE)) { - MaterialCodes = dataRow["MATERIAL_CODE"].ToString(); + var MaterialCodes = ""; + var dataSrouce = _agent.InvokeServiceFunction(B9IPCService.BZDConfigBLL_GetMaterialCode.ToString(), processMainCode); + foreach (DataRow dataRow in dataSrouce.Rows) + { + MaterialCodes = dataRow["MATERIAL_CODE"].ToString(); + } + if (!string.IsNullOrEmpty(MaterialCodes)) + planMATERIAL_CODE = MaterialCodes; + else + { + WriteFile("ZSN,缺少planMATERIAL_CODE ", @"D:\MES\Log"); + throw new Exception("创建BZD码失败!缺少planMATERIAL_CODE"); + } } - if (!string.IsNullOrEmpty(MaterialCodes)) - planMATERIAL_CODE = MaterialCodes; - else - throw new Exception("创建BZD码失败!缺少planMATERIAL_CODE"); - } - //张松男 20210207 总成工位打印052 缺少物料号 重新查找填充 end + //张松男 20210207 总成工位打印052 缺少物料号 重新查找填充 end - paramList.Add(planMATERIAL_CODE); - paramList.Add(processMainCode); + paramList.Add(planMATERIAL_CODE); + paramList.Add(processMainCode); + + WriteFile("ZSN,planMATERIAL_CODE =2= " + planMATERIAL_CODE, @"D:\MES\Log"); + WriteFile("ZSN,processMainCode =2= " + processMainCode, @"D:\MES\Log"); - try - { //读取BZDCONFIG配置列表 list = _agent.InvokeServiceFunction>( B9IPCService.BZDRecorderBLL_CreateBZDCode.ToString(), paramList); if (list != null) { + WriteFile("ZSN,查询到list " + processMainCode, @"D:\MES\Log"); //将返回值赋值给bzd对象 bzd.barcode = list[0]; bzd.color = list[1]; @@ -2001,6 +2019,7 @@ namespace QMAPP.WinForm.Forms.Operation bzd.count = list[3]; if (bzd.count == "0") { + WriteFile("创建BZD码失败!缺少list[3] ", @"D:\MES\Log"); planMATERIAL_CODE = null; processMainCode = null; throw new Exception($"创建BZD码失败!缺少list[3];planMATERIAL_CODE={planMATERIAL_CODE};processMainCode={processMainCode}"); @@ -2010,6 +2029,7 @@ namespace QMAPP.WinForm.Forms.Operation } else { + WriteFile("创建BZD码失败!list=null ", @"D:\MES\Log"); planMATERIAL_CODE = null; processMainCode = null; throw new Exception($"创建BZD码异常!list=null;planMATERIAL_CODE={planMATERIAL_CODE};processMainCode={processMainCode}"); @@ -2017,6 +2037,7 @@ namespace QMAPP.WinForm.Forms.Operation } catch (Exception e) { + WriteFile("创建BZD码失败!Exception: " + e.Message, @"D:\MES\Log"); planMATERIAL_CODE = null; processMainCode = null; MessageBox.Show(e.Message); @@ -3821,5 +3842,50 @@ namespace QMAPP.WinForm.Forms.Operation BindPlanView(); } + + /// + /// 临时日志 + /// + /// + /// + /// + public string WriteFile(string strText, string path) + { + Encoding code = Encoding.GetEncoding("gb2312"); + StreamWriter sw = null; + string filename = DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; + + if (string.IsNullOrEmpty(path)) + { + path = System.AppDomain.CurrentDomain.BaseDirectory; + } + + if (Directory.Exists(path) == false) + { + Directory.CreateDirectory(path); + + } + + try + { + string fullpath = System.IO.Path.Combine(path, filename); + sw = new StreamWriter(fullpath, true, code); + sw.Write("[" + DateTime.Now.ToString() + "]\r\n--" + strText + "\r\n"); + sw.Flush(); + } + catch (Exception ex) + { + //HttpContext.Current.Response.Write(ex.Message); + //HttpContext.Current.Response.End(); + } + finally + { + if (sw != null) + { + sw.Close(); + } + } + return filename; + } } } \ No newline at end of file diff --git a/APPQ5/QMAPP.WinForm/Properties/AssemblyInfo.cs b/APPQ5/QMAPP.WinForm/Properties/AssemblyInfo.cs index e9c07b4..ea2f9c9 100644 --- a/APPQ5/QMAPP.WinForm/Properties/AssemblyInfo.cs +++ b/APPQ5/QMAPP.WinForm/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2022.06.16.01")] -[assembly: AssemblyFileVersion("2022.06.16.01")] +[assembly: AssemblyVersion("2022.06.23.01")] +[assembly: AssemblyFileVersion("2022.06.23.01")]