稽查优化修改

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
@@ -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);
}
}