diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index d3621bee..ca14191f 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -26,6 +26,7 @@ namespace AMESCoreStudio.Web.Controllers public class PCSController : Controller { private readonly ILogger _logger; + private readonly ILogger _log; public readonly ISYS _sysApi; public readonly IPCS _pcsApi; public readonly IBAS _basApi; @@ -35,10 +36,11 @@ namespace AMESCoreStudio.Web.Controllers public readonly IFileServerProvider _fileServerProvider; private readonly IWebHostEnvironment _env; - public PCSController(ILogger logger, ISYS sysApi, IPCS pcsApi, IBAS basApi, IPPS ppsApi, IFQC fqcApi + public PCSController(ILogger logger, ILogger log, ISYS sysApi, IPCS pcsApi, IBAS basApi, IPPS ppsApi, IFQC fqcApi , IFileServerProvider fileServerProvider, IWebHostEnvironment env, IKCS kcsApi) { _logger = logger; + _log = log; _sysApi = sysApi; _pcsApi = pcsApi; _basApi = basApi; @@ -1233,8 +1235,8 @@ namespace AMESCoreStudio.Web.Controllers GetCheckboxDIP(); GetCheckboxSMD(); #endregion - IResultModel result; + int UserID = GetLogInUserID(); // Checkbox轉換 model.wipInfo.ECNCheck = model.wipInfo.ECNCheck == "true" ? "Y" : "N"; model.wipInfo.ModelCheck = model.wipInfo.ModelCheck == "true" ? "Y" : "N"; @@ -1301,17 +1303,21 @@ namespace AMESCoreStudio.Web.Controllers await _pcsApi.PostMaterialItem(JsonConvert.SerializeObject( new MaterialItem { - ItemNo = model.wipAtt.ItemNO + ItemNo = model.wipAtt.ItemNO, + CreateUserID = UserID })); } // 工單屬性 model.wipAtt.WipNO = model.wipInfo.WipNO; + model.wipAtt.CreateUserID = UserID; await _pcsApi.PostWipAtt(JsonConvert.SerializeObject(model.wipAtt)); // 標籤 model.wipLabel.ApproveLogo = model.wipLabel.ApproveLogos == null ? null : string.Join(',', model.wipLabel.ApproveLogos); model.wipLabel.WipNO = model.wipInfo.WipNO; + model.wipLabel.CreateUserID = UserID; + model.wipLabel.UpdateUserID = UserID; await _pcsApi.PostWipLabel(JsonConvert.SerializeObject(model.wipLabel)); // 新增工單Log @@ -1319,6 +1325,7 @@ namespace AMESCoreStudio.Web.Controllers wiplog.WipID = wipID; wiplog.StatusNO = "N"; wiplog.WipDesc = "."; + wiplog.CreateUserID = UserID; await _pcsApi.PostWipLog(JsonConvert.SerializeObject(wiplog)); // 系統 @@ -1330,6 +1337,8 @@ namespace AMESCoreStudio.Web.Controllers { model.wipSystem.ItemNo = model.wipAtt.ItemNO; model.wipSystem.WipNo = model.wipInfo.WipNO; + model.wipSystem.CreateUserID = UserID; + model.wipSystem.UpdateUserID = UserID; await _pcsApi.PostWipSystem(JsonConvert.SerializeObject(model.wipSystem)); } } @@ -1346,6 +1355,8 @@ namespace AMESCoreStudio.Web.Controllers model.wipBoard.SmdSolderMask = model.wipBoard.SmdSolderMasks == null ? null : string.Join(',', model.wipBoard.SmdSolderMasks); model.wipBoard.ItemNo = model.wipAtt.ItemNO; model.wipBoard.WipNo = model.wipInfo.WipNO; + model.wipBoard.CreateUserID = UserID; + model.wipBoard.UpdateUserID = UserID; await _pcsApi.PostWipBoard(JsonConvert.SerializeObject(model.wipBoard)); } } @@ -1357,6 +1368,7 @@ namespace AMESCoreStudio.Web.Controllers model.wipBarcode.WipID = wipID; model.wipBarcode.WipNO = model.wipInfo.WipNO; model.wipBarcode.UnitNO = model.wipInfo.UnitNO; + model.wipBarcode.CreateUserID = UserID; result = await _pcsApi.PostWipBarcode(JsonConvert.SerializeObject(model.wipBarcode)); // 工單條碼規則設定文件檔 @@ -1376,6 +1388,8 @@ namespace AMESCoreStudio.Web.Controllers { model.wipBarcodeOther.WipNO = model.wipInfo.WipNO; model.wipBarcodeOther.TypeNO = type_no.TypeNo; + model.wipBarcodeOther.CreateUserID = UserID; + model.wipBarcodeOther.UpdateUserID = UserID; result = await _pcsApi.PostWipBarcodeOther(JsonConvert.SerializeObject(model.wipBarcodeOther)); } } @@ -1389,6 +1403,7 @@ namespace AMESCoreStudio.Web.Controllers model.wipMAC.WipNO = model.wipInfo.WipNO; model.wipMAC.Title = mACInfo.Title; model.wipMAC.ClassGroup = mACInfo.ClassGroup; + model.wipMAC.CreateUserID = UserID; result = await _pcsApi.PostWipMAC(JsonConvert.SerializeObject(model.wipMAC)); result = await _pcsApi.PutMACInfoByClassGroup(mACInfo.ClassGroup, model.wipMAC.EndNO); } @@ -1411,8 +1426,10 @@ namespace AMESCoreStudio.Web.Controllers KpNo = item.KpNo, KpSeq = item.KpSeq, Length = item.Length, - Title = item.Title - }; + Title = item.Title, + CreateUserID = UserID, + UpdateUserID = UserID + }; await _pcsApi.PostWipKp(JsonConvert.SerializeObject(wipKp)); } @@ -1426,8 +1443,10 @@ namespace AMESCoreStudio.Web.Controllers ItemNo = model.wipAtt.ItemNO, UnitNo = model.wipInfo.UnitNO, OutfitNo = item.OutfitNo, - PartNo = item.StationType - }; + PartNo = item.StationType, + CreateUserID = UserID, + UpdateUserID = UserID + }; await _pcsApi.PostWipOutfit(JsonConvert.SerializeObject(wipOutfit)); } @@ -1442,8 +1461,10 @@ namespace AMESCoreStudio.Web.Controllers UnitNo = model.wipInfo.UnitNO, SOPName = item.SopName, SOPPath = item.SopPath, - SOPType = item.SopType - }; + SOPType = item.SopType, + CreateUserID = UserID, + UpdateUserID = UserID + }; await _pcsApi.PostWipSop(JsonConvert.SerializeObject(wipSop)); } } @@ -4353,6 +4374,21 @@ namespace AMESCoreStudio.Web.Controllers var aa = "string"; return View(model); } + + public int GetLogInUserID() + { + int user_id = 0; + HttpContext.Request.Cookies.TryGetValue("UserID", out string userID); + + if (userID != null) + { + if (int.Parse(userID.ToString()) >= 0) + { + user_id = int.Parse(userID.ToString()); + } + } + return user_id; + } } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml index 4197bf83..45dd0ddb 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml @@ -30,7 +30,7 @@
- +
@@ -40,7 +40,7 @@
- +
@@ -563,7 +563,7 @@
- +
@@ -609,7 +609,7 @@
- +
@@ -632,7 +632,7 @@
- +
@@ -647,7 +647,7 @@
- +
@@ -662,7 +662,7 @@
- +
@@ -677,7 +677,7 @@
- +
@@ -692,7 +692,7 @@
- +
diff --git a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml index cc88cda9..c1c56275 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml @@ -704,7 +704,7 @@
- +
@@ -750,7 +750,7 @@
- +
@@ -773,7 +773,7 @@
- +
@@ -788,7 +788,7 @@
- +
@@ -803,7 +803,7 @@
- +
@@ -818,7 +818,7 @@
- +
@@ -833,7 +833,7 @@
- +
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs index 6631d088..3c5e0c7f 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs @@ -220,19 +220,13 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES ResultModel result = new ResultModel(); _context.Entry(barcodeInfo).State = EntityState.Modified; - // Detached 來分離已附加 + //設置容器空間某一個模型的某一個欄位 不提交到資料庫 + _context.Entry(barcodeInfo).Property("CreateDate").IsModified = false; + _context.Entry(barcodeInfo).Property("CreateUserID").IsModified = false; barcodeInfo.UpdateDate = DateTime.Now; - // 指定更新某個欄位 - //_context.Entry(barcodeInfo).Property(p => p.StatusNo).IsModified = true; - //_context.Entry(barcodeInfo).Property(p => p.RuleStationID).IsModified = true; - //_context.Entry(barcodeInfo).Property(p => p.RuleStatus).IsModified = true; - //_context.Entry(barcodeInfo).Property(p => p.WipID).IsModified = true; - //_context.Entry(barcodeInfo).Property(p => p.StatusID).IsModified = true; - //_context.Entry(barcodeInfo).Property(p => p.UpdateDate).IsModified = true; try { - //_context.BarcodeInfoes.Update(barcodeInfo); await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemChangesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemChangesController.cs index 62ab8745..40ec1892 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemChangesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemChangesController.cs @@ -89,7 +89,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } _context.Entry(barcodeItemChange).State = EntityState.Modified; - + //設置容器空間某一個模型的某一個欄位 不提交到資料庫 + _context.Entry(barcodeItemChange).Property("CreateDate").IsModified = false; + _context.Entry(barcodeItemChange).Property("CreateUserID").IsModified = false; try { await _context.SaveChangesAsync(); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs index 54ced7e5..d21d80e2 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs @@ -141,13 +141,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES ResultModel result = new ResultModel(); _context.Entry(barcodeLock).State = EntityState.Modified; - - //_context.Attach(barcodeLock); - //// 指定更新某個欄位 - //_context.Entry(barcodeLock).Property(p => p.LockStatus).IsModified = true; - //_context.Entry(barcodeLock).Property(p => p.UnLockDate).IsModified = true; - //_context.Entry(barcodeLock).Property(p => p.UnLockReason).IsModified = true; - //_context.Entry(barcodeLock).Property(p => p.UnLockUserID).IsModified = true; + //設置容器空間某一個模型的某一個欄位 不提交到資料庫 + _context.Entry(barcodeLock).Property("CreateDate").IsModified = false; + _context.Entry(barcodeLock).Property("CreateUserID").IsModified = false; try { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeOutfitController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeOutfitController.cs index 8ce85b80..d3920b73 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeOutfitController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeOutfitController.cs @@ -69,6 +69,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); _context.Entry(barcodeOutfit).State = EntityState.Modified; + //設置容器空間某一個模型的某一個欄位 不提交到資料庫 + _context.Entry(barcodeOutfit).Property("CreateDate").IsModified = false; + _context.Entry(barcodeOutfit).Property("CreateUserID").IsModified = false; barcodeOutfit.UpdateDate = DateTime.Now; barcodeOutfit.UpdateUserID = 0; diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs index 3e87dcaa..5b18cef2 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs @@ -48,62 +48,58 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return fqcInhouseDetail; } - // PUT: api/FqcInhouseDetail/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 PutFqcInhouseDetail(string id, FqcInhouseDetail fqcInhouseDetail) + /// + /// 新增檢驗單明細資料檔 + /// + /// + /// + [HttpPut] + public async Task> PutFqcInhouseDetail(FqcInhouseDetail fqcInhouseDetail) { - if (id != fqcInhouseDetail.InhouseNo) - { - return BadRequest(); - } - + ResultModel result = new ResultModel(); _context.Entry(fqcInhouseDetail).State = EntityState.Modified; + //設置容器空間某一個模型的某一個欄位 不提交到資料庫 + _context.Entry(fqcInhouseDetail).Property("CreateDate").IsModified = false; + _context.Entry(fqcInhouseDetail).Property("CreateUserID").IsModified = false; + fqcInhouseDetail.UpdateDate = DateTime.Now; + fqcInhouseDetail.UpdateUserID = 0; try { await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - catch (DbUpdateConcurrencyException) + catch (Exception ex) { - if (!FqcInhouseDetailExists(id)) - { - return NotFound(); - } - else - { - throw; - } + result.Success = false; + result.Msg = ex.InnerException.Message; } - - return NoContent(); + return result; } - // POST: api/FqcInhouseDetail - // 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. + /// + /// 新增檢驗單明細資料檔 + /// + /// + /// [HttpPost] - public async Task> PostFqcInhouseDetail(FqcInhouseDetail fqcInhouseDetail) + public async Task> PostFqcInhouseDetail(FqcInhouseDetail fqcInhouseDetail) { - _context.FqcInhouseDetails.Add(fqcInhouseDetail); + ResultModel result = new ResultModel(); try { + _context.FqcInhouseDetails.Add(fqcInhouseDetail); await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - catch (DbUpdateException) + catch (Exception ex) { - if (FqcInhouseDetailExists(fqcInhouseDetail.InhouseNo)) - { - return Conflict(); - } - else - { - throw; - } + result.Success = false; + result.Msg = ex.InnerException.Message; } - - return CreatedAtAction("GetFqcInhouseDetail", new { id = fqcInhouseDetail.InhouseNo }, fqcInhouseDetail); + return result; } // DELETE: api/FqcInhouseDetail/5 diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs index 092538a5..a3059e2d 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs @@ -250,8 +250,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); _context.Entry(fqcInhouseMaster).State = EntityState.Modified; + _context.Entry(fqcInhouseMaster).Property("CreateDate").IsModified = false; + _context.Entry(fqcInhouseMaster).Property("CreateUserID").IsModified = false; fqcInhouseMaster.UpdateDate = DateTime.Now; - fqcInhouseMaster.UpdateUserID = 0; try { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipAttsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipAttsController.cs index 727916a8..4ad21d72 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipAttsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipAttsController.cs @@ -71,11 +71,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> PostWipAtt([FromBody] WipAtt wipatt) { ResultModel result = new ResultModel(); - wipatt.CreateUserID = 0; - - _context.WipAtts.Add(wipatt); try { + _context.WipAtts.Add(wipatt); await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; @@ -98,6 +96,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); _context.Entry(wipatt).State = EntityState.Modified; + _context.Entry(wipatt).Property("CreateDate").IsModified = false; + _context.Entry(wipatt).Property("CreateUserID").IsModified = false; wipatt.UpdateDate = DateTime.Now; try diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeController.cs index d76045ef..c27c4983 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeController.cs @@ -87,9 +87,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// /// /// - // POST: api/WipBarcode - // 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. [HttpPost] public async Task> PostWipBarcode([FromBody] WipBarcode wipBarcode) { @@ -98,8 +95,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { Helper helper = new Helper(_context); wipBarcode.WipID = wipBarcode.WipID == 0 ? helper.GetIDKeyNoPost("WIP_ID").Result : wipBarcode.WipID; - wipBarcode.CreateUserID = 0; - _context.WipBarcodes.Add(wipBarcode); await _context.SaveChangesAsync(); } @@ -136,7 +131,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES _context.Entry(item).Property("CreateUserID").IsModified = false; item.UpdateDate = DateTime.Now; item.Remarks = wipBarcode.Remarks; - } } else diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeOthersController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeOthersController.cs index 4c66061c..cecc55c8 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeOthersController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeOthersController.cs @@ -72,7 +72,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// 序號 /// [HttpGet("ByNo")] - public async Task>> CheckWipBarcodeOtherByNo(string wipNO , string No) + public async Task>> CheckWipBarcodeOtherByNo(string wipNO, string No) { var wipBarcodeOther = _context.WipBarcodeOthers .FromSqlInterpolated($" SELECT * FROM WIP_BARCODE_OTHER WHERE {No} BETWEEN START_NO AND END_NO ") @@ -88,16 +88,21 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return wipBarcodeOther; } - + /// + /// 新增工單條碼區間設定檔 + /// + /// + /// [HttpPost] public async Task> PostWipBarcodeOther([FromBody] WipBarcodeOther wipBarcodeOther) { ResultModel result = new ResultModel(); Helper helper = new Helper(_context); wipBarcodeOther.OtherID = helper.GetIDKey("OTHER_ID").Result; - _context.WipBarcodeOthers.Add(wipBarcodeOther); + try { + _context.WipBarcodeOthers.Add(wipBarcodeOther); await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; @@ -111,7 +116,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } /// - /// 更新 + /// 更新工單條碼區間設定檔 /// /// /// @@ -119,26 +124,20 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> PutWipBarcodeOther(WipBarcodeOther wipBarcodeOther) { ResultModel result = new ResultModel(); - - var getWipBarcodeOther = GetWipBarcodeOtherByWipNo(wipBarcodeOther.WipNO).Result.Value; - - if (getWipBarcodeOther != null) - { - _context.Entry(getWipBarcodeOther).State = EntityState.Modified; - getWipBarcodeOther.StartNO = wipBarcodeOther.StartNO; - getWipBarcodeOther.EndNO = wipBarcodeOther.EndNO; - getWipBarcodeOther.Title = wipBarcodeOther.Title; - getWipBarcodeOther.TypeNO = wipBarcodeOther.TypeNO; - getWipBarcodeOther.UpdateDate = DateTime.Now; - getWipBarcodeOther.UpdateUserID = 0; - } - else - { - _context.WipBarcodeOthers.Add(wipBarcodeOther); - } - + var wipNo = wipBarcodeOther.WipNO; try { + var result_old = _context.WipBarcodeOthers.Where(w => w.WipNO == wipNo).ToList(); + if (result_old.Count != 0) + { + _context.Entry(wipBarcodeOther).State = EntityState.Modified; + _context.Entry(wipBarcodeOther).Property("CreateDate").IsModified = false; + _context.Entry(wipBarcodeOther).Property("CreateUserID").IsModified = false; + } + else + { + _context.WipBarcodeOthers.Add(wipBarcodeOther); + } await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipBoardController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipBoardController.cs index e6ddf947..13558770 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipBoardController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipBoardController.cs @@ -92,7 +92,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES _context.Entry(wipBoard).Property("CreateDate").IsModified = false; _context.Entry(wipBoard).Property("CreateUserID").IsModified = false; wipBoard.UpdateDate = DateTime.Now; - wipBoard.UpdateUserID = 0; } else { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipBoxController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipBoxController.cs index 23550ee8..dca99306 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipBoxController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipBoxController.cs @@ -68,7 +68,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES ResultModel result = new ResultModel(); _context.WipBoxs.Attach(wipBox); wipBox.UpdateDate = DateTime.Now; - wipBox.UpdateUserID = 0; // 指定更新某個欄位 _context.Entry(wipBox).Property(p => p.BoxCnt).IsModified = true; _context.Entry(wipBox).Property(p => p.BoxStatus).IsModified = true; @@ -77,7 +76,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES _context.Entry(wipBox).Property(p => p.UpdateUserID).IsModified = true; try { - //_context.WipBoxs.Update(wipBox); await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; @@ -90,18 +88,20 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - // POST: api/WipBox - // 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. + /// + /// 新增工單箱號資料檔 + /// + /// + /// [HttpPost] public async Task> PostWipBox(WipBox wipBox) { ResultModel result = new ResultModel(); - Helper helper = new Helper(_context); - wipBox.BoxID = helper.GetIDKey("BOX_ID").Result; - _context.WipBoxs.Add(wipBox); try { + Helper helper = new Helper(_context); + wipBox.BoxID = helper.GetIDKey("BOX_ID").Result; + _context.WipBoxs.Add(wipBox); await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipCheckController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipCheckController.cs index c35472c3..1805029d 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipCheckController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipCheckController.cs @@ -54,8 +54,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> PutWipCheckByPE(WipCheck wipCheck) { ResultModel result = new ResultModel(); - wipCheck.PEUserID = 0; - wipCheck.PECheckdate = DateTime.Now; var wipNo = wipCheck.WipNo; try { @@ -95,8 +93,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); var wipNo = wipCheck.WipNo; - wipCheck.MFUserID = 0; - wipCheck.MFCheckdate = DateTime.Now; try { if (_context.WipChecks.Any(e => e.WipNo == wipNo)) @@ -135,8 +131,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> PutWipCheckByPMC(WipCheck wipCheck) { ResultModel result = new ResultModel(); - wipCheck.PMCUserID = 0; - wipCheck.PMCCheckdate = DateTime.Now; var wipNo = wipCheck.WipNo; try { @@ -166,13 +160,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + /// + /// 新增工單確認 + /// + /// + /// [HttpPost] public async Task> PostWipCheck(WipCheck wipCheck) { ResultModel result = new ResultModel(); - _context.WipChecks.Add(wipCheck); + try { + _context.WipChecks.Add(wipCheck); await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipClassController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipClassController.cs index 2dee2416..63e80f6b 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipClassController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipClassController.cs @@ -79,6 +79,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); _context.Entry(wipClass).State = EntityState.Modified; + _context.Entry(wipClass).Property("CreateDate").IsModified = false; + _context.Entry(wipClass).Property("CreateUserID").IsModified = false; wipClass.UpdateDate = DateTime.Now; try @@ -105,9 +107,10 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> PostWipClass(WipClass wipClass) { ResultModel result = new ResultModel(); - _context.WipClass.Add(wipClass); + try { + _context.WipClass.Add(wipClass); await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfoBlobController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfoBlobController.cs index 03527bf8..86a39ab6 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfoBlobController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfoBlobController.cs @@ -69,8 +69,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES _context.Entry(wipInfoBlob).Property("CreateDate").IsModified = false; _context.Entry(wipInfoBlob).Property("CreateUserID").IsModified = false; wipInfoBlob.UpdateDate = DateTime.Now; - wipInfoBlob.UpdateUserID = 0; - try { await _context.SaveChangesAsync(); @@ -97,14 +95,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES ResultModel result = new ResultModel(); Helper helper = new Helper(_context); wipInfoBlob.WipBlobID= helper.GetIDKey("WIP_BLOB_ID").Result; - HttpContext.Request.Cookies.TryGetValue("UserID", out string userID); - if (userID != null) - { - if (int.Parse(userID.ToString()) >= 0) - { - wipInfoBlob.CreateUserID = int.Parse(userID.ToString()); - } - } + try { _context.WipInfoBlobs.Add(wipInfoBlob); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index 07d25f60..57148360 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -238,16 +238,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return "Y"; else return "N"; - // 判斷是否已經開線 - var r = from q1 in _context.WipInfos - join q2 in _context.LineInfoes on q1.WipID equals q2.WipNo - where q1.WipNO == wipno - select q2; - - if (r.Count() != 0) - return "Y"; - else - return "N"; } /// @@ -281,7 +271,14 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES ResultModel result = new ResultModel(); Helper helper = new Helper(_context); WipInfo.WipID = helper.GetIDKey("WIP_ID").Result; - WipInfo.CreateUserID = 0; + //HttpContext.Request.Cookies.TryGetValue("UserID", out string userID); + //if (userID != null) + //{ + // if (int.Parse(userID.ToString()) >= 0) + // { + // WipInfo.CreateUserID = int.Parse(userID.ToString()); + // } + //} _context.WipInfos.Add(WipInfo); try @@ -421,5 +418,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + } } diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs index 91b884a4..caa9a14f 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs @@ -42,322 +42,339 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel resultModel = new ResultModel { Success = false }; - #region 欄位資料空值判斷 - if (string.IsNullOrWhiteSpace(barCodeCheckDto.wipNo)) + try { - resultModel.Msg = "請輸入工單號碼"; - return Ok(resultModel); - } - if (string.IsNullOrWhiteSpace(barCodeCheckDto.barcode)) - { - resultModel.Msg = "請輸入內部條碼"; - return Ok(resultModel); - } + if (barCodeCheckDto.inputItems == null) + barCodeCheckDto.inputItems = new List(); - if (string.IsNullOrWhiteSpace(barCodeCheckDto.unitNo)) - { - resultModel.Msg = "請輸入生產單位"; - return Ok(resultModel); - } + if (barCodeCheckDto.outfits == null) + barCodeCheckDto.outfits = new List(); - if (barCodeCheckDto.station == 0) - { - resultModel.Msg = "請輸入作業站代碼"; - return Ok(resultModel); - } + #region 欄位資料空值判斷 + if (string.IsNullOrWhiteSpace(barCodeCheckDto.wipNo)) + { + resultModel.Msg = "請輸入工單號碼"; + return Ok(resultModel); + } - if (barCodeCheckDto.line == 0) - { - resultModel.Msg = "請輸入線別代碼"; - return Ok(resultModel); - } - #endregion + if (string.IsNullOrWhiteSpace(barCodeCheckDto.barcode)) + { + resultModel.Msg = "請輸入內部條碼"; + return Ok(resultModel); + } - #region 宣告各個Controller - WipInfosController wipInfosController = new WipInfosController(_context); - WipMACController wipMACController = new WipMACController(_context); - WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); - BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); - BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); - BarcodeItemChangesController barcodeItemChangesController = new BarcodeItemChangesController(_context); - RuleStationsController ruleStationsController = new RuleStationsController(_context); - MaterialKpController materialKpController = new MaterialKpController(_context); - #endregion + if (string.IsNullOrWhiteSpace(barCodeCheckDto.unitNo)) + { + resultModel.Msg = "請輸入生產單位"; + return Ok(resultModel); + } - #region 宣告參數 - // 料號ID - int itemID = 0; - // 料號 - string item = string.Empty; - // 存放要更新BarCodeItem - var update_BarCodeItem = new List(); - var insert_BarCodeItemChange = new List(); - #endregion + if (barCodeCheckDto.station == 0) + { + resultModel.Msg = "請輸入作業站代碼"; + return Ok(resultModel); + } - // 抓流程ID - var q_wipinfo = await wipInfosController.GetWipInfoByWipNo(barCodeCheckDto.wipNo); - barCodeCheckDto.flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; + if (barCodeCheckDto.line == 0) + { + resultModel.Msg = "請輸入線別代碼"; + return Ok(resultModel); + } + #endregion - #region 判斷工單狀態 - resultModel = (ResultModel)await CheckWipNoSationAsync(wipNo: barCodeCheckDto.wipNo, unitNo: barCodeCheckDto.unitNo - , flowRuleID: barCodeCheckDto.flowRule, line: barCodeCheckDto.line, station: barCodeCheckDto.station); + #region 宣告各個Controller + WipInfosController wipInfosController = new WipInfosController(_context); + WipMACController wipMACController = new WipMACController(_context); + WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); + BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); + BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); + BarcodeItemChangesController barcodeItemChangesController = new BarcodeItemChangesController(_context); + RuleStationsController ruleStationsController = new RuleStationsController(_context); + MaterialKpController materialKpController = new MaterialKpController(_context); + #endregion - if (!resultModel.Success) - return resultModel; - #endregion + #region 宣告參數 + // 料號ID + int itemID = 0; + // 料號 + string item = string.Empty; + // 存放要更新BarCodeItem + var update_BarCodeItem = new List(); + var insert_BarCodeItemChange = new List(); + #endregion - #region 判斷序號狀態 - resultModel = (ResultModel)await GetCheckBarCodeStation(wipno: barCodeCheckDto.wipNo, barcode: barCodeCheckDto.barcode); - if (!resultModel.Success) - return resultModel; - #endregion + // 抓流程ID + var q_wipinfo = await wipInfosController.GetWipInfoByWipNo(barCodeCheckDto.wipNo); + barCodeCheckDto.flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; - #region 判斷序號流程 - resultModel = (ResultModel)await CheckBarCodeFlowAsync(wipno: barCodeCheckDto.wipNo, barcode: barCodeCheckDto.barcode - , unitno: barCodeCheckDto.unitNo, station: barCodeCheckDto.station); + #region 判斷工單狀態 + resultModel = (ResultModel)await CheckWipNoSationAsync(wipNo: barCodeCheckDto.wipNo, unitNo: barCodeCheckDto.unitNo + , flowRuleID: barCodeCheckDto.flowRule, line: barCodeCheckDto.line, station: barCodeCheckDto.station); - if (!resultModel.Success) - return resultModel; - #endregion + if (!resultModel.Success) + return resultModel; + #endregion - barCodeCheckDto.wipID = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().WipID; - barCodeCheckDto.flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; - barCodeCheckDto.barcodeID = BarCodeToID(barCodeCheckDto.barcode).Result; - item = q_wipinfo.Value.FirstOrDefault().GetWipAtt.ItemNO; - itemID = ItemNoToItemID(item).Result; + #region 判斷序號狀態 + resultModel = (ResultModel)await GetCheckBarCodeStation(wipno: barCodeCheckDto.wipNo, barcode: barCodeCheckDto.barcode); + if (!resultModel.Success) + return resultModel; + #endregion - // 抓RulseStationID - var q_rulestation = await ruleStationsController.GetRuleStationByFlow(barCodeCheckDto.flowRule, 0, 0); - barCodeCheckDto.ruleStationID = q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).FirstOrDefault().RuleStationID; + #region 判斷序號流程 + resultModel = (ResultModel)await CheckBarCodeFlowAsync(wipno: barCodeCheckDto.wipNo, barcode: barCodeCheckDto.barcode + , unitno: barCodeCheckDto.unitNo, station: barCodeCheckDto.station); - #region KeyParts 判斷 - if (barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Count() != 0) - { - var barcodeItemKPDto = new BarcodeItemKPDto - { - WipNo = barCodeCheckDto.wipNo, - barcode = barCodeCheckDto.barcode, - unitNo = barCodeCheckDto.unitNo, - inputKP = barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Select(s => s.inputData).ToList() - }; + if (!resultModel.Success) + return resultModel; + #endregion - var resultKeyParts = await CheckBarCodeKPAsync(barcodeItemKPDto); - if (!resultKeyParts.Success) - return (ResultModel)resultKeyParts; - } - #endregion + barCodeCheckDto.wipID = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().WipID; + barCodeCheckDto.flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; + barCodeCheckDto.barcodeID = BarCodeToID(barCodeCheckDto.barcode).Result; + item = q_wipinfo.Value.FirstOrDefault().GetWipAtt.ItemNO; + itemID = ItemNoToItemID(item).Result; - // 維修過站 組件需獨立判斷 - if (barCodeCheckDto.barcodeType == "S") - { - // 確認新舊組件序號是否都有值 - if (barCodeCheckDto.inputItems.Where(w => w.inputType != "NG" && - (string.IsNullOrWhiteSpace(w.inputData) || string.IsNullOrWhiteSpace(w.oldInputData))).Any()) + // 抓RulseStationID + var q_rulestation = await ruleStationsController.GetRuleStationByFlow(barCodeCheckDto.flowRule, 0, 0); + barCodeCheckDto.ruleStationID = q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).FirstOrDefault().RuleStationID; + + #region KeyParts 判斷 + if (barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Any()) { - resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】維修過站資料有缺新舊組件序號,請確認"; - return resultModel; + var barcodeItemKPDto = new BarcodeItemKPDto + { + WipNo = barCodeCheckDto.wipNo, + barcode = barCodeCheckDto.barcode, + unitNo = barCodeCheckDto.unitNo, + inputKP = barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Select(s => s.inputData).ToList() + }; + + var resultKeyParts = await CheckBarCodeKPAsync(barcodeItemKPDto); + if (!resultKeyParts.Success) + return (ResultModel)resultKeyParts; } + #endregion - // 用BarCodeID And WipID 取BarCodeItem + // 維修過站 組件需獨立判斷 + if (barCodeCheckDto.barcodeType == "S") + { + // 確認新舊組件序號是否都有值 + if (barCodeCheckDto.inputItems.Where(w => w.inputType != "NG" && + (string.IsNullOrWhiteSpace(w.inputData) || string.IsNullOrWhiteSpace(w.oldInputData))).Any()) + { + resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】維修過站資料有缺新舊組件序號,請確認"; + resultModel.Success = false; + return resultModel; + } - var q_BarCodeItem = await barcodeItemsController.GetBarcodeItemByBarCodeID(barCodeCheckDto.barcodeID); - q_BarCodeItem = q_BarCodeItem.Value.Where(w => w.WipID == barCodeCheckDto.wipID).ToList(); + // 用BarCodeID And WipID 取BarCodeItem - foreach (var KPs in barCodeCheckDto.inputItems) - { - // 用舊組件序號比對 - var barCodeItem = q_BarCodeItem.Value.Where(w => w.PartNo == KPs.oldInputData).FirstOrDefault(); + var q_BarCodeItem = await barcodeItemsController.GetBarcodeItemByBarCodeID(barCodeCheckDto.barcodeID); + q_BarCodeItem = q_BarCodeItem.Value.Where(w => w.WipID == barCodeCheckDto.wipID).ToList(); - if (barCodeItem != null) + foreach (var KPs in barCodeCheckDto.inputItems) { + // 用舊組件序號比對 + var barCodeItem = q_BarCodeItem.Value.Where(w => w.PartNo == KPs.oldInputData).FirstOrDefault(); - var MaterialKps = (await materialKpController.GetMaterialKpByItemID(itemID)).ToList(); - MaterialKps = MaterialKps.Where(w => w.StationType == barCodeCheckDto.unitNo).OrderBy(o => o.KpSeq).ToList(); - if (MaterialKps.Count == 0) + if (barCodeItem != null) { - resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】找不到相關Key Parts對應"; - } - else - { - var q_Kp = MaterialKps.Where(w => w.KpNo == barCodeItem.ItemNo).FirstOrDefault(); - if (q_Kp != null) - { - #region 比對序號長度是否正確 - if (!string.IsNullOrWhiteSpace(q_Kp.Length.ToString())) - { - if (q_Kp.Length != KPs.inputData.Length) - resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.KpName + "】長度不符合
"; - } - #endregion - #region 前置碼正確 - if (!string.IsNullOrWhiteSpace(q_Kp.Title)) - { - if (!KPs.inputData.ToUpper().StartsWith(q_Kp.Title.ToUpper())) - resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.Title + "】前置碼不符合
"; - } - #endregion - - #region 組件代碼-組件序號是否重複 - var checkDataRedundancy = await barcodeItemsController.GetBarcodeItemByDataRedundancy(q_Kp.KpNo, KPs.inputData); - if (checkDataRedundancy.Value.Count() != 0) - { - resultModel.Msg += "組件名稱【" + q_Kp.KpName + "】已有相同組件序號【" + KPs.inputData + "】紀錄
"; - } - #endregion - - #region 判斷組件序號是否在製狀態 - if (q_Kp.KpNo.ToUpper() == "04") + var MaterialKps = (await materialKpController.GetMaterialKpByItemID(itemID)).ToList(); + MaterialKps = MaterialKps.Where(w => w.StationType == barCodeCheckDto.unitNo).OrderBy(o => o.KpSeq).ToList(); + if (MaterialKps.Count == 0) + { + resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】找不到相關Key Parts對應"; + } + else + { + var q_Kp = MaterialKps.Where(w => w.KpNo == barCodeItem.ItemNo).FirstOrDefault(); + if (q_Kp != null) { + #region 比對序號長度是否正確 + if (!string.IsNullOrWhiteSpace(q_Kp.Length.ToString())) + { + if (q_Kp.Length != KPs.inputData.Length) + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.KpName + "】長度不符合
"; + } + #endregion - var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(KPs.inputData); - if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) + #region 前置碼正確 + if (!string.IsNullOrWhiteSpace(q_Kp.Title)) { - resultModel.Msg += "組件序號【" + KPs.inputData + "】 目前是在製狀態
"; + if (!KPs.inputData.ToUpper().StartsWith(q_Kp.Title.ToUpper())) + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.Title + "】前置碼不符合
"; } - } - #endregion + #endregion - #region 判斷MAC區間 - if (q_Kp.KpNo.ToUpper() == "94") - { + #region 組件代碼-組件序號是否重複 + var checkDataRedundancy = await barcodeItemsController.GetBarcodeItemByDataRedundancy(q_Kp.KpNo, KPs.inputData); + if (checkDataRedundancy.Value.Count() != 0) + { + resultModel.Msg += "組件名稱【" + q_Kp.KpName + "】已有相同組件序號【" + KPs.inputData + "】紀錄
"; + } + #endregion - var wipMAC = await wipMACController.GetWipMAC(barCodeCheckDto.wipNo); - if (wipMAC.Value == null) + #region 判斷組件序號是否在製狀態 + if (q_Kp.KpNo.ToUpper() == "04") { - resultModel.Msg += "工單號碼【" + barCodeCheckDto.wipNo + "】 找不到綁定MAC區間
"; + + var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(KPs.inputData); + if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) + { + resultModel.Msg += "組件序號【" + KPs.inputData + "】 目前是在製狀態
"; + } } - else + #endregion + + #region 判斷MAC區間 + if (q_Kp.KpNo.ToUpper() == "94") { - // 判斷MAC前置碼是否一樣 - if (!KPs.inputData.StartsWith(wipMAC.Value.Title)) + + var wipMAC = await wipMACController.GetWipMAC(barCodeCheckDto.wipNo); + if (wipMAC.Value == null) { - resultModel.Msg += "組件序號【" + KPs.inputData + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合
"; + resultModel.Msg += "工單號碼【" + barCodeCheckDto.wipNo + "】 找不到綁定MAC區間
"; } else { - // 判斷是否符合區間 - if (KPs.inputData.Length == 12) + // 判斷MAC前置碼是否一樣 + if (!KPs.inputData.StartsWith(wipMAC.Value.Title)) + { + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合
"; + } + else { - if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) - && Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) + // 判斷是否符合區間 + if (KPs.inputData.Length == 12) { - resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定MAC區間不符合
"; + if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) + && Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) + { + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定MAC區間不符合
"; + } } } } } - } - #endregion - - #region 判斷出貨序號 - // 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間 - if (q_Kp.KpNo.ToUpper() == "95") - { + #endregion - var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barCodeCheckDto.wipNo, KPs.inputData); - if (WipBarCodeOther.Value.Count() == 0) - { - resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定出貨序號區間不符合
"; - } - else + #region 判斷出貨序號 + // 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間 + if (q_Kp.KpNo.ToUpper() == "95") { - //resultModel.Data = new List { KPs.inputData }; - //resultModel.Msg = "EXT_NO"; + + var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barCodeCheckDto.wipNo, KPs.inputData); + if (WipBarCodeOther.Value.Count() == 0) + { + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定出貨序號區間不符合
"; + } + else + { + //resultModel.Data = new List { KPs.inputData }; + //resultModel.Msg = "EXT_NO"; + } } + #endregion } - #endregion } - } - barCodeItem.PartNo = KPs.inputData; - barCodeItem.RuleStationID = barCodeCheckDto.ruleStationID; - barCodeItem.UpdateDate = DateTime.Now; - update_BarCodeItem.Add(barCodeItem); + barCodeItem.PartNo = KPs.inputData; + barCodeItem.RuleStationID = barCodeCheckDto.ruleStationID; + barCodeItem.UpdateDate = DateTime.Now; + update_BarCodeItem.Add(barCodeItem); - insert_BarCodeItemChange.Add(new BarcodeItemChange - { - WipID = barCodeCheckDto.wipID, - RuleStationID = barCodeCheckDto.ruleStationID, - BarcodeID = barCodeCheckDto.barcodeID, - ItemNo = barCodeItem.ItemNo, - PartNoOld = KPs.oldInputData, - ChangeType = "RP", - KpItemNo = KPs.inputData - }); + insert_BarCodeItemChange.Add(new BarcodeItemChange + { + WipID = barCodeCheckDto.wipID, + RuleStationID = barCodeCheckDto.ruleStationID, + BarcodeID = barCodeCheckDto.barcodeID, + ItemNo = barCodeItem.ItemNo, + PartNoOld = KPs.oldInputData, + ChangeType = "RP", + KpItemNo = KPs.inputData + }); + } } + + if (!string.IsNullOrWhiteSpace(resultModel.Msg)) + return resultModel; } - if (!string.IsNullOrWhiteSpace(resultModel.Msg)) - return resultModel; - } + //var NextStopCloseStation = await CheckNextStopCloseStation(barCodeCheckDto.wipNo, barCodeCheckDto.unitNo, barCodeCheckDto.station); - //var NextStopCloseStation = await CheckNextStopCloseStation(barCodeCheckDto.wipNo, barCodeCheckDto.unitNo, barCodeCheckDto.station); + // 過站判斷正常 往下處理Table - // 過站判斷正常 往下處理Table + #region 內部序號輸入後新增 or 更新 + if (barCodeCheckDto.inputItems.Where(w => w.inputData.Contains("$")).Count() != 0) + barCodeCheckDto.ruleStatus = "F"; + else + barCodeCheckDto.ruleStatus = "P"; - #region 內部序號輸入後新增 or 更新 - if (barCodeCheckDto.inputItems.Where(w => w.inputData.Contains("$")).Count() != 0) - barCodeCheckDto.ruleStatus = "F"; - else - barCodeCheckDto.ruleStatus = "P"; + CU_Tables(barCodeCheckDto); - CU_Tables(barCodeCheckDto); + //var barcodeInfo = barcodeInfoesController.GetBarcodeInfoes(barCodeCheckDto.barcodeID).Result.Value.FirstOrDefault(); + //barcodeInfo.RuleStationID = barCodeCheckDto.ruleStationID; + //barcodeInfo.RuleStatus = "P"; - //var barcodeInfo = barcodeInfoesController.GetBarcodeInfoes(barCodeCheckDto.barcodeID).Result.Value.FirstOrDefault(); - //barcodeInfo.RuleStationID = barCodeCheckDto.ruleStationID; - //barcodeInfo.RuleStatus = "P"; + //var resultBarCodeInfo = await barcodeInfoesController.PutBarcodeInfoes(barcodeInfo); + //if (resultBarCodeInfo.Success) + //{ + // // 新增 BarCodeStation + // BarcodeStation barcodeStation = new BarcodeStation + // { + // BarcodeID = barCodeCheckDto.barcodeID, + // WipID = barCodeCheckDto.wipID, + // RuleStationID = barCodeCheckDto.ruleStationID, + // RuleStatus = "P", //F 不良 + // InputDate = DateTime.Now, + // LineId = barCodeCheckDto.line + // }; + // await barcodeStationController.PostBarcodeStation(barcodeStation); + + // // 新增 BarCodeItem + // // 先查詢已綁定組件數量 + // //var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCodeID(model.BarCodeID); + // //int KpItemQty = BarCodeItems.Count(); + + // foreach (var item_barCodeItem in update_BarCodeItem) + // { + // await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem); + // } + + // foreach (var item_barCodeItemChange in insert_BarCodeItemChange) + // { + // await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange); + // } + + + // #endregion + // #endregion + //} - //var resultBarCodeInfo = await barcodeInfoesController.PutBarcodeInfoes(barcodeInfo); - //if (resultBarCodeInfo.Success) - //{ - // // 新增 BarCodeStation - // BarcodeStation barcodeStation = new BarcodeStation - // { - // BarcodeID = barCodeCheckDto.barcodeID, - // WipID = barCodeCheckDto.wipID, - // RuleStationID = barCodeCheckDto.ruleStationID, - // RuleStatus = "P", //F 不良 - // InputDate = DateTime.Now, - // LineId = barCodeCheckDto.line - // }; - // await barcodeStationController.PostBarcodeStation(barcodeStation); - - // // 新增 BarCodeItem - // // 先查詢已綁定組件數量 - // //var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCodeID(model.BarCodeID); - // //int KpItemQty = BarCodeItems.Count(); - - // foreach (var item_barCodeItem in update_BarCodeItem) - // { - // await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem); - // } - - // foreach (var item_barCodeItemChange in insert_BarCodeItemChange) - // { - // await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange); - // } - - - // #endregion - // #endregion - //} + foreach (var item_barCodeItem in update_BarCodeItem) + { + await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem); + } - foreach (var item_barCodeItem in update_BarCodeItem) - { - await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem); - } + foreach (var item_barCodeItemChange in insert_BarCodeItemChange) + { + await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange); + } - foreach (var item_barCodeItemChange in insert_BarCodeItemChange) + resultModel.Msg = "內部序號【" + barCodeCheckDto.barcode + "】 過站完成!"; + resultModel.Success = true; + return resultModel; + #endregion + } + catch (Exception ex) { - await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange); + resultModel.Success = false; + resultModel.Msg = ex.Message; + return resultModel; } - - resultModel.Msg = "內部序號【" + barCodeCheckDto.barcode + "】 過站完成!"; - resultModel.Success = true; - return resultModel; - #endregion } #endregion @@ -375,52 +392,59 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } - if (!Table_BarcodeStation(barCodeCheckDto).Result.Success) + if (!Table_BarcodeWip(barCodeCheckDto).Result.Success) { } - if (!Table_BarcodeItem(barCodeCheckDto).Result.Success) + if (!Table_WipStation(barCodeCheckDto).Result.Success) { } - if (!Table_NgInfo(barCodeCheckDto).Result.Success) + if (!Table_WipClass(barCodeCheckDto).Result.Success) { } - if (!Table_BarcodeWip(barCodeCheckDto).Result.Success) + if (!Table_WipTime(barCodeCheckDto).Result.Success) { } - if (!Table_WipStation(barCodeCheckDto).Result.Success) + if (!Table_BarcodeStation(barCodeCheckDto).Result.Success) { } - if (!Table_WipClass(barCodeCheckDto).Result.Success) + if (!Table_BarcodeItem(barCodeCheckDto).Result.Success) { } - if (!Table_WipTime(barCodeCheckDto).Result.Success) + if (!Table_NgInfo(barCodeCheckDto).Result.Success) { } + + + + // 工單基本檔案 + //if (!Table_WipInfo(barCodeCheckDto).Result.Success) + //{ + + //} } /// - /// BarcodeInfo-條碼資料檔 + /// WipInfo-工單基本資料 /// /// /// private async Task> Table_WipInfo(BarCodeCheckDto barCodeCheckDto) { WipInfosController wipInfosController = new WipInfosController(_context); - var wipinfo = wipInfosController.GetWipInfo(barCodeCheckDto.wipID) - .Result.Value.FirstOrDefault(); + var wipinfo = await _context.WipInfos.FindAsync(barCodeCheckDto.wipID); return await wipInfosController.PutWipinfo(wipinfo);