PlanApplication.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. using Hotline.Planlibrary;
  2. using Hotline.Settings.Hotspots;
  3. using Hotline.Share.Dtos.Knowledge;
  4. using Hotline.Share.Dtos.Planlibrary;
  5. using Hotline.Share.Enums.Planlibrary;
  6. using MapsterMapper;
  7. using XF.Domain.Authentications;
  8. using XF.Domain.Dependency;
  9. using XF.Domain.Exceptions;
  10. using XF.Domain.Repository;
  11. using Hotline.Repository.SqlSugar.Extensions;
  12. using Hotline.SeedData;
  13. using Hotline.File;
  14. using Hotline.Application.Bulletin;
  15. using Hotline.Share.Tools;
  16. using Hotline.Application.Tools;
  17. using Hotline.KnowledgeBase;
  18. using NPOI.SS.Formula.Functions;
  19. using SqlSugar;
  20. using Senparc.CO2NET.Extensions;
  21. namespace Hotline.Application.Planlibrary
  22. {
  23. /// <summary>
  24. /// 预案库处理
  25. /// </summary>
  26. public class PlanApplication : IPlanApplication, IScopeDependency
  27. {
  28. #region 注册
  29. private readonly IRepository<PlanList> _planListRepository; //预案库列表
  30. private readonly IRepository<PlanRelationType> _planRelationTypeRepository; //预案库关联类型
  31. private readonly IRepository<PlanType> _planTypeRepository; //预案库分类管理
  32. private readonly IRepository<PlanTypeOrg> _planTypeOrgRepository; //预案库分类关联机构
  33. private readonly ISessionContext _sessionContext;
  34. private readonly IMapper _mapper;
  35. private readonly IRepository<Hotspot> _hotspotTypeRepository;
  36. private readonly IFileRepository _fileRepository;
  37. private readonly IBulletinApplication _bulletinApplication;
  38. public PlanApplication(
  39. IRepository<PlanList> planListRepository,
  40. IRepository<PlanRelationType> planRelationTypeRepository,
  41. IRepository<PlanType> planTypeRepository,
  42. IRepository<PlanTypeOrg> planTypeOrgRepository,
  43. ISessionContext sessionContext,
  44. IMapper mapper,
  45. IRepository<Hotspot> hotspotTypeRepository,
  46. IFileRepository fileRepository,
  47. IBulletinApplication bulletinApplication)
  48. {
  49. _planListRepository = planListRepository;
  50. _planRelationTypeRepository = planRelationTypeRepository;
  51. _planTypeRepository = planTypeRepository;
  52. _planTypeOrgRepository = planTypeOrgRepository;
  53. _sessionContext = sessionContext;
  54. _mapper = mapper;
  55. _hotspotTypeRepository = hotspotTypeRepository;
  56. _fileRepository = fileRepository;
  57. _bulletinApplication = bulletinApplication;
  58. }
  59. #endregion
  60. #region 预案库类型管理
  61. #region 预案库类型 - 新增
  62. /// <summary>
  63. /// 预案库类型 - 新增
  64. /// </summary>
  65. /// <param name="dto"></param>
  66. /// <param name="cancellationToken"></param>
  67. /// <returns></returns>
  68. public async Task<string> AddTypeAsync(AddPlanTypeDto dto, CancellationToken cancellationToken)
  69. {
  70. var sandard = await _planTypeRepository.GetAsync(p => p.ParentId == dto.ParentId && p.Name == dto.Name && p.IsDeleted == false, cancellationToken);
  71. if (sandard is not null)
  72. throw UserFriendlyException.SameMessage("当前层级已存在相同名称的分类!");
  73. var type = _mapper.Map<PlanType>(dto);
  74. type.InitId();
  75. type.IsEnable = true;
  76. //获取分类名称全称
  77. string FullName = await GetFullName(type.ParentId);
  78. //处理全称,如果为第一级直接用全称,否则获取全称后拼接名称
  79. type.SpliceName = string.IsNullOrEmpty(FullName) ? dto.Name : FullName + "-" + dto.Name;
  80. var id = await _planTypeRepository.AddAsync(type, cancellationToken);
  81. return id;
  82. }
  83. #endregion
  84. #region 预案库类型 - 编辑
  85. /// <summary>
  86. /// 预案库类型 - 编辑
  87. /// </summary>
  88. /// <param name="dto"></param>
  89. /// <param name="cancellationToken"></param>
  90. /// <returns></returns>
  91. public async Task UpdateTypeAsync(UpdatePlanTypeDto dto, CancellationToken cancellationToken)
  92. {
  93. //查询原有数据
  94. var type = await _planTypeRepository.GetAsync(dto.Id, cancellationToken);
  95. if (type is null)
  96. throw UserFriendlyException.SameMessage("编辑失败!");
  97. bool result = type.Name != dto.Name || type.ParentId != dto.ParentId;
  98. //是否更改分类名称或者层级
  99. //转换
  100. _mapper.Map(dto, type);
  101. //如果更改了名称或者修改了层级,则修改全称,未更改不修改
  102. if (result)
  103. {
  104. string FullName = await GetFullName(type.ParentId);//获取分类名称全称
  105. type.SpliceName = string.IsNullOrEmpty(FullName) ? dto.Name : FullName + "-" + dto.Name;//处理全称,如果为第一级直接用全称,否则获取全称后拼接名称
  106. }
  107. //修改数据
  108. await _planTypeRepository.UpdateAsync(type, cancellationToken);
  109. //如果修改了名称,对应修改子分类全称
  110. if (result)
  111. await UpdateChildNode(type.Id);
  112. // 修改关联机构
  113. await _planTypeOrgRepository.RemoveAsync(x => x.TypeId == type.Id, false, cancellationToken);
  114. if (dto.TypeOrgDtos != null && dto.TypeOrgDtos.Any())
  115. {
  116. List<PlanTypeOrg> orgs = _mapper.Map<List<PlanTypeOrg>>(dto.TypeOrgDtos);
  117. orgs.ForEach(x => x.TypeId = type.Id);
  118. await _planTypeOrgRepository.AddRangeAsync(orgs, cancellationToken);
  119. }
  120. }
  121. #endregion
  122. #region 预案库类型 - 删除
  123. /// <summary>
  124. /// 预案库类型 - 删除
  125. /// </summary>
  126. /// <param name="Id"></param>
  127. /// <param name="cancellationToken"></param>
  128. /// <returns></returns>
  129. public async Task RemoveTypeAsync(string Id, CancellationToken cancellationToken)
  130. {
  131. //查询数据是否存在
  132. var sandard = await _planTypeRepository.GetAsync(p => p.Id == Id && p.IsDeleted == false, cancellationToken);
  133. if (sandard is null)
  134. throw UserFriendlyException.SameMessage("分类不存在!");
  135. //查询是否有子级分类
  136. var checkChild = await _planTypeRepository.CountAsync(p => p.ParentId == Id && p.IsDeleted == false, cancellationToken);
  137. if (checkChild > 0)
  138. throw UserFriendlyException.SameMessage("存在子级分类!");
  139. //查询是否有知识分类
  140. var checkKnowledge = await _planListRepository.CountAsync(p => p.PlanTypes.Any(t => t.PlanId == Id), cancellationToken);
  141. if (checkKnowledge > 0)
  142. throw UserFriendlyException.SameMessage("分类存在预案!");
  143. //删除操作
  144. await _planTypeRepository.RemoveAsync(sandard, true, cancellationToken);
  145. }
  146. #endregion
  147. #endregion
  148. #region 预案库管理
  149. #region 预案库 - 列表
  150. /// <summary>
  151. /// 预案库 - 列表
  152. /// </summary>
  153. /// <param name="pagedDto"></param>
  154. /// <returns></returns>
  155. public async Task<(int, IList<PlanDataDto>)> QueryAllPlanListAsync(PlanListDto pagedDto, CancellationToken cancellationToken)
  156. {
  157. //if (!_sessionContext.OrgIsCenter)
  158. //{// 部门只能查询【部门预案库】
  159. // pagedDto.Attribution = "部门预案库";
  160. //}
  161. var typeSpliceName = string.Empty;
  162. var hotspotHotSpotFullName = string.Empty;
  163. if (!string.IsNullOrEmpty(pagedDto.PlanTypeID))
  164. {
  165. var type = await _planTypeRepository.GetAsync(x => x.Id == pagedDto.PlanTypeID);
  166. typeSpliceName = type?.SpliceName;
  167. }
  168. if (!string.IsNullOrEmpty(pagedDto.HotspotId))
  169. {
  170. var hotspot = await _hotspotTypeRepository.GetAsync(x => x.Id == pagedDto.HotspotId);
  171. hotspotHotSpotFullName = hotspot?.HotSpotFullName;
  172. }
  173. //单表分页
  174. var (total, temp) = await _planListRepository.Queryable()
  175. .Includes(x => x.PlanTypes)
  176. .Includes(x => x.HotspotType)
  177. .Where(x => x.IsDeleted == false)
  178. .Where(x => (x.Status == EPlanStatus.Drafts && x.CreatorId == _sessionContext.UserId) || (x.Status != EPlanStatus.Drafts))
  179. .WhereIF(OrgSeedData.CenterId != pagedDto.CreateOrgId && !string.IsNullOrEmpty(pagedDto.CreateOrgId), x => x.CreatorOrgId != null && x.CreatorOrgId.StartsWith(pagedDto.CreateOrgId!))
  180. .WhereIF(!string.IsNullOrEmpty(pagedDto.Attribution), x => x.Attribution == pagedDto.Attribution)
  181. .WhereIF(!string.IsNullOrEmpty(pagedDto.Title), x => x.Title.Contains(pagedDto.Title))
  182. .WhereIF(!string.IsNullOrEmpty(pagedDto.Keyword), x => x.Title.Contains(pagedDto.Keyword!) ||
  183. x.CreatorName!.Contains(pagedDto.Keyword!) ||
  184. x.CreatorOrgName!.Contains(pagedDto.Keyword!))
  185. .WhereIF(pagedDto.Status.HasValue && pagedDto.Status != EPlanStatus.OffShelf &&
  186. pagedDto.Status != EPlanStatus.NewDrafts &&
  187. pagedDto.Status != EPlanStatus.All,
  188. x => x.Status == pagedDto.Status && ((x.ExpiredTime != null && x.ExpiredTime > DateTime.Now) || x.ExpiredTime == null))
  189. .WhereIF(pagedDto.Status.HasValue && pagedDto.Status == EPlanStatus.OffShelf, x => x.Status == pagedDto.Status || (x.ExpiredTime != null && x.ExpiredTime < DateTime.Now && x.Status != EPlanStatus.Drafts))
  190. .WhereIF(pagedDto.Status.HasValue && pagedDto.Status == EPlanStatus.NewDrafts, x => x.Status == EPlanStatus.Drafts || x.Status == EPlanStatus.Revert)
  191. .WhereIF(pagedDto.IsPublic.HasValue, x => x.IsPublic == pagedDto.IsPublic)
  192. .WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => x.PlanTypes.Any(t => t.PlanTypeSpliceName.StartsWith(typeSpliceName)))
  193. .WhereIF(!string.IsNullOrEmpty(hotspotHotSpotFullName), x => x.HotspotType.HotSpotFullName.EndsWith(hotspotHotSpotFullName!))
  194. .WhereIF(pagedDto.CreationTimeStart.HasValue, x => x.CreationTime >= pagedDto.CreationTimeStart)
  195. .WhereIF(pagedDto.CreationTimeEnd.HasValue, x => x.CreationTime <= pagedDto.CreationTimeEnd)
  196. .WhereIF(pagedDto.OnShelfTimeStart.HasValue, x => x.OnShelfTime >= pagedDto.OnShelfTimeStart)
  197. .WhereIF(pagedDto.OnShelfTimeEnd.HasValue, x => x.OnShelfTime <= pagedDto.OnShelfTimeEnd)
  198. .WhereIF(pagedDto.OffShelfTimeStart.HasValue, x => x.OffShelfTime >= pagedDto.OffShelfTimeStart)
  199. .WhereIF(pagedDto.OffShelfTimeEnd.HasValue, x => x.OffShelfTime <= pagedDto.OffShelfTimeEnd)
  200. .WhereIF(pagedDto.UpdateTimeStart.HasValue, x => x.UpdateTime >= pagedDto.UpdateTimeStart)
  201. .WhereIF(pagedDto.UpdateTimeEnd.HasValue, x => x.UpdateTime <= pagedDto.UpdateTimeEnd)
  202. .WhereIF(pagedDto.ExaminTimeStart.HasValue, x => x.ExaminTime >= pagedDto.ExaminTimeStart)
  203. .WhereIF(pagedDto.ExaminTimeEnd.HasValue, x => x.ExaminTime <= pagedDto.ExaminTimeEnd)
  204. .OrderByIF(string.IsNullOrEmpty(pagedDto.SortField), d => d.CreationTime, OrderByType.Desc)
  205. .OrderByIF(pagedDto is { SortField: "PageView" }, d => d.PageView, OrderByType.Desc) //阅读量
  206. .OrderByIF(pagedDto is { SortField: "Score" }, d => d.Score, OrderByType.Desc) //评分
  207. .OrderByIF(pagedDto is { SortField: "CreationTime" }, d => d.CreationTime, OrderByType.Desc) //创建时间
  208. .ToPagedListAsync(pagedDto.PageIndex, pagedDto.PageSize, cancellationToken);
  209. return (total, _mapper.Map<IList<PlanDataDto>>(temp));
  210. }
  211. #endregion
  212. #region 预案库 - 新增
  213. /// <summary>
  214. /// 新增
  215. /// </summary>
  216. /// <param name="dto"></param>
  217. /// <param name="cancellationToken"></param>
  218. /// <returns></returns>
  219. public async Task<string> AddPlanAsync(AddPlanListDto dto, CancellationToken cancellationToken)
  220. {
  221. var pList = _mapper.Map<PlanList>(dto);
  222. var any = await _planListRepository.Queryable().Where(x => x.Status == EPlanStatus.OnShelf && x.Title == dto.Title).AnyAsync();
  223. if (any)
  224. throw UserFriendlyException.SameMessage("当前知识标题存在重复标题!");
  225. if (dto.Files != null && dto.Files.Count > 0)
  226. pList.FileJson = await _fileRepository.AddFileAsync(dto.Files, pList.Id, "", cancellationToken);
  227. await _planListRepository.AddAsync(pList, cancellationToken);
  228. if (dto.PlanType.Any())
  229. {
  230. List<PlanRelationType> types = _mapper.Map<List<PlanRelationType>>(dto.PlanType);
  231. types.ForEach(x => x.PlanId = pList.Id);
  232. await _planRelationTypeRepository.AddRangeAsync(types, cancellationToken);
  233. }
  234. return pList.Id;
  235. }
  236. #endregion
  237. #region 预案库 - 修改
  238. /// <summary>
  239. /// 修改
  240. /// </summary>
  241. /// <param name="dto"></param>
  242. /// <param name="cancellationToken"></param>
  243. /// <returns></returns>
  244. public async Task UpdatePlanAsync(UpdatePlanListDto dto, CancellationToken cancellationToken)
  245. {
  246. var plan = await _planListRepository.GetAsync(dto.Id);
  247. if (plan == null)
  248. throw UserFriendlyException.SameMessage("预案库查询失败");
  249. if ((plan.Status == EPlanStatus.OnShelf || plan.Status == EPlanStatus.Auditing) && (plan.ExpiredTime.HasValue && plan.ExpiredTime.Value > DateTime.Now))
  250. throw UserFriendlyException.SameMessage("预案库数据不可修改");
  251. var any = await _planListRepository.Queryable().Where(x => x.Status == EPlanStatus.OnShelf && x.Title == dto.Title && x.Id != dto.Id).AnyAsync();
  252. if (any)
  253. throw UserFriendlyException.SameMessage("当前知识标题存在重复标题!");
  254. _mapper.Map(dto, plan);
  255. plan.HotspotId = dto.HotspotId;
  256. if (dto.Files != null && dto.Files.Count > 0)
  257. plan.FileJson = await _fileRepository.AddFileAsync(dto.Files, plan.Id, "", cancellationToken);
  258. else
  259. plan.FileJson = new List<Share.Dtos.File.FileJson>();
  260. await _planListRepository.UpdateNullAsync(plan, cancellationToken);
  261. if (dto.PlanType.Any())
  262. {
  263. var anyRelationTypes = await _planRelationTypeRepository.Queryable().Where(x => x.PlanId == plan.Id).ToListAsync();
  264. if (anyRelationTypes.Any())
  265. await _planRelationTypeRepository.RemoveRangeAsync(anyRelationTypes);
  266. List<PlanRelationType> types = _mapper.Map<List<PlanRelationType>>(dto.PlanType);
  267. types.ForEach(x => x.PlanId = dto.Id);
  268. await _planRelationTypeRepository.AddRangeAsync(types, cancellationToken);
  269. }
  270. }
  271. #endregion
  272. #region 预案库 - 下架审核
  273. /// <summary>
  274. /// 下架审核
  275. /// </summary>
  276. /// <param name="dto"></param>
  277. /// <param name="cancellationToken"></param>
  278. /// <returns></returns>
  279. public async Task AuditPlanAsync(UpdatePlanListDto dto, CancellationToken cancellationToken)
  280. {
  281. var plan = await _planListRepository.GetAsync(dto.Id);
  282. if (plan == null)
  283. throw UserFriendlyException.SameMessage("预案库查询失败");
  284. plan.Status = (EPlanStatus)dto.Status!;
  285. plan.ApplyStatus = (EPlanApplyStatus)dto.ApplyStatus!;
  286. plan.ExaminTime = dto.ExaminTime;
  287. plan.ExaminManId = dto.ExaminManId;
  288. plan.ExaminOrganizeId = dto.ExaminOrganizeId;
  289. plan.UpdateTime = dto.UpdateTime;
  290. await _planListRepository.UpdateNullAsync(plan, cancellationToken);
  291. }
  292. #endregion
  293. #region 预案库 - 详情
  294. /// <summary>
  295. /// 详情
  296. /// </summary>
  297. /// <param name="Id"></param>
  298. /// <param name="IsAddPv">默认不增加,false不增加,true增加浏览量</param>
  299. /// <returns></returns>
  300. public async Task<PlanInfoDto> GetPlanAsync(string Id, bool? IsAddPv, CancellationToken cancellationToken)
  301. {
  302. var plan = await _planListRepository.GetAsync(Id);
  303. if (plan == null)
  304. throw UserFriendlyException.SameMessage("预案库查询失败");
  305. ;
  306. //转化
  307. var planInfoDto = _mapper.Map<PlanInfoDto>(plan);
  308. if (plan != null && !string.IsNullOrEmpty(plan.Content))
  309. planInfoDto.Content = _bulletinApplication.GetSiteUrls(plan.Content);
  310. // 热点
  311. //var hot = await _hotspotTypeRepository.GetAsync(plan.HotspotId, cancellationToken);
  312. //if (hot != null)
  313. // planDto.HotspotId = hot.HotSpotFullName;
  314. if (planInfoDto.FileJson != null && planInfoDto.FileJson.Any())
  315. {
  316. var ids = planInfoDto.FileJson.Select(x => x.Id).ToList();
  317. planInfoDto.Files = await _fileRepository.GetFilesAsync(ids, cancellationToken);
  318. }
  319. // 更新浏览量
  320. if (IsAddPv == true)
  321. {
  322. //修改浏览量
  323. plan.PageView++;
  324. //修改点击量
  325. await _planListRepository.UpdateAsync(plan, cancellationToken);
  326. }
  327. return planInfoDto;
  328. }
  329. #endregion
  330. #region 预案库 - 批量导出
  331. /// <summary>
  332. /// 预案库 - 批量导出
  333. /// </summary>
  334. /// <param name="dto"></param>
  335. /// <param name="cancellationToken"></param>
  336. /// <returns></returns>
  337. public async Task<Dictionary<string, Stream>> PlanInfoListExportAsync(PlanInfoExportDto dto, CancellationToken cancellationToken)
  338. {
  339. var streamList = new Dictionary<string, Stream>();
  340. var knowList = await _planListRepository.Queryable()
  341. .Where(m => dto.Ids.Contains(m.Id))
  342. .Select(m => new { m.Title, m.Content })
  343. .ToListAsync(cancellationToken);
  344. var tasks = knowList.Select(async item =>
  345. {
  346. var stream = await Task.Run(() => item.Content.HtmlToStream(dto.FileType), cancellationToken);
  347. return new KeyValuePair<string, Stream>(
  348. item.Title + dto.FileType.GetFileExtension(),
  349. stream
  350. );
  351. });
  352. var results = await Task.WhenAll(tasks);
  353. foreach (var kvp in results)
  354. {
  355. if (!streamList.ContainsKey(kvp.Key))
  356. {
  357. streamList.Add(kvp.Key, kvp.Value);
  358. }
  359. }
  360. return streamList;
  361. }
  362. #endregion
  363. #endregion
  364. #region 私有方法
  365. #region 查询所有子级
  366. /// <summary>
  367. /// 查询所有子级
  368. /// </summary>
  369. /// <param name="treeDatas">分类数据</param>
  370. /// <param name="ID">需要查询哪级下面的分类</param>
  371. /// <param name="checkId">选中的数据ID</param>
  372. /// <returns></returns>
  373. private List<TreeListDto> GetChildren(List<PlanType> treeDatas, string ID, string? checkId)
  374. {
  375. List<TreeListDto> nodeList = new();
  376. //根据ID查询子级
  377. var children = treeDatas.Where(q => q.ParentId == ID);
  378. foreach (var dr in children)
  379. {
  380. //组装数据
  381. TreeListDto node = new()
  382. {
  383. name = dr.Name,
  384. ParentID = dr.ParentId,
  385. value = dr.Id,
  386. IsEnable = dr.IsEnable
  387. };
  388. //是否选中
  389. if (!string.IsNullOrEmpty(checkId) && checkId != Guid.Empty.ToString() && checkId == dr.Id)
  390. node.selected = true;
  391. //子级数据赋值
  392. node.children = GetChildren(treeDatas, node.value, checkId);
  393. //添加数据
  394. nodeList.Add(node);
  395. }
  396. return nodeList;
  397. }
  398. #endregion
  399. #region 获取全称
  400. /// <summary>
  401. /// 获取全称
  402. /// </summary>
  403. /// <param name="Id"></param>
  404. /// <returns></returns>
  405. private async Task<string> GetFullName(string? Id)
  406. {
  407. //获取全部父级名称
  408. var list = await GetParentNode(Id);
  409. //倒叙
  410. list.Reverse();
  411. //拆分
  412. return string.Join("-", list.ToArray());
  413. }
  414. /// <summary>
  415. /// 查询父级名称
  416. /// </summary>
  417. /// <param name="Id"></param>
  418. /// <returns></returns>
  419. private async Task<List<string>> GetParentNode(string? Id)
  420. {
  421. List<string> list = new();
  422. //查询父级数据
  423. var type = await _planTypeRepository.GetAsync(p => p.Id == Id);
  424. if (type != null)
  425. {
  426. //添加名称
  427. list.Add(type.Name);
  428. list.AddRange(await GetParentNode(type.ParentId));
  429. }
  430. return list;
  431. }
  432. #endregion
  433. #region 修改子级分类全称
  434. /// <summary>
  435. /// 修改子级分类全称
  436. /// </summary>
  437. /// <param name="Id"></param>
  438. /// <returns></returns>
  439. private async Task UpdateChildNode(string Id)
  440. {
  441. //查询子分类
  442. var list = await GetChildNode(Id);
  443. if (list is not null && list.Count > 0)
  444. {
  445. foreach (var item in list)
  446. {
  447. //获取全称
  448. string FullName = await GetFullName(item.ParentId);
  449. item.SpliceName = string.IsNullOrEmpty(FullName) ? item.Name : FullName + "-" + item.Name;
  450. //修改全称
  451. await _planTypeRepository.UpdateAsync(item);
  452. }
  453. }
  454. }
  455. /// <summary>
  456. /// 查询子级节点数据
  457. /// </summary>
  458. /// <param name="Id"></param>
  459. /// <returns></returns>
  460. private async Task<List<PlanType>> GetChildNode(string Id)
  461. {
  462. List<PlanType> list = new();
  463. //查询数据
  464. var typelist = await _planTypeRepository.QueryAsync(p => p.ParentId == Id);
  465. if (typelist != null)
  466. {
  467. //处理数据
  468. foreach (var item in typelist)
  469. {
  470. list.Add(item);
  471. list.AddRange(await GetChildNode(item.Id));
  472. }
  473. }
  474. return list;
  475. }
  476. #endregion
  477. #endregion
  478. }
  479. }