diff --git a/AMESCoreStudio.Web/Controllers/WHSController.cs b/AMESCoreStudio.Web/Controllers/WHSController.cs index 22684d1..e70a852 100644 --- a/AMESCoreStudio.Web/Controllers/WHSController.cs +++ b/AMESCoreStudio.Web/Controllers/WHSController.cs @@ -12,6 +12,9 @@ using AMESCoreStudio.CommonTools.Result; using Microsoft.AspNetCore.Http; using System.IO; using Microsoft.AspNetCore.Hosting; +using ClosedXML.Excel; +using System; +using AMESCoreStudio.Web.ViewModels.WHS; namespace AMESCoreStudio.Web.Controllers { @@ -3100,5 +3103,752 @@ namespace AMESCoreStudio.Web.Controllers return View(); } + + + #region WHS022報工站別維護相關 + + + + public IActionResult WHS022() + { + return View(); + } + + //新增頁面 + public async Task WHS022C() + { + GetSideTypeList(); + await GetFactoryUnitsList3(); + return View(); + } + + //修改页面 + [HttpGet] + public async Task WHS022UAsync(int id) + { + await GetFactoryUnitsList3(); + + var result = await _whsApi.GetWorkingUnit(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task WHS022DAsync(int id) + { + var result = await _whsApi.DeleteWorkingUnit(id); + + return Json(new Result() { success = true, msg = "" }); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task WHS022CSaveAsync(WorkingUnit model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PostWorkingUnit(JsonConvert.SerializeObject(model)); + + + if (result.Success) + { + var _msg = "添加成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors != null) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("WHS022C", model); + } + + public async Task WHS022USaveAsync(WorkingUnit model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PutWorkingUnit(model.WorkingUnitID, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors != null) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("WHS022U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWorkingUnitsAsync(int page = 0, int limit = 10) + { + var result = await _whsApi.GetWorkingUnits(page, limit); + + if (result.DataTotal > 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + + return Json(new Table() { count = 0, data = null }); + } + + + + + #endregion + + #region WHS023報工線別基本資料相關 + private async Task GetWorkingUnit(string Type) + { + var result = await _whsApi.GetWorkingUnits(); + + var UnitItems = new List(); + + if (Type == "all") + { + UnitItems.Add(new SelectListItem("全部", "all")); + } + for (int i = 0; i < result.Count; i++) + if (result[i].StatusNo == "A") + { + UnitItems.Add(new SelectListItem(result[i].WorkingUnitName, result[i].WorkingUnitNo.ToString())); + } + + ViewBag.WorkingUnitNo = UnitItems; + } + public async Task WHS023() + { + await GetWorkingUnit("all"); + return View(); + } + + //新增頁面 + public async Task WHS023C() + { + + await GetWorkingUnit(""); + return View(); + } + + //修改页面 + [HttpGet] + public async Task WHS023UAsync(int id) + { + await GetWorkingUnit(""); + + var result = await _whsApi.GetWorkingLine(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task WHS023DAsync(int id) + { + var result = await _whsApi.DeleteWorkingLine(id); + + return Json(new Result() { success = true, msg = "" }); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task WHS023CSaveAsync(WorkingLine model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PostWorkingLine(JsonConvert.SerializeObject(model)); + + + if (result.Success) + { + var _msg = "添加成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors != null) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("WHS023C", model); + } + + public async Task WHS023USaveAsync(WorkingLine model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PutWorkingLine(model.WorkingLineID, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors != null) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("WHS023U", model); + } + + #endregion + + #region WHS024報工工作站基本資料相關 + + public async Task WHS024() + { + await GetWorkingUnit("all"); + return View(); + } + + //新增頁面 + public async Task WHS024C() + { + + await GetWorkingUnit(""); + return View(); + } + + //修改页面 + [HttpGet] + public async Task WHS024UAsync(int id) + { + await GetWorkingUnit(""); + + var result = await _whsApi.GetWorkingStation(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task WHS024DAsync(int id) + { + var result = await _whsApi.DeleteWorkingStation(id); + + return Json(new Result() { success = true, msg = "" }); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task WHS024CSaveAsync(WorkingStation model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PostWorkingStation(JsonConvert.SerializeObject(model)); + + + if (result.Success) + { + var _msg = "添加成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors != null) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("WHS024C", model); + } + + public async Task WHS024USaveAsync(WorkingStation model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PutWorkingStation(model.WorkingStationID, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + if (result.Errors != null) + { + ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + return View("WHS024U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWorkingStationsAsync(string id) + { + var result = await _whsApi.GetWorkingStationsbyMultiUnit(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 }); + } + + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWorkingLinesAsync(string id) + { + // var result = await _whsApi.GetWorkingLinesbyUnit(id); + var result = await _whsApi.GetWorkingLinesbyMultiUnit(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 }); + } + + + #endregion + + #region WHS025標準工時維護相關 + public async Task WHS025() + { + await GetWorkingUnit("all"); + return View(); + } + //新增頁面 + public async Task WHS025C() + { + await GetWorkingUnit(""); //報工生產單位 + await GetFactoryUnitsListbyWH005(""); //途程生產單位 + GetSideList(); + return View(); + } + //修改页面 + [HttpGet] + public async Task WHS025UAsync(int id) + { + await GetWorkingUnit(""); //報工生產單位 + await GetFactoryUnitsListbyWH005(""); //途程生產單位 + GetSideList(); + var result = await _whsApi.GetWorkingStandardWorkTime(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + public async Task WHS025DAsync(int id) + { + var result = await _whsApi.DeleteWorkingStandardWorkTime(id); + return Json(new Result() { success = true, msg = "" }); + } + [HttpPost] + public async Task WHS025CSaveAsync(WHS025ViewModel model) + { + if (!ModelState.IsValid) + return View("WHS025C", model); + + // 若 WorkingLineIDs 為空,直接回傳錯誤 + if (model.WorkingLineIDs == null) + { + ModelState.AddModelError("error", "請至少選擇一個線別"); + return View("WHS025C", model); + } + // 複製 model 中的其他欄位,產生新的物件 + var item = new WorkingStandardWorkTime + { + WorkingStandardID = model.WorkingStandardID, + ItemNo = model.ItemNo, + WorkingUnitNo = model.WorkingUnitNo, + UnitNo = model.UnitNo, + + WorkingStationID = model.WorkingStationID, + Side = model.Side, + OpCnt = model.OpCnt, + Ct = model.Ct, + StationID = model.StationID, + MachineCnt = model.MachineCnt, + Remark = model.Remark, + CreateUserID = model.CreateUserID, + UpdateUserID = model.UpdateUserID, + CreateDate = model.CreateDate, + UpdateDate = model.UpdateDate + }; + + foreach (var lineId in model.WorkingLineIDs) + { + item.WorkingLineID = lineId; // ⭐ 關鍵:取代為迴圈內的 lineId + + var json = JsonConvert.SerializeObject(item); + var result = await _whsApi.PostWorkingStandardWorkTime(json); + + if (!result.Success) + { + // 其中一筆失敗就回傳錯誤 + ModelState.AddModelError("error", $"線別ID {lineId} 錯誤:{result.Msg}"); + return View("WHS025C", model); + } + } + + return RedirectToAction("Refresh", "Home", new { msg = "添加成功!" }); + + + //if (ModelState.IsValid) + //{ + // IResultModel result; + + + // result = await _whsApi.PostWorkingStandardWorkTime(JsonConvert.SerializeObject(model)); + + // if (result.Success) + // { + // var _msg = "添加成功!"; + // return RedirectToAction("Refresh", "Home", new { msg = _msg }); + // } + // else + // { + + // ModelState.AddModelError("error", result.Msg); + + // } + //} + //return View("WHS025C", model); + } + public async Task WHS025USaveAsync(WorkingStandardWorkTime model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _whsApi.PutWorkingStandardWorkTime(model.WorkingStandardID, 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("WHS025U", model); + } + + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWorkingLinesbyUnitAsync(string id) + { + // var result = await _whsApi.GetWorkingLinesbyUnit(id); + var result = await _whsApi.GetWorkingLinesbyMultiUnit(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 }); + } + + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWorkingStationsbyUnitAsync(string id) + { + var result = await _whsApi.GetWorkingStationsbyUnit(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 }); + } + + + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWorkingStandardWorkTimesAsync() + { + var result = await _whsApi.GetWorkingStandardWorkTimes(); + + if (result.DataTotal > 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + + return Json(new Table() { count = 0, data = null }); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWorkingStandardWorkTimes2Async(string u, int l, string i, int page = 0, int limit = 10) + { + if (l == 0) + { + l = -99; + } + + if (string.IsNullOrEmpty(i)) + { + i = "Null"; + } + + if (string.IsNullOrEmpty(u)) + { + u = "Null"; + } + + + var result = await _whsApi.GetWorkingStandardWorkTimesbyQuery(u, l, i, page, limit); + if (result.DataTotal > 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + + return Json(new Table() { count = 0, data = null }); + } + + private async Task GetFactoryUnitsListbyWH005(string Types) + { + var result = await _basApi.GetFactoryUnits(); + + var UnitItems = new List(); + if (Types == "all") + { + UnitItems.Add(new SelectListItem("全部", "0")); + } + for (int i = 0; i < result.Count; i++) + { + UnitItems.Add(new SelectListItem(result[i].UnitName, result[i].UnitNo.ToString())); + } + ViewBag.FactoryUnit = UnitItems; + } + + + + /// + ///標準工時批次Excel匯入 + /// + /// + /// + [HttpPost] + public async Task WHS025ExcelUpload(IFormFile Uploader) + { + + //通過上傳檔案流初始化Mapper + using (var workbook = new XLWorkbook(Uploader.OpenReadStream())) + { + try + { + List barcodeGroup = new List(); + + string Msg = string.Empty; + var worksheet = workbook.Worksheet(1); + // 定義資料起始/結束 Cell + var firstCell = worksheet.FirstCellUsed(); + var lastCell = worksheet.LastCellUsed(); + + // 使用資料起始/結束 Cell,來定義出一個資料範圍 + var data = worksheet.Range(firstCell.Address, lastCell.Address); + var rowCount = data.RowCount(); + var columnCount = data.ColumnCount(); + for (int i = 2; i <= rowCount; i++) + { + string seq = data.Cell(i, 2).Value.ToString(); + int sequence; + bool isNumeric = int.TryParse(seq, out sequence); + + if (!isNumeric) + { + return Json(new Result() { success = false, msg = "Group順序" + seq + "請輸入數字", data = null }); + + } + + barcodeGroup.Add(new BarcodeGroupDto + { + WipNo = data.Cell(i, 1).Value.ToString(), + Sequence = int.Parse(data.Cell(i, 2).Value.ToString()), + BarcodeNo = data.Cell(i, 3).Value.ToString(), + }); + + + //#region 判斷序號是否在工單區間內 + //var WipBarcode = await _pcbApi.GetWipBarcodesCheckInRange(data.Cell(i, 1).Value.ToString(), data.Cell(i, 3).Value.ToString()); + //if (WipBarcode.Count == 0) + //{ + // return Json(new Result() { success = false, msg = "生產序號" + data.Cell(i, 3).Value.ToString() + "不在工單" + data.Cell(i, 1).Value.ToString() + "區間內", data = null }); + //} + //#endregion + + //#region 判斷序號在Excel中是否重覆 + //var duplicateBarcodeNos = barcodeGroup.GroupBy(x => x.BarcodeNo) + // .Where(group => group.Count() > 1) + // .Select(group => group.Key); + //if (duplicateBarcodeNos.Any()) + //{ + + // return Json(new Result() { success = false, msg = "Excel檔案內的生產序號" + string.Join(", ", duplicateBarcodeNos) + "重覆", data = null }); + //} + //#endregion + //#region 判斷序號是否已綁定群組 + + //var BarCodeinto = await _pcsApi.GetBarcodeInfoesByNo(data.Cell(i, 3).Value.ToString()); + //if (BarCodeinto.Count() > 0) + //{ + // var BarcodeGroup = await _pcsApi.GetBarcodeGroupByBarCodeID(BarCodeinto.Select(s => s.BarcodeID).FirstOrDefault()); + // if (BarcodeGroup.Count() > 0) + // { + // return Json(new Result() { success = false, msg = "生產序號" + data.Cell(i, 3).Value.ToString() + "已綁定群組" + BarcodeGroup.Select(s => s.GroupID).FirstOrDefault() + ",不可重覆綁定", data = null }); + // } + //} + + + //#endregion + } + //#region 檢查工單是否全部一致 + //if (barcodeGroup.Select(s => s.WipNo).Distinct().Count() != 1) + //{ + // return Json(new Result() { success = false, msg = "Excel檔案內的工單不一致不可匯入", data = null }); + + //} + //#endregion + + + + //foreach (var item in barcodeGroup.Select(s => s.Sequence).Distinct()) + //{ + // foreach (var item1 in barcodeGroup.Where(w => w.Sequence == item)) + // { + + // #region 產生BarcodeInfo + // var barcodeInfo = new BarcodeInfo + // { + // BarcodeNo = item1.BarcodeNo, + // StationID = -1, + // LocationID = -1, + // WipID = -1, + // RuleStatus = "P", + // StatusID = -1, + // SysType = "S", + // StatusNo = "-1", + // CreateUserID = GetLogInUserID() + // }; + + // var PostResult = await _pcsApi.PostBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); + + // #endregion + // } + // #region 綁定Group + + // var barcodeinfo = await _pcbApi.PostDapperByListBarcodeNO(JsonConvert.SerializeObject(barcodeGroup.Where(w => w.Sequence == item).Select(s => s.BarcodeNo))); + // int UserID = GetLogInUserID(); + + // List barcodeGroups = barcodeinfo + // .Select((b, index) => new BarcodeGroup + // { + // BarcodeID = b.BarcodeID, + // GroupID = 0, + // Sequence = item, + // CreateUserID = UserID, + // WipNo = barcodeGroup.Select(s => s.WipNo).FirstOrDefault() + // }) + // .ToList(); + + // var BarCodeGroup = await _pcbApi.PostBarcodeGroupList(JsonConvert.SerializeObject(barcodeGroups)); + + + // #endregion + + + //} + + return Json(new Result() { success = true, msg = "綁定成功", data = null }); + + + } + catch (Exception ex) + { + return Json(new { data = ex.Message, success = false }); + } + } + + + + //将資料Json化并传到前台视图 + return Json(new { data = "", success = true }); + + } + + + + #endregion } } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs index abf5bcd..f7834a9 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IWHS.cs @@ -680,5 +680,211 @@ namespace AMESCoreStudio.Web ITask> GetStationWorkingHour2(string id); #endregion + + #region WHS022 報工生產單位別維護 + + /// + /// 新增報工生產單位別 + /// + /// + [WebApiClient.Attributes.HttpPost("api/WorkingUnits")] + ITask> PostWorkingUnit([FromBody, RawJsonContent] string model); + + /// + /// 更新報工生產單位別 + /// + /// + [WebApiClient.Attributes.HttpPut("api/WorkingUnits/{id}")] + ITask> PutWorkingUnit(int id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除報工生產單位別 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/WorkingUnits/{id}")] + ITask> DeleteWorkingUnit(int id); + + /// + /// 根據ID獲取指定報工生產單位別查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingUnits/{id}")] + ITask> GetWorkingUnit(int id); + /// + /// 獲取報工生產單位別查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingUnits")] + ITask> GetWorkingUnits(int page = 0, int limit = 10); + + #endregion + + #region WHS023 報工線別基本資料維護 + + /// + /// 根據ID獲取指定報工生產單位別查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingUnits/byALL")] + ITask> GetWorkingUnits(); + /// + + + /// + /// 新增報工線別基本資料 + /// + /// + [WebApiClient.Attributes.HttpPost("api/WorkingLines")] + ITask> PostWorkingLine([FromBody, RawJsonContent] string model); + + /// + /// 更新報工線別基本資料 + /// + /// + [WebApiClient.Attributes.HttpPut("api/WorkingLines/{id}")] + ITask> PutWorkingLine(int id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除報工線別基本資料 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/WorkingLines/{id}")] + ITask> DeleteWorkingLine(int id); + + /// + /// 根據ID獲取指定報工線別基本資料查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingLines/{id}")] + ITask> GetWorkingLine(int id); + /// + /// 獲取報工線別基本資料查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingLines")] + ITask> GetWorkingLines(int page = 0, int limit = 10); + + + + /// + /// 根据單位獲取線別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingLines/Unit/{id}")] + ITask> GetWorkingLinesbyUnit(string id); + + + + /// + /// 根据單位獲取線別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingLines/MultiUnit/{id}")] + ITask> GetWorkingLinesbyMultiUnit(string id); + + + #endregion + + #region WHS024 報工工作站基本資料 + /// + /// 新增報工線別基本資料 + /// + /// + [WebApiClient.Attributes.HttpPost("api/WorkingStations")] + ITask> PostWorkingStation([FromBody, RawJsonContent] string model); + + /// + /// 更新報工線別基本資料 + /// + /// + [WebApiClient.Attributes.HttpPut("api/WorkingStations/{id}")] + ITask> PutWorkingStation(int id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除報工線別基本資料 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/WorkingStations/{id}")] + ITask> DeleteWorkingStation(int id); + + /// + /// 根據ID獲取指定報工線別基本資料查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingStations/{id}")] + ITask> GetWorkingStation(int id); + /// + /// 獲取報工線別基本資料查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingStations")] + ITask> GetWorkingStations(int page = 0, int limit = 10); + + + /// + /// 獲取報工線別基本資料查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingStations/Unit/{id}")] + ITask> GetWorkingStationsbyUnit(string id); + + + + + /// + /// 獲取報工線別基本資料查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingStations/MultiUnit/{id}")] + ITask> GetWorkingStationsbyMultiUnit(string id); + + + + #endregion + + #region WHS025 標準工時資料 + /// + /// 新增報工標準工時資料檔 + /// + /// + [WebApiClient.Attributes.HttpPost("api/WorkingStandardWorkTimes")] + ITask> PostWorkingStandardWorkTime([FromBody, RawJsonContent] string model); + + /// + /// 更新報工標準工時資料檔 + /// + /// + [WebApiClient.Attributes.HttpPut("api/WorkingStandardWorkTimes/{id}")] + ITask> PutWorkingStandardWorkTime(int id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除報工標準工時資料檔 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/WorkingStandardWorkTimes/{id}")] + ITask> DeleteWorkingStandardWorkTime(int id); + + /// + /// 根據ID獲取指定報工標準工時資料檔查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingStandardWorkTimes/{id}")] + ITask> GetWorkingStandardWorkTime(int id); + /// + /// 獲取報工標準工時資料檔查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingStandardWorkTimes")] + ITask> GetWorkingStandardWorkTimes(int page = 0, int limit = 10); + + + /// + /// 獲取報工標準工時資料檔查詢資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WorkingStandardWorkTimes/WHS025/{u}/{l}/{i}")] + ITask> GetWorkingStandardWorkTimesbyQuery(string u, int l, string i,int page = 0, int limit = 10); + + #endregion } } diff --git a/AMESCoreStudio.Web/ViewModels/WHS/WHS025ViewModel.cs b/AMESCoreStudio.Web/ViewModels/WHS/WHS025ViewModel.cs new file mode 100644 index 0000000..68f2e36 --- /dev/null +++ b/AMESCoreStudio.Web/ViewModels/WHS/WHS025ViewModel.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using System.Runtime.Serialization; + + +#nullable disable + +namespace AMESCoreStudio.Web.ViewModels.WHS +{ + public partial class WHS025ViewModel + { + public int WorkingStandardID { get; set; } + + public string WorkingUnitNo { get; set; } + + public List WorkingLineIDs { get; set; } + public int WorkingLineID { get; set; } + + public int WorkingStationID { get; set; } + + public string UnitNo { get; set; } + + public string ItemNo { get; set; } + + public string Side { get; set; } + + public int OpCnt { get; set; } + + public int Ct { get; set; } + + public string StationID { get; set; } + + public int MachineCnt { get; set; } + + public string Remark { get; set; } + + public int CreateUserID { get; set; } + + public DateTime CreateDate { get; set; } + + public int UpdateUserID { get; set; } + + public DateTime UpdateDate { get; set; } + + // 顯示用欄位 + public string WorkingUnitName { get; set; } + + public string WorkingLineName { get; set; } + + public string WorkingStationName { get; set; } + + public string UnitName { get; set; } + } + +} diff --git a/AMESCoreStudio.Web/Views/WHS/WHS022.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS022.cshtml new file mode 100644 index 0000000..b9ddfd4 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS022.cshtml @@ -0,0 +1,120 @@ +@{ + ViewData["Title"] = "報工生產單位維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/WHS/WHS022C.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS022C.cshtml new file mode 100644 index 0000000..f711902 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS022C.cshtml @@ -0,0 +1,59 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingUnit + + +@{ ViewData["Title"] = "WHS022C"; + 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/WHS022U.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS022U.cshtml new file mode 100644 index 0000000..235b129 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS022U.cshtml @@ -0,0 +1,62 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingUnit + + +@{ ViewData["Title"] = "WHS020U"; + 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/WHS023.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS023.cshtml new file mode 100644 index 0000000..ecac8fd --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS023.cshtml @@ -0,0 +1,142 @@ +@{ + ViewData["Title"] = "報工線別基本資料"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ +
+ +
+ +
+
+ +
+
+
+ +
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/WHS/WHS023C.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS023C.cshtml new file mode 100644 index 0000000..a110828 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS023C.cshtml @@ -0,0 +1,52 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingLine + + +@{ ViewData["Title"] = "WHS023C"; + 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/WHS023U.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS023U.cshtml new file mode 100644 index 0000000..bb074cb --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS023U.cshtml @@ -0,0 +1,57 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingLine + + +@{ ViewData["Title"] = "WHS023U"; + 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/WHS024.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS024.cshtml new file mode 100644 index 0000000..6211b9f --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS024.cshtml @@ -0,0 +1,150 @@ +@{ + ViewData["Title"] = "報工工作站基本資料"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ +
+ +
+ +
+
+ +
+
+
+ +
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/WHS/WHS024C.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS024C.cshtml new file mode 100644 index 0000000..91460c2 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS024C.cshtml @@ -0,0 +1,67 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingStation + + +@{ ViewData["Title"] = "WHS024C"; + 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/WHS024U.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS024U.cshtml new file mode 100644 index 0000000..79dd19e --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS024U.cshtml @@ -0,0 +1,72 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingStation + + +@{ ViewData["Title"] = "WHS024U"; + 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/WHS025.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS025.cshtml new file mode 100644 index 0000000..2d29728 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS025.cshtml @@ -0,0 +1,307 @@ +@{ + ViewData["Title"] = "標準工時資料維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
@ViewBag.Title
+
+
+
+
+
+ +
+ +
+ + +
+ + +
+
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+ + +
+
+
+
+
+@section Scripts{ + + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/WHS/WHS025C.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS025C.cshtml new file mode 100644 index 0000000..eb5bddf --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS025C.cshtml @@ -0,0 +1,230 @@ +@model AMESCoreStudio.Web.ViewModels.WHS.WHS025ViewModel + + +@{ ViewData["Title"] = "WHS025C"; + 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/WHS025U.cshtml b/AMESCoreStudio.Web/Views/WHS/WHS025U.cshtml new file mode 100644 index 0000000..a9a7910 --- /dev/null +++ b/AMESCoreStudio.Web/Views/WHS/WHS025U.cshtml @@ -0,0 +1,226 @@ +@model AMESCoreStudio.WebApi.Models.AMES.WorkingStandardWorkTime + +@{ ViewData["Title"] = "WHS025U"; + 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/WorkingLinesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingLinesController.cs new file mode 100644 index 0000000..dba8c43 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingLinesController.cs @@ -0,0 +1,269 @@ +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 WorkingLinesController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public WorkingLinesController(AMESContext context) + { + _context = context; + } + + /// + /// 获取全部報工線別基本資料 + /// + /// + [HttpGet] + public async Task> GetWorkingLines(int page = 0, int limit = 10) + { + IQueryable q = _context.WorkingLines; + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + return result; + } + + /// + /// 用ID获取该報工線別基本資料 + /// + /// + /// + [HttpGet("{id}")] + public async Task>> GetWorkingLine(int id) + { + + IQueryable q = _context.WorkingLines; + q = q.Where(p => p.WorkingLineID.Equals(id)); + var WorkingLine = await q.ToListAsync(); + + if (WorkingLine == null) + { + return NotFound(); + } + + return WorkingLine; + } + + + /// + /// 用生產單位获取该報工線別基本資料 + /// + /// 報工生產單位 + /// + [HttpGet("Unit/{id}")] + public async Task>> GetWorkingLines(string id) + { + IQueryable q = _context.WorkingLines; + + //var q = from q1 in _context.WorkingLines + // join q2 in _context.WorkingUnits on q1.WorkingUnitNo equals q2.WorkingUnitNo + // select new WorkingLine + // { + // WorkingLineID = q1.WorkingLineID, + // WorkingLineName = q1.WorkingLineName, + // WorkingUnitNo = q1.WorkingUnitNo, + // StatusNo = q1.StatusNo, + // CreateUserID = q1.CreateUserID, + // CreateDate = q1.CreateDate, + // UpdateDate = q1.UpdateDate, + // GetWorkingUnit = q2 + // }; + + if (id != "all") + { + q = q.Where(p => p.WorkingUnitNo.Equals(id)); + } + var WorkingLine = await q.ToListAsync(); + + if (WorkingLine == null) + { + return NotFound(); + } + + return WorkingLine; + } + + + + /// + /// 用生產單位获取该報工線別基本資料 + /// + /// 報工生產單位 + /// + [HttpGet("MultiUnit/{id}")] + public async Task>> GetWorkingLinesMulti(string id) + { + // IQueryable q = _context.WorkingLines; + + var q = from q1 in _context.WorkingLines + join q2 in _context.WorkingUnits on q1.WorkingUnitNo equals q2.WorkingUnitNo + select new + { + WorkingLineID = q1.WorkingLineID, + WorkingLineName = q1.WorkingLineName, + WorkingUnitNo = q1.WorkingUnitNo, + StatusNo = q1.StatusNo, + CreateUserID = q1.CreateUserID, + CreateDate = q1.CreateDate, + UpdateDate = q1.UpdateDate, + WorkingUnitName = q2.WorkingUnitName + }; + + if (id != "all") + { + q = q.Where(p => p.WorkingUnitNo.Equals(id)); + } + var WorkingLine = await q.ToListAsync(); + + if (WorkingLine == null) + { + return NotFound(); + } + + return WorkingLine; + } + + + + /// + /// 更新條報工線別基本資料 + /// + /// + /// + /// + [HttpPut("{id}")] + public async Task> PutWorkingLines(int id, [FromBody] WorkingLine WorkingLine) + { + ResultModel result = new ResultModel(); + if (id != WorkingLine.WorkingLineID) + { + result.Success = false; + result.Msg = "序號錯誤"; + return result; + } + WorkingLine.UpdateDate = DateTime.Now; + _context.Entry(WorkingLine).State = EntityState.Modified; + + try + { + + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + return result; + + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + return result; + //throw; + + } + } + + /// + /// 新增報工線別基本資料 + /// + /// + /// + [HttpPost] + public async Task> PostWorkingLines(WorkingLine WorkingLine) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + WorkingLine.WorkingLineID = helper.GetIDKey("WorkingLine_ID").Result; + WorkingLine.CreateDate = DateTime.Now; + WorkingLine.UpdateDate = DateTime.Now; + _context.WorkingLines.Add(WorkingLine); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (DbUpdateException ex) + { + + result.Success = false; + result.Msg = ex.InnerException.Message; + } + + return result; + } + /// + /// 停用/啟用報工線別基本資料 + /// + /// + /// + [HttpDelete("{id}")] + public async Task> DeleteWorkingLines(int id) + { + ResultModel result = new ResultModel(); + var workingunit = await _context.WorkingLines.Where(m => m.WorkingLineID == id).FirstOrDefaultAsync(); + if (workingunit == null) + { + result.Success = false; + result.Msg = "序號錯誤"; + return result; + } + ////// + var workingunitNew = new WorkingLine(); + workingunitNew = workingunit; + + _context.Entry(workingunitNew).State = EntityState.Modified; + + if (workingunit.StatusNo == "A") + workingunitNew.StatusNo = "S"; + else + workingunitNew.StatusNo = "A"; + workingunitNew.UpdateDate = DateTime.Now; + + + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + + } + + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStandardWorkTimeController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStandardWorkTimeController.cs new file mode 100644 index 0000000..85dd17a --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStandardWorkTimeController.cs @@ -0,0 +1,230 @@ +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 WorkingStandardWorkTimesController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public WorkingStandardWorkTimesController(AMESContext context) + { + _context = context; + } + + /// + /// 获取全部報工標準工時資料 + /// + /// + [HttpGet] + public async Task> GetWorkingStandardWorkTimes(int page = 0, int limit = 10) + { + IQueryable q = _context.WorkingStandardWorkTimes; + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + return result; + } + /// + /// 获取全部報工標準工時資料 + /// + /// + [HttpGet("byALL")] + public async Task>> GetWorkingStationALLs() + { + IQueryable q = _context.WorkingStandardWorkTimes; + q = q.OrderBy(p => p.WorkingStandardID); + var WorkingStandardWorkTimes = await q.ToListAsync(); + return WorkingStandardWorkTimes; + + } + /// + /// 用ID获取该報工標準工時資料 + /// + /// + /// + [HttpGet("{id}")] + public async Task>> GetWorkingStandardWorkTime(int id) + { + + IQueryable q = _context.WorkingStandardWorkTimes; + q = q.Where(p => p.WorkingStandardID.Equals(id)); + var WorkingStandardWorkTime = await q.ToListAsync(); + + if (WorkingStandardWorkTime == null) + { + return NotFound(); + } + + return WorkingStandardWorkTime; + } + + + /// + /// WHS025 + /// + /// + /// + /// + /// + // GET: api/StandardWorkTimes/5 + [HttpGet("WHS025/{u}/{l}/{i}")] + public async Task> GetWorkingStandardWorkTimebyQuery(string u, int l, string i, int page = 0, int limit = 10) + { + IQueryable q = _context.WorkingStandardWorkTimes; + ResultModel result = new ResultModel(); + + + if (u != "all") + { + q = q.Where(p => p.WorkingUnitNo.Equals(l)); + } + if (l > 0) + { + q = q.Where(p => p.WorkingLineID.Equals(l)); + } + if (i != "Null") + { + q = q.Where(p => p.ItemNo.Equals(i.ToUpper())); + } + + + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + + return result; + + + } + + + + /// + /// 更新條報工標準工時資料 + /// + /// + /// + /// + [HttpPut("{id}")] + public async Task> PutWorkingStandardWorkTimes(int id, [FromBody] WorkingStandardWorkTime WorkingStandardWorkTime) + { + ResultModel result = new ResultModel(); + if (id != WorkingStandardWorkTime.WorkingStandardID) + { + result.Success = false; + result.Msg = "ID錯誤"; + return result; + } + WorkingStandardWorkTime.UpdateDate = DateTime.Now; + _context.Entry(WorkingStandardWorkTime).State = EntityState.Modified; + + try + { + + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + return result; + + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + return result; + //throw; + + } + } + + /// + /// 新增報工標準工時資料 + /// + /// + /// + [HttpPost] + public async Task> PostWorkingStandardWorkTimes(WorkingStandardWorkTime WorkingStandardWorkTime) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + WorkingStandardWorkTime.WorkingStandardID = helper.GetIDKey("WorkingST_ID").Result; + WorkingStandardWorkTime.CreateDate = DateTime.Now; + WorkingStandardWorkTime.UpdateDate = DateTime.Now; + _context.WorkingStandardWorkTimes.Add(WorkingStandardWorkTime); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (DbUpdateException ex) + { + + result.Success = false; + result.Msg = ex.InnerException.Message; + } + + return result; + } + /// + /// 停用/啟用報工標準工時資料 + /// + /// + /// + [HttpDelete("{id}")] + public async Task> DeleteWorkingStandardWorkTimes(int id) + { + ResultModel result = new ResultModel(); + + var workingStandardWorkTime = await _context.WorkingStandardWorkTimes.FindAsync(id); + if (workingStandardWorkTime == null) + { + result.Success = false; + result.Msg = "ID不存在"; + return result; + } + + _context.WorkingStandardWorkTimes.Remove(workingStandardWorkTime); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + return result; + } + + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStandardWorkTimeLogController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStandardWorkTimeLogController.cs new file mode 100644 index 0000000..f2ef141 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStandardWorkTimeLogController.cs @@ -0,0 +1,194 @@ +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 +{ + /// + /// 報工標準工時資料log维护 + /// + [Route("api/[controller]")] + [ApiController] + public class WorkingStandardWorkTimeLogsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public WorkingStandardWorkTimeLogsController(AMESContext context) + { + _context = context; + } + + /// + /// 获取全部報工標準工時資料log + /// + /// + [HttpGet] + public async Task> GetWorkingStandardWorkTimeLogs(int page = 0, int limit = 10) + { + IQueryable q = _context.WorkingStandardWorkTimeLogs; + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + return result; + } + /// + /// 获取全部報工標準工時資料log + /// + /// + [HttpGet("byALL")] + public async Task>> GetWorkingStationALLs() + { + IQueryable q = _context.WorkingStandardWorkTimeLogs; + q = q.OrderBy(p => p.WorkingStandardID); + var WorkingStandardWorkTimeLogs = await q.ToListAsync(); + return WorkingStandardWorkTimeLogs; + + } + /// + /// 用ID获取该報工標準工時資料log + /// + /// + /// + [HttpGet("{id}")] + public async Task>> GetWorkingStandardWorkTimeLog(int id) + { + + IQueryable q = _context.WorkingStandardWorkTimeLogs; + q = q.Where(p => p.WorkingStandardID.Equals(id)); + var WorkingStandardWorkTimeLog = await q.ToListAsync(); + + if (WorkingStandardWorkTimeLog == null) + { + return NotFound(); + } + + return WorkingStandardWorkTimeLog; + } + + + /// + /// WHS025 + /// + /// + /// + /// + /// + // GET: api/StandardWorkTimes/5 + [HttpGet("WHS025/{u}/{l}/{i}")] + public async Task> GetWorkingStandardWorkTimeLogbyQuery(string u, int l, string i, int page = 0, int limit = 10) + { + IQueryable q = _context.WorkingStandardWorkTimeLogs; + ResultModel result = new ResultModel(); + q = q.Where(p => p.UnitNo.Equals(u)); + + if (u != "Null") + { + + } + + if (i != "Null") + { + q = q.Where(p => p.ItemNo.Contains(i.ToUpper())); + } + if (l > 0) + { + // q = q.Where(p => p.LineID.Equals(l)); + } + + + + var WorkingStandardWorkTimeLog = await q.ToListAsync(); + + if (WorkingStandardWorkTimeLog == null) + { + // return NotFound(); + result.Data = WorkingStandardWorkTimeLog; + result.DataTotal = 0; + } + foreach (var data in WorkingStandardWorkTimeLog) + { + // data.LineInfo = _context.LineInfoes.Find(data.LineID); + // data.Stations = _context.StationWorkingHours.Find(data.StationID); + } + + return result; + } + + + /// + /// 新增報工標準工時資料log + /// + /// + /// + [HttpPost] + public async Task> PostWorkingStandardWorkTimeLogs(WorkingStandardWorkTimeLog WorkingStandardWorkTimeLog) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + WorkingStandardWorkTimeLog.WorkingStandardID = helper.GetIDKey("WorkingStandardWorkTimeLog_ID").Result; + WorkingStandardWorkTimeLog.CreateDate = DateTime.Now; + _context.WorkingStandardWorkTimeLogs.Add(WorkingStandardWorkTimeLog); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (DbUpdateException ex) + { + + result.Success = false; + result.Msg = ex.InnerException.Message; + } + + return result; + } + /// + /// 停用/啟用報工標準工時資料log + /// + /// + /// + [HttpDelete("{id}")] + public async Task> DeleteWorkingStandardWorkTimeLogs(int id) + { + ResultModel result = new ResultModel(); + + var standardWorkTime = await _context.StandardWorkTimes.FindAsync(id); + if (standardWorkTime == null) + { + result.Success = false; + result.Msg = "序號不存在"; + return result; + } + + _context.StandardWorkTimes.Remove(standardWorkTime); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + return result; + + } + + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStationsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStationsController.cs new file mode 100644 index 0000000..b66abdd --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingStationsController.cs @@ -0,0 +1,281 @@ +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 WorkingStationsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public WorkingStationsController(AMESContext context) + { + _context = context; + } + + /// + /// 获取全部報工生產單位別 + /// + /// + [HttpGet] + public async Task> GetWorkingStations(int page = 0, int limit = 10) + { + IQueryable q = _context.WorkingStations; + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + return result; + } + /// + /// 获取全部報工生產單位別 + /// + /// + [HttpGet("byALL")] + public async Task>> GetWorkingStationALLs() + { + IQueryable q = _context.WorkingStations; + q = q.OrderBy(p => p.WorkingStationID); + var WorkingStations = await q.ToListAsync(); + return WorkingStations; + + } + /// + /// 用ID获取该報工生產單位別 + /// + /// + /// + [HttpGet("{id}")] + public async Task>> GetWorkingStation(int id) + { + + IQueryable q = _context.WorkingStations; + q = q.Where(p => p.WorkingStationID.Equals(id)); + var WorkingStation = await q.ToListAsync(); + + if (WorkingStation == null) + { + return NotFound(); + } + + return WorkingStation; + } + + + /// + /// 用生產單位获取该報工線別基本資料 + /// + /// 報工生產單位 + /// + [HttpGet("Unit/{id}")] + public async Task>> GetWorkingStations(string id) + { + try + { + IQueryable q = _context.WorkingStations; + if (id != "all") + { + q = q.Where(p => p.WorkingUnitNo.Equals(id)); + } + var WorkingStation = await q.ToListAsync(); + + if (WorkingStation == null) + { + return NotFound(); + } + return WorkingStation; + } + catch (Exception ex) + { + var aa= ex.InnerException.Message; + + throw; + + } + + + } + + + + /// + /// 用用生產單位获取该報工線別基本資料 + /// + /// 報工生產單位 + /// + [HttpGet("MultiUnit/{id}")] + public async Task>> GetWorkingStationsMulti(string id) + { + // IQueryable q = _context.WorkingLines; + + var q = from q1 in _context.WorkingStations + join q2 in _context.WorkingUnits on q1.WorkingUnitNo equals q2.WorkingUnitNo + select new + { + WorkingStationID = q1.WorkingStationID, + WorkingStationName = q1.WorkingStationName, + WorkingStationDesc = q1.WorkingStationDesc, + WorkingUnitNo = q1.WorkingUnitNo, + TypeNo = q1.TypeNo, + StatusNo = q1.StatusNo, + CreateUserID = q1.CreateUserID, + CreateDate = q1.CreateDate, + UpdateDate = q1.UpdateDate, + WorkingUnitName = q2.WorkingUnitName + }; + + if (id != "all") + { + q = q.Where(p => p.WorkingUnitNo.Equals(id)); + } + var WorkingLine = await q.ToListAsync(); + + if (WorkingLine == null) + { + return NotFound(); + } + + return WorkingLine; + } + + + + + + /// + /// 更新條報工生產單位別 + /// + /// + /// + /// + [HttpPut("{id}")] + public async Task> PutWorkingStations(int id, [FromBody] WorkingStation WorkingStation) + { + ResultModel result = new ResultModel(); + if (id != WorkingStation.WorkingStationID) + { + result.Success = false; + result.Msg = "序號錯誤"; + return result; + } + WorkingStation.UpdateDate = DateTime.Now; + _context.Entry(WorkingStation).State = EntityState.Modified; + + try + { + + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + return result; + + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + return result; + //throw; + + } + } + + /// + /// 新增報工生產單位別 + /// + /// + /// + [HttpPost] + public async Task> PostWorkingStations(WorkingStation WorkingStation) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + WorkingStation.WorkingStationID = helper.GetIDKey("WorkingStation_ID").Result; + WorkingStation.CreateDate = DateTime.Now; + WorkingStation.UpdateDate = DateTime.Now; + _context.WorkingStations.Add(WorkingStation); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (DbUpdateException ex) + { + + result.Success = false; + result.Msg = ex.InnerException.Message; + } + + return result; + } + /// + /// 停用/啟用報工生產單位別 + /// + /// + /// + [HttpDelete("{id}")] + public async Task> DeleteWorkingStations(int id) + { + ResultModel result = new ResultModel(); + var WorkingStation = await _context.WorkingStations.Where(m => m.WorkingStationID == id).FirstOrDefaultAsync(); + if (WorkingStation == null) + { + result.Success = false; + result.Msg = "序號錯誤"; + return result; + } + ////// + var WorkingStationNew = new WorkingStation(); + WorkingStationNew = WorkingStation; + + _context.Entry(WorkingStationNew).State = EntityState.Modified; + + if (WorkingStation.StatusNo == "A") + WorkingStationNew.StatusNo = "S"; + else + WorkingStationNew.StatusNo = "A"; + WorkingStationNew.UpdateDate = DateTime.Now; + + + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + + } + + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WorkingUnitsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingUnitsController.cs new file mode 100644 index 0000000..cca0f25 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WorkingUnitsController.cs @@ -0,0 +1,201 @@ +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 WorkingUnitsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public WorkingUnitsController(AMESContext context) + { + _context = context; + } + + /// + /// 获取全部報工生產單位別 + /// + /// + [HttpGet] + public async Task> GetWorkingUnits(int page = 0, int limit = 10) + { + IQueryable q = _context.WorkingUnits; + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + result.Data = await q.ToListAsync(); + return result; + } + /// + /// 获取全部報工生產單位別 + /// + /// + [HttpGet("byALL")] + public async Task>> GetWorkingStationALLs() + { + IQueryable q = _context.WorkingUnits; + q = q.OrderBy(p => p.WorkingUnitID); + var WorkingUnits = await q.ToListAsync(); + return WorkingUnits; + + } + /// + /// 用ID获取该報工生產單位別 + /// + /// + /// + [HttpGet("{id}")] + public async Task>> GetWorkingUnit(int id) + { + + IQueryable q = _context.WorkingUnits; + q = q.Where(p => p.WorkingUnitID.Equals(id)); + var WorkingUnit = await q.ToListAsync(); + + if (WorkingUnit == null) + { + return NotFound(); + } + + return WorkingUnit; + } + + + /// + /// 更新條報工生產單位別 + /// + /// + /// + /// + [HttpPut("{id}")] + public async Task> PutWorkingUnits(int id, [FromBody] WorkingUnit WorkingUnit) + { + ResultModel result = new ResultModel(); + if (id != WorkingUnit.WorkingUnitID) + { + result.Success = false; + result.Msg = "序號錯誤"; + return result; + } + WorkingUnit.UpdateDate = DateTime.Now; + _context.Entry(WorkingUnit).State = EntityState.Modified; + + try + { + + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + return result; + + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + return result; + //throw; + + } + } + + /// + /// 新增報工生產單位別 + /// + /// + /// + [HttpPost] + public async Task> PostWorkingUnits(WorkingUnit WorkingUnit) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + WorkingUnit.WorkingUnitID = helper.GetIDKey("WorkingUnit_ID").Result; + WorkingUnit.CreateDate = DateTime.Now; + WorkingUnit.UpdateDate = DateTime.Now; + _context.WorkingUnits.Add(WorkingUnit); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (DbUpdateException ex) + { + + result.Success = false; + result.Msg = ex.InnerException.Message; + } + + return result; + } + /// + /// 停用/啟用報工生產單位別 + /// + /// + /// + [HttpDelete("{id}")] + public async Task> DeleteWorkingUnits(int id) + { + ResultModel result = new ResultModel(); + var workingunit = await _context.WorkingUnits.Where(m => m.WorkingUnitID == id).FirstOrDefaultAsync(); + if (workingunit == null) + { + result.Success = false; + result.Msg = "序號錯誤"; + return result; + } + ////// + var workingunitNew = new WorkingUnit(); + workingunitNew = workingunit; + + _context.Entry(workingunitNew).State = EntityState.Modified; + + if (workingunit.StatusNo == "A") + workingunitNew.StatusNo = "S"; + else + workingunitNew.StatusNo = "A"; + workingunitNew.UpdateDate = DateTime.Now; + + + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + + } + + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/WorkingLine.cs b/AMESCoreStudio.WebApi/Models/AMES/WorkingLine.cs new file mode 100644 index 0000000..53e1dad --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/WorkingLine.cs @@ -0,0 +1,78 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 報工線別基本資料 + /// + [Table("WORKING_LINE", Schema = "JHAMES")] + public class WorkingLine + { + + + /// + /// 報工線別代碼 + /// + [Key] + [Column("WORKING_LINE_ID")] + [DataMember] + [Display(Name = "報工線別代碼")] + public int WorkingLineID { get; set; } + + /// + /// 報工線別名稱 + /// + [Column("WORKING_LINE_NAME")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工線別名稱")] + public string WorkingLineName { get; set; } + /// + /// 報工生產單位代碼 + /// + [Column("WORKING_UNIT_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工生產單位代碼")] + public string WorkingUnitNo { get; set; } + /// + /// 狀態 + /// + [Column("STATUS_NO")] + [DataMember] + [Display(Name = "狀態")] + public string StatusNo { get; set; } = "A"; + /// + /// 建立者 + /// + [Column("CREATE_USERID")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "建立者")] + public int CreateUserID { get; set; } + /// + /// 建立日期 + /// + [Column("CREATE_DATE")] + [DataMember] + [Display(Name = "建立日期")] + public DateTime CreateDate { get; set; } + /// + /// 修改日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + [Display(Name = "修改日期")] + public DateTime UpdateDate { get; set; } + + ///// + ///// 生產制程單位 + ///// + //[ForeignKey("WorkingUnitNo")] + //[DataMember] + //public virtual WorkingUnit GetWorkingUnit { get; set; } + + } +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Models/AMES/WorkingStandardWorkTime.cs b/AMESCoreStudio.WebApi/Models/AMES/WorkingStandardWorkTime.cs new file mode 100644 index 0000000..f8f8209 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/WorkingStandardWorkTime.cs @@ -0,0 +1,150 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 報工標準工時資料檔 + /// + [Table("WORKING_STANDARD_WORKTIME", Schema = "JHAMES")] + public class WorkingStandardWorkTime + { + /// + /// 報工標準工時ID + /// + [Key] + [Column("WORKING_STANDARD_ID")] + [DataMember] + [Display(Name = "報工標準工時ID")] + public int WorkingStandardID { get; set; } + + /// + /// 報工生產單位 + /// + [Column("WORKING_UNIT_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工生產單位")] + public string WorkingUnitNo { get; set; } + + /// + /// 報工線別ID + /// + [Column("WORKING_LINE_ID")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工線別ID")] + public int WorkingLineID { get; set; } + + /// + /// 報工站別ID + /// + [Column("WORKING_STATION_ID")] + [DataMember] + [Display(Name = "報工站別ID")] + public int WorkingStationID { get; set; } = -1; + + /// + /// 途程生產單位 + /// + [Column("UNIT_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "途程生產單位")] + public string UnitNo { get; set; } + + /// + /// 工程編號 + /// + [Column("ITEM_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "工程編號")] + public string ItemNo { get; set; } + + /// + /// 正背面 + /// + [Column("SIDE")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "正背面")] + public string Side { get; set; } + + /// + /// 標準人力 + /// + [Column("OP_CNT")] + [DataMember] + [Display(Name = "標準人力")] + public int OpCnt { get; set; } = 0; + + /// + /// 標準工時(分) + /// + [Column("CT")] + [DataMember] + [Display(Name = "標準工時(分)")] + public int Ct { get; set; } = 0; + + /// + /// 對應途程站別ID + /// + [Column("STATION_ID")] + [DataMember] + [Display(Name = "對應途程站別ID")] + public string StationID { get; set; } = "N/A"; + + /// + /// 作業機台數 + /// + [Column("MACHINE_CNT")] + [DataMember] + [Display(Name = "作業機台數")] + public int MachineCnt { get; set; } = 0; + + /// + /// 備註 + /// + [Column("REMARK")] + [DataMember] + [Display(Name = "備註")] + public string Remark { get; set; } + + /// + /// 創建者 + /// + [Column("CREATE_USERID")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "創建者")] + public int CreateUserID { get; set; } + + /// + /// 創建日期 + /// + [Column("CREATE_DATE")] + [DataMember] + [Display(Name = "創建日期")] + public DateTime CreateDate { get; set; } + + /// + /// 更新者 + /// + [Column("UPDATE_USERID")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "更新者")] + public int UpdateUserID { get; set; } + + /// + /// 更新日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + [Display(Name = "更新日期")] + public DateTime UpdateDate { get; set; } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/WorkingStandardWorkTimeLog.cs b/AMESCoreStudio.WebApi/Models/AMES/WorkingStandardWorkTimeLog.cs new file mode 100644 index 0000000..c51e138 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/WorkingStandardWorkTimeLog.cs @@ -0,0 +1,152 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 報工標準工時資料檔 + /// + [Table("WORKING_STANDARD_WORKTIME_LOG", Schema = "JHAMES")] + public class WorkingStandardWorkTimeLog + { + /// + /// 報工標準工時 LOG ID + /// + [Key] + [Column("WORKING_STANDARD_LOG_ID")] + [DataMember] + [Display(Name = "報工標準工時 LOG ID")] + public int WorkingStandardLogID { get; set; } + + /// + /// 報工標準工時ID + /// + [Column("WORKING_STANDARD_ID")] + [DataMember] + [Display(Name = "報工標準工時ID")] + public int WorkingStandardID { get; set; } + + /// + /// 報工生產單位 + /// + [Column("WORKING_UNIT_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工生產單位")] + public string WorkingUnitNo { get; set; } + + /// + /// 報工線別ID + /// + [Column("WORKING_LINE_ID")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工線別ID")] + public int WorkingLineID { get; set; } + + /// + /// 報工站別ID + /// + [Column("WORKING_STATION_ID")] + [DataMember] + [Display(Name = "報工站別ID")] + public int WorkingStationID { get; set; } = -1; + + /// + /// 途程生產單位 + /// + [Column("UNIT_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "途程生產單位")] + public string UnitNo { get; set; } + + /// + /// 工程編號 + /// + [Column("ITEM_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "工程編號")] + public string ItemNo { get; set; } + + /// + /// 正背面 + /// + [Column("SIDE")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "正背面")] + public string Side { get; set; } + + /// + /// 標準人力 + /// + [Column("OP_CNT")] + [DataMember] + [Display(Name = "標準人力")] + public int OpCnt { get; set; } = 0; + + /// + /// 標準工時(分) + /// + [Column("CT")] + [DataMember] + [Display(Name = "標準工時(分)")] + public int Ct { get; set; } = 0; + + /// + /// 對應途程站別ID + /// + [Column("STATION_ID")] + [DataMember] + [Display(Name = "對應途程站別ID")] + public string StationID { get; set; } = "N/A"; + + /// + /// 作業機台數 + /// + [Column("MACHINE_CNT")] + [DataMember] + [Display(Name = "作業機台數")] + public int MachineCnt { get; set; } = 0; + + /// + /// 備註 + /// + [Column("REMARK")] + [DataMember] + [Display(Name = "備註")] + public string Remark { get; set; } + + /// + /// 創建者 + /// + [Column("CREATE_USERID")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "創建者")] + public int CreateUserID { get; set; } + + /// + /// 創建日期 + /// + [Column("CREATE_DATE")] + [DataMember] + [Display(Name = "創建日期")] + public DateTime CreateDate { get; set; } + + + /// + /// A:新增 U:刪除 D:修改 + /// + [Column("ACTION")] + [DataMember] + [Display(Name = "動作")] + public string Action { get; set; } + + + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/WorkingStation.cs b/AMESCoreStudio.WebApi/Models/AMES/WorkingStation.cs new file mode 100644 index 0000000..4b3c0a9 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/WorkingStation.cs @@ -0,0 +1,92 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 報工工作站基本資料 + /// + [Table("WORKING_STATIONS", Schema = "JHAMES")] + public class WorkingStation + { + /// + /// 報工工作站ID + /// + [Key] + [Column("WORKING_STATION_ID")] + [DataMember] + [Display(Name = "報工工作站ID")] + public int WorkingStationID { get; set; } + + /// + /// 報工工作站名稱 + /// + [Column("WORKING_STATION_NAME")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工工作站名稱")] + public string WorkingStationName { get; set; } + /// + /// 報工工作站敘述 + /// + [Column("WORKING_STATION_DESC")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工工作站敘述")] + public string WorkingStationDesc { get; set; } + /// + /// 報工生產單位代碼 + /// + [Column("WORKING_UNIT_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工生產單位代碼")] + public string WorkingUnitNo { get; set; } + /// + /// SAP工時類別 + /// + [Column("TYPE_NO")] + [DataMember] + [Display(Name = "SAP工時類別")] + public string TypeNo { get; set; } + + /// + /// 狀態 + /// + [Column("STATUS_NO")] + [DataMember] + [Display(Name = "狀態")] + public string StatusNo { get; set; } = "A"; + /// + /// 建立者 + /// + [Column("CREATE_USERID")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "建立者")] + public int CreateUserID { get; set; } + /// + /// 建立日期 + /// + [Column("CREATE_DATE")] + [DataMember] + [Display(Name = "建立日期")] + public DateTime CreateDate { get; set; } + /// + /// 修改日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + [Display(Name = "修改日期")] + public DateTime UpdateDate { get; set; } + + ///// + ///// 生產制程單位 + ///// + //[ForeignKey("WorkingUnitNo")] + //[DataMember] + //public virtual WorkingUnit GetWorkingUnit { get; set; } + + } +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Models/AMES/WorkingUnit.cs b/AMESCoreStudio.WebApi/Models/AMES/WorkingUnit.cs new file mode 100644 index 0000000..73f6bb3 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/WorkingUnit.cs @@ -0,0 +1,75 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; +namespace AMESCoreStudio.WebApi.Models.AMES + {/// + /// 報工生產單位別 + /// + [Table("WORKING_UNIT", Schema = "JHAMES")] + public class WorkingUnit + { + /// + /// 報工生產單位ID + /// + [Key] + [Column("WORKING_UNIT_ID")] + [DataMember] + [Display(Name = "報工生產單位ID")] + public int WorkingUnitID { get; set; } + + /// + /// 報工生產單位代碼 + /// + [Column("WORKING_UNIT_NO")] + [DataMember] + [Display(Name = "報工生產單位代碼")] + public string WorkingUnitNo { get; set; } + /// + /// 途程生產單位代碼 + /// + [Column("UNIT_NO")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "途程生產單位代碼")] + public string UnitNo { get; set; } + + /// + /// 報工生產單位名稱 + /// + [Column("WORKING_UNIT_NAME")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "報工生產單位名稱")] + public string WorkingUnitName { get; set; } + /// + /// 狀態 + /// + [Column("STATUS_NO")] + [DataMember] + [Display(Name = "狀態")] + public string StatusNo { get; set; } = "A"; + /// + /// 建立者 + /// + [Column("CREATE_USERID")] + [DataMember] + [Required(ErrorMessage = "{0} 不能空白")] + [Display(Name = "建立者")] + public int CreateUserID { get; set; } + /// + /// 建立日期 + /// + [Column("CREATE_DATE")] + [DataMember] + [Display(Name = "建立日期")] + public DateTime CreateDate { get; set; } + /// + /// 修改日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + [Display(Name = "修改日期")] + public DateTime UpdateDate { get; set; } + } +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index a4438f6..f2c8809 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -1006,6 +1006,31 @@ namespace AMESCoreStudio.WebApi ///
public virtual DbSet SolderPasteSerials { get; set; } + /// + ///報工生產單位別 + /// + public virtual DbSet WorkingUnits { get; set; } + + /// + ///報工線別基本資料 + /// + public virtual DbSet WorkingLines { get; set; } + + /// + ///報工工作站基本資料 + /// + public virtual DbSet WorkingStations { get; set; } + + /// + ///報工標準工時資料檔 + /// + public virtual DbSet WorkingStandardWorkTimes { get; set; } + + /// + ///報工標準工時資料檔log + /// + public virtual DbSet WorkingStandardWorkTimeLogs { get; set; } + }