|
@@ -6,6 +6,9 @@ import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.google.gson.Gson;
|
|
@@ -74,6 +77,7 @@ import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -1222,7 +1226,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
return dates;
|
|
|
}
|
|
|
|
|
|
- String calculateClassTime(JsonArray allClassTimeDataArray, Map<String, Double> weightSetMap, List<LocalDate> allDateList, List<String> CourseTimeTypeSet){
|
|
|
+ String calculateClassTime(JsonArray allClassTimeDataArray, Map<String, Double> weightSetMap, List<LocalDate> allDateList, List<String> CourseTimeTypeSet) throws JsonProcessingException {
|
|
|
JsonObject result = new JsonObject();
|
|
|
//计算纵向的合计
|
|
|
Double allClassTime = 0d;
|
|
@@ -1306,7 +1310,25 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
result.add("columnTitle", columnTitle);
|
|
|
|
|
|
result.add("data", allClassTimeDataArray);
|
|
|
- result.addProperty("allClassTime", allClassTime);
|
|
|
+
|
|
|
+
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ JsonNode rootNode = objectMapper.readTree(columnTitle.toString());
|
|
|
+ double sum = 0;
|
|
|
+
|
|
|
+ // 遍历 JSON 数组中的每一个元素
|
|
|
+ Iterator<JsonNode> elements = rootNode.elements();
|
|
|
+ while (elements.hasNext()) {
|
|
|
+ JsonNode element = elements.next();
|
|
|
+
|
|
|
+ // 获取 "value" 键对应的数值,并累加到总和中
|
|
|
+ if (element.has("content") && element.get("content").isNumber()) {
|
|
|
+ sum += element.get("content").asDouble();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ result.addProperty("allClassTime", sum);
|
|
|
return result.toString();
|
|
|
}
|
|
|
|