Commit e102ab02 by xiongyuwen

no message

parent 3e09f7e5
...@@ -10,7 +10,8 @@ namespace Bailun.Discuz.Application.Util ...@@ -10,7 +10,8 @@ namespace Bailun.Discuz.Application.Util
public const string File_List_Tree = "FileListTree"; public const string File_List_Tree = "FileListTree";
public const string File_Id_List = "FileIdList"; public const string ForuK_First_File_List = "FirstFileList";
public const string ForuK_File_List_Tree = "FileListTree";
} }
} }
...@@ -51,8 +51,8 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -51,8 +51,8 @@ namespace Bailun.Discuz.Application.WeiPan
/// <returns></returns> /// <returns></returns>
Task<long> CreateAttachment(long userId, string fileMd5, long typeId); Task<long> CreateAttachment(long userId, string fileMd5, long typeId);
Task<List<WeiPanFileList>> GetFileList(string userId); Task<List<WeiPanFileList>> GetFileList(string userId,string companyName);
Task<string> ProcessWeiPanWorker(string userId); Task<string> ProcessWeiPanWorker(string userId, string companyName);
Task<WeiPanFileList> GetWeiPanFileByThreadId(long threadId); Task<WeiPanFileList> GetWeiPanFileByThreadId(long threadId);
Task<WeiPanFileList> GetFileInfo(string fileId); Task<WeiPanFileList> GetFileInfo(string fileId);
} }
......
...@@ -265,13 +265,13 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -265,13 +265,13 @@ namespace Bailun.Discuz.Application.WeiPan
FileListTreeDto fileListTreeDto = new FileListTreeDto(); FileListTreeDto fileListTreeDto = new FileListTreeDto();
fileListTreeDto.id = u.fileid; fileListTreeDto.id = u.fileid;
fileListTreeDto.label = Path.GetFileNameWithoutExtension(u.file_name); fileListTreeDto.label = Path.GetFileNameWithoutExtension(u.file_name);
fileListTreeDto.file = u.file_type != 1 ? true : false; fileListTreeDto.file = u.file_type==2 ? true : false;
fileListTreeDto.md5 = u.md5; fileListTreeDto.md5 = u.md5;
fileListTreeDto.icon = u.file_type == 1 ? "el-icon-folder-opened" : "el-icon-document"; fileListTreeDto.icon = u.file_type == 1 ? "el-icon-folder-opened" : "el-icon-document";
fileListTreeDto.key = u.fileid; fileListTreeDto.key = u.fileid;
fileListTreeDtos.Add(fileListTreeDto); fileListTreeDtos.Add(fileListTreeDto);
} }
if (u.file_type != 1) if (u.file_type==2)
{ {
WeipanUserFiles weipanUserFiles = new WeipanUserFiles(); WeipanUserFiles weipanUserFiles = new WeipanUserFiles();
weipanUserFiles.UserId = userId; weipanUserFiles.UserId = userId;
...@@ -302,7 +302,7 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -302,7 +302,7 @@ namespace Bailun.Discuz.Application.WeiPan
FileListTreeDto fileListTreeDto = new FileListTreeDto(); FileListTreeDto fileListTreeDto = new FileListTreeDto();
fileListTreeDto.id = fildId; fileListTreeDto.id = fildId;
fileListTreeDto.label = fileInfo.file_info.file_name; fileListTreeDto.label = fileInfo.file_info.file_name;
fileListTreeDto.file = fileInfo.file_info.file_type != 1 ? true : false; fileListTreeDto.file = fileInfo.file_info.file_type ==2? true : false;
fileListTreeDto.md5 = fileInfo.file_info.md5; fileListTreeDto.md5 = fileInfo.file_info.md5;
fileListTreeDto.key = fildId; fileListTreeDto.key = fildId;
fileListTreeDtos.Add(fileListTreeDto); fileListTreeDtos.Add(fileListTreeDto);
...@@ -371,13 +371,13 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -371,13 +371,13 @@ namespace Bailun.Discuz.Application.WeiPan
FileListTreeDto fileListTreeDto = new FileListTreeDto(); FileListTreeDto fileListTreeDto = new FileListTreeDto();
fileListTreeDto.id = i.fileid; fileListTreeDto.id = i.fileid;
fileListTreeDto.label = Path.GetFileNameWithoutExtension(i.file_name); fileListTreeDto.label = Path.GetFileNameWithoutExtension(i.file_name);
fileListTreeDto.file = i.file_type != 1 ? true : false; fileListTreeDto.file = i.file_type==2 ? true : false;
fileListTreeDto.md5 = i.md5; fileListTreeDto.md5 = i.md5;
fileListTreeDto.icon = i.file_type == 1 ? "el-icon-folder-opened" : "el-icon-document"; fileListTreeDto.icon = i.file_type == 1 ? "el-icon-folder-opened" : "el-icon-document";
fileListTreeDto.key = i.fileid; fileListTreeDto.key = i.fileid;
fileListTreeDtos.Add(fileListTreeDto); fileListTreeDtos.Add(fileListTreeDto);
} }
if (i.file_type != 1) if (i.file_type ==2)
{ {
WeipanUserFiles weipanUserFiles = new WeipanUserFiles(); WeipanUserFiles weipanUserFiles = new WeipanUserFiles();
weipanUserFiles.UserId = userId; weipanUserFiles.UserId = userId;
...@@ -630,13 +630,13 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -630,13 +630,13 @@ namespace Bailun.Discuz.Application.WeiPan
/// 处理微盘自动发帖功能 /// 处理微盘自动发帖功能
/// </summary> /// </summary>
public async Task<string> ProcessWeiPanWorker(string userId) public async Task<string> ProcessWeiPanWorker(string userId,string companyName)
{ {
StringBuilder messageSb = new StringBuilder(); ; StringBuilder messageSb = new StringBuilder(); ;
// string userId = "chenzekai"; // string userId = "chenzekai";
List<WeiPanFileList> inserWeiPanFileList = new List<WeiPanFileList>(); List<WeiPanFileList> inserWeiPanFileList = new List<WeiPanFileList>();
//1:获取线上的所有文档数据 //1:获取线上的所有文档数据
var filList=await GetFileList(userId); var filList=await GetFileList(userId,companyName);
//string value = "测试数据"; //string value = "测试数据";
//RedisHelper.Set("key", filList); //RedisHelper.Set("key", filList);
...@@ -682,7 +682,7 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -682,7 +682,7 @@ namespace Bailun.Discuz.Application.WeiPan
} }
//判断线上文件列表数据是否有删除,如果有删除要进行同步删除 //判断线上文件列表数据是否有删除,如果有删除要进行同步删除
var fileList= await _weiPanFileListRepository.Query().AsNoTracking().ToListAsync(); var fileList= await _weiPanFileListRepository.Query().AsNoTracking().Where(u=>u.CompanyName==companyName).ToListAsync();
var delFiles = new List<WeiPanFileList>(); var delFiles = new List<WeiPanFileList>();
if (filList.Count>0) if (filList.Count>0)
{ {
...@@ -702,12 +702,12 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -702,12 +702,12 @@ namespace Bailun.Discuz.Application.WeiPan
if (inserWeiPanFileList.Count>0|| delFiles.Any())//有新增则清除缓存 if (inserWeiPanFileList.Count>0|| delFiles.Any())//有新增则清除缓存
{ {
messageSb.Append($"新增帖子数量为:{inserWeiPanFileList.Count},分别为:{string.Join(",", inserWeiPanFileList.Select(u => u.FileName).ToArray()) };"); messageSb.Append($"新增帖子数量为:{inserWeiPanFileList.Count},分别为:{string.Join(",", inserWeiPanFileList.Select(u => u.FileName).ToArray()) };");
RedisHelper.Del(Constants.File_List_Tree);//清除缓存 //RedisHelper.Del(Constants.File_List_Tree);//清除缓存
RedisHelper.Del(Constants.First_File_List);//清除缓存 //RedisHelper.Del(Constants.First_File_List);//清除缓存
await CreateUserFilesTreeRedis(); await CreateUserFilesTreeRedis(companyName);
} }
_weiPanFileListRepository.BulkInsert(inserWeiPanFileList.ToArray()); _weiPanFileListRepository.BulkInsert(inserWeiPanFileList.ToArray());
var noTieZilist=await _weiPanFileListRepository.Query().AsNoTracking().Where(u => u.ThreadId == 0).ToListAsync(); var noTieZilist=await _weiPanFileListRepository.Query().AsNoTracking().Where(u => u.ThreadId == 0&&u.CompanyName==companyName).ToListAsync();
foreach (var item in noTieZilist) foreach (var item in noTieZilist)
{ {
//对新增的文档进行创建帖子 //对新增的文档进行创建帖子
...@@ -745,16 +745,18 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -745,16 +745,18 @@ namespace Bailun.Discuz.Application.WeiPan
/// </summary> /// </summary>
/// <param name="userId"></param> /// <param name="userId"></param>
/// <returns></returns> /// <returns></returns>
public async Task<string> CreateUserFilesTreeRedis() public async Task<string> CreateUserFilesTreeRedis(string companyName)
{ {
//对推送消息进行控制,减少调用次数 //对推送消息进行控制,减少调用次数
var includUsers= "陈泽凯,田壮虎,付典,陈琦,钟晓桐,张仲杰,冯晓茵,高得胜,李可欣,黎慧琼,赵伟铭"; var includUsers= "陈泽凯,田壮虎,付典,陈琦,钟晓桐,张仲杰,冯晓茵,高得胜,李可欣,黎慧琼,赵伟铭";
var userList = await _usersRepository.Query().AsNoTracking().Where(u=>includUsers.Split(',').Contains(u.UserName)|| u.LoginAt>=(DateTime.Now.AddDays(-8).Date)).ToListAsync(); var userList = await _usersRepository.Query().AsNoTracking().Where(u=>(includUsers.Split(',').Contains(u.UserName)|| u.LoginAt>=(DateTime.Now.AddDays(-8).Date))&&u.CompanyName==companyName).ToListAsync();
foreach (var item in userList) foreach (var item in userList)
{ {
if(item.UserId!=null) if(item.UserId!=null)
{ {
RedisHelper.HDel(Constants.File_List_Tree,item.UserId);
RedisHelper.HDel(Constants.First_File_List, item.UserId);
List<string> fileIds = new List<string>(); List<string> fileIds = new List<string>();
//获取用户对于的首层文件列表 //获取用户对于的首层文件列表
var firstFiles = await GetFirstFileList(item.UserId); var firstFiles = await GetFirstFileList(item.UserId);
...@@ -876,7 +878,7 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -876,7 +878,7 @@ namespace Bailun.Discuz.Application.WeiPan
{ {
files.ForEach(i => files.ForEach(i =>
{ {
if(i.file_type!=1 && i.file_status == "1") if(i.file_type==2 && i.file_status == "1")
{ {
i.firstfileid = firstFileId; i.firstfileid = firstFileId;
fileItems.Add(i); fileItems.Add(i);
...@@ -901,7 +903,7 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -901,7 +903,7 @@ namespace Bailun.Discuz.Application.WeiPan
/// <summary> /// <summary>
/// 递归获取所有首页下的所有文件列表数据 /// 递归获取所有首页下的所有文件列表数据
/// </summary> /// </summary>
public async Task<List<WeiPanFileList>> GetFileList(string userId) public async Task<List<WeiPanFileList>> GetFileList(string userId,string companyName)
{ {
List<WeiPanFileList> weiPanFileLists = new List<WeiPanFileList>(); List<WeiPanFileList> weiPanFileLists = new List<WeiPanFileList>();
List<ItemItem> itemItems = new List<ItemItem>(); List<ItemItem> itemItems = new List<ItemItem>();
...@@ -912,7 +914,7 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -912,7 +914,7 @@ namespace Bailun.Discuz.Application.WeiPan
firstFiles.file_list.item.ForEach(u => firstFiles.file_list.item.ForEach(u =>
{ {
u.firstfileid = u.fileid; u.firstfileid = u.fileid;
if (u.file_type != 1&&u.file_status=="1")//说明是文件 if (u.file_type == 2&&u.file_status=="1")//说明是文件
{ {
itemItems.Add(u); itemItems.Add(u);
} }
...@@ -930,6 +932,7 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -930,6 +932,7 @@ namespace Bailun.Discuz.Application.WeiPan
weiPanFile.FileId = u.fileid; weiPanFile.FileId = u.fileid;
weiPanFile.FileMd5 = u.md5; weiPanFile.FileMd5 = u.md5;
weiPanFile.FileName =u.file_name; weiPanFile.FileName =u.file_name;
weiPanFile.CompanyName = companyName;
weiPanFile.FirstFileId = u.firstfileid; weiPanFile.FirstFileId = u.firstfileid;
weiPanFile.QiniuUrl =""; weiPanFile.QiniuUrl ="";
weiPanFile.FileCreateUseid = u.create_userid; weiPanFile.FileCreateUseid = u.create_userid;
......
...@@ -23,7 +23,7 @@ namespace Bailun.Discuz.Domain.WeiPan ...@@ -23,7 +23,7 @@ namespace Bailun.Discuz.Domain.WeiPan
[Column("thread_id")] public long ThreadId { get; set; } [Column("thread_id")] public long ThreadId { get; set; }
[Column("first_file_id")] public string FirstFileId { get; set; } [Column("first_file_id")] public string FirstFileId { get; set; }
[Column("file_create_useid")] public string FileCreateUseid { get; set; } [Column("file_create_useid")] public string FileCreateUseid { get; set; }
[Column("company_name")] public string CompanyName { get; set; }
} }
} }
...@@ -79,11 +79,11 @@ namespace Bailun.Discuz.Service.Controllers ...@@ -79,11 +79,11 @@ namespace Bailun.Discuz.Service.Controllers
} }
[HttpGet("ProcessWeiPanWorker")] [HttpGet("ProcessWeiPanWorker")]
public async Task<string> ProcessWeiPanWorker(string userId) public async Task<string> ProcessWeiPanWorker(string userId,string companyName)
{ {
RedisHelper.Del(Constants.File_List_Tree);//清除缓存 RedisHelper.Del(Constants.File_List_Tree);//清除缓存
RedisHelper.Del(Constants.First_File_List);//清除缓存 RedisHelper.Del(Constants.First_File_List);//清除缓存
return await _iweiPanService.ProcessWeiPanWorker(userId); return await _iweiPanService.ProcessWeiPanWorker(userId, companyName);
} }
[HttpGet("GetFileInfo")] [HttpGet("GetFileInfo")]
public async Task<WeiPanFileList> GetFileInfo(string fileId) public async Task<WeiPanFileList> GetFileInfo(string fileId)
......
...@@ -27,7 +27,7 @@ namespace Bailun.Discuz.ConsoleApp.Publish.Worker ...@@ -27,7 +27,7 @@ namespace Bailun.Discuz.ConsoleApp.Publish.Worker
Timer.Stop(); Timer.Stop();
Timer.RunOnStart = false; Timer.RunOnStart = false;
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:开始生成4K帖子中"); Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:开始生成4K帖子中");
var result = _weiPanService.ProcessWeiPanWorker("gaodesheng").GetAwaiter().GetResult(); var result = _weiPanService.ProcessWeiPanWorker("gaodesheng", "四千里数据科技有限公司").GetAwaiter().GetResult();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:生成4K帖子完毕," + result); Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:生成4K帖子完毕," + result);
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -28,7 +28,7 @@ namespace Bailun.Discuz.ConsoleApp.Publish.Worker ...@@ -28,7 +28,7 @@ namespace Bailun.Discuz.ConsoleApp.Publish.Worker
Timer.Stop(); Timer.Stop();
Timer.RunOnStart = false; Timer.RunOnStart = false;
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:开始生成百伦帖子中"); Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:开始生成百伦帖子中");
var result= _weiPanService.ProcessWeiPanWorker("chenzekai").GetAwaiter().GetResult(); var result= _weiPanService.ProcessWeiPanWorker("chenzekai", "广州百伦供应链科技有限公司").GetAwaiter().GetResult();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:生成百伦帖子完毕," + result); Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:生成百伦帖子完毕," + result);
} }
catch (Exception ex) catch (Exception ex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment