|
|
@ -255,6 +255,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
#region "PTD002 一段式入出庫作業"
|
|
|
|
public async Task<IActionResult> PTD002() |
|
|
|
{ |
|
|
|
var RBU = string.Empty; |
|
|
|
if (Request.Cookies["_AMESCookie"] != null) |
|
|
|
{ |
|
|
|
var userID = ""; |
|
|
@ -264,6 +265,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
var user_info = await _sysApi.GetUserInfo(int.Parse(userID)); |
|
|
|
var factory_info = await _basApi.GetFactoryInfo(user_info[0].FactoryID); |
|
|
|
ViewData["RBU"] = factory_info[0].Address; |
|
|
|
RBU = factory_info[0].Address; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -272,15 +274,17 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
var allRecordType = new[] { "653", "632", "261", "262", "101R", "201", "202", "291", "292", "601", "601DB", "657", "952", "634" }; |
|
|
|
var filtered = from o in RecordTypes |
|
|
|
where allRecordType.Contains(o.ID) |
|
|
|
&& o.RBU == RBU |
|
|
|
select o; |
|
|
|
|
|
|
|
RecordTypes = filtered.ToList(); |
|
|
|
RecordTypes = filtered.OrderBy(o => o.ID).ToList(); |
|
|
|
|
|
|
|
var SelectListItem = new List<SelectListItem>(); |
|
|
|
|
|
|
|
foreach (WebApi.Models.AMES.RecordTypeInfo RecordType in RecordTypes) |
|
|
|
{ |
|
|
|
SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); |
|
|
|
if (!SelectListItem.Any(a => RecordType.ID == a.Value)) |
|
|
|
SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); |
|
|
|
} |
|
|
|
ViewBag.RecordTypeInfo = RecordTypes; |
|
|
|
ViewBag.RecordType = SelectListItem; |
|
|
@ -302,25 +306,44 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
[HttpPost] |
|
|
|
public async Task<JsonResult> PTD002_Commit(string data) |
|
|
|
{ |
|
|
|
var ptd002 = JsonConvert.DeserializeObject<PTD002CommitDataModel>(data); |
|
|
|
|
|
|
|
var result = await _ptdApi.PostPTD002Commit(data); |
|
|
|
|
|
|
|
var item = ptd002.TableData.FirstOrDefault(); |
|
|
|
var zDNDetail = await _ptdApi.GetGetZDNDetail(item.DnNo, item.LineNo); |
|
|
|
var zProductTrans = await _ptdApi.GetZProductTrans(recordNumber: item.DnNo, lineNo: item.LineNo); |
|
|
|
if (zDNDetail.Any() && zProductTrans.Any()) |
|
|
|
{ |
|
|
|
// DN數量 == 已扣帳數量
|
|
|
|
if (zDNDetail.FirstOrDefault().shipQty == zProductTrans.Count()) |
|
|
|
await _ptdApi.PutZDNDetailByIsRecord(item.DnNo, item.LineNo, 1); |
|
|
|
} |
|
|
|
|
|
|
|
//将数据Json化并传到前台视图
|
|
|
|
return Json(new { data = result }); |
|
|
|
return Json(new |
|
|
|
{ |
|
|
|
data = result |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
public async Task<JsonResult> PTD002_CheckInputData(WebApi.Models.AMES.PTDCheckInputData model) |
|
|
|
{ |
|
|
|
var inputCheck = await CheckInputData(model); |
|
|
|
var correct = new List<dynamic>(); |
|
|
|
var msg = string.Empty; |
|
|
|
if (!string.IsNullOrWhiteSpace(inputCheck)) |
|
|
|
return Json(new Result() { success = false, msg = inputCheck }); |
|
|
|
|
|
|
|
//
|
|
|
|
// 取RecordType
|
|
|
|
var recordType = await _ptdApi.GetRecordTypeInfo(); |
|
|
|
var recordTypeFirst = recordType.Where(w => w.ID == model.RecordType).FirstOrDefault(); |
|
|
|
|
|
|
|
var zsnInfo = new List<dynamic>(); |
|
|
|
// 資料收集
|
|
|
|
var sn = new List<string>(); |
|
|
|
var addInput = new List<string>(); |
|
|
|
var msgInput = new List<string>(); |
|
|
|
var msgInputAlert = new List<string>(); |
|
|
|
|
|
|
|
// 序號區間
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.FrontSN)) |
|
|
@ -328,6 +351,11 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
// PCS
|
|
|
|
if (model.StockUnit == "0") |
|
|
|
{ |
|
|
|
var sequential = model.Sequential; |
|
|
|
var frontLength = model.FrontSN.Length; |
|
|
|
// 前綴
|
|
|
|
var title = model.FrontSN.Substring(0, frontLength - sequential); |
|
|
|
|
|
|
|
// Begin=End
|
|
|
|
if (model.PcsUnit == "Y") |
|
|
|
model.EndSN = model.FrontSN; |
|
|
@ -336,16 +364,20 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
// EndSn 空白 計算備貨量
|
|
|
|
if (string.IsNullOrWhiteSpace(model.EndSN)) |
|
|
|
{ |
|
|
|
var sequential = model.Sequential; |
|
|
|
var frontLength = model.FrontSN.Length; |
|
|
|
// 前綴
|
|
|
|
var title = model.FrontSN.Substring(0, frontLength - sequential); |
|
|
|
// 開始流水號
|
|
|
|
var frontSequential = int.Parse(model.FrontSN.Substring(frontLength - sequential, sequential)); |
|
|
|
model.EndSN = $"{title}{(frontSequential + model.StockQty - 1).ToString().PadLeft(sequential, '0')}"; |
|
|
|
} |
|
|
|
} |
|
|
|
zsnInfo = await _ptdApi.GetZSNInfoByIntervalNumber(model.FrontSN, model.EndSN); |
|
|
|
|
|
|
|
int startNumber = int.Parse(model.FrontSN.Substring(frontLength - sequential, sequential)); |
|
|
|
int endNumber = int.Parse(model.EndSN.Substring(frontLength - sequential, sequential)); |
|
|
|
// 用起訖區間推序號
|
|
|
|
for (int i = startNumber; i <= endNumber; i++) |
|
|
|
{ |
|
|
|
string serialNumber = title + i.ToString().PadLeft(sequential, '0'); |
|
|
|
sn.Add(serialNumber); |
|
|
|
} |
|
|
|
} |
|
|
|
// BOX
|
|
|
|
else if (model.StockUnit == "1") |
|
|
@ -364,9 +396,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
var boxSn = await _ptdApi.GetBarcodeInfoByBoxInterval(model.FrontSN, model.EndSN); |
|
|
|
foreach (var item in boxSn.Where(w => w.StatusID == -1)) |
|
|
|
{ |
|
|
|
var byBarcodeNo = await _ptdApi.GetZSNInfoByNumber(item.BarcodeNo); |
|
|
|
if (byBarcodeNo.Any()) |
|
|
|
zsnInfo.Add(byBarcodeNo.FirstOrDefault()); |
|
|
|
sn.Add(item.BarcodeNo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -374,69 +404,121 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
// ExcelInput
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.SNData)) |
|
|
|
{ |
|
|
|
var sndata = model.SNData.Split("\n"); |
|
|
|
foreach (var item in sndata) |
|
|
|
{ |
|
|
|
var byNumber = await _ptdApi.GetZSNInfoByNumber(item); |
|
|
|
if (byNumber.Any()) |
|
|
|
zsnInfo.Add(byNumber.FirstOrDefault()); |
|
|
|
} |
|
|
|
sn.AddRange(model.SNData.Split("\n").ToList()); |
|
|
|
sn = sn.Where(w => !string.IsNullOrWhiteSpace(w)).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
// Type是WO的 上一個狀態需要是WI
|
|
|
|
if (recordTypeFirst != null) |
|
|
|
{ |
|
|
|
if (recordTypeFirst.Status == "WO") |
|
|
|
// 確認序號狀態
|
|
|
|
foreach (var item in sn) |
|
|
|
{ |
|
|
|
// Record 狀態是WI 的ID
|
|
|
|
var recodeIdBystaus = recordType.Where(w => w.Status == "WI").Select(s => s.ID).ToList(); |
|
|
|
// 特殊
|
|
|
|
if (model.RecordType == "633") |
|
|
|
recodeIdBystaus.Add("631"); |
|
|
|
// zsnInfo 資料
|
|
|
|
var zSnInfo = await _ptdApi.GetZSNInfoByNumber(item); |
|
|
|
|
|
|
|
correct = zsnInfo.Where(w => recodeIdBystaus.Contains((string)w.recordTypeID) && |
|
|
|
w.originalProductID == model.ProductId).ToList(); |
|
|
|
} |
|
|
|
else if (recordTypeFirst.Status == "WI") |
|
|
|
{ |
|
|
|
// 取得特定上一個作業
|
|
|
|
var flowRule = await _ptdApi.GetPtdFlowRules(model.RecordType); |
|
|
|
if (flowRule.Any()) |
|
|
|
if (recordTypeFirst.Status == "WO") |
|
|
|
{ |
|
|
|
var toIDs = flowRule.Select(s => (string)s.toID).ToList(); |
|
|
|
// 653需要確認料號是否一樣
|
|
|
|
if (recordTypeFirst.ID == "653") |
|
|
|
// Record 狀態是WI 的ID
|
|
|
|
var recodeIdBystaus = recordType.Where(w => w.Status == "WI").Select(s => s.ID).ToList(); |
|
|
|
// 特殊
|
|
|
|
if (model.RecordType == "633") |
|
|
|
recodeIdBystaus.Add("631"); |
|
|
|
|
|
|
|
// ZsnInfo 符合狀態的序號且料號要一致
|
|
|
|
if (zSnInfo.Any()) |
|
|
|
{ |
|
|
|
correct = zsnInfo.Where(w => toIDs.Contains((string)w.recordTypeID) && |
|
|
|
w.originalProductID == model.ProductId).ToList(); |
|
|
|
if (zSnInfo.Any(w => recodeIdBystaus.Contains((string)w.recordTypeID) && |
|
|
|
w.originalProductID == model.ProductId)) |
|
|
|
addInput.Add(item); |
|
|
|
else |
|
|
|
{ |
|
|
|
msgInputAlert.Add($"{item}(型態或料號不對)"); |
|
|
|
msgInput.Add(item); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
correct = zsnInfo.Where(w => toIDs.Contains((string)w.recordTypeID)).ToList(); |
|
|
|
{ |
|
|
|
msgInputAlert.Add($"{item}(序號不存在)"); |
|
|
|
msgInput.Add(item); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if (recordTypeFirst.Status == "WI") |
|
|
|
{ |
|
|
|
// 292 不會有Info資料
|
|
|
|
if (model.RecordType == "292") |
|
|
|
{ |
|
|
|
if (zSnInfo.Any()) |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(序號重複)"); |
|
|
|
} |
|
|
|
else |
|
|
|
addInput.Add(item); |
|
|
|
} |
|
|
|
// 其他要走特定上一個作業
|
|
|
|
else |
|
|
|
{ |
|
|
|
var flowRule = await _ptdApi.GetPtdFlowRules(model.RecordType); |
|
|
|
if (flowRule.Any()) |
|
|
|
{ |
|
|
|
var toIDs = flowRule.Select(s => (string)s.toID).ToList(); |
|
|
|
|
|
|
|
// ZsnInfo 符合狀態的序號且料號要一致
|
|
|
|
if (zSnInfo.Any()) |
|
|
|
{ |
|
|
|
// 653需要確認料號是否一樣
|
|
|
|
if (recordTypeFirst.ID == "653") |
|
|
|
{ |
|
|
|
if (zSnInfo.Any(w => toIDs.Contains((string)w.recordTypeID) && |
|
|
|
w.originalProductID == model.ProductId)) |
|
|
|
addInput.Add(item); |
|
|
|
else |
|
|
|
{ |
|
|
|
msgInputAlert.Add($"{item}(型態或料號不對)"); |
|
|
|
msgInput.Add(item); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (zSnInfo.Any(w => toIDs.Contains((string)w.recordTypeID))) |
|
|
|
addInput.Add(item); |
|
|
|
else |
|
|
|
{ |
|
|
|
msgInputAlert.Add($"{item}(型態不對)"); |
|
|
|
msgInput.Add(item); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
msgInputAlert.Add($"{item}(序號不存在)"); |
|
|
|
msgInput.Add(item); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
addInput = addInput.Except(msgInput.Distinct()).ToList(); |
|
|
|
var datas = new List<dynamic>(); |
|
|
|
foreach (var item in zsnInfo) |
|
|
|
// add
|
|
|
|
foreach (var item in addInput) |
|
|
|
{ |
|
|
|
// 符合的顯示出來
|
|
|
|
if (correct.Any(a => a.serialNumber == item.serialNumber)) |
|
|
|
var newRowData = new |
|
|
|
{ |
|
|
|
var newRowData = new |
|
|
|
{ |
|
|
|
dnNo = model.RecordNumber, |
|
|
|
lineNo = model.LineNo, |
|
|
|
material = model.ProductId, |
|
|
|
sn = item.serialNumber |
|
|
|
}; |
|
|
|
datas.Add(newRowData); |
|
|
|
} |
|
|
|
else |
|
|
|
msg += $"{item.serialNumber}、"; |
|
|
|
dnNo = model.RecordNumber, |
|
|
|
lineNo = model.LineNo, |
|
|
|
material = model.ProductId, |
|
|
|
sn = item |
|
|
|
}; |
|
|
|
datas.Add(newRowData); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(msg)) |
|
|
|
msg = "流程狀態或序號比對料號錯誤:" + msg.Substring(0, msg.Length - 1); |
|
|
|
if (msgInputAlert.Any()) |
|
|
|
msg = "新增失敗:" + string.Join("、", msgInputAlert.Distinct()); |
|
|
|
|
|
|
|
return Json(new Result() { success = true, msg = msg, data = datas }); |
|
|
|
} |
|
|
@ -450,15 +532,19 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
{ |
|
|
|
// RecordNumber
|
|
|
|
if (string.IsNullOrWhiteSpace(model.RecordNumber)) |
|
|
|
{ |
|
|
|
return "請輸入 RecordNumber"; |
|
|
|
} |
|
|
|
|
|
|
|
// LineNo
|
|
|
|
if (string.IsNullOrWhiteSpace(model.LineNo)) |
|
|
|
return "請輸入 LineNo"; |
|
|
|
else if (model.LineNo.Trim().Length != 6) |
|
|
|
return "LineNo不足6碼"; |
|
|
|
|
|
|
|
// 判斷是否已備貨完成
|
|
|
|
var isRecord = await CheckRecordNoIsRecord(model.RecordNumber, model.LineNo); |
|
|
|
if (!(isRecord.Value as Result).success) |
|
|
|
{ |
|
|
|
if (model.RecordType != "101" && model.RecordType != "292") |
|
|
|
return "請輸入 LineNo"; |
|
|
|
return $"RecordNumber【{model.RecordNumber}】 LineNo【{model.LineNo}】 已備貨完成"; |
|
|
|
} |
|
|
|
|
|
|
|
// Location
|
|
|
@ -467,19 +553,21 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
return "請輸入 Location"; |
|
|
|
} |
|
|
|
|
|
|
|
var recordType = await _ptdApi.GetRecordTypeInfoById(model.RecordType); |
|
|
|
var recordType = await _ptdApi.GetRecordTypeInfo(); |
|
|
|
recordType = recordType.Where(w => w.ID == model.RecordType && w.RBU == model.Rbu).ToList(); |
|
|
|
if (recordType.Any()) |
|
|
|
{ |
|
|
|
var recordInfoItem = recordType.FirstOrDefault(); |
|
|
|
if (model.RecordNumber.Length != int.Parse((string)recordInfoItem.length)) |
|
|
|
return "RecordNumber長度與設定的長度不符,請在確認"; |
|
|
|
|
|
|
|
if (!model.RecordNumber.StartsWith((string)recordInfoItem.prefixCode)) |
|
|
|
var recordInfoItem = recordType.Where(s => model.RecordNumber.StartsWith(s.PrefixCode)) |
|
|
|
.FirstOrDefault(); |
|
|
|
if (recordInfoItem == null) |
|
|
|
return "RecordNumber單據號碼開頭與設定開頭不符,請在確認"; |
|
|
|
|
|
|
|
if (model.RecordNumber.Length != recordInfoItem.Length) |
|
|
|
return "RecordNumber長度與設定的長度不符,請在確認"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return "請維護RecordNumber單投說明表"; |
|
|
|
return "請維護RecordNumber單頭說明表"; |
|
|
|
} |
|
|
|
|
|
|
|
// ProductId
|
|
|
@ -501,6 +589,10 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
return "請輸入 Scanner"; |
|
|
|
} |
|
|
|
|
|
|
|
// 輸入序號或Excel匯入只能選一種
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.FrontSN) && !string.IsNullOrWhiteSpace(model.SNData)) |
|
|
|
return "條碼區間設定或Excel匯入只能選一種執行"; |
|
|
|
|
|
|
|
// 判斷序號區間格式正確
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.FrontSN)) |
|
|
|
{ |
|
|
@ -602,23 +694,26 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
SelectListItem.Add(new SelectListItem("全部", "全部")); |
|
|
|
foreach (WebApi.Models.AMES.RecordTypeInfo RecordType in RecordTypes) |
|
|
|
{ |
|
|
|
SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); |
|
|
|
if (!SelectListItem.Any(a => RecordType.ID == a.Value)) |
|
|
|
SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); |
|
|
|
} |
|
|
|
ViewBag.RecordType = SelectListItem; |
|
|
|
//ViewBag.StartDate = System.DateTime.Now.AddDays(-7).ToString("yyyy/MM/dd");
|
|
|
|
//ViewBag.EndDate = System.DateTime.Now.ToString("yyyy/MM/dd");
|
|
|
|
ViewBag.WorkCenter = "TWM0"; |
|
|
|
|
|
|
|
ViewBag.rowCount = "總筆數: 0"; |
|
|
|
return View(); |
|
|
|
} |
|
|
|
public async Task<IActionResult> PTD003QueryAsync(string recordType, string recordNumber, string lineNo, string materialNo, string shippingSN, string dateStart, string dateEnd, int autoLoad = 0, string RBU = null) |
|
|
|
public async Task<IActionResult> PTD003QueryAsync(string recordType, string recordNumber, string lineNo, string materialNo, string shippingSN, string dateStart, string dateEnd, |
|
|
|
int autoLoad = 0, string RBU = null, string soNumber = null, string soLineNo = null, string customer = null) |
|
|
|
{ |
|
|
|
//if (recordNumber == null || recordNumber == "")
|
|
|
|
// return Json(new Table() { count = 0, data = null });
|
|
|
|
if (autoLoad == 0) |
|
|
|
{ |
|
|
|
return Json(new Table() { count = 0, data = null }); |
|
|
|
} |
|
|
|
|
|
|
|
var result = await _ptdApi.GetData4PTD003(recordType, recordNumber, lineNo, materialNo, shippingSN, dateStart, dateEnd, RBU); |
|
|
|
var result = await _ptdApi.GetData4PTD003(recordType, recordNumber, lineNo, materialNo, shippingSN, |
|
|
|
dateStart, dateEnd, RBU, soNumber, soLineNo, customer); |
|
|
|
if (result.DataTotal > 0) |
|
|
|
{ |
|
|
|
return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); |
|
|
@ -653,10 +748,10 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
//修改页面
|
|
|
|
[HttpGet] |
|
|
|
public async Task<IActionResult> PTD004UAsync(string id) |
|
|
|
public async Task<IActionResult> PTD004UAsync(string seq) |
|
|
|
{ |
|
|
|
|
|
|
|
var result = await _ptdApi.GetRecordTypeInfo(id); |
|
|
|
var result = await _ptdApi.GetRecordTypeInfo(seq); |
|
|
|
|
|
|
|
if (result.Count == 0) |
|
|
|
{ |
|
|
@ -765,11 +860,18 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
IResultModel result; |
|
|
|
if (model.Mode == 0) |
|
|
|
{ |
|
|
|
result = await _ptdApi.PostCustomerItemMailGroup(JsonConvert.SerializeObject(model)); |
|
|
|
var checkData = await _ptdApi.GetCustomerItemMailGroup(model.CustomerCode); |
|
|
|
if (!checkData.Any()) |
|
|
|
result = await _ptdApi.PostCustomerItemMailGroup(JsonConvert.SerializeObject(model)); |
|
|
|
else |
|
|
|
{ |
|
|
|
ModelState.AddModelError("error", "客戶代號已有重複"); |
|
|
|
return View("PTD005C", model); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
result = await _ptdApi.PutCustomerItemMailGroup(model.ItemNumber, JsonConvert.SerializeObject(model)); |
|
|
|
result = await _ptdApi.PutCustomerItemMailGroup(model.CustomerCode, JsonConvert.SerializeObject(model)); |
|
|
|
} |
|
|
|
|
|
|
|
if (result.Success) |
|
|
@ -815,6 +917,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
#region "PTD006 備貨作業"
|
|
|
|
public async Task<IActionResult> PTD006() |
|
|
|
{ |
|
|
|
var RBU = string.Empty; |
|
|
|
if (Request.Cookies["_AMESCookie"] != null) |
|
|
|
{ |
|
|
|
var userID = ""; |
|
|
@ -824,26 +927,28 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
var user_info = await _sysApi.GetUserInfo(int.Parse(userID)); |
|
|
|
var factory_info = await _basApi.GetFactoryInfo(user_info[0].FactoryID); |
|
|
|
ViewData["RBU"] = factory_info[0].Address; |
|
|
|
RBU = factory_info[0].Address; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<WebApi.Models.AMES.RecordTypeInfo> RecordTypes = await _ptdApi.GetRecordTypeInfo(); |
|
|
|
var allRecordType = new[] { "101", "601", "631", "633", "951" }; |
|
|
|
var filtered = from o in RecordTypes |
|
|
|
where allRecordType.Contains(o.ID) |
|
|
|
&& o.RBU == RBU |
|
|
|
select o; |
|
|
|
|
|
|
|
RecordTypes = filtered.ToList(); |
|
|
|
RecordTypes = filtered.OrderBy(o => o.ID).ToList(); |
|
|
|
|
|
|
|
var SelectListItem = new List<SelectListItem>(); |
|
|
|
|
|
|
|
foreach (WebApi.Models.AMES.RecordTypeInfo RecordType in RecordTypes) |
|
|
|
{ |
|
|
|
SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); |
|
|
|
if (!SelectListItem.Any(a => RecordType.ID == a.Value)) |
|
|
|
SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); |
|
|
|
} |
|
|
|
ViewBag.RecordTypeInfo = RecordTypes; |
|
|
|
ViewBag.RecordType = SelectListItem; |
|
|
|
ViewBag.RecordType = SelectListItem.Distinct().ToList(); |
|
|
|
ViewBag.Location = "9000"; |
|
|
|
ViewBag.WorkCenter = "TWM0"; |
|
|
|
ViewBag.RecordDate = System.DateTime.Now.ToString("yyyy/MM/dd"); |
|
|
@ -895,11 +1000,31 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<IActionResult> PTD006DAllAsync(string recordNumber, string lineNo) |
|
|
|
{ |
|
|
|
var result = await _ptdApi.DeleteZWHPickListDetailAll(recordNumber, lineNo); |
|
|
|
if (result.Success) |
|
|
|
{ |
|
|
|
return Json(new Result() { success = true, msg = "" }); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return Json(new Result() { success = false, msg = result.Msg }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<JsonResult> PTD006_CheckInputData(WebApi.Models.AMES.PTDCheckInputData model) |
|
|
|
{ |
|
|
|
// 基本資料判定
|
|
|
|
var inputCheck = await CheckInputData(model); |
|
|
|
var msg = string.Empty; |
|
|
|
// 資料收集
|
|
|
|
var sn = new List<string>(); |
|
|
|
var addInput = new List<string>(); |
|
|
|
var msgInput = new List<string>(); |
|
|
|
var msgInputAlert = new List<string>(); |
|
|
|
var checkFQC = false; |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(inputCheck)) |
|
|
|
return Json(new Result() { success = false, msg = inputCheck }); |
|
|
|
|
|
|
@ -927,11 +1052,6 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
else |
|
|
|
return Json(new Result() { success = false, msg = "請新增單頭說明維護", data = null }); |
|
|
|
|
|
|
|
// 資料收集
|
|
|
|
var sn = new List<string>(); |
|
|
|
var addInput = new List<string>(); |
|
|
|
var msgInput = new List<string>(); |
|
|
|
|
|
|
|
// 序號區間
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.FrontSN)) |
|
|
|
{ |
|
|
@ -994,6 +1114,15 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
if (!string.IsNullOrWhiteSpace(model.SNData)) |
|
|
|
{ |
|
|
|
sn.AddRange(model.SNData.Split("\n").ToList()); |
|
|
|
sn = sn.Where(w => !string.IsNullOrWhiteSpace(w)).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
// FFQC判斷
|
|
|
|
var resultZDNDetail = await _ptdApi.GetGetZDNDetail(model.RecordNumber, model.LineNo); |
|
|
|
if (resultZDNDetail.Any()) |
|
|
|
{ |
|
|
|
if (resultZDNDetail.FirstOrDefault().shipSLoc == "0S08") |
|
|
|
checkFQC = true; |
|
|
|
} |
|
|
|
|
|
|
|
// 確認序號狀態
|
|
|
@ -1013,29 +1142,73 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
w.originalProductID == model.ProductId)) |
|
|
|
addInput.Add(item); |
|
|
|
else |
|
|
|
msgInput.Add(item); |
|
|
|
{ |
|
|
|
if (zSnInfo.Any(w => !recodeIdBystaus.Contains((string)w.recordTypeID))) |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(型態不對)"); |
|
|
|
} |
|
|
|
else if (zSnInfo.Any(w => w.originalProductID != model.ProductId)) |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(品號不符)"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(序號不存在)"); |
|
|
|
} |
|
|
|
|
|
|
|
// 排除PickDetail有重複相同recordNumber & lineNo 的序號
|
|
|
|
|
|
|
|
if (pickDetail.Any(w => w.recordNumber == model.RecordNumber && w.rcLineNO == model.LineNo)) |
|
|
|
//if (pickDetail.Any(w => w.recordNumber == model.RecordNumber && w.rcLineNO == model.LineNo))
|
|
|
|
if (pickDetail.Any(w => w.recordTypeID == model.RecordType)) |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(序號重複)"); |
|
|
|
} |
|
|
|
else |
|
|
|
addInput.Add(item); |
|
|
|
|
|
|
|
// FQC檢驗
|
|
|
|
if (checkFQC) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
var resultCheckFqc = await _ptdApi.CheckFQCTestOk(extraBarcodeNo: item); |
|
|
|
if (!resultCheckFqc.Any()) |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(尚未通過FQC檢驗)"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(尚未通過FQC檢驗)"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// 101 不會有Info資料
|
|
|
|
if (zSnInfo.Any()) |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(序號重複)"); |
|
|
|
} |
|
|
|
else |
|
|
|
addInput.Add(item); |
|
|
|
|
|
|
|
// 排除PickDetail有重複相同recordNumber & lineNo 的序號
|
|
|
|
if (pickDetail.Any(w => w.recordNumber == model.RecordNumber && w.rcLineNO == model.LineNo)) |
|
|
|
//if (pickDetail.Any(w => w.recordNumber == model.RecordNumber && w.rcLineNO == model.LineNo))
|
|
|
|
if (pickDetail.Any(w => w.recordTypeID == model.RecordType)) |
|
|
|
{ |
|
|
|
msgInput.Add(item); |
|
|
|
msgInputAlert.Add($"{item}(序號重複)"); |
|
|
|
} |
|
|
|
else |
|
|
|
addInput.Add(item); |
|
|
|
} |
|
|
@ -1063,12 +1236,18 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
var result = await _ptdApi.PostPTD006Commit(JsonConvert.SerializeObject(addPtd006)); |
|
|
|
} |
|
|
|
|
|
|
|
if (msgInput.Any()) |
|
|
|
msg = "序號新增失敗:" + string.Join("、", msgInput.Distinct()); |
|
|
|
if (msgInputAlert.Any()) |
|
|
|
msg = "新增失敗:" + string.Join("、", msgInputAlert.Distinct()); |
|
|
|
|
|
|
|
return Json(new Result() { success = true, msg = msg, data = new List<dynamic>() }); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 取得 RecordNo & LineNo 訂單數量
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dnNo">RecordNo</param>
|
|
|
|
/// <param name="dnlineNo">LineNo</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<JsonResult> GetRecordNumberQty(string dnNo, string dnlineNo) |
|
|
|
{ |
|
|
|
var zDNDetail = await _ptdApi.GetGetZDNDetail(dnNo, dnlineNo); |
|
|
@ -1085,11 +1264,31 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 確認 RecordNo & LineNo 是否可備貨
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dnNo">RecordNo</param>
|
|
|
|
/// <param name="dnlineNo">LineNo</param>
|
|
|
|
/// <returns>ture可 false不可</returns>
|
|
|
|
public async Task<JsonResult> CheckRecordNoIsRecord(string dnNo, string dnlineNo) |
|
|
|
{ |
|
|
|
var zDNDetail = await _ptdApi.GetGetZDNDetail(dnNo, dnlineNo); |
|
|
|
|
|
|
|
if (zDNDetail.Any()) |
|
|
|
{ |
|
|
|
var isRecord = zDNDetail.FirstOrDefault().isRecord; |
|
|
|
if ((int)isRecord == 1) |
|
|
|
return Json(new Result() { success = false }); |
|
|
|
} |
|
|
|
return Json(new Result() { success = true }); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region "PTD007 扣帳作業"
|
|
|
|
public async Task<IActionResult> PTD007() |
|
|
|
{ |
|
|
|
var RBU = string.Empty; |
|
|
|
if (Request.Cookies["_AMESCookie"] != null) |
|
|
|
{ |
|
|
|
var userID = ""; |
|
|
@ -1097,24 +1296,27 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
if (userID != "") |
|
|
|
{ |
|
|
|
var user_info = await _sysApi.GetUserInfo(int.Parse(userID)); |
|
|
|
List<WebApi.Models.BAS.FactoryInfo> factory_info = await _basApi.GetFactoryInfo(user_info[0].FactoryID); |
|
|
|
var factory_info = await _basApi.GetFactoryInfo(user_info[0].FactoryID); |
|
|
|
ViewData["RBU"] = factory_info[0].Address; |
|
|
|
RBU = factory_info[0].Address; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<WebApi.Models.AMES.RecordTypeInfo> RecordTypes = await _ptdApi.GetRecordTypeInfo(); |
|
|
|
var allRecordType = new[] { "101", "601", "631", "633", "951" }; |
|
|
|
var allRecordType = new[] { "101", "601", "631", "633", "951", "101P" }; |
|
|
|
var filtered = from o in RecordTypes |
|
|
|
where allRecordType.Contains(o.ID) |
|
|
|
&& o.RBU == RBU |
|
|
|
select o; |
|
|
|
|
|
|
|
RecordTypes = filtered.ToList(); |
|
|
|
RecordTypes = filtered.OrderBy(o => o.ID).ToList(); |
|
|
|
|
|
|
|
var SelectListItem = new List<SelectListItem>(); |
|
|
|
|
|
|
|
foreach (WebApi.Models.AMES.RecordTypeInfo RecordType in RecordTypes) |
|
|
|
{ |
|
|
|
SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); |
|
|
|
if (!SelectListItem.Any(a => RecordType.ID == a.Value)) |
|
|
|
SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); |
|
|
|
} |
|
|
|
|
|
|
|
ViewBag.RecordType = SelectListItem; |
|
|
@ -1123,12 +1325,20 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
return View(); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<IActionResult> PTD007QueryAsync(string recordType, string recordNumber) |
|
|
|
public async Task<IActionResult> PTD007QueryAsync(string recordType, string recordNumber, string RBU) |
|
|
|
{ |
|
|
|
if (recordNumber == null || recordNumber == "") |
|
|
|
return Json(new Table() { count = 0, data = null }); |
|
|
|
|
|
|
|
var result = await _ptdApi.GetZDNDetailJoinZWHPickListDetail(recordType, recordNumber); |
|
|
|
var result = new ResultModel<dynamic>(); |
|
|
|
|
|
|
|
if (recordType == "101P") |
|
|
|
{ |
|
|
|
result = await _ptdApi.GetPTD007QueryByRBU(recordNumber, RBU); |
|
|
|
} |
|
|
|
else |
|
|
|
result = await _ptdApi.GetZDNDetailJoinZWHPickListDetail(recordType, recordNumber); |
|
|
|
|
|
|
|
if (result.DataTotal > 0) |
|
|
|
{ |
|
|
|
return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); |
|
|
@ -1139,7 +1349,37 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
[HttpPost] |
|
|
|
public async Task<JsonResult> PTD007_Commit(string data) |
|
|
|
{ |
|
|
|
var result = await _ptdApi.PostPTD007Commit(data); |
|
|
|
var ptd007 = JsonConvert.DeserializeObject<PTD007CommitDataModel>(data); |
|
|
|
var result = new ResultModel<dynamic>(); |
|
|
|
// 先確認需求數量是否=備貨數量
|
|
|
|
foreach (var item in ptd007.TableData) |
|
|
|
{ |
|
|
|
if (item.shipQty != item.qty) |
|
|
|
{ |
|
|
|
result.Success = false; |
|
|
|
result.Msg = $"DN單號【{item.dnno}】 LineNo【{item.dnLineNO}】 數量不符合,請檢查備貨資料"; |
|
|
|
return Json(new { data = result }); |
|
|
|
} |
|
|
|
} |
|
|
|
// 執行扣帳
|
|
|
|
if (ptd007.RecordType == "101P") |
|
|
|
result = await _ptdApi.PostPTD007CommitByRBU(data); |
|
|
|
else |
|
|
|
result = await _ptdApi.PostPTD007Commit(data); |
|
|
|
|
|
|
|
foreach (var item in ptd007.TableData) |
|
|
|
{ |
|
|
|
var zDNDetail = await _ptdApi.GetGetZDNDetail(item.dnno, item.dnLineNO); |
|
|
|
var zProductTrans = await _ptdApi.GetZProductTrans(recordNumber: item.dnno, lineNo: item.dnLineNO); |
|
|
|
|
|
|
|
if (zDNDetail.Any() && zProductTrans.Any()) |
|
|
|
{ |
|
|
|
// DN數量 == 已扣帳數量
|
|
|
|
if (zDNDetail.FirstOrDefault().shipQty == zProductTrans.Count()) |
|
|
|
await _ptdApi.PutZDNDetailByIsRecord(item.dnno, item.dnLineNO, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//将数据Json化并传到前台视图
|
|
|
|
return Json(new { data = result }); |
|
|
|
} |
|
|
@ -1163,12 +1403,96 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
return Json(new Table() { count = 0, data = null, msg = result.Msg }); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
public async Task<JsonResult> PTD008_Commit(string data) |
|
|
|
public async Task<JsonResult> PTD008_Commit(string recordNumber, string lineNo, string materialNo, string shippingSN) |
|
|
|
{ |
|
|
|
var result = await _ptdApi.PostPTD008Commit(data); |
|
|
|
//将数据Json化并传到前台视图
|
|
|
|
return Json(new { data = result }); |
|
|
|
var data = await _ptdApi.GetData4PTD008(recordNumber, lineNo, materialNo, shippingSN); |
|
|
|
|
|
|
|
if (data.Data.Any(w => w.recordTypeID == "101" || w.recordTypeID == "292")) |
|
|
|
return Json(new Result() { success = false, msg = "ReCordType狀態是【101】或【292】 ,不可做還原動作" }); |
|
|
|
|
|
|
|
int okQty = 0, ngQty = 0; |
|
|
|
foreach (var item in data.Data.LastOrDefault()) |
|
|
|
{ |
|
|
|
var zProductTrans = await _ptdApi.GetZProductTrans(serialNumber: (string)item.sn); |
|
|
|
var delcheck = true; |
|
|
|
|
|
|
|
if (!zProductTrans.Any()) |
|
|
|
{ |
|
|
|
ngQty += 1; |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 取序號最新一次狀態
|
|
|
|
else if (zProductTrans.Any()) |
|
|
|
{ |
|
|
|
var newRecordId = zProductTrans.OrderByDescending(o => o.createDate).FirstOrDefault().recordTypeID; |
|
|
|
// 確認目前還原是否是最新的
|
|
|
|
if (newRecordId != item.recordTypeID) |
|
|
|
{ |
|
|
|
ngQty += 1; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 可進行還原
|
|
|
|
delcheck = await _ptdApi.Put_PTD008((string)item.sn, recordNumber, lineNo, materialNo , item.recordTypeID); |
|
|
|
if (delcheck) |
|
|
|
okQty += 1; |
|
|
|
else |
|
|
|
ngQty += 1; |
|
|
|
} |
|
|
|
|
|
|
|
// 成功刪除筆數大於1
|
|
|
|
if (okQty >= 1) |
|
|
|
{ |
|
|
|
await _ptdApi.PutZDNDetailByIsRecord(recordNumber, lineNo, 0); |
|
|
|
} |
|
|
|
|
|
|
|
return Json(new Result() { success = true, msg = $"還原成功筆數【{okQty}】,失敗筆數【{ngQty}】" }); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 刪除動作
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="data"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<JsonResult> PTD008_Del(string recordNumber, string lineNo, string materialNo, string shippingSN) |
|
|
|
{ |
|
|
|
var data = await _ptdApi.GetData4PTD008(recordNumber, lineNo, materialNo, shippingSN); |
|
|
|
|
|
|
|
if (data.Data.Any(w => w.recordTypeID != "101" && w.recordTypeID != "292")) |
|
|
|
return Json(new Result() { success = false, msg = "ReCordType狀態不是【101】或【292】 ,不可做刪除動作" }); |
|
|
|
|
|
|
|
int okQty = 0, ngQty = 0; |
|
|
|
foreach (var item in data.Data) |
|
|
|
{ |
|
|
|
var zProductTrans = await _ptdApi.GetZProductTrans(serialNumber: (string)item.sn); |
|
|
|
var delcheck = true; |
|
|
|
// 大於一筆 代表尚有其他作業需還原
|
|
|
|
if (zProductTrans.Count > 1) |
|
|
|
{ |
|
|
|
ngQty += 1; |
|
|
|
} |
|
|
|
// 可進行刪除
|
|
|
|
else |
|
|
|
{ |
|
|
|
delcheck = await _ptdApi.Del_PTD008((string)item.sn, recordNumber, lineNo, materialNo); |
|
|
|
if (delcheck) |
|
|
|
okQty += 1; |
|
|
|
else |
|
|
|
ngQty += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 成功刪除筆數大於1,將ZDetail
|
|
|
|
if (okQty >= 1) |
|
|
|
{ |
|
|
|
await _ptdApi.PutZDNDetailByIsRecord(recordNumber, lineNo, 0); |
|
|
|
} |
|
|
|
|
|
|
|
return Json(new Result() { success = true, msg = $"刪除成功筆數【{okQty}】,失敗筆數【{ngQty}】" }); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|