diff --git a/AMESCoreStudio.Web/Controllers/BASController.cs b/AMESCoreStudio.Web/Controllers/BASController.cs index c2089bf0..ab7de55b 100644 --- a/AMESCoreStudio.Web/Controllers/BASController.cs +++ b/AMESCoreStudio.Web/Controllers/BASController.cs @@ -117,12 +117,23 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.TestTypeList = TestTypeItems; } + private async Task GetUnitList() + { + var result = await _basApi.GetFactoryUnits(); + + var UnitItems = new List(); + for (int i = 0; i < result.Count; i++) + { + UnitItems.Add(new SelectListItem(result[i].UnitName, result[i].UnitNo.ToString())); + } + ViewBag.UnitList = UnitItems; + } + private async Task GetFlowRuleList() { var result = await _basApi.GetFlowRules(); var FlowRuleItems = new List(); - FlowRuleItems.Add(new SelectListItem("全部", "0")); for (int i = 0; i < result.Count; i++) { FlowRuleItems.Add(new SelectListItem(result[i].UnitNo + result[i].FlowRuleName, result[i].FlowRuleID.ToString())); @@ -172,7 +183,6 @@ namespace AMESCoreStudio.Web.Controllers var result = await _basApi.GetFlowRulesByUnit(unit_no); var item = new List(); - item.Add(new SelectListItem("全部", "0")); for (int i = 0; i < result.Count; i++) { diff --git a/AMESCoreStudio.Web/Controllers/PPSController.cs b/AMESCoreStudio.Web/Controllers/PPSController.cs index 3d26a37c..4877507b 100644 --- a/AMESCoreStudio.Web/Controllers/PPSController.cs +++ b/AMESCoreStudio.Web/Controllers/PPSController.cs @@ -51,12 +51,11 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.SectionList = SectionList; } - private async Task GetErrorGroupListAll() + private async Task GetErrorGroupList() { var result = await _ppsApi.GetErrorGroups(); var ErrorGroupList = new List(); - ErrorGroupList.Add(new SelectListItem("全部", "*")); for (int i = 0; i < result.Count; i++) { @@ -65,56 +64,69 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.ErrorGroupList = ErrorGroupList; } - private async Task GetErrorGroupList() + private async Task GetErrorClassList(string no) { - var result = await _ppsApi.GetErrorGroups(); - - var ErrorGroupList = new List(); + var result = await _ppsApi.GetErrorClassesByGroup(no); + var ErrorClassList = new List(); for (int i = 0; i < result.Count; i++) { - ErrorGroupList.Add(new SelectListItem(result[i].GroupName, result[i].GroupNo.ToString())); + ErrorClassList.Add(new SelectListItem(result[i].ClassName, result[i].ClassNo.ToString())); } - ViewBag.ErrorGroupList = ErrorGroupList; + ViewBag.ErrorClassList = ErrorClassList; } - private async Task GetErrorClassListAll(string groupNo) + [HttpPost] + public async Task GetErrorClassJson(string group_no) { - var result = await _ppsApi.GetErrorClassesByGroup(groupNo); + var result = await _ppsApi.GetErrorClassesByGroup(group_no); - var ErrorClassList = new List(); - ErrorClassList.Add(new SelectListItem("全部", "*")); + var item = new List(); + item.Add(new SelectListItem("全部", "*")); for (int i = 0; i < result.Count; i++) { - ErrorClassList.Add(new SelectListItem(result[i].ClassName, result[i].ClassNo.ToString())); + item.Add(new SelectListItem(result[i].ClassName, result[i].ClassNo.ToString())); } - ViewBag.ErrorClassList = ErrorClassList; + //将数据Json化并传到前台视图 + return Json(new { data = item }); } - private async Task GetErrorClassList(string no) + private async Task GetNGGroupList() { - var result = await _ppsApi.GetErrorClassesByGroup(no); + var result = await _ppsApi.GetNGGroups(); - var ErrorClassList = new List(); + var NGGroupList = new List(); for (int i = 0; i < result.Count; i++) { - ErrorClassList.Add(new SelectListItem(result[i].ClassName, result[i].ClassNo.ToString())); + NGGroupList.Add(new SelectListItem(result[i].NGGroupName, result[i].NGGroupNo.ToString())); } - ViewBag.ErrorClassList = ErrorClassList; + ViewBag.NGGroupList = NGGroupList; + } + + private async Task GetNGClassList(string no) + { + var result = await _ppsApi.GetNGClassesByGroup(no); + + var NGClassList = new List(); + for (int i = 0; i < result.Count; i++) + { + NGClassList.Add(new SelectListItem(result[i].NGClassName, result[i].NGClassNo.ToString())); + } + ViewBag.NGClassList = NGClassList; } [HttpPost] - public async Task GetErrorClassJson(string group_no) + public async Task GetNGClassJson(string group_no) { - var result = await _ppsApi.GetErrorClassesByGroup(group_no); + var result = await _ppsApi.GetNGClassesByGroup(group_no); var item = new List(); item.Add(new SelectListItem("全部", "*")); for (int i = 0; i < result.Count; i++) { - item.Add(new SelectListItem(result[i].ClassName, result[i].ClassNo.ToString())); + item.Add(new SelectListItem(result[i].NGClassName, result[i].NGClassNo.ToString())); } //将数据Json化并传到前台视图 return Json(new { data = item }); @@ -444,7 +456,7 @@ namespace AMESCoreStudio.Web.Controllers public async Task PPS006() { - await GetErrorGroupListAll(); + await GetErrorGroupList(); return View(); } @@ -569,8 +581,8 @@ namespace AMESCoreStudio.Web.Controllers public async Task PPS007(string groupNo) { - await GetErrorGroupListAll(); - await GetErrorClassListAll(groupNo); + await GetErrorGroupList(); + await GetErrorClassList(groupNo); return View(); } @@ -684,7 +696,7 @@ namespace AMESCoreStudio.Web.Controllers [HttpGet] public async Task GetErrorReasonsByClassAsync(string errorClassNo) { - if (errorClassNo == null || errorClassNo == "0") + if (errorClassNo == null) { errorClassNo = "*"; } @@ -700,5 +712,374 @@ namespace AMESCoreStudio.Web.Controllers #endregion + #region PPS008不良現象群組維護相關 + + public IActionResult PPS008() + { + return View(); + } + + //新增頁面 + public IActionResult PPS008C() + { + return View(); + } + + //修改页面 + [HttpGet] + public async Task PPS008UAsync(string id) + { + var result = await _ppsApi.GetNGGroup(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task PPS008DAsync(string id) + { + var result = await _ppsApi.DeleteNGGroup(id); + return Json(new Result() { success = true, msg = "" }); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task PPS008CSaveAsync(NGGroup model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _ppsApi.PostNGGroup(JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "添加成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors.Count > 0) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("PPS008C", model); + } + + public async Task PPS008USaveAsync(NGGroup model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _ppsApi.PutNGGroup(model.NGGroupNo, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors.Count > 0) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("PPS008U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetNGGroupsAsync(int page = 1, int limit = 10) + { + var result_total = await _ppsApi.GetNGGroups(page, limit); + var result = await _ppsApi.GetNGGroups(page, limit); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result_total.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + #endregion + + #region PPS009異常類別維護相關 + + public async Task PPS009() + { + await GetNGGroupList(); + + return View(); + } + + //新增頁面 + public async Task PPS009C(string id) + { + await GetNGGroupList(); + + var model = new NGClass(); + if (id != null) + { + if (id != "") + { + model.NGGroupNo = id; + } + } + + return View(model); + } + + //修改页面 + [HttpGet] + public async Task PPS009UAsync(string id) + { + await GetNGGroupList(); + var result = await _ppsApi.GetNGClass(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task PPS009DAsync(string id) + { + var result = await _ppsApi.DeleteNGClass(id); + return Json(new Result() { success = true, msg = "" }); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task PPS009CSaveAsync(NGClass model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _ppsApi.PostNGClass(JsonConvert.SerializeObject(model)); + + + if (result.Success) + { + var _msg = "添加成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors.Count > 0) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("PPS009C", model); + } + + public async Task PPS009USaveAsync(NGClass model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _ppsApi.PutNGClass(model.NGClassNo, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors.Count > 0) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("PPS009U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetNGClassesByGroupAsync(string ngGroupNo, int page = 1, int limit = 10) + { + if (ngGroupNo == null) + { + ngGroupNo = "*"; + } + + var result = await _ppsApi.GetNGClassesByGroup(ngGroupNo, page, limit); + var result_total = await _ppsApi.GetNGClassesByGroup(ngGroupNo, 0, limit); + + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result_total.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + #endregion + + #region PPS007異常原因維護相關 + + public async Task PPS010(string groupNo) + { + await GetNGGroupList(); + await GetNGClassList(groupNo); + + return View(); + } + + //新增頁面 + public async Task PPS010C(string id) + { + string[] param = id.Split(','); + + await GetNGClassList(param[1]); + await GetResponseDeptList(); + + var model = new NGReason(); + if (id != null) + { + if (id != "") + { + model.NGClassNo = id; + } + } + + return View(model); + } + + //修改页面 + [HttpGet] + public async Task PPS010UAsync(string id) + { + string[] param = id.Split(','); + await GetNGClassList(param[1]); + await GetResponseDeptList(); + + var result = await _ppsApi.GetNGReason(param[0]); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task PPS010DAsync(string id) + { + var result = await _ppsApi.DeleteNGReason(id); + return Json(new Result() { success = true, msg = "" }); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task PPS010CSaveAsync(NGReason model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _ppsApi.PostNGReason(JsonConvert.SerializeObject(model)); + + + if (result.Success) + { + var _msg = "添加成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors.Count > 0) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("PPS010C", model); + } + + public async Task PPS010USaveAsync(NGReason model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _ppsApi.PutNGReason(model.NGReasonNo, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors.Count > 0) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("PPS010U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetNGReasonsByClassAsync(string ngClassNo, int page = 1, int limit = 10) + { + if (ngClassNo == null || ngClassNo == "0") + { + ngClassNo = "*"; + } + + var result_total = await _ppsApi.GetNGReasonsByClass(ngClassNo, 0, limit); + var result = await _ppsApi.GetNGReasonsByClass(ngClassNo, page,limit); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result_total.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + #endregion + } } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs index 83b99d9f..a86ca435 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs @@ -220,5 +220,136 @@ namespace AMESCoreStudio.Web ITask> GetErrorReasonsByClass(string no); #endregion + + #region PPS008 不良現象群組維護 + + /// + /// 新增不良現象群組 + /// + /// + [WebApiClient.Attributes.HttpPost("api/NGGroups")] + ITask> PostNGGroup([FromBody, RawJsonContent] string model); + + /// + /// 更新不良現象群組 + /// + /// + [WebApiClient.Attributes.HttpPut("api/NGGroups/{id}")] + ITask> PutNGGroup(string id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除不良現象群組 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/NGGroups/{id}")] + ITask> DeleteNGGroup(string id); + + /// + /// 根據ID獲取指定不良現象群組資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGGroups/{id}")] + ITask> GetNGGroup(string id); + + /// + /// 獲取不良現象群組資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGGroups")] + ITask> GetNGGroups(int page = 1, int limit = 10); + + #endregion + + #region PPS009 不良現象類別維護 + + /// + /// 新增不良現象類別 + /// + /// + [WebApiClient.Attributes.HttpPost("api/NGClasses")] + ITask> PostNGClass([FromBody, RawJsonContent] string model); + + /// + /// 更新不良現象類別 + /// + /// + [WebApiClient.Attributes.HttpPut("api/NGClasses/{id}")] + ITask> PutNGClass(string id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除不良現象類別 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/NGClasses/{id}")] + ITask> DeleteNGClass(string id); + + /// + /// 根據ID獲取指定不良現象類別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGClasses/{id}")] + ITask> GetNGClass(string id); + + /// + /// 獲取不良現象類別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGClasses")] + ITask> GetNGClasses(); + + /// + /// 根据群組代碼獲取不良現象類別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGClasses/Group/{no}")] + ITask> GetNGClassesByGroup(string no, int page = 1, int limit = 10); + + #endregion + + #region PPS010 不良現象原因維護 + + /// + /// 新增不良現象原因 + /// + /// + [WebApiClient.Attributes.HttpPost("api/NGReasons")] + ITask> PostNGReason([FromBody, RawJsonContent] string model); + + /// + /// 更新不良現象原因 + /// + /// + [WebApiClient.Attributes.HttpPut("api/NGReasons/{id}")] + ITask> PutNGReason(string id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除不良現象原因 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/NGReasons/{id}")] + ITask> DeleteNGReason(string id); + + /// + /// 根據ID獲取指定不良現象原因資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGReasons/{id}")] + ITask> GetNGReason(string id); + + /// + /// 獲取不良現象原因資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGReasons")] + ITask> GetNGReasons(); + + /// + /// 根据類別代碼獲取不良現象原因資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGReasons/Class/{no}")] + ITask> GetNGReasonsByClass(string no, int page = 1, int limit = 10); + + #endregion } } diff --git a/AMESCoreStudio.Web/Views/BAS/BAS009.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS009.cshtml index e7eafb23..6bfb7ea3 100644 --- a/AMESCoreStudio.Web/Views/BAS/BAS009.cshtml +++ b/AMESCoreStudio.Web/Views/BAS/BAS009.cshtml @@ -35,10 +35,11 @@
- +
- +
+
+ + + +
+
+
+ + +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/PPS/PPS009C.cshtml b/AMESCoreStudio.Web/Views/PPS/PPS009C.cshtml new file mode 100644 index 00000000..e3ec0339 --- /dev/null +++ b/AMESCoreStudio.Web/Views/PPS/PPS009C.cshtml @@ -0,0 +1,58 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NGClass + + +@{ ViewData["Title"] = "PPS009C"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + + +
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/Views/PPS/PPS009U.cshtml b/AMESCoreStudio.Web/Views/PPS/PPS009U.cshtml new file mode 100644 index 00000000..2eac2ffe --- /dev/null +++ b/AMESCoreStudio.Web/Views/PPS/PPS009U.cshtml @@ -0,0 +1,58 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NGClass + + +@{ ViewData["Title"] = "PPS009U"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + + +
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/Views/PPS/PPS010.cshtml b/AMESCoreStudio.Web/Views/PPS/PPS010.cshtml new file mode 100644 index 00000000..c83835ff --- /dev/null +++ b/AMESCoreStudio.Web/Views/PPS/PPS010.cshtml @@ -0,0 +1,169 @@ +@{ + ViewData["Title"] = "不良現象原因維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+ +
+ +
+ + +
+ +
+ +
+
+ +
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/PPS/PPS010C.cshtml b/AMESCoreStudio.Web/Views/PPS/PPS010C.cshtml new file mode 100644 index 00000000..370a8e84 --- /dev/null +++ b/AMESCoreStudio.Web/Views/PPS/PPS010C.cshtml @@ -0,0 +1,68 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NGReason + + +@{ ViewData["Title"] = "PPS010C"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + + +
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/Views/PPS/PPS010U.cshtml b/AMESCoreStudio.Web/Views/PPS/PPS010U.cshtml new file mode 100644 index 00000000..aa4b12f9 --- /dev/null +++ b/AMESCoreStudio.Web/Views/PPS/PPS010U.cshtml @@ -0,0 +1,68 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NGReason + + +@{ ViewData["Title"] = "PPS007U"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + + +
+
+
+
+ +
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/ErrorClassesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/ErrorClassesController.cs index a0c8f30f..ebc36ecd 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/ErrorClassesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/ErrorClassesController.cs @@ -45,13 +45,13 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } /// - /// 根据製程單位代碼NO獲取該製程流程資料 + /// 根据異常群組代碼NO獲取該群組異常類別資料 /// /// /// // GET: api/ErrorClasses/Group/S [HttpGet("Group/{no}")] - public async Task>> GetErrorGroupByGroup(string no) + public async Task>> GetErrorClassByGroup(string no) { IQueryable q = _context.ErrorClasses; @@ -64,14 +64,14 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } q = q.OrderBy(p => p.GroupNo + p.ClassNo); - var errorGroup = await q.ToListAsync(); + var errorClass = await q.ToListAsync(); - if (errorGroup == null) + if (errorClass == null) { return NotFound(); } - return errorGroup; + return errorClass; } /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NGClassesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NGClassesController.cs new file mode 100644 index 00000000..c524233d --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NGClassesController.cs @@ -0,0 +1,225 @@ +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 NGClassesController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public NGClassesController(AMESContext context) + { + _context = context; + } + + /// + /// + /// + /// + // GET: api/NGClasses + [HttpGet] + public async Task>> GetNGClass() + { + IQueryable q = _context.NGClasses; + q = q.OrderBy(p => p.NGClassNo); + + var ngClass = await q.ToListAsync(); + + return ngClass; + } + + /// + /// 根据不良現象群組代碼NO獲取該群組不良現象類別資料 + /// + /// + /// + /// + /// + // GET: api/NGClasses/Group/S + [HttpGet("Group/{no}")] + public async Task>> GetNGClassByGroup(string no, int page = 1, int limit = 10) + { + IQueryable q = _context.NGClasses; + + if (no != null) + { + if (no != "*") + { + q = q.Where(p => p.NGGroupNo.Equals(no)); + } + } + + if (page > 0) + { + q = q.OrderBy(p => p.NGGroupNo + p.NGClassNo).Skip((page - 1) * limit).Take(limit); + } + else + { + q = q.OrderBy(p => p.NGGroupNo + p.NGClassNo); + } + + var ngClass = await q.ToListAsync(); + + if (ngClass == null) + { + return NotFound(); + } + + return ngClass; + } + + /// + /// + /// + /// + /// + // GET: api/NGClasses/5 + [HttpGet("{id}")] + public async Task>> GetNGClass(string id) + { + IQueryable q = _context.NGClasses; + q = q.Where(p => p.NGClassNo.Equals(id)); + + var ngClass = await q.ToListAsync(); + + if (ngClass == null) + { + return NotFound(); + } + + return ngClass; + } + + /// + /// + /// + /// + /// + /// + // PUT: api/NGClasses/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> PutNGClass(string id, [FromBody] NGClass nGClass) + { + ResultModel result = new ResultModel(); + + if (id != nGClass.NGClassNo) + { + result.Success = false; + result.Msg = "类别代碼錯誤"; + return result; + } + + _context.Entry(nGClass).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!NGClassExists(id)) + { + result.Success = false; + result.Msg = "类别代碼不存在"; + return result; + } + else + { + throw; + } + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// + /// + /// + /// + // POST: api/NGClasses + // 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> PostNGClass([FromBody] NGClass nGClass) + { + ResultModel result = new ResultModel(); + + _context.NGClasses.Add(nGClass); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException) + { + if (NGClassExists(nGClass.NGClassNo)) + { + result.Success = false; + result.Msg = "类别代碼重複"; + return result; + } + else + { + throw; + } + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// + /// + /// + /// + // DELETE: api/NGClasses/5 + [HttpDelete("{id}")] + public async Task> DeleteNGClass(string id) + { + ResultModel result = new ResultModel(); + + var nGClass = await _context.NGClasses.FindAsync(id); + if (nGClass == null) + { + result.Success = false; + result.Msg = "类别代碼不存在"; + return result; + } + + _context.NGClasses.Remove(nGClass); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + return result; + } + + private bool NGClassExists(string id) + { + return _context.NGClasses.Any(e => e.NGClassNo == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NGGroupsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NGGroupsController.cs new file mode 100644 index 00000000..61d7e3f0 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NGGroupsController.cs @@ -0,0 +1,195 @@ +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 NGGroupsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public NGGroupsController(AMESContext context) + { + _context = context; + } + + /// + /// + /// + /// + /// + /// + // GET: api/NGGroups + [HttpGet] + public async Task>> GetNGGroup(int page = 1, int limit = 10) + { + IQueryable q = _context.NGGroups; + if (page > 0) + { + q = q.OrderBy(p => p.NGGroupNo).Skip((page - 1) * limit).Take(limit); + } + else + { + q = q.OrderBy(p => p.NGGroupNo); + } + + var ngGroup = await q.ToListAsync(); + return ngGroup; + } + + /// + /// + /// + /// + /// + // GET: api/NGGroups/5 + [HttpGet("{id}")] + public async Task>> GetNGGroup(string id) + { + IQueryable q = _context.NGGroups; + q = q.Where(p => p.NGGroupNo.Equals(id)); + + var ngGroup = await q.ToListAsync(); + + if (ngGroup == null) + { + return NotFound(); + } + + return ngGroup; + } + + /// + /// + /// + /// + /// + /// + // PUT: api/NGGroups/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> PutNGGroup(string id, [FromBody] NGGroup nGGroup) + { + ResultModel result = new ResultModel(); + + if (id != nGGroup.NGGroupNo) + { + result.Success = false; + result.Msg = "群組代碼錯誤"; + return result; + } + + _context.Entry(nGGroup).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!NGGroupExists(id)) + { + result.Success = false; + result.Msg = "群組代碼不存在"; + return result; + } + else + { + throw; + } + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// + /// + /// + /// + // POST: api/NGGroups + // 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> PostNGGroup([FromBody] NGGroup nGGroup) + { + ResultModel result = new ResultModel(); + + _context.NGGroups.Add(nGGroup); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException) + { + if (NGGroupExists(nGGroup.NGGroupNo)) + { + result.Success = false; + result.Msg = "群組代碼重複"; + return result; + } + else + { + throw; + } + } + + result.Success = true; + result.Msg = "OK"; + + return result; + } + + /// + /// + /// + /// + /// + // DELETE: api/NGGroups/5 + [HttpDelete("{id}")] + public async Task> DeleteNGGroup(string id) + { + ResultModel result = new ResultModel(); + + var nGGroup = await _context.NGGroups.FindAsync(id); + if (nGGroup == null) + { + result.Success = false; + result.Msg = "群組代碼不存在"; + return result; + } + + _context.NGGroups.Remove(nGGroup); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + + return result; + } + + private bool NGGroupExists(string id) + { + return _context.NGGroups.Any(e => e.NGGroupNo == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NGReasonsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NGReasonsController.cs new file mode 100644 index 00000000..b5a532ab --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NGReasonsController.cs @@ -0,0 +1,225 @@ +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 NGReasonsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public NGReasonsController(AMESContext context) + { + _context = context; + } + + /// + /// + /// + /// + // GET: api/NGReasons + [HttpGet] + public async Task>> GetNGReason() + { + IQueryable q = _context.NGReasons; + q = q.OrderBy(p => p.NGClassNo + p.NGReasonNo); + + var ngReason = await q.ToListAsync(); + + return ngReason; + } + + /// + /// 根据不良現象類別代碼NO獲取該類別不良現象原因代碼資料 + /// + /// + /// + /// + /// + // GET: api/NGReasons/Class/S + [HttpGet("Class/{no}")] + public async Task>> GetNGReasonByClass(string no, int page = 1, int limit = 10) + { + IQueryable q = _context.NGReasons; + + if (no != null) + { + if (no != "*") + { + q = q.Where(p => p.NGClassNo.Equals(no)); + } + } + + if (page > 0) + { + q = q.OrderBy(p => p.NGClassNo + p.NGReasonNo).Skip((page - 1) * limit).Take(limit); + } + else + { + q = q.OrderBy(p => p.NGClassNo + p.NGReasonNo); + } + + var ngReason = await q.ToListAsync(); + + if (ngReason == null) + { + return NotFound(); + } + + return ngReason; + } + + /// + /// + /// + /// + /// + // 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/Controllers/BAS/FlowRulesController.cs b/AMESCoreStudio.WebApi/Controllers/BAS/FlowRulesController.cs index 5b9a6569..472a8485 100644 --- a/AMESCoreStudio.WebApi/Controllers/BAS/FlowRulesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BAS/FlowRulesController.cs @@ -62,7 +62,7 @@ namespace AMESCoreStudio.WebApi.Controllers.BAS if (no != null) { - if (no != "") + if (no != "*") { q = q.Where(p => p.UnitNo.Equals(no)); } diff --git a/AMESCoreStudio.WebApi/Controllers/BAS/RulesController.cs b/AMESCoreStudio.WebApi/Controllers/BAS/RulesController.cs index 1b8e532d..ac1e3746 100644 --- a/AMESCoreStudio.WebApi/Controllers/BAS/RulesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BAS/RulesController.cs @@ -65,15 +65,18 @@ namespace AMESCoreStudio.WebApi.Controllers.BAS var query = from q1 in _context.Ruleses join q2 in _context.RuleStations on q1.RuleStationID equals q2.RuleStationID join q3 in _context.Stationses on q1.NextStationID equals q3.StationID - where q2.FlowRuleID.Equals(id) select new { + q2.FlowRuleID, q1.RuleStationID, q1.RuleSeq, q1.RuleStatus, CurrStationId = q2.StationID, NextStationId = q3.StationID }; - //query = query.OrderBy(p => p.RuleStationID + p.RuleSeq); + if (id > 0) + { + query = query.Where(p => p.FlowRuleID.Equals(id)); + } query = query.OrderBy(p => p.RuleSeq); var qdata = await query.ToListAsync(); diff --git a/AMESCoreStudio.WebApi/Models/AMES/NGClass.cs b/AMESCoreStudio.WebApi/Models/AMES/NGClass.cs new file mode 100644 index 00000000..01661803 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/NGClass.cs @@ -0,0 +1,48 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 不良現象类别资料表 + /// + [Table("NG_CLASS", Schema = "JHAMES")] + [DataContract] + public class NGClass + { + /// + /// 不良現象類別代碼 + /// + [Key] + [Column("NG_CLASS_NO")] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良類別代碼")] + [StringLength(6, ErrorMessage = "{0},不能大于{1}")] + [DataMember] + public string NGClassNo { get; set; } + + + /// + /// 不良現象群組代碼 + /// + [Column("NG_GROUP_NO")] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良群組代碼")] + [StringLength(6, ErrorMessage = "{0},不能大于{1}")] + [DataMember] + public string NGGroupNo { get; set; } + + + /// + /// 不良現象類別名稱 + /// + [Column("NG_CLASS_NAME")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良類別名稱")] + [StringLength(50, ErrorMessage = "{0},不能大于{1}")] + public string NGClassName { get; set; } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/NGGroup.cs b/AMESCoreStudio.WebApi/Models/AMES/NGGroup.cs new file mode 100644 index 00000000..078fef0d --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/NGGroup.cs @@ -0,0 +1,37 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 不良現象群组资料表 + /// + [Table("NG_GROUP", Schema = "JHAMES")] + [DataContract] + public class NGGroup + { + /// + /// 不良現象代碼 + /// + [Key] + [Column("NG_GROUP_NO")] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良群组代碼")] + [StringLength(10, ErrorMessage = "{0},不能大于{1}")] + [DataMember] + public string NGGroupNo { get; set; } + + + /// + /// 不良現象名稱 + /// + [Column("NG_GROUP_NAME")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良群组名稱")] + [StringLength(50, ErrorMessage = "{0},不能大于{1}")] + public string NGGroupName { get; set; } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/NGReason.cs b/AMESCoreStudio.WebApi/Models/AMES/NGReason.cs new file mode 100644 index 00000000..79697987 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/NGReason.cs @@ -0,0 +1,66 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 不良代码资料表 + /// + [Table("NG_REASON", Schema = "JHAMES")] + [DataContract] + public class NGReason + { + /// + /// 不良現象原因代碼 + /// + [Key] + [Column("NG_REASON_NO")] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良原因代碼")] + [StringLength(6, ErrorMessage = "{0},不能大于{1}")] + [DataMember] + public string NGReasonNo { get; set; } + + /// + /// 不良現象類別代碼 + /// + [Column("NG_CLASS_NO")] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良類別代碼")] + [StringLength(6, ErrorMessage = "{0},不能大于{1}")] + [DataMember] + public string NGClassNo { get; set; } + + /// + /// 不良現象原因描述 + /// + [Column("NG_REASON_DESC")] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良原因描述")] + [StringLength(100, ErrorMessage = "{0},不能大于{1}")] + [DataMember] + public string NGReasonDesc { get; set; } + + /// + /// 不良現象原因英文描述 + /// + [Column("NG_REASON_DESC_EN")] + [Required(ErrorMessage = "{0},不能空白")] + [Display(Name = "不良原因英文描述")] + [StringLength(100, ErrorMessage = "{0},不能大于{1}")] + [DataMember] + public string NGReasonDescEn { get; set; } + + /// + /// 責任單位 + /// + [Column("RESPONSE_DEPT")] + [DataMember] + [Required] + [Display(Name = "責任單位")] + public int ResponseDept { get; set; } + + } +}