diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index 35636661..9174d081 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -14,6 +14,8 @@ using System.Dynamic; using Microsoft.Extensions.Configuration; using System.IO; using System.Collections.ObjectModel; +using AMESCoreStudio.WebApi.Controllers.BLL; +using System.Text; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -2995,6 +2997,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); string strLocation = Data.Location; string strCustomer = Data.Customer; string strCreateDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); + string strMaterial = ""; + string strMailBodyHtml = ""; //確認備貨數量 string strDNNo = Data.TableData[0].DnNo; @@ -3018,9 +3022,24 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); await connPTD.OpenAsync(); } + //Mail Body Html + StringBuilder htmlTable = new StringBuilder(); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + htmlTable.AppendLine(""); + + foreach (SNDataModel SNData in Data.TableData) { CheckFlowRules(strRecordType, SNData.Sn); + strMaterial = SNData.Material; string strLatest; //確認此出貨序號是否有ZHistoryKeyDefine strSQL = $@"select Seed FROM [SFIS_PTD].[dbo].[ZHistoryKeyDefine] where serialnumber ='{SNData.Sn}'"; @@ -3082,8 +3101,18 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); SNList.Add(SNData.Sn); } } - } + //Mail Body Html + htmlTable.AppendLine(""); + htmlTable.AppendLine($""); + htmlTable.AppendLine($""); + htmlTable.AppendLine($""); + htmlTable.AppendLine($""); + htmlTable.AppendLine(""); + } + //Mail Body Html + htmlTable.AppendLine(""); + htmlTable.AppendLine("
DN單號LineNoMaterial(料號)SN
{SNData.DnNo}{SNData.LineNo}{SNData.Material}{SNData.Sn}
"); using (var cmd = connPTD.CreateCommand()) { using (var transaction = connPTD.BeginTransaction()) @@ -3109,6 +3138,28 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); } } + if (strRecordType == "601") + { + strSQL = $@"select MailGroup FROM [SFIS_PTD].[dbo].[CustomerItemMailGroup] where [StatusNo] = 'A' + And [ItemNumber] ='{strMaterial}'"; + using (var cmd = connPTD.CreateCommand()) + { + cmd.CommandText = strSQL; + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.Read()) + { + string toMail = reader["MailGroup"].ToString(); + string Subject = $"[AMES系統通知] 出貨單號:" + strDNNo; + string emailBody = htmlTable.ToString(); + await new MailController(_context, _config).PostMail(Subject, emailBody, "", toMail, false); + + } + } + } + } + + result.Success = true; result.Msg = "OK"; result.Data = SNList;