diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 7632a71d..cb30bcb1 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -7502,8 +7502,9 @@ namespace AMESCoreStudio.Web.Controllers string seq = ids[i].Split(',')[2]; string recordNumber = ids[i].Split(',')[3]; string locationNo = ids[i].Split(',')[4]; - string Factority_ID = ids[i].Split(',')[5]; - var result = await PCS0311inhouse(InhouseNo, boxNo, Convert.ToInt16(seq), recordNumber, locationNo, Factority_ID); + string recordDate = ids[i].Split(',')[5]; + string Factority_ID = ids[i].Split(',')[6]; + var result = await PCS0311inhouse(InhouseNo, boxNo, Convert.ToInt16(seq), recordNumber, locationNo, recordDate,Factority_ID); if (!result.success) { @@ -7520,9 +7521,9 @@ namespace AMESCoreStudio.Web.Controllers } } - public async Task PCS031inhouseAsync(string InhouseNo, string boxNo, int seq, string recordNumber, string locationNo, string factorityID) + public async Task PCS031inhouseAsync(string InhouseNo, string boxNo, int seq, string recordNumber, string locationNo, string recordDate, string factorityID) { - var result = await PCS0311inhouse(InhouseNo, boxNo, seq, recordNumber, locationNo, factorityID); + var result = await PCS0311inhouse(InhouseNo, boxNo, seq, recordNumber, locationNo, recordDate, factorityID); return Json(new Result() { success = result.success, msg = result.msg }); @@ -7530,7 +7531,7 @@ namespace AMESCoreStudio.Web.Controllers } - private async Task PCS0311inhouse(string InhouseNo, string boxNo, int seq, string recordNumber, string locationNo, string factorityID) + private async Task PCS0311inhouse(string InhouseNo, string boxNo, int seq, string recordNumber, string locationNo, string recordDate, string factorityID) { /* 1.先查詢是否已入庫過 * 2.依barcodeinfo 查詢 該箱號所屬序號 @@ -7538,8 +7539,6 @@ namespace AMESCoreStudio.Web.Controllers * 4.若有序號不可入庫 => 畫面顯示不可入之序號 * 5.所有序號可入庫 = > */ - string _msgTmp = string.Empty; - var result1 = new List(); if (factorityID == "1") { @@ -7547,7 +7546,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"GetWareHouseing_EVER {InhouseNo} {seq}
"; result1 = await _pcsApi.GetWareHouseing_EVER(inhouseNo: InhouseNo, seq: seq); } @@ -7566,7 +7564,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"GetBarcodeInfoesByBoxNo_EVER {boxNo}
"; result = await _pcsApi.GetBarcodeInfoesByBoxNo_EVER(boxNo: boxNo); } @@ -7632,7 +7629,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"GetFlowRulesByUnit_EVER W
"; FlowRules_result = await _pcsApi.GetFlowRulesByUnit_EVER("W"); } @@ -7646,7 +7642,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"GetRuleStationByFlowRuleID_EVER {FlowRuleID}
"; ruleStations_result = await GetRuleStationByFlowRuleID_EVER(FlowRuleID); } @@ -7661,7 +7656,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"GetWipInfo_EVER {result.Select(s => s.WipID).First()}
"; Wipinfo_result = await _pcsApi.GetWipInfo_EVER(result.Select(s => s.WipID).First()); } @@ -7673,7 +7667,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"GetWipAtt_EVER {Wipinfo_result.Select(s => s.WipNO).First()} < br>"; WipAtt_result = await _pcsApi.GetWipAtt_EVER(Wipinfo_result.Select(s => s.WipNO).First()); //料號 } var Userinfo_result = new List(); @@ -7685,10 +7678,8 @@ namespace AMESCoreStudio.Web.Controllers { int UserID = GetLogInUserID(); //需用安勤帳號查昶亨的帳號 再轉換成ID var Userinfo = await _sysApi.GetUserInfo(UserID); - _msgTmp += $"GetUserInfoByUserNo_EVER {Userinfo.Select(s => s.UserNo).FirstOrDefault()} < br>"; var Userinfo_EVER = await _pcsApi.GetUserInfoByUserNo_EVER(Userinfo.Select(s => s.UserNo).FirstOrDefault()); if (Userinfo_EVER.UserNo != null ) - _msgTmp += $"GetUserInfo_EVER {Userinfo_EVER.UserID} < br>"; Userinfo_result = await _pcsApi.GetUserInfo_EVER(Userinfo_EVER.UserID); } @@ -7702,7 +7693,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"GetFqcInhouseMaster_EVER {InhouseNo} {seq} < br>"; fqcInhouseMaster = await _pcsApi.GetFqcInhouseMaster_EVER(InhouseNo, seq); } fqcInhouseMaster.LocationNo = locationNo; @@ -7715,7 +7705,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"PutFqcInhouseMaster_EVER {JsonConvert.SerializeObject(fqcInhouseMaster)} < br>"; result_FQC = await _pcsApi.PutFqcInhouseMaster_EVER(JsonConvert.SerializeObject(fqcInhouseMaster)); } @@ -7753,7 +7742,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"PutBarcodeInfoes_EVER {JsonConvert.SerializeObject(barcodeInfo)} < br>"; resultPutBInfo = await _pcsApi.PutBarcodeInfoes_EVER(JsonConvert.SerializeObject(barcodeInfo)); } @@ -7795,7 +7783,7 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"PostBarcodeStation_EVER {JsonConvert.SerializeObject(barcodeStations)} < br>"; + resultPoutBStation = await _pcsApi.PostBarcodeStation_EVER(JsonConvert.SerializeObject(barcodeStations)); } if (!resultPoutBStation.Success) @@ -7814,7 +7802,8 @@ namespace AMESCoreStudio.Web.Controllers PN = WipAtt_result.ItemNO, EmpID = Userinfo_result.Select(s => s.UserNo).FirstOrDefault(), Location = AppSetting.Setting.Location, - Key = AppSetting.Setting.PTD101Key + Key = AppSetting.Setting.PTD101Key, + RecordDate = recordDate + " 01:00:00" }); @@ -7831,7 +7820,8 @@ namespace AMESCoreStudio.Web.Controllers RecordNumber = recordNumber, Create_UserID = Userinfo_result.Select(s => s.UserID).FirstOrDefault(), Create_Date = DateTime.Now, - LocationNo = locationNo + LocationNo = locationNo, + Record_Date = Convert.ToDateTime(recordDate + " 01:00:00") }; var resultPostWH = new ResultModel(); if (factorityID == "1") @@ -7840,7 +7830,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - _msgTmp += $"PostWareHouseing_EVER {JsonConvert.SerializeObject(Warehouseing)} < br>"; resultPostWH = await _pcsApi.PostWareHouseing_EVER(JsonConvert.SerializeObject(Warehouseing)); } @@ -7872,18 +7861,18 @@ namespace AMESCoreStudio.Web.Controllers } else { - return new Result() { success = false, msg = _msg + "1 "+_msgTmp }; + return new Result() { success = false, msg = _msg }; } } else { - return new Result() { success = false, msg = _msg + "2_"+ _msgTmp }; + return new Result() { success = false, msg = _msg }; } } catch (Exception ex) { _msg = ex.ToString(); - return new Result() { success = false, msg = _msg + "3_"+ _msgTmp }; + return new Result() { success = false, msg = _msg }; } } @@ -9096,7 +9085,7 @@ namespace AMESCoreStudio.Web.Controllers if (result1.Select(s => s.SnNum).FirstOrDefault() > EndNO) { - return Json(new Result() { success = false, msg = "工單序號不為目前最大號,請先刪除其他工單" }); + return Json(new Result() { success = false, msg = "工單號碼【" + id + "】出貨序號不為目前最大號,請先刪除最大號工單 !" }); } else { @@ -9284,28 +9273,79 @@ namespace AMESCoreStudio.Web.Controllers } else { - // 判斷是否需要同步更新 + //取相同Rule 年、月、周 的所有料號 var result1 = await _pcsApi.GetSerialRuleDetail(model.WipBarcodeOther.SerialRuleDetailID); + var q_Detail = await _pcsApi.GetSerialRuleDetailbyPCS040(model.WipBarcodeOther.SerialRuleDetailID); + var SerialRuleDetail_All = q_Detail.Where(w => w.Rule == result1.Select(s=>s.Rule).FirstOrDefault() + && w.YNum == result1.Select(s => s.YNum).FirstOrDefault() && w.MNum == result1.Select(s => s.MNum).FirstOrDefault() + && w.WNum == result1.Select(s => s.WNum).FirstOrDefault() && w.LotNum == result1.Select(s => s.LotNum).FirstOrDefault()); + int Max_SnNum = 0; + + if (!model.SerialRuleItem.StartsWith("OTHER")) + { + //抓取所有相同參數的值 + Max_SnNum = SerialRuleDetail_All.Max(s => s.SnNum); //抓取相同參數的SN_Num 最大數值取值,避免有不一致一情況 + } + else + { + Max_SnNum = result1.Select(s => s.SnNum).FirstOrDefault(); + } + //判斷工單結束序號流水號號碼 int modelEndNO = int.Parse(model.WipBarcodeOther.EndNO.Substring(SNStart, SNLen)); //判斷是否有比此工單流水號更大的號碼 - if (result1.Select(s => s.SnNum).FirstOrDefault() <= modelEndNO) + if (Max_SnNum <= modelEndNO) { + #region OTHER 不需改其他相同規則 - SerialRuleDetail model1 = new SerialRuleDetail + if (model.SerialRuleItem.StartsWith("OTHER")) { - SerialRuleDetailID = result1.Select(s => s.SerialRuleDetailID).FirstOrDefault(), - ItemNo = result1.Select(s => s.ItemNo).FirstOrDefault(), - Rule = result1.Select(s => s.Rule).FirstOrDefault(), - YNum = result1.Select(s => s.YNum).FirstOrDefault(), - MNum = result1.Select(s => s.MNum).FirstOrDefault(), - WNum = result1.Select(s => s.WNum).FirstOrDefault(), - LotNum = result1.Select(s => s.LotNum).FirstOrDefault(), - SnNum = InputEndNoQty - }; - var resultPut = await _pcsApi.PutSerialRuleDetail(result1.Select(s => s.SerialRuleDetailID).FirstOrDefault(), JsonConvert.SerializeObject(model1)); + //需更新其他相同Rule 的最大號mark + SerialRuleDetail model1 = new SerialRuleDetail + { + SerialRuleDetailID = result1.Select(s => s.SerialRuleDetailID).FirstOrDefault(), + ItemNo = result1.Select(s => s.ItemNo).FirstOrDefault(), + Rule = result1.Select(s => s.Rule).FirstOrDefault(), + YNum = result1.Select(s => s.YNum).FirstOrDefault(), + MNum = result1.Select(s => s.MNum).FirstOrDefault(), + WNum = result1.Select(s => s.WNum).FirstOrDefault(), + LotNum = result1.Select(s => s.LotNum).FirstOrDefault(), + SnNum = InputEndNoQty, + }; + var resultPut = await _pcsApi.PutSerialRuleDetail(result1.Select(s => s.SerialRuleDetailID).FirstOrDefault(), JsonConvert.SerializeObject(model1)); + #endregion + } + else + { + #region 同步更改其他相同Rule、YY、MM、WW、Lot 的最大值流水號SN_Num (不同item會有相同rule,且流水號為累加) + foreach (var item in SerialRuleDetail_All) + { + SerialRuleDetail model1 = new SerialRuleDetail + { + SerialRuleDetailID = item.SerialRuleDetailID, + ItemNo = item.ItemNo, + Rule = item.Rule, + YNum = item.YNum, + MNum = item.MNum, + WNum = item.WNum, + LotNum = item.LotNum, + SnNum = InputEndNoQty, + }; + var resultPut = await _pcsApi.PutSerialRuleDetail(result1.Select(s => s.SerialRuleDetailID).FirstOrDefault(), JsonConvert.SerializeObject(model1)); + + } + #endregion + } + + } + else + { + + _msg += "工單號碼【" + model.WipInfo.WipNO + "】出貨序號不為目前最大號,請先刪除最大號工單 !"; + ModelState.AddModelError("error", _msg); + return View(model); } //if (WipQty < (InputEndNoQty - InputStrNoQty + 1)) @@ -9332,7 +9372,7 @@ namespace AMESCoreStudio.Web.Controllers // return RedirectToAction("PCS040", "PCS", new { wipNo = model.WipInfo.WipNO, msg = _msg }); return RedirectToAction("Refresh", "Home", new { wipNo = model.WipInfo.WipNO, msg = _msg }); // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - return Json(new Result() { success = true, msg = _msg }); + // return Json(new Result() { success = true, msg = _msg }); } else { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 183b0e5f..f54acfba 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -1775,7 +1775,10 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/SerialRuleDetails/{id}")] ITask> GetSerialRuleDetail(int id); + [WebApiClient.Attributes.HttpGet("api/SerialRuleDetails/SerialRuleDetailbyPCS040/{id}}")] + ITask> GetSerialRuleDetailbyPCS040(int id); + /// /// 查詢SerialRuleDetail /// diff --git a/AMESCoreStudio.Web/Views/PCS/PCS031.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS031.cshtml index 731eb3bf..35825e2b 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS031.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS031.cshtml @@ -417,7 +417,7 @@ hg.confirm("批量入庫所有选中的数据,確定要入庫吗?", function () { $.ajax({ url: '/PCS/PCS031inhouse_all', - data: { ids: obj.checkstatus.data.map(function (x) { return x.inhouseNo + "," + x.serialNo + "," + x.seqID + "," + recordmumber + "," + x.locationNo + "," + Factority_ID + "," +recorddate }) }, + data: { ids: obj.checkstatus.data.map(function (x) { return x.inhouseNo + "," + x.serialNo + "," + x.seqID + "," + recordmumber + "," + x.locationNo + "," + recorddate + "," +Factority_ID }) }, type: 'POST', success: function (data) { if (data.success) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesDetailController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesDetailController.cs index d354b169..25b8d01c 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesDetailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesDetailController.cs @@ -67,6 +67,24 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } + /// + /// 出貨序號編碼規則基本資料檔 to SerialRuleDetailID + /// + /// SerialRuleDetailID + /// + [HttpGet("SerialRuleDetailbyPCS040/{id}")] + public async Task>> GetSerialRuleDetailbyPCS040(int id) + { + IQueryable q = _context.SerialRuleDetails; + + var SerialRuleDetail = await q.Where(p => p.SerialRuleDetailID == id).FirstOrDefaultAsync(); + var SerialRuleDetail_ALL = await q.Where(w => w.Rule == SerialRuleDetail.Rule && w.YNum == SerialRuleDetail.YNum && w.MNum == SerialRuleDetail.MNum && w.WNum == SerialRuleDetail.WNum && w.LotNum == SerialRuleDetail.LotNum).ToListAsync(); + return SerialRuleDetail_ALL; + } + + + + /// /// 新增料號基本資料檔 ///