diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index 52e365b2..d69746ce 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -2705,12 +2705,16 @@ namespace AMESCoreStudio.Web.Controllers } else // 昶亨 { - nginfo = await _esuncApi.GetNgRepairDataByBarcodeNO(item.BarcodeNoH); + // nginfo = await _esuncApi.GetNgRepairDataByBarcodeNO(item.BarcodeNoH); + nginfo = await _fqcApi.GetNgRepairDataByBarcodeNO_ESUN(item.BarcodeNoH); + + } result_data.Add(new { + caseID = item.CaseID, barcodeNo = item.BarcodeNo, factoryNo = Factorydata.Select(s => s.FactoryNo).FirstOrDefault(), wipNoF = item.WipNoF, @@ -2720,10 +2724,10 @@ namespace AMESCoreStudio.Web.Controllers itemNoH = item.ItemNoH, createDate = item.CreateDate, reasonNo = item.ReasonNo, - stationNo = nginfo.Data.Select(s => s.stationName).FirstOrDefault(), - userName = nginfo.Data.Select(s => s.userName).FirstOrDefault(), - repairNo = nginfo.Data.Select(s => s.repairNo).FirstOrDefault(), - repairDesc = nginfo.Data.Select(s => s.repairDesc).FirstOrDefault() + stationNo = nginfo.Data.Select(s => s.stationname).FirstOrDefault(), + userName = nginfo.Data.Select(s => s.username).FirstOrDefault(), + repairNo = nginfo.Data.Select(s => s.repairno).FirstOrDefault(), + repairDesc = nginfo.Data.Select(s => s.repairdesc).FirstOrDefault() }); @@ -2777,7 +2781,9 @@ namespace AMESCoreStudio.Web.Controllers if (!allowedExtensions.Contains(fileExtension)) { - ModelState.AddModelError("error", "僅允許上傳 png、jpg、bmp、gif、xlsx、xls、docx、pdf、pptx、txt、eml、etc 格式的檔案!"); + string msg = "檔案格式錯誤,請確認\r\n"; + msg += "僅允許上傳 png、jpg、bmp、gif、xlsx、xls、docx、pdf、pptx、txt、eml、etc 格式的檔案!"; + ModelState.AddModelError("error", msg); ViewBag.CaseID = model.CaseID; return View("FQC014R"); } @@ -2879,9 +2885,20 @@ namespace AMESCoreStudio.Web.Controllers { var tt = Request.Cookies["UserID"]; ViewBag.UserID = tt; - await GetUserInfo("1004,1009"); + // await GetUserInfo("1004,1009"); var result = await _fqcApi.GetNgInfoAlertMaster(id); + if (result.UpdateUserID != 0) + { + var user_info = await _sysApi.GetUserInfo(result.UpdateUserID); + ViewBag.UpdateUserName = user_info[0].UserName; + + + // ViewBag.UpdateUserName = await _sysApi.GetUserData(result.UpdateUserID); + } + else + ViewBag.UpdateUserName = ""; + return View(result); } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index f648f60b..334ccc65 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -886,6 +886,15 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetNgRepairDataByBarcodeNO")] ITask> GetNgRepairDataByBarcodeNO(string barcodeNo); + + // + /// 查詢工單條碼資料-WipNo + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetNgRepairDataByBarcodeNO_ESUN")] + ITask> GetNgRepairDataByBarcodeNO_ESUN(string barcodeNo); + + /// /// 查詢異常不良警示 /// diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml index 99e2f96b..8f8764e5 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml @@ -22,7 +22,7 @@
-
+
@@ -67,9 +67,9 @@ - + - + @@ -134,7 +134,13 @@ var toolbar = []; - var tableCols = [[ + var tableCols = [[ + { + field: 'caseID', + width: 100, + title: 'CaseID', + sort: true + }, { field: 'barcodeNo', width: 100, @@ -182,6 +188,7 @@ field: 'createDate', width: 100, title: '警報異常時間', + templet: '
{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd") }}
', sort: true }, { @@ -213,6 +220,19 @@ width: 100, title: '作業人員', sort: true + }, + { + field: 'right', + width: 130, + title: '操作', + fixed: 'right', + templet: function (d) { + btn = `下載` + if (d.statusNo != "已結案") { + btn += `上傳` + } + return btn + } } ]]; @@ -220,6 +240,21 @@ var caseID = $("#CaseID").val(); var table = hg.table.datatable('test', '異常不良警示資料維護', '/FQC/GetNGINFOAlertDetailByQuery?caseID=' + caseID, {}, tableCols, '', false, 'full-100'); + + //上傳 + function Upload(obj) { + if (obj.data.caseID) { + + hg.open('上傳檔案', '/FQC/FQC014R/' + obj.data.caseID, 800, 550); + } + }; + //下載 + function Download(obj) { + if (obj.data.caseID) { + + hg.open('下載檔案', '/FQC/FQC014RV/' + obj.data.caseID, 800, 550); + } + }; @@ -232,3 +267,19 @@ {{ d.wipNoF }} {{# } }} + diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml index b97e64c1..03700162 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml @@ -22,7 +22,7 @@
- +
@@ -67,19 +67,13 @@
- + - + - - + @@ -104,7 +98,8 @@ - + +
- -
@Html.ValidationMessage("error") @@ -178,6 +173,7 @@ field: 'createDate', width: 100, title: '警報異常時間', + templet: '
{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd") }}
', sort: true }, { @@ -209,6 +205,16 @@ width: 100, title: '作業人員', sort: true + }, + { + field: 'right', + width: 130, + title: '操作', + fixed: 'right', + templet: function (d) { + btn = `下載` + return btn + } } ]]; @@ -216,6 +222,20 @@ var caseID = $("#CaseID").val(); var table = hg.table.datatable('test', '異常不良警示資料維護', '/FQC/GetNGINFOAlertDetailByQuery?caseID=' + caseID, {}, tableCols, '', false, 'full-100'); + //上傳 + function Upload(obj) { + if (obj.data.caseID) { + + hg.open('上傳檔案', '/FQC/FQC014R/' + obj.data.caseID, 800, 550); + } + }; + //下載 + function Download(obj) { + if (obj.data.caseID) { + + hg.open('下載檔案', '/FQC/FQC014RV/' + obj.data.caseID, 800, 550); + } + }; @@ -226,5 +246,20 @@ {{ d.wipNoF }} {{# } }} + } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs index 3a493dfe..712d748a 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs @@ -15,6 +15,8 @@ using System.Net.Mail; using System.Data.Common; using System.Data; using System.Dynamic; +using Dapper; +using AMESCoreStudio.WebApi.Extensions; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -27,14 +29,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { private readonly AMESContext _context; private readonly IConfiguration _config; + private readonly ESUNAMESContext _context_esun; + private readonly IConfiguration _config_esun; /// /// /// /// - public NgRepairsController(AMESContext context) + public NgRepairsController(AMESContext context, ESUNAMESContext context_esun) { _config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build(); _context = context; + + _config_esun = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build(); + _context_esun = context_esun; } /// @@ -1642,39 +1649,96 @@ and d.wip_no = '{0}' and a.station_id={1} and b.part_no='{2}'", wipNo, stationID public async Task> GetNgRepairDataByBarcodeNO(string barcodeNo) { ResultModel result = new ResultModel(); - var q = from q1 in _context.NgRepairs - join q2 in _context.NgInfos on q1.NgID equals q2.NgID - join q3 in _context.BarcodeInfoes on q2.BarcodeID equals q3.BarcodeID - where q3.BarcodeNo == barcodeNo - join q7 in _context.Stationses on q2.StationId equals q7.StationID - join q8 in _context.UserInfoes on q1.CreateUserID equals q8.UserID - join q9 in _context.WipInfos on q3.WipID equals q9.WipID - join q5 in _context.FactoryInfos on q9.WerksNO equals q5.FactoryNo - select new - { - q1.CreateDate, - q7.StationName, - q3.BarcodeNo, - q2.TypeNo, - q2.StationId, - q2.ReasonNo, - q1.RepairNo, - q1.RepairTypeNo, - q1.RepairDesc, - q1.PartNo, - UserName = q5.FactoryNameCh + q8.UserName - }; + var querySql = @"select + q1.create_date CreateDate, + q7.station_name StationName, + q3.barcode_no BarcodeNo, + q2.type_no TypeNo, + q2.station_id StationId, + q2.reason_no ReasonNo, + q1.repair_no RepairNo, + q1.repair_type_no RepairTypeNo, + q1.repair_desc RepairDesc, + q1.part_no PartNo, + q5.factory_name_ch || q8.user_name AS UserName + from JHAMES.Barcode_Info q3 ,JHAMES.Stations q7, + JHSYS.User_Info q8 ,JHAMES.Wip_Info q9 , + JHAMES.Factory_Info q5,JHAMES.Ng_Info q2 + LEFT outer join JHAMES.Ng_Repair q1 on q2.NG_ID = q1.NG_ID + where q2.barcode_id = q3.barcode_id + and q2.station_id = q7.station_id + and q2.Create_UserID = q8.User_ID + and q3.wip_id = q9.wip_id + and q9.werks_no = q5.Factory_No + and q3.Barcode_No = :BarcodeNo "; + DynamicParameters p = new DynamicParameters(); + p.Add("BarcodeNo", barcodeNo); + + var q = _context.Database.DapperQuery(querySql, p).ToList(); + + + + + //紀錄筆數 + result.DataTotal = q.Count(); + + result.Data = q; + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + result.Success = true; + result.Msg = "OK"; + return result; + } + /// + /// 安勤異常警示使用 + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetNgRepairDataByBarcodeNO_ESUN(string barcodeNo) + { - q = q.OrderBy(w => w.CreateDate); + ResultModel result = new ResultModel(); + var querySql = @"select + q1.create_date CreateDate, + q7.station_name StationName, + q3.barcode_no BarcodeNo, + q2.type_no TypeNo, + q2.station_id StationId, + q2.reason_no ReasonNo, + q1.repair_no RepairNo, + q1.repair_type_no RepairTypeNo, + q1.repair_desc RepairDesc, + q1.part_no PartNo, + q5.factory_name_ch || q8.user_name AS UserName + from JHAMES.Barcode_Info q3 ,JHAMES.Stations q7, + JHSYS.User_Info q8 ,JHAMES.Wip_Info q9 , + JHAMES.Factory_Info q5,JHAMES.Ng_Info q2 + LEFT outer join JHAMES.Ng_Repair q1 on q2.NG_ID = q1.NG_ID + where q2.barcode_id = q3.barcode_id + and q2.station_id = q7.station_id + and q2.Create_UserID = q8.User_ID + and q3.wip_id = q9.wip_id + and q9.werks_no = q5.Factory_No + and q3.Barcode_No = :BarcodeNo "; + DynamicParameters p = new DynamicParameters(); + p.Add("BarcodeNo", barcodeNo); + + var q = _context_esun.Database.DapperQuery(querySql, p).ToList(); //紀錄筆數 result.DataTotal = q.Count(); - result.Data = await q.ToListAsync(); + result.Data = q; if (result == null) { diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs index 7d07630d..a5a2151c 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs @@ -141,7 +141,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES public DateTime? FinishDate { get; set; } /// - /// 警報處理人員 + /// QA人員 /// [DataMember] [Display(Name = "QA人員")] diff --git a/AMESCoreStudio.WebApi/Models/ESUNAMESContext.cs b/AMESCoreStudio.WebApi/Models/ESUNAMESContext.cs new file mode 100644 index 00000000..96a2f930 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/ESUNAMESContext.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using AMESCoreStudio.WebApi; +using AMESCoreStudio.WebApi.Models.SYS; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.WebApi.Models.BAS; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Query.SqlExpressions; +using System.Reflection; + + +namespace AMESCoreStudio.WebApi +{ + /// + /// + /// + public class ESUNAMESContext : DbContext + { + /// + /// + /// + /// + public ESUNAMESContext(DbContextOptions options) + : base(options) + { + //Configuration.ProxyCreationEnabled = false; + } + + /// + /// + /// + /// + /// + /// + public int? DatePart(string datePartArg, DateTimeOffset? date) => throw new InvalidOperationException($"{nameof(DatePart)} cannot be called client side."); + + + /// + /// + /// + /// + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + var methodInfo = typeof(DbFunctionExtensions).GetMethod(nameof(DatePart)); + + var datePartMethodInfo = typeof(ESUNAMESContext) + .GetRuntimeMethod(nameof(ESUNAMESContext.DatePart), new[] { typeof(string), typeof(DateTimeOffset) }); + modelBuilder.HasDbFunction(datePartMethodInfo) + .HasTranslation(args => + new SqlFunctionExpression("DatePart", + new[] + { + new SqlFragmentExpression((args.ToArray()[0] as SqlConstantExpression).Value.ToString()), + args.ToArray()[1] + }, + true, + new[] { false, false }, + typeof(int?), + null + ) + ); + + + } + + } +} diff --git a/AMESCoreStudio.WebApi/Startup.cs b/AMESCoreStudio.WebApi/Startup.cs index 3a72c747..589402f1 100644 --- a/AMESCoreStudio.WebApi/Startup.cs +++ b/AMESCoreStudio.WebApi/Startup.cs @@ -58,7 +58,9 @@ namespace AMESCoreStudio.WebApi services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("QASRVConnection")) ); - + services.AddDbContext( + opt => opt.UseLazyLoadingProxies().UseOracle(Configuration.GetConnectionString("ESUNAMESContext"), b => b.UseOracleSQLCompatibility("11")) + .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()))); services.AddControllers(); services.AddSwaggerGen(c => diff --git a/AMESCoreStudio.WebApi/appsettings.json b/AMESCoreStudio.WebApi/appsettings.json index e1c6d44a..f6a9be2b 100644 --- a/AMESCoreStudio.WebApi/appsettings.json +++ b/AMESCoreStudio.WebApi/appsettings.json @@ -11,7 +11,8 @@ "ESUNContext": "Data Source=.;Initial Catalog=SFIS_ESUN;User Id=sa;Password=20000123;Encrypt=True;TrustServerCertificate=True;Connect Timeout=0;", "AVLEContext": "Data Source=GPMDBN;Initial Catalog=iFactory;User Id=ipro_mis;Password=mmii@2019;Encrypt=False;", "TestLogConnection": "Data Source=GPMDBN;Initial Catalog=TestAutomate;user id=ipro_mis;password=mmii@2019;Encrypt=False;", - "AMESContext": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=61.216.68.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=jhdb)));User Id=JHSYS;Password=ASYS666;" + "AMESContext": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=jinhon-info.com.tw)(PORT=1526))(CONNECT_DATA=(SERVICE_NAME=jinhon1)));User Id=JHSYS;Password=ASYS666;", + "ESUNAMESContext": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=jinhon-info.com.tw)(PORT=1528))(CONNECT_DATA=(SERVICE_NAME=jinhon2)));User Id=JHSYS;Password=ASYS666;" //"AMESContext": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=61.216.68.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=jhdb)));User Id=system;Password=admin;" //"AMESContextO": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=61.216.68.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=cpadb)));User Id=JHSYS;Password=ASYS666;" },