diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index eb16df6b..2f05b151 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -1569,15 +1569,17 @@ namespace AMESCoreStudio.Web.Controllers { model.SopPath = wipsop.GetWipSop.FilePath + wipsop.GetWipSop.NewName; } + + model.Input = "1234"; } return View("PCS021", model); } [HttpPost] - public async Task PCS021_Input(int inputtxt) + public IActionResult PCS021_Input(PCS021ViewModel model) { - await GetFactoryUnit(); - await GetLineInfo(); + //await GetFactoryUnit(); + //await GetLineInfo(); //model.WipInfo.WipNO = "WO0001A1"; //var q = await _pcsApi.GetWipInfoByWipNO(model.WipInfo.WipNO); //if (q.Count() != 0) @@ -1589,7 +1591,10 @@ namespace AMESCoreStudio.Web.Controllers // model.materialKpDto = await _pcsApi.GetMaterialKpQuery(model.wipAtt.ItemNO, model.WipInfo.UnitNO); //} - return View("PCS021"); + //if () + // return View("PCS021"); + //else + return Json("Hello"); } #endregion diff --git a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml index b24e73a4..db6f7d30 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml @@ -47,7 +47,7 @@ -
+
@@ -55,7 +55,7 @@
  • 過站資料
  • -
  • 模具資料
  • +
  • 治具資料
@@ -99,7 +99,7 @@
- +
@@ -115,76 +115,135 @@
- - + +
檢查項目 + + + + + + + + + + @foreach (var index in Model.MaterialStationsItems) + { + + + + + + } + +
+ 工項順序 + + 工項名稱 + + 工項描述 +
+ @index.StationsItemSeq + + @index.StationsItemNo + + @index.StationsItemDesc +
+
+
+ KeyParts
- - +
+ + + + + + + + + + + + @foreach (var index in Model.MaterialKps) + { - - - - - - - + + + + + + - - - @foreach (var index in Model.MaterialKps) - { - - - - - - - - - - } - -
+ KP料號名稱 + + KP料號NO + + 順序 + + 前置碼 + + 長度 + + 站(前段) +
- 料號 - - KP料號名稱 - - KP料號NO - - 順序 - - 前置碼 - - 長度 - - 站(前段) - + @index.KpName + + @index.KpNo + + @index.KpSeq + + @index.Title + + @index.Length + + @index.StationType +
- @index.ItemID - - @index.KpName - - @index.KpNo - - @index.KpSeq - - @index.Title - - @index.Length - - @index.StationType -
+ } + +
-
模具內容
+
+ + + + + + + + + + @foreach (var index in Model.MaterialOutfits) + { + + + + + + } + +
+ 治具NO + + 站(前段) + + 序號 +
+ @index.OutfitNo + + @index.StationType + +
+
@@ -264,14 +323,19 @@ function input(e) { if (e.keyCode == 13) { + var data = $("#PCS021Form").serialize(); + $.ajax({ url: "@Url.Action("PCS021_Input", "PCS")", type:"POST", - data: { "inputtxt": $("#inpputtxt").val() }, - success: function (data) { - $("#txtNamaPetugas").html(data); + //data: { "inputtxt": $("#inpputtxt").val() }, + data: data, + success: function (result) { + $("#txtNamaPetugas").html(result); } - }); + }); + event.preventDefault(); + return false; } }; diff --git a/AMESCoreStudio.WebApi/Code/BarcodeContext.cs b/AMESCoreStudio.WebApi/Code/BarcodeContext.cs new file mode 100644 index 00000000..f614d886 --- /dev/null +++ b/AMESCoreStudio.WebApi/Code/BarcodeContext.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.WebApi.Controllers.AMES; +using AMESCoreStudio.WebApi.Controllers.BAS; + +namespace AMESCoreStudio.WebApi +{ + /// + /// + /// + public class BarcodeContext + { + private readonly AMESContext _context; + + public BarcodeContext(AMESContext context) + { + _context = context; + } + + /// + /// 確認工單狀態 + /// + /// 工單號碼 + /// 生產單位 + /// 流程 + /// 站別 + /// 線別 + /// + public async Task CheckWipNoSationAsync(string WipNo, string UnitNo, int FlowRuleID, int Station, int Line) + { + WipInfosController wipInfosController = new WipInfosController(_context); + + var q = await wipInfosController.GetWipInfoByWipNo(WipNo); + if (q.Value.Count() == 0) + return "找不到工單號碼:" + WipNo; + + var WipNoItem = q.Value.Where(w => w.WipNO == WipNo && w.UnitNO == UnitNo).ToList(); + if (WipNoItem.Count == 0) + return "工單號碼:" + WipNo + ",尚未設定此生產單位"; + + if (!WipNoItem.Where(w => w.FlowRuleID == FlowRuleID).Any()) + return "工單號碼:" + WipNo + ",尚未設定此流程站"; + + if (WipNoItem.Where(w => w.StatusNO == "Y").Any()) + return "工單號碼:" + WipNo + ",該工單已經投入完工,請切換工單"; + + WipLockController wipLockController = new WipLockController(_context); + var q1 = await wipLockController.GetWipLockByWipNO(WipNo); + if (q1.Data.Where(w => w.LockStatus == "0" && w.StationID == Station).Any()) + return "工單號碼:" + WipNo + ",工單在當前站別被鎖定,不可過站"; + + int WipID = WipNoItem.FirstOrDefault().WipID; + LineInfoesController lineInfoesController = new LineInfoesController(_context); + var q2 = await lineInfoesController.GetLineInfoByWipID(WipID); + if (!q2.Value.Where(w => w.LineID == Line).Any()) + return "工單號碼:" + WipNo + ",工單尚未開線,不可過站"; + + + return ""; + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/BAS/LineInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/BAS/LineInfoesController.cs index 5de1c11a..1bc0f97d 100644 --- a/AMESCoreStudio.WebApi/Controllers/BAS/LineInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BAS/LineInfoesController.cs @@ -188,9 +188,11 @@ namespace AMESCoreStudio.WebApi.Controllers.BAS LineInfo lineinfo = new LineInfo(); lineinfo.LineID = id; lineinfo.WipNo = wipid; + lineinfo.UpdateDate = DateTime.Now; // 指定更新欄位 _context.Entry(lineinfo).Property(p => p.WipNo).IsModified = true; + _context.Entry(lineinfo).Property(p => p.UpdateDate).IsModified = true; try { await _context.SaveChangesAsync(); diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs new file mode 100644 index 00000000..0e54bc3c --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs @@ -0,0 +1,205 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using AMESCoreStudio.WebApi; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.CommonTools.Result; + +namespace AMESCoreStudio.WebApi.Controllers.AMES +{ + /// + /// 過站判斷 + /// + [Route("api/[controller]")] + [ApiController] + public class BarCodeCheckController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public BarCodeCheckController(AMESContext context) + { + _context = context; + } + + + /// + /// + /// + /// + // GET: api/NGReasons + [HttpGet] + public string GetBarCodeCheck(string wipno = null, string unitno = null, string stations = null, string inputbarcode = null) + { + + + IQueryable q = _context.NGReasons; + q = q.OrderBy(p => p.NGClassNo + p.NGReasonNo); + + + + return ""; + } + + /// + /// 判斷工單狀態 + /// + /// 工單號碼 + /// 生產單位 + /// 站別 + /// 線別 + /// 流程 + /// + [HttpGet("BarCodeDataCheck")] + public string GetBarCodeDataCheck(string wipno, string unitno, int station, int line, int flowrule) + { + BarcodeContext barcodeContext = new BarcodeContext(_context); + var result = barcodeContext.CheckWipNoSationAsync(WipNo: wipno, UnitNo: unitno, FlowRuleID: flowrule, Station: station, Line: line); + return result.Result; + } + + /// + /// + /// + /// + /// + // GET: api/NGReasons/5 + [HttpGet("{id}")] + public async Task>> GetNGReason(string id) + { + IQueryable q = _context.NGReasons; + q = q.Where(p => p.NGReasonNo.Equals(id)); + + var ngReason = await q.ToListAsync(); + + if (ngReason == null) + { + return NotFound(); + } + + return ngReason; + } + + /// + /// + /// + /// + /// + /// + // PUT: api/NGReasons/5 + // To protect from overposting attacks, enable the specific properties you want to bind to, for + // more details, see https://go.microsoft.com/fwlink/?linkid=2123754. + [HttpPut("{id}")] + public async Task> PutNGReason(string id, [FromBody] NGReason nGReason) + { + ResultModel result = new ResultModel(); + + if (id != nGReason.NGReasonNo) + { + result.Success = false; + result.Msg = "原因代碼錯誤"; + return result; + } + + _context.Entry(nGReason).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!NGReasonExists(id)) + { + result.Success = false; + result.Msg = "原因代碼不存在"; + return result; + } + else + { + throw; + } + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// + /// + /// + /// + // POST: api/NGReasons + // To protect from overposting attacks, enable the specific properties you want to bind to, for + // more details, see https://go.microsoft.com/fwlink/?linkid=2123754. + [HttpPost] + public async Task> PostNGReason([FromBody] NGReason nGReason) + { + ResultModel result = new ResultModel(); + + _context.NGReasons.Add(nGReason); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException) + { + if (NGReasonExists(nGReason.NGReasonNo)) + { + result.Success = false; + result.Msg = "原因代碼重複"; + return result; + } + else + { + throw; + } + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// + /// + /// + /// + // DELETE: api/NGReasons/5 + [HttpDelete("{id}")] + public async Task> DeleteNGReason(string id) + { + ResultModel result = new ResultModel(); + + var nGReason = await _context.NGReasons.FindAsync(id); + if (nGReason == null) + { + result.Success = false; + result.Msg = "原因代碼不存在"; + return result; + } + + _context.NGReasons.Remove(nGReason); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + return result; + } + + private bool NGReasonExists(string id) + { + return _context.NGReasons.Any(e => e.NGReasonNo == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipSop.cs b/AMESCoreStudio.WebApi/Models/AMES/WipSop.cs index a30a06c7..d553adfc 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WipSop.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WipSop.cs @@ -118,6 +118,6 @@ namespace AMESCoreStudio.WebApi.Models.AMES [ForeignKey("UnitNo")] public virtual AMESCoreStudio.WebApi.Models.BAS.FactoryUnit FactoryUnit { get; set; } - public virtual List WipSopLogs { get; set; } + //public virtual List WipSopLogs { get; set; } } } diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs b/AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs index c8d09e65..1b3cadab 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WipSopLog.cs @@ -20,7 +20,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// WIP_ID /// [Key] - [Column("WIP_ID", Order = 0)] + [Column("WIP_ID")] [DataMember] public int WipID { get; set; } @@ -28,7 +28,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// WIP_SOP_ID /// [Key] - [Column("WIP_SOP_ID", Order = 1)] + [Column("WIP_SOP_ID")] [DataMember] public int WipSopID { get; set; } @@ -73,12 +73,14 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 工單資料 /// [ForeignKey("WipID")] + [DataMember] public virtual WipInfo GetWipInfo { get; set; } /// /// SOP資料 /// [ForeignKey("WipSopID")] - public virtual WipSop GetWipSop { get; set; } + [DataMember] + public virtual WipSop GetWipSop { get; set; } } }