From 6f1ba379ed44c326c271dca7bab0415a0cab2531 Mon Sep 17 00:00:00 2001 From: "BB.Wang" Date: Tue, 12 Jul 2022 14:19:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=AE=8C=E5=B7=A5?= =?UTF-8?q?=E5=85=A5=E5=BA=AB=E4=BD=9C=E6=A5=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AMESCoreStudio.Web/AppSetting.cs | 4 + .../Controllers/PCSController.cs | 350 ++++++++++++++++++ AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 57 +++ AMESCoreStudio.Web/Views/PCS/PCS031.cshtml | 331 +++++++++++++++++ AMESCoreStudio.Web/Views/PCS/PCS031Q.cshtml | 100 +++++ AMESCoreStudio.Web/Views/PCS/PCS031V.cshtml | 108 ++++++ .../AMES/BarcodeInfoesController.cs | 52 +++ .../AMES/FqcInhouseMasterController.cs | 99 +++++ AMESCoreStudio.WebApi/DTO/AMES/BoxNO_SNDto.cs | 79 ++++ .../DTO/AMES/FqcInhouseMaster_WareDto.cs | 119 ++++++ .../Models/AMES/PTD101AMESModel.cs | 60 +++ .../Models/AMES/WareHouseing.cs | 80 ++++ AMESCoreStudio.WebApi/Models/AMESContext.cs | 10 + 13 files changed, 1449 insertions(+) create mode 100644 AMESCoreStudio.Web/Views/PCS/PCS031.cshtml create mode 100644 AMESCoreStudio.Web/Views/PCS/PCS031Q.cshtml create mode 100644 AMESCoreStudio.Web/Views/PCS/PCS031V.cshtml create mode 100644 AMESCoreStudio.WebApi/DTO/AMES/BoxNO_SNDto.cs create mode 100644 AMESCoreStudio.WebApi/DTO/AMES/FqcInhouseMaster_WareDto.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/WareHouseing.cs diff --git a/AMESCoreStudio.Web/AppSetting.cs b/AMESCoreStudio.Web/AppSetting.cs index 4eeca77f..89b27c8e 100644 --- a/AMESCoreStudio.Web/AppSetting.cs +++ b/AMESCoreStudio.Web/AppSetting.cs @@ -16,6 +16,10 @@ namespace AMESCoreStudio.Web /// public string ApiUrl { get; set; } + //Yiru Add ------------------------------------------------------------------- + public string Location { get; set; } + //Yiru End ------------------------------------------------------------------- + public static AppSetting Setting { get; set; } = new AppSetting(); } } diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 472be05e..9152db9c 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -6317,6 +6317,356 @@ namespace AMESCoreStudio.Web.Controllers #endregion + //YIRU ADD ------------------------------------------------------------------------------------------------------------------------------- + + #region PCS031 完工入庫 + public IActionResult PCS031() + { + return View(); + } + + public async Task PCS031QueryAsync(string barcodeNo, string wipNo + , string boxNo, string inhouseNo, string date_str, string date_end + , string status, int page = 0, int limit = 10) + { + //IResultModel result = await _fqcApi.GetFqcInhouseMasterQuery(barcodeNo: barcodeNo, wipNo: wipNo + //, boxNo: boxNo, inhouseNo: inhouseNo, date_str: date_str, date_end: date_end + //, status: status, page: page, limit: limit); + IResultModel result = await _pcsApi.GetFqcInhouseMasterMultiQuery(barcodeNo: barcodeNo, wipNo: wipNo + , boxNo: boxNo, inhouseNo: inhouseNo, date_str: date_str, date_end: date_end + , status: status, page: page, limit: limit); + if (result.Data.Count() != 0) + { + var Data = result.Data.Where(w => w.StatusName == "允收"); + return Json(new Table() { code = 0, msg = "", data = Data, count = Data.Count() }); + } + return Json(new Table() { count = 0, data = null }); + } + public async Task PCS031inhouse_allAsync(string[] ids) + { + string msg = ""; + if (ids.Length > 0) + { + for (int i = 0; i < ids.Length; i++) + { + string InhouseNo = ids[i].Split(',')[0]; + string boxNo = ids[i].Split(',')[1]; + string seq = ids[i].Split(',')[2]; + string recordNumber = ids[i].Split(',')[3]; + var result = await PCS0311inhouse(InhouseNo, boxNo, Convert.ToInt16(seq), recordNumber); + + if (!result.success) + { + msg += result.msg + "
"; + } + + } + + return Json(new Result() { success = true, msg = "批次入庫完成
" + msg }); + } + else + { + return Json(new Result() { success = false, msg = "NO Select Data" }); + } + + } + public async Task PCS031inhouseAsync(string InhouseNo, string boxNo, int seq, string recordNumber) + { + var result = await PCS0311inhouse(InhouseNo, boxNo, seq, recordNumber); + return Json(new Result() { success = result.success, msg = result.msg }); + + + + } + + + private async Task PCS0311inhouse(string InhouseNo, string boxNo, int seq, string recordNumber) + { + /* 1.依barcodeinfo 查詢 該箱號所屬序號 + * 2.查詢所有序號查詢該流程 是否為最後一個流程(入庫),即在可入庫狀態 + * 3.若有序號不可入庫 => 畫面顯示不可入之序號 + * 4.所有序號可入庫 = > + */ + + var result = await _fqcApi.GetBarcodeInfoesByBoxNo(boxNo: boxNo); + + if (result.Count() != 0) + { + var _msg = string.Empty; + + if (recordNumber == null) _msg = "請輸入入庫箱號"; + if (AppSetting.Setting.Location == "9000" || AppSetting.Setting.Location == "0S08") + { + if (recordNumber.Length != 10 || !recordNumber.StartsWith("50000")) + { + _msg = "箱號:" + boxNo + " recordNumber 必須為10碼且為50000開頭,RecordNumber format error
"; + + } + + } + foreach (var item in result) + { + var FlowStation_result = await _basApi.GetRuleStation(item.RuleStationID); + if (FlowStation_result.Count() != 0) + { + var FlowRule_result = await _basApi.GetRuleStationsByFlow(FlowStation_result.Select(s => s.FlowRuleID).First()); + if (FlowRule_result.Count() != 0) + { + var LastRuleStationID = FlowRule_result.Where(w => w.StationID != 1000).OrderBy(o => o.Sequence).Select(s => s.RuleStationID).Last(); + + if (item.RuleStationID != LastRuleStationID || item.RuleStatus != "P" || item.StatusID != -1) + { + _msg += "序號【" + item.BarcodeNo + "】,流程尚未完成,不可入庫!
"; + } + } + else + { + _msg = "查無序號" + item.BarcodeNo + "目前流程(flowID)"; + } + } + + else + { + _msg = "查無序號" + item.BarcodeNo + "目前流程(rule_station_ID)"; + } + } + if (_msg == string.Empty) + { + + var FlowRules_result = await _basApi.GetFlowRulesByUnit("W"); + if (FlowRules_result.Count() != 0) + { + var ruleStations_result = await GetRuleStationByFlowRuleID(FlowRules_result.Select(s => s.FlowRuleID).First()); + var RuleStationID = ruleStations_result.Select(s => s.RuleStationID).First(); + + var Wipinfo_result = await _pcsApi.GetWipInfo(result.Select(s => s.WipID).First()); + var Wipinfo_LineID = Wipinfo_result.Select(s => s.LineID).First(); //lineid + var WipAtt_result = await _pcsApi.GetWipAtt(Wipinfo_result.Select(s => s.WipNO).First()); //料號 + var Userinfo_result = await _sysApi.GetUserInfo(GetLogInUserID()); + + + + List PTD101AMESModels = new List(); + foreach (var item in result) + { + + BarcodeInfo barcodeInfo = new BarcodeInfo + { + BarcodeID = item.BarcodeID, + BarcodeNo = item.BarcodeNo, + StatusNo = item.StatusNo, + RuleStationID = RuleStationID, + RuleStatus = "P",//F 不良 + BoxNo = item.BoxNo, + WipID = item.WipID, + StatusID = -1, + CreateUserID = item.CreateUserID, + CreateDate = item.CreateDate, + UpdateDate = System.DateTime.Now + + + }; + + await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); + + var barcodeStations = new BarcodeStation + { + BarcodeID = item.BarcodeID, + WipID = item.WipID, + RuleStationID = RuleStationID, + RuleStatus = "P", + InputDate = DateTime.Now, + LineId = (int)Wipinfo_LineID, + CreateUserID = item.CreateUserID, + GetRuleStation = new RuleStation + { + //RuleStationID = RuleStationID, + //FlowRuleID = "", + //StationID ="", + //StationDescl + //Sequence="", + //StationType = "", + //CreateUserId =item.CreateUserID, + //CreateDate = DateTime.Now, + //UpdateDate = DateTime.Now + + + } + }; + await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStations)); + + + + PTD101AMESModels.Add(new PTD101AMESModel + { + FQCID = InhouseNo, + SSN = item.ExtraBarcodeNo, + ISN = item.BarcodeNo, + RecordNumber = recordNumber, + PN = WipAtt_result.ItemNO, + EmpID = Userinfo_result.Select(s => s.UserNo).FirstOrDefault(), + Location = AppSetting.Setting.Location + + + }); + + + } + + var Warehouseing = new WareHouseing + { + InhouseNo = InhouseNo, + SeqID = seq, + SerialNo = boxNo, + Serial_Type = "B", + RecordNumber = recordNumber, + Create_UserID = Userinfo_result.Select(s => s.UserID).FirstOrDefault(), + Create_Date = DateTime.Now + }; + + await _pcsApi.PostWareHouseing(JsonConvert.SerializeObject(Warehouseing)); + // await _pcsApi.PostPTD101AMES(JsonConvert.SerializeObject(PTD101AMESModels)); + + + } + else + { + _msg = "查無入庫代碼(W)"; + } + + + + //執行入庫作業 + return new Result() { success = true, msg = "入庫完成" }; + } + else + { + return new Result() { success = false, msg = _msg }; + } + + + } + else + { + return new Result() { success = false, msg = "NO SN DATA" }; + } + + + } + + + #endregion + + #region PCS031V入庫單箱號查詢 + public async Task PCS031V(string InhouseNo, int SeqID) + { + var model = new FqcDto(); + model.InhouseNo = InhouseNo;// "QWO0002A1001"; + model.SeqID = SeqID; + IResultModel result; + result = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); + + if (result.Data.Count() != 0) + { + model = result.Data.FirstOrDefault(); + model.h_InhouseNo = model.InhouseNo; + model.h_SeqID = model.SeqID.ToString(); + } + else + { + ModelState.AddModelError("error", "找不到入庫單號【" + model.InhouseNo + "】的資料"); + model.h_InhouseNo = ""; + model.h_SeqID = ""; + } + + return View("PCS031V", model); + // return View(model); + } + + + [HttpGet] + public async Task PCS031VAsync(FqcDto model) + { + if (string.IsNullOrWhiteSpace(model.InhouseNo)) + { + ModelState.AddModelError("error", "請輸入入庫單號"); + return View("PCS031V", model); + } + + IResultModel result; + + result = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); + + if (result.Data.Count() != 0) + { + model = result.Data.FirstOrDefault(); + model.h_InhouseNo = model.InhouseNo; + model.h_SeqID = model.SeqID.ToString(); + } + else + { + ModelState.AddModelError("error", "找不到入庫單號【" + model.InhouseNo + "】的資料"); + model.h_InhouseNo = ""; + model.h_SeqID = ""; + } + + return View("PCS031V", model); + } + + + #endregion + + #region PCS031Q入庫單箱號查詢 + // [HttpGet] + public async Task PCS031Q(string BoxNo) + { + + + var model = new BoxNO_SNDto(); + model.BoxNo = BoxNo; + return View(model); + + //IResultModel result; + + //result = await _pcsApi.GetBarcodeInfoesByBoxNoPCS031Q(boxNo: model.BoxNo); + + + //if (result.Data.Count() != 0) + //{ + // model = result.Data.FirstOrDefault(); + + // model.BoxNo = model.BoxNo; + + //} + //else + //{ + // ModelState.AddModelError("error", "找不到箱號單號【" + model.BoxNo + "】的序號資料"); + // model.BoxNo = ""; + + //} + ////// ViewBag.BoxNO = boxNo; + //return View("PCS031Q", model); + } + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task PCS031QQueryAsync(string id, int page = 0, int limit = 10) + { + + + IResultModel result = await _pcsApi.GetBarcodeInfoesByBoxNoPCS031Q(boxNo: id, page: page, limit: limit); + if (result.Data.Count() != 0) + { + + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.Data.Count() }); + } + return Json(new Table() { count = 0, data = null }); + } + + + #endregion + + //YIRU End ------------------------------------------------------------------------------------------------------------------------------- + /// /// 登入UserID /// diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 126ed28f..98195f87 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -1227,5 +1227,62 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/WipStation")] ITask> GetWipStation(); + + // YIRU ADD ---------------------------------------------------------------------------------------- + + #region PTD101AMES 完工入庫序號轉檔 + [WebApiClient.Attributes.HttpGet("http://nportal.avalue.com.tw/PTD_Batch/api/PTD101AMES")] + ITask> PostPTD101AMES([FromBody, RawJsonContent] string model); + + #endregion + + /// + /// 用入庫單號與序號取完工入庫明细資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WareHouseing/{inhouseNo}/{seq}")] + ITask> GetWareHouseing(string inhouseNo, int seq); + + /// + ///新增完工入庫明细資料 + /// + /// + [WebApiClient.Attributes.HttpPost("api/WareHouseing")] + ITask> PostWareHouseing([FromBody, RawJsonContent] string model); + + /// + ///修改完工入庫明细資料 + /// + /// + [WebApiClient.Attributes.HttpPut("api/WareHouseing")] + ITask> PutWareHouseing([FromBody, RawJsonContent] string model); + + + #region PCS031 FQC查詢 + /// + /// FQC查詢 + /// + /// 內部序號 + /// 工單號碼 + /// 外箱號碼 + /// 入庫單號碼 + /// 入庫時間起 + /// 入庫時間迄 + /// 抽驗結果 + /// 頁數 + /// 筆數 + /// + [WebApiClient.Attributes.HttpGet("api/FqcInhouseMaster/FqcInhouseMasterMultiQuery/")] + ITask> GetFqcInhouseMasterMultiQuery(string barcodeNo = null, string wipNo = null + , string boxNo = null, string inhouseNo = null, string date_str = null, string date_end = null + , string status = null, int page = 0, int limit = 10); + + + [WebApiClient.Attributes.HttpGet("api/BarcodeInfoes/ByBoxNoPCS031Q/")] + ITask> GetBarcodeInfoesByBoxNoPCS031Q(string boxNo, int page = 0, int limit = 10); + + #endregion + + //YIRU End ---------------------------------------------------------------------------------------- } } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS031.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS031.cshtml new file mode 100644 index 00000000..c209f742 --- /dev/null +++ b/AMESCoreStudio.Web/Views/PCS/PCS031.cshtml @@ -0,0 +1,331 @@ + +@{ + ViewData["Title"] = "完工入庫"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + + + + + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +@section Scripts{ + + + + + + +} + diff --git a/AMESCoreStudio.Web/Views/PCS/PCS031Q.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS031Q.cshtml new file mode 100644 index 00000000..646be43d --- /dev/null +++ b/AMESCoreStudio.Web/Views/PCS/PCS031Q.cshtml @@ -0,0 +1,100 @@ +@model AMESCoreStudio.WebApi.DTO.AMES.BoxNO_SNDto + +@{ + ViewData["Title"] = "箱號序號查詢"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+ + +
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/PCS/PCS031V.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS031V.cshtml new file mode 100644 index 00000000..e309133d --- /dev/null +++ b/AMESCoreStudio.Web/Views/PCS/PCS031V.cshtml @@ -0,0 +1,108 @@ +@model AMESCoreStudio.WebApi.DTO.AMES.FqcDto +@{ + ViewData["Title"] = "箱號資料查詢"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
+
@ViewBag.Title
+
+
+
+ +
+ +
+ + + +
+ +
+
+
+
+
+ + + +
+ + + @*
*@ + + @{ int i = 0;} + + + + + + + + + + + + @foreach (var index in Model.fqcDetails) + { + + + + + + + + + i++; + } + + +
+ 箱號 + + 總數量 + + 已抽數量 + + 抽驗PASS數量 + + 抽驗FAIL數量 +
+ @index.SerialNo + + @index.Qty + + + @index.HasQty + + @index.PassQty + + @index.FailQty +
+
+ +
+ +@section Scripts{ + + + +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs index cf42b7d1..49008a11 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs @@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore; using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.CommonTools.Result; +using AMESCoreStudio.WebApi.DTO.AMES; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -305,6 +306,57 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return barcodeInfo; } + //YIRU ADD ------------------------------------------------------------------------------------------ + + /// + /// FQC查詢 by Table + /// + /// 內部序號 + /// 工單號碼 + /// 外箱號碼 + /// 入庫單號碼 + /// 入庫時間起 + /// 入庫時間迄 + /// 抽驗結果 + /// 頁數 + /// 筆數 + /// + [HttpGet("ByBoxNoPCS031Q")] + public async Task> GetBarcodeInfoesByBoxNoPCS031Q(string boxNo, int page = 0, int limit = 10) + { + + IQueryable q = from q1 in _context.BarcodeInfoes + join q2 in _context.WipInfos on q1.WipID equals q2.WipID + select new BoxNO_SNDto + { + BarcodeID = q1.BarcodeID, + BarcodeNo = q1.BarcodeNo, + BoxNo = q1.BoxNo, + ExtraBarcodeNo = q1.ExtraBarcodeNo, + StatusNo = q1.StatusNo, + WipNO = q2.WipNO, + RuleStationID = q1.RuleStationID + }; + + q = q.Where(w => w.BoxNo == boxNo); + + + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + return result; + } + + //YIRU End ------------------------------------------------------------------------------------------ + private bool BarcodeInfoesExists(int id) { return _context.BarcodeInfoes.Any(e => e.BarcodeID == id); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs index 0780b8b8..6464f368 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs @@ -364,6 +364,105 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + //YIRU ADD ----------------------------------------------------------------------------------------------------------------------------------------------- + /// + /// FQC查詢 by Table + /// + /// 內部序號 + /// 工單號碼 + /// 外箱號碼 + /// 入庫單號碼 + /// 入庫時間起 + /// 入庫時間迄 + /// 抽驗結果 + /// 頁數 + /// 筆數 + /// + [HttpGet("FqcInhouseMasterMultiQuery")] + public async Task> GetFqcInhouseMasteMultiQuery(string barcodeNo, string wipNo, string boxNo + , string inhouseNo, string date_str, string date_end, string status, int page = 0, int limit = 10) + { + IQueryable q = from q1 in _context.FqcInhouseMasters + join q2 in _context.FqcInhouseDetails on new { q1.InhouseNo, q1.SeqID } equals new { q2.InhouseNo, q2.SeqID } + join q3 in _context.FqcResultMasters on q1.InhouseNo equals q3.InhouseNo + join q4 in _context.WareHouseings on new { q2.InhouseNo, q2.SeqID, q2.SerialNo } equals new { q4.InhouseNo, q4.SeqID, q4.SerialNo } into q2q4 + from q402 in q2q4.DefaultIfEmpty() + select new FqcInhouseMaster_WareDto + { + InhouseNo = q1.InhouseNo, + SeqID = q1.SeqID, + WipNo = q1.WipNo, + ItemNo = q1.ItemNo, + ModelNo = q1.ModelNo, + SerialNo = q2.SerialNo, + StatusName = q1.Status, + ProTypeName = q1.ProType, + CreateDate = q1.CreateDate, + EndTime = q3.EndTime, + RecordNumber = q402.RecordNumber + }; + //q1.Status == "P" ? "允收" : q1.Status == "R" ? "批退" : "未驗收完成", + //IQueryable q1 = _context.FqcInhouseDetails; + if (!string.IsNullOrWhiteSpace(inhouseNo)) + q = q.Where(w => w.InhouseNo == inhouseNo); + + if (!string.IsNullOrWhiteSpace(wipNo)) + q = q.Where(w => w.WipNo == wipNo); + + if (!string.IsNullOrWhiteSpace(status)) + q = q.Where(w => w.StatusName == status); + + // 優先用內部序號取出包裝序號 + if (!string.IsNullOrWhiteSpace(barcodeNo)) + { + BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); + var q1 = await barcodeInfoesController.GetBarcodeInfoesByNo(barcodeNo); + if (q1.Value.Count() != 0) + { + boxNo = q1.Value.FirstOrDefault().BoxNo; + } + } + + if (!string.IsNullOrWhiteSpace(boxNo)) + { + q = q.Where(w => w.SerialNo == boxNo); + } + + if (DateTime.TryParse(date_str, out _)) + { + q = q.Where(w => w.CreateDate >= DateTime.Parse(date_str)); + } + + if (DateTime.TryParse(date_end, out _)) + { + q = q.Where(w => w.CreateDate <= DateTime.Parse(date_end)); + } + + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + + // 判斷結束時間 + result.Data = result.Data.Select(s => { s.EndTime = s.StatusName == "A" ? null : s.EndTime; return s; }) + .ToList(); + + // 修改狀態名稱 + result.Data = result.Data.Select(s => { s.StatusName = s.StatusName == "P" ? "允收" : s.StatusName == "R" ? "批退" : "未驗收完成"; return s; }) + .ToList(); + + return result; + } + + //YIRU End ----------------------------------------------------------------------------------------------------------------------------------------------- + private bool FqcInhouseMasterExists(string id) { return _context.FqcInhouseMasters.Any(e => e.InhouseNo == id); diff --git a/AMESCoreStudio.WebApi/DTO/AMES/BoxNO_SNDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/BoxNO_SNDto.cs new file mode 100644 index 00000000..d8e8c633 --- /dev/null +++ b/AMESCoreStudio.WebApi/DTO/AMES/BoxNO_SNDto.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Runtime.Serialization; +using System.Threading.Tasks; + +namespace AMESCoreStudio.WebApi.DTO.AMES +{ + /// + /// BarcodeItemKP Dto + /// + /// yiru add + /// + public partial class BoxNO_SNDto + { + /// + /// 序號id + /// + [DataMember] + public int BarcodeID { get; set; } + + /// + /// 序號 + /// + [Key] + [DataMember] + public string BarcodeNo { get; set; } + + /// + /// 箱號 + /// + [DataMember] + [Display(Name = "箱號")] + public string BoxNo { get; set; } + + /// + /// 外部序號 + /// + [DataMember] + [Display(Name = "外部序號")] + public string ExtraBarcodeNo { get; set; } + + /// + /// 狀態 + /// + [DataMember] + [Display(Name = "狀態")] + public string StatusNo { get; set; } + + + /// + /// 箱號/條碼 + /// + [DataMember] + [Display(Name = "箱號/條碼")] + public string SerialNo { get; set; } + + /// + /// 工單號碼 + /// + [DataMember] + [Display(Name = "工單號碼")] + + public string WipNO { get; set; } + + /// + /// 流程 + /// + [DataMember] + [Display(Name = "流程")] + + public int RuleStationID { get; set; } + + + } + +} diff --git a/AMESCoreStudio.WebApi/DTO/AMES/FqcInhouseMaster_WareDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/FqcInhouseMaster_WareDto.cs new file mode 100644 index 00000000..b56278d1 --- /dev/null +++ b/AMESCoreStudio.WebApi/DTO/AMES/FqcInhouseMaster_WareDto.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using System.Runtime.Serialization; + + +#nullable disable + +namespace AMESCoreStudio.WebApi.DTO.AMES +{//yiru add + /// + /// 入庫單資料檔 Dto + /// + public partial class FqcInhouseMaster_WareDto + { + /// + /// 入庫單號碼 + /// + [DataMember] + public string InhouseNo { get; set; } + + /// + /// 順序ID + /// + [Key] + [DataMember] + public int SeqID { get; set; } = 1; + + /// + /// 工單號碼 + /// + [DataMember] + [Display(Name = "工單號碼")] + public string WipNo { get; set; } + + /// + /// 料號 + /// + [DataMember] + [Display(Name = "料號")] + public string ItemNo { get; set; } + + /// + /// 品名/機種 + /// + [DataMember] + [Display(Name = "品名/機種")] + public string ModelNo { get; set; } + + /// + /// 箱號/條碼 + /// + [DataMember] + [Display(Name = "箱號/條碼")] + public string SerialNo { get; set; } + + /// + /// 抽驗狀態 P-PASS(允收);R-REJECT(批退); A-初始狀態 + /// + [DataMember] + [Display(Name = "抽驗狀態")] + + public string StatusName { get; set; } = "A"; + + /// + /// 產品類別 STANDARD(標準品),Order(訂單) + /// + [DataMember] + [Display(Name = "產品類別")] + + public string ProTypeName { get; set; } + + /// + /// 結束抽驗時間 + /// + [DataMember] + [Display(Name = "結束抽驗時間")] + + public DateTime? EndTime { get; set; } + + /// + /// 建立UserID + /// + [Column("CREATE_USERID")] + [DataMember] + public int CreateUserID { get; set; } = 0; + + /// + /// 建立日期 + /// + [Column("CREATE_DATE")] + [DataMember] + public DateTime CreateDate { get; set; } = DateTime.Now; + + /// + /// 更新UserID + /// + [Column("UPDATE_USERID")] + [DataMember] + public int UpdateUserID { get; set; } = 0; + + /// + /// 更新日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + public DateTime? UpdateDate { get; set; } = DateTime.Now; + + + /// + /// 入庫單號 + /// + [DataMember] + [Display(Name = "入庫單號")] + public string RecordNumber { get; set; } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs b/AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs new file mode 100644 index 00000000..e268ea10 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 完工入庫呼叫安勤api轉檔 + /// + public class PTD101AMESModel + { + /// + /// AME驗單單號 + /// + public string FQCID { get; set; } + + /// + /// 出貨序號 + /// + /// + public string SSN { get; set; } + + /// + /// 生產序號 + /// + public string ISN { get; set; } + + /// + /// 本次入庫單號 + /// + public string RecordNumber { get; set; } + + /// + /// 料號 + /// + public string PN { get; set; } + + /// + /// 成倉人員工號 + /// + public string EmpID { get; set; } + + /// + /// 安勤: 9000 昶亨:0S08 + /// + public string Location { get; set; } + + /// + /// 101 + /// + public string RecordTypeID { get; set; } = "101"; + + /// + /// 正式資料:Ava.ptdbatch 測試資料 :test-Ava.ptdbatch-test + /// + public string Key { get; set; } = "test-Ava.ptdbatch-test"; + + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/WareHouseing.cs b/AMESCoreStudio.WebApi/Models/AMES/WareHouseing.cs new file mode 100644 index 00000000..724a0979 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/WareHouseing.cs @@ -0,0 +1,80 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; +using AMESCoreStudio.WebApi; +namespace AMESCoreStudio.WebApi.Models.AMES +{ //yiru add + /// + /// 工單條碼起迄資料檔 + /// + [Table("WAREHOUSEING", Schema = "JHAMES")] + [DataContract] + public class WareHouseing + { + /// + /// 入庫單號碼 + /// + [Key] + [DataMember] + [Display(Name = "入庫單號碼")] + [Required] + [Column("INHOUSE_NO")] + [StringLength(13)] + public string InhouseNo { get; set; } + + /// + /// 順序ID + /// + [Key] + [DataMember] + [Display(Name = "順序ID")] + [Column("SEQ_ID")] + public int SeqID { get; set; } + + /// + /// 箱號/條碼 + /// + [Key] + [DataMember] + [Display(Name = "箱號/條碼")] + [Required(ErrorMessage = "{0},不能空白")] + [Column("SERIAL_NO")] + [StringLength(30)] + public string SerialNo { get; set; } + + + /// + /// 單號產生類型 B-按箱號產生;A-按條碼產生 + /// + [DataMember] + [Display(Name = "單號產生類型")] + [Required(ErrorMessage = "{0},不能空白")] + [Column("SERIAL_TYPE")] + [StringLength(1)] + public string Serial_Type { get; set; } = "B"; + + + /// + /// + /// + [Column("RECORDNUMBER")] + [DataMember] + [Display(Name = "本次入庫單號")] + public string RecordNumber { get; set; } + + [Column("CREATE_USERID")] + [DataMember] + [Display(Name = "建立者")] + public decimal Create_UserID { get; set; } + + + + [Column("CREATE_DATE")] + [DataMember] + [Display(Name = "建立日期")] + public DateTime Create_Date { get; set; } = DateTime.Now; + + + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 99fefe90..099b7dc1 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -97,6 +97,10 @@ namespace AMESCoreStudio.WebApi modelBuilder.Entity().HasKey(c => new { c.WipID, c.RuleStationID, c.RuleStatus, c.ClassID, c.CreateDate }); modelBuilder.Entity().HasKey(c => new { c.WipID, c.RuleStationID, c.RuleStatus, c.SegmentID, c.CreateDate }); + //Yiru add --------------------------------------------------------------------------------------------------------------------------- + modelBuilder.Entity().HasKey(c => new { c.InhouseNo, c.SeqID, c.SerialNo }); + //Yiru End --------------------------------------------------------------------------------------------------------------------------- + modelBuilder.Entity().HasKey(c => new { c.InspectionItemID, c.InspectionID,c.CreateDate }); modelBuilder.Entity().HasKey(c => new { c.InspectionItemID, c.InspectionID }); @@ -807,6 +811,12 @@ namespace AMESCoreStudio.WebApi /// 外包機種資料 /// public DbSet SNKeyParts { get; set; } + + /// Yiru add --------------------------------------------------- + /// 檢驗單明細資料檔 + /// + public virtual DbSet WareHouseings { get; set; } + } }