|
|
@ -39,20 +39,48 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
/// <param name="line">線別</param>
|
|
|
|
/// <param name="flowrule">流程</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("BarCodeDataCheck")] |
|
|
|
public IActionResult GetBarCodeDataCheck(string wipno, string unitno, int station, int line, int flowrule) |
|
|
|
[HttpGet("CheckWipNoSation")] |
|
|
|
public IActionResult GetCheckWipNoSation(string wipno, string unitno, int station, int line, int flowrule) |
|
|
|
{ |
|
|
|
var result = CheckWipNoSationAsync(WipNo: wipno, UnitNo: unitno, FlowRuleID: flowrule, Station: station, Line: line); |
|
|
|
return Ok(result.Result); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判斷序號狀態
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="wipno"></param>
|
|
|
|
/// <param name="barcode"></param>
|
|
|
|
/// <param name="unitno"></param>
|
|
|
|
/// <param name="station"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("CheckBarCodeStation")] |
|
|
|
public async Task<IActionResult> GetCheckBarCodeStation(string wipno, string barcode, string unitno, int station) |
|
|
|
{ |
|
|
|
//ResultModel<string> resultModel = new ResultModel<string>()
|
|
|
|
//ResultModel<string> aa = await (ResultModel<string>)CheckBarCodeLockAsync(barcode);
|
|
|
|
//return Ok(aa);
|
|
|
|
|
|
|
|
//return Ok();
|
|
|
|
//resultModel = (ResultModel<string>)CheckBarCodeLockAsync(barcode).AsyncState;
|
|
|
|
//if (!resultModel.Success)
|
|
|
|
// return Ok(resultModel);
|
|
|
|
|
|
|
|
//resultModel = (ResultModel<string>)CheckBarCodeScrappedAsync(barcode).AsyncState;
|
|
|
|
//if (!resultModel.Success)
|
|
|
|
// return Ok(resultModel);
|
|
|
|
|
|
|
|
return Ok(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 內部序號查詢工單號碼
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="barcode">內部序號</param>
|
|
|
|
/// <returns>Success:true or false</returns>
|
|
|
|
[HttpGet("BarCodeFromWip")] |
|
|
|
public IActionResult CheckBarCodeFromWip(string barcode) |
|
|
|
public ActionResult<ResultModel<string>> CheckBarCodeFromWip(string barcode) |
|
|
|
{ |
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
if (barcode.Length <= 4) |
|
|
@ -228,6 +256,151 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 確認內部條碼流動
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="wipno">工單號碼</param>
|
|
|
|
/// <param name="barcode">內部條碼</param>
|
|
|
|
/// <param name="unitno">生產單位編號</param>
|
|
|
|
/// <param name="station">作業站編號</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("BarCodeFlow")] |
|
|
|
public async Task<IActionResult> CheckBarCodeFlowAsync(string wipno, string barcode, string unitno, int station) |
|
|
|
{ |
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
var q = await wipInfosController.GetWipInfoByWipNo(wipno); |
|
|
|
if (q.Value.Count() == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "找不到工單號碼【" + wipno + "】"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
// 找該筆工單號碼的生產單位代號
|
|
|
|
var q1 = q.Value.Where(w => w.UnitNO == unitno).FirstOrDefault(); |
|
|
|
if (q1 == null) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】 找不到對應生產單位代號資料"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
// 取工單號碼開立的 WipID、生產單位
|
|
|
|
var wipinfo = q.Value.Select(s => new { s.WipID, s.UnitNO }).ToList(); |
|
|
|
|
|
|
|
// 取BarCodeID
|
|
|
|
int BarCodeID = await BarCodeToID(barcode); |
|
|
|
|
|
|
|
// 取內部序號過站紀錄
|
|
|
|
BarcodeStationController barcodeStationController = new BarcodeStationController(_context); |
|
|
|
var BarCodeStations = await barcodeStationController.GetBarcodeStationByBarCodeID(BarCodeID); |
|
|
|
BarCodeStations = BarCodeStations.Value.ToList(); |
|
|
|
|
|
|
|
// 判斷需要前製程是否已經投入
|
|
|
|
if (q1.InputFlag == "Y") |
|
|
|
{ |
|
|
|
// 有BarCodeID
|
|
|
|
if (BarCodeID != 0) |
|
|
|
{ |
|
|
|
// 判斷是否有前製程過站資料
|
|
|
|
// SMT(S)->DIP(D)
|
|
|
|
if (unitno == "D") |
|
|
|
{ |
|
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "S").Select(s => s.WipID).FirstOrDefault(); |
|
|
|
if (WipID == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
if (!BarCodeStations.Value.Where(w => w.BarcodeID == BarCodeID && w.WipID == WipID && w.RuleStatus == "P").Any()) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該內部序號【" + barcode + "】前製程生產單位尚未有過站紀錄"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
} |
|
|
|
// 組裝(B)->系統測試(T)->成品包裝(P)
|
|
|
|
else if (unitno == "T") |
|
|
|
{ |
|
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "B").Select(s => s.WipID).FirstOrDefault(); |
|
|
|
if (WipID == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
if (!BarCodeStations.Value.Where(w => w.BarcodeID == BarCodeID && w.WipID == WipID && w.RuleStatus == "P").Any()) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該內部序號【" + barcode + "】前製程生產單位尚未有過站紀錄"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (unitno == "P") |
|
|
|
{ |
|
|
|
int? WipID = wipinfo.Where(w => w.UnitNO == "T").Select(s => s.WipID).FirstOrDefault(); |
|
|
|
if (WipID == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
if (!BarCodeStations.Value.Where(w => w.BarcodeID == BarCodeID && w.WipID == WipID && w.RuleStatus == "P").Any()) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該內部序號【" + barcode + "】前製程生產單位尚未有過站紀錄"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 沒有BarCodeID
|
|
|
|
else |
|
|
|
{ |
|
|
|
if (unitno != "S" && unitno != "B") |
|
|
|
{ |
|
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】前製程式尚未投產"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region 判斷作業站順序
|
|
|
|
// 抓流程順序資料
|
|
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
|
var ruleStations = await ruleStationsController.GetRuleStationByFlow(q1.FlowRuleID, 0); |
|
|
|
if (ruleStations.Value.Count() == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的流程編號尚未設定流程"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
// 該作業站 RuleStationID
|
|
|
|
int? RuleStationID = ruleStations.Value.Where(w => w.StationID == station).Select(s => s.RuleStationID).FirstOrDefault(); |
|
|
|
// 該作業站順序
|
|
|
|
int? Sequence = ruleStations.Value.Where(w => w.StationID == station).Select(s => s.Sequence).FirstOrDefault(); |
|
|
|
if (RuleStationID == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "該工單號碼【" + wipno + "】的流程未設定此作業站"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
// 取目前工單ID
|
|
|
|
int wipID = q1.WipID; |
|
|
|
// 該筆工單ID過站紀錄
|
|
|
|
var BarCodeStationByWipID = BarCodeStations.Value.Where(w => w.WipID == wipID).ToList(); |
|
|
|
foreach (var item in ruleStations.Value.OrderBy(o => o.Sequence)) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
return Ok(ruleStations); |
|
|
|
//if (q.Value.Any(w => w.RuleStatus == "S"))
|
|
|
|
//{
|
|
|
|
// resultModel.Msg = "內部序號【" + barcode + "】已報廢或轉賣, 不可繼續過站!";
|
|
|
|
// return Ok(resultModel);
|
|
|
|
|
|
|
|
//}
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 確認工單狀態
|
|
|
|
/// </summary>
|
|
|
@ -291,35 +464,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 內部序號是否被鎖定
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="WipNo">工單號碼</param>
|
|
|
|
/// <param name="BarCode">內部序號</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<string> CheckBarCodeStationAsync(string WipNo, string BarCode) |
|
|
|
{ |
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
|
|
|
|
// 序號與工單相同視為序號
|
|
|
|
if (BarCode.IndexOf(WipNo) != -1) |
|
|
|
{ |
|
|
|
// 判斷BarCodeInfo 是否有條碼序號資料
|
|
|
|
var q = await barcodeInfoesController.GetBarcodeInfoesByNo(BarCode); |
|
|
|
if (q.Value.Count() != 0) |
|
|
|
{ |
|
|
|
// 判斷條碼序號是否有被鎖定
|
|
|
|
BarcodeLockController barcodeLockController = new BarcodeLockController(_context); |
|
|
|
var q1 = await barcodeLockController.GetBarcodeLockByBarCodeID(q.Value.FirstOrDefault().BarcodeID); |
|
|
|
if (q1.Value.Where(w => w.LockStatus == 0).Any()) |
|
|
|
{ |
|
|
|
return "條碼編號:" + BarCode + ",已被鎖定,無法過站"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 內部序號找BarCodeID
|
|
|
|