|
|
@ -159,6 +159,10 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 治具判斷
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
// 維修過站 組件需獨立判斷
|
|
|
@ -448,6 +452,11 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//if (!Table_BarcodeOutfit(barCodeCheckDto).Result.Success)
|
|
|
|
//{
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (!Table_NgInfo(barCodeCheckDto).Result.Success) |
|
|
|
{ |
|
|
|
|
|
|
@ -539,7 +548,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// NgInfo-組件资料
|
|
|
|
/// BarcodeItem-組件资料
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="barCodeCheckDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
@ -569,6 +578,36 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
return resut; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// BarcodeOutfit-治具资料
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="barCodeCheckDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<ResultModel<BarcodeOutfit>> Table_BarcodeOutfit(BarCodeCheckDto barCodeCheckDto) |
|
|
|
{ |
|
|
|
BarcodeOutfitController barcodeOutfitController = new BarcodeOutfitController(_context); |
|
|
|
var OutfitsItem = barCodeCheckDto.outfits; |
|
|
|
var resut = new ResultModel<BarcodeOutfit>(); |
|
|
|
// 新增 BarCodeStation
|
|
|
|
foreach (var item in OutfitsItem) |
|
|
|
{ |
|
|
|
var barcodeOutfit = new BarcodeOutfit |
|
|
|
{ |
|
|
|
BarcodeNo = barCodeCheckDto.barcode, |
|
|
|
WipNo = barCodeCheckDto.wipNo, |
|
|
|
OutfitNo = item.inputData, |
|
|
|
StationID = barCodeCheckDto.station, |
|
|
|
CreateUserID = 0, |
|
|
|
CreateDate = DateTime.Now, |
|
|
|
UpdateUserID = 0, |
|
|
|
UpdateDate = DateTime.Now |
|
|
|
}; |
|
|
|
await barcodeOutfitController.PostBarcodeOutfit(barcodeOutfit); |
|
|
|
} |
|
|
|
|
|
|
|
return resut; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// NgInfo-測試不良基本資料檔
|
|
|
|
/// </summary>
|
|
|
@ -1263,168 +1302,198 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
public async Task<IResultModel> CheckBarCodeKPAsync([FromQuery] BarcodeItemKPDto barcodeItemKPDto) |
|
|
|
{ |
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
|
|
|
|
#region 判斷是否有工單
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
var q = await wipInfosController.GetWipInfoByWipNo(barcodeItemKPDto.WipNo); |
|
|
|
q = q.Value.Where(w => w.UnitNO == barcodeItemKPDto.unitNo).ToList(); |
|
|
|
if (q.Value.Count() == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "找不到工單號碼【" + barcodeItemKPDto.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 = "工單號碼【" + barcodeItemKPDto.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資料
|
|
|
|
WipKpsController wipKpsController = new WipKpsController(_context); |
|
|
|
var wipKps = (await wipKpsController.GetWipKpByWipNo(barcodeItemKPDto.WipNo)).Value.ToList(); |
|
|
|
wipKps = wipKps.Where(w => w.UnitNo == barcodeItemKPDto.unitNo).OrderBy(o => o.KpSeq).ToList(); |
|
|
|
if (wipKps.Count != 0) |
|
|
|
try |
|
|
|
{ |
|
|
|
#region 判斷內部序號是否有過站紀錄
|
|
|
|
var BarCodeID = await BarCodeToID(barcodeItemKPDto.barcode); |
|
|
|
//if (BarCodeID == 0)
|
|
|
|
//{
|
|
|
|
// resultModel.Msg = "內部序號【" + barcode + "】,在條碼資料檔找不到";
|
|
|
|
// return resultModel;
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件序號是否有紀錄
|
|
|
|
BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); |
|
|
|
var BarCodeItems = (await barcodeItemsController.GetBarcodeItemByBarCodeID(BarCodeID)).Value.ToList(); |
|
|
|
BarCodeItems = BarCodeItems.Where(w => w.WipID == q.Value.FirstOrDefault().WipID).ToList(); |
|
|
|
#region 判斷是否有工單
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
var q = await wipInfosController.GetWipInfoByWipNo(barcodeItemKPDto.WipNo); |
|
|
|
q = q.Value.Where(w => w.UnitNO == barcodeItemKPDto.unitNo).ToList(); |
|
|
|
if (q.Value.Count() == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "找不到工單號碼【" + barcodeItemKPDto.WipNo + "】"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
// 計算過站時刷的組件數量與已經存BarCodeItems
|
|
|
|
var KPQty = barcodeItemKPDto.inputKP.Count + BarCodeItems.Count; |
|
|
|
#region 刷入組件數量超過
|
|
|
|
if (KPQty > wipKps.Count) |
|
|
|
#region 判斷是否有輸入工單料號
|
|
|
|
WipAttsController wipAttsController = new WipAttsController(_context); |
|
|
|
string ItemNo = (await wipAttsController.GetWipAtt(q.Value.FirstOrDefault().WipNO)).Value.ItemNO; |
|
|
|
if (string.IsNullOrWhiteSpace(ItemNo)) |
|
|
|
{ |
|
|
|
resultModel.Msg = "組件數量已刷超過設定數量,請確認"; |
|
|
|
resultModel.Msg = "工單號碼【" + barcodeItemKPDto.WipNo + "】,找不到料號名稱"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 比對組件資料
|
|
|
|
var CheckMsg = string.Empty; |
|
|
|
int x = BarCodeItems.Count; |
|
|
|
#region 判斷工單料號是否有在料號基本檔
|
|
|
|
MaterialItemController materialItemController = new MaterialItemController(_context); |
|
|
|
var MaterialItem = await materialItemController.GetMaterialItemByItemNO(ItemNo); |
|
|
|
if (MaterialItem == null) |
|
|
|
{ |
|
|
|
resultModel.Msg = "料號【" + ItemNo + "】,在料號基本資料檔找不到"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
for (int i = 0; i < barcodeItemKPDto.inputKP.Count; i++) |
|
|
|
#region 確認是否有設定key Parts資料
|
|
|
|
WipKpsController wipKpsController = new WipKpsController(_context); |
|
|
|
var wipKps = (await wipKpsController.GetWipKpByWipNo(barcodeItemKPDto.WipNo)).Value.ToList(); |
|
|
|
wipKps = wipKps.Where(w => w.UnitNo == barcodeItemKPDto.unitNo).OrderBy(o => o.KpSeq).ToList(); |
|
|
|
if (wipKps.Count != 0) |
|
|
|
{ |
|
|
|
#region 比對序號長度是否正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(wipKps[x + i].Length.ToString())) |
|
|
|
{ |
|
|
|
if (wipKps[x + i].Length != barcodeItemKPDto.inputKP[i].Length) |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與組件名稱【" + wipKps[x + i].KpName + "】長度不符合</br>"; |
|
|
|
} |
|
|
|
#region 判斷內部序號是否有過站紀錄
|
|
|
|
var BarCodeID = await BarCodeToID(barcodeItemKPDto.barcode); |
|
|
|
//if (BarCodeID == 0)
|
|
|
|
//{
|
|
|
|
// resultModel.Msg = "內部序號【" + barcode + "】,在條碼資料檔找不到";
|
|
|
|
// return resultModel;
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 前置碼正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(wipKps[x + i].Title)) |
|
|
|
{ |
|
|
|
if (!barcodeItemKPDto.inputKP[i].ToUpper().StartsWith(wipKps[x + i].Title.ToUpper())) |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與組件名稱【" + wipKps[x + i].Title + "】前置碼不符合</br>"; |
|
|
|
} |
|
|
|
#region 判斷組件序號是否有紀錄
|
|
|
|
BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); |
|
|
|
var BarCodeItems = (await barcodeItemsController.GetBarcodeItemByBarCodeID(BarCodeID)).Value.ToList(); |
|
|
|
BarCodeItems = BarCodeItems.Where(w => w.WipID == q.Value.FirstOrDefault().WipID).ToList(); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 組件代碼-組件序號是否重複
|
|
|
|
var checkDataRedundancy = await barcodeItemsController.GetBarcodeItemByDataRedundancy(wipKps[x + i].KpNo, barcodeItemKPDto.inputKP[i]); |
|
|
|
if (checkDataRedundancy.Value.Count() != 0) |
|
|
|
// 計算過站時刷的組件數量與已經存BarCodeItems
|
|
|
|
var KPQty = barcodeItemKPDto.inputKP.Count + BarCodeItems.Count; |
|
|
|
#region 刷入組件數量超過
|
|
|
|
if (KPQty > wipKps.Count) |
|
|
|
{ |
|
|
|
CheckMsg += "組件名稱【" + wipKps[x + i].KpName + "】已有相同組件序號【" + barcodeItemKPDto.inputKP[i] + "】紀錄 </br>"; |
|
|
|
resultModel.Msg = "組件數量已刷超過設定數量,請確認"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "04") |
|
|
|
#region 比對組件資料
|
|
|
|
var CheckMsg = string.Empty; |
|
|
|
int x = BarCodeItems.Count; |
|
|
|
#endregion
|
|
|
|
|
|
|
|
for (int i = 0; i < barcodeItemKPDto.inputKP.Count; i++) |
|
|
|
{ |
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(barcodeItemKPDto.inputKP[i]); |
|
|
|
if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) |
|
|
|
#region 比對序號長度是否正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(wipKps[x + i].Length.ToString())) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 目前是在製狀態</br>"; |
|
|
|
if (wipKps[x + i].Length != barcodeItemKPDto.inputKP[i].Length) |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與組件名稱【" + wipKps[x + i].KpName + "】長度不符合</br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷MAC區間
|
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "94") |
|
|
|
{ |
|
|
|
WipMACController wipMACController = new WipMACController(_context); |
|
|
|
var wipMAC = await wipMACController.GetWipMAC(barcodeItemKPDto.WipNo); |
|
|
|
if (wipMAC.Value == null) |
|
|
|
#region 前置碼正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(wipKps[x + i].Title)) |
|
|
|
{ |
|
|
|
if (!barcodeItemKPDto.inputKP[i].ToUpper().StartsWith(wipKps[x + i].Title.ToUpper())) |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與組件名稱【" + wipKps[x + i].Title + "】前置碼不符合</br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 組件代碼-組件序號是否重複
|
|
|
|
var checkDataRedundancy = await barcodeItemsController.GetBarcodeItemByDataRedundancy(wipKps[x + i].KpNo, barcodeItemKPDto.inputKP[i]); |
|
|
|
if (checkDataRedundancy.Value.Count() != 0) |
|
|
|
{ |
|
|
|
CheckMsg += "組件名稱【" + wipKps[x + i].KpName + "】已有相同組件序號【" + barcodeItemKPDto.inputKP[i] + "】紀錄 </br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "04") |
|
|
|
{ |
|
|
|
CheckMsg += "工單號碼【" + barcodeItemKPDto.WipNo + "】 找不到綁定MAC區間</br>"; |
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(barcodeItemKPDto.inputKP[i]); |
|
|
|
if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 目前是在製狀態</br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷MAC區間
|
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "94") |
|
|
|
{ |
|
|
|
// 判斷MAC前置碼是否一樣
|
|
|
|
if (!barcodeItemKPDto.inputKP[i].StartsWith(wipMAC.Value.Title)) |
|
|
|
WipMACController wipMACController = new WipMACController(_context); |
|
|
|
var wipMAC = await wipMACController.GetWipMAC(barcodeItemKPDto.WipNo); |
|
|
|
if (wipMAC.Value == null) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合 </br>"; |
|
|
|
CheckMsg += "工單號碼【" + barcodeItemKPDto.WipNo + "】 找不到綁定MAC區間</br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// 判斷是否符合區間
|
|
|
|
if (barcodeItemKPDto.inputKP[i].Length == 12) |
|
|
|
// 判斷MAC前置碼是否一樣
|
|
|
|
if (!barcodeItemKPDto.inputKP[i].StartsWith(wipMAC.Value.Title)) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合 </br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(barcodeItemKPDto.inputKP[i].Substring(7, 6), 16) |
|
|
|
&& Convert.ToInt32(barcodeItemKPDto.inputKP[i].Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) |
|
|
|
// 判斷是否符合區間
|
|
|
|
if (barcodeItemKPDto.inputKP[i].Length == 12) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與工單設定MAC區間不符合 </br>"; |
|
|
|
if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(barcodeItemKPDto.inputKP[i].Substring(7, 6), 16) |
|
|
|
&& Convert.ToInt32(barcodeItemKPDto.inputKP[i].Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與工單設定MAC區間不符合 </br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷出貨序號
|
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "95") |
|
|
|
{ |
|
|
|
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); |
|
|
|
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barcodeItemKPDto.WipNo, barcodeItemKPDto.inputKP[i]); |
|
|
|
if (WipBarCodeOther.Value.Count() == 0) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與工單設定出貨序號區間不符合 </br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
#region 判斷出貨序號
|
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "95") |
|
|
|
{ |
|
|
|
resultModel.Data = new List<string> { barcodeItemKPDto.inputKP[i] }; |
|
|
|
resultModel.Msg = barcodeItemKPDto.inputKP[i]; |
|
|
|
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); |
|
|
|
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barcodeItemKPDto.WipNo, barcodeItemKPDto.inputKP[i]); |
|
|
|
if (WipBarCodeOther.Value.Count() == 0) |
|
|
|
{ |
|
|
|
CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與工單設定出貨序號區間不符合 </br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
resultModel.Data = new List<string> { barcodeItemKPDto.inputKP[i] }; |
|
|
|
resultModel.Msg = barcodeItemKPDto.inputKP[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(CheckMsg)) |
|
|
|
{ |
|
|
|
resultModel.Msg = CheckMsg; |
|
|
|
return resultModel; |
|
|
|
if (!string.IsNullOrWhiteSpace(CheckMsg)) |
|
|
|
{ |
|
|
|
resultModel.Msg = CheckMsg; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
resultModel.Success = true; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
resultModel.Success = false; |
|
|
|
resultModel.Msg = ex.Message; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 確認治具狀態
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("BarCodeOutfit")] |
|
|
|
public async Task<IResultModel> CheckBarCodeOutfitAsync(string barcodeNo, string wipNo, string outfitNo) |
|
|
|
{ |
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
|
|
|
|
#region 判斷是否有重複治具紀錄
|
|
|
|
BarcodeOutfitController barcodeOutfitController = new BarcodeOutfitController(_context); |
|
|
|
var q = await barcodeOutfitController.GetBarcodeOutfitByBarcodeNo(barcodeNo); |
|
|
|
if (q.Value.Any(w => w.WipNo == wipNo && w.OutfitNo == outfitNo)) |
|
|
|
{ |
|
|
|
resultModel.Msg = "治具編號號碼【" + outfitNo + "】,已有在條碼【" + barcodeNo + "】使用紀錄"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
resultModel.Success = true; |
|
|
|