diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index c52ec4c1..5df1661b 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -6880,12 +6880,64 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task PCS032Async(PCS032ViewModel model) { + var BarCodeInterval = new List(); + if (model.GoByStation == 0 || model.RetrueStation == 0) { ModelState.AddModelError("error", "請輸入正確資料"); return View(model); } + // 有設定條碼區間判斷 + if (!string.IsNullOrWhiteSpace(model.BarCodeNoStr) && !string.IsNullOrWhiteSpace(model.BarCodeNoEnd)) + { + + if (model.BarCodeNoStr.Length != model.BarCodeNoEnd.Length) + { + ModelState.AddModelError("error", "條碼區間起訖長度不相同"); + return View(model); + } + + // 流水碼預設長度 + int NoLength = 4; + if (model.BarCodeNoStr.Length <= NoLength || model.BarCodeNoEnd.Length <= NoLength) + { + ModelState.AddModelError("error", "條碼區間號碼長度不能小於" + NoLength + 1); + return View(model); + } + + if (model.BarCodeNoStr.Substring(0, model.BarCodeNoStr.Length - NoLength) != + model.BarCodeNoEnd.Substring(0, model.BarCodeNoEnd.Length - NoLength)) + { + ModelState.AddModelError("error", "條碼區間前置號碼不一樣"); + return View(model); + } + + + if (!int.TryParse(model.BarCodeNoStr.Substring(model.BarCodeNoStr.Length - NoLength, NoLength), out _) || + !int.TryParse(model.BarCodeNoEnd.Substring(model.BarCodeNoEnd.Length - NoLength, NoLength), out _)) + { + ModelState.AddModelError("error", "條碼區間流水碼格式錯誤"); + return View(model); + } + + var NoStr = int.Parse(model.BarCodeNoStr.Substring(model.BarCodeNoStr.Length - NoLength, NoLength)); + var NoEnd = int.Parse(model.BarCodeNoEnd.Substring(model.BarCodeNoEnd.Length - NoLength, NoLength)); + if (NoStr > NoEnd) + { + ModelState.AddModelError("error", "條碼區間結束流水碼不可以小於條碼區間起始流水碼"); + return View(model); + } + + var BarCode = model.BarCodeNoEnd.Substring(0, model.BarCodeNoEnd.Length - NoLength); + for (int i = NoStr; i <= NoEnd; i++) + { + // 將條碼區間寫入List + var itemBarcodeNo = BarCode + i.ToString().PadLeft(NoLength, '0'); + BarCodeInterval.Add(itemBarcodeNo.ToUpper()); + } + } + var result_Wip = await _pcsApi.GetWipInfoByWipNO(model.WipNo.Trim().ToUpper()); var FlowRule = result_Wip.FirstOrDefault().FlowRuleID; var result_RuleStation = await _basApi.GetRuleStationsByFlow(FlowRule, 0); @@ -6919,8 +6971,15 @@ namespace AMESCoreStudio.Web.Controllers var result_BarcodeInfo = await _pcsApi.GetBarcodeInfoesByWipNo(model.WipNo.Trim().ToUpper()); if (model.Type == "P") { - var put_BarcodeInfo = result_BarcodeInfo.Where(w => w.StationID == model.GoByStation && w.StatusNo != "-1").ToList(); + var put_BarcodeInfo = result_BarcodeInfo.Where(w => w.StationID == model.GoByStation && w.StatusID != -1).ToList(); put_BarcodeInfo = put_BarcodeInfo.Select(s => { s.StationID = model.RetrueStation; return s; }).ToList(); + + // 有設定條碼區間,在抓區間內條碼 + if (BarCodeInterval.Count() != 0) + { + put_BarcodeInfo = put_BarcodeInfo.Where(w => BarCodeInterval.Contains(w.BarcodeNo)).ToList(); + } + foreach (var item in put_BarcodeInfo) { await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(item)); @@ -6933,8 +6992,15 @@ namespace AMESCoreStudio.Web.Controllers var goByStations = result_RuleStation.Where(w => w.Sequence >= goBySequence).Select(s => s.StationID).ToList(); foreach (var Station in goByStations) { - var put_BarcodeInfo = result_BarcodeInfo.Where(w => w.StationID == Station && w.StatusNo != "-1").ToList(); + var put_BarcodeInfo = result_BarcodeInfo.Where(w => w.StationID == Station && w.StatusID != -1).ToList(); put_BarcodeInfo = put_BarcodeInfo.Select(s => { s.StationID = model.RetrueStation; return s; }).ToList(); + + // 有設定條碼區間,在抓區間內條碼 + if (BarCodeInterval.Count() != 0) + { + put_BarcodeInfo = put_BarcodeInfo.Where(w => BarCodeInterval.Contains(w.BarcodeNo)).ToList(); + } + foreach (var item in put_BarcodeInfo) { await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(item)); diff --git a/AMESCoreStudio.Web/ViewModels/PCS/PCS032ViewModel.cs b/AMESCoreStudio.Web/ViewModels/PCS/PCS032ViewModel.cs index c3ac7753..25456781 100644 --- a/AMESCoreStudio.Web/ViewModels/PCS/PCS032ViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/PCS/PCS032ViewModel.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.WebApi.Models.BAS; using AMESCoreStudio.WebApi.DTO.AMES; +using System.ComponentModel.DataAnnotations; namespace AMESCoreStudio.Web.ViewModels.PCS { @@ -30,6 +31,9 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// public int RetrueStation { get; set; } + + [Display(Name = "備註")] + [Required(ErrorMessage = "{0},不能空白")] /// /// 備註 /// @@ -39,5 +43,15 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// 退站類型 /// public string Type { get; set; } + + /// + /// 指定起訖條碼 + /// + public string BarCodeNoStr { get; set; } + + /// + /// 指定起訖條碼 + /// + public string BarCodeNoEnd { get; set; } } } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS032.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS032.cshtml index f8bcacc7..ca5aaca8 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS032.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS032.cshtml @@ -68,10 +68,24 @@ +
+
+ +
+ +
+
+
+ +
+
+
+
+
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs index a496906c..3697d2e1 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs @@ -205,7 +205,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES RepairDesc = q5.RepairDesc, RepairNoDesc = q6.RMAReasonDesc, ReplyUser = q7.UserName, - ReplyDate = q3.ReplyDate.ToString("yyyy/MM/dd") + ReplyDate = q3.ReplyDate.ToString("yyyy/MM/dd HH:mm:ss") }; return await q.Distinct().ToListAsync();