From 6be9be174c14179af183e4e6b2fb9c875c042fc4 Mon Sep 17 00:00:00 2001 From: dev02 Date: Tue, 15 Nov 2022 16:16:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=97=E8=A1=A8,=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DeviceManageController.cs | 50 ++++++++ .../ApiControllers/OperationController.cs | 108 +++++++++--------- 2 files changed, 102 insertions(+), 56 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index b2f95e9..b46c2cb 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -434,5 +434,55 @@ namespace FrontendWebApi.ApiControllers } + /// + /// 即時趨勢條件過濾條件面板 + /// + /// + /// + [HttpPost] + [Route("api/Device/GetMainSub")] + public async Task>> GetMainSub() + { + ApiResult apiResult = new ApiResult(jwt_str); + if (!jwtlife) + { + apiResult.Code = "5000"; + return BadRequest(apiResult); + } + try + { + var dbsub = await frontendRepository.GetAllAsync( + @$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority + from role_auth a + join auth_page b on a.AuthCode = b.AuthCode + join userinfo c on c.role_guid = a.role_guid + join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type + join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type + where c.account = @account + order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type }); + var mains = dbsub.GroupBy(a => a.main_system_tag).ToList(); + apiResult.Data = new History_MainSubBuildFloor(); + apiResult.Data.history_Main_Systems = new List(); + foreach (var main in mains) + { + History_Main_system history_Main_System = new History_Main_system(); + history_Main_System.main_system_tag = main.Select(a => a.main_system_tag).FirstOrDefault(); + history_Main_System.full_name = main.Select(a => a.main_name).FirstOrDefault(); + + apiResult.Data.history_Main_Systems.Add(history_Main_System); + } + + apiResult.Code = "0000"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + return Ok(apiResult); + } + return Ok(apiResult); + + } } } diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs index 8279d59..0c81caa 100644 --- a/FrontendWebApi/ApiControllers/OperationController.cs +++ b/FrontendWebApi/ApiControllers/OperationController.cs @@ -428,57 +428,57 @@ namespace FrontendWebApi.ApiControllers cell.CellStyle = styleLine12; #endregion foreach (var or in operation_record.Result) - { - RowPosition += 1; - row = sheet.CreateRow(RowPosition); - for (var i = 0; i < 10; i++) { - cell = row.CreateCell(i); - if (i == 0) + RowPosition += 1; + row = sheet.CreateRow(RowPosition); + for (var i = 0; i < 10; i++) { - cell.SetCellValue(or.work_type_name); - } - if (i == 1) - { - cell.SetCellValue(or.location); - } - if (i == 2) - { - cell.SetCellValue(or.formId); - } - if (i == 3) - { - cell.SetCellValue(or.device_name); - } - if (i == 4) - { - cell.SetCellValue(or.status_name); - } - if (i == 5) - { - cell.SetCellValue(or.user_full_name); - } - if (i == 6) - { - cell.SetCellValue(or.start_time); - } - if (i == 7) - { - cell.SetCellValue(or.finish_time); // image - } - if (i == 8) - { - cell.SetCellValue(or.finish_time); - } - if (i == 9) - { - cell.SetCellValue(or.Created_at); - } + cell = row.CreateCell(i); + if (i == 0) + { + cell.SetCellValue(or.work_type_name); + } + if (i == 1) + { + cell.SetCellValue(or.location); + } + if (i == 2) + { + cell.SetCellValue(or.formId); + } + if (i == 3) + { + cell.SetCellValue(or.device_name); + } + if (i == 4) + { + cell.SetCellValue(or.status_name); + } + if (i == 5) + { + cell.SetCellValue(or.user_full_name); + } + if (i == 6) + { + cell.SetCellValue(or.start_time); + } + if (i == 7) + { + cell.SetCellValue(or.finish_time); // image + } + if (i == 8) + { + cell.SetCellValue(or.finish_time); + } + if (i == 9) + { + cell.SetCellValue(or.Created_at); + } - cell.CellStyle = style12; + cell.CellStyle = style12; + } } } - } } else if (work_type == 2) { @@ -494,11 +494,11 @@ namespace FrontendWebApi.ApiControllers if (operation_record.Result.Count > 0) { foreach(var or in operation_record.Result) - { - sqlString = $@"select * from operation_record_file where record_id = @record_id"; - var param = new { @record_id = or.id }; - operation_record_file = backendRepository.GetAllAsync(sqlString, param).Result; - or.lorf = operation_record_file; + { + sqlString = $@"select * from operation_record_file where record_id = @record_id"; + var param = new { @record_id = or.id }; + operation_record_file = backendRepository.GetAllAsync(sqlString, param).Result; + or.lorf = operation_record_file; } int RowPosition = 0; @@ -597,11 +597,7 @@ namespace FrontendWebApi.ApiControllers var imageByte = System.IO.File.ReadAllBytes(fullPath); int format = 0; var drawing = sheet.CreateDrawingPatriarch(); - foreach (var v in Enum.GetNames(typeof(PictureType))) - { - if (v == extName) - format = Convert.ToInt32(Enum.Parse(typeof(PictureType), v)); - } + format = Convert.ToInt32(Enum.Parse(typeof(PictureType), extName)); if (format != 0) {