|
|
@ -17,6 +17,7 @@ using System; |
|
|
|
using System.IO; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
|
|
|
|
namespace AMESCoreStudio.Web.Controllers |
|
|
|
{ |
|
|
@ -42,6 +43,141 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
_env = env; |
|
|
|
} |
|
|
|
|
|
|
|
#region Funcion BLL
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 工單建立時判斷是否都有資料
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="model"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public string CheckWipInfoInsert(WipViewModel model) |
|
|
|
{ |
|
|
|
string Msg = string.Empty; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.wipInfo.LineID.ToString())) |
|
|
|
Msg += "," + model.wipInfo.GetAttributeFrom<DisplayAttribute>(nameof(model.wipInfo.LineID)).Name; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.wipInfo.UnitNO)) |
|
|
|
Msg += "," + model.wipInfo.GetAttributeFrom<DisplayAttribute>(nameof(model.wipInfo.UnitNO)).Name; |
|
|
|
|
|
|
|
if (model.wipInfo.WipDueDate == DateTime.MinValue) |
|
|
|
Msg += "," + model.wipInfo.GetAttributeFrom<DisplayAttribute>(nameof(model.wipInfo.WipDueDate)).Name; |
|
|
|
|
|
|
|
if (model.wipInfo.WipScheduleDate == DateTime.MinValue) |
|
|
|
Msg += "," + model.wipInfo.GetAttributeFrom<DisplayAttribute>(nameof(model.wipInfo.WipScheduleDate)).Name; |
|
|
|
|
|
|
|
// 序號編碼sheet
|
|
|
|
|
|
|
|
|
|
|
|
// 系統
|
|
|
|
if (model.wipInfo.UnitNO == "B" || model.wipInfo.UnitNO == "P" || model.wipInfo.UnitNO == "T") |
|
|
|
{ |
|
|
|
|
|
|
|
Msg += CheckWipInfoInsert_WipSystem(model.wipSystem); |
|
|
|
} |
|
|
|
// 板卡
|
|
|
|
else |
|
|
|
{ |
|
|
|
Msg += CheckWipInfoInsert_WipBoard(model.wipBoard); |
|
|
|
} |
|
|
|
|
|
|
|
// 內部條碼
|
|
|
|
if (string.IsNullOrWhiteSpace(model.wipBarcode.StartNO) != string.IsNullOrWhiteSpace(model.wipBarcode.EndNO)) |
|
|
|
{ |
|
|
|
Msg += ",內部序號未填完整"; |
|
|
|
} |
|
|
|
|
|
|
|
// 出貨序號
|
|
|
|
if (string.IsNullOrWhiteSpace(model.wipBarcodeOther.StartNO) != string.IsNullOrWhiteSpace(model.wipBarcodeOther.EndNO)) |
|
|
|
{ |
|
|
|
Msg += ",客戶序號未填完整"; |
|
|
|
} |
|
|
|
|
|
|
|
// MAC
|
|
|
|
if (string.IsNullOrWhiteSpace(model.wipMAC.StartNO) != string.IsNullOrWhiteSpace(model.wipMAC.EndNO)) |
|
|
|
{ |
|
|
|
Msg += ",MAC未填完整"; |
|
|
|
} |
|
|
|
|
|
|
|
return Msg; |
|
|
|
} |
|
|
|
|
|
|
|
public string CheckWipInfoInsert_WipSystem(WipSystem model) |
|
|
|
{ |
|
|
|
string Msg = string.Empty; |
|
|
|
|
|
|
|
// 判斷預設值是否更改過,如果有就判斷必填欄位
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.BiTemperature) || |
|
|
|
!string.IsNullOrWhiteSpace(model.BiTime) || |
|
|
|
!string.IsNullOrWhiteSpace(model.BiMemo) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Checksum) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Cpu) || |
|
|
|
!string.IsNullOrWhiteSpace(model.DmiBi) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Ec) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Fw) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Fw) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Fw1) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Fw2) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Jumper) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Memo) || |
|
|
|
!string.IsNullOrWhiteSpace(model.OsVer) || |
|
|
|
!string.IsNullOrWhiteSpace(model.PowerMode) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Ram)) |
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(model.BiTemperature)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.BiTemperature)).Name; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.BiTime)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.BiTime)).Name; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.Checksum)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.Checksum)).Name; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.Cpu)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.Cpu)).Name; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.Ram)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.Ram)).Name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Msg; |
|
|
|
} |
|
|
|
|
|
|
|
public string CheckWipInfoInsert_WipBoard(WipBoard model) |
|
|
|
{ |
|
|
|
string Msg = string.Empty; |
|
|
|
|
|
|
|
// 判斷預設值是否更改過,如果有就判斷必填欄位
|
|
|
|
if (model.BiRatio != 0 || |
|
|
|
model.BiosVer != 0 || |
|
|
|
model.PartsBakeTime != 0 || |
|
|
|
model.PcbBake != 0 || |
|
|
|
!string.IsNullOrWhiteSpace(model.BiTemperature) || |
|
|
|
!string.IsNullOrWhiteSpace(model.BiTime) || |
|
|
|
!string.IsNullOrWhiteSpace(model.Checksum) || |
|
|
|
!string.IsNullOrWhiteSpace(model.BurnLocation)) |
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(model.BiTemperature)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.BiTemperature)).Name; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.BiTime)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.BiTime)).Name; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.Checksum)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.Checksum)).Name; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.BurnLocation)) |
|
|
|
Msg += "," + model.GetAttributeFrom<DisplayAttribute>(nameof(model.BurnLocation)).Name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Msg; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 下拉選單
|
|
|
|
/// <summary>
|
|
|
@ -746,10 +882,34 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
model.wipInfo.ModelCheck = model.wipInfo.ModelCheck == "true" ? "Y" : "N"; |
|
|
|
model.wipInfo.InputFlag = model.wipInfo.InputFlag == "true" ? "Y" : "N"; |
|
|
|
model.wipInfo.Priority = model.wipInfo.Priority == "true" ? "Y" : "N"; |
|
|
|
//板卡
|
|
|
|
model.wipBoard.DipCarrier = model.wipBoard.DipCarrier == "true" ? "Y" : "N"; |
|
|
|
model.wipBoard.DipTape = model.wipBoard.DipTape == "true" ? "Y" : "N"; |
|
|
|
model.wipBoard.Burn = model.wipBoard.Burn == "true" ? "Y" : "N"; |
|
|
|
//系統
|
|
|
|
model.wipSystem.FinePackage = model.wipSystem.FinePackage == "true" ? "Y" : "N"; |
|
|
|
|
|
|
|
var Msg = CheckWipInfoInsert(model); |
|
|
|
if (!string.IsNullOrWhiteSpace(Msg)) |
|
|
|
{ |
|
|
|
model.wipInfo.ECNCheck = model.wipInfo.ECNCheck == "Y" ? "true" : "false"; |
|
|
|
model.wipInfo.ModelCheck = model.wipInfo.ModelCheck == "Y" ? "true" : "false"; |
|
|
|
model.wipInfo.InputFlag = model.wipInfo.InputFlag == "Y" ? "true" : "false"; |
|
|
|
model.wipInfo.Priority = model.wipInfo.Priority == "Y" ? "true" : "false"; |
|
|
|
//板卡
|
|
|
|
model.wipBoard.DipCarrier = model.wipBoard.DipCarrier == "Y" ? "true" : "false"; |
|
|
|
model.wipBoard.DipTape = model.wipBoard.DipTape == "Y" ? "true" : "false"; |
|
|
|
model.wipBoard.Burn = model.wipBoard.Burn == "Y" ? "true" : "false"; |
|
|
|
//系統
|
|
|
|
model.wipSystem.FinePackage = model.wipSystem.FinePackage == "Y" ? "true" : "false"; |
|
|
|
ModelState.AddModelError("error", Msg); |
|
|
|
GetCheckboxApproveLogo(); |
|
|
|
GetCheckboxCompanyLogo(); |
|
|
|
GetCheckboxPrintMode(); |
|
|
|
GetCheckboxWipAttr(); |
|
|
|
return View("PCS001", model); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (model.wipInfo.WipID == 0) |
|
|
|
{ |
|
|
|
result = await _pcsApi.PostWipInfo(JsonConvert.SerializeObject(model.wipInfo)); |
|
|
|
if (result.Success) |
|
|
|
{ |
|
|
@ -771,23 +931,26 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
wiplog.WipDesc = "."; |
|
|
|
await _pcsApi.PostWipLog(JsonConvert.SerializeObject(wiplog)); |
|
|
|
|
|
|
|
//// 系統
|
|
|
|
//if (model.wipInfo.UnitNO == "B" || model.wipInfo.UnitNO == "P" || model.wipInfo.UnitNO == "T")
|
|
|
|
//{
|
|
|
|
// model.wipSystem.ItemNo = model.wipAtt.ItemNO;
|
|
|
|
// model.wipSystem.WipNo = model.wipInfo.WipNO;
|
|
|
|
// await _pcsApi.PostWipSystem(JsonConvert.SerializeObject(model.wipSystem));
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//// 板卡
|
|
|
|
//{
|
|
|
|
// model.wipBoard.DipCarrier = model.wipBoard.DipCarrier == "true" ? "Y" : "N";
|
|
|
|
// model.wipBoard.DipTape = model.wipBoard.DipTape == "true" ? "Y" : "N";
|
|
|
|
// model.wipBoard.Burn = model.wipBoard.Burn == "true" ? "Y" : "N";
|
|
|
|
// model.wipBoard.ItemNo = model.wipAtt.ItemNO;
|
|
|
|
// model.wipBoard.WipNo = model.wipInfo.WipNO;
|
|
|
|
// await _pcsApi.PostWipBoard(JsonConvert.SerializeObject(model.wipBoard));
|
|
|
|
//}
|
|
|
|
// 系統
|
|
|
|
if (model.wipInfo.UnitNO == "B" || model.wipInfo.UnitNO == "P" || model.wipInfo.UnitNO == "T") |
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(CheckWipInfoInsert_WipSystem(model.wipSystem))) |
|
|
|
{ |
|
|
|
model.wipSystem.ItemNo = model.wipAtt.ItemNO; |
|
|
|
model.wipSystem.WipNo = model.wipInfo.WipNO; |
|
|
|
await _pcsApi.PostWipSystem(JsonConvert.SerializeObject(model.wipSystem)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
// 板卡
|
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(CheckWipInfoInsert_WipSystem(model.wipSystem))) |
|
|
|
{ |
|
|
|
model.wipBoard.ItemNo = model.wipAtt.ItemNO; |
|
|
|
model.wipBoard.WipNo = model.wipInfo.WipNO; |
|
|
|
await _pcsApi.PostWipBoard(JsonConvert.SerializeObject(model.wipBoard)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 工單對應SOP Log
|
|
|
|
var q = await _pcsApi.GetWipSopQuery(itemNo: model.wipAtt.ItemNO, unitNo: model.wipInfo.UnitNO, state: "Y"); |
|
|
@ -798,7 +961,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
|
|
|
|
// 內部條碼
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.wipBarcode.StartNO)) |
|
|
|
if (!string.IsNullOrWhiteSpace(model.wipBarcode.StartNO) && !string.IsNullOrWhiteSpace(model.wipBarcode.EndNO)) |
|
|
|
{ |
|
|
|
model.wipBarcode.WipID = wipID; |
|
|
|
model.wipBarcode.WipNO = model.wipInfo.WipNO; |
|
|
@ -815,7 +978,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
|
|
|
|
// 出貨序號
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.wipBarcodeOther.StartNO)) |
|
|
|
if (!string.IsNullOrWhiteSpace(model.wipBarcodeOther.StartNO) && !string.IsNullOrWhiteSpace(model.wipBarcodeOther.EndNO)) |
|
|
|
{ |
|
|
|
var type_no = await _pcsApi.GetBarcodeTypeByTypeName("客戶條碼區間"); |
|
|
|
if (type_no.Any()) |
|
|
@ -827,22 +990,19 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
} |
|
|
|
|
|
|
|
// MAC
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.wipMAC.StartNO)) |
|
|
|
if (!string.IsNullOrWhiteSpace(model.wipMAC.StartNO) && !string.IsNullOrWhiteSpace(model.wipMAC.EndNO)) |
|
|
|
{ |
|
|
|
model.wipMAC.WipNO = model.wipInfo.WipNO; |
|
|
|
result = await _pcsApi.PostWipMAC(JsonConvert.SerializeObject(model.wipMAC)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
result = await _pcsApi.PostWipInfo(JsonConvert.SerializeObject(model.wipInfo)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result.Success) |
|
|
|
{ |
|
|
|
var _msg = model.wipInfo.WipID == 0 ? "添加成功!" : "修改成功!"; |
|
|
|
return RedirectToAction("Refresh", "Home", new { msg = _msg }); |
|
|
|
return RedirectToAction("PCB", "Home", new { msg = _msg }); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -1585,4 +1745,15 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
return PartialView("_SOPPartial", Json(new Table() { count = 0, data = null })); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static class ObjectExtension |
|
|
|
{ |
|
|
|
public static T GetAttributeFrom<T>(this object instance, string propertyName) where T : Attribute |
|
|
|
{ |
|
|
|
var attributeType = typeof(T); |
|
|
|
var property = instance.GetType().GetProperty(propertyName); |
|
|
|
if (property == null) return default(T); |
|
|
|
return (T)property.GetCustomAttributes(attributeType, false).FirstOrDefault(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|