|
@@ -2,6 +2,8 @@ using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using TEAMModelOS.SDK;
|
|
|
|
+using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Models;
|
|
using TEAMModelOS.SDK.Models;
|
|
|
|
|
|
namespace TEAMModelOS.Services.Common
|
|
namespace TEAMModelOS.Services.Common
|
|
@@ -21,7 +23,7 @@ namespace TEAMModelOS.Services.Common
|
|
{
|
|
{
|
|
string newKey = $"{newItem.subjectId}";
|
|
string newKey = $"{newItem.subjectId}";
|
|
List<string> grade = newItem.gradeIds;
|
|
List<string> grade = newItem.gradeIds;
|
|
- UpdateItemCond(cond, true, newKey, grade, newItem.type, newItem.level, newItem.field.HasValue ? newItem.field.Value : 0);
|
|
|
|
|
|
+ UpdateItemCond(cond, true, newKey, grade, newItem.type, newItem.level, newItem.field.HasValue ? newItem.field.Value : 0, newItem);
|
|
}
|
|
}
|
|
else if (newItem != null && odlItem != null)
|
|
else if (newItem != null && odlItem != null)
|
|
{
|
|
{
|
|
@@ -31,18 +33,18 @@ namespace TEAMModelOS.Services.Common
|
|
//先增加
|
|
//先增加
|
|
string newKey = $"{newItem.subjectId}";
|
|
string newKey = $"{newItem.subjectId}";
|
|
List<string> newGrade = newItem.gradeIds;
|
|
List<string> newGrade = newItem.gradeIds;
|
|
- UpdateItemCond(cond, true, newKey, newGrade, newItem.type, newItem.level, newItem.field.HasValue ? newItem.field.Value : 0);
|
|
|
|
|
|
+ UpdateItemCond(cond, true, newKey, newGrade, newItem.type, newItem.level, newItem.field.HasValue ? newItem.field.Value : 0, newItem);
|
|
//后变更删除
|
|
//后变更删除
|
|
string oldKey = $"{odlItem.subjectId}";
|
|
string oldKey = $"{odlItem.subjectId}";
|
|
List<string> oldGrade = odlItem.gradeIds;
|
|
List<string> oldGrade = odlItem.gradeIds;
|
|
- UpdateItemCond(cond, false, oldKey, oldGrade, odlItem.type, odlItem.level, odlItem.field.HasValue ? odlItem.field.Value : 0);
|
|
|
|
|
|
+ UpdateItemCond(cond, false, oldKey, oldGrade, odlItem.type, odlItem.level, odlItem.field.HasValue ? odlItem.field.Value : 0, newItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (newItem == null && odlItem != null)
|
|
else if (newItem == null && odlItem != null)
|
|
{
|
|
{
|
|
string oldKey = $"{odlItem.subjectId}";
|
|
string oldKey = $"{odlItem.subjectId}";
|
|
List<string> oldGrade = odlItem.gradeIds;
|
|
List<string> oldGrade = odlItem.gradeIds;
|
|
- UpdateItemCond(cond, false, oldKey, oldGrade, odlItem.type, odlItem.level, odlItem.field.HasValue ? odlItem.field.Value : 0);
|
|
|
|
|
|
+ UpdateItemCond(cond, false, oldKey, oldGrade, odlItem.type, odlItem.level, odlItem.field.HasValue ? odlItem.field.Value : 0,null);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -56,8 +58,9 @@ namespace TEAMModelOS.Services.Common
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="cond"></param>
|
|
/// <param name="cond"></param>
|
|
/// <param name="opt"></param>
|
|
/// <param name="opt"></param>
|
|
- public static void UpdateItemCond(ItemCond cond, bool opt, string key, List<string> grade, string type, int level, int field)
|
|
|
|
|
|
+ public static void UpdateItemCond(ItemCond cond, bool opt, string key, List<string> grade, string type, int level, int field,ItemInfo newItem)
|
|
{
|
|
{
|
|
|
|
+
|
|
int count = 0;
|
|
int count = 0;
|
|
if (opt)
|
|
if (opt)
|
|
{
|
|
{
|
|
@@ -68,10 +71,15 @@ namespace TEAMModelOS.Services.Common
|
|
//未计入的则默认0
|
|
//未计入的则默认0
|
|
count = -1;
|
|
count = -1;
|
|
}
|
|
}
|
|
- grade.ForEach(x => {
|
|
|
|
|
|
+ foreach (var x in grade) {
|
|
bool none = true;
|
|
bool none = true;
|
|
|
|
+ if (x == null)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
for (int index = 0; index < cond.grades.Count; index++)
|
|
for (int index = 0; index < cond.grades.Count; index++)
|
|
{
|
|
{
|
|
|
|
+
|
|
if (x == cond.grades[index].id)
|
|
if (x == cond.grades[index].id)
|
|
{
|
|
{
|
|
cond.grades[index].count = cond.grades[index].count + count;
|
|
cond.grades[index].count = cond.grades[index].count + count;
|
|
@@ -81,17 +89,19 @@ namespace TEAMModelOS.Services.Common
|
|
}
|
|
}
|
|
if (none)
|
|
if (none)
|
|
{
|
|
{
|
|
|
|
+ if (x == null) {
|
|
|
|
+ Console.WriteLine(newItem.ToJsonString());
|
|
|
|
+ }
|
|
cond.grades.Add(new GradeCount { id = x, count = count });
|
|
cond.grades.Add(new GradeCount { id = x, count = count });
|
|
}
|
|
}
|
|
- });
|
|
|
|
-
|
|
|
|
- SubjectCount subject = cond.subjects.Where(x => x.id == key).FirstOrDefault();
|
|
|
|
|
|
+ }
|
|
|
|
+ SubjectCount subject = cond.subjects.Find(x => x.id == key);
|
|
if (subject == null)
|
|
if (subject == null)
|
|
{
|
|
{
|
|
- cond.subjects.Add(new SubjectCount() { id=key});
|
|
|
|
|
|
+ cond.subjects.Add(new SubjectCount() { id=key, count =0});
|
|
}
|
|
}
|
|
- cond.subjects.Where(x => x.id == key).ToList().ForEach(y => {
|
|
|
|
-
|
|
|
|
|
|
+ var list = cond.subjects.FindAll(x => x.id == key).ToList();
|
|
|
|
+ foreach (var y in list) {
|
|
if (!y.types.ContainsKey(type))
|
|
if (!y.types.ContainsKey(type))
|
|
{
|
|
{
|
|
var dict = new Dictionary<string, Dictionary<string, int>>
|
|
var dict = new Dictionary<string, Dictionary<string, int>>
|
|
@@ -116,10 +126,11 @@ namespace TEAMModelOS.Services.Common
|
|
else
|
|
else
|
|
{
|
|
{
|
|
y.types[type]["level"][$"{level}"] = y.types[type]["level"][$"{level}"] + count;
|
|
y.types[type]["level"][$"{level}"] = y.types[type]["level"][$"{level}"] + count;
|
|
- y.types[type]["field"][$"{level}"] = y.types[type]["field"][$"{field}"] + count;
|
|
|
|
|
|
+
|
|
|
|
+ y.types[type]["field"][$"{field}"] = y.types[type]["field"][$"{field}"] + count;
|
|
}
|
|
}
|
|
y.count = y.count + count;
|
|
y.count = y.count + count;
|
|
- });
|
|
|
|
|
|
+ }
|
|
cond.count = cond.subjects.Select(x => x.count).Sum();
|
|
cond.count = cond.subjects.Select(x => x.count).Sum();
|
|
}
|
|
}
|
|
}
|
|
}
|