Commit 8c3a280d by xiongyuwen

no message

parent 3d04a6da
...@@ -127,6 +127,25 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -127,6 +127,25 @@ namespace Bailun.Discuz.Application.WeiPan
} }
} }
/// <summary>
/// 判断当前用户是否可以访问4K,如果companyName为4K的情况下
/// </summary>
/// <param name="userId"></param>
/// <param name="companyName"></param>
/// <returns></returns>
public string GetVisitFourKUserId(string userId, string companyName)
{
if (companyName == "四千里数据科技有限公司")
{
var user = _usersRepository.Query().AsNoTracking().Where(u => u.UserId == userId).FirstOrDefault();
if (user.VisitFourK)
{
//切换高德胜的账号来访问
userId = "gaodesheng";
}
}
return userId;
}
///// <summary> ///// <summary>
///// 获取首层文件列表 ///// 获取首层文件列表
...@@ -135,17 +154,17 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -135,17 +154,17 @@ namespace Bailun.Discuz.Application.WeiPan
///// <returns></returns> ///// <returns></returns>
public async Task<GetFileListResponse> GetFirstFileList(string userId,string companyName,bool isGetRedis=true,bool isDelCaching=false) public async Task<GetFileListResponse> GetFirstFileList(string userId,string companyName,bool isGetRedis=true,bool isDelCaching=false)
{ {
userId=GetVisitFourKUserId(userId, companyName);
//判断缓存中是否有值,如果有值直接读取 //判断缓存中是否有值,如果有值直接读取
var redisKey = Constants.First_File_List+ companyName; var redisKey = Constants.First_File_List+ $"_{companyName}";
GetFileListResponse cachingResponse = null; GetFileListResponse cachingResponse = null;
if(isDelCaching) if(isDelCaching)
{ {
RedisHelper.HDel(redisKey, $"{userId}_{companyName}"); RedisHelper.HDel(redisKey, $"{userId}");
} }
if(isGetRedis) if(isGetRedis)
{ {
cachingResponse = RedisHelper.HGet<GetFileListResponse>(redisKey,$"{userId}_{companyName}" ); cachingResponse = RedisHelper.HGet<GetFileListResponse>(redisKey,$"{userId}" );
} }
if (cachingResponse != null) if (cachingResponse != null)
{ {
...@@ -183,20 +202,24 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -183,20 +202,24 @@ namespace Bailun.Discuz.Application.WeiPan
} }
apiOutput.file_list.item.ForEach(u => apiOutput.file_list.item.ForEach(u =>
{ {
if (u.file_name.Contains("-")) if(!u.file_name.Contains("客户资料")) //剔除客户资料
{
u.file_name = u.file_name.Split('-')[1];
}
var user = realNames.Where(r => r.wxUserId == u.create_userid.ToLower()).FirstOrDefault();
if (user != null)
{ {
u.create_user_name = user.userName; if (u.file_name.Contains("-"))
} {
else u.file_name = u.file_name.Split('-')[1];
{ }
u.create_user_name = u.create_userid; var user = realNames.Where(r => r.wxUserId == u.create_userid.ToLower()).FirstOrDefault();
if (user != null)
{
u.create_user_name = user.userName;
}
else
{
u.create_user_name = u.create_userid;
}
u.ctime = ConvertToDateTime(u.ctime);
} }
u.ctime = ConvertToDateTime(u.ctime);
}); });
apiOutput.companyName = companyName; apiOutput.companyName = companyName;
} }
...@@ -251,10 +274,11 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -251,10 +274,11 @@ namespace Bailun.Discuz.Application.WeiPan
/// </summary> /// </summary>
public async Task<List<FileListTreeDto>> GetFileListTree(string userId,string companyName, string fildId, bool isGetRedis = true,bool isDelCaching = false) public async Task<List<FileListTreeDto>> GetFileListTree(string userId,string companyName, string fildId, bool isGetRedis = true,bool isDelCaching = false)
{ {
userId = GetVisitFourKUserId(userId, companyName);
List<FileListTreeDto> fileListTreeDtos = new List<FileListTreeDto>(); List<FileListTreeDto> fileListTreeDtos = new List<FileListTreeDto>();
List<FileListTreeDto> cachingResponse = null; List<FileListTreeDto> cachingResponse = null;
//判断缓存中是否有值,如果有值直接读取 //判断缓存中是否有值,如果有值直接读取
var redisKey = Constants.File_List_Tree+companyName; var redisKey = Constants.File_List_Tree + $"_{companyName}"; ;
if(isDelCaching) if(isDelCaching)
{ {
RedisHelper.HDel(redisKey, userId + "_" + fildId); RedisHelper.HDel(redisKey, userId + "_" + fildId);
...@@ -322,15 +346,17 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -322,15 +346,17 @@ namespace Bailun.Discuz.Application.WeiPan
{ {
//获取文件信息 //获取文件信息
var fileInfo = GetFileInfo(token, fildId, userId); var fileInfo = GetFileInfo(token, fildId, userId);
FileListTreeDto fileListTreeDto = new FileListTreeDto(); if (!IsVideoFile(fileInfo.file_info.file_name))//剔除视频
fileListTreeDto.id = fildId; {
fileListTreeDto.label = fileInfo.file_info.file_name; FileListTreeDto fileListTreeDto = new FileListTreeDto();
fileListTreeDto.file = fileInfo.file_info.file_type ==2? true : false; fileListTreeDto.id = fildId;
fileListTreeDto.md5 = fileInfo.file_info.md5; fileListTreeDto.label = fileInfo.file_info.file_name;
fileListTreeDto.key = fildId; fileListTreeDto.file = fileInfo.file_info.file_type == 2 ? true : false;
fileListTreeDtos.Add(fileListTreeDto); fileListTreeDto.md5 = fileInfo.file_info.md5;
fileListTreeDto.key = fildId;
fileListTreeDtos.Add(fileListTreeDto);
}
} }
} }
else else
{ {
...@@ -715,11 +741,11 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -715,11 +741,11 @@ namespace Bailun.Discuz.Application.WeiPan
// 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,companyName);//调试注释 var filList=await GetFileList(userId,companyName);//调试注释
//string value = "测试数据"; //string value = "测试数据";
//RedisHelper.Set("key", filList); //RedisHelper.Set("key", filList);
List<WeiPanFileList> filList = RedisHelper.Get<List<WeiPanFileList>>("key"); //List<WeiPanFileList> filList = RedisHelper.Get<List<WeiPanFileList>>("key");
//filList.RemoveAt(1); //filList.RemoveAt(1);
//2:判断当前fileid是否存在于数据库中, 如果不存在则添加 //2:判断当前fileid是否存在于数据库中, 如果不存在则添加
foreach (var file in filList) foreach (var file in filList)
...@@ -930,28 +956,30 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -930,28 +956,30 @@ namespace Bailun.Discuz.Application.WeiPan
public async Task ProcessWeipanUserFilesByHr(string companyName, List<WeiPanFileList> weiPanFileLists) public async Task ProcessWeipanUserFilesByHr(string companyName, List<WeiPanFileList> weiPanFileLists)
{ {
var includUsers = "陈琦,钟晓桐,冯晓茵,李可欣,黎慧琼,熊裕文,田壮虎,赵伟铭"; if(companyName != "四千里数据科技有限公司")
var userList = _usersRepository.Query().AsNoTracking().Where(u => (includUsers.Split(',').Contains(u.UserName))).ToList();
foreach (var item in userList)
{ {
if (item.UserId != null) var includUsers = "陈琦,钟晓桐,冯晓茵,李可欣,黎慧琼,熊裕文,田壮虎,赵伟铭";
var userList = _usersRepository.Query().AsNoTracking().Where(u => (includUsers.Split(',').Contains(u.UserName))).ToList();
foreach (var item in userList)
{ {
var weipanUserFileList = new List<WeipanUserFiles>(); if (item.UserId != null)
if(weiPanFileLists!=null)
{ {
weiPanFileLists.ForEach(u=> { var weipanUserFileList = new List<WeipanUserFiles>();
WeipanUserFiles weipanUserFiles = new WeipanUserFiles(); if (weiPanFileLists != null)
weipanUserFiles.File_Id = u.FileId; {
weipanUserFiles.FatherFileId = u.FirstFileId; weiPanFileLists.ForEach(u => {
weipanUserFiles.Company_Name = companyName; WeipanUserFiles weipanUserFiles = new WeipanUserFiles();
weipanUserFiles.UserId = item.UserId; weipanUserFiles.File_Id = u.FileId;
weipanUserFileList.Add(weipanUserFiles); weipanUserFiles.FatherFileId = u.FirstFileId;
}); weipanUserFiles.Company_Name = companyName;
} weipanUserFiles.UserId = item.UserId;
await _weipanUserFilesRepository.DeleteAsync(u => u.UserId == item.UserId&&u.Company_Name==companyName); weipanUserFileList.Add(weipanUserFiles);
await _weipanUserFilesRepository.BulkInsertAsync(weipanUserFileList.ToArray()); });
#region 旧逻辑 }
await _weipanUserFilesRepository.DeleteAsync(u => u.UserId == item.UserId && u.Company_Name == companyName);
await _weipanUserFilesRepository.BulkInsertAsync(weipanUserFileList.ToArray());
#region 旧逻辑
//List<string> fileIds = new List<string>(); //List<string> fileIds = new List<string>();
////获取用户对于的首层文件列表 ////获取用户对于的首层文件列表
//var firstFiles = await GetFirstFileList(item.UserId, companyName,true,true); //var firstFiles = await GetFirstFileList(item.UserId, companyName,true,true);
...@@ -965,7 +993,8 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -965,7 +993,8 @@ namespace Bailun.Discuz.Application.WeiPan
// } // }
// await _weipanUserFilesRepository.BulkInsertAsync(weipanUserFileList.ToArray()); // await _weipanUserFilesRepository.BulkInsertAsync(weipanUserFileList.ToArray());
//} //}
#endregion #endregion
}
} }
} }
} }
...@@ -1151,7 +1180,7 @@ namespace Bailun.Discuz.Application.WeiPan ...@@ -1151,7 +1180,7 @@ namespace Bailun.Discuz.Application.WeiPan
{ {
firstFiles.file_list.item.ForEach(u => firstFiles.file_list.item.ForEach(u =>
{ {
if (!u.file_name.Contains("客户资料")&& u.file_name.Contains("商务流程")) if (!u.file_name.Contains("客户资料"))
{ {
u.firstfileid = u.fileid; u.firstfileid = u.fileid;
u.firstFileName = u.file_name; u.firstFileName = u.file_name;
......
...@@ -55,5 +55,6 @@ namespace Bailun.Discuz.Domain.WeiPan ...@@ -55,5 +55,6 @@ namespace Bailun.Discuz.Domain.WeiPan
[Column("department")] public string Department { get; set; } [Column("department")] public string Department { get; set; }
[Column("userid")] public string UserId { get; set; } [Column("userid")] public string UserId { get; set; }
[Column("company_name")] public string CompanyName { get; set; } [Column("company_name")] public string CompanyName { get; set; }
[Column("visitfourk")] public bool VisitFourK { get; set; }
} }
} }
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