|
@@ -11,11 +11,13 @@ import com.google.gson.JsonArray;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamArrangementTimeVo;
|
|
import com.zhongzheng.modules.exam.vo.ExamArrangementTimeVo;
|
|
|
import com.zhongzheng.modules.user.domain.UserPlanCource;
|
|
import com.zhongzheng.modules.user.domain.UserPlanCource;
|
|
|
|
|
+import com.zhongzheng.modules.user.service.IUserPlanCourceService;
|
|
|
import com.zhongzheng.modules.user.vo.CalendarStudyVo;
|
|
import com.zhongzheng.modules.user.vo.CalendarStudyVo;
|
|
|
import com.zhongzheng.modules.user.vo.CoursePlanVo;
|
|
import com.zhongzheng.modules.user.vo.CoursePlanVo;
|
|
|
import com.zhongzheng.modules.user.vo.DayStudyVo;
|
|
import com.zhongzheng.modules.user.vo.DayStudyVo;
|
|
|
import io.micrometer.core.instrument.util.TimeUtils;
|
|
import io.micrometer.core.instrument.util.TimeUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -45,6 +47,9 @@ import java.util.stream.Collectors;
|
|
|
public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> implements IUserPlanService {
|
|
public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> implements IUserPlanService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IUserPlanCourceService userPlanCourceService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public UserPlanVo queryById(Long userId){
|
|
public UserPlanVo queryById(Long userId){
|
|
|
UserPlan db = this.baseMapper.selectById(userId);
|
|
UserPlan db = this.baseMapper.selectById(userId);
|
|
@@ -123,6 +128,11 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public UserPlanVo generate(UserPlanQueryBo bo) throws ParseException {
|
|
public UserPlanVo generate(UserPlanQueryBo bo) throws ParseException {
|
|
|
|
|
+ //判断是否课程已被生成过课程
|
|
|
|
|
+ Integer rank = baseMapper.selectCountCourse(bo);
|
|
|
|
|
+ if (rank > 0){
|
|
|
|
|
+ throw new IllegalArgumentException("您当前有课程的计划,请到计划修改上修改计划");
|
|
|
|
|
+ }
|
|
|
//自定义学习计划,自动生成计划
|
|
//自定义学习计划,自动生成计划
|
|
|
if (bo.getCourseId() != null && bo.getStudyCount() == null){
|
|
if (bo.getCourseId() != null && bo.getStudyCount() == null){
|
|
|
UserPlanVo userPlanVo = generateSelf(bo);
|
|
UserPlanVo userPlanVo = generateSelf(bo);
|
|
@@ -245,7 +255,8 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Boolean updateGenerate(UserPlanQueryBo bo) throws ParseException {
|
|
|
|
|
|
|
+ public Boolean updateGenerate(UserPlanAddBo bo) throws ParseException {
|
|
|
|
|
+ UserPlanQueryBo userPlanQueryBo = BeanUtil.toBean(bo, UserPlanQueryBo.class);
|
|
|
if (bo.getStatus() == 0) {
|
|
if (bo.getStatus() == 0) {
|
|
|
UserPlan userPlan = new UserPlan();
|
|
UserPlan userPlan = new UserPlan();
|
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
@@ -254,8 +265,8 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}else {
|
|
}else {
|
|
|
//自定义学习计划,自动生成计划
|
|
//自定义学习计划,自动生成计划
|
|
|
if (bo.getCourseId() != null && bo.getStudyCount() == null) {
|
|
if (bo.getCourseId() != null && bo.getStudyCount() == null) {
|
|
|
- UserPlanVo userPlanVo = generateSelf(bo);
|
|
|
|
|
- if (bo.getStatus() != null && bo.getStatus() == 1) {
|
|
|
|
|
|
|
+ UserPlanVo userPlanVo = generateSelf(userPlanQueryBo);
|
|
|
|
|
+ if (bo.getStatus() != null) {
|
|
|
UserPlan userPlan = new UserPlan();
|
|
UserPlan userPlan = new UserPlan();
|
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
|
String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
@@ -273,15 +284,26 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
}
|
|
|
if (bo.getStatus() == 1) {
|
|
if (bo.getStatus() == 1) {
|
|
|
boolean save = this.save(userPlan);
|
|
boolean save = this.save(userPlan);
|
|
|
|
|
+ for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
|
|
|
|
|
+ coursePlanVo.setPlanId(userPlan.getPlanId());
|
|
|
|
|
+ baseMapper.insertSource(coursePlanVo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (bo.getStatus() == 2) {
|
|
if (bo.getStatus() == 2) {
|
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
|
boolean save = this.updateById(userPlan);
|
|
boolean save = this.updateById(userPlan);
|
|
|
|
|
+ LambdaQueryWrapper<UserPlanCource> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
+ lqw.eq(bo.getPlanId() != null,UserPlanCource::getPlanId,bo.getPlanId());
|
|
|
|
|
+ userPlanCourceService.remove(lqw);
|
|
|
|
|
+ for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
|
|
|
|
|
+ coursePlanVo.setPlanId(userPlan.getPlanId());
|
|
|
|
|
+ baseMapper.insertSource(coursePlanVo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- UserPlanVo userPlanVo = generateSelfBo(bo);
|
|
|
|
|
- if (bo.getStatus() != null && bo.getStatus() == 1) {
|
|
|
|
|
|
|
+ UserPlanVo userPlanVo = generateSelfBo(userPlanQueryBo);
|
|
|
|
|
+ if (bo.getStatus() != null) {
|
|
|
UserPlan userPlan = new UserPlan();
|
|
UserPlan userPlan = new UserPlan();
|
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
|
String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
@@ -304,10 +326,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
}
|
|
|
if (bo.getStatus() == 1) {
|
|
if (bo.getStatus() == 1) {
|
|
|
boolean save = this.save(userPlan);
|
|
boolean save = this.save(userPlan);
|
|
|
|
|
+ for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
|
|
|
|
|
+ coursePlanVo.setPlanId(userPlan.getPlanId());
|
|
|
|
|
+ baseMapper.insertSource(coursePlanVo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (bo.getStatus() == 2) {
|
|
if (bo.getStatus() == 2) {
|
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
|
boolean save = this.updateById(userPlan);
|
|
boolean save = this.updateById(userPlan);
|
|
|
|
|
+ LambdaQueryWrapper<UserPlanCource> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
+ lqw.eq(bo.getPlanId() != null,UserPlanCource::getPlanId,bo.getPlanId());
|
|
|
|
|
+ userPlanCourceService.remove(lqw);
|
|
|
|
|
+ for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
|
|
|
|
|
+ coursePlanVo.setPlanId(userPlan.getPlanId());
|
|
|
|
|
+ baseMapper.insertSource(coursePlanVo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -364,17 +397,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (Sec < sectionNum) {
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
|
|
|
sectionNum = sectionNum-Sec;
|
|
sectionNum = sectionNum-Sec;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
|
|
|
sectionNum = 0;
|
|
sectionNum = 0;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
}
|
|
|
}else if(calendarStudyVo.getMonth() != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
}else if(calendarStudyVo.getMonth() != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
if (Sec < sectionNum) {
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
|
|
|
sectionNum = sectionNum-Sec;
|
|
sectionNum = sectionNum-Sec;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
|
|
|
sectionNum = 0;
|
|
sectionNum = 0;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -400,17 +437,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (Sec < sectionNum) {
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
sectionNum = sectionNum-Sec;
|
|
sectionNum = sectionNum-Sec;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
sectionNum = 0;
|
|
sectionNum = 0;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
}
|
|
|
}else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
}else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
if (Sec < sectionNum) {
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
sectionNum = sectionNum-Sec;
|
|
sectionNum = sectionNum-Sec;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
sectionNum = 0;
|
|
sectionNum = 0;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -483,17 +524,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (Sec < sectionNum) {
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
sectionNum = sectionNum-Sec;
|
|
sectionNum = sectionNum-Sec;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
sectionNum = 0;
|
|
sectionNum = 0;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
}
|
|
|
}else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
}else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
if (Sec < sectionNum) {
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
sectionNum = sectionNum-Sec;
|
|
sectionNum = sectionNum-Sec;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
sectionNum = 0;
|
|
sectionNum = 0;
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -581,6 +626,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
sectionNum = 0;
|
|
sectionNum = 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
}
|
|
|
CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
|
|
CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
|
|
|
calendarStudyVo.setYear(Convert.toLong(year));
|
|
calendarStudyVo.setYear(Convert.toLong(year));
|