|
|
@ -469,7 +469,170 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 確認組件狀態
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
|
/// <param name="barcode">內部條碼</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("BarCodeKP")] |
|
|
|
public async Task<IResultModel> CheckBarCodeKPAsync(string wipno, string barcode) |
|
|
|
{ |
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
|
|
|
|
#region 判斷是否有工單
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
var q = await wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
|
if (q.Value.Count() == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "找不到工單號碼【" + wipno + "】"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷是否有輸入工單料號
|
|
|
|
WipAttsController wipAttsController = new WipAttsController(_context); |
|
|
|
string ItemNo = (await wipAttsController.GetWipAtt(q.Value.FirstOrDefault().WipNO)).Value.ItemNO; |
|
|
|
if (string.IsNullOrWhiteSpace(ItemNo)) |
|
|
|
{ |
|
|
|
resultModel.Msg = "工單號碼【" + wipno + "】,找不到料號名稱"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷工單料號是否有在料號基本檔
|
|
|
|
MaterialItemController materialItemController = new MaterialItemController(_context); |
|
|
|
var MaterialItem = await materialItemController.GetMaterialItemByItemNO(ItemNo); |
|
|
|
if (MaterialItem == null) |
|
|
|
{ |
|
|
|
resultModel.Msg = "料號【" + ItemNo + "】,在料號基本資料檔找不到"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 確認是否有設定key Parts資料
|
|
|
|
MaterialKpController materialKpController = new MaterialKpController(_context); |
|
|
|
var MaterialKps = (await materialKpController.GetMaterialKpByItemID(MaterialItem.ItemID)).ToList(); |
|
|
|
|
|
|
|
if (MaterialKps.Count != 0) |
|
|
|
{ |
|
|
|
#region 判斷內部序號是否有過站紀錄
|
|
|
|
var BarCodeID = await BarCodeToID(barcode); |
|
|
|
if (BarCodeID == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "內部序號【" + barcode + "】,在條碼資料檔找不到"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件序號是否有紀錄
|
|
|
|
BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); |
|
|
|
var BarCodeItems = (await barcodeItemsController.GetBarcodeItems(BarCodeID)).Value.ToList(); |
|
|
|
if (BarCodeItems.Count == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "內部序號【" + barcode + "】,在條碼組件件資料檔找不到"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件數量是否正確
|
|
|
|
if (MaterialKps.Count != BarCodeItems.Count) |
|
|
|
{ |
|
|
|
resultModel.Msg = "組件對應數量【" + MaterialKps.Count + "】不等於條碼組件數量【" + BarCodeItems.Count + "】"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 比對組件資料
|
|
|
|
var CheckMsg = string.Empty; |
|
|
|
for (int i = 0; i < MaterialKps.Count; i++) |
|
|
|
{ |
|
|
|
#region 比對序號長度是否正確
|
|
|
|
if (string.IsNullOrWhiteSpace(MaterialKps[i].Length.ToString())) |
|
|
|
{ |
|
|
|
if (MaterialKps[i].Length != BarCodeItems[i].PartNo.Length) |
|
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 與組件名稱【" + MaterialKps[i].KpName + "】長度不符合</br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 前置碼正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(MaterialKps[i].Title)) |
|
|
|
{ |
|
|
|
if (!BarCodeItems[i].KpItemNo.ToUpper().StartsWith(MaterialKps[i].Title.ToUpper())) |
|
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 與組件名稱【" + MaterialKps[i].Title + "】前置碼不符合</br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
|
if (MaterialKps[i].KpName.ToUpper() == "BOARD") |
|
|
|
{ |
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(BarCodeItems[i].PartNo); |
|
|
|
if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 目前是在製狀態</br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷MAC區間
|
|
|
|
if (MaterialKps[i].KpName.ToUpper() == "MAC") |
|
|
|
{ |
|
|
|
WipMACController wipMACController = new WipMACController(_context); |
|
|
|
var wipMAC = await wipMACController.GetWipMAC(wipno); |
|
|
|
if (wipMAC.Value == null) |
|
|
|
{ |
|
|
|
CheckMsg += "工單號碼【" + wipno + "】 找不到綁定MAC區間</br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// 判斷MAC前置碼是否一樣
|
|
|
|
if (!BarCodeItems[i].PartNo.StartsWith(wipMAC.Value.Title)) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合 </br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// 判斷是否符合區間
|
|
|
|
if (BarCodeItems[i].PartNo.Length == 12) |
|
|
|
{ |
|
|
|
if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(BarCodeItems[i].PartNo.Substring(7, 6), 16) |
|
|
|
&& Convert.ToInt32(BarCodeItems[i].PartNo.Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 與工單設定MAC區間不符合 </br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷出貨序號
|
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
|
if (MaterialKps[i].KpName.ToUpper() == "EXT_NO") |
|
|
|
{ |
|
|
|
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); |
|
|
|
var WipBarCodeOther = await wipBarcodeOtherController.GetWipBarcodeOtherByWipNo(wipno); |
|
|
|
if (WipBarCodeOther.Value != null) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(CheckMsg)) |
|
|
|
{ |
|
|
|
resultModel.Msg = CheckMsg; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
resultModel.Success = true; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 內部序號找BarCodeID
|
|
|
|
/// </summary>
|
|
|
|