|
@ -560,7 +560,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
// 找該筆工單號碼的生產單位代號
|
|
|
// 找該筆工單號碼的生產單位代號
|
|
|
var q1 = q.Value.Where(w => w.UnitNO == unitno).FirstOrDefault(); |
|
|
var q1 = q.Value.Where(w => w.UnitNO == unitno).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 取工單號碼開立的 WipID、生產單位
|
|
|
// 取工單號碼開立的 WipID、生產單位
|
|
|
var wipinfo = q.Value.Select(s => new { s.WipID, s.UnitNO }).ToList(); |
|
|
var wipinfo = q.Value.Select(s => new { s.WipID, s.UnitNO }).ToList(); |
|
|
|
|
|
|
|
@ -650,7 +649,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) |
|
|
if (RuleStationID == null || RuleStationID == 0) |
|
|
{ |
|
|
{ |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的流程未設定此作業站"; |
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的流程未設定此作業站"; |
|
|
return resultModel; |
|
|
return resultModel; |
|
@ -667,15 +666,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
return resultModel; |
|
|
return resultModel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int LastStopRuleStationID = await GetBarCodeLastStopRuleStationID(wipno, station); |
|
|
resultModel = (ResultModel<string>)await GetBarCodeLastStopRuleStationID(wipID, station, BarCodeStationByWipID); |
|
|
if (LastStopRuleStationID != 0 && LastStopRuleStationID != 1000) |
|
|
if (!resultModel.Success) |
|
|
{ |
|
|
return resultModel; |
|
|
if (!BarCodeStationByWipID.Where(w => w.RuleStationID == LastStopRuleStationID).Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
resultModel.Msg = "內部序號【" + barcode + "】找不到上一個作業站過站紀錄,請確認"; |
|
|
|
|
|
return resultModel; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
resultModel.Success = true; |
|
|
resultModel.Success = true; |
|
@ -1087,79 +1080,55 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 取得上一個作業站RuleStationID
|
|
|
/// 取得上一個作業站RuleStationID
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
/// <param name="wipID">工單ID</param>
|
|
|
/// <param name="stationID">作業站ID</param>
|
|
|
/// <param name="stationID">目前作業站ID</param>
|
|
|
/// <returns>0:沒有上一站</returns>
|
|
|
/// <param name="barCodeStations">該工單號碼過站資料</param>
|
|
|
private async Task<int> GetBarCodeLastStopRuleStationID(string wipno, int stationID) |
|
|
/// <returns>true:false</returns>
|
|
|
|
|
|
private async Task<IResultModel> GetBarCodeLastStopRuleStationID(int wipID, int stationID, List<BarcodeStation> barCodeStations) |
|
|
{ |
|
|
{ |
|
|
|
|
|
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.GetWipInfo(wipID); |
|
|
|
|
|
|
|
|
if (q.Result.Value.Count() == 0) |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
var q1 = q.Result.Value.ToList(); |
|
|
var q1 = q.Result.Value.ToList(); |
|
|
List<int> FlowRuleID = new List<int>(); |
|
|
//List<int> FlowRuleID = new List<int>();
|
|
|
List<string> Unit = new List<string>(); |
|
|
//List<string> Unit = new List<string>();
|
|
|
// 取生產單位順序
|
|
|
//// 取生產單位順序
|
|
|
if (q1.Where(w => w.UnitNO == "S" || w.UnitNO == "D").Any()) |
|
|
//if (q1.Where(w => w.UnitNO == "S" || w.UnitNO == "D").Any())
|
|
|
{ |
|
|
//{
|
|
|
// SMT DIP
|
|
|
// // SMT DIP
|
|
|
Unit.Add("S"); |
|
|
// Unit.Add("S");
|
|
|
Unit.Add("D"); |
|
|
// Unit.Add("D");
|
|
|
} |
|
|
//}
|
|
|
else if (q1.Where(w => w.UnitNO == "B" || w.UnitNO == "T").Any()) |
|
|
//else if (q1.Where(w => w.UnitNO == "B" || w.UnitNO == "T").Any())
|
|
|
{ |
|
|
//{
|
|
|
// 組裝 測試 包裝
|
|
|
// // 組裝 測試 包裝
|
|
|
Unit.Add("B"); |
|
|
// Unit.Add("B");
|
|
|
Unit.Add("T"); |
|
|
// Unit.Add("T");
|
|
|
Unit.Add("P"); |
|
|
// Unit.Add("P");
|
|
|
} |
|
|
//}
|
|
|
|
|
|
|
|
|
// 抓各生產單位的流程ID
|
|
|
// 抓工單ID的流程ID
|
|
|
foreach (string str in Unit) |
|
|
int WipFlowRule = q1.FirstOrDefault().FlowRuleID; |
|
|
{ |
|
|
|
|
|
int WipFlowRule = q1.Where(w => w.UnitNO == str).Select(s => s.FlowRuleID).FirstOrDefault(); |
|
|
// 用作業站抓 有設定下一站為該站的資料
|
|
|
FlowRuleID.Add(WipFlowRule); |
|
|
RulesController rulesController = new RulesController(_context); |
|
|
} |
|
|
var rules = await rulesController.GetRulesByNextStation(stationID); |
|
|
|
|
|
|
|
|
// 將工單-生產單位 流程ID取rulestation的作業站排順序
|
|
|
//排除第一站
|
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
if (rules.Value.Count() != 0) |
|
|
List<dynamic> dy = new List<dynamic>(); |
|
|
|
|
|
int index = 1; |
|
|
|
|
|
foreach (int i in FlowRuleID) |
|
|
|
|
|
{ |
|
|
{ |
|
|
if (i == 0) |
|
|
// 反查上一站是否有資料
|
|
|
continue; |
|
|
var ruleSationID = rules.Value.Select(s => s.RuleStationID).ToList(); |
|
|
|
|
|
if (!barCodeStations.Where(w => ruleSationID.Contains(w.RuleStationID)).Any()) |
|
|
var ruleStations = await ruleStationsController.GetRuleStationByFlow(i, 0); |
|
|
|
|
|
if (ruleStations.Value.Count() != 0) |
|
|
|
|
|
{ |
|
|
{ |
|
|
foreach (var item in ruleStations.Value.OrderBy(o => o.Sequence)) |
|
|
resultModel.Msg = "找不到上一個作業站過站紀錄,請確認"; |
|
|
{ |
|
|
return resultModel; |
|
|
var x = new |
|
|
|
|
|
{ |
|
|
|
|
|
index, |
|
|
|
|
|
item.StationID, |
|
|
|
|
|
item.RuleStationID, |
|
|
|
|
|
item.Sequence, |
|
|
|
|
|
item.StationType |
|
|
|
|
|
}; |
|
|
|
|
|
dy.Add(x); |
|
|
|
|
|
index++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault() == null) |
|
|
resultModel.Success = true; |
|
|
return 0; |
|
|
return resultModel; |
|
|
|
|
|
|
|
|
int NowIndex = dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
if (dy.Where(w => w.index == (NowIndex - 1)).Select(s => s.StationID).FirstOrDefault() == null) |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
return dy.Where(w => w.index == (NowIndex - 1)).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|