|
|
@@ -11,11 +11,13 @@ import com.google.gson.JsonArray;
|
|
|
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.service.IUserPlanCourceService;
|
|
|
import com.zhongzheng.modules.user.vo.CalendarStudyVo;
|
|
|
import com.zhongzheng.modules.user.vo.CoursePlanVo;
|
|
|
import com.zhongzheng.modules.user.vo.DayStudyVo;
|
|
|
import io.micrometer.core.instrument.util.TimeUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
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 {
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserPlanCourceService userPlanCourceService;
|
|
|
+
|
|
|
@Override
|
|
|
public UserPlanVo queryById(Long userId){
|
|
|
UserPlan db = this.baseMapper.selectById(userId);
|
|
|
@@ -123,14 +128,20 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
@Override
|
|
|
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){
|
|
|
UserPlanVo userPlanVo = generateSelf(bo);
|
|
|
if (bo.getStatus() != null && bo.getStatus() == 1){
|
|
|
UserPlan userPlan = new UserPlan();
|
|
|
+
|
|
|
+
|
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
|
String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
|
-
|
|
|
userPlan.setStudyDay(bo.getStudyDay());
|
|
|
userPlan.setStudyCount(s1);
|
|
|
userPlan.setUserId(bo.getUserId());
|
|
|
@@ -244,7 +255,8 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
|
|
|
@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) {
|
|
|
UserPlan userPlan = new UserPlan();
|
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
|
@@ -253,8 +265,8 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}else {
|
|
|
//自定义学习计划,自动生成计划
|
|
|
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();
|
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
|
String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
|
@@ -272,15 +284,26 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
if (bo.getStatus() == 1) {
|
|
|
boolean save = this.save(userPlan);
|
|
|
+ for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
|
|
|
+ coursePlanVo.setPlanId(userPlan.getPlanId());
|
|
|
+ baseMapper.insertSource(coursePlanVo);
|
|
|
+ }
|
|
|
}
|
|
|
if (bo.getStatus() == 2) {
|
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
|
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 {
|
|
|
- UserPlanVo userPlanVo = generateSelfBo(bo);
|
|
|
- if (bo.getStatus() != null && bo.getStatus() == 1) {
|
|
|
+ UserPlanVo userPlanVo = generateSelfBo(userPlanQueryBo);
|
|
|
+ if (bo.getStatus() != null) {
|
|
|
UserPlan userPlan = new UserPlan();
|
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
|
String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
|
@@ -303,10 +326,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
}
|
|
|
if (bo.getStatus() == 1) {
|
|
|
boolean save = this.save(userPlan);
|
|
|
+ for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
|
|
|
+ coursePlanVo.setPlanId(userPlan.getPlanId());
|
|
|
+ baseMapper.insertSource(coursePlanVo);
|
|
|
+ }
|
|
|
}
|
|
|
if (bo.getStatus() == 2) {
|
|
|
userPlan.setPlanId(bo.getPlanId());
|
|
|
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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -363,28 +397,36 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
|
|
|
sectionNum = 0;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}else if(calendarStudyVo.getMonth() != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
|
|
|
sectionNum = 0;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//原有课程不满足课程节数则再创建课程
|
|
|
- if (sectionNum == 0){
|
|
|
+ if (sectionNum != 0){
|
|
|
while (sectionNum != 0 ) {
|
|
|
- month++;
|
|
|
- Long firstDayOfMonth = getFirstDayOfMonth(month+1);
|
|
|
- Long lastDayOfMonth = getLastDayOfMonth(month+1);
|
|
|
+ if (CollectionUtils.isEmpty(userPlanVo1.getCalendarStudyVo())) {
|
|
|
+ month = cal.get(Calendar.MONTH)+1;
|
|
|
+ }else {
|
|
|
+ ++month;
|
|
|
+ }
|
|
|
+ Long firstDayOfMonth = getFirstDayOfMonth(month);
|
|
|
+ Long lastDayOfMonth = getLastDayOfMonth(month);
|
|
|
|
|
|
List<DayStudyVo> dayStudyVos = getDays(firstDayOfMonth, lastDayOfMonth);
|
|
|
for (DayStudyVo dayStudyVo : dayStudyVos) {
|
|
|
@@ -395,17 +437,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
sectionNum = 0;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
sectionNum = 0;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -478,17 +524,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
sectionNum = 0;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
|
|
|
if (Sec < sectionNum) {
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
sectionNum = sectionNum-Sec;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}else if (Sec >= sectionNum){
|
|
|
dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
|
|
|
sectionNum = 0;
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -576,6 +626,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
sectionNum = 0;
|
|
|
}
|
|
|
}
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
}
|
|
|
CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
|
|
|
calendarStudyVo.setYear(Convert.toLong(year));
|