diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs
index 98b5db0b..e0b42cb4 100644
--- a/AMESCoreStudio.Web/Controllers/PCSController.cs
+++ b/AMESCoreStudio.Web/Controllers/PCSController.cs
@@ -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
+
+
+ ///
+ /// 工單建立時判斷是否都有資料
+ ///
+ ///
+ ///
+ public string CheckWipInfoInsert(WipViewModel model)
+ {
+ string Msg = string.Empty;
+
+ if (string.IsNullOrWhiteSpace(model.wipInfo.LineID.ToString()))
+ Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.LineID)).Name;
+
+ if (string.IsNullOrWhiteSpace(model.wipInfo.UnitNO))
+ Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.UnitNO)).Name;
+
+ if (model.wipInfo.WipDueDate == DateTime.MinValue)
+ Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.WipDueDate)).Name;
+
+ if (model.wipInfo.WipScheduleDate == DateTime.MinValue)
+ Msg += "," + model.wipInfo.GetAttributeFrom(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(nameof(model.BiTemperature)).Name;
+
+ if (string.IsNullOrWhiteSpace(model.BiTime))
+ Msg += "," + model.GetAttributeFrom(nameof(model.BiTime)).Name;
+
+ if (string.IsNullOrWhiteSpace(model.Checksum))
+ Msg += "," + model.GetAttributeFrom(nameof(model.Checksum)).Name;
+
+ if (string.IsNullOrWhiteSpace(model.Cpu))
+ Msg += "," + model.GetAttributeFrom(nameof(model.Cpu)).Name;
+
+ if (string.IsNullOrWhiteSpace(model.Ram))
+ Msg += "," + model.GetAttributeFrom(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(nameof(model.BiTemperature)).Name;
+
+ if (string.IsNullOrWhiteSpace(model.BiTime))
+ Msg += "," + model.GetAttributeFrom(nameof(model.BiTime)).Name;
+
+ if (string.IsNullOrWhiteSpace(model.Checksum))
+ Msg += "," + model.GetAttributeFrom(nameof(model.Checksum)).Name;
+
+ if (string.IsNullOrWhiteSpace(model.BurnLocation))
+ Msg += "," + model.GetAttributeFrom(nameof(model.BurnLocation)).Name;
+
+ }
+
+ return Msg;
+ }
+ #endregion
+
+
#region 下拉選單
///
@@ -746,103 +882,127 @@ 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)
{
- result = await _pcsApi.PostWipInfo(JsonConvert.SerializeObject(model.wipInfo));
- if (result.Success)
+ int wipID = int.Parse(result.Msg);
+
+ // 工單屬性
+ model.wipAtt.WipNO = model.wipInfo.WipNO;
+ await _pcsApi.PostWipAtt(JsonConvert.SerializeObject(model.wipAtt));
+
+ // 標籤
+ model.wipLabel.ApproveLogo = model.wipLabel.ApproveLogos.Count == 0 ? null : string.Join(',', model.wipLabel.ApproveLogos);
+ model.wipLabel.WipNO = model.wipInfo.WipNO;
+ await _pcsApi.PostWipLabel(JsonConvert.SerializeObject(model.wipLabel));
+
+ // 新增工單Log
+ WipLog wiplog = new WipLog();
+ wiplog.WipID = wipID;
+ wiplog.StatusNO = "N";
+ wiplog.WipDesc = ".";
+ await _pcsApi.PostWipLog(JsonConvert.SerializeObject(wiplog));
+
+ // 系統
+ if (model.wipInfo.UnitNO == "B" || model.wipInfo.UnitNO == "P" || model.wipInfo.UnitNO == "T")
{
- int wipID = int.Parse(result.Msg);
-
- // 工單屬性
- model.wipAtt.WipNO = model.wipInfo.WipNO;
- await _pcsApi.PostWipAtt(JsonConvert.SerializeObject(model.wipAtt));
-
- // 標籤
- model.wipLabel.ApproveLogo = model.wipLabel.ApproveLogos.Count == 0 ? null : string.Join(',', model.wipLabel.ApproveLogos);
- model.wipLabel.WipNO = model.wipInfo.WipNO;
- await _pcsApi.PostWipLabel(JsonConvert.SerializeObject(model.wipLabel));
-
- // 新增工單Log
- WipLog wiplog = new WipLog();
- wiplog.WipID = wipID;
- wiplog.StatusNO = "N";
- 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));
- //}
-
- // 工單對應SOP Log
- var q = await _pcsApi.GetWipSopQuery(itemNo: model.wipAtt.ItemNO, unitNo: model.wipInfo.UnitNO, state: "Y");
- if (q.Data.Count() != 0)
+ if (string.IsNullOrWhiteSpace(CheckWipInfoInsert_WipSystem(model.wipSystem)))
{
- model.wipSopLog.WipSopID = q.Data.FirstOrDefault().WipSopID;
- await _pcsApi.PostWipSopLog(JsonConvert.SerializeObject(model.wipSopLog));
+ model.wipSystem.ItemNo = model.wipAtt.ItemNO;
+ model.wipSystem.WipNo = model.wipInfo.WipNO;
+ await _pcsApi.PostWipSystem(JsonConvert.SerializeObject(model.wipSystem));
}
-
- // 內部條碼
- if (!string.IsNullOrWhiteSpace(model.wipBarcode.StartNO))
+ }
+ else
+ // 板卡
+ {
+ if (string.IsNullOrWhiteSpace(CheckWipInfoInsert_WipSystem(model.wipSystem)))
{
- model.wipBarcode.WipID = wipID;
- model.wipBarcode.WipNO = model.wipInfo.WipNO;
- model.wipBarcode.UnitNO = model.wipInfo.UnitNO;
- result = await _pcsApi.PostWipBarcode(JsonConvert.SerializeObject(model.wipBarcode));
-
- // 工單條碼規則設定文件檔
- WipRule wipRule = new WipRule();
- wipRule.WipNO = model.wipInfo.WipNO;
- wipRule.KeyNo = "00";
- wipRule.BarcodeLen = 14;
- wipRule.BarcodeFormat = model.wipInfo.UnitNO;
- result = await _pcsApi.PostWipRule(JsonConvert.SerializeObject(wipRule));
+ model.wipBoard.ItemNo = model.wipAtt.ItemNO;
+ model.wipBoard.WipNo = model.wipInfo.WipNO;
+ await _pcsApi.PostWipBoard(JsonConvert.SerializeObject(model.wipBoard));
}
+ }
- // 出貨序號
- if (!string.IsNullOrWhiteSpace(model.wipBarcodeOther.StartNO))
- {
- var type_no = await _pcsApi.GetBarcodeTypeByTypeName("客戶條碼區間");
- if (type_no.Any())
- {
- model.wipBarcodeOther.WipNO = model.wipInfo.WipNO;
- model.wipBarcodeOther.TypeNO = type_no.FirstOrDefault().TypeNO;
- result = await _pcsApi.PostWipBarcodeOther(JsonConvert.SerializeObject(model.wipBarcodeOther));
- }
- }
+ // 工單對應SOP Log
+ var q = await _pcsApi.GetWipSopQuery(itemNo: model.wipAtt.ItemNO, unitNo: model.wipInfo.UnitNO, state: "Y");
+ if (q.Data.Count() != 0)
+ {
+ model.wipSopLog.WipSopID = q.Data.FirstOrDefault().WipSopID;
+ await _pcsApi.PostWipSopLog(JsonConvert.SerializeObject(model.wipSopLog));
+ }
- // MAC
- if (!string.IsNullOrWhiteSpace(model.wipMAC.StartNO))
+ // 內部條碼
+ if (!string.IsNullOrWhiteSpace(model.wipBarcode.StartNO) && !string.IsNullOrWhiteSpace(model.wipBarcode.EndNO))
+ {
+ model.wipBarcode.WipID = wipID;
+ model.wipBarcode.WipNO = model.wipInfo.WipNO;
+ model.wipBarcode.UnitNO = model.wipInfo.UnitNO;
+ result = await _pcsApi.PostWipBarcode(JsonConvert.SerializeObject(model.wipBarcode));
+
+ // 工單條碼規則設定文件檔
+ WipRule wipRule = new WipRule();
+ wipRule.WipNO = model.wipInfo.WipNO;
+ wipRule.KeyNo = "00";
+ wipRule.BarcodeLen = 14;
+ wipRule.BarcodeFormat = model.wipInfo.UnitNO;
+ result = await _pcsApi.PostWipRule(JsonConvert.SerializeObject(wipRule));
+ }
+
+ // 出貨序號
+ if (!string.IsNullOrWhiteSpace(model.wipBarcodeOther.StartNO) && !string.IsNullOrWhiteSpace(model.wipBarcodeOther.EndNO))
+ {
+ var type_no = await _pcsApi.GetBarcodeTypeByTypeName("客戶條碼區間");
+ if (type_no.Any())
{
- model.wipMAC.WipNO = model.wipInfo.WipNO;
- result = await _pcsApi.PostWipMAC(JsonConvert.SerializeObject(model.wipMAC));
+ model.wipBarcodeOther.WipNO = model.wipInfo.WipNO;
+ model.wipBarcodeOther.TypeNO = type_no.FirstOrDefault().TypeNO;
+ result = await _pcsApi.PostWipBarcodeOther(JsonConvert.SerializeObject(model.wipBarcodeOther));
}
}
- }
- else
- {
- result = await _pcsApi.PostWipInfo(JsonConvert.SerializeObject(model.wipInfo));
+
+ // MAC
+ 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));
+ }
}
+
+
if (result.Success)
{
var _msg = model.wipInfo.WipID == 0 ? "添加成功!" : "修改成功!";
- return RedirectToAction("Refresh", "Home", new { msg = _msg });
+ return RedirectToAction("PCB", "Home", new { msg = _msg });
}
else
{
@@ -909,7 +1069,7 @@ namespace AMESCoreStudio.Web.Controllers
GetCheckboxApproveLogo(model.wipLabel != null ? model.wipLabel.ApproveLogo : null);
GetCheckboxCompanyLogo(model.wipLabel != null ? model.wipLabel.CompanyLogo : null);
GetCheckboxPrintMode(model.wipLabel != null ? model.wipLabel.PrintMode : null);
- GetCheckboxWipAttr(model.wipLabel != null ? model.wipLabel.WipAttr :null);
+ GetCheckboxWipAttr(model.wipLabel != null ? model.wipLabel.WipAttr : null);
return View(model);
}
@@ -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(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();
+ }
+ }
}
diff --git a/AMESCoreStudio.Web/ViewModels/WipViewModel.cs b/AMESCoreStudio.Web/ViewModels/WipViewModel.cs
index 5fe3d554..7b739b94 100644
--- a/AMESCoreStudio.Web/ViewModels/WipViewModel.cs
+++ b/AMESCoreStudio.Web/ViewModels/WipViewModel.cs
@@ -45,8 +45,6 @@ namespace AMESCoreStudio.Web.ViewModels
public WipMAC wipMAC { get; set; }
- public WipRule wipRule { get; set; }
-
public WipBarcodeOther wipBarcodeOther { get; set; }
diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml
index 84ee6a9a..a292279e 100644
--- a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml
+++ b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml
@@ -23,7 +23,7 @@
-
+
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipMACController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipMACController.cs
index 095416dd..8460bfa7 100644
--- a/AMESCoreStudio.WebApi/Controllers/AMES/WipMACController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipMACController.cs
@@ -47,10 +47,10 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
var WipMAC = await q.Where(p => p.WipNO == id).FirstOrDefaultAsync();
- if (WipMAC == null)
- {
- return NotFound();
- }
+ //if (WipMAC == null)
+ //{
+ // return NotFound();
+ //}
return WipMAC;
}
diff --git a/AMESCoreStudio.WebApi/Models/AMES/BarcodeType.cs b/AMESCoreStudio.WebApi/Models/AMES/BarcodeType.cs
index 70738ebb..4ebf9809 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/BarcodeType.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/BarcodeType.cs
@@ -75,7 +75,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
///
/// 更新日期
///
- [Column("UPDATE_DATE", TypeName = "DATE")]
+ [Column("UPDATE_DATE")]
[DataMember]
public DateTime UpdateDate { get; set; } = System.DateTime.Now;
}
diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipBarcodeOther.cs b/AMESCoreStudio.WebApi/Models/AMES/WipBarcodeOther.cs
index e399a8c9..babd752c 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/WipBarcodeOther.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/WipBarcodeOther.cs
@@ -26,7 +26,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
[Column("WIP_NO")]
[DataMember]
[Required(ErrorMessage = "{0},不能空白")]
- [Display(Name = "")]
+ [Display(Name = "工單號碼")]
public string WipNO { get; set; }
///
@@ -61,7 +61,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
///
[Column("TITLE")]
[DataMember]
- [Display(Name = "")]
+ [Display(Name = "title")]
public string Title { get; set; }
///
diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipMAC.cs b/AMESCoreStudio.WebApi/Models/AMES/WipMAC.cs
index 1cfd5012..b8d29536 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/WipMAC.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/WipMAC.cs
@@ -17,6 +17,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
///
[Key]
[Column("WIP_NO")]
+ [Display(Name = "工單號碼")]
[Required(ErrorMessage = "{0},不能空白")]
[DataMember]
public string WipNO { get; set; }
diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipSystem.cs b/AMESCoreStudio.WebApi/Models/AMES/WipSystem.cs
index 31333325..faba5ca0 100644
--- a/AMESCoreStudio.WebApi/Models/AMES/WipSystem.cs
+++ b/AMESCoreStudio.WebApi/Models/AMES/WipSystem.cs
@@ -120,13 +120,13 @@ namespace AMESCoreStudio.WebApi.Models.AMES
public string Ram { get; set; }
///
- /// FINE_PACKAGE
+ /// 是否為精包裝Y/N
///
[Required]
[Column("FINE_PACKAGE")]
[StringLength(2)]
[DataMember]
- [Display(Name = "RAM")]
+ [Display(Name = "是否為精包裝")]
public string FinePackage { get; set; }
///