|
|
@@ -2,6 +2,7 @@ package com.zhongzheng.modules.user.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -12,6 +13,7 @@ import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamArrangementTimeVo;
|
|
|
import com.zhongzheng.modules.user.domain.UserPlanCource;
|
|
|
import com.zhongzheng.modules.user.domain.UserStudyRecord;
|
|
|
+import com.zhongzheng.modules.user.service.IOrderPossessUserService;
|
|
|
import com.zhongzheng.modules.user.service.IUserPlanCourceService;
|
|
|
import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
import com.zhongzheng.modules.user.vo.*;
|
|
|
@@ -29,6 +31,7 @@ import com.zhongzheng.modules.user.bo.UserPlanEditBo;
|
|
|
import com.zhongzheng.modules.user.domain.UserPlan;
|
|
|
import com.zhongzheng.modules.user.mapper.UserPlanMapper;
|
|
|
import com.zhongzheng.modules.user.service.IUserPlanService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.ParseException;
|
|
|
@@ -52,6 +55,9 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
@Autowired
|
|
|
private IUserStudyRecordService userStudyRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrderPossessUserService iOrderPossessUserService;
|
|
|
+
|
|
|
@Override
|
|
|
public UserPlanVo queryById(Long userId){
|
|
|
UserPlan db = this.baseMapper.selectById(userId);
|
|
|
@@ -129,12 +135,22 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public UserPlanVo generate(UserPlanQueryBo bo) throws ParseException {
|
|
|
//判断是否课程已被生成过课程
|
|
|
Integer rank = baseMapper.selectCountCourse(bo);
|
|
|
if (rank > 0){
|
|
|
throw new IllegalArgumentException("您当前有课程的计划,请到计划修改上修改计划");
|
|
|
}
|
|
|
+ //查询是否拥有该课程
|
|
|
+ Arrays.stream(bo.getCourseId()).forEach(a ->{
|
|
|
+ Integer i = Validator.isNotNull(iOrderPossessUserService.queryByTypeAndId(Convert.toLong(a),1,bo.getUserId()))?1:0;
|
|
|
+ if (i < 1){
|
|
|
+ throw new IllegalArgumentException("您没有拥有该课程");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
//自定义学习计划,自动生成计划
|
|
|
if (bo.getCourseId() != null && bo.getStudyCount() == null){
|
|
|
UserPlanVo userPlanVo = generateSelf(bo);
|
|
|
@@ -237,6 +253,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public List<UserPlanVo> userPlan(UserPlanQueryBo bo) {
|
|
|
List<UserPlan> userPlans = baseMapper.selectByUserPlan(bo);
|
|
|
List<UserPlanVo> userPlanVos = new ArrayList<>();
|
|
|
@@ -289,60 +306,81 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
+ });
|
|
|
|
|
|
+ //更新当天学习节数是否已经完成
|
|
|
+ //代表前面是否有未完成课程
|
|
|
+ Long studyNum = 0L;
|
|
|
+ boolean goal = true;
|
|
|
+ for (CoursePlanVo b : coursePlanVo) {
|
|
|
+ if (goal == false) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(), Convert.toInt(b.getCourseId()));
|
|
|
+ List<UserStudyRecord> myList = studyCount.stream().distinct().collect(Collectors.toList());
|
|
|
+ studyNum= studyNum+Convert.toLong(myList.size());
|
|
|
//更新当天学习节数是否已经完成
|
|
|
- //代表前面是否有未完成课程
|
|
|
- List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(), array, getTimesmorning(), getTimesnight());
|
|
|
- boolean goal = true;
|
|
|
- for (CoursePlanVo b : coursePlanVo) {
|
|
|
- if (goal == false) {
|
|
|
- break;
|
|
|
- }
|
|
|
- //更新当天学习节数是否已经完成
|
|
|
- List<UserStudyRecord> collect = studyCount.stream().filter(v -> v.getCourseId().equals(s.getCourseId())).collect(Collectors.toList());
|
|
|
- if (collect.size() >= b.getStudyGoal()) {
|
|
|
- calendarStudyVos.stream().filter(c -> c.getMonth() == cal.get(Calendar.MONTH) + 1).forEach(c -> {
|
|
|
- c.getDayStudyList().stream()
|
|
|
- .forEach(d -> {
|
|
|
- if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
|
|
|
- d.setPerform(1);
|
|
|
- }
|
|
|
- if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
|
|
|
- d.setPerform(2);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- } else {
|
|
|
- calendarStudyVos.stream().filter(c -> c.getMonth() == cal.get(Calendar.MONTH) + 1).forEach(c -> {
|
|
|
- for (DayStudyVo d : c.getDayStudyList()) {
|
|
|
+ if (b.getStudyGoal() != null && studyCount.size() >= b.getStudyGoal() ) {
|
|
|
+ for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
|
|
|
+ if (calendarStudyVo.getMonth() == cal.get(Calendar.MONTH) + 1) {
|
|
|
+ for (DayStudyVo d : calendarStudyVo.getDayStudyList()) {
|
|
|
+ if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
|
|
|
+ if (d.getPerform() == 1){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Map<Long, Long> sectionIdMap = d.getSectionIdMap();
|
|
|
+ for (UserStudyRecord userStudyRecord : studyCount) {
|
|
|
+ sectionIdMap.remove(userStudyRecord.getSectionId());
|
|
|
+ }
|
|
|
+ if (sectionIdMap.isEmpty()) {
|
|
|
+ d.setPerform(1);
|
|
|
+ } else {
|
|
|
+ d.setPerform(0);
|
|
|
+ goal = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
|
|
|
d.setPerform(2);
|
|
|
}
|
|
|
- if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH)) {
|
|
|
- d.setPerform(0);
|
|
|
- }
|
|
|
}
|
|
|
- });
|
|
|
- goal = false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- UserPlan userPlan1 = new UserPlan();
|
|
|
- userPlan1.setPlanId(s.getPlanId());
|
|
|
- String calendar = JSON.toJSONString(calendarStudyVos);
|
|
|
- userPlan1.setSchedule(calendar);
|
|
|
- userPlan1.setUpdateTime(DateUtils.getNowTime());
|
|
|
- baseMapper.updateById(userPlan1);
|
|
|
+ } else {
|
|
|
+ for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
|
|
|
+ for (DayStudyVo d : calendarStudyVo.getDayStudyList()) {
|
|
|
+ if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
|
|
|
+ d.setPerform(2);
|
|
|
+ }
|
|
|
+ if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH)) {
|
|
|
+ d.setPerform(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ goal = false;
|
|
|
}
|
|
|
|
|
|
- userPlanVo.setCoursePlanVo(coursePlanVo);
|
|
|
+ }
|
|
|
+ UserPlan userPlan1 = new UserPlan();
|
|
|
+ userPlan1.setPlanId(userPlan.getPlanId());
|
|
|
+ String calendar = JSON.toJSONString(calendarStudyVos);
|
|
|
+ userPlan1.setSchedule(calendar);
|
|
|
+ userPlan1.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ userPlan1.setStudyNum(studyNum);
|
|
|
+ int i = baseMapper.updateById(userPlan1);
|
|
|
+
|
|
|
+
|
|
|
+ userPlanVo.setCoursePlanVo(coursePlanVo);
|
|
|
userPlanVos.add(userPlanVo);
|
|
|
- });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return userPlanVos;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateGenerate(UserPlanAddBo bo) throws ParseException {
|
|
|
UserPlanQueryBo userPlanQueryBo = BeanUtil.toBean(bo, UserPlanQueryBo.class);
|
|
|
if (bo.getStatus() == 0) {
|
|
|
@@ -441,6 +479,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public UserPlanVo userPlanSeven(UserPlanQueryBo bo) {
|
|
|
List<UserPlan> userPlans = baseMapper.selectByUserPlan(bo);
|
|
|
UserPlanVo userPlanVos = new UserPlanVo();
|
|
|
@@ -467,30 +506,48 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
List<DayStudyVo> dayStudyVos = new ArrayList<>();
|
|
|
List<DayStudyVo> finalDayStudyVos = dayStudyVos;
|
|
|
|
|
|
+ //更新当天学习节数是否已经完成
|
|
|
//代表前面是否有未完成课程
|
|
|
- List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(),array,getTimesmorning(),getTimesnight());
|
|
|
+ Long studyNum = 0L;
|
|
|
boolean goal = true;
|
|
|
- for (CoursePlanVo s : coursePlanVo) {
|
|
|
- if (goal == false){
|
|
|
+ for (CoursePlanVo b : coursePlanVo) {
|
|
|
+ if (goal == false) {
|
|
|
break;
|
|
|
}
|
|
|
+ List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(), Convert.toInt(b.getCourseId()));
|
|
|
+ List<UserStudyRecord> myList = studyCount.stream().distinct().collect(Collectors.toList());
|
|
|
+ studyNum= studyNum+Convert.toLong(myList.size());
|
|
|
//更新当天学习节数是否已经完成
|
|
|
- List<UserStudyRecord> collect = studyCount.stream().filter(v -> v.getCourseId().equals(s.getCourseId())).collect(Collectors.toList());
|
|
|
- if (collect.size() >= s.getStudyGoal()){
|
|
|
- calendarStudyVos.stream().filter(c -> c.getMonth()==cal.get(Calendar.MONTH) + 1).forEach(c -> {
|
|
|
- c.getDayStudyList().stream()
|
|
|
- .forEach(d -> {
|
|
|
- if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate()== cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0){
|
|
|
- d.setPerform(1);
|
|
|
+ if (b.getStudyGoal() != null && studyCount.size() >= b.getStudyGoal() ) {
|
|
|
+ for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
|
|
|
+ if (calendarStudyVo.getMonth() == cal.get(Calendar.MONTH) + 1) {
|
|
|
+ for (DayStudyVo d : calendarStudyVo.getDayStudyList()) {
|
|
|
+ if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
|
|
|
+ if (d.getPerform() == 1){
|
|
|
+ break;
|
|
|
}
|
|
|
- if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate()< cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0){
|
|
|
- d.setPerform(2);
|
|
|
+ Map<Long, Long> sectionIdMap = d.getSectionIdMap();
|
|
|
+ for (UserStudyRecord userStudyRecord : studyCount) {
|
|
|
+ sectionIdMap.remove(userStudyRecord.getSectionId());
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- }else {
|
|
|
- calendarStudyVos.stream().filter(c -> c.getMonth()==cal.get(Calendar.MONTH) + 1).forEach(c -> {
|
|
|
- for (DayStudyVo d : c.getDayStudyList()) {
|
|
|
+ if (sectionIdMap.isEmpty()) {
|
|
|
+ d.setPerform(1);
|
|
|
+ } else {
|
|
|
+ d.setPerform(0);
|
|
|
+ goal = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
|
|
|
+ d.setPerform(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
|
|
|
+ for (DayStudyVo d : calendarStudyVo.getDayStudyList()) {
|
|
|
if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
|
|
|
d.setPerform(2);
|
|
|
}
|
|
|
@@ -498,17 +555,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
d.setPerform(0);
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
- goal=false;
|
|
|
+ }
|
|
|
+ goal = false;
|
|
|
}
|
|
|
- UserPlan userPlan1 = new UserPlan();
|
|
|
- userPlan1.setPlanId(s.getPlanId());
|
|
|
- String calendar = JSON.toJSONString(calendarStudyVos);
|
|
|
- userPlan1.setSchedule(calendar);
|
|
|
- userPlan1.setUpdateTime(DateUtils.getNowTime());
|
|
|
- baseMapper.updateById(userPlan1);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ UserPlan userPlan1 = new UserPlan();
|
|
|
+ userPlan1.setPlanId(userPlan.getPlanId());
|
|
|
+ String calendar = JSON.toJSONString(calendarStudyVos);
|
|
|
+ userPlan1.setSchedule(calendar);
|
|
|
+ userPlan1.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ userPlan1.setStudyNum(studyNum);
|
|
|
+ int i = baseMapper.updateById(userPlan1);
|
|
|
+
|
|
|
+
|
|
|
calendarStudyVos.stream().filter(c -> c.getMonth() == (cal.get(Calendar.MONTH)+1))
|
|
|
.forEach(c -> {
|
|
|
finalDayStudyVos.addAll(c.getDayStudyList().stream()
|
|
|
@@ -533,22 +594,22 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
break;
|
|
|
case 3:
|
|
|
dayStudyVos=finalDayStudyVos.stream()
|
|
|
- .filter(v -> v.getDate() < 4 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 3)
|
|
|
+ .filter(v -> v.getDate() < 4 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 3)
|
|
|
.collect(Collectors.toList());
|
|
|
break;
|
|
|
case 4:
|
|
|
dayStudyVos=finalDayStudyVos.stream()
|
|
|
- .filter(v -> v.getDate() < 3 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 4)
|
|
|
+ .filter(v -> v.getDate() < 3 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 4)
|
|
|
.collect(Collectors.toList());
|
|
|
break;
|
|
|
case 5:
|
|
|
dayStudyVos=finalDayStudyVos.stream()
|
|
|
- .filter(v -> v.getDate() < 2 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 5)
|
|
|
+ .filter(v -> v.getDate() < 2 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 5)
|
|
|
.collect(Collectors.toList());
|
|
|
break;
|
|
|
case 6:
|
|
|
dayStudyVos=finalDayStudyVos.stream()
|
|
|
- .filter(v -> v.getDate() < 1 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 6)
|
|
|
+ .filter(v -> v.getDate() < 1 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 6)
|
|
|
.collect(Collectors.toList());
|
|
|
break;
|
|
|
}
|
|
|
@@ -581,22 +642,22 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
break;
|
|
|
case 3:
|
|
|
dayStudyVos=dayStudyVos.stream()
|
|
|
- .filter(v -> v.getDate() < 4 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 3)
|
|
|
+ .filter(v -> v.getDate() < 4 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 3)
|
|
|
.collect(Collectors.toList());
|
|
|
break;
|
|
|
case 4:
|
|
|
dayStudyVos=dayStudyVos.stream()
|
|
|
- .filter(v -> v.getDate() < 3 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 4)
|
|
|
+ .filter(v -> v.getDate() < 3 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 4)
|
|
|
.collect(Collectors.toList());
|
|
|
break;
|
|
|
case 5:
|
|
|
dayStudyVos=dayStudyVos.stream()
|
|
|
- .filter(v -> v.getDate() < 2 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 5)
|
|
|
+ .filter(v -> v.getDate() < 2 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 5)
|
|
|
.collect(Collectors.toList());
|
|
|
break;
|
|
|
case 6:
|
|
|
dayStudyVos=dayStudyVos.stream()
|
|
|
- .filter(v -> v.getDate() < 1 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 6)
|
|
|
+ .filter(v -> v.getDate() < 1 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 6)
|
|
|
.collect(Collectors.toList());
|
|
|
break;
|
|
|
}
|
|
|
@@ -612,6 +673,11 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
return userPlanVos;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean editPlan(UserPlanAddBo bo) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private UserPlanVo generateSelfBo(UserPlanQueryBo bo) throws ParseException {
|
|
|
@@ -643,8 +709,11 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
//总节数
|
|
|
Integer sectionNum = planVo.getSectionNum();
|
|
|
-
|
|
|
-
|
|
|
+ if(sectionNum <= 0){
|
|
|
+ throw new IllegalArgumentException("该课程没有节数,无法生成计划");
|
|
|
+ }
|
|
|
+ //查出节的ID
|
|
|
+ List<Long> listId= baseMapper.selectByCourseId(planVo.getCourseId());
|
|
|
//获得今天日期,将每天节数写入
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
int year = cal.get(Calendar.YEAR);
|
|
|
@@ -665,6 +734,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
|
|
|
courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(courseDayMap);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),planVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
|
|
|
@@ -672,6 +750,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
dayStudyVo.setPerform(0);
|
|
|
Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
|
|
|
courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (Long aLong : listId) {
|
|
|
+ sectionIdMap.put(aLong,planVo.getCourseId());
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setCourseDayMap(courseDayMap);
|
|
|
}
|
|
|
}else if(calendarStudyVo.getMonth() != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
@@ -682,7 +766,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(courseDayMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
-
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),planVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
|
|
|
@@ -690,7 +782,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(courseDayMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
-
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (Long aLong : listId) {
|
|
|
+ sectionIdMap.put(aLong,planVo.getCourseId());
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
sectionNum = 0;
|
|
|
|
|
|
}
|
|
|
@@ -724,6 +821,18 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(courseDayMap);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = dayStudyVo.getSectionIdMap();
|
|
|
+ if (sectionIdMap == null) {
|
|
|
+ courseDayMap = new HashMap<>();
|
|
|
+ }
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),planVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
@@ -733,6 +842,19 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(courseDayMap);
|
|
|
+
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = dayStudyVo.getSectionIdMap();
|
|
|
+ if (sectionIdMap == null) {
|
|
|
+ courseDayMap = new HashMap<>();
|
|
|
+ }
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),planVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
sectionNum = 0;
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
@@ -746,6 +868,19 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(courseDayMap);
|
|
|
+
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = dayStudyVo.getSectionIdMap();
|
|
|
+ if (sectionIdMap == null) {
|
|
|
+ courseDayMap = new HashMap<>();
|
|
|
+ }
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),planVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
@@ -756,6 +891,19 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(courseDayMap);
|
|
|
sectionNum = 0;
|
|
|
+
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = dayStudyVo.getSectionIdMap();
|
|
|
+ if (sectionIdMap == null) {
|
|
|
+ courseDayMap = new HashMap<>();
|
|
|
+ }
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),planVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}
|
|
|
@@ -797,7 +945,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
//总节数
|
|
|
Integer sectionNum = coursePlanVo.getSectionNum();
|
|
|
+ if(sectionNum <= 0){
|
|
|
+ throw new IllegalArgumentException("该课程没有节数,无法生成计划");
|
|
|
+ }
|
|
|
userPlanVo.setPitchNum(Convert.toLong(sectionNum));
|
|
|
+ //查出节的ID
|
|
|
+ List<Long> listId= baseMapper.selectByCourseId(coursePlanVo.getCourseId());
|
|
|
|
|
|
//获得今天日期,将每天节数写入
|
|
|
List<CalendarStudyVo> calendarStudyVos = new ArrayList<>();
|
|
|
@@ -832,6 +985,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
|
|
|
studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(studyDstudyVo);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),coursePlanVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
@@ -839,6 +1001,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
|
|
|
studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(studyDstudyVo);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (Long aLong : listId) {
|
|
|
+ sectionIdMap.put(aLong,coursePlanVo.getCourseId());
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
@@ -848,6 +1016,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
|
|
|
studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(studyDstudyVo);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),coursePlanVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
@@ -855,6 +1032,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
|
|
|
studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(studyDstudyVo);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (Long aLong : listId) {
|
|
|
+ sectionIdMap.put(aLong,coursePlanVo.getCourseId());
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}
|
|
|
@@ -901,8 +1084,14 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
//总节数
|
|
|
Integer sectionNum = coursePlanVo.getSectionNum();
|
|
|
+ if(sectionNum <= 0){
|
|
|
+ throw new IllegalArgumentException("该课程没有节数,无法生成计划");
|
|
|
+ }
|
|
|
userPlanVo.setPitchNum(Convert.toLong(sectionNum));
|
|
|
|
|
|
+ //查出节的ID
|
|
|
+ List<Long> listId= baseMapper.selectByCourseId(coursePlanVo.getCourseId());
|
|
|
+
|
|
|
//获得今天日期,将每天节数写入
|
|
|
List<CalendarStudyVo> calendarStudyVos = new ArrayList<>();
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
@@ -933,32 +1122,66 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
dayStudyVo.setPerform(0);
|
|
|
+ //添加课程节数
|
|
|
Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
|
|
|
studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(studyDstudyVo);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),coursePlanVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
dayStudyVo.setPerform(0);
|
|
|
+ //添加课程节数
|
|
|
Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
|
|
|
studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(studyDstudyVo);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (Long aLong : listId) {
|
|
|
+ sectionIdMap.put(aLong,coursePlanVo.getCourseId());
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
sectionNum = 0;
|
|
|
}
|
|
|
}else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
dayStudyVo.setPerform(0);
|
|
|
+ //添加课程节数
|
|
|
Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
|
|
|
studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(studyDstudyVo);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < Sec; i++) {
|
|
|
+ if (listId.size() >= Sec) {
|
|
|
+ sectionIdMap.put(listId.get(0),coursePlanVo.getCourseId());
|
|
|
+ listId.remove(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
dayStudyVo.setPerform(0);
|
|
|
+ //添加课程节数
|
|
|
Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
|
|
|
studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
|
|
|
dayStudyVo.setCourseDayMap(studyDstudyVo);
|
|
|
+ //添加课程学习节ID
|
|
|
+ Map<Long,Long> sectionIdMap = new HashMap<>();
|
|
|
+ for (Long aLong : listId) {
|
|
|
+ sectionIdMap.put(aLong,coursePlanVo.getCourseId());
|
|
|
+ }
|
|
|
+ dayStudyVo.setSectionIdMap(sectionIdMap);
|
|
|
sectionNum = 0;
|
|
|
}
|
|
|
}
|