Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

zouxuan 4 vuotta sitten
vanhempi
commit
5702a76062

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/InspectionItemPlanDao.java

@@ -25,4 +25,11 @@ public interface InspectionItemPlanDao extends BaseDAO<Long, InspectionItemPlan>
      * @return
      */
     InspectionItemPlan getPlanInfo(@Param("id") Long id);
+
+    /**
+     * 获取事项时间段内乐团的计划数
+     *
+     * @return
+     */
+    int getMusicGroupItemPlanCount(@Param("itemId") Long itemId, @Param("musicGroupId") String musicGroupId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
 }

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/InspectionItemPlanServiceImpl.java

@@ -87,6 +87,13 @@ public class InspectionItemPlanServiceImpl extends BaseServiceImpl<Long, Inspect
         if (itemEndTime.before(inspectionItemPlan.getPlanEnd())) {
             throw new BizException("日程时间不能晚于工作周期结束时间");
         }
+        //事项计划同一乐团同一天不能重复
+        Date dayStartTime = DateUtil.trunc(inspectionItemPlan.getPlanStart());
+        Date dayEndTime = DateUtil.trunc(inspectionItemPlan.getPlanStart());
+        int dayMusicGroupItemPlanCount = inspectionItemPlanDao.getMusicGroupItemPlanCount(inspectionItemPlan.getItemId(), inspectionItemPlan.getMusicGroupId(), dayStartTime, dayEndTime);
+        if(dayMusicGroupItemPlanCount > 0){
+            throw new BizException("该乐团当天已有巡查安排,请核查");
+        }
         //获取乐团教学点的GPS信息
         MusicGroup musicGroup = musicGroupDao.get(inspectionItemPlan.getMusicGroupId());
         School school = schoolDao.get(musicGroup.getSchoolId());
@@ -154,7 +161,7 @@ public class InspectionItemPlanServiceImpl extends BaseServiceImpl<Long, Inspect
         Date nowDate = new Date();
         Date startTime = DateUtil.getFirstDayOfMonth(nowDate);
         Date endTime = DateUtil.getLastTimeWithDay(DateUtil.getLastDayOfMonth(nowDate));
-        List<InspectionItemPlan> startPlans = inspectionItemPlanDao.getStartPlan(startTime,endTime);
+        List<InspectionItemPlan> startPlans = inspectionItemPlanDao.getStartPlan(startTime, endTime);
         Set<Integer> userIds = startPlans.stream().map(InspectionItemPlan::getUserId).collect(Collectors.toSet());
         //发送推送信息
         Map<Integer, String> userMap = new HashMap<>();

+ 26 - 45
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -370,52 +370,33 @@ public class StudentServeServiceImpl implements StudentServeService {
             Map<CourseSchedule.CourseScheduleType, List<StudentServeCourseDto>> typeCourseMap = studentCourseMapEntry.getValue().stream().collect(Collectors.groupingBy(StudentServeCourseDto::getType));
 
             if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.SINGLE)){
-
-//                List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE);
-//                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
-//                if(CollectionUtils.isEmpty(weekCourseInfo)){
-//                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = futureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
-//
-//                    Map<Integer, Integer> teacherNumMap = new HashMap<>();
-//                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
-//                        StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
-//
-//                        if(!teacherNumMap.containsKey(courseInfo.getActualTeacherId())){
-//                            teacherNumMap.put(courseInfo.getActualTeacherId(), 1);
-//                        }else{
-//                            teacherNumMap.put(courseInfo.getActualTeacherId(), teacherNumMap.get(courseInfo.getActualTeacherId())+1);
-//                        }
-//                    }
-//
-//                    for (Map.Entry<Integer, Integer> teacherNumMapEntry : teacherNumMap.entrySet()) {
-//                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-//                                teacherNumMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
-//                                DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
-//                                "EXERCISE", null);
-//                        studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherNumMapEntry.getValue());
-//                        results.add(studentExtracurricularExercisesSituation);
-//                    }
-//                }else{
-//                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
-//                    Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
-//                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
-//                        StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
-//                        if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
-//                            teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
-//                        }
-//                        teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
-//                    }
-//                    for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
-//                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-//                                teacherServiceCourseIdMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
-//                                DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
-//                                "HOMEWORK", StringUtils.join(teacherServiceCourseIdMapEntry.getValue(), ","));
-//                        studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherServiceCourseIdMapEntry.getValue().size());
-//                        results.add(studentExtracurricularExercisesSituation);
-//                    }
-//                }
-
                 Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(studentCourseMapEntry.getKey());
+                if(Objects.isNull(musicGroupIds)){
+                    musicGroupIds = new HashSet<>();
+                }
+
+                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
+                if(!CollectionUtils.isEmpty(weekCourseInfo)){
+                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
+                    Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
+                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
+                        if(musicGroupIds.contains(groupCourseInfoEntry.getKey()))
+                            musicGroupIds.remove(groupCourseInfoEntry.getKey());
+                        StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
+                        if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
+                            teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
+                        }
+                        teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
+                    }
+                    for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
+                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
+                                teacherServiceCourseIdMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
+                                DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
+                                "HOMEWORK", StringUtils.join(teacherServiceCourseIdMapEntry.getValue(), ","));
+                        studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherServiceCourseIdMapEntry.getValue().size());
+                        results.add(studentExtracurricularExercisesSituation);
+                    }
+                }
                 if(CollectionUtils.isEmpty(musicGroupIds)){
                     continue;
                 }

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -357,7 +357,7 @@
 			AND m.group_type_ IN ('VIP', 'PRACTICE')
 			AND m.status_ = 'NOT_START'
 			<if test="dayStr!=null and dayStr!=''">
-				AND (DATE_FORMAT(m.create_time_, '%Y-%m-%d') &lt;= #{dayStr} OR YEAR(m.create_time_)=3000)
+				AND (DATE_FORMAT(s.create_time_, '%Y-%m-%d') &lt;= #{dayStr} OR YEAR(m.create_time_)=3000)
 			</if>
 		GROUP BY
 			su.organ_id_

+ 13 - 1
mec-biz/src/main/resources/config/mybatis/InspectionItemPlanMapper.xml

@@ -184,7 +184,8 @@
         FROM inspection_item_plan
         WHERE plan_start_ >= #{startTime}
           AND plan_start_ <= #{endTime}
-        ]]></select>
+        ]]>
+    </select>
 
     <select id="getPlanInfo" resultMap="InspectionItemPlan">
         SELECT iip.*, su.real_name_ realName, o.name_ organName, co.name_ cooperationName, mg.name_ musicGroupName
@@ -195,4 +196,15 @@
                  LEFT JOIN music_group mg ON mg.id_ = iip.music_group_id_
         WHERE iip.id_ = #{id}
     </select>
+
+    <select id="getMusicGroupItemPlanCount" resultType="int">
+        <![CDATA[
+        SELECT COUNT(*)
+        FROM inspection_item_plan
+        WHERE music_group_id_ = #{musicGroupId}
+          AND item_id_ = #{itemId}
+          AND plan_start_ >= #{startTime}
+          AND plan_start_ <= #{endTime}
+        ]]>
+    </select>
 </mapper>