稽查优化修改

This commit is contained in:
2022-08-24 09:09:19 +08:00
parent 071ad5acd5
commit c00f7a6163
12 changed files with 459 additions and 79 deletions
@@ -52,7 +52,7 @@ namespace IRaCIS.Core.Application.Service
{
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => taskIdList.Contains(t.Id), u => new VisitTask() { TaskState = TaskState.NotEffect });
await _visitTaskRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.Id), u => new VisitTask() { TaskState = TaskState.NotEffect },true);
await _visitTaskRepository.SaveChangesAsync();
@@ -163,7 +163,7 @@ namespace IRaCIS.Core.Application.Service
return ResponseOutput.NotOk("已签名的不允许设置为失效");
}
await _taskMedicalReviewRepository.BatchUpdateNoTrackingAsync(t => command.MedicalReviewIdList.Contains(t.Id), c => new TaskMedicalReview() { IsInvalid = true });
await _taskMedicalReviewRepository.UpdatePartialFromQueryAsync(t => command.MedicalReviewIdList.Contains(t.Id), c => new TaskMedicalReview() { IsInvalid = true },true);
return ResponseOutput.Ok();
@@ -114,7 +114,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
await _visitTaskRepository
.BatchUpdateNoTrackingAsync(updateWhere,
.UpdatePartialFromQueryAsync(updateWhere,
u => new VisitTask()
{
AllocateTime = DateTime.Now,
@@ -189,7 +189,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
await _subjectUserRepository.DeleteFromQueryAsync(t => t.Id == command.Id);
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState == ReadingTaskState.WaitReading && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false, u => new VisitTask()
await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState == ReadingTaskState.WaitReading && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false, u => new VisitTask()
{
AllocateTime = null,
DoctorUserId = null,
@@ -2309,7 +2309,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
//回退后,回退状态恢复
sv.RequestBackState = RequestBackStateEnum.NotRequest;
sv.IsCheckBack = true;
sv.IsCheckBack = false;
sv.CheckState = CheckStateEnum.None;
sv.CheckChallengeState = CheckChanllengeTypeEnum.None;
@@ -224,7 +224,10 @@ namespace IRaCIS.Core.Application.Service
JsonStr = x.JsonDetail,
Identification = x.Identification,
ObjectRelationParentId = x.ObjectRelationParentId,
CreateTime=x.CreateTime
ObjectRelationParentId2 = x.ObjectRelationParentId2,
CreateTime = x.CreateTime,
BatchId = x.BatchId,
}).ToListAsync();
@@ -238,9 +241,9 @@ namespace IRaCIS.Core.Application.Service
//查询关联父层级数据
if (item.Id == currentInspectionId)
{
//把父层级的数据的 CommonData 数据合并
//把父层级的数据的 CommonData 数据合并(每一个层级把下面层级需要的数据放在CommonData 里面) 麻烦点是每个层级都需要记录一些信息,而且名称不能重复
var commonDataObjList = await GetRelationParentData(item.ObjectRelationParentId, item.CreateTime);
var commonDataObjList = await GetRelationParentData(item.ObjectRelationParentId, item.ObjectRelationParentId2, item.CreateTime, item.BatchId);
var currentDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(jsonDict[nameof(InspectionJsonDetail.CommonData)].ToJsonStr());
@@ -250,15 +253,31 @@ namespace IRaCIS.Core.Application.Service
foreach (var valuePair in otherDic)
{
if (currentDic.ContainsKey(valuePair.Key))
//关联层级的数据
if (valuePair.Key.Contains("_"))
{
currentDic[valuePair.Key] = valuePair.Value;
var entityProperName = valuePair.Key.Split("_").ToList().Last();
if (!currentDic.ContainsKey(entityProperName))
{
currentDic.Add(entityProperName, valuePair.Value);
}
else
{
if (!currentDic.ContainsKey(valuePair.Key))
{
currentDic.Add(valuePair.Key, valuePair.Value);
}
}
}
else
{
currentDic.Add(valuePair.Key, valuePair.Value);
if (!currentDic.ContainsKey(valuePair.Key))
{
currentDic.Add(valuePair.Key, valuePair.Value);
}
}
}
}
@@ -301,7 +320,7 @@ namespace IRaCIS.Core.Application.Service
private async Task<List<object>> GetRelationParentData(Guid? objectRelationParentId, DateTime createTime)
private async Task<List<object>> GetRelationParentData(Guid? objectRelationParentId, Guid? objectRelationParentId2, DateTime createTime, Guid batchId)
{
var objectLsit = new List<object>();
@@ -309,7 +328,50 @@ namespace IRaCIS.Core.Application.Service
if (objectRelationParentId != null)
{
var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId && t.CreateTime <= createTime).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail }).FirstOrDefaultAsync();
//父子层级的数据可能在同一个批次 进行更新 但是后插入的是父层级的数据 找父层级的稽查应该优先同一批次的
var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId && (t.CreateTime <= createTime || t.BatchId == batchId)).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail, t.BatchId, t.ObjectRelationParentId2, t.EntityName }).FirstOrDefaultAsync();
if (relationParentInspection != null)
{
Dictionary<string, object> jsonDic = JsonConvert.DeserializeObject<Dictionary<string, object>>(relationParentInspection.JsonDetail);
var commonDataDicObj = jsonDic[nameof(InspectionJsonDetail.CommonData)];
objectLsit.Add(commonDataDicObj);
//避免对象信息记录 把 Data里面的信息也取过去 但是加上稽查对象的前缀
var dataDicObj = jsonDic[nameof(InspectionJsonDetail.Data)];
if (dataDicObj != null)
{
var entityName = relationParentInspection.EntityName;
IDictionary<string, object> newNamepDic = new Dictionary<string, object>();
var tempDic = JsonConvert.DeserializeObject<Dictionary<string, object>>(dataDicObj.ToJsonStr());
foreach (var valuePair in tempDic)
{
newNamepDic.Add(entityName + "_" + valuePair.Key, valuePair.Value);
}
objectLsit.Add(newNamepDic);
}
await GetRelationParentData(relationParentInspection.ObjectRelationParentId, relationParentInspection.ObjectRelationParentId2, relationParentInspection.CreateTime, relationParentInspection.BatchId);
}
}
if (objectRelationParentId2 != null)
{
//父子层级的数据可能在同一个批次 进行更新 但是后插入的是父层级的数据 找父层级的稽查应该优先同一批次的
var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId2 && (t.CreateTime <= createTime || t.BatchId == batchId)).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail, t.BatchId, t.ObjectRelationParentId2, t.EntityName }).FirstOrDefaultAsync();
if (relationParentInspection != null)
@@ -322,8 +384,42 @@ namespace IRaCIS.Core.Application.Service
objectLsit.Add(commonDataDicObj);
await GetRelationParentData(relationParentInspection.ObjectRelationParentId, relationParentInspection.CreateTime);
//避免对象信息记录 把 Data里面的信息也取过去 但是加上稽查对象的前缀
var dataDicObj = jsonDic[nameof(InspectionJsonDetail.Data)];
if (dataDicObj != null)
{
var entityName = relationParentInspection.EntityName;
IDictionary<string, object> newNamepDic = new Dictionary<string, object>();
var tempDic = JsonConvert.DeserializeObject<Dictionary<string, object>>(dataDicObj.ToJsonStr());
foreach (var valuePair in tempDic)
{
newNamepDic.Add(entityName + "_" + valuePair.Key, valuePair.Value);
}
objectLsit.Add(newNamepDic);
}
await GetRelationParentData(relationParentInspection.ObjectRelationParentId, relationParentInspection.ObjectRelationParentId2, relationParentInspection.CreateTime, relationParentInspection.BatchId);
}
else
{
//用户的数据稽查没有 临时处理
var userObj = await _repository.Where<User>(t => t.Id == objectRelationParentId2).Select(t => new { UserFullName = t.FullName, t.UserName }).FirstOrDefaultAsync();
objectLsit.Add(userObj);
}
}
@@ -98,6 +98,8 @@ namespace IRaCIS.Application.Services
}).ToList();
entity.ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded;
entity.IsBlind = null;
entity.IsComplete = null;
await _readingClinicalDataRepository.AddAsync(entity, true);
var success = await _readingClinicalDataRepository.SaveChangesAsync();
return ResponseOutput.Ok(entity.Id);
@@ -307,7 +307,7 @@ namespace IRaCIS.Core.Application.Services
var isSuccess = await _trialSiteUserRepository.UpdatePartialFromQueryAsync(id, u => new TrialSiteUser()
{ IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null },true);
{ IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null },true,true);
return ResponseOutput.Ok(isSuccess);
}