diff --git a/AMESCoreStudio.Web/Controllers/REPController.cs b/AMESCoreStudio.Web/Controllers/REPController.cs index 34abf986..daa3d123 100644 --- a/AMESCoreStudio.Web/Controllers/REPController.cs +++ b/AMESCoreStudio.Web/Controllers/REPController.cs @@ -194,6 +194,25 @@ namespace AMESCoreStudio.Web.Controllers return Json(new { data = item }); } + [HttpPost] + public async Task GetMaterialNoJson(string wip_no,string location_no) + { + var wip_att = await _pcsApi.GetWipAtt(wip_no); + //E9695A4S001R + var result = await _ppsApi.GetPlmBom4REP001(wip_att.ItemNO, location_no); + //var result = await _ppsApi.GetPlmBom4REP001("E9695A4S001R", location_no); + + var item = new List(); + + for (int i = 0; i < result.Count; i++) + { + item.Add(new SelectListItem(result[i].MatnrNew, result[i].MatnrNew.ToString())); + } + + //将数据Json化并传到前台视图 + return Json(new { data = item }); + } + [HttpPost] public async Task GetMaterialDescJson(string part_no) { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs index ec262aa0..8fc72019 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs @@ -659,5 +659,12 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("/api/PlmMeterialInfoe/{id}")] ITask> GetPlmMeterialInfo(string id); + + /// + /// 根據PLM料號獲取指定資料 + /// + /// + [WebApiClient.Attributes.HttpGet("/api/PlmBoms/GetPlmBom4REP001")] + ITask> GetPlmBom4REP001(string itemNo,string locationNo); } } diff --git a/AMESCoreStudio.Web/Views/REP/REP001R.cshtml b/AMESCoreStudio.Web/Views/REP/REP001R.cshtml index 9ea1aa4f..3c758825 100644 --- a/AMESCoreStudio.Web/Views/REP/REP001R.cshtml +++ b/AMESCoreStudio.Web/Views/REP/REP001R.cshtml @@ -148,7 +148,7 @@
- +
@@ -262,7 +262,7 @@
- +
@@ -432,6 +432,28 @@ }); }; + function getMaterialNo(data) + { + $.ajax( + { + url: "@Url.Action("GetMaterialNoJson", "REP")", + dataType: 'json', + data: { "wip_no": $('#txtWipNo').val(),"location_no": data}, + type: 'post', + success: function (result) + { + console.info(result.data); + $.each(result.data, function (index, item) { + $("#txtPartNo").val(item.text); + }); + }, + error: function (result) + { + alert(result); + } + }); + }; + function getMaterialDesc(data) { $.ajax( @@ -495,6 +517,15 @@ }); + $('#txtLocationNo').on('keypress', function (event) { + + if (event.keyCode == 13) { + getMaterialNo($('#txtLocationNo').val()); + getMaterialDesc($('#txtPartNo').val()); + } + + }); + $('#txtPartNo').on('keypress', function (event) { if (event.keyCode == 13) { diff --git a/AMESCoreStudio.Web/Views/REP/REP002R.cshtml b/AMESCoreStudio.Web/Views/REP/REP002R.cshtml index 51fc1276..676b8c0c 100644 --- a/AMESCoreStudio.Web/Views/REP/REP002R.cshtml +++ b/AMESCoreStudio.Web/Views/REP/REP002R.cshtml @@ -146,7 +146,7 @@
- +
@@ -260,12 +260,13 @@
- +
- + +
@@ -386,6 +387,50 @@ } }); + function getMaterialNo(data) + { + $.ajax( + { + url: "@Url.Action("GetMaterialNoJson", "REP")", + dataType: 'json', + data: { "wip_no": $('#txtWipNo').val(),"location_no": data}, + type: 'post', + success: function (result) + { + console.info(result.data); + $.each(result.data, function (index, item) { + $("#txtPartNo").val(item.text); + }); + }, + error: function (result) + { + alert(result); + } + }); + }; + + function getMaterialDesc(data) + { + $.ajax( + { + url: "@Url.Action("GetMaterialDescJson", "REP")", + dataType: 'json', + data: { "part_no": data}, + type: 'post', + success: function (result) + { + console.info(result.data); + $.each(result.data, function (index, item) { + $("#txtPartNoDesc").val(item.text); + }); + }, + error: function (result) + { + alert(result); + } + }); + }; + function getRepairResponsible(data) { $.ajax( @@ -466,6 +511,14 @@ $("#form").submit(); }); + $('#txtPartNo').on('keypress', function (event) { + + if (event.keyCode == 13) { + getMaterialDesc($('#txtPartNo').val()); + } + + }); + $('#txtRepairTypeNo').on('keypress', function (event) { if (event.keyCode == 13) { @@ -475,6 +528,15 @@ }); + $('#txtLocationNo').on('keypress', function (event) { + + if (event.keyCode == 13) { + getMaterialNo($('#txtLocationNo').val()); + getMaterialDesc($('#txtPartNo').val()); + } + + }); + $('#txtNgNo').on('keypress', function (event) { if (event.keyCode == 13) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/PlmBomsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/PlmBomsController.cs new file mode 100644 index 00000000..bbc0abaa --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/PlmBomsController.cs @@ -0,0 +1,173 @@ +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.AMES +{ + /// + /// + /// + [Route("api/[controller]")] + [ApiController] + public class PlmBomsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public PlmBomsController(AMESContext context) + { + _context = context; + } + + /// + /// + /// + /// + // GET: api/PlmBoms + [HttpGet] + public async Task>> GetPlmBom() + { + return await _context.PlmBoms.ToListAsync(); + } + + /// + /// 根據零件位置查詢料號 + /// + /// 料號 + /// 零件位置 + /// + [HttpGet("GetPlmBom4REP001")] + public async Task>> GetPlmBom4REP001(string itemNo,string locationNo) + { + IQueryable q = _context.PlmBoms; + q = q.Where(p => p.MatnrP.Equals(itemNo) && (p.Ebort1.Contains(locationNo) || p.Ebort2.Contains(locationNo))); + + var plmBom = await q.ToListAsync(); + + return plmBom; + } + + /// + /// + /// + /// + /// + // GET: api/PlmBoms/5 + [HttpGet("{id}")] + public async Task> GetPlmBom(string id) + { + var plmBom = await _context.PlmBoms.FindAsync(id); + + if (plmBom == null) + { + return NotFound(); + } + + return plmBom; + } + + /// + /// + /// + /// + /// + /// + // PUT: api/PlmBoms/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 PutPlmBom(string id, PlmBom plmBom) + { + if (id != plmBom.BomID) + { + return BadRequest(); + } + + _context.Entry(plmBom).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!PlmBomExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + /// + /// + /// + /// + /// + // POST: api/PlmBoms + // 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> PostPlmBom(PlmBom plmBom) + { + _context.PlmBoms.Add(plmBom); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException) + { + if (PlmBomExists(plmBom.BomID)) + { + return Conflict(); + } + else + { + throw; + } + } + + return CreatedAtAction("GetPlmBom", new { id = plmBom.BomID }, plmBom); + } + + /// + /// + /// + /// + /// + // DELETE: api/PlmBoms/5 + [HttpDelete("{id}")] + public async Task> DeletePlmBom(string id) + { + var plmBom = await _context.PlmBoms.FindAsync(id); + if (plmBom == null) + { + return NotFound(); + } + + _context.PlmBoms.Remove(plmBom); + await _context.SaveChangesAsync(); + + return plmBom; + } + + private bool PlmBomExists(string id) + { + return _context.PlmBoms.Any(e => e.BomID == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/PlmMeterialInfoeController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/PlmMeterialInfoeController.cs index b6917737..f02e2615 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/PlmMeterialInfoeController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/PlmMeterialInfoeController.cs @@ -20,11 +20,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { private readonly AMESContext _context; + /// + /// + /// + /// public PlmMeterialInfoeController(AMESContext context) { _context = context; } + /// + /// + /// + /// // GET: api/PlmMeterialInfoe [HttpGet] public async Task>> GetPlmMeterialInfos() @@ -65,6 +73,12 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return plmMeterialInfo; } + /// + /// + /// + /// + /// + /// // PUT: api/PlmMeterialInfoe/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. @@ -97,6 +111,11 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return NoContent(); } + /// + /// + /// + /// + /// // POST: api/PlmMeterialInfoe // 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. @@ -123,6 +142,11 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return CreatedAtAction("GetPlmMeterialInfo", new { id = plmMeterialInfo.MeterialNo }, plmMeterialInfo); } + /// + /// + /// + /// + /// // DELETE: api/PlmMeterialInfoe/5 [HttpDelete("{id}")] public async Task> DeletePlmMeterialInfo(string id) diff --git a/AMESCoreStudio.WebApi/Models/AMES/PlmBom.cs b/AMESCoreStudio.WebApi/Models/AMES/PlmBom.cs new file mode 100644 index 00000000..66fe7af6 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/PlmBom.cs @@ -0,0 +1,138 @@ +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 +{ + /// + /// PLM BOM + /// + [Table("PLM_BOM", Schema = "JHAMES")] + public partial class PlmBom + { + /// + /// 建BOM日期 + /// + [Column("BOM_DATE")] + [StringLength(8)] + [Required] + [DataMember] + public string BomDate { get; set; } + + /// + /// 建BOM時間 + /// + [Required] + [DataMember] + [Column("BOM_TIME")] + [StringLength(6)] + public string BomTime { get; set; } + + /// + /// BOM_ID + /// + [Key] + [Required] + [DataMember] + [Column("BOM_ID")] + [StringLength(15)] + public string BomID { get; set; } + + /// + /// MATNR_P + /// + [Column("MATNR_P")] + [StringLength(18)] + [DataMember] + public string MatnrP { get; set; } + + /// + /// MATNR_OLD + /// + [Column("MATNR_OLD")] + [StringLength(18)] + [DataMember] + public string MatnrOld { get; set; } + + /// + /// MATNR_NEW + /// + [Required] + [Column("MATNR_NEW")] + [StringLength(18)] + [DataMember] + public string MatnrNew { get; set; } + + /// + /// QTY + /// + [Column("QTY")] + [StringLength(18)] + [DataMember] + public float Qty { get; set; } + + /// + /// 狀態 + /// + [Required] + [DataMember] + [Column("STATUS")] + [StringLength(3)] + public string Status { get; set; } + + /// + /// MATNR_GROUP + /// + [Column("MATNR_GROUP")] + [StringLength(3)] + [DataMember] + public string MatnrGroup { get; set; } + + /// + /// MAIN_SUBSTITUTE + /// + [Column("MAIN_SUBSTITUTE")] + [StringLength(3)] + [DataMember] + public string MainSubstitute { get; set; } + + /// + /// EBORT1 + /// + [DataMember] + [Column("EBORT1")] + [StringLength(4000)] + public string Ebort1 { get; set; } + + /// + /// EBORT2 + /// + [DataMember] + [Column("EBORT2")] + [StringLength(4000)] + public string Ebort2 { get; set; } + + /// + /// ECN_ID + /// + [DataMember] + [Column("ECN_ID")] + [StringLength(15)] + public string EcnID { get; set; } + + /// + /// 建立日期 + /// + [Required] + [Column("CREATEDATE")] + [DataMember] + public DateTime CreateDate { get; set; } = DateTime.Now; + + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 32cc0cb7..3a39f164 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -934,6 +934,11 @@ namespace AMESCoreStudio.WebApi /// 清線明細資料 /// public DbSet WipClearDetails { get; set; } + + /// + /// PlmBom資料 + /// + public DbSet PlmBoms { get; set; } } }