From d14f92c1b85e1f8ad8c55864debb40518ce9f1d5 Mon Sep 17 00:00:00 2001 From: ray Date: Thu, 24 Nov 2022 00:21:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=8A=A0=E5=85=A5=E5=AE=89=E5=8B=A4=20?= =?UTF-8?q?=E8=99=9B=E6=93=AC=E7=9B=AE=E9=8C=84=E8=A8=AD=E5=AE=9A=202.=20?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=81=8E=E7=AB=99SOP=E9=A1=AF=E7=A4=BA=203.?= =?UTF-8?q?=20=E9=81=8E=E7=AB=99API=E5=88=A4=E6=96=B7=E4=BF=AE=E6=AD=A3=20?= =?UTF-8?q?4.=20Mail=E5=AF=84=E4=BF=A1=E4=BF=AE=E6=94=B9=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 5 +-- AMESCoreStudio.Web/Startup.cs | 12 +++---- AMESCoreStudio.Web/Views/PCS/PCS021.cshtml | 4 +-- .../Controllers/BLL/BarCodeCheckController.cs | 7 ++-- .../Controllers/BLL/MailController.cs | 36 ++++++++++++++----- .../DTO/AMES/BarcodeItemKPDto.cs | 7 +++- AMESCoreStudio.WebApi/Startup.cs | 1 + 7 files changed, 50 insertions(+), 22 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 1583babc..278888ff 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -5380,7 +5380,8 @@ namespace AMESCoreStudio.Web.Controllers model.Sops.Add(new PCS021ViewModel_SOP { SopName = "SOP文件", - SopPath = @$"\\qasrv-n\Web\ISOZone\{Esop.FirstOrDefault().file_path}" + SopPath = $@"/DocEsop/{Esop.FirstOrDefault().file_path}" + //SopPath = @$"\\qasrv-n\Web\ISOZone\{Esop.FirstOrDefault().file_path}" }); } } @@ -6314,7 +6315,7 @@ namespace AMESCoreStudio.Web.Controllers // await formFile.CopyToAsync(stream); // } - // //var fileProvider = _fileServerProvider.GetProvider("/aa"); + // var fileProvider = _fileServerProvider.GetProvider("/aa"); // //var fileInfo = fileProvider.GetFileInfo(formFile.FileName); // //fileInfo = fileProvider.GetFileInfo(formFile.FileName); // ////遠端目錄 diff --git a/AMESCoreStudio.Web/Startup.cs b/AMESCoreStudio.Web/Startup.cs index 91336e90..31dfc6f1 100644 --- a/AMESCoreStudio.Web/Startup.cs +++ b/AMESCoreStudio.Web/Startup.cs @@ -45,12 +45,12 @@ namespace AMESCoreStudio.Web // RequestPath = new PathString("/aa"), // EnableDirectoryBrowsing = true //} - ////new FileServerOptions - //{ - // FileProvider = new PhysicalFileProvider(@"\\server\path"), - // RequestPath = new PathString("/MyPath"), - // EnableDirectoryBrowsing = true - //} + new FileServerOptions + { + FileProvider = new PhysicalFileProvider(@"//qasrv-n/Web/ISOZone/"), + RequestPath = new PathString("/DocEsop"), + EnableDirectoryBrowsing = true + } })); diff --git a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml index 41be59cb..18f3d605 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml @@ -349,14 +349,14 @@ if (!sopfirst) {
- +
sopfirst = true; } else {
- +
} } diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs index 529755ad..825d802a 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs @@ -185,7 +185,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { WipNo = barCodeCheckDto.wipNo, barcode = barCodeCheckDto.barcode, - unitNo = station.Value.Where(w => w.StationID == barCodeCheckDto.stationID).FirstOrDefault().UnitNo, + unitNo = barCodeCheckDto.unitNo, + ststionUnitNo = station.Value.Where(w => w.StationID == barCodeCheckDto.stationID).FirstOrDefault().UnitNo, inputKP = barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).ToList() }; @@ -1782,7 +1783,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES #region 確認是否有設定key Parts資料 WipKpsController wipKpsController = new WipKpsController(_context); var wipKps = (await wipKpsController.GetWipKpByWipNo(barcodeItemKPDto.WipNo)).Value.ToList(); - wipKps = wipKps.Where(w => w.UnitNo == barcodeItemKPDto.unitNo).OrderBy(o => o.KpSeq).ToList(); + wipKps = wipKps.Where(w => w.UnitNo == barcodeItemKPDto.ststionUnitNo).OrderBy(o => o.KpSeq).ToList(); if (wipKps.Count != 0) { #region 判斷內部序號是否有過站紀錄 @@ -1798,7 +1799,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); var BarCodeItems = (await barcodeItemsController.GetBarcodeItemByBarCodeID(BarCodeID)).Value.ToList(); BarCodeItems = BarCodeItems.Where(w => w.WipID == q.Value.FirstOrDefault().WipID - && w.S.UnitNo == barcodeItemKPDto.unitNo).ToList(); + && w.S.UnitNo == barcodeItemKPDto.ststionUnitNo).ToList(); #endregion // 計算過站時刷的組件數量與已經存BarCodeItems diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/MailController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/MailController.cs index df0e473c..4f770fc5 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/MailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/MailController.cs @@ -27,9 +27,9 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL /// 建構式 /// /// - public MailController(AMESContext context) + public MailController(AMESContext context, IConfiguration config) { - _config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build(); + _config = config; _context = context; } @@ -49,11 +49,11 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL ResultModel result = new ResultModel(); // Mail 基本設定資料 - string mailFrom = _config["MailFrom"].ToString(); - string mailSmtpServer = _config["MailSmtpServer"].ToString(); - int mailSmtpPort = int.Parse(_config["MailSmtpPort"].ToString()); - string mailUser = _config["MailUser"].ToString(); - string mailPassword = _config["MailUserPassword"].ToString(); + 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); @@ -151,7 +151,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL } // 是否有附件檔案 - if (Attachment != null) + if (!string.IsNullOrWhiteSpace(Attachment)) { mesMail.Attachments.Add(new Attachment(Attachment)); } @@ -179,5 +179,25 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL return result; } + + /// + /// 用ID获取该單位资料 + /// + /// + // GET: api/FactoryUnits/5 + [HttpGet] + public async Task GetFactoryUnit() + { + // 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; + + var aa = $"{mailFrom} {mailSmtpServer} {mailSmtpPort} {mailUser} {mailPassword}"; + + return aa; + } } } diff --git a/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemKPDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemKPDto.cs index e38ac1d0..8616c91e 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemKPDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemKPDto.cs @@ -22,10 +22,15 @@ namespace AMESCoreStudio.WebApi.DTO.AMES public string barcode { get; set; } /// - /// 生產單位 + /// 工單-生產單位 /// public string unitNo { get; set; } + /// + /// 作業站-生產單位 + /// + public string ststionUnitNo { get; set; } + /// /// List BarCodeCheckDto.inputItem /// diff --git a/AMESCoreStudio.WebApi/Startup.cs b/AMESCoreStudio.WebApi/Startup.cs index ff8c9102..aab6371c 100644 --- a/AMESCoreStudio.WebApi/Startup.cs +++ b/AMESCoreStudio.WebApi/Startup.cs @@ -46,6 +46,7 @@ namespace AMESCoreStudio.WebApi // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddSingleton(Configuration); //services.AddDbContext( // opt => opt.UseLazyLoadingProxies().UseOracle(Configuration.GetConnectionString("AMESContext"), b => b.UseOracleSQLCompatibility("11")));