yuanrf преди 8 месеца
родител
ревизия
f3c14aa600

+ 57 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -91,6 +91,7 @@ using System.Diagnostics.PerformanceData;
 using System.Drawing.Printing;
 using OASystem.Domain.Dtos.FileDto;
 using Microsoft.VisualBasic;
+using Microsoft.EntityFrameworkCore.Query.Internal;
 
 namespace OASystem.API.Controllers
 {
@@ -3600,6 +3601,7 @@ namespace OASystem.API.Controllers
                     Diid = dto.Diid,
                     IsDel = 0,
                     FilePath = saveFilePath,
+                    FileName = nameSp[0]
                 };
 
                 using (FileStream fs = System.IO.File.Create(saveFilePath))
@@ -3626,6 +3628,61 @@ namespace OASystem.API.Controllers
             return Ok(jw);
         }
 
+        [HttpPost]
+
+        public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
+        {
+            var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid).ToList();
+            return Ok(JsonView(true, "success", dbQuery.Select(x => x.FileName)));
+        }
+
+        [HttpPost]
+        public IActionResult ExportGroupZip(ExportGroupZipDto dto)
+        {
+            var jw = JsonView(false);
+            var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
+            if (groupInfo == null)
+            {
+                jw.Msg = "团组信息不存在!";
+                return Ok(jw);
+            }
+            var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
+
+            Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
+
+            foreach (var item in dbQuery)
+            {
+                using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
+                {
+                    byte[] bytes = new byte[fileStream.Length];
+                    fileStream.Read(bytes, 0, bytes.Length);
+                    fileStream.Close();
+                    Stream stream = new MemoryStream(bytes);
+                    Zips.Add(item.FileName, stream);
+                }
+            }
+
+            groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
+                   RegexOptions.None, TimeSpan.FromSeconds(1.5));
+
+
+            if (Zips.Count > 0)
+            {
+                IOOperatorHelper io = new IOOperatorHelper();
+                var byts = io.ConvertZipStream(Zips);
+                var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
+                io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
+                //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
+                jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBasePath") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{groupInfo.TeamName}_地接费用明细.zip" });
+            }
+            else
+            {
+                jw.Msg = "暂无生成文件!";
+            }
+
+            return Ok(jw);
+        }
+
         #endregion
 
         #region 团组英文资料

+ 0 - 11
OASystem/OASystem.Domain/Dtos/DtoBase.cs

@@ -89,15 +89,4 @@ namespace OASystem.Domain.Dtos
         /// </summary>
         public int PageId { get; set; }
     }
-
-    public class CommonSaveFileDto
-    {
-        public IFormFile File { get; set; }
-        public int Ctable { get; set; }
-        public int Diid { get; set; }
-
-        public int Cid { get; set; }
-
-        public int Userid { get; set; }
-    }
 }

+ 25 - 1
OASystem/OASystem.Domain/Dtos/FileDto/FileDto.cs

@@ -1,4 +1,5 @@
-using System;
+using Microsoft.AspNetCore.Http;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -23,4 +24,27 @@ namespace OASystem.Domain.Dtos.FileDto
         /// </summary>
         public string? PathUrl { get; set; }
     }
+
+    public class CommonSaveFileDto
+    {
+        public IFormFile File { get; set; }
+        public int Ctable { get; set; }
+        public int Diid { get; set; }
+
+        public int Cid { get; set; }
+
+        public int Userid { get; set; }
+    }
+
+    public class QueryGroupModelFileDto
+    {
+        public int Ctable { get; set; }
+        public int Diid { get; set; }
+        public int Cid { get; set; }
+    }
+
+    public class ExportGroupZipDto
+    {
+        public int Diid { get; set; }
+    }
 }

+ 2 - 0
OASystem/OASystem.Domain/Entities/Groups/GroupModelFile.cs

@@ -19,5 +19,7 @@ namespace OASystem.Domain.Entities.Groups
         public int Ctable { get; set; }
 
         public int Cid { get; set; }
+
+        public string FileName { get; set; }
     }
 }