From 2b1882219f6aac544c96fe0381679d3468400409 Mon Sep 17 00:00:00 2001 From: Yiru Date: Wed, 12 Jul 2023 09:13:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=A9=A2=E5=AE=89?= =?UTF-8?q?=E5=8B=A4=E5=AE=8C=E5=B7=A5=E5=85=A5=E5=BA=AB=E8=B3=87=E6=96=99?= =?UTF-8?q?(for=20EV=20=E6=A9=9F=E7=A8=AE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AMES/FqcInhouseMasterController.cs | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs index 0789d32..56e1574 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs @@ -622,6 +622,115 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + + /// + /// FQC查詢 by 安勤 + /// + /// 內部序號 + /// 工單號碼 + /// 外箱號碼 + /// 入庫單號碼 + /// 入庫時間起 + /// 入庫時間迄 + /// 是否已入庫Y/N/ALL + /// 頁數 + /// 筆數 + /// + [HttpGet("FqcInhouseMasterMultiQuery_Avalue")] + public async Task> GetFqcInhouseMasteMultiQuery_Avalue(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.Where(w => w.ItemNo.StartsWith("EV")) + join q2 in _context.FqcInhouseDetails on new { q1.InhouseNo, q1.SeqID } equals new { q2.InhouseNo, q2.SeqID } + join q2_1 in _context.WipBoxs on q2.SerialNo equals q2_1.BoxNo + 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, + RecordDate = q402.Create_Date, + LocationNo = q1.LocationNo, + BoxQty = q2_1.BoxCnt.ToString() + }; + //q1.Status == "P" ? "允收" : q1.Status == "R" ? "批退" : "未驗收完成", + //IQueryable q1 = _context.FqcInhouseDetails; + if (!string.IsNullOrWhiteSpace(inhouseNo)) + q = q.Where(w => w.RecordNumber == inhouseNo); + + if (!string.IsNullOrWhiteSpace(wipNo)) + q = q.Where(w => w.WipNo == wipNo); + + if (!string.IsNullOrWhiteSpace(status) || status != "ALL") + // q = q.Where(w => w.StatusName == status); + { + if (status == "N") + q = q.Where(w => w.RecordNumber == null); + else if (status == "Y") + q = q.Where(w => w.RecordNumber != null); + } + + + // 優先用內部序號取出包裝序號 + 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.RecordDate >= DateTime.Parse(date_str)); + } + + if (DateTime.TryParse(date_end, out _)) + { + q = q.Where(w => w.RecordDate <= DateTime.Parse(date_end)); + } + q = q.Where(w => w.StatusName == "P"); + 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)