From 47fc99017de91d3a6ebfdf70feb350190148434a Mon Sep 17 00:00:00 2001 From: Shani Date: Mon, 21 Feb 2022 12:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9ESPC005R=E5=92=8C005V=E9=A0=81?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 27 ++- AMESCoreStudio.Web/Views/SPC/SPC005R.cshtml | 155 ++++++++++++++ AMESCoreStudio.Web/Views/SPC/SPC005V.cshtml | 198 +++++++++++++++++ .../AMES/InspectionResultBlobsController.cs | 199 ++++++++++++++++++ 4 files changed, 565 insertions(+), 14 deletions(-) create mode 100644 AMESCoreStudio.Web/Views/SPC/SPC005R.cshtml create mode 100644 AMESCoreStudio.Web/Views/SPC/SPC005V.cshtml create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultBlobsController.cs diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index cd7da25a..547a0f22 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -1,23 +1,22 @@ -using Microsoft.AspNetCore.Mvc; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; +using AMESCoreStudio.CommonTools.Result; using AMESCoreStudio.Web.Models; -using Newtonsoft.Json; -using AMESCoreStudio.WebApi; -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc.Rendering; -using AMESCoreStudio.WebApi.Models.AMES; -using AMESCoreStudio.WebApi.Models.BAS; using AMESCoreStudio.Web.ViewModels; using AMESCoreStudio.Web.ViewModels.PCS; using AMESCoreStudio.WebApi.DTO.AMES; -using System.Linq; -using AMESCoreStudio.CommonTools.Result; -using System; -using System.IO; -using Microsoft.AspNetCore.Http; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.WebApi.Models.BAS; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.IO; +using System.Linq; +using System.Threading.Tasks; namespace AMESCoreStudio.Web.Controllers { diff --git a/AMESCoreStudio.Web/Views/SPC/SPC005R.cshtml b/AMESCoreStudio.Web/Views/SPC/SPC005R.cshtml new file mode 100644 index 00000000..54d51dce --- /dev/null +++ b/AMESCoreStudio.Web/Views/SPC/SPC005R.cshtml @@ -0,0 +1,155 @@ +@model AMESCoreStudio.WebApi.Models.AMES.InspectionResultBlob + + + +@{ ViewData["Title"] = "SPC005R"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+ + +
+
+ + +
+
+
+
+ @Html.ValidationMessage("error") + @* *@ +
+
+
+ @* SOP文件 sheet *@ +
+ +
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/Views/SPC/SPC005V.cshtml b/AMESCoreStudio.Web/Views/SPC/SPC005V.cshtml new file mode 100644 index 00000000..0e7df42d --- /dev/null +++ b/AMESCoreStudio.Web/Views/SPC/SPC005V.cshtml @@ -0,0 +1,198 @@ +@model AMESCoreStudio.WebApi.Models.AMES.InspectionResultMaster + + +@{ ViewData["Title"] = "SPC005U"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; + //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/InspectionResultBlobsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultBlobsController.cs new file mode 100644 index 00000000..0e795d72 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultBlobsController.cs @@ -0,0 +1,199 @@ +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 InspectionResultBlobsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public InspectionResultBlobsController(AMESContext context) + { + _context = context; + } + + /// + /// 获取全部巡檢類別資料 + /// + /// + // GET: api/InspectionResultBlobs + [HttpGet] + public async Task>> GetInspectionResultBlobs() + { + IQueryable q = _context.InspectionResultBlobs; + q = q.OrderBy(p => p.InspectionID); + q = q.OrderBy(p => p.InspectionItemID); + + var InspectionResultBlobs = await q.ToListAsync(); + + return InspectionResultBlobs; + } + + /// + /// 用ID获取该巡檢類別資料 + /// + /// + /// + // GET: api/InspectionResultBlobs/5 + [HttpGet("{id}")] + public async Task>> GetInspectionResultBlobs(int id) + { + + IQueryable q = _context.InspectionResultBlobs; + q = q.Where(p => p.InspectionID.Equals(id)); + var InspectionResultBlob = await q.ToListAsync(); + + if (InspectionResultBlob == null) + { + return NotFound(); + } + + return InspectionResultBlob; + } + + /// + /// 获取该巡檢表單Blob By Query + /// + /// + /// + /// + // GET: api/InspectionResultBlobs/Query/5 + [HttpGet("Query/{id}/{itemID}")] + public async Task>> GetInspectionResultBlobsByQuery(int id, int itemID) + { + + IQueryable q = _context.InspectionResultBlobs; + q = q.Where(p => p.InspectionID.Equals(id)); + q = q.Where(p => p.InspectionItemID.Equals(itemID)); + var InspectionResultBlob = await q.ToListAsync(); + + if (InspectionResultBlob.Count == 0 ) + { + return InspectionResultBlob; + } + + return InspectionResultBlob; + } + + + + /// + /// 更新巡檢類別資料 + /// + /// + /// + /// + // PUT: api/InspectionResultBlobs/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> PutInspectionResultBlobs(int id, [FromBody] InspectionResultBlob InspectionResultBlob) + { + ResultModel result = new ResultModel(); + if (id != InspectionResultBlob.InspectionID) + { + result.Success = false; + result.Msg = "序號錯誤"; + return result; + } + + _context.Entry(InspectionResultBlob).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (Exception e) + { + result.Success = false; + result.Msg = e.Message; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// 新增巡檢類別資料 + /// + /// + /// + // POST: api/InspectionResultBlobs + // 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> PostInspectionResultBlobs(InspectionResultBlob InspectionResultBlob) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + _context.InspectionResultBlobs.Add(InspectionResultBlob); + try + { + await _context.SaveChangesAsync(); + } + catch (Exception e) + { + result.Success = false; + result.Msg = e.Message; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + + } + + /// + /// 删除巡檢類別資料 + /// + /// + /// + // DELETE: api/InspectionResultBlobs/5 + [HttpDelete("{id}")] + public async Task> DeleteInspectionResultBlobs(int id) + { + ResultModel result = new ResultModel(); + var inspectionType = await _context.InspectionResultBlobs.Where(m => m.InspectionID == id).FirstOrDefaultAsync(); + if (inspectionType == null) + { + result.Success = false; + result.Msg = "序號不存在"; + return result; + } + + _context.InspectionResultBlobs.Remove(inspectionType); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + return result; + } + + private bool InspectionResultBlobsExists(int id) + { + return _context.InspectionResultBlobs.Any(e => e.InspectionID == id); + } + + } +}