From e5aabecb428325e230939e00fe0148211df914f2 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 8 Aug 2022 19:26:23 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E7=B5=84=E4=BB=B6=E6=89=B9=E6=AC=A1?= =?UTF-8?q?=E5=88=AA=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 161 ++++++++++++++---- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 37 +++- AMESCoreStudio.Web/Views/PCS/PCS022.cshtml | 132 +++++++------- AMESCoreStudio.Web/Views/PCS/PCS022V.cshtml | 53 ++++++ AMESCoreStudio.Web/Views/PCS/PCS027.cshtml | 95 +++++++---- .../AMES/BarcodeInfoesController.cs | 113 ++++++++++++ .../AMES/BarcodeItemsController.cs | 110 ++++++++---- .../AMES/BarcodeStationController.cs | 51 ++++++ .../DTO/AMES/BarcodeInfoDto.cs | 104 +++++++++++ .../DTO/AMES/BarcodeItemDto.cs | 19 ++- 10 files changed, 697 insertions(+), 178 deletions(-) create mode 100644 AMESCoreStudio.Web/Views/PCS/PCS022V.cshtml create mode 100644 AMESCoreStudio.WebApi/DTO/AMES/BarcodeInfoDto.cs diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index b9fe05f7..181b34c0 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -5646,25 +5646,24 @@ namespace AMESCoreStudio.Web.Controllers #region PCS022 條碼输入整批作業 public async Task PCS022() { - await GetItemsList(); + await GetLineInfo(); + await GetFactoryUnit(); return View(); } /// /// PCS022 Query /// - /// 工單號料 - /// 內部條碼 - /// 組件編號 - /// 內部條碼List + /// 工單號碼/param> + /// 料號 + /// 生產單位/param> + /// LineID /// 選擇查詢類型 /// - public async Task PCS022QueryAsync(string wipNo, string barCode, string KPItemNo, - string BarCodeItem, string type, int page = 0, int limit = 10) + public async Task PCS022QueryAsync(string wipNo, string productNo, string unit, string type, int lineID = 0, int page = 0, int limit = 10) { - IResultModel result = await _pcsApi.GetBarcodeItemByPCS027Query(wipNO: wipNo, - barCode: barCode, KPItemNo: KPItemNo, BarCodeItem: BarCodeItem - , page: page, limit: limit); + IResultModel result = await _pcsApi.GetBarcodeItemByPCS022Query(wipNo: wipNo, + itemNo: productNo, unit: unit, lineID, page: page, limit: limit); if (result.Data.Count() != 0) { @@ -5672,6 +5671,27 @@ namespace AMESCoreStudio.Web.Controllers } return Json(new Table() { count = 0, data = null }); } + + [HttpGet] + public IActionResult PCS022V(int wipID, int ruleStationID) + { + ViewBag.WIP_ID = wipID; + ViewBag.RULE_STATION_ID = ruleStationID; + return View(); + } + + [HttpGet] + public async Task PCS022VQuery(int page = 0, int limit = 10) + { + var result = await _pcsApi.GetWipStationBarcodeByPCS022(wipID, ruleStationID, page, limit); + + if (result.DataTotal > 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + + return Json(new Table() { count = 0, data = null }); + } #endregion #region PCS023 條碼置換 @@ -5920,33 +5940,40 @@ namespace AMESCoreStudio.Web.Controllers //通過上傳檔案流初始化Mapper using (var workbook = new XLWorkbook(Uploader.OpenReadStream())) { - var worksheet = workbook.Worksheet(1); - // 定義資料起始/結束 Cell - var firstCell = worksheet.FirstCellUsed(); - var lastCell = worksheet.LastCellUsed(); - - // 使用資料起始/結束 Cell,來定義出一個資料範圍 - var data = worksheet.Range(firstCell.Address, lastCell.Address); - var rowCount = data.RowCount(); - var columnCount = data.ColumnCount(); - for (int i = 1; i <= rowCount; i++) + try { - // 取得每一欄 - if (data.Cell(i, 1).Value.ToString() != null) + var worksheet = workbook.Worksheet(1); + // 定義資料起始/結束 Cell + var firstCell = worksheet.FirstCellUsed(); + var lastCell = worksheet.LastCellUsed(); + + // 使用資料起始/結束 Cell,來定義出一個資料範圍 + var data = worksheet.Range(firstCell.Address, lastCell.Address); + var rowCount = data.RowCount(); + var columnCount = data.ColumnCount(); + for (int i = 1; i <= rowCount; i++) { - Print.Add(data.Cell(i, 0).Value.ToString()); + // 取得每一欄 + if (data.Cell(i, 1).Value.ToString() != null) + { + Print.Add(data.Cell(i, 1).Value.ToString()); + } } } + catch (Exception ex) + { + return Json(new { data = ex.Message, success = false }); + } } //将数据Json化并传到前台视图 - return Json(new { data = string.Join(",", Print) }); + return Json(new { data = string.Join(",", Print), success = true }); } /// /// PCS027 Query /// - /// 工單號料 + /// 工單號料 /// 內部條碼 /// 組件編號 /// 內部條碼List @@ -5954,16 +5981,90 @@ namespace AMESCoreStudio.Web.Controllers /// public async Task PCS027QueryAsync(string wipNo, string barCode, string KPItemNo, string BarCodeItem, string type, int page = 0, int limit = 10) + { + try + { + // 初始執行不查詢 + if (type == null) + { + return Json(new Table() { count = 0, data = null }); + } + + if (type == "W") + { + barCode = string.Empty; + BarCodeItem = string.Empty; + } + else if (type == "B") + { + wipNo = string.Empty; + BarCodeItem = string.Empty; + } + else if (type == "BS") + { + wipNo = string.Empty; + barCode = string.Empty; + } + + IResultModel result = await _pcsApi.GetBarcodeItemByPCS027Query(wipNO: wipNo, + barCode: barCode, KPItemNo: KPItemNo, BarCodeItem: BarCodeItem + , page: page, limit: limit); + + if (result.Data.Count() != 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + + // 有執行錯誤 + if (!result.Success) + { + return Json(new Table() { code = 1, msg = "查詢錯誤:" + result.Msg, count = 0 }); + } + + return Json(new Table() { count = 0, data = null }); + } + catch (Exception ex) + { + return Json(new Table() { code = 1, msg = "查詢錯誤:" + ex.Message, count = 0 }); + } + } + + /// + /// PCS027 組件批次刪除 + /// + /// 工單號料 + /// 內部條碼 + /// 組件編號 + /// 內部條碼List + /// 選擇查詢類型 + /// + [HttpPost] + public async Task PCS027DAsync(string wipNo, string barCode, string KPItemNo, + string BarCodeItem, string type) { IResultModel result = await _pcsApi.GetBarcodeItemByPCS027Query(wipNO: wipNo, - barCode: barCode, KPItemNo: KPItemNo, BarCodeItem: BarCodeItem - , page: page, limit: limit); + barCode: barCode, KPItemNo: KPItemNo, BarCodeItem: BarCodeItem); - if (result.Data.Count() != 0) + var barcodeItemOld = result.Data; + foreach (var item in barcodeItemOld) { - return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + var barcodeItemChange = new BarcodeItemChange(); + barcodeItemChange.BarcodeItemChangeID = 0; + barcodeItemChange.BarcodeID = item.BarcodeID; + barcodeItemChange.PartNoOld = item.PartNo; + barcodeItemChange.ChangeType = "DR"; + barcodeItemChange.ItemNo = item.ItemNo; + barcodeItemChange.RuleStationID = item.RuleStationID; + barcodeItemChange.WipID = item.WipID; + barcodeItemChange.KpItemNo = item.KpItemNo; + barcodeItemChange.CreateUserID = GetLogInUserID(); + barcodeItemChange.CreateDate = System.DateTime.Now; + barcodeItemChange.UpdateDate = System.DateTime.Now; + + await _pcsApi.PostBarcodeItemChange(JsonConvert.SerializeObject(barcodeItemChange)); + await _pcsApi.DeleteBarcodeItem(item.BarcodeItemID); } - return Json(new Table() { count = 0, data = null }); + return Json(new Result() { success = true, msg = "刪除成功" }); } #endregion diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 9f682694..01628b17 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -16,7 +16,7 @@ namespace AMESCoreStudio.Web { ////////////////////////////////////// [WebApiClient.Attributes.HttpPost("api/BarCodeCheck/PassIngByCheck")] - ITask> PassIngByCheck([FromBody,RawJsonContent] string model); + ITask> PassIngByCheck([FromBody, RawJsonContent] string model); ////////////////////////////////////// #region 下拉選單 @@ -89,7 +89,7 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/WipInfos/GetWipInfoSelectParameter")] //ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null); ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null, int lineid = 0 - , string itemno = null, DateTime? date_str = null, DateTime? date_end = null , string wipType = null, int page = 0, int limit = 10); + , string itemno = null, DateTime? date_str = null, DateTime? date_end = null, string wipType = null, int page = 0, int limit = 10); /// /// 查詢工單基本資料+是否已過站 @@ -240,7 +240,7 @@ namespace AMESCoreStudio.Web ITask GetWipMAC(string id); [WebApiClient.Attributes.HttpGet("api/WipMAC/CheckMAC/{id}/{startNo}/{endNo}")] - ITask> GetCheckMAC(string id,string startNo, string endNo); + ITask> GetCheckMAC(string id, string startNo, string endNo); [WebApiClient.Attributes.HttpPost("api/WipMAC")] ITask> PostWipMAC([FromBody, RawJsonContent] string model); @@ -324,6 +324,20 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/BarcodeInfoes/ByExtraNo/{extraNo}")] ITask> GetBarcodeInfoesByExtraNo(string extraNo); + + /// + /// 條碼批次作業查詢Query + /// + /// 工單號碼 + /// 料號 + /// 生產單位 + /// 線別 + /// 頁數 + /// 筆數 + /// + [WebApiClient.Attributes.HttpGet("api/BarcodeInfoes/BarcodeInfoByPCS022")] + ITask> GetBarcodeItemByPCS022Query(string wipNo = null, string itemNo = null, + string unit = null, int lineID = 0, int page = 0, int limit = 10); #endregion #region BarCodeStation 條碼過站資料檔 PCS021 @@ -339,6 +353,13 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpPut("api/BarcodeStation")] ITask> PutBarcodeStation([FromBody, RawJsonContent] string model); + /// + /// 條碼批次查詢 + /// + /// + [WebApiClient.Attributes.HttpGet("api/BarcodeStation/GetWipStationBarcodeByPCS022")] + ITask> GetWipStationBarcodeByPCS022(int wipID, int ruleStationID, int page, int limit); + #endregion #region BarcodeItem BarCode組件維護 PCS021 PCS009 @@ -757,7 +778,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/MaterialFlows/ByWip/{itemno}/{unitNo}")] - ITask> GetMaterialFlowsByQuery(string itemno , string unitno); + ITask> GetMaterialFlowsByQuery(string itemno, string unitno); /// /// SOP文件變更狀態 @@ -946,7 +967,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/WipStation/GetWipStation4QRS009")] - ITask> GetWipStation4QRS009(int wipID,int ruleStationID); + ITask> GetWipStation4QRS009(int wipID, int ruleStationID); /// /// 查詢工單站别资料 @@ -1112,7 +1133,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpDelete("api/WipSop/{id}")] - ITask>DeleteWipSop(int id); + ITask> DeleteWipSop(int id); #endregion #region RuleStation 流程站別資料維護 @@ -1122,7 +1143,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/RuleStations/WipNo/{id}")] - ITask> GetRuleStationByWipNo(string id , int flowRuleIDNew =0 , int flowRuleIDOld =0); + ITask> GetRuleStationByWipNo(string id, int flowRuleIDNew = 0, int flowRuleIDOld = 0); /// /// 流程查詢 FlowDTO @@ -1213,7 +1234,7 @@ namespace AMESCoreStudio.Web #region 取出貨序號 [WebApiClient.Attributes.HttpGet("api/SerialRules/ByQurey/{itemNo}/{lotNo}/{num}")] - ITask> GetSerialRuleByQurey(string itemNo,string lotNo ,int num); + ITask> GetSerialRuleByQurey(string itemNo, string lotNo, int num); #endregion #region 樣品出貨序號紀錄 diff --git a/AMESCoreStudio.Web/Views/PCS/PCS022.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS022.cshtml index c621a360..9333c527 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS022.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS022.cshtml @@ -14,59 +14,57 @@
@ViewBag.Title
-
+
-
- -
-
- -
-
- -
-
- -
-
- -
-
- +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
-
+
- +
-
- +
+
- +
-
+
-
-
@@ -77,15 +75,15 @@
*@ - +
- -
-@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); - await Html.RenderPartialAsync("_FileinputScriptsPartial"); } +
+
+ @section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } - -} + var table = hg.table.datatable('query', '條碼输入整批查詢', '/PCS/PCS022Query', {}, tableCols, {}, true, 'full-100', ['filter', 'print', 'exports']); + + } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS022V.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS022V.cshtml new file mode 100644 index 00000000..fef37009 --- /dev/null +++ b/AMESCoreStudio.Web/Views/PCS/PCS022V.cshtml @@ -0,0 +1,53 @@ +@{ + ViewData["Title"] = "在製分布圖-過站PASS條碼資料"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+ + +
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/PCS/PCS027.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS027.cshtml index 75a31165..09383682 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS027.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS027.cshtml @@ -14,13 +14,12 @@
@ViewBag.Title
-
-
+
-
+
-
+
@@ -28,30 +27,30 @@
-
+
-
+
-
+
-
+
-
+
@@ -62,46 +61,46 @@
-
+
-
+
-
+
-
-
@*
-
- -
-
*@ - +
+ +
+
*@ +
- +
@section Scripts { @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); await Html.RenderPartialAsync("_FileinputScriptsPartial"); } - + } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs index 49008a11..6e0b932c 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs @@ -215,6 +215,119 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return barcodeInfo; } + /// + /// 條碼批次查詢 + /// + /// 工單號碼 + /// 料號 + /// 生產單位 + /// 線別 + /// 頁數 + /// 筆數 + /// + [HttpGet("BarcodeInfoByPCS022")] + public async Task> GetBarcodeInfoByPCS022(string wipNo, string itemNo, + string unit, int lineID, int page = 0, int limit = 10) + { + ResultModel result = new ResultModel(); + try + { + var barcodeInfos = new List(); + // 查詢工單號碼 + if (!string.IsNullOrWhiteSpace(wipNo)) + { + var wipID = _context.WipInfos.Where(w => w.WipNO == wipNo.Trim().ToUpper()).Select(s => s.WipID).ToList(); + barcodeInfos = await _context.BarcodeInfoes.Where(w => wipID.Contains(w.WipID)).ToListAsync(); + } + // 查詢料號 + else if (!string.IsNullOrWhiteSpace(itemNo)) + { + var wipAtt = _context.WipAtts.Where(w => w.ItemNO == itemNo.Trim().ToUpper()).Select(s => s.WipNO).ToList(); + var wipID = await _context.WipInfos.Where(w => wipAtt.Contains(w.WipNO) && w.StatusNO != "E").Select(s => s.WipID).ToListAsync(); + barcodeInfos = await _context.BarcodeInfoes.Where(w => wipID.Contains(w.WipID)).ToListAsync(); + } + + var q = from q1 in barcodeInfos + join q2 in _context.RuleStations on q1.RuleStationID equals q2.RuleStationID + join q3 in _context.WipInfos on q1.WipID equals q3.WipID + join q4 in _context.LineInfoes on q3.LineID equals q4.LineID + join q5 in _context.FactoryUnits on q3.UnitNO equals q5.UnitNo + select new BarcodeInfoDto + { + WipID = q1.WipID, + WipNo = q3.WipNO, + WipQty = q3.PlanQTY, + RuleStationID = q1.RuleStationID, + StationName = q2.StationDesc, + InputQty = 0, + LineName = q4.LineDesc, + LineID = q4.LineID, + Unit = q5.UnitNo, + UnitName = q5.UnitName + }; + + // 查詢生產單位 + if (!string.IsNullOrWhiteSpace(unit)) + { + q = q.Where(w => w.Unit == unit).ToList(); + } + + // 查詢生產單位 + if (lineID != 0) + { + q = q.Where(w => w.LineID == lineID).ToList(); + } + + // Group + + q = q.GroupBy(g => new + { + g.WipID, + g.WipNo, + g.WipQty, + g.LineID, + g.LineName, + g.StationName, + g.RuleStationID, + g.Unit, + g.UnitName + }) + .Select(s => new BarcodeInfoDto + { + WipNo = s.Key.WipNo, + WipQty = s.Key.WipQty, + WipID = s.Key.WipID, + StationName = s.Key.StationName, + RuleStationID = s.Key.RuleStationID, + LineID = s.Key.LineID, + LineName = s.Key.LineName, + Unit = s.Key.Unit, + UnitName = s.Key.UnitName, + InputQty = s.Count(), + ItemNo = _context.WipAtts.Where(w => w.WipNO == s.Key.WipNo).FirstOrDefault().ItemNO + }).ToList(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + + result.Data = q.ToList(); + result.Success = true; + return result; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.Message; + return result; + } + } + /// /// 更新條碼资料 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs index 1974f031..fa0d110e 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs @@ -285,43 +285,85 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> GetBarcodeItemByPCS027(string wipNO, string barCode, string KPItemNo, string BarCodeItem, int page = 0, int limit = 10) { - - var q = from q1 in _context.BarcodeItems.Where(w => w.WipID == 1002) - join q2 in _context.Items on q1.ItemNo equals q2.ItemNo - join q3 in _context.RuleStations on q1.RuleStationID equals q3.RuleStationID - join q4 in _context.UserInfoes on q1.CreateUserID equals q4.UserID - join q5 in _context.WipInfos on q1.WipID equals q5.WipID - join q6 in _context.BarcodeInfoes on q1.BarcodeID equals q6.BarcodeID - select new BarcodeItemDTO - { - BarcodeID = q1.BarcodeID, - Barcode = q6.BarcodeNo, - WipID = q1.WipID, - PartNo = q1.PartNo, - KpItemNo = q1.KpItemNo, - ItemNoName = q2.ItemName, - StationName = q3.StationDesc, - RuleStationID = q1.RuleStationID, - CreateUser = q4.UserName, - CreateDate = q1.CreateDate, - SysType = q1.SysType, - WipNo = q5.WipNO - }; - ResultModel result = new ResultModel(); - - // 紀錄筆數 - result.DataTotal = q.Count(); - - // Table 頁數 - if (page > 0) + try { - q = q.Skip((page - 1) * limit).Take(limit); + var barcodeItems = new List(); + // 查詢工單號碼 + if (!string.IsNullOrWhiteSpace(wipNO)) + { + var wipID = _context.WipInfos.Where(w => w.WipNO == wipNO.Trim().ToUpper()).Select(s => s.WipID).ToList(); + barcodeItems = await _context.BarcodeItems.Where(w => wipID.Contains(w.WipID)).ToListAsync(); + } + // 查詢內部序號 + else if (!string.IsNullOrWhiteSpace(barCode)) + { + int barcodeID = 0; + var barcodes = _context.BarcodeInfoes.Where(w => w.BarcodeNo == barCode.Trim().ToUpper()).FirstOrDefault(); + if (barcodes != null) + barcodeID = barcodes.BarcodeID; + + barcodeItems = await _context.BarcodeItems.Where(w => barcodeID == w.BarcodeID).ToListAsync(); + } + // 查詢多筆序號 + else if (!string.IsNullOrWhiteSpace(BarCodeItem)) + { + var barcodeList = BarCodeItem.Split(',').ToList(); + var barcodeIDs = _context.BarcodeInfoes.Where(w => barcodeList.Contains(w.BarcodeNo)).Select(s => s.BarcodeID).ToList(); + barcodeItems = await _context.BarcodeItems.Where(w => barcodeIDs.Contains(w.BarcodeID)).ToListAsync(); + } + + var q = from q1 in barcodeItems + join q2 in _context.Items on q1.ItemNo equals q2.ItemNo + join q3 in _context.RuleStations on q1.RuleStationID equals q3.RuleStationID + join q4 in _context.UserInfoes on q1.CreateUserID equals q4.UserID + join q5 in _context.WipInfos on q1.WipID equals q5.WipID + join q6 in _context.BarcodeInfoes on q1.BarcodeID equals q6.BarcodeID + select new BarcodeItemDTO + { + BarcodeItemID = q1.BarcodeItemID, + BarcodeID = q1.BarcodeID, + Barcode = q6.BarcodeNo, + WipID = q1.WipID, + PartNo = q1.PartNo, + ItemNo = q1.ItemNo, + ItemNoName = q2.ItemName, + KpItemNo = q1.KpItemNo, + StationName = q3.StationDesc, + RuleStationID = q1.RuleStationID, + CreateUser = q4.UserName, + CreateDate = q1.CreateDate, + SysType = q1.SysType, + WipNo = q5.WipNO + }; + + // 查詢組件代碼 + if (!string.IsNullOrWhiteSpace(KPItemNo)) + { + q = q.Where(w => w.KpItemNo == KPItemNo).ToList(); + } + + + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + + result.Data = q.ToList(); + result.Success = true; + return result; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.Message; + return result; } - - result.Data = await q.ToListAsync(); - - return result; } /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs index 051383d6..7ac21dc7 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs @@ -150,6 +150,57 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + /// + /// 查詢工單站別條碼資料 By 條碼批次查詢 + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetWipStationBarcodeByPCS022(int wipID, int ruleStationID, int page = 0, int limit = 10) + { + ResultModel result = new ResultModel(); + var q = from q1 in _context.BarcodeStation + join q2 in _context.BarcodeInfoes on q1.BarcodeID equals q2.BarcodeID + join q3 in _context.LineInfoes on q1.LineId equals q3.LineID + join q4 in _context.UserInfoes on q1.CreateUserID equals q4.UserID + select new + { + q1.BarcodeID, + q1.WipID, + q1.RuleStationID, + q2.BarcodeNo, + q3.LineDesc, + q1.RuleStatus, + q1.Systype, + q1.InputDate, + q4.UserName + }; + + q = q.Where(w => w.WipID == wipID && w.RuleStationID == ruleStationID); + + + //紀錄筆數 + result.DataTotal = q.Count(); + + //Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + + result.Data = await q.ToListAsync(); + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } /// /// 查詢 已過站數量 diff --git a/AMESCoreStudio.WebApi/DTO/AMES/BarcodeInfoDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/BarcodeInfoDto.cs new file mode 100644 index 00000000..eb20f7d2 --- /dev/null +++ b/AMESCoreStudio.WebApi/DTO/AMES/BarcodeInfoDto.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 條碼資料 DTO + /// + + public class BarcodeInfoDto + { + + /// + /// 内部條碼ID + /// + public int BarcodeID { get; set; } + + + /// + /// 内部條碼 + /// + public string Barcode { get; set; } + + /// + /// 工單ID + /// + public int WipID { get; set; } + + /// + /// 工單號碼 + /// + public string WipNo { get; set; } + + /// + /// 料號 + /// + + public string ItemNo { get; set; } + + /// + /// 工單數量 + /// + + public int WipQty { get; set; } + + /// + /// 流程站 + /// + public string StationName { get; set; } + + /// + /// 流程站ID + /// + public int RuleStationID { get; set; } + + /// + /// 生產單位 + /// + public string Unit { get; set; } + + /// + /// 生產單位名稱 + /// + public string UnitName { get; set; } + + /// + /// 線別ID + /// + + public int LineID { get; set; } + + /// + /// 線別名稱 + /// + + public string LineName { get; set; } + + /// + /// 數量 + /// + public int InputQty { get; set; } + + /// + /// 建立者Name + /// + + public string CreateUser { get; set; } + + /// + /// 建立時間 + /// + + public DateTime CreateDate { get; set; } + + /// + /// 修改時間 + /// + public DateTime UpdateDate { get; set; } + + } +} diff --git a/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemDto.cs index 7bf69c7e..beee95e3 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemDto.cs @@ -12,7 +12,11 @@ namespace AMESCoreStudio.WebApi.Models.AMES public class BarcodeItemDTO { - + /// + /// 條碼組件ID + /// + public int BarcodeItemID { get; set; } + /// /// 内部條碼ID /// @@ -44,6 +48,13 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// public int RuleStationID { get; set; } + + /// + /// 组件代碼 + /// + + public string ItemNo { get; set; } + /// /// 组件代碼Name /// @@ -70,18 +81,18 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 建立者Name /// - public string CreateUser { get; set; } + public string CreateUser { get; set; } /// /// 建立時間 /// - public DateTime CreateDate { get; set; } + public DateTime CreateDate { get; set; } /// /// 修改時間 /// - public DateTime UpdateDate { get; set; } + public DateTime UpdateDate { get; set; } } }