|
|
@ -127,9 +127,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
item = q_wipinfo.Value.FirstOrDefault().GetWipAtt.ItemNO; |
|
|
|
itemID = ItemNoToItemID(item).Result; |
|
|
|
|
|
|
|
var q_rulestation = await ruleStationsController.GetRuleStationByFlow(barCodeCheckDto.flowRule, 0, 0); |
|
|
|
|
|
|
|
// 抓RulseStationID
|
|
|
|
var q_rulestation = await ruleStationsController.GetRuleStationByFlow(barCodeCheckDto.flowRule, 0, 0); |
|
|
|
barCodeCheckDto.ruleStationID = q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).FirstOrDefault().RuleStationID; |
|
|
|
|
|
|
|
#region KeyParts 判斷
|
|
|
@ -209,7 +208,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
|
if (q_Kp.KpName.ToUpper() == "BOARD") |
|
|
|
if (q_Kp.KpNo.ToUpper() == "04") |
|
|
|
{ |
|
|
|
|
|
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(KPs.inputData); |
|
|
@ -221,7 +220,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷MAC區間
|
|
|
|
if (q_Kp.KpName.ToUpper() == "MAC") |
|
|
|
if (q_Kp.KpNo.ToUpper() == "94") |
|
|
|
{ |
|
|
|
|
|
|
|
var wipMAC = await wipMACController.GetWipMAC(barCodeCheckDto.wipNo); |
|
|
@ -254,7 +253,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
#region 判斷出貨序號
|
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
|
if (q_Kp.KpName.ToUpper() == "EXT_NO") |
|
|
|
if (q_Kp.KpNo.ToUpper() == "95") |
|
|
|
{ |
|
|
|
|
|
|
|
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barCodeCheckDto.wipNo, KPs.inputData); |
|
|
@ -367,8 +366,12 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
private void CU_Tables(BarCodeCheckDto barCodeCheckDto) |
|
|
|
{ |
|
|
|
string Msg = string.Empty; |
|
|
|
if (!Table_BarcodeInfo(barCodeCheckDto).Result.Success) |
|
|
|
var result_BarcodeInfo = Table_BarcodeInfo(barCodeCheckDto).Result; |
|
|
|
if (result_BarcodeInfo.Success) |
|
|
|
{ |
|
|
|
// 將BarCodeID補上
|
|
|
|
if (barCodeCheckDto.barcodeID == 0) |
|
|
|
barCodeCheckDto.barcodeID = result_BarcodeInfo.Data.FirstOrDefault().BarcodeID; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -817,7 +820,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
resultModel.Msg = ex.InnerException.Message; |
|
|
|
resultModel.Msg = ex.Message; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1071,10 +1074,21 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
// 判斷序號目前是否有重複過站
|
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
var BarcodeInfos = await barcodeInfoesController.GetBarcodeInfoesByNo(barcode); |
|
|
|
BarcodeInfos = BarcodeInfos.Value.ToList(); |
|
|
|
if (BarcodeInfos.Value.Where(w => w.RuleStationID == RuleStationID).Any()) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該內部序號【" + barcode + "】已刷過此站"; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
// 取目前工單ID
|
|
|
|
int wipID = q1.WipID; |
|
|
|
int flowRuleID = q1.FlowRuleID; |
|
|
|
|
|
|
|
resultModel = (ResultModel<string>)await GetBarCodeLastStopRuleStationID(wipID, BarCodeID, station); |
|
|
|
resultModel = (ResultModel<string>)await GetBarCodeLastStopRuleStationID(wipID, BarCodeID, station, flowRuleID); |
|
|
|
if (!resultModel.Success) |
|
|
|
return resultModel; |
|
|
|
|
|
|
@ -1295,7 +1309,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
|
if (wipKps[x + i].KpName.ToUpper() == "BOARD") |
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "04") |
|
|
|
{ |
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(barcodeItemKPDto.inputKP[i]); |
|
|
@ -1307,7 +1321,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷MAC區間
|
|
|
|
if (wipKps[x + i].KpName.ToUpper() == "MAC") |
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "94") |
|
|
|
{ |
|
|
|
WipMACController wipMACController = new WipMACController(_context); |
|
|
|
var wipMAC = await wipMACController.GetWipMAC(barcodeItemKPDto.WipNo); |
|
|
@ -1340,7 +1354,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
#region 判斷出貨序號
|
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
|
if (wipKps[x + i].KpName.ToUpper() == "EXT_NO") |
|
|
|
if (wipKps[x + i].KpNo.ToUpper() == "95") |
|
|
|
{ |
|
|
|
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); |
|
|
|
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barcodeItemKPDto.WipNo, barcodeItemKPDto.inputKP[i]); |
|
|
@ -1491,8 +1505,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
/// <param name="wipID">工單ID</param>
|
|
|
|
/// <param name="barCodeID">BarCodeID</param>
|
|
|
|
/// <param name="stationID">目前作業站ID</param>
|
|
|
|
/// <param name="flowRuleID">工單流程ID</param>
|
|
|
|
/// <returns>true:false</returns>
|
|
|
|
private async Task<IResultModel> GetBarCodeLastStopRuleStationID(int wipID, int barCodeID, int stationID) |
|
|
|
private async Task<IResultModel> GetBarCodeLastStopRuleStationID(int wipID, int barCodeID, int stationID, int flowRuleID) |
|
|
|
{ |
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
@ -1503,13 +1518,13 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
// 用作業站抓 有設定下一站為該站的資料
|
|
|
|
RulesController rulesController = new RulesController(_context); |
|
|
|
var rules = await rulesController.GetRulesByNextStation(stationID); |
|
|
|
|
|
|
|
var rules = await rulesController.GetRulesByFlowRuleID(flowRuleID); |
|
|
|
rules = rules.Value.Where(w => w.NextStationID == stationID).ToList(); |
|
|
|
//排除第一站
|
|
|
|
if (rules.Value.Count() != 0) |
|
|
|
{ |
|
|
|
// 抓有設定下一站=目前作業站的上一站
|
|
|
|
var ruleSations = rules.Value.Select(s => new { s.RuleStationID, s.RuleStatus }).ToList(); |
|
|
|
var nowruleSations = rules.Value.Select(s => new { s.RuleStationID, s.RuleStatus }).ToList(); |
|
|
|
// 取得目前BarCode 最新過站資料
|
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
var barcodeInfo = barcodeInfoesController.GetBarcodeInfoes(barCodeID).Result.Value.FirstOrDefault(); |
|
|
@ -1520,7 +1535,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
if (ruleSations.Where(w => w.RuleStationID == barcodeInfo.RuleStationID |
|
|
|
if (nowruleSations.Where(w => w.RuleStationID == barcodeInfo.RuleStationID |
|
|
|
&& w.RuleStatus == barcodeInfo.RuleStatus).Count() == 0 |
|
|
|
) |
|
|
|
{ |
|
|
@ -1552,49 +1567,28 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
} |
|
|
|
|
|
|
|
var q1 = q.Result.Value.Where(w => w.UnitNO == unitNo).FirstOrDefault(); |
|
|
|
int FlowRuleID = q1.FlowRuleID; |
|
|
|
|
|
|
|
// 將工單-生產單位 流程ID取rulestation的作業站排順序
|
|
|
|
// 取得流程
|
|
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
|
List<dynamic> dy = new List<dynamic>(); |
|
|
|
int index = 1; |
|
|
|
var ruleStations = await ruleStationsController.GetRuleStationByFlow(q1.FlowRuleID, 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.StationID |
|
|
|
}; |
|
|
|
dy.Add(x); |
|
|
|
index++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 在RuleStation 找不到該作業站
|
|
|
|
if (dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault() == null) |
|
|
|
if (!ruleStations.Value.Any(a => a.StationID == stationID)) |
|
|
|
return resultModel; |
|
|
|
|
|
|
|
// 取得目前該站順序
|
|
|
|
int NowIndex = dy.Where(w => w.StationID == stationID).Select(s => s.index).FirstOrDefault(); |
|
|
|
int rulestationID = ruleStations.Value.Where(w => w.StationID == stationID).FirstOrDefault().RuleStationID; |
|
|
|
|
|
|
|
// 判斷下一站沒有資料Error
|
|
|
|
if (dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.StationID).FirstOrDefault() == null) |
|
|
|
return resultModel; |
|
|
|
RulesController rulesController = new RulesController(_context); |
|
|
|
var rules = await rulesController.GetRulesByFlowRuleID(q1.FlowRuleID); |
|
|
|
|
|
|
|
// 當下一站SatationID= 1000 代表完工站
|
|
|
|
if (dy.Where(w => w.index == (NowIndex + 1)).Select(s => s.StationID).FirstOrDefault() == 1000) |
|
|
|
if (rules.Value.Where(w => w.RuleStationID == rulestationID && w.NextStationID == 1000).Any()) |
|
|
|
{ |
|
|
|
resultModel.Success = true; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|