From 4720cae681c43392fa6c44deb734627f1ef87f1b Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 7 Dec 2021 14:06:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=95=B4=E7=90=86Git=E8=B3=87=E6=96=99=20?= =?UTF-8?q?2.=20=E6=9B=B4=E6=96=B0=E5=B7=A5=E5=96=AE=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E8=B3=87=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 309 ++-- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 14 +- AMESCoreStudio.Web/ViewModels/WipViewModel.cs | 2 + AMESCoreStudio.Web/Views/PCS/PCS001.cshtml | 199 ++- AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml | 1548 ++++++++--------- .../Controllers/AMES/WipSopLogController.cs | 181 ++ .../Models/AMES/BarcodeItem.cs | 2 +- AMESCoreStudio.WebApi/Models/AMES/Item.cs | 45 - AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs | 15 +- .../Models/AMES/WipSopLog.cs | 84 + .../Models/AMES/WipSystem.cs | 12 +- AMESCoreStudio.WebApi/Models/AMESContext.cs | 34 +- 12 files changed, 1392 insertions(+), 1053 deletions(-) create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/WipSopLogController.cs delete mode 100644 AMESCoreStudio.WebApi/Models/AMES/Item.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 64729227..2eb1a44a 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -133,6 +133,23 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.FactoryUnitList = FactoryUnit; } + /// + /// 組件資料 + /// + /// + private async Task GetItems() + { + var result = await _pcsApi.GetItems(); + + var ItemsList = new List(); + ItemsList.Add(new SelectListItem("請選擇", "")); + for (int i = 0; i < result.Count; i++) + { + ItemsList.Add(new SelectListItem(result[i].ItemName, result[i].ItemNo.ToString())); + } + ViewBag.ItemsList = ItemsList; + } + /// /// 正背面 /// @@ -224,7 +241,7 @@ namespace AMESCoreStudio.Web.Controllers var FlowRuleItems = new List(); for (int i = 0; i < result.Count; i++) { - FlowRuleItems.Add(new SelectListItem(result[i].UnitNo + result[i].FlowRuleName, result[i].FlowRuleID.ToString())); + FlowRuleItems.Add(new SelectListItem(result[i].FlowRuleName, result[i].FlowRuleID.ToString())); } if (FlowRuleItems.Count == 0) @@ -591,47 +608,6 @@ namespace AMESCoreStudio.Web.Controllers //TempData["GetLockReasonTypeList"] = LockReasonType; ViewBag.GetLockReasonTypeList = LockReasonType; } - - - /// - /// 生產單位 - /// - /// - private async Task GetFactoryUnitList() - { - var result = await _basApi.GetFactoryUnits(); - - var UnitItems = new List(); - UnitItems.Add(new SelectListItem("請選擇", "")); - for (int i = 0; i < result.Count; i++) - { - UnitItems.Add(new SelectListItem(result[i].UnitName, result[i].UnitNo.ToString())); - } - ViewBag.FactoryUnit = UnitItems; - } - - - /// - /// 組件資料 - /// - /// - private async Task GetItems() - { - var result = await _pcsApi.GetItems(); - - var ItemsList = new List(); - ItemsList.Add(new SelectListItem("請選擇", "")); - for (int i = 0; i < result.Count; i++) - { - ItemsList.Add(new SelectListItem(result[i].ItemName, result[i].ItemNo.ToString())); - } - ViewBag.ItemsList = ItemsList; - } - - - - - #endregion [ResponseCache(Duration = 0)] @@ -719,7 +695,13 @@ namespace AMESCoreStudio.Web.Controllers 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) + { + model.wipSopLog.WipSopID = q.Data.FirstOrDefault().WipSopID; + await _pcsApi.PostWipSopLog(JsonConvert.SerializeObject(model.wipSopLog)); + } if (!string.IsNullOrWhiteSpace(model.wipBarcode.StartNO)) { model.wipBarcode.WipID = model.wipInfo.WipID; @@ -878,6 +860,18 @@ namespace AMESCoreStudio.Web.Controllers } #endregion + public async Task MaterialKpQueryAsync(string itemno = null, string station = null) + { + + IResultModel result = await _pcsApi.GetMaterialKpQuery(itemno: itemno, station: station); + + if (result.Data.Count() != 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = 0 }); + } + return Json(new Table() { count = 0, data = null }); + } + #region PCS005 工單資料查詢 public IActionResult PCS005() { @@ -1168,7 +1162,6 @@ namespace AMESCoreStudio.Web.Controllers #endregion - #region PCS021 條碼輸入作業 [ResponseCache(Duration = 0)] [HttpGet] @@ -1180,6 +1173,119 @@ namespace AMESCoreStudio.Web.Controllers } #endregion + #region PCS024組件资料维护相关 + + public async Task PCS024() + { + await GetFactoryUnit(); + return View(); + } + //新增頁面 + public async Task PCS024C(string id) + { + var result = await _pcsApi.GetBarcodeInfoesByNo(id); + var tt = result[0]; + ViewBag.BarcodeID = tt.BarcodeID; + ViewBag.WipID = tt.WipID; + ViewBag.BarcodeNo = id; + await GetFactoryUnit(); + //await GetStations(); + await GetItems(); + return View(); + } + + //修改页面 + [HttpGet] + public async Task PCS024UAsync(int id) + { + await GetItems(); + + var result = await _pcsApi.GetBarcodeItem(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task PCS024DAsync(int id) + { + var result = await _pcsApi.DeleteBarcodeItem(id); + return Json(new Result() { success = true, msg = "" }); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task PCS024CSaveAsync(BarcodeItem model) + { + if (ModelState.IsValid) + { + IResultModel result; + result = await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(model)); + + + if (!result.Success) + { + var _msg = "新增成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors.Count > 0) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("PCS024C", model); + + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetBarcodeItemsAsync() + { + var result = await _pcsApi.GetBarcodeItems(); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetBarcodeItemByUnitAsync(string ID) + { + string str, str1; + var strA = ID.Split("="); + str = strA[0]; + str1 = strA[1]; + //WO0002A10001 + + if (ID is null) + return Json(new Table() { count = 0, data = null }); + + var result = await _pcsApi.GetBItemByStr(str, str1); + //var result = await _pcsApi.GetBarcodeItemByUnit(ID); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + #endregion + [ResponseCache(Duration = 0)] [HttpGet] public async Task PCS030() @@ -1296,121 +1402,6 @@ namespace AMESCoreStudio.Web.Controllers return View(model); } - #region PCS024組件资料维护相关 - - public async Task PCS024() - { - await GetFactoryUnitList(); - return View(); - } - //新增頁面 - public async Task PCS024C(string id) - { - var result = await _pcsApi.GetBarcodeInfoesByNo(id); - var tt = result[0]; - ViewBag.BarcodeID = tt.BarcodeID; - ViewBag.WipID = tt.WipID; - ViewBag.BarcodeNo = id; - await GetFactoryUnitList(); - //await GetStations(); - await GetItems(); - return View(); - } - - //修改页面 - [HttpGet] - public async Task PCS024UAsync(int id) - { - await GetItems(); - - var result = await _pcsApi.GetBarcodeItem(id); - - if (result.Count == 0) - { - return View(); - } - return View(result[0]); - } - - public async Task PCS024DAsync(int id) - { - var result = await _pcsApi.DeleteBarcodeItem(id); - return Json(new Result() { success = true, msg = "" }); - } - - //頁面提交,id=0 添加,id>0 修改 - [HttpPost] - public async Task PCS024CSaveAsync(BarcodeItem model) - { - if (ModelState.IsValid) - { - IResultModel result; - result = await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(model)); - - - if (!result.Success) - { - var _msg = "新增成功!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); - } - else - { - if (result.Errors.Count > 0) - { - ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); - } - else - { - ModelState.AddModelError("error", result.Msg); - } - } - } - return View("PCS024C", model); - - } - - [ResponseCache(Duration = 0)] - [HttpGet] - public async Task GetBarcodeItemsAsync() - { - var result = await _pcsApi.GetBarcodeItems(); - - if (result.Count > 0) - { - return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); - } - - return Json(new Table() { count = 0, data = null }); - } - - [ResponseCache(Duration = 0)] - [HttpGet] - public async Task GetBarcodeItemByUnitAsync(string ID) - { - string str, str1; - var strA = ID.Split("="); - str = strA[0]; - str1 = strA[1]; - //WO0002A10001 - - if (ID is null) - return Json(new Table() { count = 0, data = null }); - - var result = await _pcsApi.GetBItemByStr(str, str1); - //var result = await _pcsApi.GetBarcodeItemByUnit(ID); - - if (result.Count > 0) - { - return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); - } - - return Json(new Table() { count = 0, data = null }); - } - - #endregion - - - [HttpPost] public JsonResult TestFunc(string number) { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 4be72973..ef3463dc 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -295,8 +295,18 @@ namespace AMESCoreStudio.Web /// SOP文件變更狀態 /// /// + [WebApiClient.Attributes.HttpPut("api/WipSop/{id}/{state}")] - ITask> PutWipSop(int id , string state); + ITask> PutWipSop(int id, string state); + #endregion + + #region WipSopLog 工單對應SOP log + /// + /// 新增工單對應SOP log + /// + /// + [WebApiClient.Attributes.HttpPost("api/WipSopLog")] + ITask> PostWipSopLog([FromBody, RawJsonContent] string model); #endregion #region PCS024組件維護相關 @@ -306,7 +316,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/Items")] - ITask> GetItems(); + ITask> GetItems(); /// /// 新增組件 diff --git a/AMESCoreStudio.Web/ViewModels/WipViewModel.cs b/AMESCoreStudio.Web/ViewModels/WipViewModel.cs index efc054c3..f1b08576 100644 --- a/AMESCoreStudio.Web/ViewModels/WipViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/WipViewModel.cs @@ -39,5 +39,7 @@ namespace AMESCoreStudio.Web.ViewModels public FactoryUnit factoryUnit { get; set; } + public WipSopLog wipSopLog { get; set; } + } } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml index 4a4c1603..cca30755 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml @@ -18,6 +18,7 @@
+
@@ -231,6 +232,7 @@
+
@* 序號編碼sheet *@ @@ -273,7 +275,8 @@ @* Keypart組合sheet *@
-
+ 刷新 +
@* 板卡-工程資訊sheet *@ @@ -359,6 +362,7 @@
+
@@ -393,18 +397,21 @@
+
+
+
@@ -415,12 +422,12 @@
- +
- - + +
@@ -515,18 +522,21 @@
+
+
+
@@ -541,11 +551,13 @@
+
+
@@ -555,10 +567,12 @@
+
+
@@ -802,13 +816,8 @@ @* SOP文件 sheet *@
-

檔案

- @*@await Html.PartialAsync("PCS/_SOPPartial")*@ - - @*
-
-
*@ - + 刷新 +
@@ -827,12 +836,18 @@ await Html.RenderPartialAsync("_FileinputScriptsPartial"); } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml index 1bef48e9..e090350b 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml @@ -12,805 +12,694 @@ .text-error { color: #dc3545 !important; } + + .my-read-only-class { + cursor: not-allowed; + }
- +
-
- -
- -
-
- -
- - -
- -
- -
- -
- - -
- -
- - -
+
+
-
-
-
- -
- -
- -
- -
- -
- -
- -
- - +
+
+ +
+ + +
+ +
+ +
+ +
+ + +
+ +
+ + +
-
-
-
-
- -
- -
- -
- - -
- -
- -
- -
- +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+
-
-
-
- -
- -
- - -
- - +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ + +
+ + +
- + - -
- - + +
+ + +
+ + +
+ +
+
- -
- +
+ +
+
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ + +
-
- -
- - - -
- -
-
    -
  • 工單屬性
  • -
  • 生產流程
  • -
  • 序號編碼
  • -
  • Keypart組合
  • -
  • 板卡-工程資訊
  • -
  • 系統-工程資訊
  • -
  • 標籤選項
  • -
  • SOP文件
  • -
-
- @* 工單屬性sheet *@ -
-
-
- -
- -
- -
- -
- -
- -
-
-
+
+
    +
  • 工單屬性
  • +
  • 生產流程
  • +
  • 序號編碼
  • +
  • Keypart組合
  • +
  • 板卡-工程資訊
  • +
  • 系統-工程資訊
  • +
  • 標籤選項
  • +
  • SOP文件
  • +
+
+ @* 工單屬性sheet *@ +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
-
-
- -
- -
- -
- - +
+ +
+
+ +
+ + +
+ +
+ + +
-
-
-
- -
- +
+
+ +
+ +
+ +
+ +
- -
- +
+ +
+
+ +
+ + +
+ +
+ + +
+
-
-
- -
- - + @* 生產流程sheet *@ +
+
+
+ +
+ +
+
- -
- - +
+
+ + + + + + + + + + @foreach (var index in Model.ruleStation) + { + + + + + + } + +
+ 站別描述 + + 站別順序 + + 站別類型 +
+ @index.StationDesc + + @index.Sequence + + @index.StationType +
-
+ @* 序號編碼sheet *@ +
+ + + + + - @* 生產流程sheet *@ -
-
-
- -
- +
+ + + + @foreach (var index in Model.wipBarcode) + { + + + + + } + +
+ 起始生產序號 + + 結束生產序號 +
+ @index.StartNO + + @index.EndNO +
+
+
+ +
+ +
-
-
- + +
+
+ +
+ + +
+
+
+ + @* Keypart組合sheet *@ +
+
+ + + + - @foreach (var index in Model.ruleStation) + @foreach (var index in Model.materialKp) { + + + + }
- 站別描述 + 料號 + + KP料號名稱 - 站別順序 + KP料號NO - 站別類型 + 順序 + + 前置碼 + + 長度 + + 站(前段)
- @index.StationDesc + @index.ItemName + + @index.KpName + + @index.KpNo - @index.Sequence + @index.KpSeq - @index.StationType + @index.Title + + @index.Length + + @index.Station
-
- @* 序號編碼sheet *@ -
- - - - - - - - - - - @foreach (var index in Model.wipBarcode) - { - - - - - } - -
- 起始生產序號 - - 結束生產序號 -
- @index.StartNO - - @index.EndNO -
-
-
- -
- -
-
-
- -
-
- -
- - -
-
-
-
- - @* Keypart組合sheet *@ -
-
- - - - - - - - - - - - - - @foreach (var index in Model.materialKp) - { - - - - - - - - - - } - -
- 料號 - - KP料號名稱 - - KP料號NO - - 順序 - - 前置碼 - - 長度 - - 站(前段) -
- @index.ItemName - - @index.KpName - - @index.KpNo - - @index.KpSeq - - @index.Title - - @index.Length - - @index.Station -
-
- - @* 板卡-工程資訊sheet *@ -
-
-
- -
- - -
- - -
- - -
-
-
- - @*
+ @* 板卡-工程資訊sheet *@ +
+
- +
- +
-
-
*@ - - @*
- -
- -
-
*@ - -
-
- -
- + +
+ + +
-
-
-
- -
- -
- - -
-
+ @*
+
+ +
+ + +
+
+
*@ -
-
- -
- -
-
- + + @*
+
- +
-
- -
-
+
*@ -
-
- -
- -
-
-
- -
- +
+
+ +
+ +
-
-
-
- -
- -
-
-
- -
- +
+
+ +
+ +
+ +
-
-
-
- -
- +
+
+ +
+ +
+
+ +
+ +
+
+
-
-
-
-
- -
- -
-
-
- -
- +
+
+ +
+
-
- +
+
- +
-
-
-
- -
- - +
+
+ +
+ +
- -
- - +
+ +
+ +
-
- @*
+
- +
- - +
-
- - + +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
- +
- - + +
-
-
*@ - - @*
-
- +
- +
-
*@ - - - @*
- -
- -
-
*@ -
- - @* 系統-工程資訊sheet *@ -
-
-
- -
- - -
- - -
- - -
-
-
-
- -
- - + @*
+
+ +
+ + +
+
-
-
-
- -
- -
-
- -
-
-
- -
- +
+
+ +
+ + +
-
- -
- + +
+
+ +
+ + +
-
-
- -
- +
*@ + + @*
+
+ +
+ + +
-
- -
- -
-
-
- -
-
- -
- -
+
*@ - -
- -
-
-
- -
-
- -
- -
- -
- -
- -
- -
-
-
-
-
- -
- -
-
-
- -
-
- -
- -
-
-
- -
-
- -
- -
-
-
- -
-
- -
- -
-
+ @*
+ +
+ +
+
*@
+ @* 系統-工程資訊sheet *@ +
+
+
+ +
+ + +
-
-
- -
- + +
+ + +
-
-
-
- -
- +
+
+ +
+ + +
-
-
-
- -
- +
+ +
+
-
- @*
+
-
- + +
+ +
-
- - + +
+ +
-
- - + +
+ +
+
+ +
+
- -
- -
- +
- - +
+
- - +
- +
- +
- +
- - +
- +
- - +
- +
- +
+
+
+
+
+
- - +
+
+
+
+
+
- - +
-
- +
- - +
@@ -818,172 +707,234 @@
- +
- - +
- -
- - -
- +
+
+ +
+
+
- - +
- +
- + +
+
+
+ + @*
+
+ +
+ +
+ +
+ + +
+ +
+ + +
+
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ + +
+
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ + +
-
*@ -
- -
- +
+
+ +
+ +
+ +
+ + +
+ +
+ + +
+
+
+ + +
+
+ +
+ + +
+
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ +
+
+ +
+ +
+
+
*@ + +
+ +
+ +
-
- @* 標籤選項sheet *@ -
-
- -
- - + @* 標籤選項sheet *@ +
+
+ +
+ + +
-
-
- -
- +
+ +
+ +
+
-
-
-
- -
- - - - - +
+ +
+ + + + + +
-
-
- -
- - +
+ +
+ + +
-
-
- -
- - +
+ +
+ + +
-
- @* SOP文件 sheet *@ -
-

檔案

- @*@await Html.PartialAsync("PCS/_SOPPartial")*@ - - @*
-
-
*@ + @* SOP文件 sheet *@ +
+
+
-
- - @Html.ValidationMessage("error") -
-
- -
-
@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); - await Html.RenderPartialAsync("_FileinputScriptsPartial"); } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipSopLogController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipSopLogController.cs new file mode 100644 index 00000000..b6b371f1 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipSopLogController.cs @@ -0,0 +1,181 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.CommonTools.Result; +using AMESCoreStudio.WebApi.DTO.AMES; +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace AMESCoreStudio.WebApi.Controllers.AMES +{ + [Route("api/[controller]")] + [ApiController] + public class WipSopLogController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public WipSopLogController(AMESContext context) + { + _context = context; + } + + /// + /// 工單投產纪錄資料文件 + /// + /// + [HttpGet] + public async Task>> GetWipSopLog() + { + IQueryable q = _context.WipSopLogs; + q = q.OrderBy(p => p.WipSopID); + var WipSopLog = await q.ToListAsync(); + return WipSopLog; + } + + [HttpGet("{id}")] + public async Task> GetWipSopLog(int id) + { + IQueryable q = _context.WipSopLogs; + + var WipSopLog = await q.Where(p => p.WipID == id).FirstOrDefaultAsync(); + + if (WipSopLog == null) + { + return NotFound(); + } + + return WipSopLog; + } + + /// + /// SOP文件查詢 + /// + /// 料號 + /// 生產單位 + /// 檔案名稱 + /// 狀態 + /// 建立日期起 + /// 建立日期迄 + /// + //[Route("[action]")] + //[HttpGet] + //public async Task> GetWipSopLogQuery(string itemNo = null, string unitNo = null + // , string fileName = null, string state = null, string date_str = null, string date_end = null) + //{ + // IQueryable q = _context.WipSopLogs; + + // if (!string.IsNullOrWhiteSpace(itemNo)) + // q = q.Where(w => w.ItemNo == itemNo); + + // if (!string.IsNullOrWhiteSpace(unitNo)) + // q = q.Where(w => w.UnitNo == unitNo); + + // if (!string.IsNullOrWhiteSpace(fileName)) + // q = q.Where(w => w.FileName.Contains(fileName)); + + // if (!string.IsNullOrWhiteSpace(state)) + // q = q.Where(w => w.State == state); + + + // DateTime dateValue; + // if (DateTime.TryParse(date_str, out dateValue)) + // { + // q = q.Where(w => w.CreateDate >= DateTime.Parse(date_str)); + // } + + // if (DateTime.TryParse(date_end, out dateValue)) + // { + // q = q.Where(w => w.CreateDate <= DateTime.Parse(date_end)); + // } + + // ResultModel result = new ResultModel(); + // result.Data = await q.Select(s => new WipSopLogDto + // { + // WipSopLogID = s.WipSopLogID, + // ItemNo = s.ItemNo, + // UnitName = s.FactoryUnit.UnitName, + // FileName = s.FileName, + // FilePath = s.FilePath, + // State = s.State == "Y" ? "使用中" : "停用", + // NewName = s.NewName, + // CreateDate = s.CreateDate, + // CreateUserID = s.CreateUserID, + // UpdateDate = s.UpdateDate, + // UpdateUserID = s.UpdateUserID + // }).ToListAsync(); + + // return result; + //} + + [HttpPost] + public async Task> PostWipSopLog([FromBody] WipSopLog wipSopLog) + { + + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + wipSopLog.WipID = helper.GetIDKeyNoPost("WIP_ID").Result; + wipSopLog.State = "Y"; + //wipLog.WipSopLogID = wipLog.WipID == 0 ? helper.GetIDKeyNoPost("WIP_ID").Result : wipLog.WipID; + _context.WipSopLogs.Add(wipSopLog); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.Message; + } + return result; + } + + //// PUT api//5 + //[HttpPut("{id}/{state}")] + //public async Task> PutWipSopLog(int id, string state) + //{ + // ResultModel result = new ResultModel(); + // var WipSopLog = new WipSopLog { + // WipSopLogID = id, + // State = state, + // UpdateUserID = 1, + // UpdateDate = System.DateTime.Now + + // }; + // _context.Attach(WipSopLog); + + // // 指定更新某個欄位 + // _context.Entry(WipSopLog).Property(p => p.State).IsModified = true; + // _context.Entry(WipSopLog).Property(p => p.UpdateUserID).IsModified = true; + // _context.Entry(WipSopLog).Property(p => p.UpdateDate).IsModified = true; + + // try + // { + // await _context.SaveChangesAsync(); + // result.Success = true; + // result.Msg = "OK"; + // } + // catch (Exception ex) + // { + // result.Success = false; + // result.Msg = ex.Message; + // } + // return result; + //} + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/BarcodeItem.cs b/AMESCoreStudio.WebApi/Models/AMES/BarcodeItem.cs index f5dc2381..e5cf6b43 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/BarcodeItem.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/BarcodeItem.cs @@ -109,7 +109,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// 組件资料 /// - public virtual Item I { get; set; } + public virtual Items I { get; set; } /// /// 站別资料 diff --git a/AMESCoreStudio.WebApi/Models/AMES/Item.cs b/AMESCoreStudio.WebApi/Models/AMES/Item.cs deleted file mode 100644 index 3ee2cfa9..00000000 --- a/AMESCoreStudio.WebApi/Models/AMES/Item.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Runtime.Serialization; - -namespace AMESCoreStudio.WebApi.Models.AMES -{ - /// - /// 組件資料檔 - /// - [Table("ITEMS", Schema = "JHAMES")] - [DataContract] - public class Item - { - /// - /// 组件代碼 - /// - [Column("ITEM_NO")] - [DataMember] - [Key] - public string ItemNo { get; set; } - - /// - /// 组件名稱 - /// - [Column("ITEM_NAME")] - [DataMember] - public string ItemName { get; set; } - - /// - /// 組件類別 - /// - [Column("ITEM_TYPE")] - [DataMember] - public string ItemType { get; set; } - - /// - /// 組件區間管控 - /// - [Column("SN_INTERVAL")] - [DataMember] - public string SnInerval { get; set; } - - } -} diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs b/AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs index 280782ab..3a85caac 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs @@ -88,6 +88,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [StringLength(20)] [DataMember] [Display(Name = "燒錄位置")] + public string BurnLocation { get; set; } /// @@ -96,6 +97,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("PARTS_BAKE", TypeName = "NUMBER")] [DataMember] [Display(Name = "零件烘烤溫度")] + [Required(ErrorMessage = "{0},不能空白")] public decimal PartsBake { get; set; } /// @@ -104,6 +106,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("PARTS_BAKE_TIME", TypeName = "NUMBER")] [DataMember] [Display(Name = "零件烘烤時間")] + [Required(ErrorMessage = "{0},不能空白")] public decimal PartsBakeTime { get; set; } /// @@ -112,15 +115,16 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("PCB_BAKE", TypeName = "NUMBER")] [DataMember] [Display(Name = "PCB烘烤")] + [Required(ErrorMessage = "{0},不能空白")] public decimal PcbBake { get; set; } /// /// 錫膏 /// - [Column("SOLDER_PASTE", TypeName = "NUMBER")] + [Column("SOLDER_PASTE")] [DataMember] [Display(Name = "錫膏")] - public decimal SolderPaste { get; set; } + public int SolderPaste { get; set; } /// /// 燒機比率 @@ -128,26 +132,27 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("BI_RATIO", TypeName = "NUMBER")] [DataMember] [Display(Name = "燒機比率")] + [Required(ErrorMessage = "{0},不能空白")] public decimal BiRatio { get; set; } /// /// 燒機溫度 /// - [Required] [Column("BI_TEMPERATURE")] [StringLength(20)] [DataMember] [Display(Name = "燒機溫度")] + [Required(ErrorMessage = "{0},不能空白")] public string BiTemperature { get; set; } /// /// 燒機時間 /// - [Required] [Column("BI_TIME")] [StringLength(20)] [DataMember] [Display(Name = "燒機時間")] + [Required(ErrorMessage = "{0},不能空白")] public string BiTime { get; set; } /// @@ -161,11 +166,11 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// Check Sum /// - [Required] [Column("CHECKSUM")] [StringLength(20)] [DataMember] [Display(Name = "Check Sum")] + [Required(ErrorMessage = "{0},不能空白")] public string Checksum { get; set; } /// diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs b/AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs new file mode 100644 index 00000000..c8d09e65 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using System.Runtime.Serialization; + +#nullable disable + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 工單對應SOP文件紀錄 + /// + [Table("WIP_SOP_LOG", Schema = "JHAMES")] + [DataContract] + public partial class WipSopLog + { + /// + /// WIP_ID + /// + [Key] + [Column("WIP_ID", Order = 0)] + [DataMember] + public int WipID { get; set; } + + /// + /// WIP_SOP_ID + /// + [Key] + [Column("WIP_SOP_ID", Order = 1)] + [DataMember] + public int WipSopID { get; set; } + + /// + /// 狀態 + /// + [Column("STATE")] + [DataMember] + public string State { get; set; } + + /// + /// 建立UserID + /// + [Column("CREATE_USERID")] + [Required] + [DataMember] + public int CreateUserID { get; set; } = 0; + + /// + /// 建立日期 + /// + [Required] + [Column("CREATE_DATE")] + [DataMember] + public DateTime CreateDate { get; set; } = System.DateTime.Now; + + /// + /// 更新UserID + /// + [Column("UPDATE_USERID")] + [DataMember] + public int UpdateUserID { get; set; } + + /// + /// 更新日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + public DateTime? UpdateDate { get; set; } + + /// + /// 工單資料 + /// + [ForeignKey("WipID")] + public virtual WipInfo GetWipInfo { get; set; } + + /// + /// SOP資料 + /// + [ForeignKey("WipSopID")] + public virtual WipSop GetWipSop { get; set; } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipSystem.cs b/AMESCoreStudio.WebApi/Models/AMES/WipSystem.cs index e1299cd8..31333325 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WipSystem.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WipSystem.cs @@ -48,22 +48,23 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("BI_RATIO")] [DataMember] [Display(Name = "燒機比率")] + [Required(ErrorMessage = "{0},不能空白")] public decimal BiRatio { get; set; } /// /// 燒機溫度 /// - [Required] [Column("BI_TEMPERATURE")] [StringLength(20)] [DataMember] [Display(Name = "燒機溫度")] + [Required(ErrorMessage = "{0},不能空白")] public string BiTemperature { get; set; } /// /// 燒機時間 /// - [Required] + [Required(ErrorMessage = "{0},不能空白")] [Column("BI_TIME")] [StringLength(20)] [DataMember] @@ -85,12 +86,13 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] [Display(Name = "BIOS版本")] [Column("BIOS_VER", TypeName = "NUMBER")] + [Required(ErrorMessage = "{0},不能空白")] public decimal BiosVer { get; set; } /// /// Check Sum /// - [Required] + [Required(ErrorMessage = "{0},不能空白")] [Column("CHECKSUM")] [StringLength(20)] [DataMember] @@ -100,7 +102,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// CPU頻率 /// - [Required] + [Required(ErrorMessage = "{0},不能空白")] [Column("CPU")] [StringLength(20)] [DataMember] @@ -110,7 +112,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// RAM /// - [Required] + [Required(ErrorMessage = "{0},不能空白")] [Column("RAM")] [StringLength(20)] [DataMember] diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 4335198f..86202b12 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -85,17 +85,18 @@ namespace AMESCoreStudio.WebApi modelBuilder.Entity().HasKey(c => new { c.WipNO, c.StartNO, c.EndNO }); modelBuilder.Entity().HasKey(c => new { c.WipID, c.CreateDate}); modelBuilder.Entity().HasKey(c => new { c.CorpSN }); + modelBuilder.Entity().HasKey(c => new { c.WipID, c.WipSopID }); modelBuilder.Entity().HasOne(r => r.B).WithMany().HasForeignKey(r => r.BarcodeID).IsRequired(); modelBuilder.Entity().HasOne(r => r.I).WithMany().HasForeignKey(r => r.ItemNo).IsRequired(); modelBuilder.Entity().HasOne(r => r.S).WithMany().HasForeignKey(r => r.RuleStationID).IsRequired(); modelBuilder.Entity().HasOne(r => r.Group).WithMany().HasForeignKey(r => r.GroupID).IsRequired(); modelBuilder.Entity().HasKey(c => new { c.value, c.name }); + modelBuilder.Entity().HasKey(c => new { c.ItemNo, c.LineID }); modelBuilder.Entity().HasOne(r => r.Unit).WithMany().HasForeignKey(r => r.SectionNo).IsRequired(); modelBuilder.Entity().HasOne(r => r.Line).WithMany().HasForeignKey(r => r.LineID).IsRequired(); - modelBuilder.Entity().HasOne(r => r.Unit).WithMany().HasForeignKey(r => r.UnitNo).IsRequired(); modelBuilder.Entity().HasOne(r => r.Unit).WithMany().HasForeignKey(r => r.UnitNo).IsRequired(); modelBuilder.Entity().HasOne(r => r.Dept).WithMany().HasForeignKey(r => r.DeptID).IsRequired(); @@ -252,27 +253,23 @@ namespace AMESCoreStudio.WebApi /// 異常原因資料 /// public DbSet ErrorReasons { get; set; } - + /// /// 工單投產纪錄資料文件 /// public DbSet WipLogs { get; set; } + /// - ///1108因無法執行SHANI補上 + /// 工單投產纪錄資料文件 /// public DbSet NGGroups { get; set; } /// - ///1108因無法執行SHANI補上 + /// 工單投產纪錄資料文件 /// public DbSet NGClasses { get; set; } - /// - ///1108因無法執行SHANI補上 - /// - public DbSet NGReasons { get; set; } - /// /// 維修群組資料 /// @@ -296,7 +293,7 @@ namespace AMESCoreStudio.WebApi ///// ///// 不良現象原因代碼資料 ///// - //public DbSet NGReasons { get; set; } + public DbSet NGReasons { get; set; } /// /// 問題類別資料 @@ -359,8 +356,12 @@ namespace AMESCoreStudio.WebApi /// 工單資訊-系統組裝工程資訊 /// public virtual DbSet BarcodeChanges { get; set; } - + /// + /// 工單對應SOP文件log + /// + public virtual DbSet WipSopLogs { get; set; } + ///條碼資料 /// public DbSet BarcodeInfoes { get; set; } @@ -370,11 +371,6 @@ namespace AMESCoreStudio.WebApi /// public DbSet BarcodeItems { get; set; } - ///// - /////組件資料 - ///// - //public DbSet Items { get; set; } - /// ///工時群組資料 /// @@ -415,10 +411,6 @@ namespace AMESCoreStudio.WebApi ///無效工時在線收集資料 /// public DbSet ExceptionWorktimeOlines { get; set; } - - - - - } + } }