From fd3ea06884538f21906034aac31d27bf1867f06c Mon Sep 17 00:00:00 2001 From: "BB.Wang" Date: Thu, 29 Sep 2022 15:31:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=AD=E5=A4=AE=E6=B2=BB?= =?UTF-8?q?=E6=93=9A=E5=BA=AB=E3=80=81=E5=B7=A5=E6=99=82=E8=B3=87=E6=96=99?= =?UTF-8?q?=E7=AD=89=E8=B3=87=E8=A8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/JIGController.cs | 291 +++++++++++------- .../Controllers/PCSController.cs | 15 +- .../Controllers/WHSController.cs | 15 +- AMESCoreStudio.Web/HttpApis/AMES/IJIG.cs | 41 +++ AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs | 3 +- AMESCoreStudio.Web/Views/JIG/JIG002.cshtml | 3 + AMESCoreStudio.Web/Views/JIG/JIG002C.cshtml | 10 + AMESCoreStudio.Web/Views/JIG/JIG003.cshtml | 3 +- AMESCoreStudio.Web/Views/JIG/JIG004.cshtml | 8 + AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml | 12 +- AMESCoreStudio.Web/Views/JIG/JIG004U.cshtml | 14 +- AMESCoreStudio.Web/Views/WHS/WHS003.cshtml | 11 +- AMESCoreStudio.Web/Views/WHS/WHS011C.cshtml | 29 +- AMESCoreStudio.Web/Views/WHS/WHS018.cshtml | 2 +- AMESCoreStudio.Web/Views/WHS/WHS019.cshtml | 8 +- AMESCoreStudio.Web/Views/WHS/WHS019C.cshtml | 43 ++- .../AMES/OutfitInfoBlobController.cs | 154 +++++++++ .../Controllers/AMES/WipBoxController.cs | 86 ++++++ .../Controllers/AMES/WorkGroupsController.cs | 1 + .../Models/AMES/OutfitInfo.cs | 6 +- .../Models/AMES/OutfitInfoBlob.cs | 92 ++++++ 21 files changed, 667 insertions(+), 180 deletions(-) create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/OutfitInfoBlobController.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/OutfitInfoBlob.cs diff --git a/AMESCoreStudio.Web/Controllers/JIGController.cs b/AMESCoreStudio.Web/Controllers/JIGController.cs index 4ccf5057..ad347fa0 100644 --- a/AMESCoreStudio.Web/Controllers/JIGController.cs +++ b/AMESCoreStudio.Web/Controllers/JIGController.cs @@ -165,19 +165,21 @@ namespace AMESCoreStudio.Web.Controllers } ViewBag.UserID = user_id; } - - private async Task GetOutfitFactoryInfosList() //YIRU + + //yiru 2022-09-19 + private async Task GetOutfitFactoryInfosList() { var result = await _jigApi.GetOutfitFactoryInfos(); var GroupList = new List(); for (int i = 0; i < result.Count; i++) { - GroupList.Add(new SelectListItem(result[i].OutfitFactoryName, result[i].OutfitFactoryID.ToString())); + GroupList.Add(new SelectListItem(result[i].OutfitFactoryName, result[i].OutfitFactoryNo.ToString())); } ViewBag.OutfitFactoryList = GroupList; } + //yiru add end #endregion #region JIG001 設備種類維護相關 @@ -337,6 +339,20 @@ namespace AMESCoreStudio.Web.Controllers var result = await _jigApi.DeleteOutfitVarityInfo(id); return Json(new Result() { success = true, msg = "" }); } + public async Task GetOutfitInfoBlobByOutfitIDAsync(int id) + { + if (id == 0) + return Json(new Table() { count = 0, data = null }); + + var result = await _jigApi.GetOutfitInfoBlobByOutfitID(id); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } [HttpPost] public async Task JIG002CSaveAsync(OutfitVarityInfo model) @@ -408,85 +424,6 @@ namespace AMESCoreStudio.Web.Controllers } - //YIRU ADD - //public async Task JIG002RSaveAsync(InspectionResultBlob model, IFormFile formFile) - //{ - // IResultModel result; - // var userID = ""; - // HttpContext.Request.Cookies.TryGetValue("UserID", out userID); - // int user_id = 0; - // if (userID != null) - // { - // if (int.Parse(userID.ToString()) >= 0) - // { - // user_id = int.Parse(userID.ToString()); - // } - // } - // model.CreateUserID = user_id; - // model.CreateDate = System.DateTime.Now; - // model.UpdateUserID = user_id; - // model.UpdateDate = System.DateTime.Now; - // string FileName = string.Empty; - // string NewName = string.Empty; - // string FilePath = string.Empty; - - - // if (formFile != null) - // { - // if (formFile.Length > 0) - // { - // //取得使用者上傳檔案的原始檔名 - // FileName = Path.GetFileName(formFile.FileName); - // //取原始檔名中的副檔名 - // var fileExt = Path.GetExtension(FileName); - // //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱 - // NewName = Path.GetRandomFileName() + fileExt; - // //指定要寫入的路徑、檔名和副檔名 - // FilePath = $"\\PCSFile\\";//本機目錄 - // using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create)) - // { - // await formFile.CopyToAsync(stream); - // } - - // //var fileProvider = _fileServerProvider.GetProvider("/aa"); - // //var fileInfo = fileProvider.GetFileInfo(formFile.FileName); - // //fileInfo = fileProvider.GetFileInfo(formFile.FileName); - // ////遠端目錄 - // //using (var stream = new FileStream(fileInfo.PhysicalPath, FileMode.Create)) - // //{ - // // await formFile.CopyToAsync(stream); - - // model.ImageName = FileName; - // model.NewName = NewName; - // model.FilePath = FilePath;// fileInfo.PhysicalPath; - - // result = await _spcApi.PostInspectionResultBlob(JsonConvert.SerializeObject(model)); - // if (result.Success) - // { - // //var _msg = "上傳成功!"; - // ViewBag.ItemID = model.InspectionItemID; - // ViewBag.MasterID = model.InspectionID; - // return View("SPC005R"); - // } - // else - // { - // ModelState.AddModelError("error", result.Msg); - // } - // } - // } - // else - // { - // ModelState.AddModelError("error", "請選擇要上傳檔案"); - // } - - - // ViewBag.ItemID = model.InspectionItemID; - // ViewBag.MasterID = model.InspectionID; - - // return View("SPC005R"); - //} - - //YIRU ADD [ResponseCache(Duration = 0)] [HttpGet] public async Task GetOutfitVarityInfoesAsync() @@ -611,7 +548,7 @@ namespace AMESCoreStudio.Web.Controllers #endregion - #region JIG004巡檢結果維護相關 + #region JIG004巡檢結果維護相關 YIRU Modify 2022-09-23 public async Task JIG004() { @@ -623,7 +560,7 @@ namespace AMESCoreStudio.Web.Controllers public async Task JIG004C(int id) { GetUserID(); - await GetFactoryList(); + // await GetFactoryList(); await GetOutfitCommodityInfoesList(); await GetOutfitVarityInfoesList(); await GetOutfitVendorInfoesList(); @@ -634,10 +571,11 @@ namespace AMESCoreStudio.Web.Controllers { GetUserID(); - await GetFactoryList(); + // await GetFactoryList(); await GetOutfitCommodityInfoesList(); await GetOutfitVarityInfoesList(); await GetOutfitVendorInfoesList(); + await GetOutfitFactoryInfosList(); var result = await _jigApi.GetOutfitInfo(id); if (result.Count == 0) @@ -657,7 +595,7 @@ namespace AMESCoreStudio.Web.Controllers { var msg = ""; GetUserID(); - await GetFactoryList(); + // await GetFactoryList(); await GetOutfitCommodityInfoesList(); await GetOutfitVarityInfoesList(); await GetOutfitVendorInfoesList(); @@ -666,51 +604,72 @@ namespace AMESCoreStudio.Web.Controllers { IResultModel result; - + var commodity = await _jigApi.GetOutfitCommodityInfo(model.CommodityID); model.TypeFlag = commodity[0].TypeFlag; - //yiru add 自動產生治具編碼 (取最大號 往後累加產生) - var commodityno = commodity[0].CommodityNo.PadLeft(3,'0'); //類別代號(3碼) + //yiru 2022-09-19 add 自動產生治具編碼 (取最大號 往後累加產生) ==== BEGIN + var commodityno = commodity[0].CommodityNo.PadLeft(3, '0'); //類別代號(3碼) var varity = await _jigApi.GetOutfitVarityInfo(model.VarietyID); - var varityno = varity[0].VarityNo.PadLeft(4,'0'); //種類代號(4碼) + var varityno = varity[0].VarityNo.PadLeft(4, '0'); //種類代號(4碼) var outfitinfo = await _jigApi.GetOutfitInfoes(); - var outfitinfo_Max = outfitinfo.Where(w => w.OutfitNo.Contains(model.FactoryCode + commodityno + varityno)).OrderBy(o => o.OutfitNo).Select(s => s.OutfitNo).LastOrDefault(); - var outfitinfo_num = 0; - if (outfitinfo_Max!= null) - { - outfitinfo_num = int.Parse(outfitinfo_Max.Substring(outfitinfo_Max.Length -4,4)); - } - - for (int i = 0; i < model.StockQty; i++) + if (varityno.Length > 4) { - model.OutfitNo = model.FactoryCode + commodityno + varityno + (outfitinfo_num + i +1).ToString().PadLeft(4,'0'); - model.QANo = model.OutfitNo; - result = await _jigApi.PostOutfitInfo(JsonConvert.SerializeObject(model)); + msg = "種類代碼超出4碼 無法產生設備編碼"; } - result = await _jigApi.PostOutfitInfo(JsonConvert.SerializeObject(model)); - //yiru add ==== - - if (result.Success) + else if (commodityno.Length > 4) { - var _msg = "添加成功!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); + msg = "類別代號超出3碼 無法產生設備編碼"; } else { - msg = result.Msg; + var outfitinfo_Max = outfitinfo.Where(w => w.OutfitNo.Contains(model.OutfitFactoryNo + commodityno + varityno)).OrderBy(o => o.OutfitNo).Select(s => s.OutfitNo).LastOrDefault(); + var outfitinfo_num = 0; + if (outfitinfo_Max != null) + { + outfitinfo_num = int.Parse(outfitinfo_Max.Substring(outfitinfo_Max.Length - 4, 4)); + } + + List msglist = new List(); + for (int i = 0; i < model.StockQty; i++) + { + model.OutfitNo = model.OutfitFactoryNo + commodityno + varityno + (outfitinfo_num + i + 1).ToString().PadLeft(4, '0'); + model.QANo = model.OutfitNo; + result = await _jigApi.PostOutfitInfo(JsonConvert.SerializeObject(model)); + if (result.Success) + { + msglist.Add(model.OutfitNo + " 添加成功!"); + } + else + { + msglist.Add(model.OutfitNo + " error: " + result.Msg); + + } + } + + //yiru 2022-09-19 add ==== END + if (msglist.Where(w => w.Contains("error")) == null) + { + var _msg = "添加成功!共" + msglist.Count + "筆設備編號"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + ModelState.AddModelError("error", string.Join(",", msglist)); + return View("JIG004C", model); + } } } if (msg == "") msg = "缺少必填資料"; - ModelState.AddModelError("error", msg); + ModelState.AddModelError("error", msg ); return View("JIG004C", model); } public async Task JIG004USaveAsync(OutfitInfo model) { var msg = ""; GetUserID(); - await GetFactoryList(); + // await GetFactoryList(); await GetOutfitCommodityInfoesList(); await GetOutfitVarityInfoesList(); await GetOutfitVendorInfoesList(); @@ -737,6 +696,108 @@ namespace AMESCoreStudio.Web.Controllers return View("JIG004U", model); } + // YIRU ADD + public async Task JIG004RDAsync(int id) + { + var result = await _jigApi.DeleteOutfitInfoBlob(id); + return Json(new Result() { success = true, msg = "" }); + } + + public async Task JIG004RSaveAsync(OutfitInfoBlob model, IFormFile formFile) + { + IResultModel result; + var userID = ""; + HttpContext.Request.Cookies.TryGetValue("UserID", out userID); + int user_id = 0; + if (userID != null) + { + if (int.Parse(userID.ToString()) >= 0) + { + user_id = int.Parse(userID.ToString()); + } + } + model.CreateUserID = user_id; + model.CreateDate = System.DateTime.Now; + model.UpdateUserID = user_id; + model.UpdateDate = System.DateTime.Now; + string FileName = string.Empty; + string NewName = string.Empty; + string FilePath = string.Empty; + + + if (formFile != null) + { + if (formFile.Length > 0) + { + //取得使用者上傳檔案的原始檔名 + FileName = Path.GetFileName(formFile.FileName); + //為避免使用者上傳的檔案名稱發生重複,重新給一個名稱 設備代號-原檔名 + NewName = model.OutfitID + "-" + FileName ;//Path.GetRandomFileName() + fileExt; + //指定要寫入的路徑、檔名和副檔名 + FilePath = $"\\JIGFile\\";//本機目錄 + using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create)) + { + await formFile.CopyToAsync(stream); + } + + //var fileProvider = _fileServerProvider.GetProvider("/aa"); + //var fileInfo = fileProvider.GetFileInfo(formFile.FileName); + //fileInfo = fileProvider.GetFileInfo(formFile.FileName); + ////遠端目錄 + //using (var stream = new FileStream(fileInfo.PhysicalPath, FileMode.Create)) + //{ + // await formFile.CopyToAsync(stream); + model.NewName = NewName; + model.ImageName = FileName; + model.FilePath = FilePath;// fileInfo.PhysicalPath; + + var result1 = await _jigApi.GetOutfitInfoBlobByOutfitID(model.OutfitID); + + if (result1.Count > 0) + { + result = await _jigApi.PutOutfitInfoBlob(model.OutfitID, JsonConvert.SerializeObject(model)); + string ExitingFile = Path.Combine(_env.WebRootPath + FilePath, result1.Select(s => s.NewName).FirstOrDefault()); + System.IO.File.Delete(ExitingFile); + } + else + result = await _jigApi.PostOutfitInfoBlob(JsonConvert.SerializeObject(model)); + + if (result.Success) + { + //var _msg = "上傳成功!"; + ViewBag.OutfitID = model.OutfitID; + + return View("JIG004R"); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + else + { + ModelState.AddModelError("error", "請選擇要上傳檔案"); + } + + + ViewBag.OutfitID = model.OutfitID; + + + return View("JIG004R"); + } + + public async Task JIG004RAsync(int id) + { + await GetOutfitCommodityInfoesList(); + ViewBag.OutfitID = id; + // GetUserID(); + return View(); + } + // YIRU ADD + + + [ResponseCache(Duration = 0)] [HttpGet] public async Task GetOutfitInfoesAsync() @@ -878,7 +939,7 @@ namespace AMESCoreStudio.Web.Controllers if (result.Success) { - //yiru add 更新outift_into sche + //yiru 2022-09-19 add 更新outift_into sche_return_day BEGIN OutfitInfo[0].ScheReturnDay = model.StatusDate; result = await _jigApi.PutOutfitInfo(model.OutfitID, JsonConvert.SerializeObject(OutfitInfo[0])); if (result.Success) @@ -891,7 +952,7 @@ namespace AMESCoreStudio.Web.Controllers { msg = result.Msg; } - //yiru add + //yiru 2022-09-19 END } else { @@ -1053,7 +1114,7 @@ namespace AMESCoreStudio.Web.Controllers #endregion - #region JIG010設備未歸還查詢相關 yiru + #region JIG010設備未歸還查詢相關 yiru 2022-09-19 public IActionResult JIG010() { return View(); @@ -1099,7 +1160,7 @@ namespace AMESCoreStudio.Web.Controllers #endregion - #region JIG014 設備基本數據查詢 yiru + #region JIG014 設備基本數據查詢 yiru 2022-09-19 public async Task JIG014() { @@ -1109,7 +1170,7 @@ namespace AMESCoreStudio.Web.Controllers #endregion - #region JIG015設備廠區維護相關 + #region JIG015設備廠區維護相關 yiru 2022-09-19 public IActionResult JIG015() { return View(); diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 1cab35d8..a898f2c6 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -6666,9 +6666,9 @@ namespace AMESCoreStudio.Web.Controllers 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(); + var LastStationID = FlowRule_result.Where(w => w.StationID != 1000).OrderBy(o => o.Sequence).Select(s => s.StationID).Last(); - if (item.StationID != LastRuleStationID || item.RuleStatus != "P" || item.StatusID != -1) + if (item.StationID != LastStationID || item.RuleStatus != "P" || item.StatusID != -1) { _msg += "序號【" + item.BarcodeNo + "】,流程尚未完成,不可入庫!
"; } @@ -6690,8 +6690,10 @@ namespace AMESCoreStudio.Web.Controllers 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 FlowRuleID = FlowRules_result.Select(s => s.FlowRuleID).First(); + var ruleStations_result = await GetRuleStationByFlowRuleID(FlowRuleID); + var StationID = ruleStations_result.Select(s => s.StationID).First(); + var Wipinfo_result = await _pcsApi.GetWipInfo(result.Select(s => s.WipID).First()); var Wipinfo_LineID = Wipinfo_result.Select(s => s.LineID).First(); //lineid @@ -6709,7 +6711,7 @@ namespace AMESCoreStudio.Web.Controllers BarcodeID = item.BarcodeID, BarcodeNo = item.BarcodeNo, StatusNo = item.StatusNo, - StationID = RuleStationID, + StationID = StationID, RuleStatus = "P",//F 不良 BoxNo = item.BoxNo, WipID = item.WipID, @@ -6727,7 +6729,8 @@ namespace AMESCoreStudio.Web.Controllers { BarcodeID = item.BarcodeID, WipID = item.WipID, - StationID = RuleStationID, + StationID = StationID, + FlowRuleID = FlowRuleID, RuleStatus = "P", InputDate = DateTime.Now, LineId = (int)Wipinfo_LineID, diff --git a/AMESCoreStudio.Web/Controllers/WHSController.cs b/AMESCoreStudio.Web/Controllers/WHSController.cs index 47252255..529ab74f 100644 --- a/AMESCoreStudio.Web/Controllers/WHSController.cs +++ b/AMESCoreStudio.Web/Controllers/WHSController.cs @@ -289,7 +289,7 @@ namespace AMESCoreStudio.Web.Controllers result = await _whsApi.PostWorkGroups(JsonConvert.SerializeObject(model)); - if (!result.Success) + if (result.Success) //yiru modify 2022-09-27 { var _msg = "添加成功!"; return RedirectToAction("Refresh", "Home", new { msg = _msg }); @@ -311,13 +311,13 @@ namespace AMESCoreStudio.Web.Controllers public async Task WHS001USaveAsync(WorkGroup model) { - if (ModelState.IsValid) + if (ModelState.IsValid) { IResultModel result; result = await _whsApi.PutWorkGroups(model.GroupID, JsonConvert.SerializeObject(model)); - if (!result.Success) + if (result.Success) //yiru modify 2022 - 09 - 27 { var _msg = "修改成功!"; return RedirectToAction("Refresh", "Home", new { msg = _msg }); @@ -391,14 +391,14 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task WHS002CSaveAsync(WorkClass model) { - if (ModelState.IsValid) + if (ModelState.IsValid) //yiru modify 2022-09-27 { IResultModel result; result = await _whsApi.PostWorkClass(JsonConvert.SerializeObject(model)); - if (!result.Success) + if (result.Success) //yiru modify 2022-09-27 { var _msg = "添加成功!"; return RedirectToAction("Refresh", "Home", new { msg = _msg }); @@ -426,7 +426,7 @@ namespace AMESCoreStudio.Web.Controllers result = await _whsApi.PutWorkClass(model.ClassID, JsonConvert.SerializeObject(model)); - if (!result.Success) + if (result.Success) //yiru modify 2022-09-27 { var _msg = "修改成功!"; return RedirectToAction("Refresh", "Home", new { msg = _msg }); @@ -502,7 +502,7 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task WHS003CSaveAsync(StandardWorkTime model) { - if (ModelState.IsValid) + if (ModelState.IsValid) //yiru modify 2022-09-27 { IResultModel result; @@ -2267,6 +2267,7 @@ namespace AMESCoreStudio.Web.Controllers return View("WHS019E", model); } + [ResponseCache(Duration = 0)] [HttpGet] public async Task GetWorkingHoursCollectionByQuery4WHS019Async(string unitNo, string lineid, string stationid, string wipno, string itemno, string user, string sdate, string edate) diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IJIG.cs b/AMESCoreStudio.Web/HttpApis/AMES/IJIG.cs index fe7c6a43..8ce49c94 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IJIG.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IJIG.cs @@ -189,6 +189,47 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/OutfitInfoes/Query/{TypeFlag}/{CommodityID}/{VarityID}/{Status}/{QANo}/{PartNo}/{UseStatus}")] ITask> GetOutfitInfoesByQuery(int TypeFlag, int CommodityID, int VarityID, string Status, string QANo, string PartNo, string UseStatus); + //yiru 2022-09-20 add BEGIN + /// + /// 新增 檢驗結果上傳圖檔資料表 + /// + /// + /// + [WebApiClient.Attributes.HttpPost("api/OutfitInfoBlob")] + ITask> PostOutfitInfoBlob([FromBody, RawJsonContent] string model); + + + /// + /// 更新 檢驗結果上傳圖檔資料表 + /// + /// + [WebApiClient.Attributes.HttpPut("api/OutfitInfoBlob/{id}")] + ITask> PutOutfitInfoBlob(int id,[FromBody, RawJsonContent] string model); + + + /// + /// 查詢 檢驗結果上傳圖檔資料表 By OUTFITID + /// + /// + /// + [WebApiClient.Attributes.HttpGet("api/OutfitInfoBlob/ByOutfitID/{id}")] + ITask> GetOutfitInfoBlobByOutfitID(int id); + + + /// + /// 刪除圖檔資料表 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/OutfitInfoBlob/{id}")] + ITask> DeleteOutfitInfoBlob(int id); + + + + + //yiru 2022-09-20 add END + + + #endregion #region JIG005 設備狀態紀錄維護 diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs index b851ea13..39a99d8c 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs @@ -419,8 +419,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpDelete("api/ExceptionClasses/{id}")] - ITask> DeleteExceptionClass(string id); - + ITask> DeleteExceptionClass(string id); //yiru modify /// /// 根據ID獲取指定異常工時類別查詢資料 /// diff --git a/AMESCoreStudio.Web/Views/JIG/JIG002.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG002.cshtml index 4e3c9a9a..26dfcc10 100644 --- a/AMESCoreStudio.Web/Views/JIG/JIG002.cshtml +++ b/AMESCoreStudio.Web/Views/JIG/JIG002.cshtml @@ -100,6 +100,8 @@ }] ]; + + //通过行tool编辑,lay-event="edit" function edit(obj) { if (obj.data.varityID) { @@ -142,6 +144,7 @@ class: 'layui-btn-normal', handler: function () { hg.open('新增設備規格', '/JIG/JIG002C', 640, 320); + // hg.open('修改設備規格', '/JIG/JIG002R', 640, 320); } } diff --git a/AMESCoreStudio.Web/Views/JIG/JIG002C.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG002C.cshtml index 0df8af5a..e45b3128 100644 --- a/AMESCoreStudio.Web/Views/JIG/JIG002C.cshtml +++ b/AMESCoreStudio.Web/Views/JIG/JIG002C.cshtml @@ -62,6 +62,15 @@ *@ + +
+
+ @Html.ValidationMessage("error") + @* *@ +
+
+ + @Html.ValidationMessage("error")
@@ -82,6 +91,7 @@ parent.hg.msg(error); } }); + diff --git a/AMESCoreStudio.Web/Views/JIG/JIG003.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG003.cshtml index cc54664c..e45d362b 100644 --- a/AMESCoreStudio.Web/Views/JIG/JIG003.cshtml +++ b/AMESCoreStudio.Web/Views/JIG/JIG003.cshtml @@ -62,6 +62,7 @@ } } + //通过行tool删除,lay-event="del" function del(obj) { if (obj.data.vendorID) { @@ -80,7 +81,7 @@ } }, error: function () { - hg.msg("网络请求失败!"); + hg.msg("网络请求失败!" ); } }); }); diff --git a/AMESCoreStudio.Web/Views/JIG/JIG004.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG004.cshtml index 5bb70071..aca3477f 100644 --- a/AMESCoreStudio.Web/Views/JIG/JIG004.cshtml +++ b/AMESCoreStudio.Web/Views/JIG/JIG004.cshtml @@ -134,12 +134,20 @@ btn += ' 停用'; else btn += ' 啟用'; + btn += '上傳 '; return btn //return '修改 删除' } }] ]; + function Upload(obj) { + if (obj.data.outfitID) { + + hg.open('上傳檔案', '/JIG/JIG004R/' + obj.data.outfitID, 640, 320); + } + }; + //通过行tool编辑,lay-event="edit" function edit(obj) { if (obj.data.outfitID) { diff --git a/AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml index 94c5c36b..f559980c 100644 --- a/AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml +++ b/AMESCoreStudio.Web/Views/JIG/JIG004C.cshtml @@ -1,7 +1,7 @@ @model AMESCoreStudio.WebApi.Models.AMES.OutfitInfo -@{ ViewData["Title"] = "SPC004C"; +@{ ViewData["Title"] = "JIG004C"; Layout = "~/Views/Shared/_FormLayout.cshtml"; } @@ -24,11 +24,11 @@
- - - +
@@ -51,7 +51,7 @@
- @* yiru *@ + @* yiru 2022-09-19 *@
@@ -61,7 +61,7 @@
- @* yiru *@ + @* yiru 2022-09-19 *@
diff --git a/AMESCoreStudio.Web/Views/JIG/JIG004U.cshtml b/AMESCoreStudio.Web/Views/JIG/JIG004U.cshtml index 8087ec91..5a74d86c 100644 --- a/AMESCoreStudio.Web/Views/JIG/JIG004U.cshtml +++ b/AMESCoreStudio.Web/Views/JIG/JIG004U.cshtml @@ -25,11 +25,11 @@
- - - +
@@ -52,7 +52,7 @@
- @* yiru *@ + @* yiru 2022-09-19 *@
@@ -62,9 +62,9 @@
- @* yiru *@ - -
+ @* yiru 2022-09-19 *@ + +
+
@@ -54,14 +54,37 @@ @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); await Html.RenderPartialAsync("_FileinputScriptsPartial"); } - + $("#WipNo").change(function () { + var data = $("#WipNo").val(); + + $.ajax({ + url: "/WHS/GetWipAtt", + dataType: 'json', + data: { id: data }, + contentType: "application/json", + type: 'get', + success: function (result) { + if (result.data) { + //console.info(result.data);//確認itemNO/modelNO + $("#searchItemNo").val(result.data.itemNO); + } + else { + alert("查無資料,請確認工單是否正確!"); + } + } + + }); + + }) + + } diff --git a/AMESCoreStudio.Web/Views/WHS/WHS018.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS018.cshtml index 92e2c0e4..c4998cce 100644 --- a/AMESCoreStudio.Web/Views/WHS/WHS018.cshtml +++ b/AMESCoreStudio.Web/Views/WHS/WHS018.cshtml @@ -76,7 +76,7 @@
- +
diff --git a/AMESCoreStudio.Web/Views/WHS/WHS019.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS019.cshtml index ab282cd2..4155f59b 100644 --- a/AMESCoreStudio.Web/Views/WHS/WHS019.cshtml +++ b/AMESCoreStudio.Web/Views/WHS/WHS019.cshtml @@ -79,7 +79,7 @@
- +
@@ -323,13 +323,13 @@ //通过行tool编辑,lay-event="edit" function edit(obj) { if (obj.data.timeSheetID) { - hg.open('修改生產工時', '/WHS/WHS019U/' + obj.data.timeSheetID, 800,720); + hg.open('修改生產工時', '/WHS/WHS019U/' + obj.data.timeSheetID, 600, 520); } } //通过行tool编辑,lay-event="finish" function finish(obj) { if (obj.data.timeSheetID) { - hg.open('完工', '/WHS/WHS019E/' + obj.data.timeSheetID, 800, 800); + hg.open('完工', '/WHS/WHS019E/' + obj.data.timeSheetID, 600, 520); } } //通过行tool删除,lay-event="del" @@ -361,7 +361,7 @@ layuiicon: '', class: 'layui-btn-normal', handler: function () { - hg.open('開工', '/WHS/WHS019C', 800, 720); + hg.open('開工', '/WHS/WHS019C', 600, 520); } } diff --git a/AMESCoreStudio.Web/Views/WHS/WHS019C.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS019C.cshtml index 762dbc7c..c0e5563e 100644 --- a/AMESCoreStudio.Web/Views/WHS/WHS019C.cshtml +++ b/AMESCoreStudio.Web/Views/WHS/WHS019C.cshtml @@ -106,30 +106,30 @@ parent.hg.msg(error); } }); - $('#searchItemNo').click(function () { + + $("#WipNo").change(function () { var data = $("#WipNo").val(); - if (data) { - $.ajax({ - url: "/WHS/GetWipAtt", - dataType: 'json', - data: { id: data }, - contentType: "application/json", - type: 'get', - success: function (result) { - if (result.data) { - //console.info(result.data);//確認itemNO/modelNO - $("#searchItemNo").val(result.data.modelNO); - } - else { - alert("查無資料,請確認工單是否正確!"); - } + + $.ajax({ + url: "/WHS/GetWipAtt", + dataType: 'json', + data: { id: data }, + contentType: "application/json", + type: 'get', + success: function (result) { + if (result.data) { + //console.info(result.data);//確認itemNO/modelNO + $("#searchItemNo").val(result.data.itemNO); } - }); - } else { - alert("請填寫工單!"); - } + else { + alert("查無資料,請確認工單是否正確!"); + } + } + + }); + + }) - }); $('#countTime').click(function () { var data = ""; var data1 = $("#StartTime").val(); @@ -164,7 +164,6 @@ getStations(data); getStations2(data); }); - function getUserInfoes(data) { $.ajax({ url: "/SYS/GetUserInfoes", diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/OutfitInfoBlobController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/OutfitInfoBlobController.cs new file mode 100644 index 00000000..507b40b3 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/OutfitInfoBlobController.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using AMESCoreStudio.WebApi; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.CommonTools.Result; + +namespace AMESCoreStudio.WebApi.Controllers.AMES +{ //YIRU 2022-09-20 + /// + /// 設備上傳圖檔資料表 + /// + [Route("api/[controller]")] + [ApiController] + public class OutfitInfoBlobController : ControllerBase + { + private readonly AMESContext _context; + + public OutfitInfoBlobController(AMESContext context) + { + _context = context; + } + + // GET: api/OutfitInfoBlob + [HttpGet] + public async Task>> GetOutfitInfoBlobs() + { + return await _context.OutfitInfoBlobs.ToListAsync(); + } + + // GET: api/OutfitInfoBlob/5 + [HttpGet("{id}")] + public async Task> GetOutfitInfoBlob(int id) + { + var OutfitInfoBlob = await _context.OutfitInfoBlobs.FindAsync(id); + + if (OutfitInfoBlob == null) + { + return NotFound(); + } + + return OutfitInfoBlob; + } + + /// + /// 設備上傳圖檔資料表 By OutfitID + /// + /// OutfitID + /// + [HttpGet("ByOutfitID/{id}")] + public async Task>> GetOutfitInfoBlobByOutfitID(int id) + { + var OutfitInfoBlobs = await _context.OutfitInfoBlobs.Where(w => w.OutfitID == id).ToListAsync(); + return OutfitInfoBlobs; + } + + /// + /// 更新上傳圖檔資料 + /// + /// + /// + /// + // PUT: api/OutfitInfoes/5 + // To protect from overposting attacks, enable the specific properties you want to bind to, for + // more details, see https://go.microsoft.com/fwlink/?linkid=2123754. + [HttpPut("{id}")] + public async Task> PutOutfitInfo(int id, [FromBody] OutfitInfoBlob OutfitInfoBlob) + { + ResultModel result = new ResultModel(); + if (id != OutfitInfoBlob.OutfitID) + { + result.Success = false; + result.Msg = "序號錯誤"; + return result; + } + + _context.Entry(OutfitInfoBlob).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (Exception ex) + { + + result.Success = false; + result.Msg = ex.Message; + return result; + + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + + /// + /// 新增 設備上傳圖檔資料表 + /// + /// + /// + [HttpPost] + public async Task> PostOutfitInfoBlob(OutfitInfoBlob OutfitInfoBlob) + { + ResultModel result = new ResultModel(); + OutfitInfoBlob.CreateDate = DateTime.Now; + OutfitInfoBlob.UpdateDate = DateTime.Now; + + _context.OutfitInfoBlobs.Add(OutfitInfoBlob); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + } + /// + /// 刪除 設備上上傳圖檔資料表 + /// + /// + /// + + [HttpDelete("{id}")] + public async Task> DeleteOutfitInfoBlob(int id) + { + var OutfitInfoBlob = await _context.OutfitInfoBlobs.FindAsync(id); + if (OutfitInfoBlob == null) + { + return NotFound(); + } + + _context.OutfitInfoBlobs.Remove(OutfitInfoBlob); + await _context.SaveChangesAsync(); + + return OutfitInfoBlob; + } + + private bool OutfitInfoBlobExists(int id) + { + return _context.OutfitInfoBlobs.Any(e => e.OutfitID == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipBoxController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipBoxController.cs index dca99306..99df2c8e 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipBoxController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipBoxController.cs @@ -130,6 +130,92 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return wipBox; } + //Yiru Add -------------------------------------------------------------------------------------------- + /// + /// 自動裝箱 + /// + /// BarcodeID + /// + [HttpPost("ByBeerAP")] + public async Task>> PostWipBox(int id) + { + ResultModel resultModel = new ResultModel { Success = false }; + #region 宣告Coltroller + BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); + WipInfosController wipInfosController = new WipInfosController(_context); + #endregion + try + { + + var BarcodeInfos = await barcodeInfoesController.GetBarcodeInfoes(id); + int wipID = BarcodeInfos.Value.Select(s => s.WipID).FirstOrDefault(); //當前工單ID + var WipInfos = await wipInfosController.GetWipInfo(wipID); + + var WipNo = WipInfos.Value.Select(s => s.WipNO).FirstOrDefault(); //當前工單 + var BoxCnt = WipInfos.Value.Select(s => s.BoxCNT).FirstOrDefault(); //當前工單單箱入數 + var wipBoxs = await GetWipBoxByWipID(wipID); + + //// 當前箱號 + var NowBoxNo = string.Empty; + if (wipBoxs.Value.Where(w => w.BoxStatus != 0).Count() == 0) + NowBoxNo = "BOX" + WipNo + "001"; + else + NowBoxNo = wipBoxs.Value.Where(w => w.BoxStatus != 0).FirstOrDefault().BoxNo; + + + var query_barCode = await barcodeInfoesController.GetBarcodeInfoesByBoxNo(NowBoxNo); + var ByBox = query_barCode.Value.Count().ToString();// 本箱已裝數量 + + + bool checkbox = false; //是否已滿箱需裝箱 + int boxQty = int.Parse(ByBox) + 1; + + if (boxQty == BoxCnt) //當滿箱=>自動裝箱=true + checkbox = true; + + var wipBox = new WipBox + { + WipID = wipID, + BoxNo = NowBoxNo, + BoxCnt = int.Parse(ByBox) + 1, + BoxStatus = checkbox ? 0 : 1 + }; + + var query_wipBox = await GetWipBox(NowBoxNo); + + if (query_wipBox.Value.BoxNo == null) + await PostWipBox(wipBox); + else + await PutWipBox(wipBox); + + //// 自動裝箱 + if (checkbox) + { + string BoxNoOrder = NowBoxNo.Substring(NowBoxNo.Length - 3, 3); + BoxNoOrder = (int.Parse(BoxNoOrder) + 1).ToString().PadLeft(3, '0'); + + NowBoxNo = NowBoxNo.Substring(0, NowBoxNo.Length - 3) + BoxNoOrder; + wipBox.BoxNo = NowBoxNo; + wipBox.BoxStatus = 1; + wipBox.BoxCnt = 0; + await PostWipBox(wipBox); + } + } + + catch (Exception ex) + { + resultModel.Success = false; + resultModel.Msg = ex.InnerException.Message; + return resultModel; + } + + resultModel.Success = true; + resultModel.Msg = "裝箱完成"; + return resultModel; + + } + //------------------------------------------------------------------------------------------------------ + private bool WipBoxExists(string id) { return _context.WipBoxs.Any(e => e.BoxNo == id); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WorkGroupsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WorkGroupsController.cs index 19418fe7..e71ee388 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WorkGroupsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WorkGroupsController.cs @@ -166,6 +166,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES try { + _context.WorkGroups.Remove(workGroup); //yiru add 2022-09-27 await _context.SaveChangesAsync(); } catch (Exception ex) diff --git a/AMESCoreStudio.WebApi/Models/AMES/OutfitInfo.cs b/AMESCoreStudio.WebApi/Models/AMES/OutfitInfo.cs index 99deca09..8ba66d53 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/OutfitInfo.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/OutfitInfo.cs @@ -168,11 +168,11 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// 廠別代碼 /// - [Column("FACTORY_CODE")] - [StringLength(5)] + [Column("OUTFIT_FACTORY_NO")] + [StringLength(2)] [DataMember] [Display(Name = "廠別")] - public string FactoryCode { get; set; } = "NA"; + public string OutfitFactoryNo { get; set; } = "NA"; /// /// 購置日期 diff --git a/AMESCoreStudio.WebApi/Models/AMES/OutfitInfoBlob.cs b/AMESCoreStudio.WebApi/Models/AMES/OutfitInfoBlob.cs new file mode 100644 index 00000000..31e34b34 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/OutfitInfoBlob.cs @@ -0,0 +1,92 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; +using Microsoft.EntityFrameworkCore; + +#nullable disable + +namespace AMESCoreStudio.WebApi.Models.AMES +{ // YIRU 2022-90-20 + /// + /// 設備圖 + /// + [Table("OUTFIT_INFO_BLOB", Schema = "JHAMES")] + public partial class OutfitInfoBlob + { + /// + /// 治具ID + /// + [Column("OUTFIT_ID")] + [DataMember] + [Key] + [Required] + + public int OutfitID { get; set; } + + + /// + /// 檔名 + /// + [Column("IMAGE_NAME")] + [StringLength(50)] + [Display(Name = "檔名")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + public string ImageName { get; set; } + + /// + /// 新檔名 + /// + [Column("NEWNAME")] + [DataMember] + public string NewName { get; set; } + + /// + /// 圖檔 + /// + [Column("IMAGE_BLOB")] + [StringLength(50)] + [Display(Name = "圖檔")] + [DataMember] + public byte[] ImageBlob { get; set; } + + + /// + /// 儲存路徑 + /// + [Column("FILEPATH")] + [StringLength(100)] + [Display(Name = "儲存路徑")] + [DataMember] + public string FilePath { get; set; } + + /// + /// 創建者ID + /// + [Column("CREATE_USERID")] + [DataMember] + public int CreateUserID { get; set; } = 0; + + /// + /// 創建日期 + /// + [Column("CREATE_DATE")] + [DataMember] + public DateTime CreateDate { get; set; } = System.DateTime.Now; + + /// + /// 更新者ID + /// + [Column("UPDATE_USERID")] + [DataMember] + public int UpdateUserID { get; set; } = 0; + + /// + /// 更新日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + public DateTime UpdateDate { get; set; } = System.DateTime.Now; + } +}