增加系统文档导出
This commit is contained in:
@@ -350,6 +350,114 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
|
||||
#region 导表查询
|
||||
|
||||
///getSysDocumentConfirmList 系统文档培训查询
|
||||
///
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> GetSysDocumentConfirmList_Export(SystemDocQuery inQuery,
|
||||
[FromServices] IRepository<SystemDocument> _systemDocumentRepository,
|
||||
[FromServices] IRepository<IdentityUser> _identityUserRepository,
|
||||
[FromServices] IDictionaryService _dictionaryService)
|
||||
{
|
||||
var systemDocQuery =
|
||||
from sysDoc in _systemDocumentRepository.AsQueryable(false)
|
||||
.Where(t => inQuery.UserTypeId != null ? t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == inQuery.UserTypeId) : true)
|
||||
from identityUser in _identityUserRepository.AsQueryable(false).Where(t => t.UserRoleList.Where(t => t.IsUserRoleDisabled == false).Any(t => sysDoc.NeedConfirmedUserTypeList.AsQueryable().Any(c => c.NeedConfirmUserTypeId == t.UserTypeId)))
|
||||
.Where(t => inQuery.UserId != null ? t.Id == inQuery.UserId : true)
|
||||
.Where(t => inQuery.UserTypeId != null ? t.UserRoleList.Any(t => t.UserTypeId == inQuery.UserTypeId && t.IsUserRoleDisabled == false) : true)
|
||||
join confirm in _systemDocConfirmedUserRepository.Where() on new { ConfirmUserId = identityUser.Id, SystemDocumentId = sysDoc.Id } equals new { confirm.ConfirmUserId, confirm.SystemDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new TrainingRecordExportDTO()
|
||||
{
|
||||
IsSystemDoc = true,
|
||||
Id = sysDoc.Id,
|
||||
CreateTime = sysDoc.CreateTime,
|
||||
IsDeleted = sysDoc.IsDeleted,
|
||||
Name = sysDoc.Name,
|
||||
FileType = _userInfo.IsEn_Us ? sysDoc.FileType.Value : sysDoc.FileType.ValueCN,
|
||||
FileTypeId = sysDoc.FileTypeId,
|
||||
//IsConfirmed = confirm.ConfirmTime != null,
|
||||
|
||||
ConfirmUserId = identityUser.Id,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
|
||||
RealName = identityUser.FullName,
|
||||
UserName = identityUser.UserName,
|
||||
|
||||
|
||||
//UpdateTime = sysDoc.UpdateTime,
|
||||
//SignViewMinimumMinutes = sysDoc.SignViewMinimumMinutes,
|
||||
//UserTypeId = trialUser.UserRole.UserTypeId,
|
||||
//UserTypeShortName = trialUser.UserRole.UserTypeRole.UserTypeShortName,
|
||||
//Path = sysDoc.Path,
|
||||
//FullFilePath = sysDoc.Path
|
||||
};
|
||||
|
||||
var unionQuery = systemDocQuery.IgnoreQueryFilters().Where(t => !(t.IsDeleted == true && t.ConfirmTime == null))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name))
|
||||
.WhereIf(inQuery.FileTypeId != null, t => t.FileTypeId == inQuery.FileTypeId)
|
||||
.WhereIf(inQuery.IsConfirmed == true, t => t.ConfirmTime != null)
|
||||
.WhereIf(inQuery.IsConfirmed == false, t => t.ConfirmTime == null)
|
||||
.WhereIf(inQuery.StartConfirmTime != null, t => t.ConfirmTime >= inQuery.StartConfirmTime.Value)
|
||||
.WhereIf(inQuery.EndConfirmTime != null, t => t.ConfirmTime <= inQuery.EndConfirmTime.Value)
|
||||
.WhereIf(inQuery.BeginCreateTime != null, t => t.CreateTime >= inQuery.BeginCreateTime)
|
||||
.WhereIf(inQuery.EndCreateTime != null, t => t.CreateTime <= inQuery.EndCreateTime)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.UserName), t => t.UserName.Contains(inQuery.UserName))
|
||||
.WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted);
|
||||
|
||||
var list = await unionQuery.SortToListAsync(inQuery);
|
||||
|
||||
#region 处理文档 需要签署的角色类型 和每个人的角色信息
|
||||
|
||||
var trialDocIdList = list.Where(t => t.IsSystemDoc == false).Select(t => t.Id).ToList();
|
||||
|
||||
var sysDocIdList = list.Where(t => t.IsSystemDoc == true).Select(t => t.Id).ToList();
|
||||
|
||||
var identityUserIdList = list.Select(t => t.ConfirmUserId).Distinct().ToList();
|
||||
|
||||
|
||||
var sysDocUserTypeList = _systemDocNeedConfirmedUserTypeRepository.Where(t => sysDocIdList.Contains(t.SystemDocumentId)).Select(t => new { t.SystemDocumentId, t.UserTypeRole.UserTypeShortName }).ToList();
|
||||
|
||||
var identityUserUserTypeList = _identityUserRepository.Where(t => identityUserIdList.Contains(t.Id)).IgnoreQueryFilters().Select(t => new { IdentityUserId = t.Id, UserTypeList = t.UserRoleList.Where(t => t.IsUserRoleDisabled == false).Select(c => c.UserTypeRole.UserTypeShortName).ToList() });
|
||||
|
||||
//Concat 不能用导航属性
|
||||
var sysids = list.Where(t => t.IsSystemDoc == true).Select(t => t.Id).ToList();
|
||||
|
||||
//var sysDataList = await _systemDocumentRepository.Where(x => sysids.Contains(x.Id)).Include(x => x.SystemDocumentAttachmentList).ToListAsync();
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
|
||||
//if (sysDataList.Any(y => y.Id == item.Id))
|
||||
//{
|
||||
// item.AttachmentCount = sysDataList.Where(y => y.Id == item.Id).Select(x => x.SystemDocumentAttachmentList.Where(z => !z.OffLine).Count()).FirstOrDefault();
|
||||
//}
|
||||
|
||||
if (item.IsSystemDoc)
|
||||
{
|
||||
item.DocNeedSignUserTypeList = sysDocUserTypeList.Where(t => t.SystemDocumentId == item.Id).Select(t => t.UserTypeShortName).ToList();
|
||||
}
|
||||
|
||||
|
||||
item.IdentityUserTypeList = identityUserUserTypeList.Where(t => t.IdentityUserId == item.ConfirmUserId).SelectMany(c => c.UserTypeList).ToList();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
var exportInfo = new ExcelExportInfo();
|
||||
|
||||
exportInfo.List = list;
|
||||
exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId);
|
||||
exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId);
|
||||
|
||||
|
||||
|
||||
return await ExcelExportHelper.DataExportAsync(StaticData.Export.CommonTrainingRecordList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(TrainingRecordExportDTO));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// getDocumentConfirmList 培训记录导出--new
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user