From a8958809b874d3a8a59de48aba247d85b3b68120 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 20 Dec 2021 18:38:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E9=81=8E=E7=AB=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 24 +-- AMESCoreStudio.Web/Views/PCS/PCS021.cshtml | 184 ++++++++++++++++-- AMESCoreStudio.WebApi/Code/BarcodeContext.cs | 29 +++ .../AMES/BarcodeInfoesController.cs | 1 + .../Controllers/AMES/BarcodeLockController.cs | 146 ++++++++++++++ .../Controllers/BarcodeWipController.cs | 127 ++++++++++++ .../Models/AMES/BarcodeWip.cs | 62 ++++++ AMESCoreStudio.WebApi/Models/AMESContext.cs | 12 ++ 8 files changed, 554 insertions(+), 31 deletions(-) create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs create mode 100644 AMESCoreStudio.WebApi/Controllers/BarcodeWipController.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index de42696f..f5062409 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -1572,14 +1572,13 @@ namespace AMESCoreStudio.Web.Controllers //model.WipNO = "WO0001A1"; var q = await _pcsApi.GetWipInfoByWipNO(model.WipNO); + q = q.Where(w => w.UnitNO == model.UnitNO).ToList(); if (q.Count() == 0) { - ModelState.AddModelError("error", "找不到工單號碼"); + ModelState.AddModelError("error", "找不到該生產單位的工單號碼"); } - q = q.Where(w => w.UnitNO == model.UnitNO).ToList(); - if (q.Count != 0) { model.PlanQTY = q.FirstOrDefault().PlanQTY; @@ -1593,6 +1592,12 @@ namespace AMESCoreStudio.Web.Controllers { model.MaterialKps = await _pcsApi.GetMaterialKpByItemID(model.MaterialItem.ItemID); model.MaterialStationsItems = await _pcsApi.GetMaterialStationsItemByItemID(model.MaterialItem.ItemID); + + if (model.MaterialStationsItems.Count() == 0) + { + ModelState.AddModelError("error", "找不到該站別作業工項"); + } + var q1 = await _pcsApi.GetMaterialOutfitByItemID(model.MaterialItem.ItemID); foreach (var item in q1) { @@ -1624,10 +1629,6 @@ namespace AMESCoreStudio.Web.Controllers if (model.MaterialOutfits.Where(w => string.IsNullOrWhiteSpace(w.Inputs)).Any()) ModelState.AddModelError("error", "請刷入治具編號"); - //model.Inputs = TempData["TmpData"] as List; - var aa = TempData["TmpData"]; - model.Inputs.Add(model.Input); - TempData["TmpData"] = model.Inputs; //var aa = TempData["TmpData"]; //await GetFactoryUnit(); @@ -1643,10 +1644,11 @@ namespace AMESCoreStudio.Web.Controllers // model.materialKpDto = await _pcsApi.GetMaterialKpQuery(model.wipAtt.ItemNO, model.WipInfo.UnitNO); //} - //if () - // return View("PCS021"); - //else - return Json("Hello"); + if (model.Input == "OK") + return Json("OK"); + else + + return Json(model.Input); } #endregion diff --git a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml index 77f0e370..71684391 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml @@ -31,22 +31,32 @@ border: none; } - - .element { float: left; } + + .layui-field-title { + margin: auto; + } + + .layui-elem-field { + border-style: groove; + } + + .layui-form-item { + margin-bottom: auto; + } -
-
+
+ @*
-
-
@ViewBag.Title
-
-
-
+
+
@ViewBag.Title
+
+
+
*@
@@ -117,11 +127,23 @@
- TmpData:@TempData["TmpData"]
+
+ 刷入資料 + + + + @* + + + + + *@ +
+
檢查項目 @@ -243,7 +265,7 @@ @index.StationType j++; @@ -292,7 +314,6 @@ type: 'post', success: function (result) { - console.info(result.data); $("#line").empty();//清空下拉框的值 $.each(result.data, function (index, item) { $("#line").append($("' + + '' + + '' + + ''; + $('#tblCustomers').append(contactdiv); + //rollPage('left'); + var txtName = $("#txtInput"); + //Get the reference of the Table's TBODY element. + /* var tBody = $("#tblCustomers > TBODY")[0];*/ + + //Add Row. + /* var row = tBody.insertRow(-1);*/ + + //Add Name cell. + //var input = $(""); + //input.attr("type", "text"); + //input.attr("value", "1111"); + //var cell = $(row.insertCell(-1)); + //cell.html(e); + //cell.append(input); + + //Add Button cell. + //cell = $(row.insertCell(-1)); + //var btnRemove = $(""); + //btnRemove.attr("type", "button"); + //btnRemove.attr("onclick", "Remove(this);"); + //btnRemove.val("Remove"); + //cell.append(btnRemove); + + //Clear the TextBoxes. + //txtName.val(e); + AutoWindowSize(); + }; + + // Table 刪除 + function Remove(button) { + //Determine the reference of the Row using the Button. + var row = $(button).closest("TR"); + var table = $("#tblCustomers")[0]; + table.deleteRow(row[0].rowIndex); + //var name = $("TD", row).eq(0).html(); + //if (confirm("Do you want to delete: " + name)) { + // //Get the reference of the Table. + // var table = $("#tblCustomers")[0]; + + // //Delete the Table row using it's Index. + // table.deleteRow(row[0].rowIndex); + //} + }; + + function GetAllEmpData() { + var data = []; + $('tr.data-contact-person').each(function () { + var firstName = $(this).find('.f-name01').val();//Bind to the first name with class f-name01 + data.push(firstName); + }); + return data; + } + + function AutoWindowSize() { + $(window).on('resize', function () { + //AdminInit(); + //var $content = $('#nav_xbs_tab .layui-tab-content'); + //$content.height($(this).height() - 125); + //$content.find('iframe').each(function () { + // $(this).height($content.height()); + //}); + }).resize(); + } + function AdminInit() { + + var hgfull = function () { + var layfull = $('[lay-height]'); + if (layfull.attr('lay-height')) { + var arr = layfull.attr('lay-height').split('-'); + if (arr.length === 2) { + var height = window.innerHeight - arr[1]; + layfull.css('height', height + 'px'); + layfull.css('overflow-y', 'auto'); + } + else if (arr[0] === 'full') { + layfull.css('height', window.innerHeight - 200 + 'px'); + layfull.css('overflow-y', 'auto'); + } + else if (arr[0] === 'auto') { + var next = layfull.next(); + if (next.length > 0) { + setTimeout(function () { + //console.log(next.height()); + if (next.height() === 99) { + hgfull(); + return false; + } + layfull.children('.layui-card').css('height', next.height() + 'px'); + layfull.children('.layui-card').css('overflow-y', 'auto'); + }, 5); + } + } + } + } + $(window).resize(function () { + hgfull(); + if (!document.fullscreenElement) { + $("body").find('.fa-compress').removeClass('fa-compress').addClass('fa-arrows-alt'); + } + }); + } } diff --git a/AMESCoreStudio.WebApi/Code/BarcodeContext.cs b/AMESCoreStudio.WebApi/Code/BarcodeContext.cs index f614d886..b396a59f 100644 --- a/AMESCoreStudio.WebApi/Code/BarcodeContext.cs +++ b/AMESCoreStudio.WebApi/Code/BarcodeContext.cs @@ -61,5 +61,34 @@ namespace AMESCoreStudio.WebApi return ""; } + + /// + /// 是否被鎖定 + /// + /// + /// + /// + public async Task CheckBarCodeStationAsync(string WipNo, string BarCode) + { + BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); + + // 序號與工單相同視為序號 + if (BarCode.IndexOf(WipNo) != -1) + { + // 判斷BarCodeInfo 是否有條碼序號資料 + var q = await barcodeInfoesController.GetBarcodeInfoesByNo(BarCode); + if (q.Value.Count() != 0) + { + // 判斷條碼序號是否有被鎖定 + BarcodeLockController barcodeLockController = new BarcodeLockController(_context); + var q1 = await barcodeLockController.GetBarcodeLockByBarCodeID(q.Value.FirstOrDefault().BarcodeID); + if (q1.Value.Where(w => w.LockStatus == 0).Any()) + { + return "條碼編號:" + BarCode + ",已被鎖定,無法過站"; + } + } + } + return ""; + } } } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs index 84747049..313fc2f8 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs @@ -65,6 +65,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return barcodeInfo; } + /// /// 用No获取该條碼资料 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs new file mode 100644 index 00000000..3347f3c1 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeLockController.cs @@ -0,0 +1,146 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using AMESCoreStudio.WebApi.Models.AMES; + +namespace AMESCoreStudio.WebApi.Controllers.AMES +{ + /// + /// 條碼鎖定資料表 + /// + [Route("api/[controller]")] + [ApiController] + public class BarcodeLockController : ControllerBase + { + private readonly AMESContext _context; + + public BarcodeLockController(AMESContext context) + { + _context = context; + } + + // GET: api/BarcodeLock + [HttpGet] + public async Task>> GetBarcodeLock() + { + return await _context.BarcodeLocks.ToListAsync(); + } + + // GET: api/BarcodeLock/5 + [HttpGet("{id}")] + public async Task> GetBarcodeLock(int id) + { + var barcodeLock = await _context.BarcodeLocks.FindAsync(id); + + if (barcodeLock == null) + { + return NotFound(); + } + + return barcodeLock; + } + + /// + /// 條碼鎖定資料表 by BarCodeID + /// + /// BarCodeID + /// + // GET: api/BarcodeLock/5 + [HttpGet("BarCodeID/{id}")] + public async Task>> GetBarcodeLockByBarCodeID(int id) + { + + IQueryable q = _context.BarcodeLocks; + q = q.Where(p => p.BarcodeID.Equals(id)); + var barcodelock = await q.ToListAsync(); + + if (barcodelock == null) + { + return NotFound(); + } + + return barcodelock; + } + + // PUT: api/BarcodeLock/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 PutBarcodeLock(decimal id, BarcodeLock barcodeLock) + { + if (id != barcodeLock.BarcodeLockID) + { + return BadRequest(); + } + + _context.Entry(barcodeLock).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!BarcodeLockExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/BarcodeLock + // 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> PostBarcodeLock(BarcodeLock barcodeLock) + { + _context.BarcodeLocks.Add(barcodeLock); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException) + { + if (BarcodeLockExists(barcodeLock.BarcodeLockID)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtAction("GetBarcodeLock", new { id = barcodeLock.BarcodeLockID }, barcodeLock); + } + + // DELETE: api/BarcodeLock/5 + [HttpDelete("{id}")] + public async Task> DeleteBarcodeLock(decimal id) + { + var barcodeLock = await _context.BarcodeLocks.FindAsync(id); + if (barcodeLock == null) + { + return NotFound(); + } + + _context.BarcodeLocks.Remove(barcodeLock); + await _context.SaveChangesAsync(); + + return barcodeLock; + } + + private bool BarcodeLockExists(decimal id) + { + return _context.BarcodeLocks.Any(e => e.BarcodeLockID == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/BarcodeWipController.cs b/AMESCoreStudio.WebApi/Controllers/BarcodeWipController.cs new file mode 100644 index 00000000..6a4a1bc2 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/BarcodeWipController.cs @@ -0,0 +1,127 @@ +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; + +namespace AMESCoreStudio.WebApi.Controllers +{ + /// + /// 檔案用途 條碼工單資料檔 + /// + [Route("api/[controller]")] + [ApiController] + public class BarcodeWipController : ControllerBase + { + private readonly AMESContext _context; + + public BarcodeWipController(AMESContext context) + { + _context = context; + } + + // GET: api/BarcodeWip + [HttpGet] + public async Task>> GetBarcodeWips() + { + return await _context.BarcodeWips.ToListAsync(); + } + + // GET: api/BarcodeWip/5 + [HttpGet("{id}/{wipid}")] + public async Task> GetBarcodeWipByTwoKey(decimal id, decimal wipid) + { + var barcodeWip = await _context.BarcodeWips.Where(w => w.BarcodeID == id && w.WipID == wipid).FirstOrDefaultAsync(); + + if (barcodeWip == null) + { + return NotFound(); + } + + return barcodeWip; + } + + // PUT: api/BarcodeWip/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 PutBarcodeWip(decimal id, BarcodeWip barcodeWip) + { + if (id != barcodeWip.WipID) + { + return BadRequest(); + } + + _context.Entry(barcodeWip).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!BarcodeWipExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/BarcodeWip + // 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> PostBarcodeWip(BarcodeWip barcodeWip) + { + _context.BarcodeWips.Add(barcodeWip); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException) + { + if (BarcodeWipExists(barcodeWip.WipID)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtAction("GetBarcodeWip", new { id = barcodeWip.WipID }, barcodeWip); + } + + // DELETE: api/BarcodeWip/5 + [HttpDelete("{id}")] + public async Task> DeleteBarcodeWip(decimal id) + { + var barcodeWip = await _context.BarcodeWips.FindAsync(id); + if (barcodeWip == null) + { + return NotFound(); + } + + _context.BarcodeWips.Remove(barcodeWip); + await _context.SaveChangesAsync(); + + return barcodeWip; + } + + private bool BarcodeWipExists(decimal id) + { + return _context.BarcodeWips.Any(e => e.WipID == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs b/AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs new file mode 100644 index 00000000..f0bb1dde --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs @@ -0,0 +1,62 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +#nullable disable + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 檔案用途 條碼工單資料檔 + /// + [Table("BARCODE_WIP", Schema = "JHAMES")] + public partial class BarcodeWip + { + /// + /// 內部條碼ID + /// + [Key] + [Column("BARCODE_ID", TypeName = "NUMBER")] + [DataMember] + [Display(Name = "內部條碼ID")] + public decimal BarcodeID { get; set; } + + /// + /// 工單ID + /// + [Key] + [Column("WIP_ID", TypeName = "NUMBER")] + [DataMember] + [Display(Name = "工單ID")] + public decimal WipID { get; set; } + + /// + /// 建立者 + /// + [Column("CREATE_USERID")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "建立者")] + public decimal CreateUserID { get; set; } = -1; + + /// + /// 建立時間 + /// + [Column("CREATE_DATE")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "建立時間")] + public DateTime CreateDate { get; set; } = DateTime.Now; + + /// + /// 修改時間 + /// + [Column("UPDATE_DATE")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "修改時間")] + public DateTime UpdateDate { get; set; } = DateTime.Now; + + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 639000f6..77ca9b11 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -41,6 +41,7 @@ namespace AMESCoreStudio.WebApi 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().HasKey(c => new { c.WipID, c.BarcodeID }); modelBuilder.Entity().HasKey(c => new { c.WipNO, c.RuleStationID, c.KeyNo }); modelBuilder.Entity().HasKey(c => new { c.WipNO, c.StartNO, c.EndNO }); @@ -396,6 +397,7 @@ namespace AMESCoreStudio.WebApi /// public DbSet BarcodeItems { get; set; } + /// ///工時群組資料 /// @@ -463,6 +465,16 @@ namespace AMESCoreStudio.WebApi /// public virtual DbSet MaterialOutfits { get; set; } + /// + /// 條碼鎖定資料表 + /// + public DbSet BarcodeLocks { get; set; } + + /// + /// 檔案用途 條碼工單資料檔 + /// + public virtual DbSet BarcodeWips { get; set; } + } }
- +
刪除