diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index d1a2ab4b..6738d9c2 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -3984,16 +3984,45 @@ namespace AMESCoreStudio.Web.Controllers #region PCS005 工單資料查詢 public async Task PCS005(string id) { - if (id != null) + string[] param = id.Split('_'); + if (param[0] != null && param[0] != "") { - await GetFactoryUnit(id); - ViewBag.UnitNo = id; + await GetFactoryUnit(param[0]); + ViewBag.UnitNo = param[0]; } else { await GetFactoryUnit(); } + if (param[1] != null && param[1] == "OC") + { + if (Request.Cookies["_AMESCookie"] != null) + { + var userID = ""; + HttpContext.Request.Cookies.TryGetValue("UserID", out userID); + if (userID != null) + { + if (int.Parse(userID.ToString()) >= 0) + { + int user_id = int.Parse(userID.ToString()); + var user_info = await _sysApi.GetUserData(user_id); + + if (user_info.DataTotal > 0) + { + foreach (var item in user_info.Data) + { + JObject jo = JObject.Parse(item.ToString()); + string factoryNo = jo["factoryNo"].ToString(); + ViewBag.UserFactory = factoryNo; + } + } + } + } + + } + } + //await GetFactoryUnit(); return View(); } @@ -4001,24 +4030,36 @@ namespace AMESCoreStudio.Web.Controllers /// /// PCS005 Query /// - /// 生產單位 + /// 生產單位 /// 工單號碼 /// 料號 + /// 廠別 /// - public async Task PCS005QueryAsync(string unitno, string wipNo, string itemNo, int page = 0, int limit = 10) + public async Task PCS005QueryAsync(string unitNo, string wipNo, string itemNo, string factoryNo, int page = 0, int limit = 10) { - if (unitno == null) + string[] param = Request.Path.ToString().Replace("/PCS/PCS005Query/", "").Split('_'); + if (param[0] != null && param[0] != "") { - string unit_no = Request.Path.ToString().Replace("/PCS/PCS005Query/", ""); - if (unit_no != "") - { - unitno = unit_no; - } + unitNo = param[0]; + } + if (param[1] != null && param[1] != "") + { + wipNo = param[1]; + } + if (param[2] != null && param[2] != "") + { + itemNo = param[2]; + } + if (param[3] != null && param[3] != "") + { + factoryNo = param[3]; } - IResultModel result = await _pcsApi.GetWipInfoSelectParameter(unitno: unitno + + IResultModel result = await _pcsApi.GetWipInfoSelectParameter(unitno: unitNo , wipno: wipNo , itemno: itemNo + , factoryno: factoryNo , page: page , limit: limit); diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 17322df9..3ee5850a 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -90,7 +90,7 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/WipInfos/GetWipInfoSelectParameter")] //ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null); ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null, int lineid = 0 - , string itemno = null, DateTime? date_str = null, DateTime? date_end = null, string wipType = null, int page = 0, int limit = 10); + , string itemno = null, DateTime? date_str = null, DateTime? date_end = null, string wipType = null, string factoryno = null, int page = 0, int limit = 10); /// /// 查詢工單基本資料+是否已過站 diff --git a/AMESCoreStudio.Web/HttpApis/ISYS.cs b/AMESCoreStudio.Web/HttpApis/ISYS.cs index 88a21eae..b352bd3a 100644 --- a/AMESCoreStudio.Web/HttpApis/ISYS.cs +++ b/AMESCoreStudio.Web/HttpApis/ISYS.cs @@ -349,6 +349,13 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/UserInfoes/{id}")] ITask> GetUserInfo(int id); + /// + /// 根據ID獲取指定用户關聯資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/UserInfoes/GetUserData")] + ITask> GetUserData(int id); + /// /// 獲取用户資料 /// diff --git a/AMESCoreStudio.Web/Views/PCS/PCS005.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS005.cshtml index be206151..5dede873 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS005.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS005.cshtml @@ -47,6 +47,7 @@ + @@ -218,7 +219,14 @@ //} //]; //基本数据表格 - var table = hg.table.datatable('query', '工單資料查詢', '/PCS/PCS005Query/' + unitNo.value, {}, tableCols, "", true, 'full-100', ['filter', 'print', 'exports']); + //alert(factoryNo.value); + //alert(unitNo.value); + //alert(wipNo.value); + //alert(itemNo.value); + var param = unitNo.value + '_' + wipNo.value + '_' + itemNo.value + '_' + factoryNo.value; + //alert(param); + + var table = hg.table.datatable('query', '工單資料查詢', '/PCS/PCS005Query/' + param, {}, tableCols, "", true, 'full-100', ['filter', 'print', 'exports']); $(document).off('mousedown', '.layui-table-grid-down'). on('mousedown', '.layui-table-grid-down', function (event) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index d4e44576..79ac52cc 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -373,7 +373,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES itemNo = q2.ItemNO, lineDesc = q3.LineDesc, unitName = q4.UnitName, - wipType = q1.WipType + wipType = q1.WipType, + factoryNo=q1.WerksNO }; @@ -413,6 +414,11 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES q = q.Where(w => w.wipType == value.wipType); } + if (!string.IsNullOrWhiteSpace(value.factoryno)) + { + q = q.Where(w => w.factoryNo == value.factoryno); + } + // 紀錄筆數 result.DataTotal = q.Count(); diff --git a/AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs index eb4e8778..b0f9420d 100644 --- a/AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs @@ -68,12 +68,48 @@ namespace AMESCoreStudio.WebApi.Controllers.SYS } /// - /// + /// 查詢用戶數據 /// /// /// - // GET: api/UserInfoes/5 - [HttpGet("{id}")] + [Route("[action]")] + [HttpGet] + public async Task> GetUserData(int id) + { + ResultModel result = new ResultModel(); + var q = from q1 in _context.UserInfoes + join q2 in _context.FactoryInfos on q1.FactoryID equals q2.FactoryID + select new + { + q1.UserID, + q1.UserName, + q2.FactoryNo + }; + + //紀錄筆數 + result.DataTotal = q.Count(); + + result.Data = await q.ToListAsync(); + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// + /// + /// + /// + // GET: api/UserInfoes/5 + [HttpGet("{id}")] public async Task>> GetUserInfo(int id) { IQueryable q = _context.UserInfoes; diff --git a/AMESCoreStudio.WebApi/DTO/AMES/WipInfoDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/WipInfoDto.cs index f80fc9fb..658df04a 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/WipInfoDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/WipInfoDto.cs @@ -44,5 +44,10 @@ namespace AMESCoreStudio.WebApi.DTO.AMES /// 工單類型 /// public string wipType { get; set; } + + /// + /// 工單廠別 + /// + public string factoryno { get; set; } } } diff --git a/AMESCoreStudio.WebApi/DTO/AMES/WipQueryDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/WipQueryDto.cs index daff8857..8fc0b90d 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/WipQueryDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/WipQueryDto.cs @@ -65,6 +65,11 @@ namespace AMESCoreStudio.WebApi.DTO.AMES /// public DateTime wipDueDate { get; set; } + /// + /// 廠商代碼 + /// + public string factoryNo { get; set; } + /// /// 廠商中文廠名 /// diff --git a/AMESCoreStudio.WebApi/Models/SYS/UserInfo.cs b/AMESCoreStudio.WebApi/Models/SYS/UserInfo.cs index 18f4d7b8..a9c60e49 100644 --- a/AMESCoreStudio.WebApi/Models/SYS/UserInfo.cs +++ b/AMESCoreStudio.WebApi/Models/SYS/UserInfo.cs @@ -49,6 +49,14 @@ namespace AMESCoreStudio.WebApi.Models.SYS [Display(Name = "部門編號")] public int DeptID { get; set; } + /// + /// 廠別編號 + /// + [Column("FACTORY_ID")] + [DataMember] + [Display(Name = "廠別編號")] + public int FactoryID { get; set; } + /// /// 登入帳號 ///