|
|
@@ -12,6 +12,7 @@ import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.common.enums.CourseAdjustTypeEnum;
|
|
|
import com.xjrsoft.common.enums.CourseTimeTypeEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
import com.xjrsoft.module.classtime.dto.AddClassTimeStatisticsDto;
|
|
|
import com.xjrsoft.module.classtime.entity.ClassTimeDelete;
|
|
|
import com.xjrsoft.module.classtime.entity.ClassTimeStatistics;
|
|
|
@@ -42,11 +43,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
@@ -174,9 +175,11 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
}
|
|
|
//计算出这个时间段内一共多少周
|
|
|
List<WeekTimeRangeVo> weekTimeRangeVos = calculateNaturalWeeks(statistics.getStartDate(), statistics.getEndDate());
|
|
|
-
|
|
|
+ //取出所有的日期
|
|
|
+ List<LocalDate> allDateList = getDatesBetween(statistics.getStartDate(), statistics.getEndDate());
|
|
|
//查询课程数据,排除开节假日的数据
|
|
|
List<CourseListVo> allCourseList = this.baseMapper.getCourseList(statistics);
|
|
|
+ allCourseList.addAll(this.baseMapper.getHolidayReplaceCourseList(statistics));
|
|
|
|
|
|
//查询删除课时的数据,将每个班删除的具体日期统计出来
|
|
|
List<ClassTimeDelete> deleteList = deleteService.list(
|
|
|
@@ -199,7 +202,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
}
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
- //查询所有老师发起顶课通过的数量(只查询事假、病假),也要分别计算早自习、晚自习、正课、如果日期出入课时删除中,也需要跳过
|
|
|
+ //查询所有老师发起顶课通过的数量,也要分别计算早自习、晚自习、正课、如果日期出入课时删除中,也需要跳过
|
|
|
List<CourseListVo> allSubstituteList = this.baseMapper.getSubstituteList(statistics);
|
|
|
List<ClassTimeStatisticsRecord> insertList = new ArrayList<>();
|
|
|
//循环教师,准备开始计算
|
|
|
@@ -221,20 +224,86 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
allClassTime = allClassTime + sum;
|
|
|
if(CourseTimeTypeEnum.CTT001.getCode().equals(courseTimeType)){
|
|
|
record.setClassTime1(sum);
|
|
|
+ for (LocalDate localDate : allDateList) {
|
|
|
+ double sum1 = courseTimes.stream()
|
|
|
+ .filter(x -> x.getTeacherIds().contains(teacher.getId().toString()) && localDate.equals(x.getScheduleDate()))
|
|
|
+ .mapToDouble(WfTeacherCourseTime::getCourseTime).sum();
|
|
|
+ JsonObject courseJson = new JsonObject();
|
|
|
+ courseJson.addProperty("type", CourseTimeTypeEnum.CTT001.getValue());
|
|
|
+ courseJson.addProperty("scheduleDate", localDate.format(formatter));
|
|
|
+ courseJson.addProperty("content", sum1);
|
|
|
+ courseJson.addProperty("adjustType", "");
|
|
|
+ allClassTimeDataArray.add(courseJson);
|
|
|
+ }
|
|
|
}else if(CourseTimeTypeEnum.CTT002.getCode().equals(courseTimeType)){
|
|
|
record.setClassTime2(sum);
|
|
|
+ for (LocalDate localDate : allDateList) {
|
|
|
+ double sum1 = courseTimes.stream()
|
|
|
+ .filter(x -> x.getTeacherIds().contains(teacher.getId().toString()) && localDate.equals(x.getScheduleDate()))
|
|
|
+ .mapToDouble(WfTeacherCourseTime::getCourseTime).sum();
|
|
|
+ JsonObject courseJson = new JsonObject();
|
|
|
+ courseJson.addProperty("type", CourseTimeTypeEnum.CTT001.getValue());
|
|
|
+ courseJson.addProperty("scheduleDate", localDate.format(formatter));
|
|
|
+ courseJson.addProperty("content", sum1);
|
|
|
+ courseJson.addProperty("adjustType", "");
|
|
|
+ allClassTimeDataArray.add(courseJson);
|
|
|
+ }
|
|
|
}else if(CourseTimeTypeEnum.CTT003.getCode().equals(courseTimeType)){
|
|
|
record.setClassTime3(sum);
|
|
|
+ for (LocalDate localDate : allDateList) {
|
|
|
+ double sum1 = courseTimes.stream()
|
|
|
+ .filter(x -> x.getTeacherIds().contains(teacher.getId().toString()) && localDate.equals(x.getScheduleDate()))
|
|
|
+ .mapToDouble(WfTeacherCourseTime::getCourseTime).sum();
|
|
|
+ JsonObject courseJson = new JsonObject();
|
|
|
+ courseJson.addProperty("type", CourseTimeTypeEnum.CTT001.getValue());
|
|
|
+ courseJson.addProperty("scheduleDate", localDate.format(formatter));
|
|
|
+ courseJson.addProperty("content", sum1);
|
|
|
+ courseJson.addProperty("adjustType", "");
|
|
|
+ allClassTimeDataArray.add(courseJson);
|
|
|
+ }
|
|
|
}else if(CourseTimeTypeEnum.CTT004.getCode().equals(courseTimeType)){
|
|
|
record.setClassTime4(sum);
|
|
|
+ for (LocalDate localDate : allDateList) {
|
|
|
+ double sum1 = courseTimes.stream()
|
|
|
+ .filter(x -> x.getTeacherIds().contains(teacher.getId().toString()) && localDate.equals(x.getScheduleDate()))
|
|
|
+ .mapToDouble(WfTeacherCourseTime::getCourseTime).sum();
|
|
|
+ JsonObject courseJson = new JsonObject();
|
|
|
+ courseJson.addProperty("type", CourseTimeTypeEnum.CTT001.getValue());
|
|
|
+ courseJson.addProperty("scheduleDate", localDate.format(formatter));
|
|
|
+ courseJson.addProperty("content", sum1);
|
|
|
+ courseJson.addProperty("adjustType", "");
|
|
|
+ allClassTimeDataArray.add(courseJson);
|
|
|
+ }
|
|
|
}else if(CourseTimeTypeEnum.CTT005.getCode().equals(courseTimeType)){
|
|
|
record.setClassTime5(sum);
|
|
|
+ for (LocalDate localDate : allDateList) {
|
|
|
+ double sum1 = courseTimes.stream()
|
|
|
+ .filter(x -> x.getTeacherIds().contains(teacher.getId().toString()) && localDate.equals(x.getScheduleDate()))
|
|
|
+ .mapToDouble(WfTeacherCourseTime::getCourseTime).sum();
|
|
|
+ JsonObject courseJson = new JsonObject();
|
|
|
+ courseJson.addProperty("type", CourseTimeTypeEnum.CTT001.getValue());
|
|
|
+ courseJson.addProperty("scheduleDate", localDate.format(formatter));
|
|
|
+ courseJson.addProperty("content", sum1);
|
|
|
+ courseJson.addProperty("adjustType", "");
|
|
|
+ allClassTimeDataArray.add(courseJson);
|
|
|
+ }
|
|
|
}else if(CourseTimeTypeEnum.CTT006.getCode().equals(courseTimeType)){
|
|
|
record.setClassTime6(sum);
|
|
|
+ for (LocalDate localDate : allDateList) {
|
|
|
+ double sum1 = courseTimes.stream()
|
|
|
+ .filter(x -> x.getTeacherIds().contains(teacher.getId().toString()) && localDate.equals(x.getScheduleDate()))
|
|
|
+ .mapToDouble(WfTeacherCourseTime::getCourseTime).sum();
|
|
|
+ JsonObject courseJson = new JsonObject();
|
|
|
+ courseJson.addProperty("type", CourseTimeTypeEnum.CTT001.getValue());
|
|
|
+ courseJson.addProperty("scheduleDate", localDate.format(formatter));
|
|
|
+ courseJson.addProperty("content", sum1);
|
|
|
+ courseJson.addProperty("adjustType", "");
|
|
|
+ allClassTimeDataArray.add(courseJson);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//早自习、正课、晚辅、顶课、调课
|
|
|
- Double classTime7 = 0D,classTime8 = 0D,classTime9 = 0D,classTime10 = 0D,classTime11 = 0D;
|
|
|
+ Double classTime7 = 0D,classTime8 = 0D,classTime9 = 0D,classTime11 = 0D;
|
|
|
|
|
|
List<String> zkList = Arrays.asList("上1","上2","上3","上4","下1","下2","下3","下4");
|
|
|
List<String> wzxList = Arrays.asList("晚1","晚2","晚3");
|
|
|
@@ -247,7 +316,13 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
for (CourseListVo courseListVo : courseList) {
|
|
|
//如果这个课程数据包含在被删除的课时中,跳过不计算
|
|
|
Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
|
+ JsonObject courseJson = new JsonObject();
|
|
|
if(deleteDates != null && deleteDates.contains(courseListVo.getScheduleDate())){
|
|
|
+ courseJson.addProperty("type", courseListVo.getShortName());
|
|
|
+ courseJson.addProperty("scheduleDate", courseListVo.getScheduleDate().format(formatter));
|
|
|
+ courseJson.addProperty("content", "");
|
|
|
+ courseJson.addProperty("adjustType", "course_delete");
|
|
|
+ allClassTimeDataArray.add(courseJson);
|
|
|
continue;
|
|
|
}
|
|
|
if("早自习".equals(courseListVo.getShortName())){
|
|
|
@@ -263,11 +338,10 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
classTime11 += weightSetMap.get(courseListVo.getShortName());
|
|
|
}
|
|
|
}
|
|
|
- JsonObject courseJson = new JsonObject();
|
|
|
courseJson.addProperty("type", courseListVo.getShortName());
|
|
|
courseJson.addProperty("scheduleDate", courseListVo.getScheduleDate().format(formatter));
|
|
|
courseJson.addProperty("content", courseListVo.getClassName() + "," + courseListVo.getCourseName());
|
|
|
- courseJson.addProperty("adjustType", courseListVo.getAdjustType());
|
|
|
+ courseJson.addProperty("adjustType", courseListVo.getAdjustType() == null?"":courseListVo.getAdjustType());
|
|
|
allClassTimeDataArray.add(courseJson);
|
|
|
}
|
|
|
record.setClassTime7(classTime7);
|
|
|
@@ -330,30 +404,6 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
weekDataJson.add("weekData", new Gson().toJsonTree(weekTimeRangeVos));
|
|
|
weekDataJson.addProperty("allTimes", allTimes);
|
|
|
record.setWeekData(weekDataJson.toString());
|
|
|
-
|
|
|
- //计算该老师发起的事假、病假顶课数据
|
|
|
- List<CourseListVo> substituteList = allSubstituteList.stream().filter(x -> x.getExchangeTeacherId().equals(teacher.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- Double reduceTime = 0d;
|
|
|
- for (CourseListVo courseListVo : substituteList) {
|
|
|
- Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
|
- if(deleteDates !=null && deleteDates.contains(courseListVo.getScheduleDate())){
|
|
|
- continue;
|
|
|
- }
|
|
|
- reduceTime += weightSetMap.get(courseListVo.getShortName());
|
|
|
- }
|
|
|
-
|
|
|
- substituteList = allSubstituteList.stream().filter(x -> x.getTeacherId().equals(teacher.getId().toString()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- for (CourseListVo courseListVo : substituteList) {
|
|
|
- Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
|
- if(deleteDates !=null && deleteDates.contains(courseListVo.getScheduleDate())){
|
|
|
- continue;
|
|
|
- }
|
|
|
- reduceTime = reduceTime - weightSetMap.get(courseListVo.getShortName());
|
|
|
- }
|
|
|
-
|
|
|
- record.setClassTime10(reduceTime);
|
|
|
//计算总课时
|
|
|
allClassTime = allClassTime + classTime7 + classTime8 + classTime9;
|
|
|
record.setAllClassTime(allClassTime);
|
|
|
@@ -394,29 +444,61 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
wzxCost = BigDecimal.valueOf(costSetMap.get("cost6"));
|
|
|
}
|
|
|
classTimeAmount += BigDecimal.valueOf(classTime9).multiply(wzxCost).doubleValue();
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 顶课:
|
|
|
+ * 1、流程发起人(被顶老师)的课被顶课老师上了,那么被顶老师的课时就会-1,顶课老师课时就会+1
|
|
|
+ * 2、顶课老师会根据规则额外加一笔费用,根据设置1课时额外加4元
|
|
|
+ * 3、顶课类型为事假和病假的时候会扣除被顶老师的费用,根据设置为扣除4元
|
|
|
+ */
|
|
|
BigDecimal reduceTimeAmount = BigDecimal.ZERO;
|
|
|
- BigDecimal dkCost = BigDecimal.ZERO;//顶课费用,顶课老师加钱
|
|
|
- if("FB1601".equals(teacher.getEmployType())){
|
|
|
- dkCost = BigDecimal.valueOf(costSetMap.get("cost11"));
|
|
|
- }else{//外聘FB1605、合作人员FB1609
|
|
|
- dkCost = BigDecimal.valueOf(costSetMap.get("cost12"));
|
|
|
- }
|
|
|
- if(record.getClassTime10() != null && record.getClassTime10() > 0){
|
|
|
- reduceTimeAmount = BigDecimal.valueOf(record.getClassTime10()).multiply(dkCost);
|
|
|
- }
|
|
|
+ {
|
|
|
+ //计算该老师发起的事假、病假顶课数据
|
|
|
+ List<CourseListVo> substituteList = allSubstituteList.stream().filter(x -> x.getExchangeTeacherId().equals(teacher.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Double reduceTime = 0d;//顶课课时
|
|
|
+ Double dkClassTime = 0d;//去顶课的数量,所有顶课数量
|
|
|
+ for (CourseListVo courseListVo : substituteList) {
|
|
|
+ Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
|
+ if(deleteDates !=null && deleteDates.contains(courseListVo.getScheduleDate())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ reduceTime += weightSetMap.get(courseListVo.getShortName());
|
|
|
+ dkClassTime += weightSetMap.get(courseListVo.getShortName());
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- BigDecimal bdkCost = BigDecimal.ZERO;//顶课费用,被顶课老师扣钱
|
|
|
- if("FB1601".equals(teacher.getEmployType())){
|
|
|
- bdkCost = BigDecimal.valueOf(costSetMap.get("cost13")==null?0:costSetMap.get("cost13"));
|
|
|
- }else{//外聘FB1605、合作人员FB1609
|
|
|
- bdkCost = BigDecimal.valueOf(costSetMap.get("cost14")==null?0:costSetMap.get("cost14"));
|
|
|
- }
|
|
|
- //计算被扣除的费用
|
|
|
- if(record.getClassTime10() != null && record.getClassTime10() < 0){
|
|
|
- reduceTimeAmount = bdkCost.multiply(BigDecimal.valueOf(record.getClassTime10()));
|
|
|
+ Double bdkClassTime = 0d;//发起顶课的数量,只统计事假和病假的数量
|
|
|
+ substituteList = allSubstituteList.stream().filter(x -> x.getTeacherId().equals(teacher.getId().toString()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (CourseListVo courseListVo : substituteList) {
|
|
|
+ Set<LocalDate> deleteDates = deleteMap.get(courseListVo.getClassId());
|
|
|
+ if(deleteDates !=null && deleteDates.contains(courseListVo.getScheduleDate())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ reduceTime = reduceTime - weightSetMap.get(courseListVo.getShortName());
|
|
|
+ if("sick_leave".equals(courseListVo.getReason()) || "leave_absence".equals(courseListVo.getReason())){
|
|
|
+ bdkClassTime += weightSetMap.get(courseListVo.getShortName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setClassTime10(reduceTime);
|
|
|
+
|
|
|
+ BigDecimal dkCost = BigDecimal.ZERO;//顶课费用,顶课老师加钱
|
|
|
+ if("FB1601".equals(teacher.getEmployType())){
|
|
|
+ dkCost = BigDecimal.valueOf(costSetMap.get("cost11"));
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
+ dkCost = BigDecimal.valueOf(costSetMap.get("cost12"));
|
|
|
+ }
|
|
|
+ reduceTimeAmount = BigDecimal.valueOf(dkClassTime).multiply(dkCost);
|
|
|
+ BigDecimal bdkCost = BigDecimal.ZERO;//顶课费用,被顶课老师扣钱
|
|
|
+ if("FB1601".equals(teacher.getEmployType())){
|
|
|
+ bdkCost = BigDecimal.valueOf(costSetMap.get("cost13")==null?0:costSetMap.get("cost13"));
|
|
|
+ }else{//外聘FB1605、合作人员FB1609
|
|
|
+ bdkCost = BigDecimal.valueOf(costSetMap.get("cost14")==null?0:costSetMap.get("cost14"));
|
|
|
+ }
|
|
|
+ //计算被扣除的费用
|
|
|
+ reduceTimeAmount = reduceTimeAmount.subtract(bdkCost.multiply(BigDecimal.valueOf(bdkClassTime)));
|
|
|
}
|
|
|
+
|
|
|
record.setClassTimeAmount(classTimeAmount);
|
|
|
//计算超出的课时,需要先计算出每个周的开始结束时间
|
|
|
BigDecimal ccksCost = BigDecimal.ZERO;
|
|
|
@@ -434,21 +516,20 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
//计算总金额,课时费+超课时费
|
|
|
Double totalAmount = classTimeAmount + beyondClassTimeAmount + reduceTimeAmount.doubleValue();
|
|
|
record.setTotalAmount(totalAmount);
|
|
|
+ record.setAllClassTimeData(calculateClassTime(allClassTimeDataArray, weightSetMap, allDateList));
|
|
|
+ record.setCreateDate(new Date());
|
|
|
|
|
|
insertList.add(record);
|
|
|
}
|
|
|
|
|
|
if(!insertList.isEmpty()){
|
|
|
//先删除
|
|
|
- recordMapper.delete(
|
|
|
- new QueryWrapper<ClassTimeStatisticsRecord>().lambda()
|
|
|
- .eq(ClassTimeStatisticsRecord::getClassTimeStatisticsId, statistics.getId())
|
|
|
- );
|
|
|
+ String sql = "delete from class_time_statistics_record where class_time_statistics_id = " + statistics.getId();
|
|
|
+ SqlRunnerAdapter.db().delete(sql);
|
|
|
for (ClassTimeStatisticsRecord record : insertList) {
|
|
|
recordMapper.insert(record);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
statistics.setAllClassTime(insertList.stream().filter(x -> x.getAllClassTime() != null).mapToDouble(ClassTimeStatisticsRecord::getAllClassTime).sum());
|
|
|
statistics.setTotalAmount(insertList.stream().filter(x -> x.getTotalAmount() != null).mapToDouble(ClassTimeStatisticsRecord::getTotalAmount).sum());
|
|
|
statistics.setBeyondClassTimeAmount(insertList.stream().filter(x -> x.getBeyondClassTimeAmount() != null).mapToDouble(ClassTimeStatisticsRecord::getBeyondClassTimeAmount).sum());
|
|
|
@@ -479,7 +560,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public byte[] recordExport(Long id) throws IOException {
|
|
|
+ public byte[] recordExport(Long id) {
|
|
|
try {
|
|
|
//1、查询数据
|
|
|
List<ClassTimeStatisticsRecordVo> recordList = this.baseMapper.getRecordList(id);
|
|
|
@@ -849,4 +930,110 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 取出所有日期
|
|
|
+ * @param startDate 开始时间
|
|
|
+ * @param endDate 结束时间
|
|
|
+ * @return 返回所有日期的集合
|
|
|
+ */
|
|
|
+ private static List<LocalDate> getDatesBetween(LocalDate startDate, LocalDate endDate) {
|
|
|
+ List<LocalDate> dates = new ArrayList<>();
|
|
|
+
|
|
|
+ long numOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate) + 1; // +1 包含结束日期
|
|
|
+ for (long i = 0; i < numOfDaysBetween; i++) {
|
|
|
+ dates.add(startDate.plusDays(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ return dates;
|
|
|
+ }
|
|
|
+
|
|
|
+ String calculateClassTime(JsonArray allClassTimeDataArray, Map<String, Double> weightSetMap, List<LocalDate> allDateList){
|
|
|
+ JsonObject result = new JsonObject();
|
|
|
+ //计算纵向的合计
|
|
|
+ Double allClassTime = 0d;
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM.dd");
|
|
|
+ JsonArray rowTitle = new JsonArray();
|
|
|
+ for (LocalDate localDate : allDateList) {
|
|
|
+ JsonObject rowTitleJson = new JsonObject();
|
|
|
+ rowTitleJson.addProperty("scheduleDate", localDate.format(formatter));
|
|
|
+ Double sum = 0d;
|
|
|
+ for (JsonElement jsonElement : allClassTimeDataArray) {
|
|
|
+ JsonObject object = jsonElement.getAsJsonObject();
|
|
|
+ LocalDate scheduleDate = LocalDate.parse(object.get("scheduleDate").getAsString());
|
|
|
+ if(!scheduleDate.equals(localDate)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String adjustType = object.get("adjustType").getAsString();
|
|
|
+ if("course_delete".equals(adjustType)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(weightSetMap.get(object.get("type").getAsString()) == null){
|
|
|
+ sum += object.get("content").getAsDouble();
|
|
|
+ allClassTime += object.get("content").getAsDouble();
|
|
|
+ }else{
|
|
|
+ sum += weightSetMap.get(object.get("type").getAsString());
|
|
|
+ allClassTime += weightSetMap.get(object.get("type").getAsString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rowTitleJson.addProperty("content", sum);
|
|
|
+ rowTitleJson.addProperty("type", "");
|
|
|
+ rowTitleJson.addProperty("adjustType", "");
|
|
|
+ rowTitle.add(rowTitleJson);
|
|
|
+ }
|
|
|
+ result.add("rowTitle", rowTitle);
|
|
|
+
|
|
|
+ //计算横向的合计
|
|
|
+ JsonArray columnTitle = new JsonArray();
|
|
|
+ for (String type : weightSetMap.keySet()) {
|
|
|
+ Double sum = 0d;
|
|
|
+ JsonObject columnTitleJson = new JsonObject();
|
|
|
+ for (JsonElement jsonElement : allClassTimeDataArray) {
|
|
|
+ JsonObject object = jsonElement.getAsJsonObject();
|
|
|
+ String typeStr = object.get("type").getAsString();
|
|
|
+
|
|
|
+ if(!type.equals(typeStr)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String adjustType = object.get("adjustType").getAsString();
|
|
|
+ if("course_delete".equals(adjustType)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ sum += weightSetMap.get(typeStr);
|
|
|
+ }
|
|
|
+ columnTitleJson.addProperty("type", type);
|
|
|
+ columnTitleJson.addProperty("content", sum);
|
|
|
+ columnTitleJson.addProperty("scheduleDate", "");
|
|
|
+ columnTitleJson.addProperty("adjustType", "");
|
|
|
+ columnTitle.add(columnTitleJson);
|
|
|
+ }
|
|
|
+ String[] courseTimeTypes = CourseTimeTypeEnum.getValues();
|
|
|
+ for (String courseTimeType : courseTimeTypes) {
|
|
|
+ double sum = 0d;
|
|
|
+ JsonObject columnTitleJson = new JsonObject();
|
|
|
+ for (JsonElement jsonElement : allClassTimeDataArray) {
|
|
|
+ JsonObject object = jsonElement.getAsJsonObject();
|
|
|
+ String typeStr = object.get("type").getAsString();
|
|
|
+ if (!courseTimeType.equals(typeStr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String adjustType = object.get("adjustType").getAsString();
|
|
|
+ if("course_delete".equals(adjustType)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ sum += object.get("content").getAsDouble();
|
|
|
+ }
|
|
|
+ columnTitleJson.addProperty("type", courseTimeType);
|
|
|
+ columnTitleJson.addProperty("content", sum);
|
|
|
+ columnTitleJson.addProperty("scheduleDate", "");
|
|
|
+ columnTitleJson.addProperty("adjustType", "");
|
|
|
+ columnTitle.add(columnTitleJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.add("columnTitle", columnTitle);
|
|
|
+
|
|
|
+ result.add("data", allClassTimeDataArray);
|
|
|
+ result.addProperty("allClassTime", allClassTime);
|
|
|
+ return result.toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|