From fd8707e899340ddeb3d644c70be3ad2b543c33c1 Mon Sep 17 00:00:00 2001 From: sunliang <593170460@qq.com> Date: Tue, 17 Oct 2023 13:57:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B8=85=E5=8D=95=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MinioController/MinioApiController.cs | 84 +++++++++++-------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs index 266b66f..55ac33d 100644 --- a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs +++ b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs @@ -806,7 +806,7 @@ namespace IBKLinker_Minio.Controller.MinioController /// /// /// - [HttpPost, Route("GetMenuTree")] + [HttpPost, Route("GetMenuTree")] public List GetMenuTree(string PK = "") { List date = new List(); @@ -921,7 +921,7 @@ namespace IBKLinker_Minio.Controller.MinioController request.code = "1"; //throw; } - + //通过用户ID查询用户得角色ID, //判断当前角色是否有操作权限 //通过角色ID查询用户有权限得文件夹 @@ -932,12 +932,12 @@ namespace IBKLinker_Minio.Controller.MinioController #region minio文件下载及预览 [HttpPost, Route("FileDownload")] - public RequestEntity FileDownload(List minioStoragePath) + public RequestEntity FileDownload(List minioStoragePath) { MinioBusinessLogic bb = new MinioBusinessLogic(); RequestEntity request = new RequestEntity(); MinioStoragePath data = new MinioStoragePath(); - using (IDbContext db = ObjectContainer.GetObject("db")) + using (IDbContext db = ObjectContainer.GetObject("db")) { try { @@ -953,7 +953,7 @@ namespace IBKLinker_Minio.Controller.MinioController if (uploadTask.Status == TaskStatus.RanToCompletion && !uploadTask.IsFaulted) //判读是否由数值 { data.Bate64 = uploadTask.Result; - data.FileName = item.FileName; + data.FileName = item.FileName; if (item.OperationType == "0") //操作类型为下载 { int DownloadNum = item.DownloadNum + 1; @@ -973,7 +973,7 @@ namespace IBKLinker_Minio.Controller.MinioController request.data = data; } } - else + else { request.msg = "请联系管理员检查!"; request.code = "1"; @@ -992,91 +992,93 @@ namespace IBKLinker_Minio.Controller.MinioController #endregion #region 标准清单 [HttpGet, Route("StandardListGeneration")] - public HttpResponseMessage StandardListGeneration(StandardListGenerationModel args) + public HttpResponseMessage StandardListGeneration(string InventoryName, string InventoryType, string BeginTime, string EndTime) { RequestEntity request = new RequestEntity(); IList date = new List(); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); - using (IDbContext db = ObjectContainer.GetObject("db")) + using (IDbContext db = ObjectContainer.GetObject("db")) { try { - if (args != null) + if (InventoryName != null && InventoryType != null) { string ExcelName = "";//定义导出Excel文件名称 FileStream file = new FileStream("D:/linshi/" + "清单模板.xlsx", FileMode.Open, FileAccess.Read); XSSFWorkbook hssfworkbook = new XSSFWorkbook(file); string sql = "select * from MINIO_STORAGE_PATH where 1=1 and FILE_TYPE='1' "; - if (args.InventoryType == "0")//标准类型 + if (InventoryType == "0")//标准类型 { - if (!string.IsNullOrEmpty(args.BeginTime)) + if (!string.IsNullOrEmpty(BeginTime)) { - sql += string.Format(" and CREATE_TIME >= to_date('{0}', 'yyyy/mm/dd hh24:mi:ss')", args.BeginTime);//开始时间 + sql += string.Format(" and CREATE_TIME >= to_date('{0}', 'yyyy/mm/dd hh24:mi:ss')", BeginTime);//开始时间 } - if (!string.IsNullOrEmpty(args.EndTime)) + if (!string.IsNullOrEmpty(EndTime)) { - sql += string.Format(" and CREATE_TIME <= to_date('{0}', 'yyyy/mm/dd hh24:mi:ss')", args.EndTime);//结束时间 + sql += string.Format(" and CREATE_TIME <= to_date('{0}', 'yyyy/mm/dd hh24:mi:ss')", EndTime);//结束时间 } - sql += string.Format(" and FILE_PATH like'%{0}%'", args.InventoryName);//直接添加文件加名称 + sql += string.Format(" and FILE_PATH like'%{0}%'", InventoryName);//直接添加文件加名称 ExcelName = "标准清单"; } - else + else { #region 清单判断 - if (args.InventoryName =="HY企业标准清单") + if (InventoryName == "HY企业标准清单") { sql += "and FILE_PATH like'%HY%'"; ExcelName = "HY企业标准清单"; } - if (args.InventoryName == "Q-HY企业标准清单") + if (InventoryName == "Q-HY企业标准清单") { sql += "and (FILE_PATH like'%Q/HY%'"; ExcelName = "Q-HY企业标准清单"; } - if (args.InventoryName == "新产品标准清单") + if (InventoryName == "新产品标准清单") { sql += "and (FILE_PATH like'%XYGN%' or FILE_PATH like'%XYGW%')"; ExcelName = "新产品标准清单"; } - if (args.InventoryName == "标准目录有效清单") + if (InventoryName == "标准目录有效清单") { + sql += "and (FILE_PATH like'企业标准'"; ExcelName = "标准目录有效清单"; } - if (args.InventoryName == "企业标准明细表") + if (InventoryName == "企业标准明细表") { + sql += "and (FILE_PATH like'企业标准'"; ExcelName = "企业标准明细表"; } - if (args.InventoryName == "过期标准清单") + if (InventoryName == "过期标准清单") { - sql += "and (FILE_PATH like'%过期XYGN%' or FILE_PATH like'%过期XYGW%')"; + sql += "and (FILE_PATH like'%过期标准%'"; ExcelName = "过期标准清单"; } - if (args.InventoryName == "参考标准清单") + if (InventoryName == "参考标准清单") { - sql += "and (FILE_PATH like'%XYGN%' or FILE_PATH like'%XYGW%')"; + sql += "and (FILE_PATH like'%参考标准%'"; ExcelName = "参考标准清单"; } - if (args.InventoryName == "工艺卡清单") + if (InventoryName == "工艺卡清单") { - sql += "and (FILE_PATH like'%170钢管厂工艺卡%' or FILE_PATH like'%219钢管厂工艺卡%' or FILE_PATH like'%460钢管厂工艺卡%' or FILE_PATH like'%170热处理工艺卡%' or FILE_PATH like'%连模铸系列工艺卡/转炉厂%' or FILE_PATH like'%连模铸系列工艺卡/特冶厂%' or FILE_PATH like'%连模铸系列工艺卡/电炉厂%' or FILE_PATH like'%电炉厂工艺卡%' or FILE_PATH like'%转炉厂工艺卡%' or FILE_PATH like'%特冶厂工艺卡%' or FILE_PATH like'%大棒厂工艺卡%' or FILE_PATH like'%小棒厂工艺卡%' or FILE_PATH like'%中棒厂工艺卡%'or FILE_PATH like'%锻造厂工艺卡%' or FILE_PATH like'%扁棒厂工艺卡)"; + sql += "and (FILE_PATH like'%170钢管厂工艺卡%' or FILE_PATH like'%219钢管厂工艺卡%' or FILE_PATH like'%460钢管厂工艺卡%' or FILE_PATH like'%170热处理工艺卡%' or FILE_PATH like'%连模铸系列工艺卡/转炉厂%' or FILE_PATH like'%连模铸系列工艺卡/特冶厂%' or FILE_PATH like'%连模铸系列工艺卡/电炉厂%' or FILE_PATH like'%电炉厂工艺卡%' or FILE_PATH like'%转炉厂工艺卡%' or FILE_PATH like'%特冶厂工艺卡%' or FILE_PATH like'%大棒厂工艺卡%' or FILE_PATH like'%小棒厂工艺卡%' or FILE_PATH like'%中棒厂工艺卡%'or FILE_PATH like'%锻造厂工艺卡%' or FILE_PATH like'%扁棒厂工艺卡%')"; ExcelName = "工艺卡清单"; } - if (args.InventoryName == "工艺规程清单") + if (InventoryName == "工艺规程清单") { sql += "and FILE_PATH like'%工艺规程%'"; ExcelName = "工艺规程清单"; } - if (args.InventoryName == "技术制度清单") + if (InventoryName == "技术制度清单") { sql += "and FILE_PATH like'%技术制度%'"; ExcelName = "技术制度清单"; } - if (args.InventoryName == "艺字工艺清单") + if (InventoryName == "艺字工艺清单") { sql += "and FILE_PATH like'%艺字工艺%'"; ExcelName = "艺字工艺清单"; } - if (args.InventoryName == "技字通知清单") + if (InventoryName == "技字通知清单") { sql += "and FILE_PATH like'%技字通知%'"; ExcelName = "技字通知清单"; @@ -1100,7 +1102,7 @@ namespace IBKLinker_Minio.Controller.MinioController { var curRow = sheet.GetRow(rowIndex); var data = date[i]; - if (data.FilePath.IndexOf("XYGN") >= 0 || data.FilePath.IndexOf("XYGW") >= 0)//对国内国外标准进行特殊处理 + if (data.FilePath.IndexOf("企业标准/XYGN") >= 0 || data.FilePath.IndexOf("企业标准/XYGW") >= 0)//对国内国外标准进行特殊处理 { int Num = data.FileName.IndexOf("-") + 8;//取文件名称技术协议编号位数 int name = data.FileName.Length - Num;//取文件名称技术协议名称位数 @@ -1108,10 +1110,20 @@ namespace IBKLinker_Minio.Controller.MinioController curRow.GetCell(1).SetCellValue(data.FileName.Substring(0, Num).Trim());//协议编号 curRow.GetCell(2).SetCellValue(data.FileName.Substring(Num, name).Trim());//名称 } - else + if (data.FilePath.IndexOf("标准通知")>=0) + { + int Num = data.FileName.IndexOf("号");//取文件名称编号位数 + int name = data.FileName.Length - Num;//取文件名称名称位数 + curRow.GetCell(0).SetCellValue(data.FilePath.Replace(data.FileName, ""));//路 + curRow.GetCell(1).SetCellValue(data.FileName.Substring(0, Num).Trim());//编号 + curRow.GetCell(2).SetCellValue(data.FileName.Substring(Num, name).Replace(":", "").Trim());//名称 + } + if(data.FilePath.IndexOf("标准通知") == -1 && data.FilePath.IndexOf("企业标准/XYGN") == -1 || data.FilePath.IndexOf("企业标准/XYGW") == -1) { + var filecontent = data.FileName.Split(' ');//以空格进行区分 curRow.GetCell(0).SetCellValue(data.FilePath.Replace(data.FileName, ""));//路径 - curRow.GetCell(2).SetCellValue(data.FileName);//名称 + curRow.GetCell(1).SetCellValue(filecontent[0].ToString().Trim());//编号 + curRow.GetCell(2).SetCellValue(data.FileName.Replace(filecontent[0].ToString(), ""));//名称 } rowIndex = rowIndex + 1; } @@ -1125,7 +1137,7 @@ namespace IBKLinker_Minio.Controller.MinioController { result.Content.Headers.ContentDisposition.FileName = ExcelName + ".xlsx"; } - else + else { result.Content.Headers.ContentDisposition.FileName = "标准清单.xlsx"; } @@ -1133,7 +1145,7 @@ namespace IBKLinker_Minio.Controller.MinioController } } } - catch (Exception ex) + catch (Exception ex) { logger.InfoFormat(ex.ToString()); }