修改标识

This commit is contained in:
2022-08-25 10:38:01 +08:00
parent 15dda3678b
commit 5a7ad0a4b4
7 changed files with 495 additions and 345 deletions
@@ -195,7 +195,7 @@ namespace IRaCIS.Core.Application.Service
var currentInspection = await _dataInspectionRepository.Where(t => t.Id == id).Select(t => new { t.GeneralId, t.ObjectRelationParentId, t.CreateTime }).FirstOrDefaultAsync();
var beforeId = await _dataInspectionRepository.Where(x => x.GeneralId == currentInspection.GeneralId && x.ObjectRelationParentId == currentInspection.ObjectRelationParentId && x.CreateTime <= currentInspection.CreateTime && x.Id!=id).OrderByDescending(x => x.CreateTime).Select(t => t.Id)
var beforeId = await _dataInspectionRepository.Where(x => x.GeneralId == currentInspection.GeneralId && x.ObjectRelationParentId == currentInspection.ObjectRelationParentId && x.CreateTime <= currentInspection.CreateTime && x.Id != id).OrderByDescending(x => x.CreateTime).Select(t => t.Id)
.FirstOrDefaultAsync();
List<Guid> searchGuidList = new List<Guid>() { id };
@@ -243,7 +243,9 @@ namespace IRaCIS.Core.Application.Service
{
//把父层级的数据的 CommonData 数据合并(每一个层级把下面层级需要的数据放在CommonData 里面) 麻烦点是每个层级都需要记录一些信息,而且名称不能重复
var commonDataObjList = await GetRelationParentData(item.ObjectRelationParentId, item.ObjectRelationParentId2, item.CreateTime, item.BatchId);
var objectLsit = new List<object>();
var commonDataObjList = await GetRelationParentData(item.ObjectRelationParentId, item.ObjectRelationParentId2, item.CreateTime, item.BatchId, objectLsit);
var currentDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(jsonDict[nameof(InspectionJsonDetail.CommonData)].ToJsonStr());
@@ -276,7 +278,7 @@ namespace IRaCIS.Core.Application.Service
if (!currentDic.ContainsKey(valuePair.Key))
{
currentDic.Add(valuePair.Key, valuePair.Value);
}
}
}
}
}
@@ -345,12 +347,8 @@ namespace IRaCIS.Core.Application.Service
private async Task<List<object>> GetRelationParentData(Guid? objectRelationParentId, Guid? objectRelationParentId2, DateTime createTime, Guid batchId)
private async Task AddJsonObjectToDic(Guid? objectRelationParentId, DateTime createTime, Guid batchId, List<object> objectLsit)
{
var objectLsit = new List<object>();
if (objectRelationParentId != null)
{
//父子层级的数据可能在同一个批次 进行更新 但是后插入的是父层级的数据 找父层级的稽查应该优先同一批次的
@@ -388,65 +386,133 @@ namespace IRaCIS.Core.Application.Service
await GetRelationParentData(relationParentInspection.ObjectRelationParentId, relationParentInspection.ObjectRelationParentId2, relationParentInspection.CreateTime, relationParentInspection.BatchId);
await AddJsonObjectToDic(relationParentInspection.ObjectRelationParentId, relationParentInspection.CreateTime, relationParentInspection.BatchId, objectLsit);
await AddJsonObjectToDic( relationParentInspection.ObjectRelationParentId2, relationParentInspection.CreateTime, relationParentInspection.BatchId, objectLsit);
}
}
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)
{
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);
}
else
{
//用户的数据稽查没有 临时处理
var userObj = await _repository.Where<User>(t => t.Id == objectRelationParentId2).Select(t => new { UserFullName = t.FullName, t.UserName }).FirstOrDefaultAsync();
var userObj = await _repository.Where<User>(t => t.Id == objectRelationParentId).Select(t => new { UserRealName = t.FullName, t.Phone, t.UserName, UserType = t.UserTypeRole.UserTypeShortName, t.EMail, t.OrganizationName }).FirstOrDefaultAsync();
objectLsit.Add(userObj);
}
}
}
private async Task<List<object>> GetRelationParentData(Guid? objectRelationParentId, Guid? objectRelationParentId2, DateTime createTime, Guid batchId, List<object> objectLsit)
{
await AddJsonObjectToDic(objectRelationParentId, createTime, batchId, objectLsit);
await AddJsonObjectToDic(objectRelationParentId2, createTime, batchId, objectLsit);
#region
//if (objectRelationParentId != null)
//{
// //父子层级的数据可能在同一个批次 进行更新 但是后插入的是父层级的数据 找父层级的稽查应该优先同一批次的
// 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, objectLsit);
// }
//}
//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)
// {
// 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, objectLsit);
// }
// else
// {
// //用户的数据稽查没有 临时处理
// var userObj = await _repository.Where<User>(t => t.Id == objectRelationParentId2).Select(t => new { UserRealName = t.FullName, t.Phone, t.UserName, UserType = t.UserTypeRole.UserTypeShortName, t.EMail, t.OrganizationName }).FirstOrDefaultAsync();
// objectLsit.Add(userObj);
// }
//}
#endregion
return objectLsit;
}
@@ -455,6 +521,7 @@ namespace IRaCIS.Core.Application.Service
/// <summary>
/// 格式化日期和时间
/// </summary>