|
@ -207,7 +207,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
|
if (BarCodeID == 0) |
|
|
if (BarCodeID == 0) |
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "找不到內部序號【" + barcode + "】 對應BarCodeID"; |
|
|
//resultModel.Msg = "找不到內部序號【" + barcode + "】 對應BarCodeID";
|
|
|
|
|
|
resultModel.Success = true; |
|
|
return Ok(resultModel); |
|
|
return Ok(resultModel); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -242,6 +243,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
var q = await barcodeInfoesController.GetBarcodeInfoesByNo(barcode); |
|
|
var q = await barcodeInfoesController.GetBarcodeInfoesByNo(barcode); |
|
|
if (q.Value.Count() == 0) |
|
|
if (q.Value.Count() == 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
resultModel.Success = true; |
|
|
resultModel.Msg = "找不到內部序號【" + barcode + "】 對應BarCodeID"; |
|
|
resultModel.Msg = "找不到內部序號【" + barcode + "】 對應BarCodeID"; |
|
|
return Ok(resultModel); |
|
|
return Ok(resultModel); |
|
|
} |
|
|
} |
|
@ -306,7 +308,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
if (unitno == "D") |
|
|
if (unitno == "D") |
|
|
{ |
|
|
{ |
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "S").Select(s => s.WipID).FirstOrDefault(); |
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "S").Select(s => s.WipID).FirstOrDefault(); |
|
|
if (WipID == 0) |
|
|
if (WipID == null) |
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
return Ok(resultModel); |
|
|
return Ok(resultModel); |
|
@ -322,7 +324,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
else if (unitno == "T") |
|
|
else if (unitno == "T") |
|
|
{ |
|
|
{ |
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "B").Select(s => s.WipID).FirstOrDefault(); |
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "B").Select(s => s.WipID).FirstOrDefault(); |
|
|
if (WipID == 0) |
|
|
if (WipID == null) |
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
return Ok(resultModel); |
|
|
return Ok(resultModel); |
|
@ -337,7 +339,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
else if (unitno == "P") |
|
|
else if (unitno == "P") |
|
|
{ |
|
|
{ |
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "T").Select(s => s.WipID).FirstOrDefault(); |
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "T").Select(s => s.WipID).FirstOrDefault(); |
|
|
if (WipID == 0) |
|
|
if (WipID == null) |
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
return Ok(resultModel); |
|
|
return Ok(resultModel); |
|
@ -373,9 +375,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
|
// 該作業站 RuleStationID
|
|
|
// 該作業站 RuleStationID
|
|
|
int? RuleStationID = ruleStations.Value.Where(w => w.StationID == station).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
int? RuleStationID = ruleStations.Value.Where(w => w.StationID == station).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
// 該作業站順序
|
|
|
if (RuleStationID == null) |
|
|
int? Sequence = ruleStations.Value.Where(w => w.StationID == station).Select(s => s.Sequence).FirstOrDefault(); |
|
|
|
|
|
if (RuleStationID == 0) |
|
|
|
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的流程未設定此作業站"; |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的流程未設定此作業站"; |
|
|
return Ok(resultModel); |
|
|
return Ok(resultModel); |
|
@ -383,22 +383,28 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
|
// 取目前工單ID
|
|
|
// 取目前工單ID
|
|
|
int wipID = q1.WipID; |
|
|
int wipID = q1.WipID; |
|
|
|
|
|
|
|
|
// 該筆工單ID過站紀錄
|
|
|
// 該筆工單ID過站紀錄
|
|
|
var BarCodeStationByWipID = BarCodeStations.Value.Where(w => w.WipID == wipID).ToList(); |
|
|
var BarCodeStationByWipID = BarCodeStations.Value.Where(w => w.WipID == wipID).ToList(); |
|
|
foreach (var item in ruleStations.Value.OrderBy(o => o.Sequence)) |
|
|
if (BarCodeStationByWipID.Where(w => w.RuleStationID == RuleStationID && w.RuleStatus == "P").Any()) |
|
|
{ |
|
|
{ |
|
|
|
|
|
resultModel.Msg = "內部序號【" + barcode + "】該作業站已有過站紀錄,請確認"; |
|
|
|
|
|
return Ok(resultModel); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int LastStopRuleStationID = await GetBarCodeLastStopRuleStationID(wipno, station); |
|
|
|
|
|
if (LastStopRuleStationID != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!BarCodeStationByWipID.Where(w => w.RuleStationID == LastStopRuleStationID && w.RuleStatus == "P").Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
resultModel.Msg = "內部序號【" + barcode + "】找不到上一個作業站過站紀錄,請確認"; |
|
|
|
|
|
return Ok(resultModel); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
return Ok(ruleStations); |
|
|
resultModel.Success = true; |
|
|
//if (q.Value.Any(w => w.RuleStatus == "S"))
|
|
|
return Ok(resultModel); |
|
|
//{
|
|
|
|
|
|
// resultModel.Msg = "內部序號【" + barcode + "】已報廢或轉賣, 不可繼續過站!";
|
|
|
|
|
|
// return Ok(resultModel);
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
@ -480,5 +486,157 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
return q.Value.FirstOrDefault().BarcodeID; |
|
|
return q.Value.FirstOrDefault().BarcodeID; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取得上一個作業站RuleStationID
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
|
|
|
/// <param name="stationID">作業站ID</param>
|
|
|
|
|
|
/// <returns>0:沒有上一站</returns>
|
|
|
|
|
|
private async Task<int> GetBarCodeLastStopRuleStationID(string wipno, int stationID) |
|
|
|
|
|
{ |
|
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
|
|
var q = wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
|
|
|
|
|
|
|
|
|
if (q.Result.Value.Count() == 0) |
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
foreach (string str in Unit) |
|
|
|
|
|
{ |
|
|
|
|
|
int WipFlowRule = q1.Where(w => w.UnitNO == str).Select(s => s.FlowRuleID).FirstOrDefault(); |
|
|
|
|
|
FlowRuleID.Add(WipFlowRule); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 將工單-生產單位 流程ID取rulestation的作業站排順序
|
|
|
|
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
|
|
|
List<dynamic> dy = new List<dynamic>(); |
|
|
|
|
|
int index = 1; |
|
|
|
|
|
foreach (int i in FlowRuleID) |
|
|
|
|
|
{ |
|
|
|
|
|
if (i == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
{ |
|
|
|
|
|
index, |
|
|
|
|
|
item.RuleStationID |
|
|
|
|
|
}; |
|
|
|
|
|
dy.Add(x); |
|
|
|
|
|
index++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (dy.Where(w => w.RuleStationID == stationID).Select(s => s.index).FirstOrDefault() == null) |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
int NowIndex = dy.Where(w => w.RuleStationID == stationID).Select(s => s.index).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
if (dy.Where(w => w.index == (NowIndex - 1)).Select(s => s.RuleStationID).FirstOrDefault() == null) |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
return dy.Where(w => w.index == (NowIndex - 1)).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
|
|
|
int NextStopStationID = dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取得下一個作業站RuleStationID
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
|
|
|
/// <param name="stationID">作業站ID</param>
|
|
|
|
|
|
/// <returns>0:沒有下一站</returns>
|
|
|
|
|
|
private async Task<int> GetBarCodeNextStopRuleStationID(string wipno, int stationID) |
|
|
|
|
|
{ |
|
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
|
|
var q = wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
|
|
|
|
|
|
|
|
|
if (q.Result.Value.Count() == 0) |
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
foreach (string str in Unit) |
|
|
|
|
|
{ |
|
|
|
|
|
int WipFlowRule = q1.Where(w => w.UnitNO == str).Select(s => s.FlowRuleID).FirstOrDefault(); |
|
|
|
|
|
FlowRuleID.Add(WipFlowRule); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 將工單-生產單位 流程ID取rulestation的作業站排順序
|
|
|
|
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
|
|
|
List<dynamic> dy = new List<dynamic>(); |
|
|
|
|
|
int index = 1; |
|
|
|
|
|
foreach (int i in FlowRuleID) |
|
|
|
|
|
{ |
|
|
|
|
|
if (i == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
{ |
|
|
|
|
|
index, |
|
|
|
|
|
item.RuleStationID |
|
|
|
|
|
}; |
|
|
|
|
|
dy.Add(x); |
|
|
|
|
|
index++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (dy.Where(w => w.RuleStationID == stationID).Select(s => s.index).FirstOrDefault() == null) |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
int NowIndex = dy.Where(w => w.RuleStationID == stationID).Select(s => s.index).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
if (dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.RuleStationID).FirstOrDefault() == null) |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
return dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|