diff --git a/AMESCoreStudio.Web/Controllers/WHSController.cs b/AMESCoreStudio.Web/Controllers/WHSController.cs index 4e4e13c8..ef2c5074 100644 --- a/AMESCoreStudio.Web/Controllers/WHSController.cs +++ b/AMESCoreStudio.Web/Controllers/WHSController.cs @@ -2076,6 +2076,308 @@ namespace AMESCoreStudio.Web.Controllers #endregion + #region WHS019生產工時報工相關 + public async Task WHS019() + { + var user_id = Request.Cookies["UserID"]; + //製程單位 + await GetFactoryUnitsList3(); + //線別 + await GetLineList2(); + //站別 + await GetStationList2(); + + return View(); + } + //新增頁面 + public async Task WHS019C() + { + var user_id = Request.Cookies["UserID"]; + ViewBag.UserID = user_id; + //製程單位 + await GetFactoryUnitsList2(); + //廠別 + await GetFactoryList(); + //線別 + await GetLineList2(); + //站別 + await GetStationList(); + + + return View(); + } + //修改页面 + [HttpGet] + public async Task WHS019UAsync(string id) + { + var user_id = Request.Cookies["UserID"]; + ViewBag.UserID = user_id; + //製程單位 + await GetFactoryUnitsList2(); + //廠別 + await GetFactoryList(); + //線別 + await GetLineList2(); + //站別 + await GetStationList(); + + var result = await _whsApi.GetWorkingHoursCollection(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + //完工页面 + [HttpGet] + public async Task WHS019EAsync(string id) + { + var user_id = Request.Cookies["UserID"]; + ViewBag.UserID = user_id; + //製程單位 + await GetFactoryUnitsList2(); + //廠別 + await GetFactoryList(); + //線別 + await GetLineList2(); + //站別 + await GetStationList(); + //班別 + GetClassList(); + //判定單位部門 + await GetDeptList(); + + var result = await _whsApi.GetWorkingHoursCollection(id); + + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + public async Task WHS019DAsync(int id) + { + var result = await _whsApi.DeleteSupportUser(id); + return Json(new Result() { success = true, msg = "" }); + } + [HttpPost] + public async Task WHS019CSaveAsync(WorkingHoursCollection model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PostWorkingHoursCollection(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("WHS019C", model); + } + public async Task WHS019USaveAsync(WorkingHoursCollection model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PutWorkingHoursCollection(model.TimeSheetID, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + var user_id = Request.Cookies["UserID"]; + ViewBag.UserID = user_id; + //製程單位 + await GetFactoryUnitsList2(); + //廠別 + await GetFactoryList(); + //線別 + await GetLineList2(); + //站別 + await GetStationList(); + //班別 + GetClassList(); + //判定單位部門 + await GetDeptList(); + + ModelState.AddModelError("error", result.Msg); + + } + } + return View("WHS019U", model); + } + public async Task WHS019ESaveAsync(WorkingHoursCollection model) + { + if (ModelState.IsValid) + { + IResultModel result; + + + result = await _whsApi.PutWorkingHoursCollection(model.TimeSheetID, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + var tt = Request.Cookies["UserID"]; + ViewBag.UserID = tt; + //製程單位 + await GetFactoryUnitsList2(); + //廠別 + await GetFactoryList(); + //線別 + await GetLineList2(); + //站別 + await GetStationList(); + //班別 + GetClassList(); + //判定單位部門 + await GetDeptList(); + + + ModelState.AddModelError("error", result.Msg); + + } + } + return View("WHS019E", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWorkingHoursCollectionByQuery4WHS019Async(string unitNo, string lineid, string stationid, string wipno, string itemno, string user, string sdate, string edate) + { + if (unitNo == null) + { + unitNo = "*"; + } + if (lineid == null || lineid == "0") + { + lineid = "*"; + } + if (stationid == null || stationid == "0") + { + stationid = "*"; + } + if (itemno == null) + { + itemno = "*"; + } + if (user == null) + { + user = "*"; + } + if (sdate == null || edate == null) + { + sdate = "*"; + edate = "*"; + } + + var result = await _whsApi.GetWorkingHoursCollectionByQuery(unitNo, lineid, stationid, wipno, itemno, user, sdate, edate); + + + if (result.Count > 0) + { + //List < AMESCoreStudio.WebApi.DTO.AMES.WorkingHoursCollectionDto > workingHoursCollectionDto = new List(); + + //foreach (var data in result) + //{ + // var dd = _context.StandardWorkTimes.Where(w => w.ItemNo == data.ItemNo); + // var d1 = dd.Where(w => w.UnitNo == data.UnitNo); + // var d2 = d1.Where(w => w.LineID == data.LineID); + // var d3 = d2.Where(w => w.StationID == data.StationID).FirstOrDefault(); + // data.RuleCNT = d3.OPCNT; + // data.RuleTime = d3.TotalCT; + // var p1 = _context.UserInfoes.Where(w => w.UserID == data.CreateUserID).FirstOrDefault(); + // data.CreateUser = p1.UserName; + // if (data.UpdateUserID != null) + // { + // var p2 = _context.UserInfoes.Where(w => w.UserID == data.UpdateUserID).FirstOrDefault(); + // data.UpdateUser = p2.UserName; + // } + // if (data.TotalCT != null) + // { + // data.Effective = (data.RuleCNT * data.RuleTime) / (data.TotalCT * data.OPCNT); //標準工時 * 人數 / 該筆資料的實際標工(TOTAL_CT) * 人數 * 100 % + // } + // + //} + + + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + public async Task GetWorkingHoursCollectionDtoByQuery4WHS019Async(string unitNo, string lineid, string stationid, string wipno, string itemno, string user, string sdate, string edate) + { + if (unitNo == null) + { + unitNo = "*"; + } + if (lineid == null || lineid == "0") + { + lineid = "*"; + } + if (stationid == null || stationid == "0") + { + stationid = "*"; + } + if (itemno == null) + { + itemno = "*"; + } + if (wipno == null) + { + wipno = "*"; + } + + if (user == null) + { + user = "*"; + } + if (sdate == null || edate == null) + { + sdate = "*"; + edate = "*"; + } + + var result = await _whsApi.GetWorkingHoursCollectionDtoByQuery(unitNo, lineid, stationid, wipno, itemno, user, sdate, edate); + + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + + #endregion } } diff --git a/AMESCoreStudio.Web/Views/WHS/WHS019.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS019.cshtml new file mode 100644 index 00000000..ab282cd2 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS019.cshtml @@ -0,0 +1,392 @@ +@{ + ViewData["Title"] = "生產工時報工"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + + + + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +@section Scripts{ + +} diff --git a/AMESCoreStudio.Web/Views/WHS/WHS019C.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS019C.cshtml new file mode 100644 index 00000000..762dbc7c --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS019C.cshtml @@ -0,0 +1,319 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingHoursCollection + + +@{ ViewData["Title"] = "WHS018C"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + +
+
+
+
+ + + + + +
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + + @**@ +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/Views/WHS/WHS019E.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS019E.cshtml new file mode 100644 index 00000000..5d90d653 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS019E.cshtml @@ -0,0 +1,355 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingHoursCollection + + +@{ ViewData["Title"] = "WHS018C"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + +
+
+
+
+ + + + + + +
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + +
+
+ + + + @**@ +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/Views/WHS/WHS019U.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS019U.cshtml new file mode 100644 index 00000000..c5c0f002 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS019U.cshtml @@ -0,0 +1,319 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingHoursCollection + + +@{ ViewData["Title"] = "WHS018U"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + +
+
+
+
+ + + + + + +
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.WebApi/Models/AMES/WorkingHoursCollection.cs b/AMESCoreStudio.WebApi/Models/AMES/WorkingHoursCollection.cs index d706998f..68551017 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WorkingHoursCollection.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WorkingHoursCollection.cs @@ -144,7 +144,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("INPUT_SENSOR_ID")] [StringLength(16)] [DataMember] - [Display(Name = "起始Sensor")] + [Display(Name = "資料採集器(投入站)")] public string InputSensorID { get; set; } /// @@ -153,7 +153,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Column("OUTPUT_SENSOR_ID")] [StringLength(16)] [DataMember] - [Display(Name = "結止Sensor")] + [Display(Name = "資料採集器(產出站)")] public string OutputSensorID { get; set; } /// diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 099b7dc1..e00ae8dd 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -817,6 +817,11 @@ namespace AMESCoreStudio.WebApi /// public virtual DbSet WareHouseings { get; set; } + /// + /// 生產工時報工資料檔 + /// + public DbSet WipTimeSheets { get; set; } + } }