diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 6cd87beb..856b61fa 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -6425,6 +6425,7 @@ namespace AMESCoreStudio.Web.Controllers public async Task PCS024C(string id) { var result = await _pcsApi.GetBarcodeInfoesByNo(id); + var tt = result[0]; ViewBag.BarcodeID = tt.BarcodeID; ViewBag.WipID = tt.WipID; @@ -6465,6 +6466,7 @@ namespace AMESCoreStudio.Web.Controllers if (ModelState.IsValid) { IResultModel result; + model.CreateUserID = GetLogInUserID(); result = await _pcsApi.PostBarcodeItemAddnew(JsonConvert.SerializeObject(model)); @@ -7070,11 +7072,13 @@ namespace AMESCoreStudio.Web.Controllers barcodeItemChange.StationID = barcodeItemOld.StationID; barcodeItemChange.WipID = barcodeItemOld.WipID; barcodeItemChange.KpItemNo = barcodeItemOld.KpItemNo; - barcodeItemChange.CreateUserID = barcodeItemOld.CreateUserID; + // barcodeItemChange.CreateUserID = barcodeItemOld.CreateUserID; YIRU + barcodeItemChange.CreateUserID = GetLogInUserID(); barcodeItemChange.CreateDate = System.DateTime.Now; barcodeItemChange.UpdateDate = System.DateTime.Now; - + model.CreateUserID = GetLogInUserID(); result = await _pcsApi.PutBarcodeItem(model.BarcodeItemID, JsonConvert.SerializeObject(model)); + result2 = await _pcsApi.PostBarcodeItemChange(JsonConvert.SerializeObject(barcodeItemChange)); //result = await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(model)); @@ -7117,7 +7121,8 @@ namespace AMESCoreStudio.Web.Controllers barcodeItemChange.StationID = barcodeItemOld.StationID; barcodeItemChange.WipID = barcodeItemOld.WipID; barcodeItemChange.KpItemNo = barcodeItemOld.KpItemNo; - barcodeItemChange.CreateUserID = barcodeItemOld.CreateUserID; + // barcodeItemChange.CreateUserID = barcodeItemOld.CreateUserID; yiru + barcodeItemChange.CreateUserID = GetLogInUserID(); barcodeItemChange.CreateDate = System.DateTime.Now; barcodeItemChange.UpdateDate = System.DateTime.Now; @@ -7160,7 +7165,10 @@ namespace AMESCoreStudio.Web.Controllers , status: status, page: page, limit: limit); if (result.Data.Count() != 0) { - var Data = result.Data.Where(w => w.StatusName == "允收"); + // var Data = result.Data.Where(w => w.StatusName == "允收"); + var Data = result.Data; + + return Json(new Table() { code = 0, msg = "", data = Data, count = Data.Count() }); } return Json(new Table() { count = 0, data = null }); @@ -7289,6 +7297,7 @@ namespace AMESCoreStudio.Web.Controllers BarcodeID = item.BarcodeID, BarcodeNo = item.BarcodeNo, StatusNo = item.StatusNo, + ExtraBarcodeNo = item.ExtraBarcodeNo, StationID = StationID, RuleStatus = "P",//F 不良 BoxNo = item.BoxNo, @@ -7375,7 +7384,7 @@ namespace AMESCoreStudio.Web.Controllers return new Result() { success = false, msg = _msg }; } - var resultPTD101AMES = await _pcsApi.PostPTD101AMES(JsonConvert.SerializeObject(PTD101AMESModels)); + await _pcsApi.PostPTD101AMES(JsonConvert.SerializeObject(PTD101AMESModels)); } diff --git a/AMESCoreStudio.Web/Controllers/SPCController.cs b/AMESCoreStudio.Web/Controllers/SPCController.cs index 95fa5688..e69e4072 100644 --- a/AMESCoreStudio.Web/Controllers/SPCController.cs +++ b/AMESCoreStudio.Web/Controllers/SPCController.cs @@ -665,14 +665,38 @@ namespace AMESCoreStudio.Web.Controllers #endregion #region SPC004巡檢結果維護相關 - - // public IActionResult SPC004() public async Task SPC004() { - await GetStationList1(); - await GetLineList1(); + + await GetInspectionTypesList(); + await GetInspectionFormsList(); + return View(); } + + public async Task SPC004VAsync(int id) + { + //await GetStationList1(); + //await GetLineList1(); + //return View(); + await GetStationList(); + await GetLineList(); + await GetFactoryUnitsList(); + await GetUserInfo(); + var result = await _spcApi.GetInspectionResultMaster(id); + if (result.Count == 0) + { + return View(); + } + var user = await _sysApi.GetUserInfo(result[0].CreateUserID); + var userName = user[0].UserName; + ViewBag.UserName = userName; + ViewBag.WipNo = result[0].WipNo; + ViewBag.ItemNo = result[0].ItemNo; + ViewBag.BarcodeNo = result[0].BarcodeNo; + ViewBag.InspectionID = result[0].InspectionID; + return View(result[0]); + } //修改页面 [HttpGet] public async Task SPC004UAsync(int id, int Iid) diff --git a/AMESCoreStudio.Web/HttpApis/AMES/ISPC.cs b/AMESCoreStudio.Web/HttpApis/AMES/ISPC.cs index 3c9db36b..72a5c941 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/ISPC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/ISPC.cs @@ -226,7 +226,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/InspectionResultMasters/QueryAll/{id}/{WipNo}/{ItemNo}/{BarcodeNo}/{StatusNo}/{sdate}/{edate}")] - ITask> GetInspectionResultMastersByQueryAll(int id, string WipNo, string ItemNo, string BarcodeNo, string StatusNo, string sdate, string edate, int page = 0, int limit = 10); + ITask> GetInspectionResultMastersByQueryAll(int id, string WipNo, string ItemNo, string BarcodeNo, string StatusNo, string sdate, string edate, int page = 0, int limit = 10); /// diff --git a/AMESCoreStudio.Web/Views/SPC/SPC004.cshtml b/AMESCoreStudio.Web/Views/SPC/SPC004.cshtml index 96e7b2c2..98188701 100644 --- a/AMESCoreStudio.Web/Views/SPC/SPC004.cshtml +++ b/AMESCoreStudio.Web/Views/SPC/SPC004.cshtml @@ -13,216 +13,366 @@
-
-
-
- - +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
-
+
- - +
+ + +
-
- -
+
- - +
+ + +
-
-
- -
+
+
- -
- +
+ +
-
-
+
- -
- + +
+ +
+
+
+
-
- -
- -
- +
+
+
+ +
+
+
+
+
+
+
+@section Scripts{ + + + -
-
- -
-
+ + + function CheckBarcodeNo(BarcodeNo, WipNo) { + + $.ajax({ + url: '/SPC/CheckBarcodeNO?BarcodeNo=' + BarcodeNo + '&WipNo=' + WipNo, + dataType: 'json', + contentType: "application/json", + type: 'get', + success: function (result) { + if (!result.data) { + alert("抽驗編號不在工單區間內"); + } + } + }); + }; + + + + function GetdetailQuery(id) { + + var str = ""; + $.ajax({ + url: '/SPC/GetInspectionResultDetails?id=' + id, + dataType: 'json', + contentType: "application/json", + type: 'get', + success: function (result) { + if (result.data) { + var P = 0; + var F = 0; + var NA = 0; + var Total = 0; + // $.each(result.data, (index, item) { + $.each(result.data, function () { + Total += 1; + if (result.data.result == "P") { + P += 1; + } + if (result.data.result == "F") { + F += 1; + } + if (result.data.result == "NA") { + NA += 1; + } + }); + if (F != "0") + str = "F" + else + str = "P" + // str = "Total:" + Total.toString + " P:" + P.toString() + " F:" + F.toString + " NA:" + NA.toString; + return str; + } + + } + }); + }; + + + + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/SPC/SPC004V.cshtml b/AMESCoreStudio.Web/Views/SPC/SPC004V.cshtml new file mode 100644 index 00000000..6bba3415 --- /dev/null +++ b/AMESCoreStudio.Web/Views/SPC/SPC004V.cshtml @@ -0,0 +1,259 @@ +@{ + ViewData["Title"] = "巡檢結果回覆"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+ + + + + + + +
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+ + @section Scripts{ + + } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs index b8b160a9..d82985ee 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs @@ -502,7 +502,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { q = q.Where(w => w.RecordDate <= DateTime.Parse(date_end)); } - + q= q.Where(w => w.StatusName == "P"); ResultModel result = new ResultModel(); // 紀錄筆數 diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultDetailsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultDetailsController.cs index 58d06203..78ba5c64 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultDetailsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultDetailsController.cs @@ -113,6 +113,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES CreateDate = q1.CreateDate, UpdateDate = q1.UpdateDate, InspectionResult =q1.Result, + PeplyReason = q1.ReplyReason, + PeplyMethod = q1.ReplyMethod, @@ -149,6 +151,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return InspectionResultDetail; } + + + /// /// 更新巡檢類別資料 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultMastersController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultMastersController.cs index 6f32b2f8..e6ca68df 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultMastersController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultMastersController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.CommonTools.Result; - +using AMESCoreStudio.WebApi.DTO.AMES; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -141,11 +141,40 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// // GET: api/InspectionItems/5 [HttpGet("QueryAll/{id}/{WipNo}/{ItemNo}/{BarcodeNo}/{StatusNo}/{sdate}/{edate}")] - public async Task> GetInspectionResultMastersByQueryAll(int id, string WipNo, string ItemNo, string BarcodeNo, string StatusNo, string sdate, string edate, int page = 0, int limit = 10) + public async Task> GetInspectionResultMastersByQueryAll(int id, string WipNo, string ItemNo, string BarcodeNo, string StatusNo, string sdate, string edate, int page = 0, int limit = 10) { + ResultModel result = new ResultModel(); + + var q = from q1 in _context.InspectionResultMasters + join q3 in _context.InspectionResultDetails on q1.InspectionID equals q3.InspectionID + // from q3 in j1.DefaultIfEmpty() + + select new InspectionResultMasterDto + { + InspectionID = q1.InspectionID, + InspectionFormID = q1.InspectionFormID, + BarcodeNo = q1.BarcodeNo, + WipNo = q1.WipNo, + ItemNo = q1.ItemNo, + StatusNo = q1.StatusNo, + CreateUserID = q1.CreateUserID, + CreateDate = q1.CreateDate, + UpdateUserID = q1.UpdateUserID, + UpdateDate = q1.UpdateDate, + DetailItem = q3.Result != "" ? "1":"0", + DetailPass = q3.Result == "P" ? "1":"0", + DetailFail = q3.Result == "F" ? "1" : "0", + DetailNA = q3.Result == "NA" ? "1" : "0", + + }; + + + + + //yiru 2022-11-17 - ResultModel result = new ResultModel(); - IQueryable q = _context.InspectionResultMasters; + // ResultModel result = new ResultModel(); + // IQueryable q = _context.InspectionResultMasters; if (id.ToString()!="-99"&&id.ToString()!="0") q = q.Where(p => p.InspectionFormID.Equals(id)); @@ -163,8 +192,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES q = q.Where(w => w.StatusNo == StatusNo); - - DateTime dateValue; if (sdate != "*") { @@ -183,15 +210,40 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } // 紀錄筆數 - result.DataTotal = q.Count(); + + var q0 = q.GroupBy(q => q.InspectionID).Select(cl => new InspectionResultMasterDto + { + InspectionID = cl.Max(m => m.InspectionID), + InspectionFormID = cl.Max(m => m.InspectionFormID), + BarcodeNo = cl.Max(m => m.BarcodeNo), + WipNo = cl.Max(m => m.WipNo), + ItemNo = cl.Max(m => m.ItemNo), + StatusNo = cl.Max(m => m.StatusNo), + CreateUserID = cl.Max(m => m.CreateUserID), + CreateDate = cl.Max(m => m.CreateDate), + UpdateUserID = cl.Max(m => m.UpdateUserID), + UpdateDate = cl.Max(m => m.UpdateDate), + DetailItem = cl.Count(c => c.DetailItem == "1").ToString(), + DetailPass = cl.Count(c => c.DetailPass == "1").ToString(), + DetailFail = cl.Count(c => c.DetailFail == "1").ToString(), + DetailNA = cl.Count(c => c.DetailNA == "1").ToString() + + }); + + + + + + + result.DataTotal = q0.Count(); // Table 頁數 if (page > 0) { - q = q.Skip((page - 1) * limit).Take(limit); + q0 = q0.Skip((page - 1) * limit).Take(limit); } - result.Data = await q.ToListAsync(); + result.Data = await q0.ToListAsync(); result.Data = result.Data.Select(s => { s.StatusNo = s.StatusNo == "C" ? "保存" : "暫存"; diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WarehouseingController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WarehouseingController.cs new file mode 100644 index 00000000..6c656edb --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WarehouseingController.cs @@ -0,0 +1,136 @@ +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 +{ + ///yiru add + /// + /// 檢驗單明細資料檔 + /// + [Route("api/[controller]")] + [ApiController] + public class WarehouseingController : ControllerBase + { + private readonly AMESContext _context; + /// + /// 完工入庫資料 + /// + /// + public WarehouseingController(AMESContext context) + { + _context = context; + } + + // GET: api/Warehouseing + /// + /// 查詢所有已入庫資料 + /// + /// + [HttpGet] + public async Task>> GetWareHouseings() + { + return await _context.WareHouseings.ToListAsync(); + } + + /// + /// 查詢完工入庫資料 By 送驗單號、序號 + /// + /// 入庫單號 + /// 序號 + /// + [HttpGet("{inhouseNo}/{seq}")] + public async Task>> GetWareHouseing(string inhouseNo, int seq) + { + var WareHouseing = await _context.WareHouseings + .Where(w => w.InhouseNo == inhouseNo && w.SeqID == seq) + .ToListAsync(); + + return WareHouseing; + } + + /// + /// 修改完工入庫資料 + /// + /// + /// + [HttpPut] + public async Task> PutWareHouseing(WareHouseing WareHouseing) + { + ResultModel result = new ResultModel(); + _context.Entry(WareHouseing).State = EntityState.Modified; + //設置容器空間某一個模型的某一個欄位 不提交到資料庫 + _context.Entry(WareHouseing).Property("Create_Date").IsModified = false; + _context.Entry(WareHouseing).Property("Create_UserID").IsModified = false; + + + 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> PostWareHouseing(WareHouseing WareHouseing) + { + ResultModel result = new ResultModel(); + try + { + + _context.WareHouseings.Add(WareHouseing); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + } + + + /// + /// 刪除完工入庫資料檔 + /// + /// + /// + //[HttpDelete("{id}")] + //public async Task> DeleteWareHouseing(string id) + //{ + // var WareHouseing = await _context.WareHouseings.FindAsync(id); + // if (WareHouseing == null) + // { + // return NotFound(); + // } + + // _context.WareHouseings.Remove(WareHouseing); + // await _context.SaveChangesAsync(); + + // return WareHouseing; + //} + + } +} diff --git a/AMESCoreStudio.WebApi/DTO/AMES/InspectionResultMasterDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/InspectionResultMasterDto.cs new file mode 100644 index 00000000..f574174b --- /dev/null +++ b/AMESCoreStudio.WebApi/DTO/AMES/InspectionResultMasterDto.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AMESCoreStudio.WebApi.DTO.AMES +{ + /// + /// 檢驗表頭資料檔DTO + /// + public class InspectionResultMasterDto + { + public int InspectionID { get; set; } + public int InspectionFormID { get; set; } + public string BarcodeNo { get; set; } + public string WipNo { get; set; } + public string ItemNo { get; set; } + public string StatusNo { get; set; } + public int CreateUserID { get; set; } + public DateTime CreateDate { get; set; } + public int UpdateUserID { get; set; } + public DateTime UpdateDate { get; set; } + + public string DetailItem { get; set; } + public string DetailPass { get; set; } + public string DetailFail { get; set; } + public string DetailNA { get; set; } + } + +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/InspectionResultMaster.cs b/AMESCoreStudio.WebApi/Models/AMES/InspectionResultMaster.cs index d7632da0..5022aa04 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/InspectionResultMaster.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/InspectionResultMaster.cs @@ -29,11 +29,11 @@ namespace AMESCoreStudio.WebApi.Models.AMES public int InspectionFormID { get; set; } /// - /// 生產序號 + /// 抽驗號碼 /// [Column("BARCODE_NO")] [StringLength(30)] - [Display(Name = "生產序號")] + [Display(Name = "抽驗號碼")] [DataMember] // [Required(ErrorMessage = "{0},不能空白")] YIRU modify 改為可以空白 系統自行卡關 工單號與生產序號可二擇一輸入 public string BarcodeNo { get; set; }