|
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|
|
using TEAMModelOS.Model.Syllabus.Dtos;
|
|
|
using TEAMModelOS.Model.Syllabus.Models;
|
|
|
using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
|
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
|
using TEAMModelOS.Service.Core.Implements;
|
|
|
using TEAMModelOS.Service.Syllabus.Interfaces;
|
|
|
|
|
@@ -27,14 +28,14 @@ namespace TEAMModelOS.Service.Syllabus.Implements
|
|
|
return points.OrderBy(x => x.Order).ToList();
|
|
|
}
|
|
|
|
|
|
- public async Task<List<KnowledgePoint>> FindKnowledgeBlockAndPointByDict(KnowledgeDto knowledgePoint) {
|
|
|
+ public async Task<List<BlockPointDto>> FindKnowledgeBlockAndPointByDict(KnowledgeDto knowledgePoint) {
|
|
|
List<KnowledgeBlock> blocks = await FindListByDict<KnowledgeBlock>(knowledgePoint.PointParams);
|
|
|
List<KnowledgeBlockPoint> blockPoints = await FindListByDict<KnowledgeBlockPoint>(knowledgePoint.PointParams);
|
|
|
- HashSet<KnowledgeBlock> knowledges = new HashSet<KnowledgeBlock>();
|
|
|
- HashSet<KnowledgeBlockPoint> knowledgeBlocks = new HashSet<KnowledgeBlockPoint>();
|
|
|
+
|
|
|
if (knowledgePoint.Periods.IsNotEmpty())
|
|
|
{
|
|
|
-
|
|
|
+ HashSet<KnowledgeBlock> knowledges = new HashSet<KnowledgeBlock>();
|
|
|
+ HashSet<KnowledgeBlockPoint> knowledgeBlocks = new HashSet<KnowledgeBlockPoint>();
|
|
|
foreach (string period in knowledgePoint.Periods)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(period))
|
|
@@ -43,10 +44,53 @@ namespace TEAMModelOS.Service.Syllabus.Implements
|
|
|
knowledgeBlocks.UnionWith(blockPoints.Where(x => x.AdvicePeriodCode.Contains(period)).ToHashSet());
|
|
|
}
|
|
|
}
|
|
|
- //knowledges.OrderBy(x => x.Order).ToList();
|
|
|
- // knowledgeBlocks.OrderBy(x => x.Order).ToList();
|
|
|
+ blocks= knowledges.OrderBy(x => x.Order).ToList();
|
|
|
+ blockPoints= knowledgeBlocks.OrderBy(x => x.Order).ToList();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return ListToTree(blocks, blockPoints);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<BlockPointDto> ListToTree(List<KnowledgeBlock> blocks ,List<KnowledgeBlockPoint> points)
|
|
|
+ {
|
|
|
+ List<PointDto> pointList = MessagePackHelper.JsonToObject<List<PointDto>>(MessagePackHelper.ObjectToJson(points));
|
|
|
+ List<BlockPointDto> blockList = MessagePackHelper.JsonToObject<List<BlockPointDto>>(MessagePackHelper.ObjectToJson(blocks));
|
|
|
+ Dictionary<string, List<PointDto>> pointDict = new Dictionary<string, List<PointDto>>();
|
|
|
+ List<string> keys = (pointList.GroupBy(c => c.BlockId).Select(group => group.Key)).ToList();
|
|
|
+ foreach (string key in keys) {
|
|
|
+ pointDict.Add(key, pointList.Where(x => x.BlockId.Equals(key)).ToList());
|
|
|
+ }
|
|
|
+ var blockDict = blockList.ToDictionary(n => n.RowKey, n => n);
|
|
|
+ return GetChild(blockList, blockDict , pointDict);
|
|
|
+ }
|
|
|
+ public List<BlockPointDto> GetChild(List<BlockPointDto> list, Dictionary<string, BlockPointDto> blockDict, Dictionary<string, List<PointDto>> pointDict)
|
|
|
+ {
|
|
|
+ List<PointDto> empt = new List<PointDto>();
|
|
|
+ list = list.OrderBy(m => m.Order).ToList();
|
|
|
+ List<BlockPointDto> trees = new List<BlockPointDto>();
|
|
|
+ foreach (BlockPointDto node in list)
|
|
|
+ {
|
|
|
+ bool fl= pointDict.TryGetValue(node.RowKey,out List<PointDto> points);
|
|
|
+ if (fl && points.IsNotEmpty())
|
|
|
+ {
|
|
|
+ node.Points = points;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ node.Points = empt;
|
|
|
+ }
|
|
|
+ bool flag = blockDict.TryGetValue(node.Pid, out BlockPointDto syllabus);
|
|
|
+ if (flag && syllabus != null)
|
|
|
+ {
|
|
|
+ syllabus.Children.Add(node);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ trees.Add(node);
|
|
|
+ }
|
|
|
}
|
|
|
- return null;
|
|
|
+ return trees.OrderBy(x=>x.Order).ToList();
|
|
|
}
|
|
|
}
|
|
|
}
|