|
@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.modules.course.vo.CourseVo;
|
|
import com.zhongzheng.modules.course.vo.CourseVo;
|
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsUserVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.user.bo.UserPlanGoodsAddBo;
|
|
import com.zhongzheng.modules.user.bo.UserPlanGoodsAddBo;
|
|
import com.zhongzheng.modules.user.domain.UserPlanGoods;
|
|
import com.zhongzheng.modules.user.domain.UserPlanGoods;
|
|
@@ -49,8 +50,10 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
@Autowired
|
|
@Autowired
|
|
private IUserPlanGoodsService userPlanGoodsService;
|
|
private IUserPlanGoodsService userPlanGoodsService;
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public UserPlanVo queryById(Long planId){
|
|
|
|
|
|
+ public UserPlanVo queryById(Long planId,Long UserId){
|
|
UserPlan userPlan = this.baseMapper.selectById(planId);
|
|
UserPlan userPlan = this.baseMapper.selectById(planId);
|
|
//得到日历日期
|
|
//得到日历日期
|
|
UserPlanVo userPlanVo = new UserPlanVo();
|
|
UserPlanVo userPlanVo = new UserPlanVo();
|
|
@@ -63,7 +66,17 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
userPlanVo.setPitchNum(userPlan.getPitchNum());
|
|
userPlanVo.setPitchNum(userPlan.getPitchNum());
|
|
userPlanVo.setStudyNum(userPlan.getStudyNum());
|
|
userPlanVo.setStudyNum(userPlan.getStudyNum());
|
|
userPlanVo.setPlanId(userPlan.getPlanId());
|
|
userPlanVo.setPlanId(userPlan.getPlanId());
|
|
-
|
|
|
|
|
|
+ List<GoodsUserVo> goodsVos = userPlanGoodsService.selectGoods(planId,UserId);
|
|
|
|
+ userPlanVo.setGoodsVos(goodsVos);
|
|
|
|
+ // List转成数组
|
|
|
|
+ Long[] array = new Long[goodsVos.size()];
|
|
|
|
+ // 输出数组
|
|
|
|
+ List<Long> arrys = new ArrayList<>();
|
|
|
|
+ for (GoodsUserVo goodsVo : goodsVos) {
|
|
|
|
+ arrys.add(goodsVo.getGoodsId());
|
|
|
|
+ }
|
|
|
|
+ arrys.toArray(array);
|
|
|
|
+ userPlanVo.setGoodsId(array);
|
|
//得到日历日期
|
|
//得到日历日期
|
|
List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
|
|
List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
|
|
//得到学习的周
|
|
//得到学习的周
|
|
@@ -103,7 +116,17 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
userPlanVo.setPitchNum(userPlan.getPitchNum());
|
|
userPlanVo.setPitchNum(userPlan.getPitchNum());
|
|
userPlanVo.setStudyNum(userPlan.getStudyNum());
|
|
userPlanVo.setStudyNum(userPlan.getStudyNum());
|
|
userPlanVo.setPlanId(userPlan.getPlanId());
|
|
userPlanVo.setPlanId(userPlan.getPlanId());
|
|
-
|
|
|
|
|
|
+ List<GoodsUserVo> goodsVos = userPlanGoodsService.selectGoods(userPlanVo.getPlanId(),userPlanVo.getUserId());
|
|
|
|
+ userPlanVo.setGoodsVos(goodsVos);
|
|
|
|
+ // List转成数组
|
|
|
|
+ Long[] array = new Long[goodsVos.size()];
|
|
|
|
+ // 输出数组
|
|
|
|
+ List<Long> arrys = new ArrayList<>();
|
|
|
|
+ for (GoodsUserVo goodsVo : goodsVos) {
|
|
|
|
+ arrys.add(goodsVo.getGoodsId());
|
|
|
|
+ }
|
|
|
|
+ arrys.toArray(array);
|
|
|
|
+ userPlanVo.setGoodsId(array);
|
|
//得到日历日期
|
|
//得到日历日期
|
|
List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
|
|
List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
|
|
//得到学习的周
|
|
//得到学习的周
|
|
@@ -141,6 +164,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Boolean insertByAddBo(UserPlanAddBo bo) throws ParseException {
|
|
public Boolean insertByAddBo(UserPlanAddBo bo) throws ParseException {
|
|
|
|
+ validEntityPlanBeforeSave(bo);
|
|
UserPlan userPlan = new UserPlan();
|
|
UserPlan userPlan = new UserPlan();
|
|
List<CalendarStudyVo> clCalendarStudyVos = findDates(bo.getStartTime(),bo.getEndTime());
|
|
List<CalendarStudyVo> clCalendarStudyVos = findDates(bo.getStartTime(),bo.getEndTime());
|
|
Long sumUp=0L;
|
|
Long sumUp=0L;
|
|
@@ -161,6 +185,10 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
|
|
if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
|
|
|
|
+ if (allNum.equals(0)){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ allNum -= Sec;
|
|
if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
}else {
|
|
}else {
|
|
@@ -232,6 +260,10 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
|
|
if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
|
|
|
|
+ if (allNum.equals(0)){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ allNum -= Sec;
|
|
if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
}else {
|
|
}else {
|
|
@@ -304,15 +336,17 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public UserPlanVo listPlan(UserPlanEditBo bo) throws ParseException {
|
|
public UserPlanVo listPlan(UserPlanEditBo bo) throws ParseException {
|
|
- validEntityPlanBeforeSave(bo);
|
|
|
|
UserPlanVo userPlanVo = new UserPlanVo();
|
|
UserPlanVo userPlanVo = new UserPlanVo();
|
|
List<CalendarStudyVo> clCalendarStudyVos = findDates(bo.getStartTime(),bo.getEndTime());
|
|
List<CalendarStudyVo> clCalendarStudyVos = findDates(bo.getStartTime(),bo.getEndTime());
|
|
|
|
+ Long secAll = 0L;
|
|
for (Long aLong : bo.getGoodsId()) {
|
|
for (Long aLong : bo.getGoodsId()) {
|
|
//最近考试时间七天前到现在的天数,学习视频时长
|
|
//最近考试时间七天前到现在的天数,学习视频时长
|
|
Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
//获得相隔天数
|
|
//获得相隔天数
|
|
int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
|
|
int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
|
|
-
|
|
|
|
|
|
+ if (dutyDays < 1){
|
|
|
|
+ throw new IllegalArgumentException("没有学习天数,请认真填写开始结束时间");
|
|
|
|
+ }
|
|
List<Long> seLongs = baseMapper.selectGoods(aLong);
|
|
List<Long> seLongs = baseMapper.selectGoods(aLong);
|
|
Long allNum = 0L;
|
|
Long allNum = 0L;
|
|
for (Long seLong : seLongs) {
|
|
for (Long seLong : seLongs) {
|
|
@@ -320,9 +354,14 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
}
|
|
}
|
|
//计算每天需要学习多少节课
|
|
//计算每天需要学习多少节课
|
|
int Sec = (int) Math.ceil((double) allNum / dutyDays);
|
|
int Sec = (int) Math.ceil((double) allNum / dutyDays);
|
|
|
|
+ secAll+=Sec;
|
|
for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
|
|
if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
|
|
|
|
+ if (allNum.equals(0)){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ allNum -= Sec;
|
|
if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
}else {
|
|
}else {
|
|
@@ -345,7 +384,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
}
|
|
}
|
|
}
|
|
}
|
|
userPlanVo.setCalendarStudyVo(clCalendarStudyVos);
|
|
userPlanVo.setCalendarStudyVo(clCalendarStudyVos);
|
|
- userPlanVo.setStudyCourseKnob(clCalendarStudyVos.get(0).getDayStudyList().get(0).getStudyCourseKnob());
|
|
|
|
|
|
+ userPlanVo.setStudyCourseKnob(secAll);
|
|
return userPlanVo;
|
|
return userPlanVo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -433,7 +472,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
*
|
|
*
|
|
* @param bo 实体类数据
|
|
* @param bo 实体类数据
|
|
*/
|
|
*/
|
|
- private void validEntityPlanBeforeSave(UserPlanEditBo bo){
|
|
|
|
|
|
+ private void validEntityPlanBeforeSave(UserPlanAddBo bo){
|
|
//判断是否商品已被生成过课程
|
|
//判断是否商品已被生成过课程
|
|
Integer rank = baseMapper.selectCountGoods(bo);
|
|
Integer rank = baseMapper.selectCountGoods(bo);
|
|
if (rank > 0){
|
|
if (rank > 0){
|