From a0e647d3a0f537a76ac6ada5e78efc62d7a1409d Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 22 Dec 2021 01:15:51 +0800 Subject: [PATCH] 1. --- .../Controllers/PCSController.cs | 40 +++-- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 22 ++- AMESCoreStudio.Web/Views/PCS/PCS021.cshtml | 2 +- .../AMES/BarcodeInfoesController.cs | 2 +- .../AMES/BarcodeStationController.cs | 146 ++++++++++++++++++ ...InfoeController.cs => NgInfoController.cs} | 55 +++---- .../Models/AMES/BarcodeInfo.cs | 4 +- .../Models/AMES/BarcodeStation.cs | 99 ++++++++++-- AMESCoreStudio.WebApi/Models/AMESContext.cs | 7 + 9 files changed, 309 insertions(+), 68 deletions(-) create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs rename AMESCoreStudio.WebApi/Controllers/AMES/{NgInfoeController.cs => NgInfoController.cs} (69%) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index d80036d0..45fa807a 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -1659,6 +1659,9 @@ namespace AMESCoreStudio.Web.Controllers bool Success = true; string Data = string.Empty; + if (model.WipID == 0) + Msg += "請確認是否有輸入工單相關訊息\r\n"; + if (model.MaterialOutfits.Where(w => string.IsNullOrWhiteSpace(w.Inputs)).Any()) Msg += "請刷入治具編號\r\n"; @@ -1676,19 +1679,30 @@ namespace AMESCoreStudio.Web.Controllers if (!string.IsNullOrWhiteSpace(Msg)) Success = false; - // 新增or更新 BarCode_Info - BarcodeInfo barcodeInfo = new BarcodeInfo - { - BarcodeNo = model.Input, - StatusNo = "SMT", - RuleStationID = model.Station, - RuleStatus = "P", //F 不良 - WipID = model.WipID, - StatusID = 1, - CreateUserID = 1 - }; - - + //// 新增or更新 BarCode_Info + //BarcodeInfo barcodeInfo = new BarcodeInfo + //{ + // BarcodeNo = model.Input, + // StatusNo = "SMT", + // RuleStationID = model.Station, + // RuleStatus = "P", //F 不良 + // WipID = model.WipID, + // StatusID = 1, + // CreateUserID = 1 + //}; + //await _pcsApi.PostBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); + + //// 新增or更新 BarCodeStation + //BarcodeStation barcodeStation = new BarcodeStation + //{ + // BarcodeID = 1, + // WipID = model.WipID, + // RuleStationID = model.Station, + // RuleStatus = "S", + // InputDate = DateTime.Now, + // LineId = (decimal)model.LineID + //}; + //await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation)); return Json(new Result() { success = Success, msg = Msg, data = Data }); } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 1c5d859e..84fa3eb8 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -189,14 +189,30 @@ namespace AMESCoreStudio.Web //ITask> GetBarcodeInfoesByNo(string id); [WebApiClient.Attributes.HttpPost("api/BarcodeInfoes")] - ITask> PostBarcodeInfoes([FromBody, RawJsonContent] string model); + ITask> PostBarcodeInfoes([FromBody, RawJsonContent] string model); [WebApiClient.Attributes.HttpPut("api/BarcodeInfoes")] - ITask> PutBarcodeInfoes([FromBody, RawJsonContent] string model); + ITask> PutBarcodeInfoes([FromBody, RawJsonContent] string model); #endregion - #region 條碼過站資料檔 + #region BarCodeStation 條碼過站資料檔 PCS021 + [WebApiClient.Attributes.HttpGet("api/BarcodeStation/GetBarcodeStationByKey")] + ITask GetBarcodeStationByKey(string id); + [WebApiClient.Attributes.HttpPost("api/BarcodeStation")] + ITask> PostBarcodeStation([FromBody, RawJsonContent] string model); + + [WebApiClient.Attributes.HttpPut("api/BarcodeStation")] + ITask> PutBarcodeStation([FromBody, RawJsonContent] string model); + + #endregion + + #region NgInfo 測試不良基本資料檔 PCS021 + [WebApiClient.Attributes.HttpPost("api/NgInfo")] + ITask> PostNgInfo([FromBody, RawJsonContent] string model); + + [WebApiClient.Attributes.HttpPut("api/NgInfo")] + ITask> PutNgInfo([FromBody, RawJsonContent] string model); #endregion #region BarcodeType 條碼類別資料檔 PCS001 diff --git a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml index 388930dc..c2f2c56e 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml @@ -97,7 +97,7 @@
- +
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs index 0eaf72ad..d391b790 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs @@ -12,7 +12,7 @@ using AMESCoreStudio.CommonTools.Result; namespace AMESCoreStudio.WebApi.Controllers.AMES { /// - /// 工廠资料维护 + /// 條碼變更資料表 /// [Route("api/[controller]")] [ApiController] diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs new file mode 100644 index 00000000..65ae7e10 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs @@ -0,0 +1,146 @@ +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 BarcodeStationController : ControllerBase + { + private readonly AMESContext _context; + + public BarcodeStationController(AMESContext context) + { + _context = context; + } + + // GET: api/BarcodeStation + [HttpGet] + public async Task>> GetBarcodeStation() + { + return await _context.BarcodeStation.ToListAsync(); + } + + // GET: api/BarcodeStation/5 + [HttpGet("{id}")] + public async Task> GetBarcodeStation(decimal id) + { + var barcodeStation = await _context.BarcodeStation.FindAsync(id); + + if (barcodeStation == null) + { + return NotFound(); + } + + return barcodeStation; + } + + /// + /// + /// + /// 內務條碼ID + /// 工單ID + /// 流程站別ID + /// + /// + // GET: api/BarcodeStation/5 + [HttpGet("Key")] + public async Task> GetBarcodeStationByKey(decimal barcodeID, decimal wipID + , decimal ruleStationID, string ruleStatus) + { + var barcodeStation = await _context.BarcodeStation + .Where(w => w.BarcodeID == barcodeID + && w.WipID == wipID + && w.RuleStationID == ruleStationID + && w.RuleStatus == ruleStatus).FirstOrDefaultAsync(); + + + if (barcodeStation == null) + { + return NotFound(); + } + + return barcodeStation; + } + + // PUT: api/BarcodeStation/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] + public async Task> PutBarcodeStation([FromBody]BarcodeStation barcodeStation) + { + ResultModel result = new ResultModel(); + _context.Attach(barcodeStation); + + // 指定更新某個欄位 + _context.Entry(barcodeStation).Property(p => p.LineId).IsModified = true; + + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.Message; + } + return result; + } + + // POST: api/BarcodeStation + // 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> PostBarcodeStation([FromBody] BarcodeStation barcodeStation) + { + ResultModel result = new ResultModel(); + _context.BarcodeStation.Add(barcodeStation); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.Message; + } + return result; + } + + // DELETE: api/BarcodeStation/5 + [HttpDelete("{id}")] + public async Task> DeleteBarcodeStation(decimal id) + { + var barcodeStation = await _context.BarcodeStation.FindAsync(id); + if (barcodeStation == null) + { + return NotFound(); + } + + _context.BarcodeStation.Remove(barcodeStation); + await _context.SaveChangesAsync(); + + return barcodeStation; + } + + private bool BarcodeStationExists(decimal id) + { + return _context.BarcodeStation.Any(e => e.BarcodeID == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoeController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs similarity index 69% rename from AMESCoreStudio.WebApi/Controllers/AMES/NgInfoeController.cs rename to AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs index 74f1924b..d1f3799a 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoeController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.CommonTools.Result; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -15,11 +16,11 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// [Route("api/[controller]")] [ApiController] - public class NgInfoeController : ControllerBase + public class NgInfoController : ControllerBase { private readonly AMESContext _context; - public NgInfoeController(AMESContext context) + public NgInfoController(AMESContext context) { _context = context; } @@ -48,59 +49,49 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES // PUT: api/NgInfoe/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 PutNgInfo(decimal id, NgInfo ngInfo) + [HttpPut] + public async Task> PutNgInfo([FromBody] NgInfo ngInfo) { - if (id != ngInfo.NgID) - { - return BadRequest(); - } + ResultModel result = new ResultModel(); + _context.Attach(ngInfo); - _context.Entry(ngInfo).State = EntityState.Modified; + // 指定更新某個欄位 + _context.Entry(ngInfo).Property(p => p.CreateUserID).IsModified = true; try { await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - catch (DbUpdateConcurrencyException) + catch (Exception ex) { - if (!NgInfoExists(id)) - { - return NotFound(); - } - else - { - throw; - } + result.Success = false; + result.Msg = ex.Message; } - - return NoContent(); + return result; } // POST: api/NgInfoe // 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> PostNgInfo(NgInfo ngInfo) + public async Task> PostNgInfo([FromBody] NgInfo ngInfo) { + ResultModel result = new ResultModel(); _context.NgInfos.Add(ngInfo); try { await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - catch (DbUpdateException) + catch (Exception ex) { - if (NgInfoExists(ngInfo.NgID)) - { - return Conflict(); - } - else - { - throw; - } + result.Success = false; + result.Msg = ex.Message; } - - return CreatedAtAction("GetNgInfo", new { id = ngInfo.NgID }, ngInfo); + return result; } // DELETE: api/NgInfoe/5 diff --git a/AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs b/AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs index 2c12d14f..7a59cee0 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs @@ -85,14 +85,14 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// [Column("SYSTYPE")] [DataMember] - public string SysType { get; set; } + public string SysType { get; set; } = "S"; /// /// 條碼流程狀態 /// [Column("STATUS_ID")] [DataMember] - public int StatusID { get; set; } + public int StatusID { get; set; } = 1; /// /// 建立者 diff --git a/AMESCoreStudio.WebApi/Models/AMES/BarcodeStation.cs b/AMESCoreStudio.WebApi/Models/AMES/BarcodeStation.cs index e0cf98a4..8b58d5ce 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/BarcodeStation.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/BarcodeStation.cs @@ -11,38 +11,105 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 條碼過站資料檔 /// [Table("BARCODE_STATION")] - + [DataContract] public partial class BarcodeStation { - //[Key] + /// + /// 內部條碼ID + /// + [Key] [Column("BARCODE_ID", TypeName = "NUMBER")] - public decimal BarcodeId { get; set; } - //[Key] + [DataMember] + [Display(Name = "內部條碼ID")] + public decimal BarcodeID { get; set; } + + /// + /// 工單ID + /// + [Key] [Column("WIP_ID", TypeName = "NUMBER")] - public decimal WipId { get; set; } - //[Key] + [DataMember] + [Display(Name = "工單ID")] + public decimal WipID { get; set; } + + /// + /// 流程站別ID + /// + [Key] [Column("RULE_STATION_ID", TypeName = "NUMBER")] - public decimal RuleStationId { get; set; } - //[Key] + [DataMember] + [Display(Name = "流程站別ID")] + public decimal RuleStationID { get; set; } + + /// + /// 規則狀態值 + /// + [Key] [Column("RULE_STATUS")] [StringLength(1)] + [DataMember] + [Display(Name = "規則狀態值")] public string RuleStatus { get; set; } + + /// + /// 投入日期 + /// [Key] [Column("INPUT_DATE", TypeName = "DATE")] + [DataMember] + [Display(Name = "投入日期")] public DateTime InputDate { get; set; } + + /// + /// 系统狀態 + /// [Required] [Column("SYSTYPE")] [StringLength(1)] - public string Systype { get; set; } + [DataMember] + [Display(Name = "系统狀態")] + public string Systype { get; set; } = "S"; + + + /// + /// 線别ID + /// [Column("LINE_ID", TypeName = "NUMBER")] - public decimal LineId { get; set; } + [DataMember] + [Display(Name = "線别ID")] + public decimal LineId { get; set; } = -1; + + /// + /// 站别的次數 + /// [Column("STATION_FLAG", TypeName = "NUMBER")] - public decimal? StationFlag { get; set; } + [DataMember] + [Display(Name = "站别的次數")] + public decimal StationFlag { get; set; } = 1; + + /// + /// 過站次數(不限定工單) + /// [Column("STATION_TIMES", TypeName = "NUMBER")] - public decimal StationTimes { get; set; } - [Column("CREATE_USERID", TypeName = "NUMBER")] - public decimal CreateUserid { get; set; } - [Column("CREATE_DATE", TypeName = "DATE")] - public DateTime CreateDate { get; set; } + [DataMember] + [Display(Name = "過站次數")] + public decimal StationTimes { get; set; } = 1; + + /// + /// 建立者 + /// + [Column("CREATE_USERID")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "建立者")] + public int CreateUserID { get; set; } = 0; + + /// + /// 建立時間 + /// + [Column("CREATE_DATE")] + [DataMember] + [Display(Name = "建立時間")] + public DateTime CreateDate { get; set; } = DateTime.Now; } } diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 30d4ca92..87848372 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -42,6 +42,7 @@ namespace AMESCoreStudio.WebApi 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.BarcodeID ,c.WipID, c.RuleStationID ,c.RuleStatus ,c.InputDate }); modelBuilder.Entity().HasKey(c => new { c.WipNO, c.RuleStationID, c.KeyNo }); modelBuilder.Entity().HasKey(c => new { c.WipNO, c.StartNO, c.EndNO }); @@ -63,6 +64,7 @@ namespace AMESCoreStudio.WebApi modelBuilder.Entity().HasKey(c => new { c.Class, c.ClassGroup }); modelBuilder.Entity().HasOne(r => r.Module).WithMany().HasForeignKey(r => r.ModuleID).IsRequired(); + } /// @@ -480,6 +482,11 @@ namespace AMESCoreStudio.WebApi /// public virtual DbSet NgInfos { get; set; } + /// + /// 測試不良基本資料檔 + /// + public DbSet BarcodeStation { get; set; } + /// /// 條碼過站資料檔 ///