|
@ -450,6 +450,13 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
resultModel.Msg = "工單號碼【" + WipNo + "】,尚未設定此流程站"; |
|
|
resultModel.Msg = "工單號碼【" + WipNo + "】,尚未設定此流程站"; |
|
|
return resultModel; |
|
|
return resultModel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!WipNoItem.Where(w => w.LineID == Line).Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
resultModel.Msg = "工單號碼【" + WipNo + "】,尚未設定此線別"; |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (WipNoItem.Where(w => w.StatusNO == "Y").Any()) |
|
|
if (WipNoItem.Where(w => w.StatusNO == "Y").Any()) |
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "工單號碼【" + WipNo + "】,該工單已經投入完工,請切換工單"; |
|
|
resultModel.Msg = "工單號碼【" + WipNo + "】,該工單已經投入完工,請切換工單"; |
|
@ -474,15 +481,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
/// <param name="barcode">內部條碼</param>
|
|
|
/// <param name="barcode">內部條碼</param>
|
|
|
|
|
|
/// <param name="unitNo">生產單位ID</param>
|
|
|
|
|
|
/// <param name="inputKP">過站刷入組件序號</param>
|
|
|
|
|
|
/// <param name="inputNo">過站刷入組件數量</param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet("BarCodeKP")] |
|
|
[HttpGet("BarCodeKP")] |
|
|
public async Task<IResultModel> CheckBarCodeKPAsync(string wipno, string barcode) |
|
|
public async Task<IResultModel> CheckBarCodeKPAsync(string wipno, string barcode, string unitNo, List<string> inputKP) |
|
|
{ |
|
|
{ |
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
|
|
|
|
|
#region 判斷是否有工單
|
|
|
#region 判斷是否有工單
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
var q = await wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
var q = await wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
|
|
|
q = q.Value.Where(w => w.UnitNO == unitNo).ToList(); |
|
|
if (q.Value.Count() == 0) |
|
|
if (q.Value.Count() == 0) |
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "找不到工單號碼【" + wipno + "】"; |
|
|
resultModel.Msg = "找不到工單號碼【" + wipno + "】"; |
|
@ -513,70 +524,71 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
#region 確認是否有設定key Parts資料
|
|
|
#region 確認是否有設定key Parts資料
|
|
|
MaterialKpController materialKpController = new MaterialKpController(_context); |
|
|
MaterialKpController materialKpController = new MaterialKpController(_context); |
|
|
var MaterialKps = (await materialKpController.GetMaterialKpByItemID(MaterialItem.ItemID)).ToList(); |
|
|
var MaterialKps = (await materialKpController.GetMaterialKpByItemID(MaterialItem.ItemID)).ToList(); |
|
|
|
|
|
MaterialKps = MaterialKps.Where(w => w.StationType == unitNo).ToList(); |
|
|
if (MaterialKps.Count != 0) |
|
|
if (MaterialKps.Count != 0) |
|
|
{ |
|
|
{ |
|
|
#region 判斷內部序號是否有過站紀錄
|
|
|
#region 判斷內部序號是否有過站紀錄
|
|
|
var BarCodeID = await BarCodeToID(barcode); |
|
|
var BarCodeID = await BarCodeToID(barcode); |
|
|
if (BarCodeID == 0) |
|
|
//if (BarCodeID == 0)
|
|
|
{ |
|
|
//{
|
|
|
resultModel.Msg = "內部序號【" + barcode + "】,在條碼資料檔找不到"; |
|
|
// resultModel.Msg = "內部序號【" + barcode + "】,在條碼資料檔找不到";
|
|
|
return resultModel; |
|
|
// return resultModel;
|
|
|
} |
|
|
//}
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 判斷組件序號是否有紀錄
|
|
|
#region 判斷組件序號是否有紀錄
|
|
|
BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); |
|
|
BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); |
|
|
var BarCodeItems = (await barcodeItemsController.GetBarcodeItems(BarCodeID)).Value.ToList(); |
|
|
var BarCodeItems = (await barcodeItemsController.GetBarcodeItems(BarCodeID)).Value.ToList(); |
|
|
if (BarCodeItems.Count == 0) |
|
|
BarCodeItems = BarCodeItems.Where(w => w.WipID == q.Value.FirstOrDefault().WipID).ToList(); |
|
|
{ |
|
|
|
|
|
resultModel.Msg = "內部序號【" + barcode + "】,在條碼組件件資料檔找不到"; |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 判斷組件數量是否正確
|
|
|
// 計算過站時刷的組件數量與已經存BarCodeItems
|
|
|
if (MaterialKps.Count != BarCodeItems.Count) |
|
|
var KPQty = inputKP.Count + BarCodeItems.Count; |
|
|
|
|
|
#region 刷入組件數量超過
|
|
|
|
|
|
if (KPQty > MaterialKps.Count) |
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "組件對應數量【" + MaterialKps.Count + "】不等於條碼組件數量【" + BarCodeItems.Count + "】"; |
|
|
resultModel.Msg = "組件數量已刷超過設定數量,請確認"; |
|
|
return resultModel; |
|
|
return resultModel; |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 比對組件資料
|
|
|
#region 比對組件資料
|
|
|
var CheckMsg = string.Empty; |
|
|
var CheckMsg = string.Empty; |
|
|
for (int i = 0; i < MaterialKps.Count; i++) |
|
|
int x= BarCodeItems.Count; |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < inputKP.Count; i++) |
|
|
{ |
|
|
{ |
|
|
#region 比對序號長度是否正確
|
|
|
#region 比對序號長度是否正確
|
|
|
if (string.IsNullOrWhiteSpace(MaterialKps[i].Length.ToString())) |
|
|
if (string.IsNullOrWhiteSpace(MaterialKps[x+i].Length.ToString())) |
|
|
{ |
|
|
{ |
|
|
if (MaterialKps[i].Length != BarCodeItems[i].PartNo.Length) |
|
|
if (MaterialKps[x + i].Length != inputKP[i].Length) |
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 與組件名稱【" + MaterialKps[i].KpName + "】長度不符合</br>"; |
|
|
CheckMsg += "組件序號【" + inputKP + "】 與組件名稱【" + MaterialKps[x + i].KpName + "】長度不符合</br>"; |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 前置碼正確
|
|
|
#region 前置碼正確
|
|
|
if (!string.IsNullOrWhiteSpace(MaterialKps[i].Title)) |
|
|
if (!string.IsNullOrWhiteSpace(MaterialKps[x + i].Title)) |
|
|
{ |
|
|
{ |
|
|
if (!BarCodeItems[i].KpItemNo.ToUpper().StartsWith(MaterialKps[i].Title.ToUpper())) |
|
|
if (!inputKP[i].ToUpper().StartsWith(MaterialKps[x + i].Title.ToUpper())) |
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 與組件名稱【" + MaterialKps[i].Title + "】前置碼不符合</br>"; |
|
|
CheckMsg += "組件序號【" + inputKP + "】 與組件名稱【" + MaterialKps[x + i].Title + "】前置碼不符合</br>"; |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
if (MaterialKps[i].KpName.ToUpper() == "BOARD") |
|
|
if (MaterialKps[x + i].KpName.ToUpper() == "BOARD") |
|
|
{ |
|
|
{ |
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(BarCodeItems[i].PartNo); |
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(inputKP[i]); |
|
|
if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) |
|
|
if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) |
|
|
{ |
|
|
{ |
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 目前是在製狀態</br>"; |
|
|
CheckMsg += "組件序號【" + inputKP + "】 目前是在製狀態</br>"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 判斷MAC區間
|
|
|
#region 判斷MAC區間
|
|
|
if (MaterialKps[i].KpName.ToUpper() == "MAC") |
|
|
if (MaterialKps[x + i].KpName.ToUpper() == "MAC") |
|
|
{ |
|
|
{ |
|
|
WipMACController wipMACController = new WipMACController(_context); |
|
|
WipMACController wipMACController = new WipMACController(_context); |
|
|
var wipMAC = await wipMACController.GetWipMAC(wipno); |
|
|
var wipMAC = await wipMACController.GetWipMAC(wipno); |
|
@ -587,19 +599,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
// 判斷MAC前置碼是否一樣
|
|
|
// 判斷MAC前置碼是否一樣
|
|
|
if (!BarCodeItems[i].PartNo.StartsWith(wipMAC.Value.Title)) |
|
|
if (!inputKP[i].StartsWith(wipMAC.Value.Title)) |
|
|
{ |
|
|
{ |
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合 </br>"; |
|
|
CheckMsg += "組件序號【" + inputKP + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合 </br>"; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
// 判斷是否符合區間
|
|
|
// 判斷是否符合區間
|
|
|
if (BarCodeItems[i].PartNo.Length == 12) |
|
|
if (inputKP[i].Length == 12) |
|
|
{ |
|
|
{ |
|
|
if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(BarCodeItems[i].PartNo.Substring(7, 6), 16) |
|
|
if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(inputKP[i].Substring(7, 6), 16) |
|
|
&& Convert.ToInt32(BarCodeItems[i].PartNo.Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) |
|
|
&& Convert.ToInt32(inputKP[i].Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) |
|
|
{ |
|
|
{ |
|
|
CheckMsg += "組件序號【" + BarCodeItems[i].PartNo + "】 與工單設定MAC區間不符合 </br>"; |
|
|
CheckMsg += "組件序號【" + inputKP + "】 與工單設定MAC區間不符合 </br>"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -609,18 +621,21 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
|
#region 判斷出貨序號
|
|
|
#region 判斷出貨序號
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
if (MaterialKps[i].KpName.ToUpper() == "EXT_NO") |
|
|
if (MaterialKps[x + i].KpName.ToUpper() == "EXT_NO") |
|
|
{ |
|
|
{ |
|
|
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); |
|
|
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); |
|
|
var WipBarCodeOther = await wipBarcodeOtherController.GetWipBarcodeOtherByWipNo(wipno); |
|
|
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(wipno, inputKP[i]); |
|
|
if (WipBarCodeOther.Value != null) |
|
|
if (WipBarCodeOther.Value.Count() == 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
CheckMsg += "組件序號【" + inputKP + "】 與工單設定出貨序號區間不符合 </br>"; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
resultModel.Msg = "EXT_NO"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(CheckMsg)) |
|
|
if (!string.IsNullOrWhiteSpace(CheckMsg)) |
|
|
{ |
|
|
{ |
|
@ -633,6 +648,92 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
resultModel.Success = true; |
|
|
resultModel.Success = true; |
|
|
return resultModel; |
|
|
return resultModel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 確認組件數量正確
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
|
|
|
/// <param name="barcode">內部條碼</param>
|
|
|
|
|
|
/// <param name="unitno">生產單位</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("CheckBarCodeKPQty")] |
|
|
|
|
|
public async Task<IResultModel> CheckBarCodeKPQtyAsync(string wipno, string barcode, string unitno) |
|
|
|
|
|
{ |
|
|
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
|
|
|
|
|
|
|
|
#region 判斷是否有工單
|
|
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
|
|
var q = await wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
|
|
|
q = q.Value.Where(w => w.UnitNO == unitno).ToList(); |
|
|
|
|
|
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(); |
|
|
|
|
|
MaterialKps = MaterialKps.Where(w => w.StationType == unitno).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(); |
|
|
|
|
|
BarCodeItems = BarCodeItems.Where(w => w.WipID == q.Value.FirstOrDefault().WipID).ToList(); |
|
|
|
|
|
if (BarCodeItems.Count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
resultModel.Msg = "內部序號【" + barcode + "】,在條碼組件件資料檔找不到"; |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 判斷組件數量是否正確
|
|
|
|
|
|
// 先把出貨序號拿掉
|
|
|
|
|
|
MaterialKps = MaterialKps.Where(w => w.KpName.ToUpper() != "EXT_NO").ToList(); |
|
|
|
|
|
if (MaterialKps.Count != BarCodeItems.Count) |
|
|
|
|
|
{ |
|
|
|
|
|
resultModel.Msg = "組件對應數量【" + MaterialKps.Count + "】不等於條碼組件數量【" + BarCodeItems.Count + "】"; |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
resultModel.Success = true; |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 內部序號找BarCodeID
|
|
|
/// 內部序號找BarCodeID
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -706,7 +807,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
var x = new |
|
|
var x = new |
|
|
{ |
|
|
{ |
|
|
index, |
|
|
index, |
|
|
item.RuleStationID |
|
|
item.StationID |
|
|
}; |
|
|
}; |
|
|
dy.Add(x); |
|
|
dy.Add(x); |
|
|
index++; |
|
|
index++; |
|
@ -714,91 +815,116 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (dy.Where(w => w.RuleStationID == stationID).Select(s => s.index).FirstOrDefault() == null) |
|
|
if (dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault() == null) |
|
|
return 0; |
|
|
return 0; |
|
|
|
|
|
|
|
|
int NowIndex = dy.Where(w => w.RuleStationID == stationID).Select(s => s.index).FirstOrDefault(); |
|
|
int NowIndex = dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault(); |
|
|
|
|
|
|
|
|
if (dy.Where(w => w.index == (NowIndex - 1)).Select(s => s.RuleStationID).FirstOrDefault() == null) |
|
|
if (dy.Where(w => w.index == (NowIndex - 1)).Select(s => s.StationID).FirstOrDefault() == null) |
|
|
return 0; |
|
|
return 0; |
|
|
|
|
|
|
|
|
return dy.Where(w => w.index == (NowIndex - 1)).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
return dy.Where(w => w.index == (NowIndex - 1)).Select(s => s.StationID).FirstOrDefault(); |
|
|
int NextStopStationID = dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 取得下一個作業站RuleStationID
|
|
|
/// 確認下一站為完工
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
|
|
|
/// <param name="unitNo">生產單位ID</param>
|
|
|
/// <param name="stationID">作業站ID</param>
|
|
|
/// <param name="stationID">作業站ID</param>
|
|
|
/// <returns>0:沒有下一站</returns>
|
|
|
/// <returns>0:完工 -1:不是</returns>
|
|
|
private async Task<int> GetBarCodeNextStopRuleStationID(string wipno, int stationID) |
|
|
[HttpGet("CheckNextStopCloseStation")] |
|
|
|
|
|
public async Task<IResultModel> CheckNextStopCloseStation(string wipno, string unitNo, int stationID) |
|
|
{ |
|
|
{ |
|
|
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
var q = wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
var q = wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
|
|
|
|
|
|
if (q.Result.Value.Count() == 0) |
|
|
if (!q.Result.Value.Where(w => w.UnitNO == unitNo).Any()) |
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
var q1 = q.Result.Value.ToList(); |
|
|
|
|
|
List<int> FlowRuleID = new List<int>(); |
|
|
|
|
|
List<string> Unit = new List<string>(); |
|
|
|
|
|
// 取生產單位順序
|
|
|
|
|
|
if (q1.Where(w => w.UnitNO == "S" || w.UnitNO == "D").Any()) |
|
|
|
|
|
{ |
|
|
{ |
|
|
// SMT DIP
|
|
|
return resultModel; |
|
|
Unit.Add("S"); |
|
|
|
|
|
Unit.Add("D"); |
|
|
|
|
|
} |
|
|
|
|
|
else if (q1.Where(w => w.UnitNO == "B" || w.UnitNO == "T").Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
// 組裝 測試 包裝
|
|
|
|
|
|
Unit.Add("B"); |
|
|
|
|
|
Unit.Add("T"); |
|
|
|
|
|
Unit.Add("P"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 抓各生產單位的流程ID
|
|
|
var q1 = q.Result.Value.Where(w => w.UnitNO == unitNo).FirstOrDefault(); |
|
|
foreach (string str in Unit) |
|
|
int FlowRuleID = q1.FlowRuleID; |
|
|
{ |
|
|
|
|
|
int WipFlowRule = q1.Where(w => w.UnitNO == str).Select(s => s.FlowRuleID).FirstOrDefault(); |
|
|
|
|
|
FlowRuleID.Add(WipFlowRule); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 將工單-生產單位 流程ID取rulestation的作業站排順序
|
|
|
// 將工單-生產單位 流程ID取rulestation的作業站排順序
|
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
List<dynamic> dy = new List<dynamic>(); |
|
|
List<dynamic> dy = new List<dynamic>(); |
|
|
int index = 1; |
|
|
int index = 1; |
|
|
foreach (int i in FlowRuleID) |
|
|
var ruleStations = await ruleStationsController.GetRuleStationByFlow(q1.FlowRuleID, 0); |
|
|
|
|
|
if (ruleStations.Value.Count() != 0) |
|
|
{ |
|
|
{ |
|
|
if (i == 0) |
|
|
// 按照順序塞入判斷資料
|
|
|
continue; |
|
|
foreach (var item in ruleStations.Value.Where(w => w.StationType == "M").OrderBy(o => o.Sequence)) |
|
|
|
|
|
|
|
|
var ruleStations = await ruleStationsController.GetRuleStationByFlow(i, 0); |
|
|
|
|
|
if (ruleStations.Value.Count() != 0) |
|
|
|
|
|
{ |
|
|
{ |
|
|
foreach (var item in ruleStations.Value.Where(w => w.StationType == "M").OrderBy(o => o.Sequence)) |
|
|
var x = new |
|
|
{ |
|
|
{ |
|
|
var x = new |
|
|
index, |
|
|
{ |
|
|
item.StationID |
|
|
index, |
|
|
}; |
|
|
item.RuleStationID |
|
|
dy.Add(x); |
|
|
}; |
|
|
index++; |
|
|
dy.Add(x); |
|
|
|
|
|
index++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (dy.Where(w => w.RuleStationID == stationID).Select(s => s.index).FirstOrDefault() == null) |
|
|
// 在RuleStation 找不到該作業站
|
|
|
return 0; |
|
|
if (dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault() == null) |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
|
|
|
int NowIndex = dy.Where(w => w.RuleStationID == stationID).Select(s => s.index).FirstOrDefault(); |
|
|
// 取得目前該站順序
|
|
|
|
|
|
int NowIndex = dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault(); |
|
|
|
|
|
|
|
|
if (dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.RuleStationID).FirstOrDefault() == null) |
|
|
// 判斷下一站沒有資料Error
|
|
|
return 0; |
|
|
if (dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.StationID).FirstOrDefault() == null) |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
|
|
|
return dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
// 當下一站SatationID= 1000 代表完工站
|
|
|
|
|
|
if (dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.StationID).FirstOrDefault() == 1000) |
|
|
|
|
|
{ |
|
|
|
|
|
resultModel.Success = true; |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 判斷生產中工單是否已經全部完工 自動更新
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
|
|
|
/// <param name="unitNo">生產單位ID</param>
|
|
|
|
|
|
/// <param name="ruleStationID">ruleStationID</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("CheckWipNoBarCodeAllClost")] |
|
|
|
|
|
public async Task<IResultModel> CheckWipNoBarCodeAllClost(string wipno, string unitNo, int ruleStationID) |
|
|
|
|
|
{ |
|
|
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
|
|
var q = wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
|
|
|
|
|
|
|
|
|
if (!q.Result.Value.Where(w => w.UnitNO == unitNo).Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var q1 = q.Result.Value.Where(w => w.UnitNO == unitNo).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
BarcodeStationController barcodeStationController = new BarcodeStationController(_context); |
|
|
|
|
|
var barCodeStations = await barcodeStationController.GetBarcodeStationByWipID(q1.WipID); |
|
|
|
|
|
|
|
|
|
|
|
// 比對過站Station完工跟工單數一樣 = 完工
|
|
|
|
|
|
|
|
|
|
|
|
if (q1.PlanQTY == |
|
|
|
|
|
barCodeStations.Value.Where(w => w.RuleStatus == "P" && w.RuleStationID == ruleStationID).Count()) |
|
|
|
|
|
{ |
|
|
|
|
|
await wipInfosController.PutWipinfoToStatusNO(q1.WipID, "E"); |
|
|
|
|
|
resultModel.Success = true; |
|
|
|
|
|
resultModel.Msg = "完工"; |
|
|
|
|
|
} |
|
|
|
|
|
return resultModel; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|