diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 02fc0ca7..b7ebb498 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -8436,6 +8436,7 @@ namespace AMESCoreStudio.Web.Controllers { IResultModel result; var _msg = string.Empty; + var _msgError = string.Empty; // 內部條碼 if (select == "0") { @@ -8453,9 +8454,27 @@ namespace AMESCoreStudio.Web.Controllers } BarcodeInfo barcodeInfo = q.FirstOrDefault(); + // 有箱號時判斷是有否在FQC抽驗,允收或未檢驗不能刪除 + if (!string.IsNullOrWhiteSpace(barcodeInfo.BoxNo)) + { + var CheckFqcOn = await _pcsApi.GetCheckFqcOnGoIng(barcodeInfo.BoxNo, barcodeInfo.WipID); + if (CheckFqcOn.Any()) + { + ModelState.AddModelError("error", $"無法解除綁定,內部序號【{model.BarCodeNo}】已綁定箱號【{barcodeInfo.BoxNo}】並且已開FQC"); + return View(model); + } + } + + if (barcodeInfo.StatusID == -1) + { + ModelState.AddModelError("error", $"無法解除綁定,內部序號【{model.BarCodeNo}】目前流程已結束"); + return View(model); + } + barcodeInfo.BoxNo = ""; barcodeInfo.ExtraBarcodeNo = ""; barcodeInfo.UpdateDate = DateTime.Now; + result = await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); if (result.Success) { @@ -8470,6 +8489,7 @@ namespace AMESCoreStudio.Web.Controllers // 條碼區間 if (select == "1") { + if (string.IsNullOrWhiteSpace(model.BarCodeNoStr) || string.IsNullOrWhiteSpace(model.BarCodeNoEnd)) { ModelState.AddModelError("error", "請確定都有輸入條碼區間"); @@ -8515,6 +8535,33 @@ namespace AMESCoreStudio.Web.Controllers var BarCode = model.BarCodeNoEnd.Substring(0, model.BarCodeNoEnd.Length - NoLength); + for (int i = NoStr; i <= NoEnd; i++) + { + var itemBarcodeNo = BarCode + i.ToString().PadLeft(NoLength, '0'); + var q_BarcodeInfo = await _pcsApi.GetBarcodeInfoesByNo(itemBarcodeNo); + + if (q_BarcodeInfo.Count != 0) + { + BarcodeInfo barcodeInfo = q_BarcodeInfo.FirstOrDefault(); + // 有箱號時判斷是有否在FQC抽驗,允收或未檢驗不能刪除 + if (!string.IsNullOrWhiteSpace(barcodeInfo.BoxNo)) + { + var CheckFqcOn = await _pcsApi.GetCheckFqcOnGoIng(barcodeInfo.BoxNo, barcodeInfo.WipID); + if (CheckFqcOn.Any()) + { + ModelState.AddModelError("error", $"無法解除綁定,內部序號【{barcodeInfo.BarcodeNo}】已綁定箱號【{barcodeInfo.BoxNo}】並且已開FQC"); + return View(model); + } + } + + if (barcodeInfo.StatusID == -1) + { + ModelState.AddModelError("error", $"無法解除綁定,內部序號【{barcodeInfo.BarcodeNo}】目前流程已結束"); + return View(model); + } + } + } + for (int i = NoStr; i <= NoEnd; i++) { var itemBarcodeNo = BarCode + i.ToString().PadLeft(NoLength, '0'); @@ -8526,18 +8573,9 @@ namespace AMESCoreStudio.Web.Controllers barcodeInfo.BoxNo = ""; barcodeInfo.ExtraBarcodeNo = ""; barcodeInfo.UpdateDate = DateTime.Now; - result = await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); - //if (result.Success) - //{ - // _msg += "解除綁定成功"; - //} - //else - //{ - // _msg += "解除綁定失敗"; - //} + await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); } } - _msg = "條碼區間【" + model.BarCodeNoStr + "】 ~ 【" + model.BarCodeNoEnd + "】解除綁定成功"; } @@ -9385,7 +9423,7 @@ namespace AMESCoreStudio.Web.Controllers if (result1.Where(w => w.ItemNo.StartsWith("OTHER")).Count() == 0) { var AllSerialRule = await _pcsApi.GetSerialRuleDetailbyPCS040(result1.Select(s => s.SerialRuleDetailID).FirstOrDefault()); - AllSerialRule = AllSerialRule.Where(w => w.YNum == model.YNum && w.MNum == model.MNum && w.WNum == model.WNum && w.LotNum == model.LotNum && w.MCode == model.MCode && w.DNum == model.DNum).ToList(); + AllSerialRule = AllSerialRule.Where(w => w.YNum == model.YNum && w.MNum == model.MNum && w.WNum == model.WNum && w.LotNum == model.LotNum && w.MCode == model.MCode && w.DNum == model.DNum).ToList(); foreach (var item in AllSerialRule) { model.SerialRuleDetailID = item.SerialRuleDetailID; diff --git a/AMESCoreStudio.Web/Controllers/REPController.cs b/AMESCoreStudio.Web/Controllers/REPController.cs index 0f700498..903cae4e 100644 --- a/AMESCoreStudio.Web/Controllers/REPController.cs +++ b/AMESCoreStudio.Web/Controllers/REPController.cs @@ -409,6 +409,64 @@ namespace AMESCoreStudio.Web.Controllers return Json(new Table() { count = 0, data = null }); } + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetNgKeyparts(int id) + { + var result = await _repApi.GetNgKeyparts(id); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + public IActionResult REP001KC(int id) + { + ViewBag.ComponentID = id; + + var model = new NgKeypart(); + if (id > 0) + { + model.ComponentID = id; + } + + return View(model); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task REP001KCSaveAsync(NgKeypart model) + { + IResultModel result; + + result = await _repApi.PostNgKeypart(JsonConvert.SerializeObject(model)); + + if (result.Success) + { + return RedirectToAction("Refresh", "Home", new { msg = "" }); + } + else + { + return Json(new Result() { success = false, msg = result.Msg }); + } + } + + public async Task REP001KDAsync(int id) + { + var result = await _repApi.DeleteNgKeypart(id); + if (result.Success) + { + return Json(new Result() { success = true, msg = "" }); + } + else + { + return Json(new Result() { success = false, msg = result.Msg }); + } + } + public IActionResult REP001B(string id) { ViewBag.ImageUrl = $"\\REPImage\\" + id; @@ -461,8 +519,152 @@ namespace AMESCoreStudio.Web.Controllers return Json(new { _msg = string.Format("維修描述保存成功!") }); } + public async Task SaveNgKeypart(int component_id, string old_part_no,string new_part_no) + { + IResultModel result; + var userID = ""; + HttpContext.Request.Cookies.TryGetValue("UserID", out userID); + int user_id = 0; + if (userID != null) + { + if (int.Parse(userID.ToString()) >= 0) + { + user_id = int.Parse(userID.ToString()); + } + } + + NgKeypart model = new NgKeypart(); + model.ComponentID = component_id; + model.OldPartNo = old_part_no; + model.NewPartNo = new_part_no; + model.UpdateUserID = user_id; + model.UpdateDate = System.DateTime.Now; + model.CreateUserID = user_id; + model.CreateDate = System.DateTime.Now; + + result = await _repApi.PostNgKeypart(JsonConvert.SerializeObject(model)); + + //return Json(new { _msg = string.Format("新增成功!") }); + return Json(new { _msg = result.Msg }); + } + + public async Task SaveNgKeypartNew(int component_id, string old_part_no, string new_part_no) + { + IResultModel result; + var userID = ""; + HttpContext.Request.Cookies.TryGetValue("UserID", out userID); + int user_id = 0; + if (userID != null) + { + if (int.Parse(userID.ToString()) >= 0) + { + user_id = int.Parse(userID.ToString()); + } + } + + NgKeypart ng_key_part = new NgKeypart(); + ng_key_part.ComponentID = component_id; + ng_key_part.OldPartNo = old_part_no; + ng_key_part.NewPartNo = new_part_no; + ng_key_part.UpdateUserID = user_id; + ng_key_part.UpdateDate = System.DateTime.Now; + ng_key_part.CreateUserID = user_id; + ng_key_part.CreateDate = System.DateTime.Now; + + result = await _repApi.PostNgKeypart(JsonConvert.SerializeObject(ng_key_part)); + + int id = component_id; + ViewBag.ComponentID = id; + + await GetRMAReasonList(); + await GetRepairTypeList(); + await GetNGReasonList(); + await GetRepairResponsibleUnitList(); + + HttpContext.Response.Cookies.Append("UserID4REP001", userID.ToString()); + + REP001NewViewModel model = new REP001NewViewModel(); + var result1 = await _repApi.GetNgComponent(id); + + var ng_reason = await _ppsApi.GetNGReason(result1[0].NgNo); + if (ng_reason.Count != 0) + { + model.ngReason = ng_reason[0]; + } + + if (result1[0].ErrorDesc == "" || result1[0].ErrorDesc == null) + { + result1[0].ErrorDesc = ng_reason[0].NGReasonDesc; + } + + if (result1.Count != 0) + { + model.ngComponent = result1[0]; + + var ng_keypart = await _repApi.GetNgKeyparts((int)result1[0].ComponentID); + if (ng_keypart.Count != 0) + { + model.NgKeyparts = ng_keypart; + } + + var result2 = await _repApi.GetNgInfo((int)result1[0].NgID); + if (result2.Count != 0) + { + model.ngInfo = result2[0]; + } + + var result3 = await _repApi.GetRepairRecord((int)result1[0].ComponentID); + if (result3.Count != 0) + { + model.repairRecord = result3[0]; + + var result31 = await _repApi.GetRepairRecordByNgID((int)result1[0].NgID); + string repair_desc = ""; + for (int r = 0; r < result31.Count; r++) + { + repair_desc = repair_desc + result31[r].RepairDesc + "\r\n"; + } + + model.repairRecord.RepairDesc = repair_desc; + } + + var result4 = await _repApi.GetNgRepairByComponent((int)result1[0].ComponentID); + if (result4.Count != 0) + { + model.ngRepair = result4[0]; + + + var result5 = await _repApi.GetNgRepairBlob(result4[0].RepairID); + if (result5.Count != 0) + { + model.ngRepairBlob = result5[0]; + } + else + { + ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; + ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; + ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; + } + } + else + { + NgRepair ngRepair = new NgRepair(); + model.ngRepair = ngRepair; + + ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; + ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; + ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; + } + } + + return View(model); + } + + public async Task REP001R(int id) { + ViewBag.ComponentID = id; + await GetRMAReasonList(); await GetRepairTypeList(); await GetNGReasonList(); @@ -471,7 +673,7 @@ namespace AMESCoreStudio.Web.Controllers var userID = HttpContext.Request.Cookies["UserID"]; HttpContext.Response.Cookies.Append("UserID4REP001", userID.ToString()); - REP001ViewModel model = new REP001ViewModel(); + REP001NewViewModel model = new REP001NewViewModel(); var result1 = await _repApi.GetNgComponent(id); var ng_reason = await _ppsApi.GetNGReason(result1[0].NgNo); @@ -489,6 +691,12 @@ namespace AMESCoreStudio.Web.Controllers { model.ngComponent = result1[0]; + var ng_keypart = await _repApi.GetNgKeyparts((int)result1[0].ComponentID); + if (ng_keypart.Count != 0) + { + model.NgKeyparts = ng_keypart; + } + var result2 = await _repApi.GetNgInfo((int)result1[0].NgID); if (result2.Count != 0) { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 2990ff5f..5a74411c 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -1406,6 +1406,15 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/FqcInhouseDetail/BySerialNo/{id}")] ITask> GetFqcInhouseDetailBySerialNo(string id); + + /// + /// 判斷箱號是否有在FQC允收或未檢驗 + /// + /// 箱號 + /// WIPID + /// + [WebApiClient.Attributes.HttpGet("api/FqcInhouseDetail/GetCheckFqcOnGoIng")] + ITask> GetCheckFqcOnGoIng(string boxNo , int wipId); #endregion #region 取出貨序號 diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs b/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs index 260519fc..11069f6a 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs @@ -354,5 +354,26 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetRepairData4REP013")] ITask> GetRepairData4REP013(string wipNo, string itemNo, string dateStart, string dateEnd, int page, int limit); + + /// + /// 根據ComponentID獲取維修不良組件資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgKeyparts/ComponentID/{id}")] + ITask> GetNgKeyparts(decimal id); + + /// + /// 新增維修組件 + /// + /// + [WebApiClient.Attributes.HttpPost("api/NgKeyparts")] + ITask> PostNgKeypart([FromBody, RawJsonContent] string model); + + /// + /// 刪除維修組件 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/NgKeyparts/{id}")] + ITask> DeleteNgKeypart(int id); } } diff --git a/AMESCoreStudio.Web/ViewModels/REP/REP001NewViewModel.cs b/AMESCoreStudio.Web/ViewModels/REP/REP001NewViewModel.cs new file mode 100644 index 00000000..3e1f7d9f --- /dev/null +++ b/AMESCoreStudio.Web/ViewModels/REP/REP001NewViewModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.WebApi.Models.BAS; +using AMESCoreStudio.WebApi.DTO.AMES; + +namespace AMESCoreStudio.Web.ViewModels +{ + public class REP001NewViewModel + { + public NgInfo ngInfo { get; set; } + + public NgComponent ngComponent { get; set; } + + public RepairRecord repairRecord { get; set; } + + public NgRepair ngRepair { get; set; } + + public NgRepairBlob ngRepairBlob { get; set; } + + public NGReason ngReason { get; set; } + + public NgKeypart NgKeypart { get; set; } + + public IEnumerable NgKeyparts { get; set; } + } +} diff --git a/AMESCoreStudio.Web/Views/REP/REP001KC.cshtml b/AMESCoreStudio.Web/Views/REP/REP001KC.cshtml new file mode 100644 index 00000000..3f059db4 --- /dev/null +++ b/AMESCoreStudio.Web/Views/REP/REP001KC.cshtml @@ -0,0 +1,53 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NgKeypart + + +@{ ViewData["Title"] = "REP001KC"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + +
+
+
+
+ + +
+ + + +
+ +
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/REP/REP001R.cshtml b/AMESCoreStudio.Web/Views/REP/REP001R.cshtml index d27edeba..15ecd3fc 100644 --- a/AMESCoreStudio.Web/Views/REP/REP001R.cshtml +++ b/AMESCoreStudio.Web/Views/REP/REP001R.cshtml @@ -1,4 +1,4 @@ -@model AMESCoreStudio.Web.ViewModels.REP001ViewModel +@model AMESCoreStudio.Web.ViewModels.REP001NewViewModel @{ ViewData["Title"] = "REP001R"; @@ -275,19 +275,76 @@
- + +
+
+ + @{ + int i = 0; + } + + + + + + + + + + + + @if (Model.NgKeyparts != null) + { + @foreach (var data in Model.NgKeyparts) + { + + + + + + + i++; + } + } + +
+ 不良組件編號 + + 舊組件序號 + + 新組件序號 + + +
+ + + + + + + + + + 刪除 +
+ +
+
+
- - + + @**@
- +
- - + + @**@
+   
+
@@ -570,6 +627,57 @@ }); + $('#btnKeypartInsertNew').click(function () { + var component_id = $('#txtComponentID').val(); + var old_part_no = $('#txtOldPartNo').val(); + var new_part_no = $('#txtNewPartNo').val(); + + $.ajax({ + url: '@Url.Action("SaveNgKeypart", "REP")', + dataType: 'json', + data: { "component_id": component_id, "old_part_no": old_part_no, "new_part_no": new_part_no }, + cache: false, + type: "POST", + success: function (data, textStatus, jqXHR) { + if (data._msg != undefined) { + parent.hg.msg("新增成功!"); + var newData = `${data._msg}${old_part_no}${new_part_no}刪除`; + $('#MydataTable').append(newData); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert("Found error when using Ajax!!"); + } + }); + + + }); + + $('#btnKeypartInsert').click(function () { + var component_id = $('#txtComponentID').val(); + var old_part_no = $('#txtOldPartNo').val(); + var new_part_no = $('#txtNewPartNo').val(); + + $.ajax({ + url: '@Url.Action("SaveNgKeypart", "REP")', + dataType: 'json', + data: { "component_id": component_id, "old_part_no": old_part_no, "new_part_no": new_part_no }, + cache: false, + type: "POST", + success: function (data, textStatus, jqXHR) { + if (data._msg != undefined) { + parent.hg.msg("新增成功!"); + location.reload(); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert("Found error when using Ajax!!"); + } + }); + + + }); + var tableCols = [[ { field: 'repairID', @@ -599,7 +707,7 @@ } } - //通过行tool删除,lay-event="del" + //通过行tool删除,lay-event="del2" function del(obj) { if (obj.data.imageName) { hg.confirm("圖片資料:" + obj.data.imageName + ",确定要删除吗?", function () { @@ -624,8 +732,62 @@ } } + // Table 刪除 + function Remove(button, OldNo, NewNo, KeypartID) { + hg.confirm("舊組件序號:" + OldNo + ",新組件序號:" + NewNo + ",確定要删除嗎?", function () { + + $.ajax({ + url: '@Url.Action("REP001KD", "REP")', + dataType: 'json', + data: { id: KeypartID }, + cache: false, + type: "POST", + success: function (data) { + if (data.success) { + hg.msg("删除成功!"); + var row = $(button).closest("TR"); + var table = $("#MydataTable")[0]; + table.deleteRow(row[0].rowIndex); + + } + + }, + error: function (jqXHR, textStatus, errorThrown) { + hg.msg("Found error when using Ajax!!"); + } + }); + }); + }; + + + //通过行tool删除,lay-event="del" + function del2(obj) { + if (obj.data.oldPartNo) { + hg.confirm("組件資料:" + obj.data.oldPartNo + ",确定要删除吗?", function () { + $.ajax({ + url: '/REP/REP001KD', + data: { id: obj.data.keypartID }, + type: 'POST', + success: function (data) { + if (data.success) { + obj.del(); //只删本地数据 + hg.msghide("删除成功!"); + } + else { + hg.msg(data.msg); + } + }, + error: function () { + hg.msg("网络请求失败!"); + } + }); + }); + } + } + //基本数据表格 var table = hg.table.datatable('test', '維修圖片資料', '/REP/GetNgRepairBlob/' + @Model.ngRepair.RepairID, {}, tableCols, false, false, 'full-100'); + diff --git a/AMESCoreStudio.Web/Views/REP/REP001V.cshtml b/AMESCoreStudio.Web/Views/REP/REP001V.cshtml index 389f2b16..1705f8da 100644 --- a/AMESCoreStudio.Web/Views/REP/REP001V.cshtml +++ b/AMESCoreStudio.Web/Views/REP/REP001V.cshtml @@ -171,6 +171,7 @@ function repair(obj) { if (obj.data.componentID) { hg.open('維修輸入', '/REP/REP001R/' + obj.data.componentID, 1080, 540); + //hg.open('維修輸入', '/REP/REP001R/' + obj.data.componentID, '', '', true); } } diff --git a/AMESCoreStudio.Web/Views/SPC/SPC004.cshtml b/AMESCoreStudio.Web/Views/SPC/SPC004.cshtml index e6f2877f..153335a8 100644 --- a/AMESCoreStudio.Web/Views/SPC/SPC004.cshtml +++ b/AMESCoreStudio.Web/Views/SPC/SPC004.cshtml @@ -236,7 +236,7 @@ templet: '
{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd") }}
' }, { - field: 'detailItem', + field: 'detailFail', title: '檢驗狀態', templet: function (d) { // yiru modify 22-12-09 if (d.detailFail != "0") diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs index 557a2f2c..ce1b3305 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs @@ -9,6 +9,8 @@ using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.CommonTools.Result; using AMESCoreStudio.WebApi.DTO.AMES; +using Dapper; +using AMESCoreStudio.WebApi.Extensions; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -213,6 +215,29 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + /// + /// 查詢箱號是否有在FQC抽驗中或允收 + /// + /// 箱號 + /// WIPID + /// + [HttpGet("GetCheckFqcOnGoIng")] + public async Task> GetCheckFqcOnGoIng(string boxNo , int wipId) + { + var querySql = @" SELECT * FROM JHAMES.FQC_INHOUSE_MASTER M + INNER JOIN JHAMES.FQC_INHOUSE_DETAIL D ON M.INHOUSE_NO = D.INHOUSE_NO AND M.SEQ_ID = D.SEQ_ID + INNER JOIN JHAMES.WIP_INFO W ON W.WIP_NO = M.WIP_NO + WHERE D.SERIAL_NO = :SerialNo + AND W.WIP_ID = :WipId + AND STATUS IN ('P','A') "; + + DynamicParameters p = new DynamicParameters(); + p.Add("SerialNo", boxNo); + p.Add("WipId", wipId); + var result = await _context.Database.DapperQueryAsync(querySql, p); + return result; + } + /// /// 新增檢驗單明細資料檔 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgKeypartsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgKeypartsController.cs new file mode 100644 index 00000000..d64763ee --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgKeypartsController.cs @@ -0,0 +1,213 @@ +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 NgKeypartsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public NgKeypartsController(AMESContext context) + { + _context = context; + } + + /// + /// + /// + /// + // GET: api/NgKeyparts + [HttpGet] + public async Task>> GetNgKeypart() + { + return await _context.NgKeyparts.ToListAsync(); + } + + /// + /// + /// + /// + /// + // GET: api/NgKeyparts/5 + [HttpGet("{id}")] + public async Task>> GetNgKeypart(int id) + { + IQueryable q = _context.NgKeyparts; + q = q.Where(p => p.KeypartID.Equals(id)); + + var ngKeypart = await q.ToListAsync(); + + if (ngKeypart == null) + { + return NotFound(); + } + + return ngKeypart; + } + + /// + /// + /// + /// + /// + // GET: api/NgKeyparts/5 + [HttpGet("ComponentID/{id}")] + public async Task>> GetNgKeypartByComponentID(int id) + { + IQueryable q = _context.NgKeyparts; + + q = q.Where(p => p.ComponentID.Equals(id)); + + try + { + var ngKeypart = await q.ToListAsync(); + + if (ngKeypart == null) + { + return NotFound(); + } + + return ngKeypart; + } + catch (Exception e1) + { + return NotFound(); + } + } + + /// + /// + /// + /// + /// + /// + // PUT: api/NgKeyparts/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> PutNgKeypart(int id, NgKeypart ngKeypart) + { + ResultModel result = new ResultModel(); + if (id != ngKeypart.KeypartID) + { + result.Success = false; + result.Msg = "不良組件ID錯誤"; + return result; + } + + _context.Entry(ngKeypart).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!NgKeypartExists(id)) + { + result.Success = false; + result.Msg = "不良組件ID不存在"; + return result; + } + else + { + throw; + } + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// + /// + /// + /// + // POST: api/NgKeyparts + // 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> PostNgKeypart(NgKeypart ngKeypart) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + ngKeypart.KeypartID = helper.GetIDKey("KEYPART_ID").Result; + + _context.NgKeyparts.Add(ngKeypart); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException ex) + { + if (NgKeypartExists(ngKeypart.KeypartID)) + { + result.Success = false; + result.Msg = "不良組件ID重複"; + return result; + } + else + { + result.Success = false; + result.Msg = ex.InnerException.Message; + return result; + } + } + + result.Success = true; + result.Msg = ngKeypart.KeypartID.ToString(); + return result; + } + + /// + /// + /// + /// + /// + // DELETE: api/NgKeyparts/5 + [HttpDelete("{id}")] + public async Task> DeleteNgKeypart(int id) + { + ResultModel result = new ResultModel(); + + var ngKeypart = await _context.NgKeyparts.FindAsync(id); + if (ngKeypart == null) + { + result.Success = false; + result.Msg = "不良組件ID不存在"; + return result; + } + + _context.NgKeyparts.Remove(ngKeypart); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + return result; + } + + private bool NgKeypartExists(int id) + { + return _context.NgKeyparts.Any(e => e.KeypartID == id); + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckNewController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckNewController.cs index 6225557b..4e9f8068 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckNewController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckNewController.cs @@ -2242,7 +2242,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } // 判斷序號為出貨條碼,並轉成內部條碼 - var BarCodeInfo = await _context.BarcodeInfoes.Where(w => w.ExtraBarcodeNo == barCodeCheckDto.barcode.Trim()).FirstOrDefaultAsync(); + var BarCodeInfo = await _context.BarcodeInfoes.Where(w => w.ExtraBarcodeNo.Trim().ToUpper() == barCodeCheckDto.barcode.Trim().ToUpper()).FirstOrDefaultAsync(); if (BarCodeInfo != null) { result.extNo = BarCodeInfo.ExtraBarcodeNo; diff --git a/AMESCoreStudio.WebApi/Models/AMES/InspectionResultDetail.cs b/AMESCoreStudio.WebApi/Models/AMES/InspectionResultDetail.cs index c12d8a62..5f7131e6 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/InspectionResultDetail.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/InspectionResultDetail.cs @@ -56,7 +56,6 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// P-PASS(允收) ; F-FAIL(批退) ; NA-無 ; A初始狀態 ; /// [Column("INSPECTION_RESULT")] - [StringLength(20)] [Display(Name = "稽核結果")] [DataMember] [Required(ErrorMessage = "{0},不能空白")] @@ -119,7 +118,6 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 缺失備註 /// [Column("MISSING_REMARK")] - [StringLength(100)] [Display(Name = "缺失備註")] [DataMember] public string MissingRemark { get; set; } @@ -128,7 +126,6 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 是否需要對策 METHOD : Y-YES : N-NO /// [Column("METHOD")] - [StringLength(100)] [Display(Name = "是否需要對策")] [DataMember] public string Method { get; set; } @@ -138,7 +135,6 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 回覆原因 /// [Column("REPLY_REASON")] - [StringLength(100)] [Display(Name = "回覆原因")] [DataMember] public string ReplyReason { get; set; } @@ -147,7 +143,6 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 回覆對策 /// [Column("REPLY_METHOD")] - [StringLength(100)] [Display(Name = "回覆對策")] [DataMember] public string ReplyMethod { get; set; } diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgKeypart.cs b/AMESCoreStudio.WebApi/Models/AMES/NgKeypart.cs new file mode 100644 index 00000000..4d16a09f --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/NgKeypart.cs @@ -0,0 +1,82 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +#nullable disable + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 維修不良組件資料檔 + /// + [Table("NG_KEYPART", Schema = "JHAMES")] + public partial class NgKeypart + { + /// + /// 不良組件ID + /// + [Key] + [Column("KEYPART_ID")] + [DataMember] + [Required] + [Display(Name = "不良組件ID")] + public int KeypartID { get; set; } + + /// + /// 不良零件ID + /// + [Column("COMPONENT_ID")] + [DataMember] + [Required] + [Display(Name = "不良零件ID")] + public int ComponentID { get; set; } + + /// + /// 舊組件序號 + /// + //[Required] + [Column("OLD_PART_NO")] + [DataMember] + [Display(Name = "舊組件序號")] + public string OldPartNo { get; set; } + + /// + /// 新組件序號 + /// + //[Required] + [Column("NEW_PART_NO")] + [DataMember] + [Display(Name = "新組件序號")] + public string NewPartNo { get; set; } + + /// + /// 創建者ID + /// + [Column("CREATE_USERID")] + [DataMember] + public int CreateUserID { get; set; } = 0; + + /// + /// 創建日期 + /// + [Column("CREATE_DATE")] + [DataMember] + [Display(Name = "不良時間")] + public DateTime CreateDate { get; set; } = System.DateTime.Now; + + /// + /// 更新者ID + /// + [Column("UPDATE_USERID")] + [DataMember] + public int UpdateUserID { get; set; } = 0; + + /// + /// 更新日期 + /// + [Column("UPDATE_DATE", TypeName = "DATE")] + [DataMember] + public DateTime UpdateDate { get; set; } = System.DateTime.Now; + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 173d9cc4..7807edb2 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -1000,6 +1000,11 @@ namespace AMESCoreStudio.WebApi /// 测试文本 /// public DbSet TestInfoes { get; set; } + + /// + /// 維修不良序號 + /// + public DbSet NgKeyparts { get; set; } } }