Просмотр исходного кода

Merge branch 'dev' of http://192.168.1.222:10010/zhongzheng-edu/zz_backend into dev

he2802 4 лет назад
Родитель
Сommit
83162c3b96

+ 1 - 1
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -196,7 +196,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
                 bigDecimal = bigDecimal.add(new BigDecimal(activityTaskUser.getScore()));
                 bigDecimal = bigDecimal.add(new BigDecimal(activityTaskUser.getScore()));
             }
             }
         }
         }
-        if (bigDecimal.compareTo(new BigDecimal(activityTaskVo.getStartIntegral())) == 0){
+        if (bigDecimal.compareTo(new BigDecimal(activityTaskVo.getStartIntegral()))  > -1){
             return;
             return;
         }
         }
         UserSchoolInfoEditBo userSchoolInfoEditBo = new UserSchoolInfoEditBo();
         UserSchoolInfoEditBo userSchoolInfoEditBo = new UserSchoolInfoEditBo();

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
 import com.zhongzheng.modules.user.vo.UserStudyRecordVo;
 import com.zhongzheng.modules.user.vo.UserStudyRecordVo;
+import org.apache.ibatis.annotations.Param;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -17,4 +18,5 @@ public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
 
 
     List<UserStudyRecordVo> selectList(UserStudyRecordQueryBo bo);
     List<UserStudyRecordVo> selectList(UserStudyRecordQueryBo bo);
 
 
+    int selectUserStudy(@Param("userId") Long userId, @Param("courseId") Long courseId, @Param("startTime") int timesMorning, @Param("endTime") int timesNight);
 }
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserStudyRecordService.java

@@ -6,6 +6,7 @@ import com.zhongzheng.modules.user.bo.UserStudyRecordEditBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
 import com.zhongzheng.modules.user.vo.UserStudyRecordVo;
 import com.zhongzheng.modules.user.vo.UserStudyRecordVo;
+import org.apache.ibatis.annotations.Param;
 
 
 import java.util.Collection;
 import java.util.Collection;
 import java.util.List;
 import java.util.List;
@@ -51,4 +52,6 @@ public interface IUserStudyRecordService extends IService<UserStudyRecord> {
 	 * @return
 	 * @return
 	 */
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    int selectUserStudy(Long userId, Long courseId, int timesMorning,int timesNight);
 }
 }

+ 101 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -293,8 +293,38 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                 });
                 });
 
 
                 //更新当天学习节数是否已经完成
                 //更新当天学习节数是否已经完成
-
-                //int studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(),s.getCourseId(),startTime,endTime);
+                int studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(),s.getCourseId(),getTimesmorning(),getTimesnight());
+                if (studyCount > 0){
+                    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.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 -> {
+                        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(2);
+                                    }
+                                    if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate()== cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 1){
+                                        d.setPerform(0);
+                                    }
+                                });
+                    });
+                }
+                UserPlan userPlan1 = new UserPlan();
+                userPlan1.setPlanId(s.getPlanId());
+                String calendar = JSON.toJSONString(calendarStudyVos);
+                userPlan1.setSchedule(calendar);
+                userPlan1.setUpdateTime(DateUtils.getNowTime());
+                baseMapper.updateById(userPlan1);
             });
             });
 
 
             userPlanVo.setCoursePlanVo(coursePlanVo);
             userPlanVo.setCoursePlanVo(coursePlanVo);
@@ -428,6 +458,43 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
             userPlanVos.setCoursePlanVo(coursePlanVo);
             userPlanVos.setCoursePlanVo(coursePlanVo);
             List<DayStudyVo> dayStudyVos = new ArrayList<>();
             List<DayStudyVo> dayStudyVos = new ArrayList<>();
             List<DayStudyVo> finalDayStudyVos = dayStudyVos;
             List<DayStudyVo> finalDayStudyVos = dayStudyVos;
+
+            coursePlanVo.stream().forEach(s -> {
+                //更新当天学习节数是否已经完成
+                int studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(),s.getCourseId(),getTimesmorning(),getTimesnight());
+                if (studyCount > 0){
+                    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.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 -> {
+                        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(2);
+                                    }
+                                    if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate()== cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 1){
+                                        d.setPerform(0);
+                                    }
+                                });
+                    });
+                }
+                UserPlan userPlan1 = new UserPlan();
+                userPlan1.setPlanId(s.getPlanId());
+                String calendar = JSON.toJSONString(calendarStudyVos);
+                userPlan1.setSchedule(calendar);
+                userPlan1.setUpdateTime(DateUtils.getNowTime());
+                baseMapper.updateById(userPlan1);
+            });
+
             calendarStudyVos.stream().filter(c -> c.getMonth() == (cal.get(Calendar.MONTH)+1))
             calendarStudyVos.stream().filter(c -> c.getMonth() == (cal.get(Calendar.MONTH)+1))
                    .forEach(c -> {
                    .forEach(c -> {
                        finalDayStudyVos.addAll(c.getDayStudyList().stream()
                        finalDayStudyVos.addAll(c.getDayStudyList().stream()
@@ -1032,4 +1099,36 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         return result-1;
         return result-1;
     }
     }
 
 
+    //获得今天时间的0点
+    public static int getTimesmorning(){
+        Calendar cal = Calendar.getInstance();
+
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+
+        cal.set(Calendar.SECOND, 0);
+
+        cal.set(Calendar.MINUTE, 0);
+
+        cal.set(Calendar.MILLISECOND, 0);
+
+        return (int) (cal.getTimeInMillis()/1000);
+
+    }
+
+    //获得当天24点时间
+    public static int getTimesnight(){
+        Calendar cal = Calendar.getInstance();
+
+        cal.set(Calendar.HOUR_OF_DAY, 24);
+
+        cal.set(Calendar.SECOND, 0);
+
+        cal.set(Calendar.MINUTE, 0);
+
+        cal.set(Calendar.MILLISECOND, 0);
+
+        return (int) (cal.getTimeInMillis()/1000);
+
+    }
+
 }
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -131,4 +131,9 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
         }
         }
         return this.removeByIds(ids);
         return this.removeByIds(ids);
     }
     }
+
+    @Override
+    public int selectUserStudy(Long userId, Long courseId, int timesMorning, int timesNight) {
+        return baseMapper.selectUserStudy(userId,courseId,timesMorning,timesNight);
+    }
 }
 }

+ 14 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -34,4 +34,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
 
 
     </select>
     </select>
+
+    <select id="selectUserStudy" parameterType="map"  resultType="integer">
+        select COUNT(user_id) FROM user_study_record where 1=1
+        <if test="userId != null and userId != ''">
+            and user_id =#{userId}
+        </if>
+        <if test="courseId != null and courseId != ''">
+            AND course_id =#{courseId}
+        </if>
+        <if test="startTime != null and startTime != ''">
+        and create_time BETWEEN #{startTime} and #{endTime}
+        </if>
+        and study_duration > 360
+    </select>
 </mapper>
 </mapper>