|
|
@ -42,322 +42,339 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
{ |
|
|
|
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|
|
|
|
|
|
|
#region 欄位資料空值判斷
|
|
|
|
if (string.IsNullOrWhiteSpace(barCodeCheckDto.wipNo)) |
|
|
|
try |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入工單號碼"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(barCodeCheckDto.barcode)) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入內部條碼"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
if (barCodeCheckDto.inputItems == null) |
|
|
|
barCodeCheckDto.inputItems = new List<BarCodeCheckDto.inputItem>(); |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(barCodeCheckDto.unitNo)) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入生產單位"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
if (barCodeCheckDto.outfits == null) |
|
|
|
barCodeCheckDto.outfits = new List<BarCodeCheckDto.Outfit>(); |
|
|
|
|
|
|
|
if (barCodeCheckDto.station == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入作業站代碼"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
#region 欄位資料空值判斷
|
|
|
|
if (string.IsNullOrWhiteSpace(barCodeCheckDto.wipNo)) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入工單號碼"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
if (barCodeCheckDto.line == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入線別代碼"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
if (string.IsNullOrWhiteSpace(barCodeCheckDto.barcode)) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入內部條碼"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
#region 宣告各個Controller
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
WipMACController wipMACController = new WipMACController(_context); |
|
|
|
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); |
|
|
|
BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); |
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
BarcodeItemChangesController barcodeItemChangesController = new BarcodeItemChangesController(_context); |
|
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
|
MaterialKpController materialKpController = new MaterialKpController(_context); |
|
|
|
#endregion
|
|
|
|
if (string.IsNullOrWhiteSpace(barCodeCheckDto.unitNo)) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入生產單位"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
#region 宣告參數
|
|
|
|
// 料號ID
|
|
|
|
int itemID = 0; |
|
|
|
// 料號
|
|
|
|
string item = string.Empty; |
|
|
|
// 存放要更新BarCodeItem
|
|
|
|
var update_BarCodeItem = new List<BarcodeItem>(); |
|
|
|
var insert_BarCodeItemChange = new List<BarcodeItemChange>(); |
|
|
|
#endregion
|
|
|
|
if (barCodeCheckDto.station == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入作業站代碼"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
|
|
|
|
// 抓流程ID
|
|
|
|
var q_wipinfo = await wipInfosController.GetWipInfoByWipNo(barCodeCheckDto.wipNo); |
|
|
|
barCodeCheckDto.flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; |
|
|
|
if (barCodeCheckDto.line == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "請輸入線別代碼"; |
|
|
|
return Ok(resultModel); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷工單狀態
|
|
|
|
resultModel = (ResultModel<string>)await CheckWipNoSationAsync(wipNo: barCodeCheckDto.wipNo, unitNo: barCodeCheckDto.unitNo |
|
|
|
, flowRuleID: barCodeCheckDto.flowRule, line: barCodeCheckDto.line, station: barCodeCheckDto.station); |
|
|
|
#region 宣告各個Controller
|
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
WipMACController wipMACController = new WipMACController(_context); |
|
|
|
WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); |
|
|
|
BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); |
|
|
|
BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); |
|
|
|
BarcodeItemChangesController barcodeItemChangesController = new BarcodeItemChangesController(_context); |
|
|
|
RuleStationsController ruleStationsController = new RuleStationsController(_context); |
|
|
|
MaterialKpController materialKpController = new MaterialKpController(_context); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (!resultModel.Success) |
|
|
|
return resultModel; |
|
|
|
#endregion
|
|
|
|
#region 宣告參數
|
|
|
|
// 料號ID
|
|
|
|
int itemID = 0; |
|
|
|
// 料號
|
|
|
|
string item = string.Empty; |
|
|
|
// 存放要更新BarCodeItem
|
|
|
|
var update_BarCodeItem = new List<BarcodeItem>(); |
|
|
|
var insert_BarCodeItemChange = new List<BarcodeItemChange>(); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷序號狀態
|
|
|
|
resultModel = (ResultModel<string>)await GetCheckBarCodeStation(wipno: barCodeCheckDto.wipNo, barcode: barCodeCheckDto.barcode); |
|
|
|
if (!resultModel.Success) |
|
|
|
return resultModel; |
|
|
|
#endregion
|
|
|
|
// 抓流程ID
|
|
|
|
var q_wipinfo = await wipInfosController.GetWipInfoByWipNo(barCodeCheckDto.wipNo); |
|
|
|
barCodeCheckDto.flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; |
|
|
|
|
|
|
|
#region 判斷序號流程
|
|
|
|
resultModel = (ResultModel<string>)await CheckBarCodeFlowAsync(wipno: barCodeCheckDto.wipNo, barcode: barCodeCheckDto.barcode |
|
|
|
, unitno: barCodeCheckDto.unitNo, station: barCodeCheckDto.station); |
|
|
|
#region 判斷工單狀態
|
|
|
|
resultModel = (ResultModel<string>)await CheckWipNoSationAsync(wipNo: barCodeCheckDto.wipNo, unitNo: barCodeCheckDto.unitNo |
|
|
|
, flowRuleID: barCodeCheckDto.flowRule, line: barCodeCheckDto.line, station: barCodeCheckDto.station); |
|
|
|
|
|
|
|
if (!resultModel.Success) |
|
|
|
return resultModel; |
|
|
|
#endregion
|
|
|
|
if (!resultModel.Success) |
|
|
|
return resultModel; |
|
|
|
#endregion
|
|
|
|
|
|
|
|
barCodeCheckDto.wipID = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().WipID; |
|
|
|
barCodeCheckDto.flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; |
|
|
|
barCodeCheckDto.barcodeID = BarCodeToID(barCodeCheckDto.barcode).Result; |
|
|
|
item = q_wipinfo.Value.FirstOrDefault().GetWipAtt.ItemNO; |
|
|
|
itemID = ItemNoToItemID(item).Result; |
|
|
|
#region 判斷序號狀態
|
|
|
|
resultModel = (ResultModel<string>)await GetCheckBarCodeStation(wipno: barCodeCheckDto.wipNo, barcode: barCodeCheckDto.barcode); |
|
|
|
if (!resultModel.Success) |
|
|
|
return resultModel; |
|
|
|
#endregion
|
|
|
|
|
|
|
|
// 抓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 判斷序號流程
|
|
|
|
resultModel = (ResultModel<string>)await CheckBarCodeFlowAsync(wipno: barCodeCheckDto.wipNo, barcode: barCodeCheckDto.barcode |
|
|
|
, unitno: barCodeCheckDto.unitNo, station: barCodeCheckDto.station); |
|
|
|
|
|
|
|
#region KeyParts 判斷
|
|
|
|
if (barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Count() != 0) |
|
|
|
{ |
|
|
|
var barcodeItemKPDto = new BarcodeItemKPDto |
|
|
|
{ |
|
|
|
WipNo = barCodeCheckDto.wipNo, |
|
|
|
barcode = barCodeCheckDto.barcode, |
|
|
|
unitNo = barCodeCheckDto.unitNo, |
|
|
|
inputKP = barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Select(s => s.inputData).ToList() |
|
|
|
}; |
|
|
|
if (!resultModel.Success) |
|
|
|
return resultModel; |
|
|
|
#endregion
|
|
|
|
|
|
|
|
var resultKeyParts = await CheckBarCodeKPAsync(barcodeItemKPDto); |
|
|
|
if (!resultKeyParts.Success) |
|
|
|
return (ResultModel<string>)resultKeyParts; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
barCodeCheckDto.wipID = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().WipID; |
|
|
|
barCodeCheckDto.flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; |
|
|
|
barCodeCheckDto.barcodeID = BarCodeToID(barCodeCheckDto.barcode).Result; |
|
|
|
item = q_wipinfo.Value.FirstOrDefault().GetWipAtt.ItemNO; |
|
|
|
itemID = ItemNoToItemID(item).Result; |
|
|
|
|
|
|
|
// 維修過站 組件需獨立判斷
|
|
|
|
if (barCodeCheckDto.barcodeType == "S") |
|
|
|
{ |
|
|
|
// 確認新舊組件序號是否都有值
|
|
|
|
if (barCodeCheckDto.inputItems.Where(w => w.inputType != "NG" && |
|
|
|
(string.IsNullOrWhiteSpace(w.inputData) || string.IsNullOrWhiteSpace(w.oldInputData))).Any()) |
|
|
|
// 抓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 判斷
|
|
|
|
if (barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Any()) |
|
|
|
{ |
|
|
|
resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】維修過站資料有缺新舊組件序號,請確認"; |
|
|
|
return resultModel; |
|
|
|
var barcodeItemKPDto = new BarcodeItemKPDto |
|
|
|
{ |
|
|
|
WipNo = barCodeCheckDto.wipNo, |
|
|
|
barcode = barCodeCheckDto.barcode, |
|
|
|
unitNo = barCodeCheckDto.unitNo, |
|
|
|
inputKP = barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Select(s => s.inputData).ToList() |
|
|
|
}; |
|
|
|
|
|
|
|
var resultKeyParts = await CheckBarCodeKPAsync(barcodeItemKPDto); |
|
|
|
if (!resultKeyParts.Success) |
|
|
|
return (ResultModel<string>)resultKeyParts; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
// 用BarCodeID And WipID 取BarCodeItem
|
|
|
|
// 維修過站 組件需獨立判斷
|
|
|
|
if (barCodeCheckDto.barcodeType == "S") |
|
|
|
{ |
|
|
|
// 確認新舊組件序號是否都有值
|
|
|
|
if (barCodeCheckDto.inputItems.Where(w => w.inputType != "NG" && |
|
|
|
(string.IsNullOrWhiteSpace(w.inputData) || string.IsNullOrWhiteSpace(w.oldInputData))).Any()) |
|
|
|
{ |
|
|
|
resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】維修過站資料有缺新舊組件序號,請確認"; |
|
|
|
resultModel.Success = false; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
var q_BarCodeItem = await barcodeItemsController.GetBarcodeItemByBarCodeID(barCodeCheckDto.barcodeID); |
|
|
|
q_BarCodeItem = q_BarCodeItem.Value.Where(w => w.WipID == barCodeCheckDto.wipID).ToList(); |
|
|
|
// 用BarCodeID And WipID 取BarCodeItem
|
|
|
|
|
|
|
|
foreach (var KPs in barCodeCheckDto.inputItems) |
|
|
|
{ |
|
|
|
// 用舊組件序號比對
|
|
|
|
var barCodeItem = q_BarCodeItem.Value.Where(w => w.PartNo == KPs.oldInputData).FirstOrDefault(); |
|
|
|
var q_BarCodeItem = await barcodeItemsController.GetBarcodeItemByBarCodeID(barCodeCheckDto.barcodeID); |
|
|
|
q_BarCodeItem = q_BarCodeItem.Value.Where(w => w.WipID == barCodeCheckDto.wipID).ToList(); |
|
|
|
|
|
|
|
if (barCodeItem != null) |
|
|
|
foreach (var KPs in barCodeCheckDto.inputItems) |
|
|
|
{ |
|
|
|
// 用舊組件序號比對
|
|
|
|
var barCodeItem = q_BarCodeItem.Value.Where(w => w.PartNo == KPs.oldInputData).FirstOrDefault(); |
|
|
|
|
|
|
|
var MaterialKps = (await materialKpController.GetMaterialKpByItemID(itemID)).ToList(); |
|
|
|
MaterialKps = MaterialKps.Where(w => w.StationType == barCodeCheckDto.unitNo).OrderBy(o => o.KpSeq).ToList(); |
|
|
|
if (MaterialKps.Count == 0) |
|
|
|
if (barCodeItem != null) |
|
|
|
{ |
|
|
|
resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】找不到相關Key Parts對應"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var q_Kp = MaterialKps.Where(w => w.KpNo == barCodeItem.ItemNo).FirstOrDefault(); |
|
|
|
if (q_Kp != null) |
|
|
|
{ |
|
|
|
#region 比對序號長度是否正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(q_Kp.Length.ToString())) |
|
|
|
{ |
|
|
|
if (q_Kp.Length != KPs.inputData.Length) |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.KpName + "】長度不符合</br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 前置碼正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(q_Kp.Title)) |
|
|
|
{ |
|
|
|
if (!KPs.inputData.ToUpper().StartsWith(q_Kp.Title.ToUpper())) |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.Title + "】前置碼不符合</br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 組件代碼-組件序號是否重複
|
|
|
|
var checkDataRedundancy = await barcodeItemsController.GetBarcodeItemByDataRedundancy(q_Kp.KpNo, KPs.inputData); |
|
|
|
if (checkDataRedundancy.Value.Count() != 0) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件名稱【" + q_Kp.KpName + "】已有相同組件序號【" + KPs.inputData + "】紀錄 </br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
|
if (q_Kp.KpNo.ToUpper() == "04") |
|
|
|
var MaterialKps = (await materialKpController.GetMaterialKpByItemID(itemID)).ToList(); |
|
|
|
MaterialKps = MaterialKps.Where(w => w.StationType == barCodeCheckDto.unitNo).OrderBy(o => o.KpSeq).ToList(); |
|
|
|
if (MaterialKps.Count == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】找不到相關Key Parts對應"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var q_Kp = MaterialKps.Where(w => w.KpNo == barCodeItem.ItemNo).FirstOrDefault(); |
|
|
|
if (q_Kp != null) |
|
|
|
{ |
|
|
|
#region 比對序號長度是否正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(q_Kp.Length.ToString())) |
|
|
|
{ |
|
|
|
if (q_Kp.Length != KPs.inputData.Length) |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.KpName + "】長度不符合</br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(KPs.inputData); |
|
|
|
if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) |
|
|
|
#region 前置碼正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(q_Kp.Title)) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 目前是在製狀態</br>"; |
|
|
|
if (!KPs.inputData.ToUpper().StartsWith(q_Kp.Title.ToUpper())) |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.Title + "】前置碼不符合</br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷MAC區間
|
|
|
|
if (q_Kp.KpNo.ToUpper() == "94") |
|
|
|
{ |
|
|
|
#region 組件代碼-組件序號是否重複
|
|
|
|
var checkDataRedundancy = await barcodeItemsController.GetBarcodeItemByDataRedundancy(q_Kp.KpNo, KPs.inputData); |
|
|
|
if (checkDataRedundancy.Value.Count() != 0) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件名稱【" + q_Kp.KpName + "】已有相同組件序號【" + KPs.inputData + "】紀錄 </br>"; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
var wipMAC = await wipMACController.GetWipMAC(barCodeCheckDto.wipNo); |
|
|
|
if (wipMAC.Value == null) |
|
|
|
#region 判斷組件序號是否在製狀態
|
|
|
|
if (q_Kp.KpNo.ToUpper() == "04") |
|
|
|
{ |
|
|
|
resultModel.Msg += "工單號碼【" + barCodeCheckDto.wipNo + "】 找不到綁定MAC區間</br>"; |
|
|
|
|
|
|
|
var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(KPs.inputData); |
|
|
|
if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 目前是在製狀態</br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷MAC區間
|
|
|
|
if (q_Kp.KpNo.ToUpper() == "94") |
|
|
|
{ |
|
|
|
// 判斷MAC前置碼是否一樣
|
|
|
|
if (!KPs.inputData.StartsWith(wipMAC.Value.Title)) |
|
|
|
|
|
|
|
var wipMAC = await wipMACController.GetWipMAC(barCodeCheckDto.wipNo); |
|
|
|
if (wipMAC.Value == null) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合 </br>"; |
|
|
|
resultModel.Msg += "工單號碼【" + barCodeCheckDto.wipNo + "】 找不到綁定MAC區間</br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// 判斷是否符合區間
|
|
|
|
if (KPs.inputData.Length == 12) |
|
|
|
// 判斷MAC前置碼是否一樣
|
|
|
|
if (!KPs.inputData.StartsWith(wipMAC.Value.Title)) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合 </br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) |
|
|
|
&& Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) |
|
|
|
// 判斷是否符合區間
|
|
|
|
if (KPs.inputData.Length == 12) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定MAC區間不符合 </br>"; |
|
|
|
if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) |
|
|
|
&& Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定MAC區間不符合 </br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判斷出貨序號
|
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
|
if (q_Kp.KpNo.ToUpper() == "95") |
|
|
|
{ |
|
|
|
#endregion
|
|
|
|
|
|
|
|
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barCodeCheckDto.wipNo, KPs.inputData); |
|
|
|
if (WipBarCodeOther.Value.Count() == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定出貨序號區間不符合 </br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
#region 判斷出貨序號
|
|
|
|
// 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間
|
|
|
|
if (q_Kp.KpNo.ToUpper() == "95") |
|
|
|
{ |
|
|
|
//resultModel.Data = new List<string> { KPs.inputData };
|
|
|
|
//resultModel.Msg = "EXT_NO";
|
|
|
|
|
|
|
|
var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barCodeCheckDto.wipNo, KPs.inputData); |
|
|
|
if (WipBarCodeOther.Value.Count() == 0) |
|
|
|
{ |
|
|
|
resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定出貨序號區間不符合 </br>"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//resultModel.Data = new List<string> { KPs.inputData };
|
|
|
|
//resultModel.Msg = "EXT_NO";
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
barCodeItem.PartNo = KPs.inputData; |
|
|
|
barCodeItem.RuleStationID = barCodeCheckDto.ruleStationID; |
|
|
|
barCodeItem.UpdateDate = DateTime.Now; |
|
|
|
update_BarCodeItem.Add(barCodeItem); |
|
|
|
barCodeItem.PartNo = KPs.inputData; |
|
|
|
barCodeItem.RuleStationID = barCodeCheckDto.ruleStationID; |
|
|
|
barCodeItem.UpdateDate = DateTime.Now; |
|
|
|
update_BarCodeItem.Add(barCodeItem); |
|
|
|
|
|
|
|
insert_BarCodeItemChange.Add(new BarcodeItemChange |
|
|
|
{ |
|
|
|
WipID = barCodeCheckDto.wipID, |
|
|
|
RuleStationID = barCodeCheckDto.ruleStationID, |
|
|
|
BarcodeID = barCodeCheckDto.barcodeID, |
|
|
|
ItemNo = barCodeItem.ItemNo, |
|
|
|
PartNoOld = KPs.oldInputData, |
|
|
|
ChangeType = "RP", |
|
|
|
KpItemNo = KPs.inputData |
|
|
|
}); |
|
|
|
insert_BarCodeItemChange.Add(new BarcodeItemChange |
|
|
|
{ |
|
|
|
WipID = barCodeCheckDto.wipID, |
|
|
|
RuleStationID = barCodeCheckDto.ruleStationID, |
|
|
|
BarcodeID = barCodeCheckDto.barcodeID, |
|
|
|
ItemNo = barCodeItem.ItemNo, |
|
|
|
PartNoOld = KPs.oldInputData, |
|
|
|
ChangeType = "RP", |
|
|
|
KpItemNo = KPs.inputData |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(resultModel.Msg)) |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(resultModel.Msg)) |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
//var NextStopCloseStation = await CheckNextStopCloseStation(barCodeCheckDto.wipNo, barCodeCheckDto.unitNo, barCodeCheckDto.station);
|
|
|
|
|
|
|
|
//var NextStopCloseStation = await CheckNextStopCloseStation(barCodeCheckDto.wipNo, barCodeCheckDto.unitNo, barCodeCheckDto.station);
|
|
|
|
// 過站判斷正常 往下處理Table
|
|
|
|
|
|
|
|
// 過站判斷正常 往下處理Table
|
|
|
|
#region 內部序號輸入後新增 or 更新
|
|
|
|
if (barCodeCheckDto.inputItems.Where(w => w.inputData.Contains("$")).Count() != 0) |
|
|
|
barCodeCheckDto.ruleStatus = "F"; |
|
|
|
else |
|
|
|
barCodeCheckDto.ruleStatus = "P"; |
|
|
|
|
|
|
|
#region 內部序號輸入後新增 or 更新
|
|
|
|
if (barCodeCheckDto.inputItems.Where(w => w.inputData.Contains("$")).Count() != 0) |
|
|
|
barCodeCheckDto.ruleStatus = "F"; |
|
|
|
else |
|
|
|
barCodeCheckDto.ruleStatus = "P"; |
|
|
|
CU_Tables(barCodeCheckDto); |
|
|
|
|
|
|
|
CU_Tables(barCodeCheckDto); |
|
|
|
//var barcodeInfo = barcodeInfoesController.GetBarcodeInfoes(barCodeCheckDto.barcodeID).Result.Value.FirstOrDefault();
|
|
|
|
//barcodeInfo.RuleStationID = barCodeCheckDto.ruleStationID;
|
|
|
|
//barcodeInfo.RuleStatus = "P";
|
|
|
|
|
|
|
|
//var barcodeInfo = barcodeInfoesController.GetBarcodeInfoes(barCodeCheckDto.barcodeID).Result.Value.FirstOrDefault();
|
|
|
|
//barcodeInfo.RuleStationID = barCodeCheckDto.ruleStationID;
|
|
|
|
//barcodeInfo.RuleStatus = "P";
|
|
|
|
//var resultBarCodeInfo = await barcodeInfoesController.PutBarcodeInfoes(barcodeInfo);
|
|
|
|
//if (resultBarCodeInfo.Success)
|
|
|
|
//{
|
|
|
|
// // 新增 BarCodeStation
|
|
|
|
// BarcodeStation barcodeStation = new BarcodeStation
|
|
|
|
// {
|
|
|
|
// BarcodeID = barCodeCheckDto.barcodeID,
|
|
|
|
// WipID = barCodeCheckDto.wipID,
|
|
|
|
// RuleStationID = barCodeCheckDto.ruleStationID,
|
|
|
|
// RuleStatus = "P", //F 不良
|
|
|
|
// InputDate = DateTime.Now,
|
|
|
|
// LineId = barCodeCheckDto.line
|
|
|
|
// };
|
|
|
|
// await barcodeStationController.PostBarcodeStation(barcodeStation);
|
|
|
|
|
|
|
|
// // 新增 BarCodeItem
|
|
|
|
// // 先查詢已綁定組件數量
|
|
|
|
// //var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCodeID(model.BarCodeID);
|
|
|
|
// //int KpItemQty = BarCodeItems.Count();
|
|
|
|
|
|
|
|
// foreach (var item_barCodeItem in update_BarCodeItem)
|
|
|
|
// {
|
|
|
|
// await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// foreach (var item_barCodeItemChange in insert_BarCodeItemChange)
|
|
|
|
// {
|
|
|
|
// await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange);
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
// #endregion
|
|
|
|
//}
|
|
|
|
|
|
|
|
//var resultBarCodeInfo = await barcodeInfoesController.PutBarcodeInfoes(barcodeInfo);
|
|
|
|
//if (resultBarCodeInfo.Success)
|
|
|
|
//{
|
|
|
|
// // 新增 BarCodeStation
|
|
|
|
// BarcodeStation barcodeStation = new BarcodeStation
|
|
|
|
// {
|
|
|
|
// BarcodeID = barCodeCheckDto.barcodeID,
|
|
|
|
// WipID = barCodeCheckDto.wipID,
|
|
|
|
// RuleStationID = barCodeCheckDto.ruleStationID,
|
|
|
|
// RuleStatus = "P", //F 不良
|
|
|
|
// InputDate = DateTime.Now,
|
|
|
|
// LineId = barCodeCheckDto.line
|
|
|
|
// };
|
|
|
|
// await barcodeStationController.PostBarcodeStation(barcodeStation);
|
|
|
|
|
|
|
|
// // 新增 BarCodeItem
|
|
|
|
// // 先查詢已綁定組件數量
|
|
|
|
// //var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCodeID(model.BarCodeID);
|
|
|
|
// //int KpItemQty = BarCodeItems.Count();
|
|
|
|
|
|
|
|
// foreach (var item_barCodeItem in update_BarCodeItem)
|
|
|
|
// {
|
|
|
|
// await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// foreach (var item_barCodeItemChange in insert_BarCodeItemChange)
|
|
|
|
// {
|
|
|
|
// await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange);
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
// #endregion
|
|
|
|
//}
|
|
|
|
foreach (var item_barCodeItem in update_BarCodeItem) |
|
|
|
{ |
|
|
|
await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var item_barCodeItem in update_BarCodeItem) |
|
|
|
{ |
|
|
|
await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem); |
|
|
|
} |
|
|
|
foreach (var item_barCodeItemChange in insert_BarCodeItemChange) |
|
|
|
{ |
|
|
|
await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var item_barCodeItemChange in insert_BarCodeItemChange) |
|
|
|
resultModel.Msg = "內部序號【" + barCodeCheckDto.barcode + "】 過站完成!"; |
|
|
|
resultModel.Success = true; |
|
|
|
return resultModel; |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange); |
|
|
|
resultModel.Success = false; |
|
|
|
resultModel.Msg = ex.Message; |
|
|
|
return resultModel; |
|
|
|
} |
|
|
|
|
|
|
|
resultModel.Msg = "內部序號【" + barCodeCheckDto.barcode + "】 過站完成!"; |
|
|
|
resultModel.Success = true; |
|
|
|
return resultModel; |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
@ -375,52 +392,59 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!Table_BarcodeStation(barCodeCheckDto).Result.Success) |
|
|
|
if (!Table_BarcodeWip(barCodeCheckDto).Result.Success) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!Table_BarcodeItem(barCodeCheckDto).Result.Success) |
|
|
|
if (!Table_WipStation(barCodeCheckDto).Result.Success) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!Table_NgInfo(barCodeCheckDto).Result.Success) |
|
|
|
if (!Table_WipClass(barCodeCheckDto).Result.Success) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!Table_BarcodeWip(barCodeCheckDto).Result.Success) |
|
|
|
if (!Table_WipTime(barCodeCheckDto).Result.Success) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!Table_WipStation(barCodeCheckDto).Result.Success) |
|
|
|
if (!Table_BarcodeStation(barCodeCheckDto).Result.Success) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!Table_WipClass(barCodeCheckDto).Result.Success) |
|
|
|
if (!Table_BarcodeItem(barCodeCheckDto).Result.Success) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!Table_WipTime(barCodeCheckDto).Result.Success) |
|
|
|
if (!Table_NgInfo(barCodeCheckDto).Result.Success) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 工單基本檔案
|
|
|
|
//if (!Table_WipInfo(barCodeCheckDto).Result.Success)
|
|
|
|
//{
|
|
|
|
|
|
|
|
//}
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// BarcodeInfo-條碼資料檔
|
|
|
|
/// WipInfo-工單基本資料
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="barCodeCheckDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<ResultModel<WipInfo>> Table_WipInfo(BarCodeCheckDto barCodeCheckDto) |
|
|
|
{ |
|
|
|
WipInfosController wipInfosController = new WipInfosController(_context); |
|
|
|
var wipinfo = wipInfosController.GetWipInfo(barCodeCheckDto.wipID) |
|
|
|
.Result.Value.FirstOrDefault(); |
|
|
|
var wipinfo = await _context.WipInfos.FindAsync(barCodeCheckDto.wipID); |
|
|
|
|
|
|
|
|
|
|
|
return await wipInfosController.PutWipinfo(wipinfo); |
|
|
|