From 0aa16bd19780425dac8e063dfc3427de01652399 Mon Sep 17 00:00:00 2001 From: ray Date: Mon, 4 Apr 2022 11:00:45 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=AD=A3=E5=B7=A5=E5=96=AE?= =?UTF-8?q?=E8=B3=87=E6=96=99=20=E6=B5=81=E7=A8=8B=E6=94=B9=E6=8A=93?= =?UTF-8?q?=E6=96=99=E8=99=9F=E6=B5=81=E7=A8=8B=E5=8F=8A=E5=82=99=E8=A8=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 62 +++++- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 19 +- .../ViewModels/PCS/WipViewModel.cs | 9 +- AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml | 4 +- AMESCoreStudio.Web/Views/PCS/PCS003.cshtml | 31 ++- .../AMES/MaterialFlowController.cs | 183 ++++++++++++++++++ .../Models/BAS/MaterialFlow.cs | 8 + 7 files changed, 302 insertions(+), 14 deletions(-) create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/MaterialFlowController.cs diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 57d19f3c..0631f2f9 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -1050,6 +1050,48 @@ namespace AMESCoreStudio.Web.Controllers } return Json(new Table() { count = 0, data = null }); } + + /// + /// 料號流程 + /// + /// + /// + [HttpPost] + public async Task GetMaterialFlowRuleJson(string itemno, string unit_no) + { + var result = await _pcsApi.GetMaterialFlowsByQuery(itemno, unit_no); + + var item = new List(); + //item.Add(new SelectListItem("全部", "0")); + for (int i = 0; i < result.Count; i++) + { + item.Add(new SelectListItem(result[i].FlowRule.FlowRuleName, result[i].FlowRuleID.ToString())); + } + + ViewBag.MaterialFlowRule = item; + //将数据Json化并传到前台视图 + return Json(new { data = item }); + } + + /// + /// 回傳料號流程_備註 + /// + /// + /// + [HttpPost] + public async Task getMaterialFlowRuleRemark(string itemno, string unit_no, int flowID) + { + var q = await _pcsApi.GetMaterialFlowsByQuery(itemno, unit_no); + + var result = q.Where(w => w.FlowRuleID == flowID).FirstOrDefault(); + + //将数据Json化并传到前台视图 + if (result == null) + return Json(new { data = "" }); + else + + return Json(new { data = result.MaterialFlowRemark }); + } #endregion [ResponseCache(Duration = 0)] @@ -1504,6 +1546,14 @@ namespace AMESCoreStudio.Web.Controllers model.WipSops = await _pcsApi.GetWipSopByWipNo(model.wipInfo.WipNO); model.wipInfoBlobs = await _pcsApi.GetWipInfoBlob(model.wipInfo.WipNO); + + // 抓料號流程備註 + var q2 = await _pcsApi.GetMaterialFlowsByQuery(model.wipAtt.ItemNO, model.wipInfo.UnitNO); + + if (q2.Where(w => w.FlowRuleID == model.wipInfo.FlowRuleID).FirstOrDefault() != null) + { + model.MaterialFlowRemark = q2.Where(w => w.FlowRuleID == model.wipInfo.FlowRuleID).FirstOrDefault().MaterialFlowRemark; + } } await GetItemsList(); await GetProductType(); @@ -1512,7 +1562,7 @@ namespace AMESCoreStudio.Web.Controllers await GetLineInfo(); await GetMFGType(); await GetProcessTypes(); - await GetFlowRuleList(); + await GetMaterialFlowRuleJson(model.wipAtt.ItemNO, model.wipInfo.UnitNO); GetWipSEQType(); GetBurnType(); GetPartsBakeType(); @@ -1591,6 +1641,14 @@ namespace AMESCoreStudio.Web.Controllers model.WipSops = await _pcsApi.GetWipSopByWipNo(model.wipInfo.WipNO); model.wipInfoBlobs = await _pcsApi.GetWipInfoBlob(model.wipInfo.WipNO); + + // 抓料號流程備註 + var q1 = await _pcsApi.GetMaterialFlowsByQuery(model.wipAtt.ItemNO, model.wipInfo.UnitNO); + + if (q1.Where(w => w.FlowRuleID == model.wipInfo.FlowRuleID).FirstOrDefault() != null) + { + model.MaterialFlowRemark = q1.Where(w => w.FlowRuleID == model.wipInfo.FlowRuleID).FirstOrDefault().MaterialFlowRemark; + } } await GetItemsList(); await GetProductType(); @@ -1599,7 +1657,7 @@ namespace AMESCoreStudio.Web.Controllers await GetLineInfo(); await GetMFGType(); await GetProcessTypes(); - await GetFlowRuleList(); + await GetMaterialFlowRuleJson(model.wipAtt.ItemNO, model.wipInfo.UnitNO); GetWipSEQType(); GetBurnType(); GetPartsBakeType(); diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 4a533836..d3c5eb96 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -622,7 +622,7 @@ namespace AMESCoreStudio.Web ITask> PutMaterialSop([FromBody, RawJsonContent] string model); /// - /// SOP文件變更狀態 + /// SOP文件刪除 /// /// @@ -630,6 +630,23 @@ namespace AMESCoreStudio.Web ITask> DeleteMaterialSop(int id); #endregion + #region MaterialFlow 料號流程資料檔 + /// + /// 料號流程資料檔查詢 + /// + /// + [WebApiClient.Attributes.HttpGet("api/MaterialFlow/Query/{itemno}/{unitNo}")] + ITask> GetMaterialFlowsByQuery(string itemno , string unitno); + + /// + /// SOP文件變更狀態 + /// + /// + + //[WebApiClient.Attributes.HttpPut("api/MaterialSop")] + //ITask> PutMaterialSop([FromBody, RawJsonContent] string model); + #endregion + #region PCS024組件維護相關 /// diff --git a/AMESCoreStudio.Web/ViewModels/PCS/WipViewModel.cs b/AMESCoreStudio.Web/ViewModels/PCS/WipViewModel.cs index a72ba312..a1e8286e 100644 --- a/AMESCoreStudio.Web/ViewModels/PCS/WipViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/PCS/WipViewModel.cs @@ -22,7 +22,7 @@ namespace AMESCoreStudio.Web.ViewModels.PCS wipInfoBlobs = new List(); wipMAC = new WipMAC(); wipBarcodeOther = new WipBarcodeOther(); - + } /// @@ -85,13 +85,18 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// 工單圖檔資料 /// public WipInfoBlob wipInfoBlob { get; set; } + + /// + /// 流程作業備註 + /// + public string MaterialFlowRemark { get; set; } } public class WipDataViewModel : WipNoDetailViewModel { public WipDataViewModel() { - + } /// diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml index a1253de5..d584ece2 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml @@ -354,7 +354,7 @@
- +
@@ -365,7 +365,7 @@
- +
diff --git a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml index e9542f44..b031427e 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml @@ -383,22 +383,22 @@
- +
- +
-
- +
+
@@ -1107,7 +1107,6 @@ $("#GetMAC").hide(); } - getFlowRuleList($("#unitNo").val()); getLineInfoList($("#unitNo").val()); }); @@ -1178,9 +1177,9 @@ { $.ajax( { - url: "@Url.Action("GetFlowRuleJson", "BAS")", + url: "@Url.Action("GetMaterialFlowRuleJson", "PCS")", dataType: 'json', - data: { "unit_no": $("#unit").val()}, + data: { "itemno": $("#wipAtt_ItemNO").val(),"unit_no": $("#unit").val()}, type: 'post', success: function (result) { @@ -1246,12 +1245,30 @@ // RuleStation function RuleStation(NewID) { + $.ajax( + { + url: "@Url.Action("getMaterialFlowRuleRemark", "PCS")", + dataType: 'json', + data: { "itemno": $("#wipAtt_ItemNO").val(), "unit_no": $("#unit").val(), "flowID": NewID }, + type: 'post', + success: function (result) + { + $("#MaterialFlowRemark").val(result.data); + }, + error: function (result) + { + alert(result); + } + }); + if (NewID == null) { NewID = 0; } var OldID = $("#flowId").val(); + + $("#rulestionOld").empty(); var tableCols_rule = [[ { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialFlowController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialFlowController.cs new file mode 100644 index 00000000..90904cbd --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialFlowController.cs @@ -0,0 +1,183 @@ +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.BAS; +using AMESCoreStudio.CommonTools.Result; + +namespace AMESCoreStudio.WebApi.Controllers.AMES +{ + /// + /// 料號基本資料檔Controller + /// + [Route("api/[controller]")] + [ApiController] + public class MaterialFlowController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// 建構式 + /// + /// + public MaterialFlowController(AMESContext context) + { + _context = context; + } + + /// + /// 查詢料號流程資料檔 + /// + /// + // GET: api/ + [HttpGet] + public async Task>> GetMaterialFlows() + { + IQueryable q = _context.MaterialFlows; + q = q.OrderBy(p => p.MFID); + var MaterialFlows = await q.ToListAsync(); + return MaterialFlows; + } + + + /// + /// 料號流程資料檔 + /// + /// ItemID + /// + [HttpGet("{id}")] + public async Task> GetMaterialFlow(int id) + { + IQueryable q = _context.MaterialFlows; + var result = await q.Where(p => p.MFID == id).ToListAsync(); + return result; + } + + /// + /// 料號流程查詢 + /// + /// 料號 + /// 站別 + /// + [HttpGet("Query/{itemno}/{unitNo}")] + public async Task>> GetMaterialFlowsByQuery(string itemno, string unitNo) + { + IQueryable q = _context.MaterialFlows; + + MaterialItemController materialItemController = new MaterialItemController(_context); + var MaterialItem = materialItemController.GetMaterialItemByItemNO(itemno); + + if (MaterialItem != null) + q = q.Where(w => w.ItemID == MaterialItem.Result.ItemID && w.UnitNo == unitNo); + else + q = q.Where(w => w.ItemID == -1); + + var materialFlows = await q.ToListAsync(); + + return materialFlows; + } + + /// + /// 新增料號流程資料檔 + /// + /// + /// + [HttpPost] + public async Task> PostMaterialFlows([FromBody] MaterialFlow MaterialFlow) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + MaterialFlow.MFID = helper.GetIDKey("MF_ID").Result; + + _context.MaterialFlows.Add(MaterialFlow); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + + } + + + /// + /// 修改料號流程資料檔 + /// + /// + [HttpPut("{id}")] + public async Task> PutMaterialFlows(int id, [FromBody] MaterialFlow materialFlow) + { + ResultModel result = new ResultModel(); + if (id != materialFlow.MFID) + { + result.Success = false; + result.Msg = "料號錯誤"; + return result; + } + //_ + //_context.Attach(materialFlow); + //// 指定更新某個欄位 + //_context.Entry(materialFlow).Property(p => p.FlowSEQ).IsModified = true; + //_context.Entry(materialFlow).Property(p => p.ItemID).IsModified = true; + //_context.Entry(materialFlow).Property(p => p.FlowRuleID).IsModified = true; + //_context.Entry(materialFlow).Property(p => p.UnitNo).IsModified = true; + _context.Entry(materialFlow).State = EntityState.Modified; + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + return result; + } + catch (DbUpdateConcurrencyException ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + return result; + //throw; + + } + } + + /// + /// Delete料號流程 + /// + /// + /// + // DELETE: api/StandardWorkTimes/5 + [HttpDelete("{id}")] + public async Task> DeleteMaterialFlow(int id) + { + ResultModel result = new ResultModel(); + + var materialFlow = await _context.MaterialFlows.Where(m => m.MFID == id).FirstOrDefaultAsync(); + if (materialFlow == null) + { + result.Success = false; + result.Msg = "序號不存在"; + return result; + } + + _context.MaterialFlows.Remove(materialFlow); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + return result; + } + + private bool MaterialFlowExists(int id) + { + return _context.MaterialFlows.Any(e => e.MFID == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Models/BAS/MaterialFlow.cs b/AMESCoreStudio.WebApi/Models/BAS/MaterialFlow.cs index 8a5033f2..6652bf30 100644 --- a/AMESCoreStudio.WebApi/Models/BAS/MaterialFlow.cs +++ b/AMESCoreStudio.WebApi/Models/BAS/MaterialFlow.cs @@ -68,6 +68,14 @@ namespace AMESCoreStudio.WebApi.Models.BAS public string MaterialFlowStatus { get; set; } + /// + /// 料號作業流程 + /// + [Column("MATERIAL_FLOW_REMARK")] + [Display(Name = "料號作業流程")] + [DataMember] + public string MaterialFlowRemark { get; set; } + /// /// 創建者ID ///