修改稽查

Uat_Study
hang 2022-08-17 10:07:26 +08:00
parent 01d86b9c2b
commit 245dd584c4
2 changed files with 25 additions and 15 deletions

View File

@ -16,6 +16,13 @@ using System.Threading.Tasks;
namespace IRaCIS.Core.Infra.EFCore.Common namespace IRaCIS.Core.Infra.EFCore.Common
{ {
public static class AuditOpt
{
public static readonly string Add = "Add";
public static readonly string Update = "Update";
public static readonly string Deleted = "Deleted";
}
/// <summary> /// <summary>
/// 添加稽查稽查数据 /// 添加稽查稽查数据
/// </summary> /// </summary>
@ -52,16 +59,16 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// 修改 // 修改
await InsertAddEntitys( await InsertAddEntitys(
entitys.Where(x => x.State == EntityState.Modified && entitys.Where(x => x.State == EntityState.Modified &&
(!typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) || !(bool)x.Entity.GetType().GetProperty("IsDeleted").GetValue(x.Entity) || NodeleteTableTypes.Contains(x.Entity.GetType())) (!typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) || !(bool)x.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(x.Entity) || NodeleteTableTypes.Contains(x.Entity.GetType()))
).ToList(), "Update"); ).ToList(), AuditOpt.Update);
// 新增 // 新增
await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Added).ToList(), "Add"); await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Added).ToList(), AuditOpt.Add);
// 删除 // 删除
await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Deleted await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Deleted
|| (typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) && (bool)x.Entity.GetType().GetProperty("IsDeleted").GetValue(x.Entity) && x.State == EntityState.Modified && !NodeleteTableTypes.Contains(x.Entity.GetType())) || (typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) && (bool)x.Entity.GetType().GetProperty(nameof(ISoftDelete.IsDeleted)).GetValue(x.Entity) && x.State == EntityState.Modified && !NodeleteTableTypes.Contains(x.Entity.GetType()))
).ToList(), "Deleted"); ).ToList(), AuditOpt.Deleted);
} }
@ -906,16 +913,19 @@ namespace IRaCIS.Core.Infra.EFCore.Common
inspection.IsSign = true; inspection.IsSign = true;
} }
var inspectionData = new InspectionJsonDetail()
inspection.JsonDetail = new InspectionJsonDetail
{ {
//稽查实体,加上扩充的信息 //稽查实体,加上扩充的信息
Data = AddJsonItem(entityObj, otherItem), Data = AddJsonItem(entityObj, otherItem),
//通用信息 //通用信息 每条稽查必须记录的
Inspection = generalData CommonData = generalData
};
inspection.JsonDetail = inspectionData.ToJsonStr(); }.ToJsonStr();
inspection.BatchId = _userInfo.BatchId.Value; inspection.BatchId = _userInfo.BatchId.Value;
await _dbContext.DataInspection.AddAsync(inspection); await _dbContext.DataInspection.AddAsync(inspection);
@ -1250,7 +1260,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
Data = AddJsonItem(data, otherItem), Data = AddJsonItem(data, otherItem),
//通用信息 //通用信息
Inspection = generalData CommonData = generalData
}; };
add.JsonDetail = inspectionData.ToJsonStr(); add.JsonDetail = inspectionData.ToJsonStr();
add.BatchId = _userInfo.BatchId.Value; add.BatchId = _userInfo.BatchId.Value;

View File

@ -88,9 +88,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common.Dto
/// </summary> /// </summary>
public class InspectionJsonDetail public class InspectionJsonDetail
{ {
public dynamic Data { get; set; } public object Data { get; set; }
public InspectionGeneralData Inspection { get; set; } public InspectionGeneralData CommonData { get; set; }
} }