|
|
@@ -4,14 +4,17 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+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.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.codehaus.jettison.json.JSONArray;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -126,7 +129,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (bo.getStatus() != null && bo.getStatus() == 1){
|
|
|
UserPlan userPlan = new UserPlan();
|
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
|
- String s1 = JSON.toJSONString(userPlanVo);
|
|
|
+ String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
|
|
|
|
userPlan.setStudyDay(bo.getStudyDay());
|
|
|
userPlan.setStudyCount(s1);
|
|
|
@@ -139,7 +142,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (bo.getStatus() != null){
|
|
|
userPlan.setStatus(bo.getStatus());
|
|
|
}
|
|
|
- boolean save = this.save(userPlan);
|
|
|
+ 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);
|
|
|
+ for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
|
|
|
+ coursePlanVo.setPlanId(userPlan.getPlanId());
|
|
|
+ baseMapper.insertSource(coursePlanVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return userPlanVo;
|
|
|
}else{
|
|
|
@@ -147,7 +164,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (bo.getStatus() != null && bo.getStatus() == 1) {
|
|
|
UserPlan userPlan = new UserPlan();
|
|
|
String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
|
|
|
- String s1 = JSON.toJSONString(userPlanVo);
|
|
|
+ String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
|
|
|
|
|
|
userPlan.setStudyDay(bo.getStudyDay());
|
|
|
userPlan.setStudyCount(s1);
|
|
|
@@ -165,7 +182,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
if (bo.getStatus() != null){
|
|
|
userPlan.setStatus(bo.getStatus());
|
|
|
}
|
|
|
- boolean save = this.save(userPlan);
|
|
|
+ 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);
|
|
|
+ for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
|
|
|
+ coursePlanVo.setPlanId(userPlan.getPlanId());
|
|
|
+ baseMapper.insertSource(coursePlanVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return userPlanVo;
|
|
|
}
|
|
|
@@ -173,7 +204,110 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
@Override
|
|
|
public UserPlanVo userPlan(UserPlanQueryBo bo) {
|
|
|
- return this.queryById(bo.getUserId());
|
|
|
+ UserPlan userPlan = baseMapper.selectByUserPlan(bo);
|
|
|
+ UserPlanVo userPlanVo = new UserPlanVo();
|
|
|
+ userPlanVo.setUserId(userPlan.getUserId());
|
|
|
+ userPlanVo.setExamDate(userPlan.getExamDate());
|
|
|
+ userPlanVo.setReminderTime(userPlan.getReminderTime());
|
|
|
+ userPlanVo.setStudyDay(userPlan.getStudyDay());
|
|
|
+ userPlanVo.setStartTime(userPlan.getStartTime());
|
|
|
+ userPlanVo.setEndTime(userPlan.getEndTime());
|
|
|
+ userPlanVo.setPitchNum(userPlan.getPitchNum());
|
|
|
+ userPlanVo.setStudyNum(userPlan.getStudyNum());
|
|
|
+ userPlanVo.setPlanId(userPlan.getPlanId());
|
|
|
+
|
|
|
+ List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
|
|
|
+ List<Long> cont = JSONObject.parseArray(userPlan.getStudyCount(), Long.class);
|
|
|
+ Long[] strings = new Long[cont.size()];
|
|
|
+ cont.toArray(strings);
|
|
|
+ userPlanVo.setCalendarStudyVo(calendarStudyVos);
|
|
|
+ userPlanVo.setStudyCount(strings);
|
|
|
+ userPlanVo.setCoursePlanVo(null);
|
|
|
+ List<UserPlanCource> userPlanClsList = baseMapper.selectCourse(userPlan.getPlanId());
|
|
|
+
|
|
|
+ //初始化需要得到的数组
|
|
|
+ Integer[] array = new Integer[userPlanClsList.size()];
|
|
|
+
|
|
|
+ //使用for循环得到数组
|
|
|
+ for(int i = 0; i < userPlanClsList.size();i++){
|
|
|
+ array[i] = Convert.toInt(userPlanClsList.get(i).getSourceId());
|
|
|
+ }
|
|
|
+ bo.setCourseId(array);
|
|
|
+ List<CoursePlanVo> coursePlanVo = baseMapper.selectByListCourse(bo);
|
|
|
+ userPlanVo.setCoursePlanVo(coursePlanVo);
|
|
|
+ return userPlanVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean updateGenerate(UserPlanQueryBo bo) throws ParseException {
|
|
|
+ if (bo.getStatus() == 0) {
|
|
|
+ UserPlan userPlan = new UserPlan();
|
|
|
+ userPlan.setPlanId(bo.getPlanId());
|
|
|
+ userPlan.setStatus(0);
|
|
|
+ int i = baseMapper.updateById(userPlan);
|
|
|
+ }else {
|
|
|
+ //自定义学习计划,自动生成计划
|
|
|
+ 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());
|
|
|
+ userPlan.setSchedule(s);
|
|
|
+ userPlan.setPitchNum(userPlanVo.getPitchNum());
|
|
|
+ userPlan.setStudyNum(0L);
|
|
|
+ userPlan.setCreateTime(DateUtils.getNowTime());
|
|
|
+ userPlan.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ if (bo.getStatus() != null) {
|
|
|
+ userPlan.setStatus(bo.getStatus());
|
|
|
+ }
|
|
|
+ if (bo.getStatus() == 1) {
|
|
|
+ boolean save = this.save(userPlan);
|
|
|
+ }
|
|
|
+ if (bo.getStatus() == 2) {
|
|
|
+ userPlan.setPlanId(bo.getPlanId());
|
|
|
+ boolean save = this.updateById(userPlan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ UserPlanVo userPlanVo = generateSelfBo(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());
|
|
|
+ userPlan.setSchedule(s);
|
|
|
+ userPlan.setExamDate(bo.getExamDate());
|
|
|
+ userPlan.setReminderTime(bo.getReminderTime());
|
|
|
+ userPlan.setPitchNum(userPlanVo.getPitchNum());
|
|
|
+ userPlan.setStudyNum(0L);
|
|
|
+ userPlan.setCreateTime(DateUtils.getNowTime());
|
|
|
+ userPlan.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ userPlan.setStartTime(bo.getStartTime());
|
|
|
+ userPlan.setEndTime(bo.getEndTime());
|
|
|
+ userPlan.setStudyDay(bo.getStudyDay());
|
|
|
+ if (bo.getStatus() != null) {
|
|
|
+ userPlan.setStatus(bo.getStatus());
|
|
|
+ }
|
|
|
+ if (bo.getStatus() == 1) {
|
|
|
+ boolean save = this.save(userPlan);
|
|
|
+ }
|
|
|
+ if (bo.getStatus() == 2) {
|
|
|
+ userPlan.setPlanId(bo.getPlanId());
|
|
|
+ boolean save = this.updateById(userPlan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
private UserPlanVo generateSelfBo(UserPlanQueryBo bo) throws ParseException {
|
|
|
@@ -284,7 +418,9 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
userPlanVo1.setUserId(bo.getUserId());
|
|
|
userPlanVo1.setStudyDay(0L);
|
|
|
userPlanVo1.setPitchNum(Convert.toLong(sectionNum)+userPlanVo1.getPitchNum());
|
|
|
- userPlanVo1.setPitchNum(Convert.toLong(sectionNum)+userPlanVo1.getPitchNum());
|
|
|
+ List<CoursePlanVo> coursePlanVo = userPlanVo1.getCoursePlanVo();
|
|
|
+ coursePlanVo.add(planVo);
|
|
|
+ userPlanVo1.setCoursePlanVo(coursePlanVo);
|
|
|
return userPlanVo1;
|
|
|
}
|
|
|
|