|
@@ -15,11 +15,7 @@ using Hotline.Application.Bulletin;
|
|
|
using Hotline.Share.Tools;
|
|
|
using Hotline.Application.Tools;
|
|
|
using SqlSugar;
|
|
|
-using Hotline.KnowledgeBase;
|
|
|
-using Hotline.Repository.SqlSugar.Knowledge;
|
|
|
-using Hotline.Share.Enums.KnowledgeBase;
|
|
|
-using Microsoft.AspNetCore.Http;
|
|
|
-using Hotline.Share.Enums.Caselibrary;
|
|
|
+using System.Numerics;
|
|
|
|
|
|
namespace Hotline.Application.Planlibrary
|
|
|
{
|
|
@@ -32,7 +28,6 @@ namespace Hotline.Application.Planlibrary
|
|
|
#region 注册
|
|
|
|
|
|
private readonly IRepository<PlanList> _planListRepository; //预案库列表
|
|
|
- private readonly IRepository<PlanRelationType> _planRelationTypeRepository; //预案库关联类型
|
|
|
private readonly IRepository<PlanType> _planTypeRepository; //预案库分类管理
|
|
|
private readonly IRepository<PlanTypeOrg> _planTypeOrgRepository; //预案库分类关联机构
|
|
|
private readonly IRepository<PlanCollect> _planCollectRepository; //预案库收藏评分
|
|
@@ -44,7 +39,6 @@ namespace Hotline.Application.Planlibrary
|
|
|
|
|
|
public PlanApplication(
|
|
|
IRepository<PlanList> planListRepository,
|
|
|
- IRepository<PlanRelationType> planRelationTypeRepository,
|
|
|
IRepository<PlanType> planTypeRepository,
|
|
|
IRepository<PlanTypeOrg> planTypeOrgRepository,
|
|
|
ISessionContext sessionContext,
|
|
@@ -55,7 +49,6 @@ namespace Hotline.Application.Planlibrary
|
|
|
IRepository<PlanCollect> planCollectRepository)
|
|
|
{
|
|
|
_planListRepository = planListRepository;
|
|
|
- _planRelationTypeRepository = planRelationTypeRepository;
|
|
|
_planTypeRepository = planTypeRepository;
|
|
|
_planTypeOrgRepository = planTypeOrgRepository;
|
|
|
_sessionContext = sessionContext;
|
|
@@ -169,7 +162,7 @@ namespace Hotline.Application.Planlibrary
|
|
|
throw UserFriendlyException.SameMessage("存在子级分类!");
|
|
|
|
|
|
//查询是否有预案分类
|
|
|
- var checkKnowledge = await _planListRepository.CountAsync(p => p.PlanTypes.Any(t => t.PlanId == Id), cancellationToken);
|
|
|
+ var checkKnowledge = await _planListRepository.CountAsync(p => p.PlanTypes.Any(t => t.Id == Id), cancellationToken);
|
|
|
if (checkKnowledge > 0)
|
|
|
throw UserFriendlyException.SameMessage("分类存在预案!");
|
|
|
|
|
@@ -248,7 +241,7 @@ namespace Hotline.Application.Planlibrary
|
|
|
(x.Status == EPlanStatus.Revert && x.CreatorId == _sessionContext.UserId) ||
|
|
|
(x.Status == EPlanStatus.NewDrafts && x.CreatorId == _sessionContext.UserId))
|
|
|
|
|
|
- .WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => x.PlanTypes.Any(t => t.PlanTypeSpliceName.StartsWith(typeSpliceName)))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => x.PlanTypes.Any(t => t.SpliceName.StartsWith(typeSpliceName)))
|
|
|
.WhereIF(!string.IsNullOrEmpty(hotspotHotSpotFullName), x => x.HotspotType.HotSpotFullName.EndsWith(hotspotHotSpotFullName!))
|
|
|
|
|
|
.WhereIF(pagedDto.CreationTimeStart.HasValue, x => x.CreationTime >= pagedDto.CreationTimeStart)
|
|
@@ -298,14 +291,17 @@ namespace Hotline.Application.Planlibrary
|
|
|
|
|
|
if (dto.Files != null && dto.Files.Count > 0)
|
|
|
pList.FileJson = await _fileRepository.AddFileAsync(dto.Files, pList.Id, "", cancellationToken);
|
|
|
- await _planListRepository.AddAsync(pList, cancellationToken);
|
|
|
|
|
|
if (dto.PlanTypes.Any())
|
|
|
{
|
|
|
- List<PlanRelationType> types = _mapper.Map<List<PlanRelationType>>(dto.PlanTypes);
|
|
|
- types.ForEach(x => x.PlanId = pList.Id);
|
|
|
- await _planRelationTypeRepository.AddRangeAsync(types, cancellationToken);
|
|
|
+ pList.PlanTypes = dto.PlanTypes.Select(d => new PlanType
|
|
|
+ {
|
|
|
+ Id = d.PlanTypeId,
|
|
|
+ }).ToList();
|
|
|
}
|
|
|
+ await _planListRepository.AddNav(pList)
|
|
|
+ .Include(d => d.PlanTypes)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
|
|
|
return pList.Id;
|
|
|
}
|
|
@@ -353,19 +349,23 @@ namespace Hotline.Application.Planlibrary
|
|
|
plan.FileJson = new List<Share.Dtos.File.FileJson>();
|
|
|
}
|
|
|
|
|
|
- await _planListRepository.UpdateNullAsync(plan, cancellationToken);
|
|
|
-
|
|
|
- if (dto.ApplyStatus != EPlanApplyStatus.Delete)
|
|
|
+ if (dto.PlanTypes.Any())
|
|
|
{
|
|
|
- if (dto.PlanTypes.Any())
|
|
|
+ plan.PlanTypes = dto.PlanTypes.Select(d => new PlanType
|
|
|
{
|
|
|
- var anyRelationTypes = await _planRelationTypeRepository.Queryable().Where(x => x.PlanId == plan.Id).ToListAsync();
|
|
|
- if (anyRelationTypes.Any())
|
|
|
- await _planRelationTypeRepository.RemoveRangeAsync(anyRelationTypes);
|
|
|
- List<PlanRelationType> types = _mapper.Map<List<PlanRelationType>>(dto.PlanTypes);
|
|
|
- types.ForEach(x => x.PlanId = dto.Id);
|
|
|
- await _planRelationTypeRepository.AddRangeAsync(types, cancellationToken);
|
|
|
- }
|
|
|
+ Id = d.PlanTypeId,
|
|
|
+ }).ToList();
|
|
|
+
|
|
|
+ await _planListRepository.UpdateNav(plan)
|
|
|
+ .Include(d => d.PlanTypes, new UpdateNavOptions
|
|
|
+ {
|
|
|
+ ManyToManyIsUpdateA = true
|
|
|
+ })
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await _planListRepository.UpdateAsync(plan, cancellationToken);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -455,11 +455,11 @@ namespace Hotline.Application.Planlibrary
|
|
|
planInfoDto.HotspotName = hot.HotSpotFullName;
|
|
|
|
|
|
// 分类
|
|
|
- var relationType = await _planRelationTypeRepository.QueryAsync(x => x.PlanId == Id && x.CreatorId == _sessionContext.UserId);
|
|
|
- if (relationType != null)
|
|
|
- {
|
|
|
- planInfoDto.PlanTypes = _mapper.Map<List<PlanRelationTypeDto>>(relationType);
|
|
|
- }
|
|
|
+ //var relationType = await _planRelationTypeRepository.QueryAsync(x => x.PlanId == Id);
|
|
|
+ //if (relationType != null)
|
|
|
+ //{
|
|
|
+ // planInfoDto.PlanTypes = _mapper.Map<List<PlanRelationTypeDto>>(relationType);
|
|
|
+ //}
|
|
|
|
|
|
// 收藏
|
|
|
var collect = await _planCollectRepository.GetAsync(x => x.PlanId == Id && x.CreatorId == _sessionContext.UserId);
|