删除领域层的 json 转换

Uat_Study
hang 2022-05-24 16:19:49 +08:00
parent 7cdbb5421d
commit f5b4af2ad7
7 changed files with 172 additions and 172 deletions

View File

@ -10,19 +10,14 @@ using System.Threading.Tasks;
using IRaCIS.Core.Application.Contracts.Dicom; using IRaCIS.Core.Application.Contracts.Dicom;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using IRaCIS.Core.Application.Dicom;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using IRaCIS.Core.Application.Filter; using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Infrastructure.Extention; using IRaCIS.Core.Infrastructure.Extention;
using EasyCaching.Core; using EasyCaching.Core;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Application.Service.Inspection.Interface; using IRaCIS.Core.Application.Service.Inspection.Interface;
using Newtonsoft.Json;
using IRaCIS.Core.Application.Service.Inspection.DTO;
using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Domain.Common;
namespace IRaCIS.Api.Controllers namespace IRaCIS.Api.Controllers
{ {

View File

@ -87,7 +87,7 @@ namespace IRaCIS.Application.Services
} }
if (dbUser.Password == oldPwd) if (dbUser.Password != oldPwd)
{ {
throw new BusinessValidationFailedException("旧密码验证失败。"); throw new BusinessValidationFailedException("旧密码验证失败。");
} }

View File

@ -1,5 +1,4 @@
using EntityFrameworkCore.Triggered; using EntityFrameworkCore.Triggered;
using IRaCIS.Core.Domain.Common;
using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Application.Triggers namespace IRaCIS.Core.Application.Triggers

View File

@ -1,29 +0,0 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace IRaCIS.Core.Domain.Common
{
public static class JJsonConvert
{
/// <summary>
/// 将对象序列化成稽查需要的Json字符串
/// </summary>
/// <param name="obj">需要序列化的对象</param>
/// <returns></returns>
public static string ToJcJson(this object obj)
{
//JsonSerializerSettings settings = new JsonSerializerSettings();
//settings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
//settings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
//return JsonConvert.SerializeObject(obj, settings);
return JsonConvert.SerializeObject(obj);
}
}
}

View File

@ -1,5 +1,4 @@
using IRaCIS.Core.Domain.Common; using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore.Common.Dto; using IRaCIS.Core.Infra.EFCore.Common.Dto;
using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Infrastructure;
@ -121,7 +120,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
await InsertInspection<SystemDocument>(item, type, x => new DataInspection() await InsertInspection<SystemDocument>(item, type, x => new DataInspection()
{ {
GeneralId = x.Id GeneralId = x.Id
},new { }, new
{
NeedConfirmedUserType = usertypeName, NeedConfirmedUserType = usertypeName,
}); });
} }
@ -177,7 +177,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
TrialName = x.ExperimentName, TrialName = x.ExperimentName,
ResearchProgramNo = x.ResearchProgramNo, ResearchProgramNo = x.ResearchProgramNo,
GeneralId = x.Id, GeneralId = x.Id,
},new { }, new
{
TrialDicList = string.Join(",", trials) TrialDicList = string.Join(",", trials)
}); });
} }
@ -197,7 +198,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
VisitStageId = x.Id, VisitStageId = x.Id,
GeneralId = x.Id, GeneralId = x.Id,
},new { }, new
{
VisitPlanStatus = VisitPlanStatus, VisitPlanStatus = VisitPlanStatus,
}); });
} }
@ -235,7 +237,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
await InsertInspection<SystemDocConfirmedUser>(item, type, x => new DataInspection() await InsertInspection<SystemDocConfirmedUser>(item, type, x => new DataInspection()
{ {
GeneralId = x.Id, GeneralId = x.Id,
},new { }, new
{
FileTypeId = systemDocument.FileTypeId, FileTypeId = systemDocument.FileTypeId,
Name = systemDocument.Name, Name = systemDocument.Name,
@ -255,7 +258,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
TrialId = trialid, TrialId = trialid,
GeneralId = x.Id, GeneralId = x.Id,
},new { }, new
{
FileTypeId = trialDocument.FileTypeId, FileTypeId = trialDocument.FileTypeId,
Name = trialDocument.Name, Name = trialDocument.Name,
CreateTime = trialDocument.CreateTime, CreateTime = trialDocument.CreateTime,
@ -402,7 +406,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
GeneralId = x.Id, GeneralId = x.Id,
},new { }, new
{
TrialSiteCode = entity.TrialSite.TrialSiteCode, TrialSiteCode = entity.TrialSite.TrialSiteCode,
TrialSiteAliasName = entity.TrialSite.TrialSiteAliasName, TrialSiteAliasName = entity.TrialSite.TrialSiteAliasName,
Phone = entity.Phone, Phone = entity.Phone,
@ -421,7 +426,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
await InsertInspection<TrialQCQuestion>(item, type, x => new DataInspection() await InsertInspection<TrialQCQuestion>(item, type, x => new DataInspection()
{ {
GeneralId = x.Id, GeneralId = x.Id,
},new { }, new
{
QuestionName = entity.QuestionName, QuestionName = entity.QuestionName,
Type = entity.Type, Type = entity.Type,
TypeValue = entity.TypeValue, TypeValue = entity.TypeValue,
@ -688,7 +694,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SubjectId = subjectvisit.SubjectId, SubjectId = subjectvisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName, SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName, BlindName = subjectvisit.BlindName,
},new { }, new
{
ChallengeCode = "Q" + entity.ChallengeCode.ToString("D5"), ChallengeCode = "Q" + entity.ChallengeCode.ToString("D5"),
AuditState = subjectvisit.AuditState, AuditState = subjectvisit.AuditState,
TalkContent = content, TalkContent = content,
@ -722,7 +729,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SubjectVisitName = subjectvisit.VisitName, SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName, BlindName = subjectvisit.BlindName,
Reason = reason, Reason = reason,
}, new { }, new
{
AuditState = subjectvisit.AuditState, AuditState = subjectvisit.AuditState,
ChallengeCode = "Q" + qCChallenge.ChallengeCode.ToString("D5"), ChallengeCode = "Q" + qCChallenge.ChallengeCode.ToString("D5"),
ReuploadEnum = qCChallenge.ReuploadEnum, ReuploadEnum = qCChallenge.ReuploadEnum,
@ -758,7 +766,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SubjectVisitName = subjectvisit.VisitName, SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName, BlindName = subjectvisit.BlindName,
Reason = reason, Reason = reason,
},new { }, new
{
CheckState = subjectvisit.CheckState, CheckState = subjectvisit.CheckState,
RequestBackState = subjectvisit.RequestBackState, RequestBackState = subjectvisit.RequestBackState,
CheckChallengeState = subjectvisit.CheckChallengeState, CheckChallengeState = subjectvisit.CheckChallengeState,
@ -983,7 +992,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
Data = AddJsonItem(data, otherItem), Data = AddJsonItem(data, otherItem),
Inspection = generalData Inspection = generalData
}; };
add.JsonDetail = inspectionData.ToJcJson(); add.JsonDetail = inspectionData.ToJsonStr();
await _dbContext.DataInspection.AddAsync(add); await _dbContext.DataInspection.AddAsync(add);
} }
@ -1000,13 +1009,13 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{ {
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>((json as object).ToJcJson()); var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>((json as object).ToJsonStr());
if (otherItem == null) if (otherItem == null)
{ {
return JsonData; return JsonData;
} }
var other = JsonConvert.DeserializeObject<IDictionary<string, object>>(otherItem.ToJcJson()); var other = JsonConvert.DeserializeObject<IDictionary<string, object>>(otherItem.ToJsonStr());
foreach (var item in other) foreach (var item in other)
{ {
@ -1055,12 +1064,18 @@ namespace IRaCIS.Core.Infra.EFCore.Common
if (generalData.TrialId != null) if (generalData.TrialId != null)
{
//项目添加哪里 直接会带信息过来,不用查询数据库 其他的地方需要查询数据库
if (string.IsNullOrEmpty(generalData.ResearchProgramNo) || string.IsNullOrEmpty(generalData.TrialName))
{ {
var trialdata = (await _dbContext.Trial.Select(x => new { x.Id, x.ResearchProgramNo, x.ExperimentName, }).FirstOrDefaultAsync(x => x.Id == generalData.TrialId)).IfNullThrowException(); var trialdata = (await _dbContext.Trial.Select(x => new { x.Id, x.ResearchProgramNo, x.ExperimentName, }).FirstOrDefaultAsync(x => x.Id == generalData.TrialId)).IfNullThrowException();
generalData.ResearchProgramNo = trialdata.ResearchProgramNo; generalData.ResearchProgramNo = trialdata.ResearchProgramNo;
generalData.TrialName = trialdata.ExperimentName; generalData.TrialName = trialdata.ExperimentName;
}
} }
@ -1074,42 +1089,53 @@ namespace IRaCIS.Core.Infra.EFCore.Common
generalData.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().Where(x => x.TrialId == generalData.TrialId && x.SiteId == generalData.SiteId).Select(t => t.TrialSiteCode).FirstOrDefaultAsync()).IfNullThrowException(); generalData.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().Where(x => x.TrialId == generalData.TrialId && x.SiteId == generalData.SiteId).Select(t => t.TrialSiteCode).FirstOrDefaultAsync()).IfNullThrowException();
// 添加Site 哪里会带信息过来
if (string.IsNullOrEmpty(generalData.SiteName))
{
generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException(); generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException();
} }
}
#endregion #endregion
#region 受试者 #region 受试者
if (generalData.SubjectId != null)
if (IsNullOrEmpty(generalData.SubjectCode) && generalData.SubjectId != null)
{ {
generalData.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => new { x.Code }).FirstOrDefaultAsync())?.Code; // 添加Subject 哪里会带信息过来
if (string.IsNullOrEmpty(generalData.SubjectCode))
{
generalData.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => x.Code).FirstOrDefaultAsync()).IfNullThrowException();
} }
}
#endregion #endregion
#region 访视 #region 访视
if (IsNullOrEmpty(generalData.SubjectVisitName))
if (generalData.SubjectVisitId != null)
{ {
generalData.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => new { x.VisitName }).FirstOrDefaultAsync())?.VisitName; //添加访视的时候,会带信息过来
if (string.IsNullOrEmpty(generalData.SubjectVisitName))
{
generalData.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => x.VisitName).FirstOrDefaultAsync()).IfNullThrowException();
} }
}
#endregion #endregion
#region 创建者
if (IsNullOrEmpty(generalData.CreateUserName))
{
generalData.CreateUserName = _userInfo.RealName; generalData.CreateUserName = _userInfo.RealName;
}
if (IsNullOrEmpty(generalData.RoleName))
{
generalData.RoleName = _userInfo.UserTypeShortName; generalData.RoleName = _userInfo.UserTypeShortName;
}
#endregion
} }
} }

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
@ -18,7 +17,6 @@ using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.Data.SqlClient; using Microsoft.Data.SqlClient;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using IRaCIS.Core.Domain.Common;
using IRaCIS.Core.Infra.EFCore.Common.Dto; using IRaCIS.Core.Infra.EFCore.Common.Dto;
namespace IRaCIS.Core.Infra.EFCore namespace IRaCIS.Core.Infra.EFCore

View File

@ -3,7 +3,7 @@ using System;
namespace IRaCIS.Core.Infrastructure.Extention namespace IRaCIS.Core.Infrastructure.Extention
{ {
public static class CloneExtension public static class ObjectExtension
{ {
public static T Clone<T>(this T source) public static T Clone<T>(this T source)
@ -18,5 +18,16 @@ namespace IRaCIS.Core.Infrastructure.Extention
var serializeSettings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; var serializeSettings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };
return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(source, serializeSettings), deserializeSettings); return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(source, serializeSettings), deserializeSettings);
} }
/// <summary>
/// 将对象序列化成稽查需要的Json字符串
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string ToJsonStr(this object obj)
{
return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
}
} }
} }