diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index a6d6a41b..9a0d21fc 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -464,11 +464,104 @@ namespace AMESCoreStudio.Web.Controllers #endregion #region FQC006 FQC狀態維護 + public IActionResult FQC006() + { + return View(); + } + + //新增頁面 + public IActionResult FQC006C() + { + return View(); + } + + //修改页面 + [HttpGet] + public async Task FQC006UAsync(string id) + { + var result = await _fqcApi.GetStatusType(id); + return View(result); + } + + public async Task FQC006DAsync(string id) + { + var result = await _fqcApi.DeleteStatusType(id); + return Json(new Result() { success = result.Success, msg = result.Msg }); + } + + // 添加 + [HttpPost] + public async Task FQC006CAsync(StatusType model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _fqcApi.PostStatusType(JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "新增成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + + return View("FQC006C", model); + } + // 修改 + [HttpPost] + public async Task FQC006UAsync(StatusType model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _fqcApi.PutStatusType(JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + + return View("FQC006U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task FQC006QueryAsync(int page = 1, int limit = 10) + { + var result = await _fqcApi.GetStatusTypeQuery(page, limit); + + if (result.Data.Count() != 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + + return Json(new Table() { count = 0, data = null }); + } #endregion #region FQC007 FQC抽驗作業 + public IActionResult FQC007() + { + return View(); + } + public IActionResult FQC007C() + { + return View(); + } #endregion #region FQC008 FQC查詢 diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index c9104900..011addb2 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -206,7 +206,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/QcCriterion/QcCriterionQuery")] - ITask> GetQcCriterionQuery(int quotID, int page, int limit); + ITask> GetQcCriterionQuery(int quotID, int page, int limit); /// /// 查詢抽驗標準維護 ID @@ -224,7 +224,43 @@ namespace AMESCoreStudio.Web #endregion #region FQC006 FQC狀態維護 + /// + /// 刪除過站狀態檔 + /// + /// + /// + [WebApiClient.Attributes.HttpPost("api/StatusType")] + ITask> PostStatusType([FromBody, RawJsonContent] string model); + + /// + /// 更新過站狀態檔 + /// + /// + [WebApiClient.Attributes.HttpPut("api/StatusType")] + ITask> PutStatusType([FromBody, RawJsonContent] string model); + + /// + /// 刪除過站狀態檔 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/StatusType/{id}")] + ITask> DeleteStatusType(string id); + + /// + /// 查詢過站狀態檔 + /// + /// 頁數 + /// + /// + [WebApiClient.Attributes.HttpGet("api/StatusType/StatusTypeQuery")] + ITask> GetStatusTypeQuery(int page = 1, int limit = 10); + /// + /// 查詢過站狀態檔 ID + /// + /// + [WebApiClient.Attributes.HttpGet("api/StatusType/{id}")] + ITask GetStatusType(string id); #endregion #region FQC007 FQC抽驗作業 diff --git a/AMESCoreStudio.Web/Views/FQC/FQC005.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC005.cshtml index d5f077e1..59f44749 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC005.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC005.cshtml @@ -50,13 +50,18 @@ table && table.reload(data); }); var tableCols = [[ + { + field: 'quotName', + title: '係數名稱', + sort: true + }, { field: 'critNo', title: '抽樣代碼', sort: true }, { - field: 'itemNameCN', + field: 'intervalNumber', title: '抽樣點數', sort: true }, @@ -89,7 +94,7 @@ //通过行tool编辑,lay-event="edit" function edit(obj) { if (obj.data.critID) { - hg.open('修改抽驗標準', '/FQC/FQC005U/' + obj.data.critID, 400, 400); + hg.open('修改抽驗標準', '/FQC/FQC005U/' + obj.data.critID, 500, 500); } } @@ -122,7 +127,7 @@ layuiicon: '', class: 'layui-btn-normal', handler: function () { - hg.open('新增抽驗標準', '/FQC/FQC005C', 400, 400); + hg.open('新增抽驗標準', '/FQC/FQC005C', 500, 500); } } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC005C.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC005C.cshtml index 3b848908..e3fd2b79 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC005C.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC005C.cshtml @@ -1,7 +1,7 @@ -@model AMESCoreStudio.WebApi.Models.AMES.QcItem +@model AMESCoreStudio.WebApi.Models.AMES.QcCriterion -@{ ViewData["Title"] = "FQC001C"; +@{ Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + +
+
+
+
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ + @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC006U.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC006U.cshtml new file mode 100644 index 00000000..1382e926 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC006U.cshtml @@ -0,0 +1,63 @@ +@model AMESCoreStudio.WebApi.Models.AMES.StatusType + + +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ + @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml new file mode 100644 index 00000000..df797529 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml @@ -0,0 +1,285 @@ +@{ + ViewData["Title"] = "FQC抽驗作業"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ 抽驗 +
+ +
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007C.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007C.cshtml new file mode 100644 index 00000000..827c821d --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC007C.cshtml @@ -0,0 +1,93 @@ +@model AMESCoreStudio.WebApi.Models.AMES.FqcResultDetail + + +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml index b9e91966..c094f2fc 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml @@ -106,12 +106,12 @@
- +
- +
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/QcCriterionController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/QcCriterionController.cs index 49b0e947..cd24744e 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/QcCriterionController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/QcCriterionController.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.WebApi.DTO.AMES; using AMESCoreStudio.CommonTools.Result; namespace AMESCoreStudio.WebApi.Controllers.AMES @@ -47,10 +48,10 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } [HttpGet("QcCriterionQuery")] - public async Task> GetQcCriterionQuery(int quotID = 0,int page = 1, int limit = 10) + public async Task> GetQcCriterionQuery(int quotID = 0,int page = 1, int limit = 10) { IQueryable q = _context.QcCriteria; - ResultModel result = new ResultModel(); + ResultModel result = new ResultModel(); if (quotID != 0) q = q.Where(w => w.QuotID == quotID); @@ -63,7 +64,21 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { q = q.Skip((page - 1) * limit).Take(limit); } - result.Data = await q.ToListAsync(); + + result.Data = await q.Select(s => new QcCriterionDto + { + CritID = s.CritID, + CritNo = s.CritNo, + AcQty = s.AcQty, + ReQty = s.ReQty, + QcQty = s.QcQty, + IntervalNumber = s.QcStart + " ~ " + s.QcEnd, + QuotName = s.GetQcQuot.QuotName, + CreateDate = s.CreateDate, + UpdateUserID = s.UpdateUserID, + UpdateDate = s.UpdateDate + }).ToListAsync(); + return result; } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/StatusTypeController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/StatusTypeController.cs new file mode 100644 index 00000000..a7af0a0e --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/StatusTypeController.cs @@ -0,0 +1,158 @@ +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 StatusTypeController : ControllerBase + { + private readonly AMESContext _context; + + public StatusTypeController(AMESContext context) + { + _context = context; + } + + // GET: api/StatusType + [HttpGet] + public async Task>> GetStatusTypes() + { + return await _context.StatusTypes.ToListAsync(); + } + + // GET: api/StatusType/5 + [HttpGet("{id}")] + public async Task> GetStatusType(string id) + { + var statusType = await _context.StatusTypes.FindAsync(id); + + if (statusType == null) + { + return NotFound(); + } + + return statusType; + } + + [HttpGet("StatusTypeQuery")] + public async Task> GetStatusTypeQuery(int page = 1, int limit = 10) + { + IQueryable q = _context.StatusTypes; + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + return result; + } + + /// + /// 更新過站狀態 + /// + /// + /// + [HttpPut] + public async Task> PutStatusType(StatusType statusType) + { + ResultModel result = new ResultModel(); + _context.Entry(statusType).State = EntityState.Modified; + statusType.UpdateDate = DateTime.Now; + statusType.UpdateUserID = 0; + + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = "更新失敗!,錯誤訊息:" + ex.InnerException.Message; + } + return result; + } + + /// + /// 新增過站狀態 + /// + /// + /// + [HttpPost] + public async Task> PostStatusType(StatusType statusType) + { + ResultModel result = new ResultModel(); + _context.StatusTypes.Add(statusType); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + //result.Msg = ex.Message; + result.Msg = "新增失敗!,錯誤訊息:" + ex.InnerException.Message; + } + return result; + } + + /// + /// 刪除過站狀態 + /// + /// STATUS_NO + /// + [HttpDelete("{id}")] + public async Task> DeleteStatusType(string id) + { + ResultModel result = new ResultModel(); + var statusType = await _context.StatusTypes.FindAsync(id); + + try + { + if (statusType == null) + { + result.Success = false; + result.Msg = "找不到要刪除資料"; + } + else + { + _context.StatusTypes.Remove(statusType); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "刪除成功!"; + } + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.Message; + } + return result; + } + + private bool StatusTypeExists(string id) + { + return _context.StatusTypes.Any(e => e.StatusNo == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/DTO/AMES/QcCriterionDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/QcCriterionDto.cs new file mode 100644 index 00000000..f23375db --- /dev/null +++ b/AMESCoreStudio.WebApi/DTO/AMES/QcCriterionDto.cs @@ -0,0 +1,61 @@ +using System; + + +namespace AMESCoreStudio.WebApi.DTO.AMES +{ + /// + /// 抽驗標準資料檔 DTO + /// + public partial class QcCriterionDto + { + /// + /// 抽驗標準ID + /// + public int CritID { get; set; } + + /// + /// 係數名稱 + /// + public string QuotName { get; set; } + + /// + /// 抽樣代碼 + /// + public string CritNo { get; set; } + + /// + /// 抽樣點數 + /// + public string IntervalNumber { get; set; } + + /// + /// 抽樣數量 + /// + public int QcQty { get; set; } + + /// + /// 允收數量 + /// + public int AcQty { get; set; } + + /// + /// 拒收數量 + /// + public int ReQty { get; set; } + + /// + /// 建立日期 + /// + public DateTime CreateDate { get; set; } = DateTime.Now; + + /// + /// 更新UserID + /// + public int UpdateUserID { get; set; } = 0; + + /// + /// 更新日期 + /// + public DateTime? UpdateDate { get; set; } = DateTime.Now; + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/QcCriterion.cs b/AMESCoreStudio.WebApi/Models/AMES/QcCriterion.cs index f0793029..b2961e9a 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/QcCriterion.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/QcCriterion.cs @@ -37,6 +37,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] [Display(Name = "起始數量")] [Required(ErrorMessage = "{0},不能空白")] + [RegularExpression("^[0-9]*$",ErrorMessage = "數字不能小於0")] [Column("QC_START")] public int QcStart { get; set; } @@ -46,6 +47,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] [Display(Name = "結束數量")] [Required(ErrorMessage = "{0},不能空白")] + [RegularExpression("^[0-9]*$", ErrorMessage = "數字不能小於0")] [Column("QC_END")] public int QcEnd { get; set; } @@ -57,7 +59,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Required(ErrorMessage = "{0},不能空白")] [Column("CRIT_NO")] [StringLength(3)] - public int CritNo { get; set; } + public string CritNo { get; set; } /// /// 抽樣數量 @@ -65,6 +67,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] [Display(Name = "抽樣數量")] [Required(ErrorMessage = "{0},不能空白")] + [RegularExpression("^[0-9]*$", ErrorMessage = "數字不能小於0")] [Column("QC_QTY")] public int QcQty { get; set; } @@ -74,6 +77,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] [Display(Name = "允收數量")] [Required(ErrorMessage = "{0},不能空白")] + [RegularExpression("^[0-9]*$", ErrorMessage = "數字不能小於0")] [Column("AC_QTY")] public int AcQty { get; set; } @@ -83,6 +87,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] [Display(Name = "拒收數量")] [Required(ErrorMessage = "{0},不能空白")] + [RegularExpression("^[0-9]*$", ErrorMessage = "數字不能小於0")] [Column("RE_QTY")] public int ReQty { get; set; } @@ -115,5 +120,11 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("UPDATE_DATE")] [DataMember] public DateTime? UpdateDate { get; set; } = DateTime.Now; + + /// + /// 抽驗係數資料 + /// + [ForeignKey("QuotID")] + public virtual QcQuot GetQcQuot { get; set; } } } diff --git a/AMESCoreStudio.WebApi/Models/AMES/QcQuot.cs b/AMESCoreStudio.WebApi/Models/AMES/QcQuot.cs index 848e88ea..86e82740 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/QcQuot.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/QcQuot.cs @@ -10,7 +10,7 @@ using System.Runtime.Serialization; namespace AMESCoreStudio.WebApi.Models.AMES { /// - /// 抽驗係数資料檔 + /// 抽驗係數資料檔 /// [Table("QC_QUOT", Schema = "JHAMES")] public partial class QcQuot diff --git a/AMESCoreStudio.WebApi/Models/AMES/StatusType.cs b/AMESCoreStudio.WebApi/Models/AMES/StatusType.cs new file mode 100644 index 00000000..86434ef5 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/StatusType.cs @@ -0,0 +1,70 @@ +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 +{ + /// + /// 過站狀態檔 + /// + [Table("STATUS_TYPE", Schema = "JHAMES")] + [Index(nameof(StatusName), Name = "STATUS_TYPE_AK2", IsUnique = true)] + public partial class StatusType + { + /// + /// 狀態代碼 + /// + [Key] + [Column("STATUS_NO")] + [StringLength(2)] + [DataMember] + [Display(Name = "狀態代碼")] + [Required(ErrorMessage = "{0},不能空白")] + public string StatusNo { get; set; } + + /// + /// 狀態名稱 + /// + [Display(Name = "狀態名稱")] + [Required(ErrorMessage = "{0},不能空白")] + [DataMember] + [Column("STATUS_NAME")] + [StringLength(20)] + public string StatusName { get; set; } + + /// + /// 建立UserID + /// + [Column("CREATE_USERID")] + [Required] + [DataMember] + public int CreateUserID { get; set; } = 0; + + /// + /// 建立日期 + /// + [Required] + [Column("CREATE_DATE")] + [DataMember] + public DateTime CreateDate { get; set; } = DateTime.Now; + + /// + /// 更新UserID + /// + [Column("UPDATE_USERID")] + [DataMember] + public int UpdateUserID { get; set; } = 0; + + /// + /// 更新日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + public DateTime? UpdateDate { get; set; } = DateTime.Now; + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index a934bfc8..404257de 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -609,6 +609,10 @@ namespace AMESCoreStudio.WebApi /// 維修解碼上傳圖檔資料表 /// public DbSet NgRepairBlobs { get; set; } + + /// 過站狀態檔 + ///
+ public virtual DbSet StatusTypes { get; set; } } }