diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index 6ba098df..27b8be0b 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -2693,24 +2693,26 @@ namespace AMESCoreStudio.Web.Controllers public async Task GetNGINFOAlertDetailByQueryAsync(string caseID) { var result = await _fqcApi.GetNgInfoAlertDetail(caseID); + List result_data = new List(); foreach (var item in result) { + var Factorydata = await _basApi.GetFactoryInfo(item.FactoryID); var nginfo = new ResultModel(); if (item.Source == "1") //安勤 { - nginfo = await _fqcApi.GetNgRepairDataByBarcodeNO(item.BarcodeNo); + nginfo = await _fqcApi.GetNgRepairDataByBarcodeNO(item.BarcodeNoH); } else // 昶亨 { - nginfo = await _esuncApi.GetNgRepairDataByBarcodeNO(item.BarcodeNo); + nginfo = await _esuncApi.GetNgRepairDataByBarcodeNO(item.BarcodeNoH); } result_data.Add(new { barcodeNo = item.BarcodeNo, - factoryNo = nginfo.Data.Select(s => s.FACTORYNO).FirstOrDefault(), + factoryNo = Factorydata.Select(s => s.FactoryNo).FirstOrDefault(), wipNoF = item.WipNoF, itemNoF = item.ItemNoF, modelName = item.ModelName, @@ -2718,10 +2720,10 @@ namespace AMESCoreStudio.Web.Controllers itemNoH = item.ItemNoH, createDate = item.CreateDate, reasonNo = item.ReasonNo, - stationNo = nginfo.Data.Select(s => s.STATIONNAME).FirstOrDefault(), - userID = nginfo.Data.Select(s => s.USERNAME).FirstOrDefault(), - repairNo = nginfo.Data.Select(s => s.REPAIRNO).FirstOrDefault(), - repairDesc = nginfo.Data.Select(s => s.REPAIRDESC).FirstOrDefault() + stationNo = nginfo.Data.Select(s => s.stationName).FirstOrDefault(), + userName = nginfo.Data.Select(s => s.userName).FirstOrDefault(), + repairNo = nginfo.Data.Select(s => s.repairNo).FirstOrDefault(), + repairDesc = nginfo.Data.Select(s => s.repairDesc).FirstOrDefault() }); @@ -2824,7 +2826,7 @@ namespace AMESCoreStudio.Web.Controllers return View("FQC014R"); } -\\ + public async Task FQC014RAsync(string id ) { diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014.cshtml index daca5846..cfdea908 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC014.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC014.cshtml @@ -250,7 +250,7 @@ function view(obj) { if (obj.data.caseID) { - hg.open('異常警報處理檢視', '/FQC/FQC014UV/' + obj.data.caseID, 1000, 800); + hg.open('異常警報處理檢視', '/FQC/FQC014UV/' + obj.data.caseID, 1200, 800); } } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml index 1e7f1fe4..85667db6 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml @@ -2,109 +2,121 @@ @{ ViewData["Title"] = "FQC014U"; - // Layout = "~/Views/Shared/_FormLayout.cshtml"; + // Layout = "~/Views/Shared/_FormLayout.cshtml"; Layout = "~/Views/Shared/_AMESLayout.cshtml";}
-
-
-
- - - - - - - - - - - - - @*//
*@ - - - - - - - - - - - - - - - - - - - - - - - -
- CASE 編輯 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- @Html.ValidationMessage("error") -
- -
-
-
-
-
-
+
+
+
+ + + + + + + + + + + + + + + @*//
*@ + + + + + + + + + + + + + + + + + + + + + + + +
+ CASE 編輯 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ @Html.ValidationMessage("error") +
+ +
+
+
+
+
+
@section Scripts { @@ -138,7 +150,8 @@ field: 'wipNoF', width: 100, title: '系統工單', - sort: true + sort: true, + templet: '#wipNoF1' }, { field: 'itemNoF', @@ -204,10 +217,17 @@ ]]; var caseID = $("#CaseID").val(); - // alert(caseID); + var table = hg.table.datatable('test', '異常不良警示資料維護', '/FQC/GetNGINFOAlertDetailByQuery?caseID=' + caseID, {}, tableCols, '', false, 'full-100'); - //alert("TABLE1"); + } + diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml index 9c8e9bee..b97e64c1 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml @@ -1,104 +1,126 @@ @model AMESCoreStudio.WebApi.Models.AMES.NgInfoAlertMaster -@{ ViewData["Title"] = "FQC014U"; - Layout = "~/Views/Shared/_FormLayout.cshtml"; } +@{ ViewData["Title"] = "FQC014UV"; + // Layout = "~/Views/Shared/_FormLayout.cshtml"; + Layout = "~/Views/Shared/_AMESLayout.cshtml";} -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- CASE 內容 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- @Html.ValidationMessage("error") - -
+
+
+
+
+
+ + + + + + + + + + + + + + + @*//
*@ + + + + + + + + + + + + + + + + + + + + + + + +
+ CASE 編輯 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ @Html.ValidationMessage("error") + +
+
+
+
+
- @section Scripts { @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); await Html.RenderPartialAsync("_FileinputScriptsPartial"); } - + var toolbar = []; + var tableCols = [[ + { + field: 'barcodeNo', + width: 100, + title: '生產序號', + sort: true + }, + { + field: 'factoryNo', + width: 100, + title: '廠別', + sort: true + }, + { + field: 'wipNoF', + width: 100, + title: '系統工單', + sort: true, + templet: '#wipNoF1' + }, + { + field: 'itemNoF', + width: 100, + title: '系統料號', + sort: true + }, + { + field: 'modelName', + width: 100, + title: '機種', + sort: true + }, + { + field: 'wipNoH', + width: 100, + title: '單板工單', + sort: true + }, + { + field: 'itemNoH', + width: 100, + title: '單板料號', + sort: true + }, + { + field: 'createDate', + width: 100, + title: '警報異常時間', + sort: true + }, + { + field: 'reasonNo', + width: 100, + title: '警報原因', + sort: true + }, + { + field: 'stationNo', + width: 100, + title: '發生站別', + sort: true + }, + { + field: 'repairNo', + width: 100, + title: '維修代碼', + sort: true + }, + { + field: 'repairDesc', + width: 100, + title: '維修原因', + sort: true + }, + { + field: 'userName', + width: 100, + title: '作業人員', + sort: true + } -} + ]]; + var caseID = $("#CaseID").val(); + + var table = hg.table.datatable('test', '異常不良警示資料維護', '/FQC/GetNGINFOAlertDetailByQuery?caseID=' + caseID, {}, tableCols, '', false, 'full-100'); + + + + + +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertMasterController.cs index ccbf2da9..f918d614 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertMasterController.cs @@ -78,7 +78,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } else { - MaxCaseID = MaxCaseID.Substring(4); + MaxCaseID = MaxCaseID.Substring(5); } int serialNumber = int.Parse(MaxCaseID); // 將四位數字轉換為整數 // 若流水號小於9999,則加1 diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs index d6881fed..afffe945 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs @@ -1646,21 +1646,13 @@ and d.wip_no = '{0}' and a.station_id={1} and b.part_no='{2}'", wipNo, stationID join q2 in _context.NgInfos on q1.NgID equals q2.NgID join q3 in _context.BarcodeInfoes on q2.BarcodeID equals q3.BarcodeID where q3.BarcodeNo == barcodeNo - join q4 in _context.WipInfos on q2.WipId equals q4.WipID - join q5 in _context.WipAtts on q4.WipNO equals q5.WipNO - join q6 in _context.LineInfoes on q4.LineID equals q6.LineID join q7 in _context.Stationses on q2.StationId equals q7.StationID join q8 in _context.UserInfoes on q1.CreateUserID equals q8.UserID select new { - q4.UnitNO, - q6.LineDesc, + q1.CreateDate, q7.StationName, - q4.WipNO, - q5.ItemNO, - q5.ModelNO, - q4.LineID, q3.BarcodeNo, q2.TypeNo, q2.StationId, diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/MailController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/MailController.cs index 8a5947c7..2efa4bee 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/MailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/MailController.cs @@ -13,6 +13,7 @@ using System.Collections.Generic; using System.Web; using System.IO; using Microsoft.AspNetCore.StaticFiles; +using AMESCoreStudio.WebApi.Models.AMES; namespace AMESCoreStudio.WebApi.Controllers.BLL { @@ -183,6 +184,149 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL return result; } + + /// + /// Mail 寄信 + /// + /// + [HttpPost("ToMail1")] + public async Task> PostMail1(Mail Mails) + { + ResultModel result = new ResultModel(); + + // Mail 基本設定資料 + string mailFrom = _config.GetSection("MailFrom").Value; + string mailSmtpServer = _config.GetSection("MailSmtpServer").Value; + int mailSmtpPort = int.Parse(_config.GetSection("MailSmtpPort").Value); + string mailUser = _config.GetSection("MailUser").Value; + string mailPassword = _config.GetSection("MailUserPassword").Value; + + MailMessage mesMail = new MailMessage(); + mesMail.From = new MailAddress(mailFrom); + mesMail.Subject = Mails.Subject; + mesMail.SubjectEncoding = System.Text.Encoding.UTF8; + mesMail.Body = Mails.Body; + mesMail.IsBodyHtml = true; + mesMail.BodyEncoding = System.Text.Encoding.UTF8; + // 判斷是否加密 + if (Mails.ToCC) + { + #region 判斷群組 + if (!string.IsNullOrWhiteSpace(Mails.ToMailGroup)) + { + var mailGroups = Mails.ToMailGroup.Split(','); + foreach (var mailG in mailGroups) + { + var q = from a in _context.MailGroups + where a.GroupNo.ToUpper() == mailG.ToUpper() + join b in _context.MailGroupDetails on a.GroupID equals b.GroupID + join c in _context.UserInfoes on b.UserID equals c.UserID + select new + { + b.UserID, + c.UserName, + c.UserEMail + }; + + foreach (var userMail in await q.ToListAsync()) + { + if (!string.IsNullOrWhiteSpace(userMail.UserEMail)) + { + mesMail.CC.Add(new MailAddress(userMail.UserEMail)); + } + } + } + + } + #endregion + + #region 個人 + if (!string.IsNullOrWhiteSpace(Mails.ToMail)) + { + var mails = Mails.ToMail.Split(','); + foreach (var mail in mails) + { + mesMail.CC.Add(new MailAddress(mail)); + } + + } + #endregion + } + else + { + #region 判斷群組 + if (!string.IsNullOrWhiteSpace(Mails.ToMailGroup)) + { + var mailGroups = Mails.ToMailGroup.Split(','); + foreach (var mailG in mailGroups) + { + var q = from a in _context.MailGroups + where a.GroupNo.ToUpper() == mailG.ToUpper() + join b in _context.MailGroupDetails on a.GroupID equals b.GroupID + join c in _context.UserInfoes on b.UserID equals c.UserID + select new + { + b.UserID, + c.UserName, + c.UserEMail + }; + + foreach (var userMail in await q.ToListAsync()) + { + if (!string.IsNullOrWhiteSpace(userMail.UserEMail)) + { + mesMail.To.Add(new MailAddress(userMail.UserEMail)); + } + } + } + + } + #endregion + + #region 個人 + if (!string.IsNullOrWhiteSpace(Mails.ToMail)) + { + var mails = Mails.ToMail.Split(','); + foreach (var mail in mails) + { + mesMail.To.Add(new MailAddress(mail)); + } + + } + #endregion + } + + // 是否有附件檔案 + if (!string.IsNullOrWhiteSpace(Mails.Attachments)) + { + mesMail.Attachments.Add(new Attachment(Mails.Attachments)); + } + + SmtpClient mailClient = new SmtpClient(mailSmtpServer, mailSmtpPort); + + //mailClient.EnableSsl = true; + NetworkCredential nc = new NetworkCredential(); + nc.UserName = mailUser; + nc.Password = mailPassword; + + + try + { + mailClient.Credentials = nc; + mailClient.Send(mesMail); + result.Success = true; + result.Msg = "寄信成功"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = "寄信失敗,錯誤:" + ex.InnerException.Message; + } + return result; + } + + + /// /// Mail 寄信 /// diff --git a/AMESCoreStudio.WebApi/Models/AMES/Mail.cs b/AMESCoreStudio.WebApi/Models/AMES/Mail.cs new file mode 100644 index 00000000..260d3f86 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/Mail.cs @@ -0,0 +1,35 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// + /// + public class Mail + { + // 主題 + public string Subject { get; set; } + + // 正文 + public string Body { get; set; } + + // 收件人群組 + public string ToMailGroup { get; set; } + + // 收件人郵箱 + public string ToMail { get; set; } + + // 是否抄送 + public bool ToCC { get; set; } + + // 附件(可選) + public string Attachments { get; set; } + + + } + +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertDetail.cs b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertDetail.cs index 13d457ca..39eb4509 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertDetail.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertDetail.cs @@ -63,13 +63,23 @@ namespace AMESCoreStudio.WebApi.Models.AMES public int UserID { get; set; } /// - /// 資料來源 (Data Source) + /// 單板資料來源 1:安勤 2:昶亨 /// [DataMember] [Display(Name = "資料來源")] [Column("SOURCE")] public string Source { get; set; } + /// + /// 單板序號 + /// + [DataMember] + [Display(Name = "單板序號")] + [Column("BARCODE_NO_H")] + public string BarcodeNoH { get; set; } + + + /// /// 警報原因 (Alert Reason) /// diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs index 020863a9..7d07630d 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs @@ -185,6 +185,24 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("LINK")] public string Link { get; set; } + + /// + /// 單板序號 + /// + [DataMember] + [Display(Name = "單板序號")] + [Column("BARCODE_NO_H")] + public string BarcodeNoH { get; set; } + + /// + /// 單板資料來源 1:安勤 2:昶亨 + /// + [DataMember] + [Display(Name = "資料來源")] + [Column("SOURCE")] + public string Source { get; set; } + + /// /// 工單-基本資料 ///