添加项目文件。
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||
// 生成时间 2022-01-05 09:17:10
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace IRaCIS.Core.Application.Contracts
|
||||
{
|
||||
/// <summary> SystemDocumentView 列表视图模型 </summary>
|
||||
public class SystemDocumentView : SystemDocumentAddOrEdit
|
||||
{
|
||||
public string FullFilePath { get; set; } = string.Empty;
|
||||
public DateTime CreateTime { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
public List<NeedConfirmedUserTypeView> NeedConfirmedUserTypeList { get; set; }=new List<NeedConfirmedUserTypeView>();
|
||||
}
|
||||
|
||||
public class UnionDocumentView : SystemDocumentAddOrEdit
|
||||
{
|
||||
public string FullFilePath { get; set; } = string.Empty;
|
||||
public DateTime CreateTime { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
public bool IsSystemDoc { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class UnionDocumentWithConfirmInfoView: UnionDocumentView
|
||||
{
|
||||
public DateTime? ConfirmTime { get; set; }
|
||||
|
||||
public Guid? ConfirmUserId { get; set; }
|
||||
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
public string RealName { get; set; } = string.Empty;
|
||||
|
||||
public string UserTypeShortName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
public class TrialUserDto
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
public string RealName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class DocumentUnionWithUserStatView: UnionDocumentView
|
||||
{
|
||||
public int? DocumentUserCount { get; set; }
|
||||
public int? DocumentConfirmedUserCount { get; set; }
|
||||
}
|
||||
|
||||
public class TrialUserUnionDocumentView
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public string UserTypeShortName { get; set; } = string.Empty;
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string RealName { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public int? SystemDocumentCount { get; set; }
|
||||
public int? TrialDocumentCount { get; set; }
|
||||
public int? TrialDocumentConfirmedCount { get; set; }
|
||||
public int? SystemDocumentConfirmedCount { get; set; }
|
||||
|
||||
//public List<UnionDocumentView> DocumentList { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///<summary>SystemDocumentQuery 列表查询参数模型</summary>
|
||||
public class SystemDocumentQuery : PageInput
|
||||
{
|
||||
|
||||
|
||||
public Guid? SystemDocumentId { get; set; }
|
||||
|
||||
public string Type { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class TrialUserDocUnionQuery: PageInput
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public string Type { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
|
||||
public class UserConfirmCommand
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
[NotDefault]
|
||||
public Guid DocumentId { get; set; }
|
||||
|
||||
|
||||
public bool isSystemDoc { get; set; }
|
||||
|
||||
|
||||
public string UserName { get; set; } = String.Empty;
|
||||
|
||||
public string PassWord { get; set; } = String.Empty;
|
||||
|
||||
public string SignText { get; set; } = String.Empty;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class DocumentTrialUnionQuery : TrialUserDocUnionQuery
|
||||
{
|
||||
|
||||
public Guid? UserTypeId { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
}
|
||||
|
||||
///<summary> SystemDocumentAddOrEdit 列表查询参数模型</summary>
|
||||
public class SystemDocumentAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Path { get; set; } = string.Empty;
|
||||
|
||||
public bool IsAbandon { get; set; }
|
||||
|
||||
public int SignViewMinimumMinutes { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class AddOrEditSystemDocument : SystemDocumentAddOrEdit
|
||||
{
|
||||
|
||||
public List<Guid> NeedConfirmedUserTypeIdList { get; set; }=new List<Guid>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||
// 生成时间 2022-01-05 09:17:10
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace IRaCIS.Core.Application.Contracts
|
||||
{
|
||||
/// <summary> TrialDocumentUserConfirmView 列表视图模型 </summary>
|
||||
public class TrialDocumentUserConfirmView
|
||||
{
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public Guid? TrialDocumentId { get; set; }
|
||||
|
||||
public DateTime? ConfirmTime { get; set; }
|
||||
|
||||
public Guid? ConfirmUserId { get; set; }
|
||||
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
public string RealName { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class NeedConfirmedUserTypeView
|
||||
{
|
||||
public Guid NeedConfirmUserTypeId { get; set; }
|
||||
|
||||
public string UserTypeShortName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||
// 生成时间 2022-01-05 09:17:10
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace IRaCIS.Core.Application.Contracts
|
||||
{
|
||||
/// <summary> TrialDocumentView 列表视图模型 </summary>
|
||||
public class TrialDocumentView : TrialDocumentAddOrEdit
|
||||
{
|
||||
public string FullFilePath { get; set; } = String.Empty;
|
||||
|
||||
public bool IsSomeUserSigned{get;set;}
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
public Guid UpdateUserId { get; set; }
|
||||
|
||||
public List<NeedConfirmedUserTypeView> NeedConfirmedUserTypeList { get; set; } = new List<NeedConfirmedUserTypeView>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
///<summary>TrialDocumentQuery 列表查询参数模型</summary>
|
||||
public class TrialDocumentQuery : PageInput
|
||||
{
|
||||
|
||||
public string Type { get; set; } = String.Empty;
|
||||
|
||||
public string Name { get; set; } = String.Empty;
|
||||
|
||||
[NotDefault]
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
///<summary> TrialDocumentAddOrEdit 列表查询参数模型</summary>
|
||||
public class TrialDocumentAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public string Type { get; set; } = String.Empty;
|
||||
public string Name { get; set; } = String.Empty;
|
||||
public string Path { get; set; } = String.Empty;
|
||||
|
||||
public string Description { get; set; } = String.Empty;
|
||||
public bool IsAbandon { get; set; }
|
||||
|
||||
public int SignViewMinimumMinutes { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class AddOrEditTrialDocument: TrialDocumentAddOrEdit
|
||||
{
|
||||
|
||||
public List<Guid> NeedConfirmedUserTypeIdList { get; set; } = new List<Guid>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||
// 生成时间 2022-01-05 09:17:00
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
namespace IRaCIS.Core.Application.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// ISystemDocumentService
|
||||
/// </summary>
|
||||
public interface ISystemDocumentService
|
||||
{
|
||||
|
||||
//PageOutput<SystemDocumentView> GetSystemDocumentList(SystemDocumentQuery querySystemDocument);
|
||||
|
||||
|
||||
//IResponseOutput AddOrUpdateSystemDocument(AddOrEditSystemDocument addOrEditSystemDocument);
|
||||
|
||||
//IResponseOutput DeleteSystemDocument(Guid systemDocumentId);
|
||||
|
||||
Task<PageOutput<SystemDocumentView>> GetSystemDocumentListAsync(SystemDocumentQuery querySystemDocument);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateSystemDocumentAsync(AddOrEditSystemDocument addOrEditSystemDocument);
|
||||
|
||||
Task<IResponseOutput> DeleteSystemDocumentAsync(Guid systemDocumentId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||
// 生成时间 2022-01-05 09:17:03
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace IRaCIS.Core.Application.Contracts
|
||||
{
|
||||
public interface ITrialDocumentService
|
||||
{
|
||||
Task<IResponseOutput> AddOrUpdateTrialDocument(AddOrEditTrialDocument addOrEditTrialDocument);
|
||||
Task<IResponseOutput> DeleteTrialDocument(Guid trialDocumentId, Guid trialId);
|
||||
Task<PageOutput<UnionDocumentWithConfirmInfoView>> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument);
|
||||
Task<PageOutput<TrialDocumentView>> GetTrialDocumentList(TrialDocumentQuery queryTrialDocument);
|
||||
|
||||
Task<PageOutput<UnionDocumentWithConfirmInfoView>> GetUserDocumentList(TrialUserDocUnionQuery querySystemDocument);
|
||||
Task<IResponseOutput> SetFirstViewDocumentTime(Guid documentId, bool isSystemDoc);
|
||||
Task<IResponseOutput> UserConfirm(UserConfirmCommand userConfirmCommand);
|
||||
Task<List<TrialUserDto>> GetTrialUserSelect(Guid trialId);
|
||||
|
||||
|
||||
PageOutput<DocumentUnionWithUserStatView> GetTrialSystemDocumentList(DocumentTrialUnionQuery querySystemDocument);
|
||||
List<TrialUserUnionDocumentView> GetTrialUserDocumentList(Guid trialId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||
// 生成时间 2022-01-05 09:17:03
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
|
||||
namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// SystemDocumentService
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Trial")]
|
||||
public class SystemDocumentService : BaseService, ISystemDocumentService
|
||||
{
|
||||
|
||||
private readonly IWebHostEnvironment _hostEnvironment;
|
||||
private readonly IRepository<SystemDocument> systemDocumentRepository;
|
||||
|
||||
public SystemDocumentService(IWebHostEnvironment hostEnvironment, IRepository<SystemDocument> systemDocumentRepository)
|
||||
{
|
||||
_hostEnvironment = hostEnvironment;
|
||||
this.systemDocumentRepository = systemDocumentRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 管理端列表
|
||||
/// </summary>
|
||||
/// <param name="querySystemDocument"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<SystemDocumentView>> GetSystemDocumentListAsync(SystemDocumentQuery querySystemDocument)
|
||||
{
|
||||
var systemDocumentQueryable = systemDocumentRepository
|
||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type))
|
||||
.ProjectTo<SystemDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, userId = _userInfo.Id });
|
||||
|
||||
return await systemDocumentQueryable.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
||||
}
|
||||
|
||||
public async Task<IResponseOutput> AddOrUpdateSystemDocumentAsync(AddOrEditSystemDocument addOrEditSystemDocument)
|
||||
{
|
||||
if (addOrEditSystemDocument.Id == null)
|
||||
{
|
||||
var entity = _mapper.Map<SystemDocument>(addOrEditSystemDocument);
|
||||
|
||||
|
||||
if (await systemDocumentRepository.AnyAsync(t => t.Type == addOrEditSystemDocument.Type && t.Name == addOrEditSystemDocument.Name))
|
||||
{
|
||||
return ResponseOutput.NotOk("同类型已存在该文件名");
|
||||
}
|
||||
|
||||
await systemDocumentRepository.AddAsync(entity,true);
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var document = await systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync();
|
||||
|
||||
if (document == null) return Null404NotFound(document);
|
||||
|
||||
if (await systemDocumentRepository.AnyAsync(t => t.Type == addOrEditSystemDocument.Type && t.Name == addOrEditSystemDocument.Name && t.Id != addOrEditSystemDocument.Id))
|
||||
{
|
||||
return ResponseOutput.NotOk("同类型已存在该文件名");
|
||||
}
|
||||
var dbDocumentType = document.Type;
|
||||
|
||||
_mapper.Map(addOrEditSystemDocument, document);
|
||||
|
||||
if (dbDocumentType != addOrEditSystemDocument.Type)
|
||||
{
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
|
||||
var beforeFilePath = Path.Combine(rootPath, document.Path);
|
||||
|
||||
document.Path = document.Path.Replace(dbDocumentType, addOrEditSystemDocument.Type);
|
||||
|
||||
var nowPath = Path.Combine(rootPath, document.Path);
|
||||
|
||||
if (File.Exists(beforeFilePath))
|
||||
{
|
||||
File.Move(beforeFilePath, nowPath, true);
|
||||
File.Delete(beforeFilePath);
|
||||
}
|
||||
|
||||
}
|
||||
var success = _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok(document.Id.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpDelete("{systemDocumentId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteSystemDocumentAsync(Guid systemDocumentId)
|
||||
{
|
||||
|
||||
if (await _repository.Where<SystemDocument>(t => t.Id == systemDocumentId).AnyAsync(u => u.SystemDocConfirmedUserList.Any()))
|
||||
{
|
||||
return ResponseOutput.NotOk("该文档下已有签名的用户");
|
||||
}
|
||||
|
||||
var success = await _repository.DeleteFromQueryAsync<SystemDocument>(t => t.Id == systemDocumentId);
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,642 @@
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||
// 生成时间 2022-01-05 09:17:03
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using Panda.DynamicWebApi.Attributes;
|
||||
|
||||
namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// TrialDocumentService
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Trial")]
|
||||
public class TrialDocumentService : BaseService, ITrialDocumentService
|
||||
{
|
||||
|
||||
|
||||
private readonly IWebHostEnvironment _hostEnvironment;
|
||||
private readonly IRepository<TrialDocument> trialDocumentRepository;
|
||||
|
||||
public TrialDocumentService(IWebHostEnvironment hostEnvironment, IRepository<TrialDocument> trialDocumentRepository)
|
||||
{
|
||||
_hostEnvironment = hostEnvironment;
|
||||
this.trialDocumentRepository = trialDocumentRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setting 界面的 项目所有文档列表
|
||||
/// </summary>
|
||||
/// <param name="queryTrialDocument"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<TrialDocumentView>> GetTrialDocumentList(TrialDocumentQuery queryTrialDocument)
|
||||
{
|
||||
|
||||
var trialDocumentQueryable = trialDocumentRepository.Where(t => t.TrialId == queryTrialDocument.TrialId)
|
||||
.WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name))
|
||||
.WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Type), t => t.Type.Contains(queryTrialDocument.Type))
|
||||
.ProjectTo<TrialDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken });
|
||||
|
||||
return await trialDocumentQueryable.ToPagedListAsync(queryTrialDocument.PageIndex, queryTrialDocument.PageSize, queryTrialDocument.SortField, queryTrialDocument.Asc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 具体用户看到的 系统文件列表 + 项目类型文档
|
||||
/// </summary>
|
||||
/// <param name="querySystemDocument"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<UnionDocumentWithConfirmInfoView>> GetUserDocumentList(TrialUserDocUnionQuery querySystemDocument)
|
||||
{
|
||||
#region https://github.com/dotnet/efcore/issues/16243 操作不行
|
||||
////系统文档查询
|
||||
//var systemDocumentQueryable = _systemDocumentRepository
|
||||
// .WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
// .WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
|
||||
//.ProjectTo<UnionDocumentView>(_mapper.ConfigurationProvider, new { userId = _userInfo.Id, token = _userInfo.UserToken });
|
||||
|
||||
////项目文档查询
|
||||
//var trialDocQueryable = _trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId)
|
||||
// .WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
// .WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
|
||||
// .ProjectTo<UnionDocumentView>(_mapper.ConfigurationProvider, new { userId = _userInfo.Id, token = _userInfo.UserToken });
|
||||
|
||||
//var unionQuery = systemDocumentQueryable.Union(trialDocQueryable);
|
||||
// .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
||||
// .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type));
|
||||
#endregion
|
||||
|
||||
#region 仅仅文档信息
|
||||
|
||||
////系统文档查询
|
||||
//var systemDocumentQueryable = _systemDocumentRepository
|
||||
// .WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
// .WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
|
||||
// .Select(t => new UnionDocumentView()
|
||||
// {
|
||||
// Id = t.Id,
|
||||
// IsSystemDoc = true,
|
||||
// CreateTime = t.CreateTime,
|
||||
// FullFilePath = t.Path + "?access_token=" + _userInfo.UserToken,
|
||||
// IsAbandon = t.IsAbandon,
|
||||
// Name = t.Name,
|
||||
// Path = t.Path,
|
||||
// Type = t.Type,
|
||||
// UpdateTime = t.UpdateTime,
|
||||
// SignViewMinimumMinutes = t.SignViewMinimumMinutes,
|
||||
|
||||
// });
|
||||
|
||||
////项目文档查询
|
||||
//var trialDocQueryable = _trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId)
|
||||
// .WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
// .WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
|
||||
// .Select(t => new UnionDocumentView()
|
||||
// {
|
||||
// Id = t.Id,
|
||||
// IsSystemDoc = false,
|
||||
// CreateTime = t.CreateTime,
|
||||
// FullFilePath = t.Path + "?access_token=" + _userInfo.UserToken,
|
||||
// IsAbandon = t.IsAbandon,
|
||||
// Name = t.Name,
|
||||
// Path = t.Path,
|
||||
// Type = t.Type,
|
||||
// UpdateTime = t.UpdateTime,
|
||||
// SignViewMinimumMinutes = t.SignViewMinimumMinutes,
|
||||
|
||||
// });
|
||||
|
||||
#endregion
|
||||
|
||||
var trialFininshedTime = await _repository.Where<Trial>(t => t.Id == querySystemDocument.TrialId).Select(t => t.TrialFinishedTime).FirstOrDefaultAsync();
|
||||
|
||||
//系统文档查询
|
||||
var systemDocumentQueryable = from needConfirmedUserType in _repository.Where<SystemDocNeedConfirmedUserType>(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)
|
||||
//.Where(u => u.UserTypeRole.UserList.SelectMany(cc => cc.UserTrials.Where(t => t.TrialId == querySystemDocument.TrialId)).Any(e => e.Trial.TrialFinishedTime < u.SystemDocument.CreateTime))
|
||||
.WhereIf(trialFininshedTime != null, u => u.SystemDocument.CreateTime < trialFininshedTime)
|
||||
.WhereIf(!_userInfo.IsAdmin, t => t.SystemDocument.IsAbandon == false || (t.SystemDocument.IsAbandon == true && t.SystemDocument.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
|
||||
|
||||
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == querySystemDocument.TrialId && t.UserId == _userInfo.Id)
|
||||
on needConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId
|
||||
join confirm in _repository.GetQueryable<SystemDocConfirmedUser>() on new { ConfirmUserId = trialUser.UserId, SystemDocumentId = needConfirmedUserType.SystemDocumentId } equals new { confirm.ConfirmUserId, confirm.SystemDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new UnionDocumentWithConfirmInfoView()
|
||||
{
|
||||
IsSystemDoc = true,
|
||||
|
||||
Id = needConfirmedUserType.SystemDocument.Id,
|
||||
CreateTime = needConfirmedUserType.SystemDocument.CreateTime,
|
||||
IsAbandon = needConfirmedUserType.SystemDocument.IsAbandon,
|
||||
SignViewMinimumMinutes = needConfirmedUserType.SystemDocument.SignViewMinimumMinutes,
|
||||
Name = needConfirmedUserType.SystemDocument.Name,
|
||||
Path = needConfirmedUserType.SystemDocument.Path,
|
||||
Type = needConfirmedUserType.SystemDocument.Type,
|
||||
UpdateTime = needConfirmedUserType.SystemDocument.UpdateTime,
|
||||
|
||||
FullFilePath = needConfirmedUserType.SystemDocument.Path + "?access_token=" + _userInfo.UserToken,
|
||||
|
||||
ConfirmUserId = confirm.ConfirmUserId,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
RealName = trialUser.User.LastName + " / " + trialUser.User.FirstName,
|
||||
UserName = trialUser.User.UserName,
|
||||
UserTypeShortName = trialUser.User.UserTypeRole.UserTypeShortName
|
||||
};
|
||||
|
||||
//项目文档查询
|
||||
var trialDocQueryable = from trialDoc in trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId)
|
||||
.WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
.WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
|
||||
|
||||
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == querySystemDocument.TrialId && t.UserId == _userInfo.Id) on trialDoc.TrialId equals trialUser.TrialId
|
||||
join confirm in _repository.Where<TrialDocUserTypeConfirmedUser>(t => t.TrialDocument.TrialId == querySystemDocument.TrialId) on
|
||||
new { trialUser.UserId, TrialDocumentId = trialDoc.Id } equals new { UserId = confirm.ConfirmUserId, confirm.TrialDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new UnionDocumentWithConfirmInfoView()
|
||||
{
|
||||
Id = trialDoc.Id,
|
||||
IsSystemDoc = false,
|
||||
CreateTime = trialDoc.CreateTime,
|
||||
FullFilePath = trialDoc.Path + "?access_token=" + _userInfo.UserToken,
|
||||
IsAbandon = trialDoc.IsAbandon,
|
||||
Name = trialDoc.Name,
|
||||
Path = trialDoc.Path,
|
||||
Type = trialDoc.Type,
|
||||
UpdateTime = trialDoc.UpdateTime,
|
||||
SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes,
|
||||
|
||||
ConfirmUserId = confirm.ConfirmUserId,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
RealName = trialUser.User.LastName + " / " + trialUser.User.FirstName,
|
||||
UserName = trialUser.User.UserName,
|
||||
UserTypeShortName = trialUser.User.UserTypeRole.UserTypeShortName
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
var unionQuery = systemDocumentQueryable.Union(trialDocQueryable)
|
||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type));
|
||||
|
||||
return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户是否有文档未签署
|
||||
/// </summary>
|
||||
/// <param name="trialId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{trialId:guid}")]
|
||||
public async Task<bool> GetUserIsHaveDocumentNeedSign(Guid trialId)
|
||||
{
|
||||
var trialFininshedTime = await _repository.Where<Trial>(t => t.Id == trialId).Select(t => t.TrialFinishedTime).FirstOrDefaultAsync();
|
||||
|
||||
//系统文档查询
|
||||
var systemDocumentQueryable = from needConfirmedUserType in _repository.Where<SystemDocNeedConfirmedUserType>(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)
|
||||
//.Where(u => u.UserTypeRole.UserList.SelectMany(cc => cc.UserTrials.Where(t => t.TrialId == querySystemDocument.TrialId)).Any(e => e.Trial.TrialFinishedTime < u.SystemDocument.CreateTime))
|
||||
.WhereIf(trialFininshedTime != null, u => u.SystemDocument.CreateTime < trialFininshedTime)
|
||||
.WhereIf(!_userInfo.IsAdmin, t => t.SystemDocument.IsAbandon == false || (t.SystemDocument.IsAbandon == true && t.SystemDocument.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
|
||||
|
||||
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == trialId && t.UserId == _userInfo.Id)
|
||||
on needConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId
|
||||
join confirm in _repository.GetQueryable<SystemDocConfirmedUser>() on new { ConfirmUserId = trialUser.UserId, SystemDocumentId = needConfirmedUserType.SystemDocumentId } equals new { confirm.ConfirmUserId, confirm.SystemDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
//ConfirmUserId = confirm.ConfirmUserId,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
};
|
||||
|
||||
//项目文档查询
|
||||
var trialDocQueryable = from trialDoc in trialDocumentRepository.Where(t => t.TrialId == trialId)
|
||||
.WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
.WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
|
||||
|
||||
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == trialId && t.UserId == _userInfo.Id) on trialDoc.TrialId equals trialUser.TrialId
|
||||
join confirm in _repository.Where<TrialDocUserTypeConfirmedUser>(t => t.TrialDocument.TrialId == trialId) on
|
||||
new { trialUser.UserId, TrialDocumentId = trialDoc.Id } equals new { UserId = confirm.ConfirmUserId, confirm.TrialDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
//ConfirmUserId = confirm.ConfirmUserId,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
};
|
||||
|
||||
var unionQuery = systemDocumentQueryable.Union(trialDocQueryable);
|
||||
|
||||
return await unionQuery.AnyAsync(t => t.ConfirmTime == null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取确认列表情况 项目文档+系统文档+具体的人
|
||||
/// </summary>
|
||||
/// <param name="querySystemDocument"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<UnionDocumentWithConfirmInfoView>> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument)
|
||||
{
|
||||
|
||||
|
||||
#region linq join 方式
|
||||
//var trialDocQuery = from trialDocumentNeedConfirmedUserType in _trialDocumentNeedConfirmedUserTypeRepository.Where(t => t.TrialDocument.TrialId == querySystemDocument.TrialId)
|
||||
// join trialUser in _trialUserRepository.Where(t => t.TrialId == querySystemDocument.TrialId)
|
||||
// .WhereIf(querySystemDocument.UserId != null, t => t.UserId == querySystemDocument.UserId)
|
||||
// on trialDocumentNeedConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId
|
||||
|
||||
// join confirm in _trialDocuserConfrimedRepository.AsQueryable() on trialUser.UserId equals confirm.ConfirmUserId into cc
|
||||
// from confirm in cc.DefaultIfEmpty()
|
||||
// select new UnionDocumentConfirmListView()
|
||||
// {
|
||||
// Id = trialDocumentNeedConfirmedUserType.TrialDocument.Id,
|
||||
// CreateTime = trialDocumentNeedConfirmedUserType.TrialDocument.CreateTime,
|
||||
// IsAbandon = trialDocumentNeedConfirmedUserType.TrialDocument.IsAbandon,
|
||||
// SignViewMinimumMinutes = trialDocumentNeedConfirmedUserType.TrialDocument.SignViewMinimumMinutes,
|
||||
// Name = trialDocumentNeedConfirmedUserType.TrialDocument.Name,
|
||||
// Path = trialDocumentNeedConfirmedUserType.TrialDocument.Path,
|
||||
// Type = trialDocumentNeedConfirmedUserType.TrialDocument.Type,
|
||||
// UpdateTime = trialDocumentNeedConfirmedUserType.TrialDocument.UpdateTime,
|
||||
|
||||
// UserConfirmInfo = /*confirm == null ? null : */new UnionDocumentUserConfirmView()
|
||||
// {
|
||||
|
||||
// ConfirmUserId = confirm.ConfirmUserId,
|
||||
// ConfirmTime = confirm.ConfirmTime,
|
||||
// RealName = trialUser.User.LastName + " / " + trialUser.User.LastName,
|
||||
// UserName = trialUser.User.UserName,
|
||||
// },
|
||||
|
||||
// FullFilePath = trialDocumentNeedConfirmedUserType.TrialDocument.Path + "?access_token=" + _userInfo.UserToken
|
||||
// };
|
||||
|
||||
#endregion
|
||||
|
||||
var trialFininshedTime = await _repository.Where<Trial>(t => t.Id == querySystemDocument.TrialId).Select(t => t.TrialFinishedTime).FirstOrDefaultAsync();
|
||||
|
||||
var trialDocQuery = from trialDocumentNeedConfirmedUserType in _repository.Where<TrialDocNeedConfirmedUserType>(t => t.TrialDocument.TrialId == querySystemDocument.TrialId)
|
||||
//.Where(t => t.TrialDocument.Trial.TrialUserList.Any(cc => cc.User.UserTypeId == t.NeedConfirmUserTypeId))
|
||||
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == querySystemDocument.TrialId)
|
||||
.WhereIf(querySystemDocument.UserId != null, t => t.UserId == querySystemDocument.UserId)
|
||||
.WhereIf(querySystemDocument.UserTypeId != null, t => t.User.UserTypeId == querySystemDocument.UserTypeId)
|
||||
on trialDocumentNeedConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId
|
||||
|
||||
join confirm in _repository.Where<TrialDocUserTypeConfirmedUser>(t => t.TrialDocument.TrialId == querySystemDocument.TrialId) on
|
||||
new { trialUser.UserId, TrialDocumentId = trialDocumentNeedConfirmedUserType.TrialDocumentId } equals new { UserId = confirm.ConfirmUserId, confirm.TrialDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new UnionDocumentWithConfirmInfoView()
|
||||
{
|
||||
IsSystemDoc = false,
|
||||
|
||||
Id = trialDocumentNeedConfirmedUserType.TrialDocument.Id,
|
||||
CreateTime = trialDocumentNeedConfirmedUserType.TrialDocument.CreateTime,
|
||||
IsAbandon = trialDocumentNeedConfirmedUserType.TrialDocument.IsAbandon,
|
||||
SignViewMinimumMinutes = trialDocumentNeedConfirmedUserType.TrialDocument.SignViewMinimumMinutes,
|
||||
Name = trialDocumentNeedConfirmedUserType.TrialDocument.Name,
|
||||
Path = trialDocumentNeedConfirmedUserType.TrialDocument.Path,
|
||||
Type = trialDocumentNeedConfirmedUserType.TrialDocument.Type,
|
||||
UpdateTime = trialDocumentNeedConfirmedUserType.TrialDocument.UpdateTime,
|
||||
|
||||
|
||||
|
||||
ConfirmUserId = confirm.ConfirmUserId,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
RealName = trialUser.User.LastName + " / " + trialUser.User.FirstName,
|
||||
UserName = trialUser.User.UserName,
|
||||
UserTypeShortName = trialUser.User.UserTypeRole.UserTypeShortName,
|
||||
|
||||
FullFilePath = trialDocumentNeedConfirmedUserType.TrialDocument.Path + "?access_token=" + _userInfo.UserToken
|
||||
};
|
||||
|
||||
|
||||
|
||||
var systemDocQuery = from needConfirmEdUserType in _repository.WhereIf<SystemDocNeedConfirmedUserType>(trialFininshedTime != null, u => u.SystemDocument.CreateTime < trialFininshedTime)
|
||||
|
||||
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == querySystemDocument.TrialId)
|
||||
.WhereIf(querySystemDocument.UserId != null, t => t.UserId == querySystemDocument.UserId)
|
||||
on needConfirmEdUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId
|
||||
join confirm in _repository.GetQueryable<SystemDocConfirmedUser>() on new { ConfirmUserId = trialUser.UserId, SystemDocumentId = needConfirmEdUserType.SystemDocumentId } equals new { confirm.ConfirmUserId, confirm.SystemDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new UnionDocumentWithConfirmInfoView()
|
||||
{
|
||||
IsSystemDoc = true,
|
||||
|
||||
Id = needConfirmEdUserType.SystemDocument.Id,
|
||||
CreateTime = needConfirmEdUserType.SystemDocument.CreateTime,
|
||||
IsAbandon = needConfirmEdUserType.SystemDocument.IsAbandon,
|
||||
SignViewMinimumMinutes = needConfirmEdUserType.SystemDocument.SignViewMinimumMinutes,
|
||||
Name = needConfirmEdUserType.SystemDocument.Name,
|
||||
Path = needConfirmEdUserType.SystemDocument.Path,
|
||||
Type = needConfirmEdUserType.SystemDocument.Type,
|
||||
UpdateTime = needConfirmEdUserType.SystemDocument.UpdateTime,
|
||||
|
||||
|
||||
ConfirmUserId = confirm.ConfirmUserId,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
RealName = trialUser.User.LastName + " / " + trialUser.User.FirstName,
|
||||
UserName = trialUser.User.UserName,
|
||||
UserTypeShortName = trialUser.User.UserTypeRole.UserTypeShortName,
|
||||
|
||||
FullFilePath = needConfirmEdUserType.SystemDocument.Path + "?access_token=" + _userInfo.UserToken
|
||||
};
|
||||
|
||||
var unionQuery = trialDocQuery.Union(systemDocQuery)
|
||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type));
|
||||
|
||||
return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("{trialId:guid}")]
|
||||
public async Task<List<TrialUserDto>> GetTrialUserSelect(Guid trialId)
|
||||
{
|
||||
return await _repository.Where<TrialUser>(t => t.TrialId == trialId)
|
||||
.Select(t => new TrialUserDto() { UserId = t.UserId, RealName = t.User.LastName + " / " + t.User.FirstName, UserName = t.User.UserName })
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("{trialId:guid}")]
|
||||
public async Task<List<string>> GetTrialDocAndSystemDocType(Guid trialId)
|
||||
{
|
||||
return await trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => t.Type).Union(_repository.GetQueryable<SystemDocument>().Select(t => t.Type)).Distinct()
|
||||
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IResponseOutput> AddOrUpdateTrialDocument(AddOrEditTrialDocument addOrEditTrialDocument)
|
||||
{
|
||||
if (addOrEditTrialDocument.Id == null)
|
||||
{
|
||||
var entity = _mapper.Map<TrialDocument>(addOrEditTrialDocument);
|
||||
|
||||
|
||||
if (await trialDocumentRepository.AnyAsync(t => t.Type == addOrEditTrialDocument.Type && t.Name == addOrEditTrialDocument.Name && t.TrialId == addOrEditTrialDocument.TrialId))
|
||||
{
|
||||
return ResponseOutput.NotOk("同类型已存在该文件名");
|
||||
}
|
||||
|
||||
await _repository.AddAsync(entity, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (await trialDocumentRepository.AnyAsync(t => t.Type == addOrEditTrialDocument.Type && t.Name == addOrEditTrialDocument.Name && t.Id != addOrEditTrialDocument.Id && t.TrialId == addOrEditTrialDocument.TrialId))
|
||||
{
|
||||
return ResponseOutput.NotOk("同类型已存在该文件名");
|
||||
}
|
||||
|
||||
var document = trialDocumentRepository.Where(t => t.Id == addOrEditTrialDocument.Id, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefault();
|
||||
|
||||
if (document == null) return Null404NotFound(document);
|
||||
|
||||
var dbDocumentType = document.Type;
|
||||
|
||||
_mapper.Map(addOrEditTrialDocument, document);
|
||||
|
||||
if (dbDocumentType != addOrEditTrialDocument.Type)
|
||||
{
|
||||
|
||||
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
|
||||
var beforeFilePath = Path.Combine(rootPath, document.Path);
|
||||
|
||||
document.Path = document.Path.Replace(dbDocumentType, addOrEditTrialDocument.Type);
|
||||
|
||||
var nowPath = Path.Combine(rootPath, document.Path);
|
||||
|
||||
if (File.Exists(beforeFilePath))
|
||||
{
|
||||
File.Move(beforeFilePath, nowPath, true);
|
||||
File.Delete(beforeFilePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var success = await _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok(document.Id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 已签名的文档 不允许删除
|
||||
/// </summary>
|
||||
/// <param name="trialDocumentId"></param>
|
||||
/// <param name="trialId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{trialId:guid}/{trialDocumentId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteTrialDocument(Guid trialDocumentId, Guid trialId)
|
||||
{
|
||||
if (await trialDocumentRepository.Where(t => t.Id == trialDocumentId).AnyAsync(t => t.TrialDocConfirmedUserList.Any()))
|
||||
{
|
||||
return ResponseOutput.NotOk("该文档,已有用户签名 不允许删除");
|
||||
}
|
||||
|
||||
var success = await trialDocumentRepository.DeleteFromQueryAsync(t => t.Id == trialDocumentId);
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 浏览文档说明时调用,记录第一次看的时间
|
||||
/// </summary>
|
||||
/// <param name="documentId"></param>
|
||||
/// <param name="isSystemDoc"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{trialId:guid}/{documentId:guid}/{isSystemDoc:bool}")]
|
||||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> SetFirstViewDocumentTime(Guid documentId, bool isSystemDoc)
|
||||
{
|
||||
|
||||
var success = false;
|
||||
if (isSystemDoc)
|
||||
{
|
||||
await _repository.AddAsync(new SystemDocConfirmedUser() { SystemDocumentId = documentId, SignFirstViewTime = DateTime.Now });
|
||||
//success = await _repository.UpdateFromQueryAsync<SystemDocConfirmedUser>(t => t.Id == documentId, d => new SystemDocConfirmedUser() { SignFirstViewTime = DateTime.Now });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
await _repository.AddAsync(new TrialDocUserTypeConfirmedUser() { TrialDocumentId = documentId, SignFirstViewTime = DateTime.Now });
|
||||
|
||||
//success = await _repository.UpdateFromQueryAsync<TrialDocUserTypeConfirmedUser>(t => t.Id == documentId , d => new TrialDocUserTypeConfirmedUser() { SignFirstViewTime = DateTime.Now });
|
||||
}
|
||||
|
||||
success= await _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户 签名某个文档
|
||||
/// </summary>
|
||||
|
||||
/// <returns></returns>
|
||||
[NonDynamicMethod]
|
||||
public async Task<IResponseOutput> UserConfirm(UserConfirmCommand userConfirmCommand)
|
||||
{
|
||||
|
||||
var user = await _repository.FirstOrDefaultAsync<User>(u => u.UserName == userConfirmCommand.UserName && u.Password == userConfirmCommand.PassWord);
|
||||
if (user == null)
|
||||
{
|
||||
return ResponseOutput.NotOk("password error");
|
||||
}
|
||||
else if (user.Status == UserStateEnum.Disable)
|
||||
{
|
||||
return ResponseOutput.NotOk("The user has been disabled!");
|
||||
}
|
||||
|
||||
|
||||
if (userConfirmCommand.isSystemDoc)
|
||||
{
|
||||
if (await _repository.AnyAsync<SystemDocConfirmedUser>(t => t.SystemDocumentId == userConfirmCommand.DocumentId && t.ConfirmUserId == _userInfo.Id))
|
||||
{
|
||||
return ResponseOutput.NotOk("该文档已经签名");
|
||||
}
|
||||
if (!await _repository.AnyAsync<SystemDocument>(t => t.Id == userConfirmCommand.DocumentId) || await trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsAbandon))
|
||||
{
|
||||
return ResponseOutput.NotOk("文件已删除或者废除,签署失败!");
|
||||
}
|
||||
|
||||
await _repository.AddAsync(new SystemDocConfirmedUser() { ConfirmTime = DateTime.Now, ConfirmUserId = _userInfo.Id, SystemDocumentId = userConfirmCommand.DocumentId });
|
||||
}
|
||||
else
|
||||
{
|
||||
if (await _repository.AnyAsync<TrialDocUserTypeConfirmedUser>(t => t.TrialDocumentId == userConfirmCommand.DocumentId && t.ConfirmUserId == _userInfo.Id))
|
||||
{
|
||||
return ResponseOutput.NotOk("该文档已经签名");
|
||||
}
|
||||
|
||||
if (!await trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _repository.AnyAsync<TrialDocument>(t => t.Id == userConfirmCommand.DocumentId && t.IsAbandon))
|
||||
{
|
||||
return ResponseOutput.NotOk("文件已删除或者废除,签署失败!");
|
||||
}
|
||||
|
||||
await _repository.AddAsync(new TrialDocUserTypeConfirmedUser() { ConfirmTime = DateTime.Now, ConfirmUserId = _userInfo.Id, TrialDocumentId = userConfirmCommand.DocumentId });
|
||||
}
|
||||
|
||||
await _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户 废除某个文档
|
||||
/// </summary>
|
||||
/// <param name="documentId"></param>
|
||||
/// <param name="isSystemDoc"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{documentId:guid}/{isSystemDoc:bool}")]
|
||||
public async Task<IResponseOutput> UserAbandonDoc(Guid documentId, bool isSystemDoc)
|
||||
{
|
||||
if (isSystemDoc)
|
||||
{
|
||||
await _repository.UpdateFromQueryAsync<SystemDocument>(t => t.Id == documentId, u => new SystemDocument() { IsAbandon = true });
|
||||
}
|
||||
else
|
||||
{
|
||||
await trialDocumentRepository.UpdateFromQueryAsync(t => t.Id == documentId, u => new TrialDocument() { IsAbandon = true });
|
||||
}
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从项目下参与者的维度 先看人员列表(展示统计数字) 点击数字 再看人员具体签署的 系统文档+项目文档(共用上面与人相关的具体文档列表)
|
||||
/// </summary>
|
||||
/// <param name="trialId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{trialId:guid}")]
|
||||
public List<TrialUserUnionDocumentView> GetTrialUserDocumentList(Guid trialId)
|
||||
{
|
||||
var query = _repository.Where<TrialUser>(t => t.TrialId == trialId)
|
||||
.Select(t => new TrialUserUnionDocumentView()
|
||||
{
|
||||
UserId = t.UserId,
|
||||
UserName = t.User.UserName,
|
||||
RealName = t.User.LastName + " / " + t.User.FirstName,
|
||||
UserTypeShortName = t.User.UserTypeRole.UserTypeShortName,
|
||||
TrialDocumentCount = t.Trial.TrialDocumentList.Count(u => u.NeedConfirmedUserTypeList.Any(k => k.NeedConfirmUserTypeId == t.User.UserTypeId)),
|
||||
TrialDocumentConfirmedCount = t.Trial.TrialDocumentList.SelectMany(u => u.TrialDocConfirmedUserList).Count(k => k.ConfirmUserId == t.UserId),
|
||||
SystemDocumentConfirmedCount = t.User.SystemDocConfirmedList.Count(),
|
||||
//这样写不行
|
||||
//SystemDocumentCount = _systemDocumentRepository.Where(s => s.NeedConfirmedUserTypeList.Any(kk => kk.NeedConfirmUserTypeId == t.User.UserTypeId))
|
||||
// .WhereIf(!_userInfo.IsAdmin, s => s.IsAbandon == false || (s.IsAbandon == true && s.SystemDocConfirmedUserList.Any(uu => uu.ConfirmUserId == t.UserId))).Count()
|
||||
SystemDocumentCount = t.User.UserTypeRole.SystemDocNeedConfirmedUserTypeList.Where(cc => cc.NeedConfirmUserTypeId == t.User.UserTypeId).Select(y => y.SystemDocument).Count()
|
||||
});
|
||||
|
||||
return query.ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 从 文档的维度 先看到文档列表(系统文档+项目文档 以及需要确认的人数 和已经确认人数) 点击数字查看某文档下面人确认情况
|
||||
/// </summary>
|
||||
/// <param name="querySystemDocument"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public PageOutput<DocumentUnionWithUserStatView> GetTrialSystemDocumentList(DocumentTrialUnionQuery querySystemDocument)
|
||||
{
|
||||
var systemDocumentQueryable = _repository
|
||||
.WhereIf<SystemDocument>(!_userInfo.IsAdmin, t => t.IsAbandon == false)
|
||||
.Select(t => new DocumentUnionWithUserStatView()
|
||||
{
|
||||
Id = t.Id,
|
||||
IsSystemDoc = true,
|
||||
CreateTime = t.CreateTime,
|
||||
FullFilePath = t.Path + "?access_token=" + _userInfo.UserToken,
|
||||
IsAbandon = t.IsAbandon,
|
||||
Name = t.Name,
|
||||
Path = t.Path,
|
||||
Type = t.Type,
|
||||
UpdateTime = t.UpdateTime,
|
||||
SignViewMinimumMinutes = t.SignViewMinimumMinutes,
|
||||
DocumentConfirmedUserCount = t.SystemDocConfirmedUserList.Count(),
|
||||
|
||||
//DocumentUserCount= _trialUserRepository.Where(tu=>tu.TrialId== querySystemDocument.TrialId).Count(u=>t.NeedConfirmedUserTypeList.Any(cc=>cc.NeedConfirmUserTypeId== u.User.UserTypeId ))
|
||||
DocumentUserCount = t.NeedConfirmedUserTypeList.SelectMany(u => u.UserTypeRole.UserList.SelectMany(b => b.UserTrials.Where(r => r.TrialId == querySystemDocument.TrialId))).Count()
|
||||
});
|
||||
|
||||
var trialDocQueryable = trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId).Select(t => new DocumentUnionWithUserStatView()
|
||||
{
|
||||
Id = t.Id,
|
||||
IsSystemDoc = false,
|
||||
CreateTime = t.CreateTime,
|
||||
FullFilePath = t.Path + "?access_token=" + _userInfo.UserToken,
|
||||
IsAbandon = t.IsAbandon,
|
||||
Name = t.Name,
|
||||
Path = t.Path,
|
||||
Type = t.Type,
|
||||
UpdateTime = t.UpdateTime,
|
||||
SignViewMinimumMinutes = t.SignViewMinimumMinutes,
|
||||
|
||||
DocumentConfirmedUserCount = t.TrialDocConfirmedUserList.Count(),
|
||||
DocumentUserCount = t.Trial.TrialUserList.Count(cc => t.NeedConfirmedUserTypeList.Any(k => k.NeedConfirmUserTypeId == cc.User.UserTypeId))
|
||||
|
||||
});
|
||||
|
||||
var unionQuery = systemDocumentQueryable.Union(trialDocQueryable)
|
||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type));
|
||||
|
||||
return unionQuery.ToPagedList(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using AutoMapper;
|
||||
using AutoMapper.EquivalencyExpression;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
public class DocumentConfig : Profile
|
||||
{
|
||||
public DocumentConfig()
|
||||
{
|
||||
|
||||
var userId = Guid.Empty;
|
||||
var token = string.Empty;
|
||||
CreateMap<SystemDocument, SystemDocumentView>()
|
||||
//.ForMember(d => d.UserConfirmInfo, u => u.MapFrom(s => s.SystemDocConfirmedUserList.FirstOrDefault(t=>t.ConfirmUserId==userId)))
|
||||
.ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token));
|
||||
|
||||
CreateMap<TrialDocument, TrialDocumentView>()
|
||||
.ForMember(d => d.IsSomeUserSigned, u => u.MapFrom(s => s.TrialDocConfirmedUserList.Any()))
|
||||
.ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token));
|
||||
|
||||
|
||||
CreateMap<SystemDocument, UnionDocumentView>()
|
||||
.ForMember(d => d.IsSystemDoc, u => u.MapFrom(s => true))
|
||||
.ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token));
|
||||
|
||||
CreateMap<TrialDocument, UnionDocumentView>()
|
||||
.ForMember(d => d.IsSystemDoc, u => u.MapFrom(s => false))
|
||||
.ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token));
|
||||
|
||||
CreateMap<TrialDocNeedConfirmedUserType, NeedConfirmedUserTypeView>().ForMember(d => d.UserTypeShortName, t => t.MapFrom(c => c.UserTypeRole.UserTypeShortName));
|
||||
CreateMap<SystemDocNeedConfirmedUserType, NeedConfirmedUserTypeView>().ForMember(d => d.UserTypeShortName, t => t.MapFrom(c => c.UserTypeRole.UserTypeShortName));
|
||||
|
||||
|
||||
//CreateMap<TrialDocument, TrialDocumentUserView>()
|
||||
// .ForMember(t => t.UserConfirmInfo, c => c.MapFrom(t => t.TrialDocConfirmedUserList.Where(u => u.ConfirmUserId == userId).FirstOrDefault()))
|
||||
// .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path + "?access_token=" + token)); ;
|
||||
|
||||
CreateMap<TrialDocUserTypeConfirmedUser, TrialDocumentUserConfirmView>()
|
||||
.ForMember(d => d.UserName, c => c.MapFrom(t => t.User.UserName))
|
||||
.ForMember(d => d.RealName, c => c.MapFrom(t => t.User.LastName + " / " + t.User.FirstName));
|
||||
|
||||
//CreateMap<SystemDocConfirmedUser, SystemDocumentUserConfirmView>()
|
||||
// .ForMember(d => d.UserName, c => c.MapFrom(t => t.User.UserName))
|
||||
// .ForMember(d => d.RealName, c => c.MapFrom(t => t.User.LastName + " / " + t.User.FirstName));
|
||||
|
||||
|
||||
CreateMap<TrialUser, TrialDocumentUserConfirmView>();
|
||||
|
||||
|
||||
|
||||
|
||||
CreateMap<AddOrEditTrialDocument, TrialDocument>()
|
||||
.ForMember(d => d.NeedConfirmedUserTypeList, c => c.MapFrom(t => t.NeedConfirmedUserTypeIdList));
|
||||
|
||||
CreateMap<Guid, TrialDocNeedConfirmedUserType>().EqualityComparison((odto, o) => odto == o.NeedConfirmUserTypeId)
|
||||
.ForMember(d => d.NeedConfirmUserTypeId, c => c.MapFrom(t => t))
|
||||
.ForMember(d => d.TrialDocumentId, c => c.Ignore());
|
||||
|
||||
|
||||
|
||||
CreateMap<AddOrEditSystemDocument, SystemDocument>().ForMember(d => d.NeedConfirmedUserTypeList, c => c.MapFrom(t => t.NeedConfirmedUserTypeIdList));
|
||||
CreateMap<Guid, SystemDocNeedConfirmedUserType>().EqualityComparison((odto, o) => odto == o.NeedConfirmUserTypeId)
|
||||
.ForMember(d => d.NeedConfirmUserTypeId, c => c.MapFrom(t => t))
|
||||
.ForMember(d => d.SystemDocumentId, c => c.Ignore());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user