Forráskód Böngészése

共享文件Api添加......

yuanrf 4 hónapja%!(EXTRA string=óta)
szülő
commit
7c726a2f09

+ 4 - 3
OASystem/EntitySync/Program.cs

@@ -150,8 +150,9 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Grp_RestaurantInfo),
     //ypeof(Grp_EnterExitCostQuote), //团组 - 出入境费用报价表
     //ypeof(Grp_EnterExitCostQuoteItem), //团组 - 出入境费用报价表
-    typeof(Sys_FormTemp), //表单模板
-    typeof(Grp_OrderPreInfo), //团组下单前信息
-    typeof(Grp_OrderPreItem), //团组下单前信息Item
+    //typeof(Sys_FormTemp), //表单模板
+    //typeof(Grp_OrderPreInfo), //团组下单前信息
+    //typeof(Grp_OrderPreItem), //团组下单前信息Item
+    typeof(GroupShareFile),//团组共享文件
 }); 
 Console.WriteLine("数据库结构同步完成!");

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

@@ -6,6 +6,7 @@ using Aspose.Words.Tables;
 using DiffMatchPatch;
 using EyeSoft.Runtime.InteropServices;
 using Google.Protobuf.WellKnownTypes;
+using Microsoft.AspNetCore.Mvc.RazorPages;
 using Microsoft.AspNetCore.SignalR;
 using Microsoft.IdentityModel.Tokens;
 using Microsoft.VisualBasic;
@@ -50,6 +51,7 @@ using System.Data;
 using System.Diagnostics;
 using System.Drawing.Printing;
 using System.Globalization;
+using System.IO;
 using System.IO.Compression;
 using System.Text.Json;
 using System.Web;
@@ -5095,6 +5097,153 @@ FROM
             return Ok(jw);
         }
 
+        [HttpPost]
+        public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
+        {
+            if (dto.Files == null || dto.Files.Count == 0)
+            {
+                return Ok(JsonView(false, "无文件信息!"));
+            }
+
+            if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
+            {
+                return Ok(JsonView(false, "文件大小超过20M!"));
+            }
+
+            if(dto.Userid < 1)
+            {
+                return Ok(JsonView(false, "请传入有效的Userid!"));
+            }
+
+            var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
+                                    .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
+                                    .Select((u,j)=> new
+                                    {
+                                        u.CnName,
+                                        UserId = u.Id,
+                                        j.JobName,
+                                    })
+                                    .First();
+
+            if (jobInfo == null)
+            {
+                return Ok(JsonView(false, "请传入有效的Userid!"));
+            }
+
+            List<string> commonFileExtensions = new List<string>
+            {
+                // 文本文件
+                ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
+            
+                // 图片文件
+                ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
+            
+                // 视频文件
+                ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
+            
+                // 音频文件
+                ".mp3", ".wav", ".ogg", ".aac", ".flac",
+            
+                // 压缩文件
+                ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
+            
+                // 数据文件
+                ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
+            };
+
+            try
+            {
+                var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
+                var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
+                commonFileExtensions.AddRange(settingExtend);
+            }
+            catch (Exception)
+            {}
+
+            var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
+
+            if (setdata == null)
+            {
+                return Ok(JsonView(false, "请传入有效的FileType!"));
+            }
+
+            List<GroupShareFile> insertList = new List<GroupShareFile>();
+
+            string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"\\{setdata.Name}\\";
+
+            if (!Directory.Exists(winPath))
+            {
+                Directory.CreateDirectory(winPath);
+            }
+
+            foreach (var item in dto.Files)
+            {
+                var houzui = Path.GetExtension(item.FileName);
+
+                if (!commonFileExtensions.Contains(houzui))
+                {
+                    return Ok(JsonView(false, "未知后缀名称!"));
+                }
+
+                var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
+                var saveFilePath = winPath + fileName;
+
+                using (FileStream fs = System.IO.File.Create(saveFilePath))
+                {
+                    item.CopyTo(fs);
+                    fs.Flush();
+                }
+
+                var fileDetail = new GroupShareFile()
+                {
+                    CreateUserId = dto.Userid,
+                    CreateTime = DateTime.Now,
+                    UploadJob = jobInfo.JobName,
+                    FileName = fileName,
+                    FileType = dto.FileType,
+                    Diid = dto.Diid,
+                    FilePath = winPath + fileName,
+                };
+
+                insertList.Add(fileDetail);
+            }
+
+            _sqlSugar.Insertable<GroupShareFile>(insertList).ExecuteCommand();
+
+            return Ok(JsonView(true,"保存成功!"));
+            
+        }
+
+        [HttpPost]
+        public IActionResult QuerySharedFile(QuerySharedFileDto dto) 
+        {
+            var queryExpression = Expressionable.Create<GroupShareFile>()
+                .AndIF(dto.Diid != 0, x => x.Diid == dto.Diid)
+                .AndIF(dto.FileType != 0, x => x.FileType == dto.FileType)
+                .And(x => x.IsDel == 0);
+
+            int totalCount = 0;
+            var dbQuery = _sqlSugar.Queryable<GroupShareFile>()
+                        .Where(queryExpression.ToExpression())
+                        .Select(x => new
+                        {
+                            x.Id,
+                            FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
+                            x.FileName,
+                            x.FileType,
+                            x.CreateTime,
+                        })
+                        .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
+
+            return Ok(JsonView(true, "success", new
+            {
+                FileList = dbQuery,
+                dto.PageSize,
+                dto.PageIndex,
+                totalCount
+            }));
+        }
+
         /// <summary>
         /// 查询各模块已保存文件
         /// </summary>

+ 124 - 0
OASystem/OASystem.Api/Controllers/MarketCustomerResourcesController.cs

@@ -1197,5 +1197,129 @@ namespace OASystem.API.Controllers
             return Ok(jw);
         }
 
+        [HttpPost]
+        public IActionResult InsertDataExcel(InsertDataExcelDto dto)
+        {
+            //string client = dto.Client;
+
+            int toUser = dto.ToUser;
+
+            var clietnArr = dto.Client;
+
+            var count = 0;
+
+            var notClentUser = new List<int>() { 21, 95  , 327 };
+
+            var insertList = new List<Crm_ClientDataAndUser>();
+
+            if (clietnArr.Count > 0)
+            {
+                _sqlSugar.BeginTran();
+
+
+                //检索相关客户数据
+                var newClientArr = _sqlSugar.Queryable<Crm_NewClientData>()
+                    .Where(x => x.IsDel == 0)
+                    .Select(x => new Crm_NewClientData
+                    {
+                        Client = x.Client,
+                        Id = x.Id
+                    })
+                    .ToList()
+                    .Select(x => new
+                    {
+                        Client = AesEncryptionHelper.Decrypt(x.Client),
+                        Id = x.Id
+                    });
+
+                foreach (var item in clietnArr)
+                {
+                    var searchClient = newClientArr.Where(x => x.Client == item).ToList();
+
+                    foreach (var clientData in searchClient)
+                    {
+                        var clientDataAndUser = _sqlSugar.Queryable<Crm_ClientDataAndUser>()
+                                                .Where(x => x.NewClientDataId == clientData.Id && x.IsDel == 0)
+                                                .ToList();
+
+                        if (clientDataAndUser.Count > 0)
+                        {
+                            //清除关联表数据
+                            _sqlSugar.Updateable<Crm_ClientDataAndUser>()
+                                .Where(x => !notClentUser.Contains(x.usersId) 
+                                && x.NewClientDataId == clientData.Id && x.IsDel == 0)
+                                .SetColumns(x=> new Crm_ClientDataAndUser
+                                {
+                                    IsDel = 1,
+                                    DeleteTime = DateTime.Now.ToString(),
+                                    DeleteUserId = 235
+                                })
+                                .ExecuteCommand();
+                        }
+
+                        insertList.Add(new Crm_ClientDataAndUser
+                        {
+                            usersId = toUser,
+                            NewClientDataId = clientData.Id,
+                            CreateTime = DateTime.Now,
+                            CreateUserId = 235,
+                        });
+                    }
+                }
+
+                count = _sqlSugar.Insertable(insertList).ExecuteCommand();
+
+                _sqlSugar.CommitTran();
+            }
+
+            return Ok(new
+            {
+                count,
+            });
+        }
+
+
+        #region 回滚数据记录
+
+
+        //[HttpPost]
+        //public async Task<IActionResult> actionResult()
+        //{
+        //    var jw = JsonView(true);
+        //    var sql = @" SELECT * FROM OA2023DB.dbo.Crm_TableOperationRecord 
+        //                 WHERE TableName ='Crm_NewClientData' 
+        //                 AND OperationItem IN(4) AND  CreateTime > '2025-02-03' AND  CreateTime < '2025-03-06' 
+        //                 AND ReturnResult LIKE '%修改成功%'	";
+
+        //    var list = _sqlSugar.SqlQueryable<Crm_TableOperationRecord>(sql).Select(x=>new Crm_TableOperationRecord
+        //    {
+        //        RequestParam = x.RequestParam
+        //    }).ToList();
+
+        //    foreach (var item in list)
+        //    {
+        //        var string1 = item.RequestParam.Trim('"').Replace("\\", "");
+        //        //if (!string.IsNullOrEmpty(item.RequestParam))
+        //        //{
+
+        //        //    var req = item.RequestParam;
+
+        //        //    if (CommonFun.IsValidJson(item.RequestParam))
+        //        //    {
+
+        //        //        var res1 = JToken.Parse(item.RequestParam);
+
+        //        //    }
+
+
+        //        //    NewClientOpDto dto = JsonConvert.DeserializeObject<NewClientOpDto>(JsonConvert.DeserializeObject<string>(item.RequestParam));
+        //            NewClientOpDto dto1 = JsonConvert.DeserializeObject<NewClientOpDto>(string1);
+        //            var result = await this.NewClientOp(dto1);
+        //        //}
+        //    }
+
+        //    return Ok(jw);
+        //}
+        #endregion
     }
 }

+ 4 - 0
OASystem/OASystem.Api/appsettings.json

@@ -150,6 +150,10 @@
   "GrpFileBasePath": "D:/FTP/File/OA2023/Office/GrpFile/",
   "GrpFileFtpPath": "Office/GrpFile/",
 
+  "ShareFileBaseUrl": "http://132.232.92.186:24/",
+  "ShareFileBasePath": "D:/FTP/File/OA2023/Office/ShareFile/",
+  "ShareFileFtpPath": "Office/ShareFile/",
+
   "ExcelTempPath": "D:/FTP/File/OA2023/Office/Excel/Template/",
   "GrpListFileBasePath": "D:/FTP/File/OA2023/Office/GrpFile/GroupList/",
   "GrpListFileFtpPath": "Office/GrpFile/GroupList/",

+ 8 - 1
OASystem/OASystem.Domain/Dtos/CRM/NewClientDataQueryDto.cs

@@ -155,7 +155,7 @@ namespace OASystem.Domain.Dtos.CRM
         /// <summary>
         /// 护照日期
         /// </summary>
-        public DateTime PassportDate { get; set; }
+        public DateTime? PassportDate { get; set; }
 
         /// <summary>
         /// 职位
@@ -319,4 +319,11 @@ namespace OASystem.Domain.Dtos.CRM
         public int UserId { get; set; }
     }
 
+    public class InsertDataExcelDto
+    {
+        public List<string>  Client { get; set; }
+
+        public int ToUser { get; set; }
+    }
+
 }

+ 17 - 0
OASystem/OASystem.Domain/Dtos/FileDto/FileDto.cs

@@ -36,6 +36,23 @@ namespace OASystem.Domain.Dtos.FileDto
         public int Userid { get; set; }
     }
 
+    public class SharedFileUploadDto
+    {
+        public List<IFormFile> Files { get; set; }
+        public int Diid { get; set; }
+        public int Userid { get; set; }
+        public int FileType { get; set; }
+    }
+
+    public class QuerySharedFileDto
+    {
+        public int Diid { get; set; }
+        public int FileType { get; set; }
+        public int PageIndex { get; set; }
+
+        public int PageSize { get; set; }
+    }
+
     public class QueryGroupModelFileDto
     {
         public int Ctable { get; set; }

+ 41 - 0
OASystem/OASystem.Domain/Entities/Groups/GroupShareFile.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Groups
+{
+    public class GroupShareFile:EntityBase
+    {
+        /// <summary>
+        /// 文件名称
+        /// </summary>
+        [SugarColumn(ColumnName = "FileName", ColumnDescription = "文件名称", IsNullable = false)]
+        public string FileName { get; set; }
+
+        /// <summary>
+        /// 文件存储路径
+        /// </summary>
+        [SugarColumn(ColumnName = "FilePath", ColumnDescription = "文件存储路径", IsNullable = false)]
+        public string FilePath { get; set; }
+
+        /// <summary>
+        /// 文件所属类型
+        /// </summary>
+        [SugarColumn(ColumnName = "FileType", ColumnDescription = "文件所属类型", IsNullable = false)]
+        public int FileType { get; set; }
+
+        /// <summary>
+        /// 团组关联ID
+        /// </summary>
+        [SugarColumn(ColumnName = "Diid", ColumnDescription = "团组关联ID", IsNullable = false)]
+        public int Diid { get; set; }
+
+        /// <summary>
+        /// 上传人职位
+        /// </summary>
+        [SugarColumn(ColumnName = "UploadJob", ColumnDescription = "上传人职位", IsNullable = false)]
+        public string UploadJob { get; set; }
+    }
+}