forked from ddrilling/AsbCloudServer
Fix drillingProgram fileMarks DateTime
This commit is contained in:
parent
6a0289f216
commit
557d7af25a
@ -110,10 +110,10 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
.ToListAsync(token);
|
||||
|
||||
var parts = new List<DrillingProgramPartDto>(partEntities.Count);
|
||||
|
||||
var timezoneOffset = wellService.GetTimezone(idWell)?.Hours ?? 5;
|
||||
foreach (var partEntity in partEntities)
|
||||
{
|
||||
var part = ConvertPart(idUser, fileCategories, files, partEntity);
|
||||
var part = ConvertPart(idUser, fileCategories, files, partEntity, timezoneOffset);
|
||||
parts.Add(part);
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
return result;
|
||||
}
|
||||
|
||||
private static DrillingProgramPartDto ConvertPart(int idUser, List<FileCategory> fileCategories, List<AsbCloudDb.Model.FileInfo> files, DrillingProgramPart partEntity)
|
||||
private DrillingProgramPartDto ConvertPart(int idUser, List<FileCategory> fileCategories, List<AsbCloudDb.Model.FileInfo> files, DrillingProgramPart partEntity, double timezoneOffset)
|
||||
{
|
||||
var part = new DrillingProgramPartDto
|
||||
{
|
||||
@ -341,18 +341,35 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
|
||||
|
||||
if (fileEntity is not null)
|
||||
{
|
||||
part.File = fileEntity.Adapt<FileInfoDto>();
|
||||
if (part.File.FileMarks is not null)
|
||||
part.File.FileMarks = part.File.FileMarks.Where(m => !m.IsDeleted);
|
||||
|
||||
part.IdState = idPartStateApproving;
|
||||
var marks = fileEntity.FileMarks.Where(m => !m.IsDeleted);
|
||||
var hasReject = marks.Any(m => m.IdMarkType == idMarkTypeReject);
|
||||
if (!hasReject)
|
||||
part.File = new FileInfoDto
|
||||
{
|
||||
var allAproved = part.Approvers.All(a => marks.Any(m => m.IdUser == a.Id && m.IdMarkType == idMarkTypeApprove));
|
||||
if (allAproved)
|
||||
part.IdState = idPartStateApproved;
|
||||
Id = fileEntity.Id,
|
||||
Author = fileEntity.Author.Adapt<UserDto>(),
|
||||
IdAuthor = fileEntity.Author.Id,
|
||||
IdCategory = fileEntity.IdCategory,
|
||||
IdWell = fileEntity.IdWell,
|
||||
Name = fileEntity.Name,
|
||||
PublishInfo = fileEntity.PublishInfo.Adapt<FilePublishInfoDto>(),
|
||||
Size = fileEntity.Size,
|
||||
UploadDate = fileEntity.UploadDate.ToRemoteDateTime(timezoneOffset),
|
||||
};
|
||||
|
||||
var marks = fileEntity.FileMarks?.Where(m => !m.IsDeleted);
|
||||
if (marks?.Any() == true)
|
||||
{
|
||||
part.File.FileMarks = marks.Select(m => {
|
||||
var mark = m.Adapt<FileMarkDto>();
|
||||
mark.DateCreated = m.DateCreated.ToRemoteDateTime(timezoneOffset);
|
||||
return mark;
|
||||
});
|
||||
var hasReject = marks.Any(m => m.IdMarkType == idMarkTypeReject);
|
||||
if (!hasReject)
|
||||
{
|
||||
var allAproved = part.Approvers.All(a => marks.Any(m => m.IdUser == a.Id && m.IdMarkType == idMarkTypeApprove));
|
||||
if (allAproved)
|
||||
part.IdState = idPartStateApproved;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user