|
|
@ -7315,174 +7315,215 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
* 3.若有序號不可入庫 => 畫面顯示不可入之序號 |
|
|
|
* 4.所有序號可入庫 = > |
|
|
|
*/ |
|
|
|
|
|
|
|
var result = await _fqcApi.GetBarcodeInfoesByBoxNo(boxNo: boxNo); |
|
|
|
|
|
|
|
var result = await _fqcApi.GetBarcodeInfoesByBoxNo(boxNo: boxNo); |
|
|
|
|
|
|
|
if (result.Count() != 0) |
|
|
|
{ |
|
|
|
var _msg = string.Empty; |
|
|
|
|
|
|
|
if (recordNumber == null) _msg = "請輸入入庫箱號"; |
|
|
|
if (AppSetting.Setting.Location == "9000" || AppSetting.Setting.Location == "0S08") |
|
|
|
{ |
|
|
|
if (recordNumber.Length != 10 || !recordNumber.StartsWith("50000")) |
|
|
|
{ |
|
|
|
_msg = "箱號:" + boxNo + " recordNumber 必須為10碼且為50000開頭,RecordNumber format error<br>"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
foreach (var item in result) |
|
|
|
try |
|
|
|
{ |
|
|
|
var FlowStation_result = await _basApi.GetRuleStation(item.StationID); |
|
|
|
if (FlowStation_result.Count() != 0) |
|
|
|
if (recordNumber == null) _msg = "請輸入recordNumber"; |
|
|
|
if (AppSetting.Setting.Location == "9000" || AppSetting.Setting.Location == "0S08") |
|
|
|
{ |
|
|
|
var FlowRule_result = await _basApi.GetRuleStationsByFlow(FlowStation_result.Select(s => s.FlowRuleID).First()); |
|
|
|
if (FlowRule_result.Count() != 0) |
|
|
|
if (recordNumber.Length != 10 || !recordNumber.StartsWith("50000")) |
|
|
|
{ |
|
|
|
var LastStationID = FlowRule_result.Where(w => w.StationID != 1000).OrderBy(o => o.Sequence).Select(s => s.StationID).Last(); |
|
|
|
_msg = "箱號:" + boxNo + " recordNumber 必須為10碼且為50000開頭,RecordNumber format error<br>"; |
|
|
|
|
|
|
|
if (item.StationID != LastStationID || item.RuleStatus != "P" || item.StatusID != -1) |
|
|
|
{ |
|
|
|
_msg += "序號【" + item.BarcodeNo + "】,流程尚未完成,不可入庫!<br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
} |
|
|
|
foreach (var item in result) |
|
|
|
{ |
|
|
|
//因已到入庫階段有帶出箱號才會進到此判斷,因此判斷流程是否流結束改如下條件
|
|
|
|
if (item.RuleStatus != "P" || item.StatusID != -1) |
|
|
|
{ |
|
|
|
_msg = "查無序號" + item.BarcodeNo + "目前流程(flowID)"; |
|
|
|
_msg += "序號【" + item.BarcodeNo + "】,流程尚未完成,不可入庫!<br>"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
_msg = "查無序號" + item.BarcodeNo + "目前流程(rule_station_ID)"; |
|
|
|
//var FlowStation_result = await _basApi.GetRuleStation(item.StationID);
|
|
|
|
//if (FlowStation_result.Count() != 0)
|
|
|
|
//{
|
|
|
|
// var FlowRule_result = await _basApi.GetRuleStationsByFlow(FlowStation_result.Select(s => s.FlowRuleID).First());
|
|
|
|
// if (FlowRule_result.Count() != 0)
|
|
|
|
// {
|
|
|
|
// var LastStationID = FlowRule_result.Where(w => w.StationID != 1000).OrderBy(o => o.Sequence).Select(s => s.StationID).Last();
|
|
|
|
|
|
|
|
// if (item.StationID != LastStationID || item.RuleStatus != "P" || item.StatusID != -1)
|
|
|
|
// {
|
|
|
|
// _msg += "序號【" + item.BarcodeNo + "】,流程尚未完成,不可入庫!<br>";
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// _msg = "查無序號" + item.BarcodeNo + "目前流程(flowID)";
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// _msg = "查無序號" + item.BarcodeNo + "目前流程(rule_station_ID)";
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
if (_msg == string.Empty) |
|
|
|
{ |
|
|
|
|
|
|
|
var FlowRules_result = await _basApi.GetFlowRulesByUnit("W"); |
|
|
|
if (FlowRules_result.Count() != 0) |
|
|
|
if (_msg == string.Empty) |
|
|
|
{ |
|
|
|
var FlowRuleID = FlowRules_result.Select(s => s.FlowRuleID).First(); |
|
|
|
var ruleStations_result = await GetRuleStationByFlowRuleID(FlowRuleID); |
|
|
|
var StationID = ruleStations_result.Select(s => s.StationID).First(); |
|
|
|
|
|
|
|
var FlowRules_result = await _basApi.GetFlowRulesByUnit("W"); |
|
|
|
if (FlowRules_result.Count() != 0) |
|
|
|
{ |
|
|
|
var FlowRuleID = FlowRules_result.Select(s => s.FlowRuleID).First(); |
|
|
|
var ruleStations_result = await GetRuleStationByFlowRuleID(FlowRuleID); |
|
|
|
if (ruleStations_result.Count() != 0) |
|
|
|
{ |
|
|
|
var StationID = ruleStations_result.Select(s => s.StationID).First(); |
|
|
|
|
|
|
|
var Wipinfo_result = await _pcsApi.GetWipInfo(result.Select(s => s.WipID).First()); |
|
|
|
var Wipinfo_LineID = Wipinfo_result.Select(s => s.LineID).First(); //lineid
|
|
|
|
var WipAtt_result = await _pcsApi.GetWipAtt(Wipinfo_result.Select(s => s.WipNO).First()); //料號
|
|
|
|
var Userinfo_result = await _sysApi.GetUserInfo(GetLogInUserID()); |
|
|
|
|
|
|
|
var Wipinfo_result = await _pcsApi.GetWipInfo(result.Select(s => s.WipID).First()); |
|
|
|
var Wipinfo_LineID = Wipinfo_result.Select(s => s.LineID).First(); //lineid
|
|
|
|
var WipAtt_result = await _pcsApi.GetWipAtt(Wipinfo_result.Select(s => s.WipNO).First()); //料號
|
|
|
|
var Userinfo_result = await _sysApi.GetUserInfo(GetLogInUserID()); |
|
|
|
|
|
|
|
|
|
|
|
List<PTD101AMESModel> PTD101AMESModels = new List<PTD101AMESModel>(); |
|
|
|
foreach (var item in result) |
|
|
|
{ |
|
|
|
|
|
|
|
BarcodeInfo barcodeInfo = new BarcodeInfo |
|
|
|
{ |
|
|
|
BarcodeID = item.BarcodeID, |
|
|
|
BarcodeNo = item.BarcodeNo, |
|
|
|
StatusNo = item.StatusNo, |
|
|
|
StationID = StationID, |
|
|
|
RuleStatus = "P",//F 不良
|
|
|
|
BoxNo = item.BoxNo, |
|
|
|
WipID = item.WipID, |
|
|
|
StatusID = -1, |
|
|
|
CreateUserID = item.CreateUserID, |
|
|
|
CreateDate = item.CreateDate, |
|
|
|
UpdateDate = System.DateTime.Now |
|
|
|
List<PTD101AMESModel> PTD101AMESModels = new List<PTD101AMESModel>(); |
|
|
|
foreach (var item in result) |
|
|
|
{ |
|
|
|
|
|
|
|
BarcodeInfo barcodeInfo = new BarcodeInfo |
|
|
|
{ |
|
|
|
BarcodeID = item.BarcodeID, |
|
|
|
BarcodeNo = item.BarcodeNo, |
|
|
|
StatusNo = item.StatusNo, |
|
|
|
StationID = StationID, |
|
|
|
RuleStatus = "P",//F 不良
|
|
|
|
BoxNo = item.BoxNo, |
|
|
|
WipID = item.WipID, |
|
|
|
StatusID = -1, |
|
|
|
CreateUserID = item.CreateUserID, |
|
|
|
CreateDate = item.CreateDate, |
|
|
|
UpdateDate = System.DateTime.Now |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var resultPutBInfo = await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); |
|
|
|
if (!resultPutBInfo.Success) |
|
|
|
{ |
|
|
|
_msg = resultPutBInfo.Msg; |
|
|
|
return new Result() { success = false, msg = _msg }; |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
var barcodeStations = new BarcodeStation |
|
|
|
{ |
|
|
|
BarcodeID = item.BarcodeID, |
|
|
|
WipID = item.WipID, |
|
|
|
StationID = StationID, |
|
|
|
FlowRuleID = FlowRuleID, |
|
|
|
RuleStatus = "P", |
|
|
|
InputDate = DateTime.Now, |
|
|
|
LineId = (int)Wipinfo_LineID, |
|
|
|
CreateUserID = item.CreateUserID, |
|
|
|
GetRuleStation = new RuleStation |
|
|
|
{ |
|
|
|
//RuleStationID = RuleStationID,
|
|
|
|
//FlowRuleID = "",
|
|
|
|
//StationID ="",
|
|
|
|
//StationDescl
|
|
|
|
//Sequence="",
|
|
|
|
//StationType = "",
|
|
|
|
//CreateUserId =item.CreateUserID,
|
|
|
|
//CreateDate = DateTime.Now,
|
|
|
|
//UpdateDate = DateTime.Now
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
var resultPoutBStation = await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStations)); |
|
|
|
if (!resultPoutBStation.Success) |
|
|
|
{ |
|
|
|
_msg = resultPoutBStation.Msg; |
|
|
|
return new Result() { success = false, msg = _msg }; |
|
|
|
} |
|
|
|
|
|
|
|
await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); |
|
|
|
|
|
|
|
var barcodeStations = new BarcodeStation |
|
|
|
{ |
|
|
|
BarcodeID = item.BarcodeID, |
|
|
|
WipID = item.WipID, |
|
|
|
StationID = StationID, |
|
|
|
FlowRuleID = FlowRuleID, |
|
|
|
RuleStatus = "P", |
|
|
|
InputDate = DateTime.Now, |
|
|
|
LineId = (int)Wipinfo_LineID, |
|
|
|
CreateUserID = item.CreateUserID, |
|
|
|
GetRuleStation = new RuleStation |
|
|
|
{ |
|
|
|
//RuleStationID = RuleStationID,
|
|
|
|
//FlowRuleID = "",
|
|
|
|
//StationID ="",
|
|
|
|
//StationDescl
|
|
|
|
//Sequence="",
|
|
|
|
//StationType = "",
|
|
|
|
//CreateUserId =item.CreateUserID,
|
|
|
|
//CreateDate = DateTime.Now,
|
|
|
|
//UpdateDate = DateTime.Now
|
|
|
|
PTD101AMESModels.Add(new PTD101AMESModel |
|
|
|
{ |
|
|
|
FQCID = InhouseNo, |
|
|
|
SSN = item.ExtraBarcodeNo, |
|
|
|
ISN = item.BarcodeNo, |
|
|
|
RecordNumber = recordNumber, |
|
|
|
PN = WipAtt_result.ItemNO, |
|
|
|
EmpID = Userinfo_result.Select(s => s.UserNo).FirstOrDefault(), |
|
|
|
Location = AppSetting.Setting.Location |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStations)); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PTD101AMESModels.Add(new PTD101AMESModel |
|
|
|
{ |
|
|
|
FQCID = InhouseNo, |
|
|
|
SSN = item.ExtraBarcodeNo, |
|
|
|
ISN = item.BarcodeNo, |
|
|
|
RecordNumber = recordNumber, |
|
|
|
PN = WipAtt_result.ItemNO, |
|
|
|
EmpID = Userinfo_result.Select(s => s.UserNo).FirstOrDefault(), |
|
|
|
Location = AppSetting.Setting.Location |
|
|
|
var Warehouseing = new WareHouseing |
|
|
|
{ |
|
|
|
InhouseNo = InhouseNo, |
|
|
|
SeqID = seq, |
|
|
|
SerialNo = boxNo, |
|
|
|
Serial_Type = "B", |
|
|
|
RecordNumber = recordNumber, |
|
|
|
Create_UserID = Userinfo_result.Select(s => s.UserID).FirstOrDefault(), |
|
|
|
Create_Date = DateTime.Now |
|
|
|
}; |
|
|
|
|
|
|
|
var resultPostWH = await _pcsApi.PostWareHouseing(JsonConvert.SerializeObject(Warehouseing)); |
|
|
|
if (!resultPostWH.Success) |
|
|
|
{ |
|
|
|
_msg = resultPostWH.Msg; |
|
|
|
return new Result() { success = false, msg = _msg }; |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
var resultPTD101AMES = await _pcsApi.PostPTD101AMES(JsonConvert.SerializeObject(PTD101AMESModels)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_msg = "入庫代碼(W)查無設定站別"; |
|
|
|
} |
|
|
|
|
|
|
|
var Warehouseing = new WareHouseing |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
InhouseNo = InhouseNo, |
|
|
|
SeqID = seq, |
|
|
|
SerialNo = boxNo, |
|
|
|
Serial_Type = "B", |
|
|
|
RecordNumber = recordNumber, |
|
|
|
Create_UserID = Userinfo_result.Select(s => s.UserID).FirstOrDefault(), |
|
|
|
Create_Date = DateTime.Now |
|
|
|
}; |
|
|
|
|
|
|
|
await _pcsApi.PostWareHouseing(JsonConvert.SerializeObject(Warehouseing)); |
|
|
|
// await _pcsApi.PostPTD101AMES(JsonConvert.SerializeObject(PTD101AMESModels));
|
|
|
|
|
|
|
|
_msg = "查無入庫代碼(W)"; |
|
|
|
} |
|
|
|
|
|
|
|
if (_msg == string.Empty) |
|
|
|
{ |
|
|
|
//執行入庫作業
|
|
|
|
return new Result() { success = true, msg = "入庫完成" }; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return new Result() { success = false, msg = _msg }; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_msg = "查無入庫代碼(W)"; |
|
|
|
return new Result() { success = false, msg = _msg }; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//執行入庫作業
|
|
|
|
return new Result() { success = true, msg = "入庫完成" }; |
|
|
|
} |
|
|
|
else |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
_msg = ex.ToString(); |
|
|
|
return new Result() { success = false, msg = _msg }; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return new Result() { success = false, msg = "NO SN DATA" }; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|