diff --git a/AMESCoreStudio.Web/Controllers/QRSController.cs b/AMESCoreStudio.Web/Controllers/QRSController.cs index c79891ea..0751ab63 100644 --- a/AMESCoreStudio.Web/Controllers/QRSController.cs +++ b/AMESCoreStudio.Web/Controllers/QRSController.cs @@ -1600,11 +1600,122 @@ namespace AMESCoreStudio.Web.Controllers return View(); } - public async Task QRS018AAsync(string wipNO) + public IActionResult QRS018A(string wipNO) { ViewData["Title"] = "查詢條件 - 工單號碼 : " + wipNO; - IResultModel result = await _pcsApi.GetWipInfo4QRS013(wipNO, null, 0, 10); + ViewBag.WIP_NO = wipNO; + + return View(); + } + + public async Task QRS018B(string wipNO, string stationID, string ngNO) + { + var station = await _basApi.GetStations(int.Parse(stationID)); + + ViewData["Title"] = "查詢條件 - 工單號碼 : " + wipNO + " , 站別 : " + station[0].StationName + " , 不良代碼 : " + ngNO; + + ViewBag.WIP_NO = wipNO; + ViewBag.STATION_ID = stationID; + ViewBag.NG_NO = ngNO; + + return View(); + } + + public async Task QRS018C(string wipNO, string stationID, string repairNO) + { + var station = await _basApi.GetStations(int.Parse(stationID)); + + ViewData["Title"] = "查詢條件 - 工單號碼 : " + wipNO + " , 站別 : " + station[0].StationName + " , 維修代碼 : " + repairNO; + + ViewBag.WIP_NO = wipNO; + ViewBag.STATION_ID = stationID; + ViewBag.REPAIR_NO = repairNO; + + return View(); + } + + public async Task QRS018D(string wipNO,string stationID,string partNO) + { + var station = await _basApi.GetStations(int.Parse(stationID)); + + ViewData["Title"] = "查詢條件 - 工單號碼 : " + wipNO + " , 站別 : " + station[0].StationName + " , 維修料號 : " + partNO; + + ViewBag.WIP_NO = wipNO; + ViewBag.STATION_ID = stationID; + ViewBag.PART_NO = partNO; + + return View(); + } + + + public async Task GetErrorCode4QRS018Async(string id) + { + IResultModel result = await _repApi.GetErrorCode4QRS018(id); + + 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 }); + } + + public async Task GetErrorCodeList4QRS018Async(string id) + { + string[] param = id.Split('_'); + + IResultModel result = await _repApi.GetErrorCodeList4QRS018(param[0], int.Parse(param[1]), param[2]); + + 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 }); + } + + public async Task GetRepairCode4QRS018Async(string id) + { + IResultModel result = await _repApi.GetRepairCode4QRS018(id); + + 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 }); + } + + public async Task GetRepairCodeList4QRS018Async(string id) + { + string[] param = id.Split('_'); + IResultModel result = await _repApi.GetRepairCodeList4QRS018(param[0], int.Parse(param[1]), param[2]); + + 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 }); + } + + public async Task GetRepairPartNo4QRS018Async(string id) + { + IResultModel result = await _repApi.GetRepairPartNo4QRS018(id); + + 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 }); + } + + public async Task GetRepairPartNoList4QRS018Async(string id) + { + string[] param = id.Split('_'); + IResultModel result = await _repApi.GetRepairPartNoList4QRS018(param[0], int.Parse(param[1]), param[2]); if (result.DataTotal > 0) { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs b/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs index 5f1d775a..0934c38f 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs @@ -149,6 +149,47 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetRepairResponsibleUnit4REP012")] ITask> GetRepairResponsibleUnit4REP012(string productType, string testType, string unitNo, string lineID, string stationID, string wipNo, string itemNo, string dateStart, string dateEnd, string modelNo); + /// + /// 查詢統計不良代碼by工單號碼 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetErrorCode4QRS018")] + ITask> GetErrorCode4QRS018(string wipNo); + + /// + /// 查詢統計維修代碼by工單號碼 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetRepairCode4QRS018")] + ITask> GetRepairCode4QRS018(string wipNo); + + /// + /// 查詢統計維修料號by工單號碼 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetRepairPartNo4QRS018")] + ITask> GetRepairPartNo4QRS018(string wipNo); + + /// + /// 根據工單+站別+不良代碼查詢不良條碼明細 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetErrorCodeList4QRS018")] + ITask> GetErrorCodeList4QRS018(string wipNo, int stationID, string ngNo); + + /// + /// 根據工單+站別+維修代碼查詢維修條碼明細 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetRepairCodeList4QRS018")] + ITask> GetRepairCodeList4QRS018(string wipNo, int stationID, string repairNo); + + /// + /// 根據工單+站別+料號查詢維修條碼明細 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetRepairPartNoList4QRS018")] + ITask> GetRepairPartNoList4QRS018(string wipNo, int stationID, string partNo); /// /// 根據COMPONENT_ID獲取指定維修過程資料 diff --git a/AMESCoreStudio.Web/Views/QRS/QRS018.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS018.cshtml new file mode 100644 index 00000000..327c3e2c --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS018.cshtml @@ -0,0 +1,145 @@ +@{ + ViewData["Title"] = "iRepair查詢2"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+ +
+
+ +@section Scripts{ + + + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/QRS/QRS018A.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS018A.cshtml new file mode 100644 index 00000000..48fe8e95 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS018A.cshtml @@ -0,0 +1,221 @@ +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/QRS/QRS018B.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS018B.cshtml new file mode 100644 index 00000000..12de4ffe --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS018B.cshtml @@ -0,0 +1,87 @@ +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+ + + +
+
+ +
+
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/QRS/QRS018C.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS018C.cshtml new file mode 100644 index 00000000..56a6d7ed --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS018C.cshtml @@ -0,0 +1,88 @@ +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+ + + +
+
+ +
+
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/QRS/QRS018D.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS018D.cshtml new file mode 100644 index 00000000..6f4c26fc --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS018D.cshtml @@ -0,0 +1,88 @@ +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+ + + +
+
+ +
+
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs index 2c4700cf..ca455c7a 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs @@ -12,6 +12,9 @@ using AMESCoreStudio.CommonTools.Result; using Microsoft.Extensions.Configuration; using System.Net; using System.Net.Mail; +using System.Data.Common; +using System.Data; +using System.Dynamic; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -521,6 +524,498 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + /// + /// + /// + /// + /// + public static DataTable DataReaderToDataTable(DbDataReader reader) + { + try + { + DataTable dt = new DataTable(); + int fieldCount = reader.FieldCount; + for (int fieldIndex = 0; fieldIndex < fieldCount; ++fieldIndex) + { + dt.Columns.Add(reader.GetName(fieldIndex), reader.GetFieldType(fieldIndex)); + } + + dt.BeginLoadData(); + + object[] rowValues = new object[fieldCount]; + while (reader.Read()) + { + reader.GetValues(rowValues); + dt.LoadDataRow(rowValues, true); + } + reader.Close(); + dt.EndLoadData(); + + return dt; + + } + catch (Exception ex) + { + throw new Exception("DataReader Convert DataTable Error!", ex); + } + } + + /// + /// 根據工單統計不良代碼 + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetErrorCode4QRS018(string wipNo) + { + ResultModel result = new ResultModel(); + + /* + var q = from a in _context.NgInfos + join b in _context.NgComponents on a.NgID equals b.NgID + join c in _context.Stationses on a.StationId equals c.StationID + join d in _context.WipInfos on a.WipId equals d.WipID + join e in _context.NGReasons on b.NgNo equals e.NGReasonNo + select new + { + a.WipId, + d.WipNO, + a.StationId, + c.StationName, + b.NgNo, + e.NGReasonDesc, + a.BarcodeID, + a.CreateDate + }; + + if (wipNo != null) + { + if (wipNo != "") + { + q = q.Where(w => w.WipNO == wipNo); + } + } + + q = q.OrderBy(w => w.CreateDate).Distinct(); + + var g = q.GroupBy(x => new { x.WipId, x.WipNO, x.StationId, x.StationName, x.NgNo, x.NGReasonDesc }).Select(x => new + { + WipID = x.Key.WipId, + WipNO = x.Key.WipNO, + StationId = x.Key.StationId, + StationName = x.Key.StationName, + NgNo = x.Key.NgNo, + NGReasonDesc = x.Key.NGReasonDesc, + NgQty = x.Count() + }); + + //紀錄筆數 + result.DataTotal = g.Count(); + + result.Data = await g.ToListAsync(); + */ + string sql = string.Format(@"select x.*,y.total_qty,round(x.ng_qty * 100 / y.total_qty,2) as rate from ( +select a.wip_id,e.wip_no,b.ng_no,d.ng_reason_desc,a.station_id,c.station_name,count(distinct a.barcode_id) as ng_qty +from jhames.ng_info a,jhames.ng_component b, jhames.stations c, jhames.ng_reason d, jhames.wip_info e +where a.ng_id = b.ng_id and b.ng_no = d.ng_reason_no and a.station_id = c.station_id and a.wip_id = e.wip_id and e.wip_no = '{0}' +group by a.wip_id,e.wip_no,b.ng_no,d.ng_reason_desc,a.station_id,c.station_name) x, +( +select wip_id, sum(ng_qty) as total_qty from( + select a.wip_id, e.wip_no, b.ng_no, d.ng_reason_desc, a.station_id, c.station_name, count(distinct a.barcode_id) as ng_qty + from jhames.ng_info a, jhames.ng_component b, jhames.stations c, jhames.ng_reason d, jhames.wip_info e + where a.ng_id = b.ng_id and b.ng_no = d.ng_reason_no and a.station_id = c.station_id and a.wip_id = e.wip_id and e.wip_no = '{0}' + group by a.wip_id, e.wip_no, b.ng_no, d.ng_reason_desc, a.station_id, c.station_name) +group by wip_id) y +where x.wip_id = y.wip_id", wipNo); + + DbConnection conn = _context.Database.GetDbConnection(); + if (conn.State != System.Data.ConnectionState.Open) + { + await conn.OpenAsync(); + } + + using (var cmd = conn.CreateCommand()) + { + cmd.CommandText = sql; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + List list = new List(); + DataTable table = new DataTable(); + + table = DataReaderToDataTable(reader); + + foreach (DataRow row in table.Rows) + { + dynamic dyn = new ExpandoObject(); + list.Add(dyn); + foreach (DataColumn column in table.Columns) + { + var dic = (IDictionary)dyn; + dic[column.ColumnName] = row[column]; + } + } + + result.DataTotal = list.Count(); + result.Data = list; + } + } + } + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// 根據工單統計維修代碼 + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetRepairCode4QRS018(string wipNo) + { + ResultModel result = new ResultModel(); + string sql = string.Format(@"select x.*,y.total_qty,round(x.rma_qty * 100 / y.total_qty,2) as rate from ( +select a.wip_id,e.wip_no,b.repair_no,d.rma_reason_desc,a.station_id,c.station_name,count(distinct a.barcode_id) as rma_qty +from jhames.ng_info a,jhames.ng_repair b,jhames.stations c,jhames.rma_reason d,jhames.wip_info e +where a.ng_id = b.ng_id and b.repair_no = d.rma_reason_no and a.station_id = c.station_id and a.wip_id = e.wip_id and e.wip_no = '{0}' +group by a.wip_id,e.wip_no,b.repair_no,d.rma_reason_desc,a.station_id,c.station_name) x, +( +select wip_id,sum(rma_qty) as total_qty from ( +select a.wip_id,e.wip_no,b.repair_no,d.rma_reason_desc,a.station_id,c.station_name,count(distinct a.barcode_id) as rma_qty +from jhames.ng_info a,jhames.ng_repair b,jhames.stations c,jhames.rma_reason d,jhames.wip_info e +where a.ng_id = b.ng_id and b.repair_no = d.rma_reason_no and a.station_id = c.station_id and a.wip_id = e.wip_id and e.wip_no = '{0}' +group by a.wip_id,e.wip_no,b.repair_no,d.rma_reason_desc,a.station_id,c.station_name) +group by wip_id) y +where x.wip_id = y.wip_id", wipNo); + + DbConnection conn = _context.Database.GetDbConnection(); + if (conn.State != System.Data.ConnectionState.Open) + { + await conn.OpenAsync(); + } + + using (var cmd = conn.CreateCommand()) + { + cmd.CommandText = sql; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + List list = new List(); + DataTable table = new DataTable(); + + table = DataReaderToDataTable(reader); + + foreach (DataRow row in table.Rows) + { + dynamic dyn = new ExpandoObject(); + list.Add(dyn); + foreach (DataColumn column in table.Columns) + { + var dic = (IDictionary)dyn; + dic[column.ColumnName] = row[column]; + } + } + + result.DataTotal = list.Count(); + result.Data = list; + } + } + } + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// 根據工單統計維修料號 + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetRepairPartNo4QRS018(string wipNo) + { + ResultModel result = new ResultModel(); + string sql = string.Format(@"select x.*, y.total_qty, round(x.part_qty * 100 / y.total_qty, 2) as rate from( +select a.wip_id, e.wip_no, b.part_no, a.station_id, c.station_name, count(distinct a.barcode_id) as part_qty +from jhames.ng_info a, jhames.ng_repair b, jhames.stations c, jhames.wip_info e +where a.ng_id = b.ng_id and a.station_id = c.station_id and a.wip_id = e.wip_id and e.wip_no = '{0}' +group by a.wip_id, e.wip_no, b.part_no, a.station_id, c.station_name) x, +( +select wip_id, sum(part_qty) as total_qty from( +select a.wip_id, e.wip_no, b.part_no, a.station_id, c.station_name, count(distinct a.barcode_id) as part_qty +from jhames.ng_info a, jhames.ng_repair b, jhames.stations c, jhames.wip_info e +where a.ng_id = b.ng_id and a.station_id = c.station_id and a.wip_id = e.wip_id and e.wip_no = '{0}' +group by a.wip_id, e.wip_no, b.part_no, a.station_id, c.station_name) +group by wip_id) y +where x.wip_id = y.wip_id", wipNo); + + DbConnection conn = _context.Database.GetDbConnection(); + if (conn.State != System.Data.ConnectionState.Open) + { + await conn.OpenAsync(); + } + + using (var cmd = conn.CreateCommand()) + { + cmd.CommandText = sql; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + List list = new List(); + DataTable table = new DataTable(); + + table = DataReaderToDataTable(reader); + + foreach (DataRow row in table.Rows) + { + dynamic dyn = new ExpandoObject(); + list.Add(dyn); + foreach (DataColumn column in table.Columns) + { + var dic = (IDictionary)dyn; + dic[column.ColumnName] = row[column]; + } + } + + result.DataTotal = list.Count(); + result.Data = list; + } + } + } + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// 根據工單+站別+b不良代碼查詢不良條碼明細 + /// + /// + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetErrorCodeList4QRS018(string wipNo, int stationID, string ngNo) + { + ResultModel result = new ResultModel(); + string sql = string.Format(@"select c.barcode_no,e.station_name,b.ng_no,g.ng_reason_desc,b.location_no,b.reply_reason,f.user_name,a.create_date +from jhames.ng_info a,jhames.ng_component b,jhames.barcode_info c,jhames.wip_info d,jhames.stations e,jhsys.user_info f,jhames.ng_reason g +where a.ng_id = b.ng_id and a.barcode_id = c.barcode_id and c.wip_id = d.wip_id and a.station_id = e.station_id and b.create_userid = f.user_id(+) +and b.ng_no = g.ng_reason_no and d.wip_no = '{0}' and a.station_id={1} and b.ng_no='{2}'", wipNo, stationID, ngNo); + + DbConnection conn = _context.Database.GetDbConnection(); + if (conn.State != System.Data.ConnectionState.Open) + { + await conn.OpenAsync(); + } + + using (var cmd = conn.CreateCommand()) + { + cmd.CommandText = sql; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + List list = new List(); + DataTable table = new DataTable(); + + table = DataReaderToDataTable(reader); + + foreach (DataRow row in table.Rows) + { + dynamic dyn = new ExpandoObject(); + list.Add(dyn); + foreach (DataColumn column in table.Columns) + { + var dic = (IDictionary)dyn; + dic[column.ColumnName] = row[column]; + } + } + + result.DataTotal = list.Count(); + result.Data = list; + } + } + } + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// 根據工單+站別+維修代碼查詢維修條碼明細 + /// + /// + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetRepairCodeList4QRS018(string wipNo, int stationID, string repairNo) + { + ResultModel result = new ResultModel(); + string sql = string.Format(@"select distinct c.barcode_no,e.station_name,b.repair_no,g.rma_reason_desc,b.part_no,f.user_name,a.create_date,b.memo +from jhames.ng_info a,jhames.ng_repair b,jhames.barcode_info c,jhames.wip_info d,jhames.stations e,jhsys.user_info f,jhames.rma_reason g +where a.ng_id = b.ng_id and a.barcode_id = c.barcode_id and c.wip_id = d.wip_id and a.station_id = e.station_id and b.create_userid = f.user_id(+) +and b.repair_no = g.rma_reason_no and d.wip_no = '{0}' and a.station_id={1} and b.repair_no='{2}'", wipNo, stationID, repairNo); + + DbConnection conn = _context.Database.GetDbConnection(); + if (conn.State != System.Data.ConnectionState.Open) + { + await conn.OpenAsync(); + } + + using (var cmd = conn.CreateCommand()) + { + cmd.CommandText = sql; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + List list = new List(); + DataTable table = new DataTable(); + + table = DataReaderToDataTable(reader); + + foreach (DataRow row in table.Rows) + { + dynamic dyn = new ExpandoObject(); + list.Add(dyn); + foreach (DataColumn column in table.Columns) + { + var dic = (IDictionary)dyn; + dic[column.ColumnName] = row[column]; + } + } + + result.DataTotal = list.Count(); + result.Data = list; + } + } + } + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// 根據工單+站別+料號查詢維修條碼明細 + /// + /// + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetRepairPartNoList4QRS018(string wipNo,int stationID,string partNo) + { + ResultModel result = new ResultModel(); + string sql = string.Format(@"select c.barcode_no,e.station_name,b.repair_no,b.repair_desc,b.part_no,f.user_name,a.create_date,b.memo +from jhames.ng_info a,jhames.ng_repair b,jhames.barcode_info c,jhames.wip_info d,jhames.stations e,jhsys.user_info f +where a.ng_id = b.ng_id and a.barcode_id = c.barcode_id and c.wip_id = d.wip_id and a.station_id = e.station_id and b.create_userid = f.user_id(+) +and d.wip_no = '{0}' and a.station_id={1} and b.part_no='{2}'", wipNo, stationID, partNo); + + DbConnection conn = _context.Database.GetDbConnection(); + if (conn.State != System.Data.ConnectionState.Open) + { + await conn.OpenAsync(); + } + + using (var cmd = conn.CreateCommand()) + { + cmd.CommandText = sql; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + List list = new List(); + DataTable table = new DataTable(); + + table = DataReaderToDataTable(reader); + + foreach (DataRow row in table.Rows) + { + dynamic dyn = new ExpandoObject(); + list.Add(dyn); + foreach (DataColumn column in table.Columns) + { + var dic = (IDictionary)dyn; + dic[column.ColumnName] = row[column]; + } + } + + result.DataTotal = list.Count(); + result.Data = list; + } + } + } + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + /// /// 維修資料統計by不良代碼 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index 70a99435..412ddcfe 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -527,7 +527,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); for (int m = 0; m < esun_table.Rows.Count; m++) { mac = esun_table.Rows[m]["part_barcode"].ToString().Trim(); - dtBarcode.Rows[k]["KP_MB" + k.ToString() + "_MAC" + (k + 1).ToString()] = mac; + dtBarcode.Rows[k]["KP_MB" + k.ToString() + "_MAC" + (m + 1).ToString()] = mac; dtBarcode.AcceptChanges(); } }