|
@@ -92,6 +92,7 @@ using System.Drawing.Printing;
|
|
using OASystem.Domain.Dtos.FileDto;
|
|
using OASystem.Domain.Dtos.FileDto;
|
|
using Microsoft.VisualBasic;
|
|
using Microsoft.VisualBasic;
|
|
using Microsoft.EntityFrameworkCore.Query.Internal;
|
|
using Microsoft.EntityFrameworkCore.Query.Internal;
|
|
|
|
+using MathNet.Numerics.Distributions;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
namespace OASystem.API.Controllers
|
|
{
|
|
{
|
|
@@ -3760,6 +3761,10 @@ namespace OASystem.API.Controllers
|
|
fileStream.Read(bytes, 0, bytes.Length);
|
|
fileStream.Read(bytes, 0, bytes.Length);
|
|
fileStream.Close();
|
|
fileStream.Close();
|
|
Stream stream = new MemoryStream(bytes);
|
|
Stream stream = new MemoryStream(bytes);
|
|
|
|
+ while (Zips.Keys.Contains(item.FileName))
|
|
|
|
+ {
|
|
|
|
+ item.FileName = new Random().Next(100) + "_" + item.FileName;
|
|
|
|
+ }
|
|
Zips.Add(item.FileName, stream);
|
|
Zips.Add(item.FileName, stream);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3783,6 +3788,74 @@ namespace OASystem.API.Controllers
|
|
return Ok(jw);
|
|
return Ok(jw);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 下载该团组下此模块的所有文件
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost]
|
|
|
|
+ public IActionResult ExportGroupByModule(ExportGroupByModuleDto 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 && x.Ctable == dto.Ctable).ToList();
|
|
|
|
+ var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
|
|
|
|
+ && x.IsDel == 0);
|
|
|
|
+
|
|
|
|
+ if (key == null)
|
|
|
|
+ {
|
|
|
|
+ jw.Msg = "Ctable指向错误!";
|
|
|
|
+ return Ok(jw);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
|
|
|
|
+ RegexOptions.None, TimeSpan.FromSeconds(1.5));
|
|
|
|
+ groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
|
|
|
|
+ RegexOptions.None, TimeSpan.FromSeconds(1.5));
|
|
|
|
+
|
|
|
|
+ IOOperatorHelper io = new IOOperatorHelper();
|
|
|
|
+ Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
|
|
|
|
+
|
|
|
|
+ foreach (var item in dbQuery)
|
|
|
|
+ {
|
|
|
|
+ if (System.IO.File.Exists(item.FilePath))
|
|
|
|
+ {
|
|
|
|
+ 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);
|
|
|
|
+ while (Zips.Keys.Contains(item.FileName))
|
|
|
|
+ {
|
|
|
|
+ item.FileName = new Random().Next(100) + "_" + item.FileName;
|
|
|
|
+ }
|
|
|
|
+ Zips.Add(item.FileName, stream);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Zips.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ var byts = io.ConvertZipStream(Zips);
|
|
|
|
+ var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
|
|
|
|
+ io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{key.Name}_.Zip");
|
|
|
|
+ jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{key.Name}_.zip" });
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ jw.Msg = "暂无生成文件!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Ok(jw);
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 删除该团组下的指定文件
|
|
/// 删除该团组下的指定文件
|
|
/// </summary>
|
|
/// </summary>
|