2 changed files with 90 additions and 220 deletions
@ -1,107 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using AMESCoreStudio.WebApi.Models.AMES; |
|
||||
using AMESCoreStudio.WebApi.Controllers.AMES; |
|
||||
using AMESCoreStudio.WebApi.Controllers.BAS; |
|
||||
|
|
||||
namespace AMESCoreStudio.WebApi |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
///
|
|
||||
/// </summary>
|
|
||||
public class BarcodeContext |
|
||||
{ |
|
||||
private readonly AMESContext _context; |
|
||||
|
|
||||
public BarcodeContext(AMESContext context) |
|
||||
{ |
|
||||
_context = context; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 確認工單狀態
|
|
||||
/// </summary>
|
|
||||
/// <param name="WipNo">工單號碼</param>
|
|
||||
/// <param name="UnitNo">生產單位</param>
|
|
||||
/// <param name="FlowRuleID">流程</param>
|
|
||||
/// <param name="Station">站別</param>
|
|
||||
/// <param name="Line">線別</param>
|
|
||||
/// <returns></returns>
|
|
||||
public async Task<string> CheckWipNoSationAsync(string WipNo, string UnitNo, int FlowRuleID, int Station, int Line) |
|
||||
{ |
|
||||
WipInfosController wipInfosController = new WipInfosController(_context); |
|
||||
|
|
||||
var q = await wipInfosController.GetWipInfoByWipNo(WipNo); |
|
||||
if (q.Value.Count() == 0) |
|
||||
return "找不到工單號碼:" + WipNo; |
|
||||
|
|
||||
var WipNoItem = q.Value.Where(w => w.WipNO == WipNo && w.UnitNO == UnitNo).ToList(); |
|
||||
if (WipNoItem.Count == 0) |
|
||||
return "工單號碼:" + WipNo + ",尚未設定此生產單位"; |
|
||||
|
|
||||
if (!WipNoItem.Where(w => w.FlowRuleID == FlowRuleID).Any()) |
|
||||
return "工單號碼:" + WipNo + ",尚未設定此流程站"; |
|
||||
|
|
||||
if (WipNoItem.Where(w => w.StatusNO == "Y").Any()) |
|
||||
return "工單號碼:" + WipNo + ",該工單已經投入完工,請切換工單"; |
|
||||
|
|
||||
WipLockController wipLockController = new WipLockController(_context); |
|
||||
var q1 = await wipLockController.GetWipLockByWipNO(WipNo); |
|
||||
if (q1.Data.Where(w => w.LockStatus == "0" && w.StationID == Station).Any()) |
|
||||
return "工單號碼:" + WipNo + ",工單在當前站別被鎖定,不可過站"; |
|
||||
|
|
||||
int WipID = WipNoItem.FirstOrDefault().WipID; |
|
||||
LineInfoesController lineInfoesController = new LineInfoesController(_context); |
|
||||
var q2 = await lineInfoesController.GetLineInfoByWipID(WipID); |
|
||||
if (!q2.Value.Where(w => w.LineID == Line).Any()) |
|
||||
return "工單號碼:" + WipNo + ",工單尚未開線,不可過站"; |
|
||||
|
|
||||
|
|
||||
return ""; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 內部序號是否被鎖定
|
|
||||
/// </summary>
|
|
||||
/// <param name="WipNo"></param>
|
|
||||
/// <param name="BarCode"></param>
|
|
||||
/// <returns></returns>
|
|
||||
public 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>
|
|
||||
/// 判斷內部序號對應工單號買
|
|
||||
/// </summary>
|
|
||||
/// <param name="BarCode">內部序號</param>
|
|
||||
/// <returns></returns>
|
|
||||
public async Task<string> CheckBarCodeFromWip(string BarCode) |
|
||||
{ |
|
||||
//if (BarCode.Length <= 4)
|
|
||||
return "NG, 找不到相關工單號碼"; |
|
||||
|
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue