|
|
@ -347,14 +347,16 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
/// <summary>
|
|
|
|
/// 生產單位
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="SelectAll">true:Add全部選項</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task GetFactoryUnit() |
|
|
|
private async Task GetFactoryUnit(bool SelectAll = true) |
|
|
|
{ |
|
|
|
var result = await _basApi.GetFactoryUnits(); |
|
|
|
|
|
|
|
var FactoryUnit = new List<SelectListItem>(); |
|
|
|
|
|
|
|
FactoryUnit.Add(new SelectListItem("全部", "")); |
|
|
|
if (SelectAll) |
|
|
|
FactoryUnit.Add(new SelectListItem("全部", "")); |
|
|
|
|
|
|
|
for (int i = 0; i < result.Count; i++) |
|
|
|
{ |
|
|
@ -1570,11 +1572,11 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
Title = item.Title |
|
|
|
}); |
|
|
|
} |
|
|
|
await WipDataSelectAll(model.wipAtt.WipNO, model.wipAtt.ItemNO, model.wipInfo.UnitNO); |
|
|
|
await WipDataSelectAll(model.wipInfo.WipNO, model.wipAtt.ItemNO, model.wipInfo.UnitNO); |
|
|
|
return View(model); |
|
|
|
} |
|
|
|
|
|
|
|
// 料號刷新
|
|
|
|
// 工單刷新
|
|
|
|
if (action == "Copy") |
|
|
|
{ |
|
|
|
model.wipAtt = await _pcsApi.GetWipAtt(model.wipInfo.WipNO); |
|
|
@ -1592,12 +1594,14 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
model.wipBarcodeOther = await _pcsApi.GetWipBarcodeOther(model.wipInfo.WipNO); |
|
|
|
|
|
|
|
model.WipKps = await _pcsApi.GetWipKpByWipNo(model.wipInfo.WipNO); |
|
|
|
await WipDataSelectAll(model.wipAtt.WipNO, model.wipAtt.ItemNO, model.wipInfo.UnitNO); |
|
|
|
|
|
|
|
|
|
|
|
await WipDataSelectAll(model.wipInfo.WipNO, UnitNo: model.wipInfo.UnitNO); |
|
|
|
TempData["request"] = JsonConvert.SerializeObject(model); |
|
|
|
return Redirect("PCS001N"); |
|
|
|
} |
|
|
|
// 保存
|
|
|
|
await WipDataSelectAll(model.wipAtt.WipNO, model.wipAtt.ItemNO, model.wipInfo.UnitNO); |
|
|
|
await WipDataSelectAll(model.wipInfo.WipNO, model.wipAtt.ItemNO, model.wipInfo.UnitNO); |
|
|
|
IResultModel result; |
|
|
|
int UserID = GetLogInUserID(); |
|
|
|
// Checkbox轉換
|
|
|
@ -1657,6 +1661,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
if (result.Success) |
|
|
|
{ |
|
|
|
int wipID = int.Parse(result.Msg); |
|
|
|
int materialID = 0; // 料號ItemNo
|
|
|
|
|
|
|
|
// 新增工單Log
|
|
|
|
WipLog wiplog = new WipLog(); |
|
|
@ -1670,12 +1675,18 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
var checkMaterialItem = await _pcsApi.GetMaterialItemByItemNO(model.wipAtt.ItemNO); |
|
|
|
if (checkMaterialItem == null) |
|
|
|
{ |
|
|
|
await _pcsApi.PostMaterialItem(JsonConvert.SerializeObject( |
|
|
|
new MaterialItem |
|
|
|
{ |
|
|
|
ItemNo = model.wipAtt.ItemNO, |
|
|
|
CreateUserID = UserID |
|
|
|
})); |
|
|
|
var result_PostMaterial = await _pcsApi.PostMaterialItem(JsonConvert.SerializeObject( |
|
|
|
new MaterialItem |
|
|
|
{ |
|
|
|
ItemNo = model.wipAtt.ItemNO, |
|
|
|
CreateUserID = UserID |
|
|
|
})); |
|
|
|
|
|
|
|
// 新增料號檔成功 取料號ID
|
|
|
|
if (result_PostMaterial.Success) |
|
|
|
{ |
|
|
|
materialID = int.Parse(result_PostMaterial.Msg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1753,6 +1764,12 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
//
|
|
|
|
if (model.WipKps != null) |
|
|
|
{ |
|
|
|
// 判斷料號KP有資料 沒有資料時 一起新增到料號KP
|
|
|
|
bool addMasterKP = false; |
|
|
|
var materialKp = await _pcsApi.GetMaterialKpByItemID(materialItem.ItemID); |
|
|
|
if (materialKp.Count() == 0) |
|
|
|
addMasterKP = true; |
|
|
|
|
|
|
|
// KeyParts
|
|
|
|
// 先比對新舊ID 當舊ID有 新的沒有代表已刪除
|
|
|
|
var resultOld_WipKp = await _pcsApi.GetWipKpByWipNo(model.wipInfo.WipNO); |
|
|
@ -1770,8 +1787,27 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
await _pcsApi.PostWipKp(JsonConvert.SerializeObject(item)); |
|
|
|
else |
|
|
|
await _pcsApi.PutWipKp(JsonConvert.SerializeObject(item)); |
|
|
|
|
|
|
|
// 判斷料號KP有資料 沒有資料時 一起新增到料號KP
|
|
|
|
if (addMasterKP) |
|
|
|
{ |
|
|
|
await _pcsApi.PostMaterialKp(JsonConvert.SerializeObject(new MaterialKp |
|
|
|
{ |
|
|
|
ItemID = materialID, |
|
|
|
KpName = item.KpName, |
|
|
|
KpNo = item.KpNo, |
|
|
|
KpSeq = Convert.ToInt32(item.KpSeq), |
|
|
|
Length = item.Length, |
|
|
|
StationType = item.UnitNo, |
|
|
|
IsRepeat = "N", |
|
|
|
Title = item.Title, |
|
|
|
CreateUserID = UserID, |
|
|
|
UpdateUserID = UserID |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 將料號KP新增到WIP_KP 上
|
|
|
|
else |
|
|
|
{ |
|
|
|
// KeyParts 組合
|
|
|
@ -2699,6 +2735,17 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
} |
|
|
|
// KeyParts
|
|
|
|
|
|
|
|
// 判斷料號KP有資料 沒有資料時 一起新增到料號KP
|
|
|
|
bool addMasterKP = false; |
|
|
|
var materialItem = await _pcsApi.GetMaterialItemByItemNO(model.wipAtt.ItemNO); |
|
|
|
if (materialItem != null) |
|
|
|
{ |
|
|
|
var materialKp = await _pcsApi.GetMaterialKpByItemID(materialItem.ItemID); |
|
|
|
if (materialKp.Count() == 0) |
|
|
|
addMasterKP = true; |
|
|
|
} |
|
|
|
|
|
|
|
// 先比對新舊ID 當舊ID有 新的沒有代表已刪除
|
|
|
|
var resultOld_WipKp = await _pcsApi.GetWipKpByWipNo(model.wipInfo.WipNO); |
|
|
|
var delete_WipKpID = resultOld_WipKp.Select(s => s.WipKpID).Except(model.WipKps.Select(s => s.WipKpID)); |
|
|
@ -2714,6 +2761,24 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
await _pcsApi.PostWipKp(JsonConvert.SerializeObject(item)); |
|
|
|
else |
|
|
|
await _pcsApi.PutWipKp(JsonConvert.SerializeObject(item)); |
|
|
|
|
|
|
|
// 判斷料號KP有資料 沒有資料時 一起新增到料號KP
|
|
|
|
if (addMasterKP) |
|
|
|
{ |
|
|
|
await _pcsApi.PostMaterialKp(JsonConvert.SerializeObject(new MaterialKp |
|
|
|
{ |
|
|
|
ItemID = materialItem.ItemID, |
|
|
|
KpName = item.KpName, |
|
|
|
KpNo = item.KpNo, |
|
|
|
KpSeq = Convert.ToInt32(item.KpSeq), |
|
|
|
Length = item.Length, |
|
|
|
StationType = item.UnitNo, |
|
|
|
IsRepeat = "N", |
|
|
|
Title = item.Title, |
|
|
|
CreateUserID = UserID, |
|
|
|
UpdateUserID = UserID |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 治具
|
|
|
@ -2854,7 +2919,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
// 廠別 委外廠
|
|
|
|
await GetFactoryInfo(); |
|
|
|
// 生產單位
|
|
|
|
await GetFactoryUnit(); |
|
|
|
await GetFactoryUnit(false); |
|
|
|
// 線別
|
|
|
|
await GetLineInfo(); |
|
|
|
// 正背面
|
|
|
@ -6664,7 +6729,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
//YIRU End -------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|