This commit is contained in:
he
2023-03-28 17:00:57 +08:00
parent e8f2dfc5d6
commit b0a3aa4b18
4 changed files with 139 additions and 95 deletions
@@ -1,4 +1,4 @@
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// 此代码由T4模板自动生成 byzhouhang 20210918
// 生成时间 2022-03-31 13:18:56
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
@@ -49,7 +49,8 @@ namespace IRaCIS.Core.Application.Service
var verifyExp1 = new EntityVerifyExp<CommonDocument>()
{
VerifyExp = t => t.Code == addOrEditCommonDocument.Code,
VerifyMsg = "文档的Code不能够重复。"
//---文档的Code不能够重复。
VerifyMsg = _localizer["Document_CodeDuplication"]
};
//var verifyExp3 = new EntityVerifyExp<CommonDocument>()
@@ -61,10 +62,11 @@ namespace IRaCIS.Core.Application.Service
var verifyExp2 = new EntityVerifyExp<CommonDocument>()
{
VerifyExp = t => t.CriterionTypeEnum == addOrEditCommonDocument.CriterionTypeEnum && t.BusinessScenarioEnum==addOrEditCommonDocument.BusinessScenarioEnum &&
t.IsDeleted==addOrEditCommonDocument.IsDeleted,
VerifyMsg = "一个场景一个标准只允许有一个模板文档",
IsVerify=addOrEditCommonDocument.CriterionTypeEnum !=null && addOrEditCommonDocument.IsDeleted==false
VerifyExp = t => t.CriterionTypeEnum == addOrEditCommonDocument.CriterionTypeEnum && t.BusinessScenarioEnum == addOrEditCommonDocument.BusinessScenarioEnum &&
t.IsDeleted == addOrEditCommonDocument.IsDeleted,
//---一个场景一个标准只允许有一个模板文档
VerifyMsg = _localizer["Document_SingleTemplate"],
IsVerify = addOrEditCommonDocument.CriterionTypeEnum != null && addOrEditCommonDocument.IsDeleted == false
};
@@ -91,10 +93,11 @@ namespace IRaCIS.Core.Application.Service
}
catch (Exception )
catch (Exception)
{
return ResponseOutput.NotOk("读取模板内容失败, 请将文件另存为docx格式尝试!");
//---读取模板内容失败, 请将文件另存为docx格式尝试!
return ResponseOutput.NotOk(_localizer["Document_ TemplateRead"]);
}
@@ -121,9 +121,10 @@ namespace IRaCIS.Application.Services
{
var verifyExp1 = new EntityVerifyExp<Dictionary>()
{
VerifyExp = t => t.Code == addOrEditBasic.Code&&t.ParentId== addOrEditBasic.ParentId,
VerifyMsg = $"已有{addOrEditBasic.Code}名称的字典",
IsVerify= addOrEditBasic.ParentId ==null
VerifyExp = t => t.Code == addOrEditBasic.Code && t.ParentId == addOrEditBasic.ParentId,
//---------- $"已有{addOrEditBasic.Code}名称的字典"
VerifyMsg = _localizer["Dictionary_DictionaryName", addOrEditBasic.Code],
IsVerify = addOrEditBasic.ParentId == null
};
@@ -138,7 +139,7 @@ namespace IRaCIS.Application.Services
//}
if (addOrEditBasic.Id != null && addOrEditBasic.ParentId==null)
if (addOrEditBasic.Id != null && addOrEditBasic.ParentId == null)
{
await _dicRepository.UpdatePartialFromQueryAsync(t => t.ParentId == addOrEditBasic.Id, c => new Dictionary() { DataTypeEnum = addOrEditBasic.DataTypeEnum });
@@ -174,12 +175,14 @@ namespace IRaCIS.Application.Services
if (await _readingCriterionDictionaryRepository.AnyAsync(x => x.DictionaryId == id))
{
await _readingCriterionDictionaryRepository.BatchDeleteNoTrackingAsync(t => t.DictionaryId == id);
//return ResponseOutput.NotOk("当前字典在标准中被引用,不允许删除!");
//---当前字典在标准中被引用,不允许删除!
//return ResponseOutput.NotOk(_localizer["Dictionary_DictionaryDeletion"]);
}
if (await _dicRepository.AnyAsync(t => t.ParentId == id))
{
return ResponseOutput.NotOk("有子项数据,不允许直接删除!");
//---有子项数据,不允许直接删除!
return ResponseOutput.NotOk(_localizer["Dictionary_SubitemDeletion"]);
}
if ((await _doctorDictionaryRepository.AnyAsync(t => t.DictionaryId == id)) ||
@@ -187,19 +190,22 @@ namespace IRaCIS.Application.Services
)
{
return ResponseOutput.NotOk("当前条目已经在阅片人的简历中被引用。");
//---当前条目已经在阅片人的简历中被引用。
return ResponseOutput.NotOk(_localizer["Dictionary_ResumeReference"]);
}
if (await _trialDictionaryRepository.AnyAsync(t => t.DictionaryId == id) ||
await _trialRepository.AnyAsync(t => t.ReviewModeId == id))
{
return ResponseOutput.NotOk("当前条目已经在项目信息中被引用。");
//---当前条目已经在项目信息中被引用。
return ResponseOutput.NotOk(_localizer["Dictionary_ProjectReference"]);
}
if (await _readingCriterionDictionaryRepository.AnyAsync(x => x.DictionaryId == id))
{
await _readingCriterionDictionaryRepository.BatchDeleteNoTrackingAsync(t => t.DictionaryId == id);
//return ResponseOutput.NotOk("当前条目已经在阅片标准中被引用。");
//---当前条目已经在阅片标准中被引用。
//return ResponseOutput.NotOk(_localizer["Dictionary_StandardReference"]);
}
var success = await _dicRepository.BatchDeleteNoTrackingAsync(t => t.Id == id);
@@ -243,7 +249,7 @@ namespace IRaCIS.Application.Services
/// <returns></returns>
public async Task<List<BasicDicSelect>> GetBasicConfigSelect(string searchKey)
{
var searchList = await _dicRepository.Where(t => t.ConfigDictionary.Code == searchKey && t.ParentId == null && t.IsEnable).ProjectTo<BasicDicSelect>(_mapper.ConfigurationProvider).OrderBy(x=>x.ShowOrder).ToListAsync();
var searchList = await _dicRepository.Where(t => t.ConfigDictionary.Code == searchKey && t.ParentId == null && t.IsEnable).ProjectTo<BasicDicSelect>(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync();
return searchList;
}
@@ -254,12 +260,12 @@ namespace IRaCIS.Application.Services
/// <returns></returns>
public async Task<List<GetCriterionDictionaryListOutDto>> GetCriterionDictionaryList(GetCriterionDictionaryListInDto inDto)
{
var criterionCodes= await _systemCriterionDictionaryCodeRepository.Where(x => x.SystemCriterionId == inDto.SystemCriterionId).ToListAsync();
var criterionCodes = await _systemCriterionDictionaryCodeRepository.Where(x => x.SystemCriterionId == inDto.SystemCriterionId).ToListAsync();
var parentCodes = await _readingCriterionDictionaryRepository.Where(x => x.CriterionId== inDto.SystemCriterionId).Select(x => x.ParentCode).ToListAsync();
var parentCodes = await _readingCriterionDictionaryRepository.Where(x => x.CriterionId == inDto.SystemCriterionId).Select(x => x.ParentCode).ToListAsync();
var codes = criterionCodes.Select(x=>x.Code).ToList();
var codes = criterionCodes.Select(x => x.Code).ToList();
var dictionaryList = await _dicRepository.Where(x => codes.Contains(x.Code) && x.ParentId == null)
.OrderBy(x => x.ShowOrder).Select(x => new GetCriterionDictionaryListOutDto()
@@ -269,7 +275,8 @@ namespace IRaCIS.Application.Services
Description = x.Description
}).ToListAsync();
dictionaryList.ForEach(x => {
dictionaryList.ForEach(x =>
{
x.Count = parentCodes.Count(y => y == x.Code);
x.Id = criterionCodes.Where(y => y.Code == x.Code).Select(x => x.Id).FirstOrDefault();
});
@@ -299,7 +306,8 @@ namespace IRaCIS.Application.Services
Description = x.Description
}).ToListAsync();
dictionaryList.ForEach(x => {
dictionaryList.ForEach(x =>
{
x.Count = parentCodes.Count(y => y == x.Code);
x.Id = criterionCodes.Where(y => y.Code == x.Code).Select(x => x.Id).FirstOrDefault();
});
@@ -317,8 +325,8 @@ namespace IRaCIS.Application.Services
public async Task<Dictionary<string, List<BasicDicSelect>>> GetCriterionDictionary(GetCriterionDictionaryInDto inDto)
{
var searchList = await _dicRepository.Where(t => t.ParentId != null && t.IsEnable)
.WhereIf(!inDto.DictionaryCode.IsNullOrEmpty(), x =>x.Parent.Code==inDto.DictionaryCode)
.WhereIf(inDto.DictionaryCodeList.Count()>0, x => inDto.DictionaryCodeList.Contains(x.Parent.Code))
.WhereIf(!inDto.DictionaryCode.IsNullOrEmpty(), x => x.Parent.Code == inDto.DictionaryCode)
.WhereIf(inDto.DictionaryCodeList.Count() > 0, x => inDto.DictionaryCodeList.Contains(x.Parent.Code))
.ProjectTo<BasicDicSelect>(_mapper.ConfigurationProvider).ToListAsync();
var result = searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.OrderBy(t => t.ShowOrder).ToList());
@@ -348,7 +356,7 @@ namespace IRaCIS.Application.Services
{
if (result.ContainsKey(item))
{
result[item] = new List<BasicDicSelect> ();
result[item] = new List<BasicDicSelect>();
}
}
@@ -361,7 +369,7 @@ namespace IRaCIS.Application.Services
ParentChildCodeEnum = x.Dictionary.Parent.ChildCodeEnum,
ShowOrder = x.Dictionary.ShowOrder,
ParentCode = x.ParentCode,
CrterionDictionaryGroup=x.CrterionDictionaryGroup,
CrterionDictionaryGroup = x.CrterionDictionaryGroup,
Id = x.DictionaryId,
ParentId = x.Dictionary.ParentId,
Value = x.Dictionary.Value,
@@ -380,7 +388,7 @@ namespace IRaCIS.Application.Services
result[item.Key] = item.Value;
}
}
return result;
@@ -396,7 +404,7 @@ namespace IRaCIS.Application.Services
[AllowAnonymous]
public async Task<Dictionary<string, List<BasicDicSelect>>> GetBasicDataAllSelect(GetBasicDataAllSelectInDto inDto)
{
var searchList = await _dicRepository.Where(t => t.ParentId != null && t.IsEnable ).ProjectTo<BasicDicSelect>(_mapper.ConfigurationProvider).ToListAsync();
var searchList = await _dicRepository.Where(t => t.ParentId != null && t.IsEnable).ProjectTo<BasicDicSelect>(_mapper.ConfigurationProvider).ToListAsync();
var result = searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.OrderBy(t => t.ShowOrder).ToList());
@@ -406,7 +414,7 @@ namespace IRaCIS.Application.Services
}
else
{
List<string> selectCode = await _trialCriterionDictionaryCodeRepository.Where(x => x.TrialCriterionId == inDto.TrialReadingCriterionId).Select(x => x.Code).ToListAsync();
List<string> selectCode = await _trialCriterionDictionaryCodeRepository.Where(x => x.TrialCriterionId == inDto.TrialReadingCriterionId).Select(x => x.Code).ToListAsync();
var criterionCode = await _dicRepository.Where(x => x.ConfigDictionary.Code == "Reading_eCRF_Criterion").Select(x => x.Code).ToListAsync();
@@ -427,13 +435,13 @@ namespace IRaCIS.Application.Services
{
ChildGroup = x.Dictionary.ChildGroup,
Code = x.Dictionary.Code,
Description=x.Dictionary.Description,
Description = x.Dictionary.Description,
DataTypeEnum = x.Dictionary.DataTypeEnum,
ParentChildCodeEnum = x.Dictionary.Parent.ChildCodeEnum,
ShowOrder = x.Dictionary.ShowOrder,
ParentCode = x.ParentCode,
Id = x.DictionaryId,
CrterionDictionaryGroup=x.CrterionDictionaryGroup,
CrterionDictionaryGroup = x.CrterionDictionaryGroup,
ParentId = x.Dictionary.ParentId,
Value = x.Dictionary.Value,
ValueCN = x.Dictionary.ValueCN
@@ -452,7 +460,7 @@ namespace IRaCIS.Application.Services
return result;
}
}
#region