浏览代码

Merge remote-tracking branch 'origin/saas' into saas

zouxuan 3 年之前
父节点
当前提交
e96d60544b
共有 21 个文件被更改,包括 566 次插入494 次删除
  1. 17 8
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java
  2. 6 4
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupTeacherMapperDao.java
  3. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java
  4. 28 5
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java
  5. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupStudentMapperDto.java
  6. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroup.java
  7. 28 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentExtracurricularExercisesSituation.java
  8. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/TemplateTypeEnum.java
  9. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java
  10. 3 4
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentServeService.java
  11. 19 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java
  12. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  13. 227 357
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java
  14. 18 0
      mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml
  15. 6 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml
  16. 3 7
      mec-biz/src/main/resources/config/mybatis/StudentMapper.xml
  17. 8 0
      mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml
  18. 51 23
      mec-web/src/main/java/com/ym/mec/web/controller/ImportController.java
  19. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java
  20. 二进制
      mec-web/src/main/resources/excelTemplate/外部学生入团导入模板.xls
  21. 98 78
      mec-web/src/main/resources/logback-spring.xml

+ 17 - 8
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -1,20 +1,27 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.biz.dal.dto.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.ym.mec.biz.dal.dto.BaseMapDto;
+import com.ym.mec.biz.dal.dto.ClassGroupStudentInfoDto;
+import com.ym.mec.biz.dal.dto.ClassGroupStudentMapperDto;
+import com.ym.mec.biz.dal.dto.StudentAttendanceViewDto;
+import com.ym.mec.biz.dal.dto.StudentEduTeacherDto;
+import com.ym.mec.biz.dal.dto.StudentNameAndPhoneDto;
+import com.ym.mec.biz.dal.dto.TeacherClassStudentDto;
 import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
-import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.TeachTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStudentMapper> {
 
@@ -479,4 +486,6 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      */
     List<ClassGroup> getStudentClassGroupWithTeacher(@Param("studentIds") Set<Integer> studentIds,
                                                      @Param("teacherId") Integer teacherId);
+    
+    List<ClassGroupStudentMapperDto> queryByClassGroupType(@Param("musicGroupId") String musicGroupId,@Param("classGroupType") ClassGroupTypeEnum classGroupType,@Param("teacherRole") TeachTypeEnum teacherRole, @Param("studentIdList") List<Integer> studentIdList);
 }

+ 6 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupTeacherMapperDao.java

@@ -1,14 +1,16 @@
 package com.ym.mec.biz.dal.dao;
 
+import java.util.List;
+import java.util.Set;
+
+import org.apache.ibatis.annotations.Param;
+
 import com.ym.mec.biz.dal.dto.ClassGroupTeacherMapDto;
 import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.TeachTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Set;
 
 public interface ClassGroupTeacherMapperDao extends BaseDAO<Long, ClassGroupTeacherMapper> {
 

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java

@@ -102,7 +102,7 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
     List<StudentServeCourseDto> getServeStudentCourseStartTimes(@Param("monday") String monday, @Param("tenantId") Integer tenantId);
 
     List<StudentServeCourseDto> getStudentFutureCourseInfo(@Param("monday") String monday,
-                                                           @Param("nextMonday") String nextMonday,
+                                                           @Param("sunday") String sunday,
                                                            @Param("studentIds") List<Integer> studentIds, @Param("tenantId") Integer tenantId);
 
     List<StudentServeCourseDto> getNoCourseBeServeStudentInfo(@Param("studentIds") List<Integer> noCourseStudentIds, @Param("tenantId") Integer tenantId);

+ 28 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java

@@ -1,16 +1,37 @@
 package com.ym.mec.biz.dal.dao;
 
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.*;
-
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import org.apache.ibatis.annotations.Param;
 
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.Mapper;
+import com.ym.mec.biz.dal.dto.MusicGroupRegAndMoneyDto;
+import com.ym.mec.biz.dal.dto.NoClassMusicStudentDto;
+import com.ym.mec.biz.dal.dto.OrderStatisDto;
+import com.ym.mec.biz.dal.dto.RegisterDto;
+import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
+import com.ym.mec.biz.dal.dto.StudentClassInfoDto;
+import com.ym.mec.biz.dal.dto.StudentFeeDetailDto;
+import com.ym.mec.biz.dal.dto.StudentInfo;
+import com.ym.mec.biz.dal.dto.StudentMusicDetailDto;
+import com.ym.mec.biz.dal.dto.StudentMusicGroupDto;
+import com.ym.mec.biz.dal.dto.StudentRegisterInstrumentsDetailDto;
+import com.ym.mec.biz.dal.dto.StudentRegisterPerDto;
+import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
+import com.ym.mec.biz.dal.dto.UserGroupDto;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.common.dal.BaseDAO;
 
 public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistration> {
@@ -738,4 +759,6 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
     * @date 2022/3/16 14:10
     */
     List<Map<Integer,String>> getLastMusicGroupName(@Param("userIds") List<Integer> userIds);
+    
+    List<StudentRegistration> queryServiceStudentByMusicGroupStatus(@Param("nextMonday") String nextMonday,@Param("tenantId") Integer tenantId);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupStudentMapperDto.java

@@ -9,6 +9,8 @@ public class ClassGroupStudentMapperDto extends ClassGroupStudentMapper {
 
     @ApiModelProperty(value = "科目名称(声部名称)",required = true)
     private String subjectName;
+    
+    private Integer teacherId;
 
     public Integer actualSubjectId() {
         return actualSubjectId;
@@ -25,4 +27,12 @@ public class ClassGroupStudentMapperDto extends ClassGroupStudentMapper {
     public void setSubjectName(String subjectName) {
         this.subjectName = subjectName;
     }
+
+	public Integer getTeacherId() {
+		return teacherId;
+	}
+
+	public void setTeacherId(Integer teacherId) {
+		this.teacherId = teacherId;
+	}
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroup.java

@@ -8,6 +8,7 @@ import java.util.Date;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.ym.mec.biz.dal.entity.CooperationOrgan.OwnershipType;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.SalarySettlementTypeEnum;
@@ -202,6 +203,8 @@ public class MusicGroup extends BaseEntity {
 	
 	@ApiModelProperty(value = "是否赠送辅件",required = false)
 	private Boolean isGiveAccessories;
+	
+	private ClassGroupTypeEnum extracurricularTeacher;
 
 	public Integer getHasInstrumentNum() {
 		return hasInstrumentNum;
@@ -700,4 +703,12 @@ public class MusicGroup extends BaseEntity {
 	public void setIsGiveAccessories(Boolean isGiveAccessories) {
 		this.isGiveAccessories = isGiveAccessories;
 	}
+
+	public ClassGroupTypeEnum getExtracurricularTeacher() {
+		return extracurricularTeacher;
+	}
+
+	public void setExtracurricularTeacher(ClassGroupTypeEnum extracurricularTeacher) {
+		this.extracurricularTeacher = extracurricularTeacher;
+	}
 }

+ 28 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentExtracurricularExercisesSituation.java

@@ -228,6 +228,34 @@ public class StudentExtracurricularExercisesSituation extends BaseEntity {
 	}
 
 	@Override
+	public int hashCode() {
+		Object[] objs = { monday, studentId, teacherId, serveType };
+		int result = 1;
+		for (Object obj : objs) {
+			if(obj == null){
+				continue;
+			}
+			result = 31 * result + obj.hashCode();
+		}
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+
+		if (obj instanceof StudentExtracurricularExercisesSituation) {
+
+			StudentExtracurricularExercisesSituation dto = (StudentExtracurricularExercisesSituation) obj;
+
+			if (this.monday.equals(dto.getMonday()) && this.studentId.intValue() == dto.getStudentId() && this.teacherId.intValue() == dto.getTeacherId()
+					&& this.serveType.equals(dto.getServeType())) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/TemplateTypeEnum.java

@@ -7,7 +7,8 @@ public enum TemplateTypeEnum implements BaseEnum<String, TemplateTypeEnum> {
     ROUTE_ORDER("ROUTE_ORDER","财务管理导入模板"),
     FINANCIAL_EXPENDITURE("FINANCIAL_EXPENDITURE","财务支出导入模板"),
     REDEMPTIONCODE("REDEMPTION_CODE", "兑换码分配模板表"),
-    OA_QUIT_MUSIC_GROUP("OA_QUIT_MUSIC_GROUP", "乐团退费模板");
+    OA_QUIT_MUSIC_GROUP("OA_QUIT_MUSIC_GROUP", "乐团退费模板"),
+    EXTERNAL_STUDENT_IMPORT_MUSIC_GROUP("EXTERNAL_STUDENT_IMPORT_MUSIC_GROUP", "外部学生导入乐团模板");
 
     private String code;
 

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java

@@ -18,6 +18,15 @@ import java.util.Map;
 import java.util.Set;
 
 public interface MusicGroupService extends BaseService<String, MusicGroup> {
+	
+	/**
+	 * 将学生导入至乐团中
+	 * @param musicGroupId
+	 * @param excelData
+	 * @return
+	 */
+	boolean importStudentToMusicGroup(String musicGroupId, Map<String, List<Map<String, Object>>> excelData);
+	
     /**
      * 建团申请数据提交
      *

+ 3 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/StudentServeService.java

@@ -1,13 +1,12 @@
 package com.ym.mec.biz.service;
 
-import com.ym.mec.biz.dal.dto.IndexBaseDto;
-import org.apache.ibatis.annotations.Param;
-
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.ym.mec.biz.dal.dto.IndexBaseDto;
+
 /**
  * @Author Joburgess
  * @Date 2020.05.27
@@ -23,7 +22,7 @@ public interface StudentServeService {
      */
     void exercisesSituationStatistics(String monday, Integer tenantId);
 
-    void exercisesSituationStatistics2(String monday, List<Integer> studentIds, Integer tenantId);
+    void exercisesSituationStatistics2(String monday, Integer tenantId);
 
     /**
      * @describe

+ 19 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java

@@ -43,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.io.Serializable;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.function.BiConsumer;
 import java.util.stream.Collectors;
 
@@ -81,6 +82,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
     public static final String LIVE_SPEAKER_INFO = "IM:LIVE_SPEAKER_INFO:" + USER_ID;
     //用户对应的直播间Uid
     public static final String LIVE_USER_ROOM = "IM:LIVE_ROOM_USER:" + USER_ID;
+    //记录人员最后变更的状态消息时间
+    public static final String LIVE_USER_STATE_TIME = "IM:LIVE_USER_STATE_TIME:" + USER_ID;
     //房间点赞数
     public static final String LIVE_ROOM_LIKE = "IM:LIVE_ROOM_LIKE:" + ROOM_UID;
     //直播提前开始时间
@@ -443,8 +446,21 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 return;
             }
             Date now = new Date();
+            //获取当前用户状态变更的时间
+            long userStateTime = Optional.ofNullable(user.getTime()).orElse(now.getTime());
+            String userid = user.getUserid();
+            RBucket<Long> userStateTimeCache = redissonClient.getBucket(LIVE_USER_STATE_TIME.replace(USER_ID, userid));
+            if (userStateTimeCache.isExists()) {
+                //缓存的时间比当前传入时间大则放弃这条数据
+                long cacheTime = userStateTimeCache.get();
+                if (cacheTime > userStateTime) {
+                    return;
+                }
+            }
+            //将最新的时间写入缓存
+            userStateTimeCache.set(userStateTime,5L, TimeUnit.MINUTES);
             //查询主讲人userId,若是主讲人
-            RBucket<RoomSpeakerInfo> speakerCache = redissonClient.getBucket(LIVE_SPEAKER_INFO.replace(USER_ID, user.getUserid()));
+            RBucket<RoomSpeakerInfo> speakerCache = redissonClient.getBucket(LIVE_SPEAKER_INFO.replace(USER_ID, userid));
             if (speakerCache.isExists()) {
                 RoomSpeakerInfo speakerInfo = speakerCache.get();
                 //主讲人进入房间
@@ -466,12 +482,12 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 return;
             }
             //获取当前用户所在房间的uid
-            RBucket<String> userRoom = redissonClient.getBucket(LIVE_USER_ROOM.replace(USER_ID, user.getUserid()));
+            RBucket<String> userRoom = redissonClient.getBucket(LIVE_USER_ROOM.replace(USER_ID, userid));
             if (!userRoom.isExists()) {
                 return;
             }
             String roomUid = userRoom.get();
-            Integer userId = Integer.valueOf(user.getUserid());
+            Integer userId = Integer.valueOf(userid);
 
             //从房间累计用户信息中查询该用户的信息
             RMap<Integer, RoomUserInfoVo> roomTotalUser = redissonClient.getMap(LIVE_ROOM_TOTAL_USER_LIST.replace(ROOM_UID, roomUid));

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -32,6 +32,7 @@ import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
 import com.ym.mec.util.json.JsonUtil;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -203,6 +204,25 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     }
 
     @Override
+	public boolean importStudentToMusicGroup(String musicGroupId, Map<String, List<Map<String, Object>>> excelData) {
+    	
+    	MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+    	
+    	if(musicGroup == null){
+    		throw new BizException("乐团[{}]信息查询失败", musicGroupId);
+    	}
+    	
+    	if(musicGroup.getStatus() != MusicGroupStatusEnum.PAY){
+    		throw new BizException("只有[缴费中]状态的乐团才能导入数据");
+    	}
+    	
+    	//查询缴费金额是否是0
+    	
+    	
+		return false;
+	}
+
+	@Override
     @Transactional(rollbackFor = Exception.class)
     public String createGroup(SubFeeSettingDto subFeeSettingDto) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();

+ 227 - 357
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -1,33 +1,70 @@
 package com.ym.mec.biz.service.impl;
 
-import com.alibaba.fastjson.JSON;
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.*;
-import com.ym.mec.biz.service.StudentServeService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysTenantConfigService;
-import com.ym.mec.common.exception.BizException;
-import com.ym.mec.common.tenant.TenantContextHolder;
-import com.ym.mec.util.date.DateUtil;
-
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
-
 import java.math.BigDecimal;
 import java.time.DayOfWeek;
 import java.time.Instant;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
 import java.util.stream.Collectors;
 
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import com.alibaba.fastjson.JSON;
+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
+import com.ym.mec.biz.dal.dao.ExtracurricularExercisesReplyDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentExtracurricularExercisesSituationDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.dto.ClassGroupStudentMapperDto;
+import com.ym.mec.biz.dal.dto.IndexBaseDto;
+import com.ym.mec.biz.dal.dto.StudentServeCourseDto;
+import com.ym.mec.biz.dal.dto.StudentServeCourseHomeworkDto;
+import com.ym.mec.biz.dal.dto.StudentServeDto;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
+import com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply;
+import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.StudentCourseHomework;
+import com.ym.mec.biz.dal.entity.StudentExtracurricularExercisesSituation;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.IndexDataType;
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
+import com.ym.mec.biz.dal.enums.TeachTypeEnum;
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+import com.ym.mec.biz.service.StudentServeService;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.biz.service.SysTenantConfigService;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.tenant.TenantContextHolder;
+import com.ym.mec.util.date.DateUtil;
+
 /**
  * @Author Joburgess
  * @Date 2020.05.27
@@ -57,7 +94,7 @@ public class StudentServeServiceImpl implements StudentServeService {
     private MusicGroupDao musicGroupDao;
     @Autowired
     private StudentRegistrationDao studentRegistrationDao;
-
+    
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void exercisesSituationStatistics(String monday, Integer tenantId) {
@@ -301,11 +338,15 @@ public class StudentServeServiceImpl implements StudentServeService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void exercisesSituationStatistics2(String monday, List<Integer> studentIds, Integer tenantId) {
+    public void exercisesSituationStatistics2(String monday, Integer tenantId) {
         LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
         
+        //统计上周的服务指标总数
         int preWeekServiceNum = studentExtracurricularExercisesSituationDao.countWeekServiceNum(nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue()).plusDays(-7).toString(), tenantId);
+        
+        //统计上周数据今日更新的条数
         int lastWeekTodayUpdateNum = studentExtracurricularExercisesSituationDao.findLastWeekTodayUpdateNum(nowDate.plusDays(-nowDate.getDayOfWeek().getValue()).toString(), tenantId);
+        
         if(preWeekServiceNum>0 && lastWeekTodayUpdateNum<=0){
             nowDate = nowDate.plusDays(-nowDate.getDayOfWeek().getValue());
         }
@@ -317,6 +358,19 @@ public class StudentServeServiceImpl implements StudentServeService {
         LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
         LocalDate sunDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
         Date nextMonday = Date.from(sunDayDate.plusDays(1).atStartOfDay(DateUtil.zoneId).toInstant());
+        
+        /**
+         * 学员在读才生成服务指标,若本周有声部课或合奏课,则布置课后训练;否则,布置课外训练(课外训练看是指定由哪个班级的老师来布置)
+         * 学员在每一个进行中的乐团,且已开始上课都需要布置作业
+         */
+        
+        //查询进行中乐团在读的学生列表
+        List<StudentRegistration> studentRegistrationList = studentRegistrationDao.queryServiceStudentByMusicGroupStatus(DateUtil.dateToString(nextMonday, "yyyy-MM-dd"), tenantId);
+        if(studentRegistrationList == null || studentRegistrationList.size() == 0){
+        	return;
+        }
+        
+        List<Integer> studentIds = studentRegistrationList.stream().map(t -> t.getUserId()).distinct().collect(Collectors.toList());
 
         Set<String> holidayDays = new HashSet<>();
         String holidaySetting = sysTenantConfigService.getTenantConfigValue(SysConfigService.HOLIDAY_SETTING,tenantId);
@@ -333,303 +387,164 @@ public class StudentServeServiceImpl implements StudentServeService {
             everyDay = everyDay.plusDays(1);
         }
 
+        //节假日不产生服务指标
         if(weekInHoliday){
             studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), studentIds);
             return;
         }
-
-//        int weekServiceNum = studentExtracurricularExercisesSituationDao.countWeekServiceNum(monDayDate.toString());
-//        if(weekServiceNum>0&&CollectionUtils.isEmpty(studentIds)){
-//            return;
-//        }
-
-        //查询需要生成服务指标的学员
-        List<StudentServeCourseDto> studentFutureCourseInfo = studentDao.getStudentFutureCourseInfo(monDayDate.toString(), DateUtil.dateToString(nextMonday, "yyyy-MM-dd"), studentIds, tenantId);
-        if(CollectionUtils.isEmpty(studentFutureCourseInfo)){
-            return;
-        }
-        Map<Integer, List<StudentServeCourseDto>> studentCourseMap = studentFutureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId));
-        //有单技课或合奏课,且需要服务的学员
-        Set<Integer> musicCourseStudentIds = studentFutureCourseInfo.stream().filter(s -> CourseSchedule.CourseScheduleType.SINGLE.equals(s.getType()) || CourseSchedule.CourseScheduleType.MIX.equals(s.getType())).map(StudentServeCourseDto::getStudentId).collect(Collectors.toSet());
-
-        //有课且被服务的学生
-        Set<Integer> haveCourseBeServeStudentIds = studentCourseMap.keySet();
-        //查询所有开启了服务状态的学员
-        List<Integer> allServeStudentIds = studentDao.getServeStudentIds(tenantId);
-        //没课但需要服务的学员
-        Set<Integer> noCourseServeStudentIds = allServeStudentIds.stream().filter(id -> !haveCourseBeServeStudentIds.contains(id)).collect(Collectors.toSet());
-
-        Set<Integer> musicStudentIds = new HashSet<>();
-        if(!Objects.isNull(noCourseServeStudentIds)){
-            musicStudentIds.addAll(noCourseServeStudentIds);
-        }
-        if(!CollectionUtils.isEmpty(musicCourseStudentIds)){
-            musicStudentIds.addAll(musicCourseStudentIds);
+        
+        //查询截止到本周有课的信息
+        List<StudentServeCourseDto> studentCutoffWeekCourseInfo = studentDao.getStudentFutureCourseInfo("2019-01-01", sunDayDate.toString(), studentIds, tenantId);
+        
+        Map<String,List<Integer>> musicGroupStudentIdListMap = new HashMap<String, List<Integer>>();
+        
+        Map<String, List<StudentServeCourseDto>> musicGroupStudentServiceCourseMap = studentCutoffWeekCourseInfo.stream().collect((Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId)));
+        //学员在单乐团中课程去重
+        for(Entry<String, List<StudentServeCourseDto>> entry : musicGroupStudentServiceCourseMap.entrySet()){
+        	musicGroupStudentIdListMap.put(entry.getKey(), entry.getValue().stream().map(t -> t.getStudentId()).distinct().collect(Collectors.toList()));
         }
-        List<StudentServeCourseDto> noCourseBeServeStudentInfo = new ArrayList<>();
-        if(!CollectionUtils.isEmpty(musicStudentIds)){
-        	//查询进行中的乐团,且需要服务的学生、老师、乐团信息
-            noCourseBeServeStudentInfo = studentDao.getNoCourseBeServeStudentInfo(new ArrayList<>(musicStudentIds), tenantId);
+        
+        //查询本周有声部或合奏的学生
+        List<StudentServeCourseDto> studentCurrentWeekCourseInfo = studentDao.getStudentFutureCourseInfo(monDayDate.toString(), sunDayDate.toString(), studentIds, tenantId);
+        Map<String, List<StudentServeCourseDto>> studentCurrentWeekCourseMap = studentCurrentWeekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
+        
+        //本周学生在不同乐团中上的第一节课
+        Map<String,Map<Integer,StudentServeCourseDto>> musicGroupStudentCurrentWeekCourseMap = new HashMap<String, Map<Integer,StudentServeCourseDto>>();
+        
+        Map<Integer,List<StudentServeCourseDto>> userCourseListMap = null;
+        Map<Integer,StudentServeCourseDto> userCourseMap = null;
+        String musicGroupId = null;
+        Optional<StudentServeCourseDto> optional = null;
+        
+        //查询学生在乐团中的第一节课
+        for(Entry<String, List<StudentServeCourseDto>> entry : studentCurrentWeekCourseMap.entrySet()){
+        	musicGroupId = entry.getKey();
+        	
+        	userCourseMap = musicGroupStudentCurrentWeekCourseMap.get(musicGroupId);
+        	if(userCourseMap == null){
+        		userCourseMap = new HashMap<Integer, StudentServeCourseDto>();
+        	}
+        	//获取学生本周所有课程
+        	userCourseListMap = entry.getValue().stream().collect(Collectors.groupingBy(StudentServeCourseDto :: getStudentId));
+        	
+        	for(Entry<Integer, List<StudentServeCourseDto>> stuCourseListEntry : userCourseListMap.entrySet()){
+            	//获取学生本周第一节课
+        		optional = stuCourseListEntry.getValue().stream().filter(dto -> (dto.getType() == CourseScheduleType.SINGLE || dto.getType() == CourseScheduleType.TRAINING_SINGLE)).min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime));
+        		if(optional.isPresent()){
+        			userCourseMap.put(stuCourseListEntry.getKey(), optional.get());
+        		}else{
+        			userCourseMap.put(stuCourseListEntry.getKey(), stuCourseListEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get());
+        		}
+        	}
+    		musicGroupStudentCurrentWeekCourseMap.put(musicGroupId, userCourseMap);
         }
-
-        Map<Integer, Set<String>> noCourseStudentMusicIdsMap = noCourseBeServeStudentInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId, Collectors.mapping(StudentServeCourseDto::getMusicGroupId, Collectors.toSet())));
-        Map<Integer, List<StudentServeCourseDto>> noCourseStudentCourseMap = noCourseBeServeStudentInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId));
-
-        List<StudentExtracurricularExercisesSituation> results=new ArrayList<>();
-
-        for (Map.Entry<Integer, List<StudentServeCourseDto>> studentCourseMapEntry : studentCourseMap.entrySet()) {
-            Map<CourseSchedule.CourseScheduleType, List<StudentServeCourseDto>> typeCourseMap = studentCourseMapEntry.getValue().stream().collect(Collectors.groupingBy(StudentServeCourseDto::getType));
-            
-            Integer userId = studentCourseMapEntry.getKey();
-            
-            Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(studentCourseMapEntry.getKey());
-            if(Objects.isNull(musicGroupIds)){
-                musicGroupIds = new HashSet<>();
-            }
-            //查询用户在指定乐团截止本周末的课程数
-            List<Mapper> mapperList = new ArrayList<Mapper>();
-            if(musicGroupIds.size() > 0){
-            	mapperList = courseScheduleStudentPaymentDao.queryUserMusicGroupCourseNumByClassTime(GroupType.MUSIC, musicGroupIds, userId, new Date(0, 1, 1), LocalDateToUdate(sunDayDate));
-            }
-            Map<Object, Object> map = mapperList.stream().collect(Collectors.toMap(Mapper :: getKey, Mapper :: getValue));
-            
-            //是否在乐团生成服务指标
-            boolean isServiceWithMusicGroup = false;
-            //判断截止本周末是否有乐团课
-            for(Mapper m : mapperList){
-            	if((long)m.getValue() > 0){
-            		isServiceWithMusicGroup = true;
-            	}
-            }
-            
-            //有未上的单技课
-            if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.SINGLE) && isServiceWithMusicGroup){
-                
-                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>> teacherNotOverCourseIds = new HashMap<>();
-                    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());
-                        }
-                        
-                        //学生在当前乐团没有上过课,就不需要生成服务指标
-                        if(map.get(groupCourseInfoEntry.getKey()) != null && (long)map.get(groupCourseInfoEntry.getKey()) == 0){
-                        	continue;
-                        }
-                        
-                        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());
-
-                        if(!teacherNotOverCourseIds.containsKey(courseInfo.getActualTeacherId())){
-                            teacherNotOverCourseIds.put(courseInfo.getActualTeacherId(), new HashSet<>());
-                        }
-                        if(!CourseStatusEnum.OVER.equals(courseInfo.getStatus())){
-                            teacherNotOverCourseIds.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());
-                        studentExtracurricularExercisesSituation.setNotOverCourseIds(StringUtils.join(teacherNotOverCourseIds.get(teacherServiceCourseIdMapEntry.getKey()), ","));
-                        studentExtracurricularExercisesSituation.setNotOverCourseNum(teacherNotOverCourseIds.get(teacherServiceCourseIdMapEntry.getKey()).size());
-                        results.add(studentExtracurricularExercisesSituation);
-                    }
-                }
-                if(CollectionUtils.isEmpty(musicGroupIds)){
-                    continue;
-                }
-                Map<Integer, Integer> teacherNumMap = new HashMap<>();
-                for (String groupId : musicGroupIds) {
-                    Integer teacherId = null;
-                    List<BaseMapDto<Integer, Integer>> studentTeacherIdList = classGroupStudentMapperDao.getStudentClassGroupBishopTeacherMap(Arrays.asList(studentCourseMapEntry.getKey()), groupId);
-                    if(!CollectionUtils.isEmpty(studentTeacherIdList)){
-                        teacherId = studentTeacherIdList.get(0).getValue();
-                    }
-                    teacherId = Objects.isNull(teacherId)?noCourseStudentCourseMap.get(studentCourseMapEntry.getKey()).get(0).getLeadTeacherId():teacherId;
-                    if(Objects.isNull(teacherId)){
-                        continue;
-                    }
-
-                    if(!teacherNumMap.containsKey(teacherId)){
-                        teacherNumMap.put(teacherId, 1);
-                    }else{
-                        teacherNumMap.put(teacherId, teacherNumMap.get(teacherId)+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 if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.VIP)){ //有未上的VIP
-                List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP);
-                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
-                if(CollectionUtils.isEmpty(weekCourseInfo)){
-                    Map<Integer, List<StudentServeCourseDto>> teacherCourseMap = futureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getActualTeacherId));
-                    for (Integer teacherId : teacherCourseMap.keySet()) {
-                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-                                teacherId,nowDate.get(DateUtil.weekFields.weekOfYear()),
-                                DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
-                                "EXERCISE", null);
-                        results.add(studentExtracurricularExercisesSituation);
-                    }
-                }else{
-                    Map<Integer, List<StudentServeCourseDto>> teacherCourseMap = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getActualTeacherId));
-                    for (Map.Entry<Integer, List<StudentServeCourseDto>> teacherCourseMapEntry : teacherCourseMap.entrySet()) {
-                        StudentServeCourseDto courseInfo = teacherCourseMapEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
-                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation;
-                        if(TeachModeEnum.OFFLINE.equals(courseInfo.getTeachMode())){
-                            studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-                                    teacherCourseMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
-                                    DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
-                                    "EXERCISE", null);
-                        }else{
-                            studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-                                    teacherCourseMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
-                                    DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
-                                    "HOMEWORK", String.valueOf(courseInfo.getCourseScheduleId()));
-                            if(!CourseStatusEnum.OVER.equals(courseInfo.getStatus())){
-                                studentExtracurricularExercisesSituation.setNotOverCourseIds(String.valueOf(courseInfo.getCourseScheduleId()));
-                                studentExtracurricularExercisesSituation.setNotOverCourseNum(1);
-                            }
-                        }
-                        results.add(studentExtracurricularExercisesSituation);
-                    }
-                }
-            }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.MIX)){//有未上的合奏课
-                
-                Map<Integer, Integer> teacherNumMap = new HashMap<>();
-                for (String groupId : musicGroupIds) {
-                	
-                    //学生在当前乐团没有上过课,就不需要生成服务指标
-                    if(map.get(groupId) == null || (long)map.get(groupId) == 0){
-                    	continue;
-                    }
+        
+        StudentServeCourseDto studentServeCourseDto = null;
+        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation = null;
+        List<StudentExtracurricularExercisesSituation> results=new ArrayList<StudentExtracurricularExercisesSituation>();
+        
+        Map<Integer,Map<Integer,Set<Long>>> studentTeacherCourseMap = new HashMap<Integer, Map<Integer,Set<Long>>>();
+        Map<Integer,Map<Integer,Set<Long>>> studentTeacherNotOverCourseMap = new HashMap<Integer, Map<Integer,Set<Long>>>();
+        Map<Integer,Map<Integer,Integer>> studentTeacherCourseNumMap = new HashMap<Integer, Map<Integer,Integer>>();
+		
+		Map<Integer, Set<Long>> teacherCourseMap = null;
+		Map<Integer, Set<Long>> teacherNotOverCourseMap = null;
+		Integer teacherId = null;
+		Set<Long> courseIdList = null;
+		ClassGroupTypeEnum teacherType;
+		Map<Integer,Integer> teacherCourseNumMap = null;
+        
+        //理论上一个学生一个乐团只布置一次作业
+		for (Entry<String, List<Integer>> entry : musicGroupStudentIdListMap.entrySet()) {
+			
+			musicGroupId = entry.getKey();
+			
+			MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+			if(musicGroup == null || musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS){
+				continue;
+			}
+			Map<Integer,Integer> studentTeacherMapper = null;
+			
+			teacherType = musicGroup.getExtracurricularTeacher() == null ? ClassGroupTypeEnum.NORMAL : musicGroup.getExtracurricularTeacher();
+			List<ClassGroupStudentMapperDto> classGroupStudentMapperDtoList = classGroupStudentMapperDao.queryByClassGroupType(musicGroupId, teacherType, TeachTypeEnum.BISHOP, entry.getValue());
+			if(classGroupStudentMapperDtoList != null){
+				studentTeacherMapper = classGroupStudentMapperDtoList.stream().collect(Collectors.toMap(ClassGroupStudentMapperDto :: getUserId, ClassGroupStudentMapperDto :: getTeacherId));
+			}
+			
+			userCourseMap = musicGroupStudentCurrentWeekCourseMap.get(musicGroupId);
+			
+			for(Integer studentId : entry.getValue()){
+				//在当前乐团,学生本周是否有课
+				if(userCourseMap == null || userCourseMap.get(studentId) == null){//如果本周没课
+					
+					if(studentTeacherMapper == null || (teacherId = studentTeacherMapper.get(studentId)) == null){
+						continue;
+					}
+					
+					teacherCourseNumMap = studentTeacherCourseNumMap.get(studentId);
+					if(teacherCourseNumMap == null){
+						teacherCourseNumMap = new HashMap<Integer, Integer>();
+					}
+					teacherCourseNumMap.put(teacherId, teacherCourseNumMap.get(teacherId) == null ? 1 : teacherCourseNumMap.get(teacherId) + 1);
+					studentTeacherCourseNumMap.put(studentId, teacherCourseNumMap);
+					
+					//本周没有课,布置课外训练
+					studentExtracurricularExercisesSituation = new StudentExtracurricularExercisesSituation(studentId, teacherId,
+							nowDate.get(DateUtil.weekFields.weekOfYear()), DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(
+									sunDayDate.toString(), "yyyy-MM-dd"), "EXERCISE", null);
+					
+					
+					studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherCourseNumMap.get(teacherId));
+					if(results.contains(studentExtracurricularExercisesSituation)){
+						results.remove(studentExtracurricularExercisesSituation);
+					}
+					results.add(studentExtracurricularExercisesSituation);
+				}else{//如果本周有课
+
+					studentServeCourseDto = userCourseMap.get(studentId);
+					teacherId = studentServeCourseDto.getActualTeacherId();
+					
+					teacherCourseMap = studentTeacherCourseMap.get(studentId);
+					if(teacherCourseMap == null){
+						teacherCourseMap = new HashMap<Integer, Set<Long>>();
+					}
+					courseIdList = teacherCourseMap.get(teacherId);
+					if(courseIdList == null){
+						courseIdList = new HashSet<Long>();
+					}
+					courseIdList.add(studentServeCourseDto.getCourseScheduleId());
+					teacherCourseMap.put(teacherId, courseIdList);
+					studentTeacherCourseMap.put(studentId, teacherCourseMap);
+					
+					studentExtracurricularExercisesSituation = new StudentExtracurricularExercisesSituation(studentId, teacherId,
+							nowDate.get(DateUtil.weekFields.weekOfYear()), DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(
+									sunDayDate.toString(), "yyyy-MM-dd"), "HOMEWORK", StringUtils.join(courseIdList, ","));
+                    studentExtracurricularExercisesSituation.setExpectExercisesNum(courseIdList.size());
                     
-                    Integer teacherId = null;
-                    List<BaseMapDto<Integer, Integer>> studentTeacherIdList = classGroupStudentMapperDao.getStudentClassGroupBishopTeacherMap(Arrays.asList(studentCourseMapEntry.getKey()), groupId);
-                    if(!CollectionUtils.isEmpty(studentTeacherIdList)){
-                        teacherId = studentTeacherIdList.get(0).getValue();
-                    }
-                    teacherId = Objects.isNull(teacherId)?noCourseStudentCourseMap.get(studentCourseMapEntry.getKey()).get(0).getLeadTeacherId():teacherId;
-                    if(Objects.isNull(teacherId)){
-                        continue;
-                    }
-
-                    if(!teacherNumMap.containsKey(teacherId)){
-                        teacherNumMap.put(teacherId, 1);
-                    }else{
-                        teacherNumMap.put(teacherId, teacherNumMap.get(teacherId)+1);
+                    teacherNotOverCourseMap = studentTeacherNotOverCourseMap.get(studentId);
+					if(teacherNotOverCourseMap == null){
+						teacherNotOverCourseMap = new HashMap<Integer, Set<Long>>();
+					}
+					courseIdList = teacherNotOverCourseMap.get(teacherId);
+					if(courseIdList == null){
+						courseIdList = new HashSet<Long>();
+					}
+                    if(studentServeCourseDto.getStatus() != CourseStatusEnum.OVER){
+    					courseIdList.add(studentServeCourseDto.getCourseScheduleId());
+    					teacherNotOverCourseMap.put(teacherId, courseIdList);
+    					studentTeacherNotOverCourseMap.put(studentId, teacherCourseMap);
                     }
-
-                }
-
-                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());
+                    
+                    studentExtracurricularExercisesSituation.setNotOverCourseIds(StringUtils.join(courseIdList, ","));
+                    studentExtracurricularExercisesSituation.setNotOverCourseNum(courseIdList.size());
+					if(results.contains(studentExtracurricularExercisesSituation)){
+						results.remove(studentExtracurricularExercisesSituation);
+					}
                     results.add(studentExtracurricularExercisesSituation);
-                }
-            }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.PRACTICE)){//有未上的陪练课
-                List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE);
-                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
-                if(CollectionUtils.isEmpty(weekCourseInfo)){
-                    Set<Integer> teacherIds = futureCourseInfo.stream().map(StudentServeCourseDto::getActualTeacherId).collect(Collectors.toSet());
-                    for (Integer teacherId : teacherIds) {
-                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-                                teacherId,nowDate.get(DateUtil.weekFields.weekOfYear()),
-                                DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
-                                "EXERCISE", null);
-                        results.add(studentExtracurricularExercisesSituation);
-                    }
-                }else{
-                    Map<Integer, List<StudentServeCourseDto>> teacherCourseMap = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getActualTeacherId));
-                    Map<Integer, Set<Long>> teacherNotOverCourseIds = new HashMap<>();
-                    Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
-                    for (Map.Entry<Integer, List<StudentServeCourseDto>> teacherCourseMapEntry : teacherCourseMap.entrySet()) {
-                        StudentServeCourseDto courseInfo = teacherCourseMapEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
-                        teacherServiceCourseIdMap.put(teacherCourseMapEntry.getKey(), new HashSet<>());
-                        teacherServiceCourseIdMap.get(teacherCourseMapEntry.getKey()).add(courseInfo.getCourseScheduleId());
-
-                        if(!teacherNotOverCourseIds.containsKey(courseInfo.getActualTeacherId())){
-                            teacherNotOverCourseIds.put(courseInfo.getActualTeacherId(), new HashSet<>());
-                        }
-                        if(!CourseStatusEnum.OVER.equals(courseInfo.getStatus())){
-                            teacherNotOverCourseIds.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());
-                        studentExtracurricularExercisesSituation.setNotOverCourseIds(StringUtils.join(teacherNotOverCourseIds.get(teacherServiceCourseIdMapEntry.getKey()), ","));
-                        studentExtracurricularExercisesSituation.setNotOverCourseNum(teacherNotOverCourseIds.get(teacherServiceCourseIdMapEntry.getKey()).size());
-                        results.add(studentExtracurricularExercisesSituation);
-                    }
-                }
-            }else{
-                continue;
-            }
-        }
-
-        for (Integer noCourseServeStudentId : noCourseServeStudentIds) {
-            Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(noCourseServeStudentId);
-            if(CollectionUtils.isEmpty(musicGroupIds)){
-                continue;
-            }
-            
-            Map<Integer, Integer> teacherNumMap = new HashMap<>();
-            for (String groupId : musicGroupIds) {
-            	
-                Integer teacherId = null;
-                List<BaseMapDto<Integer, Integer>> studentTeacherIdList = classGroupStudentMapperDao.getStudentClassGroupBishopTeacherMap(Arrays.asList(noCourseServeStudentId), groupId);
-                if(!CollectionUtils.isEmpty(studentTeacherIdList)){
-                    teacherId = studentTeacherIdList.get(0).getValue();
-                }
-                teacherId = Objects.isNull(teacherId)?noCourseStudentCourseMap.get(noCourseServeStudentId).get(0).getLeadTeacherId():teacherId;
-                if(Objects.isNull(teacherId)){
-                    continue;
-                }
-
-                if(!teacherNumMap.containsKey(teacherId)){
-                    teacherNumMap.put(teacherId, 1);
-                }else{
-                    teacherNumMap.put(teacherId, teacherNumMap.get(teacherId)+1);
-                }
-
-            }
-
-            for (Map.Entry<Integer, Integer> teacherNumMapEntry : teacherNumMap.entrySet()) {
-                StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(noCourseServeStudentId,
-                        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);
-            }
-        }
+				}
+			}
+			
+		}
 
         if(!CollectionUtils.isEmpty(results)){
             List<Integer> allStudentIds = new ArrayList<>();
@@ -666,7 +581,7 @@ public class StudentServeServiceImpl implements StudentServeService {
                         .collect(Collectors.groupingBy(StudentServeCourseHomeworkDto::getUserId));
             }
 
-            List<ExtracurricularExercisesReply> allStudentExercises = extracurricularExercisesReplyDao.getStudentExercisesWithTimeZone(monDayDate.toString(), sunDayDate.toString(), new ArrayList<>(allStudentIds), TenantContextHolder.getTenantId());
+            List<ExtracurricularExercisesReply> allStudentExercises = extracurricularExercisesReplyDao.getStudentExercisesWithTimeZone(monDayDate.toString(), sunDayDate.toString(), new ArrayList<>(allStudentIds), tenantId);
             if(!CollectionUtils.isEmpty(allStudentExercises)){
                 studentExercisesMap = allStudentExercises.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getUserId));
             }
@@ -745,7 +660,7 @@ public class StudentServeServiceImpl implements StudentServeService {
                 }
             }
 
-            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), studentIds);
+            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), null);
 
             BigDecimal currentPage1=BigDecimal.ONE,
                     pageSize1=new BigDecimal(10000),
@@ -754,51 +669,6 @@ public class StudentServeServiceImpl implements StudentServeService {
 
             while (currentPage1.compareTo(totalPage1)<=0){
                 List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList());
-//                List<Integer> updateStudentIds = rows.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
-//
-//                List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), null, updateStudentIds);
-//                Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1));
-//
-//                Set<String> newCodes = rows.stream().map(StudentExtracurricularExercisesSituation::getStuAndTeaCode).collect(Collectors.toSet());
-//                for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
-//                    if(weekServiceWithStudent.getActualExercisesNum()>0||newCodes.contains(weekServiceWithStudent.getStuAndTeaCode())){
-//                        continue;
-//                    }
-//                    studentExtracurricularExercisesSituationDao.delete(weekServiceWithStudent.getId());
-//                }
-//
-//                List<StudentExtracurricularExercisesSituation> newService = new ArrayList<>();
-//                List<StudentExtracurricularExercisesSituation> updateService = new ArrayList<>();
-//                for (StudentExtracurricularExercisesSituation result : rows) {
-//                    if(codeServeMap.containsKey(result.getStuAndTeaCode())){
-//                        StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
-//                        Set<Long> courseIds = new HashSet<>();
-//                        if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
-//                            courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
-//                        }
-//                        if(StringUtils.isNotBlank(result.getCourseIds())){
-//                            courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()));
-//                        }
-//                        s.setServeType(result.getServeType());
-//                        if(s.getServeType().equals("HOMEWORK")){
-//                            s.setCourseIds(StringUtils.join(courseIds, ","));
-//                        }else{
-//                            s.setCourseIds("");
-//                        }
-//                        if(StringUtils.isBlank(s.getCourseIds())){
-//                            s.setExpectExercisesNum(1);
-//                        }else{
-//                            s.setExpectExercisesNum(courseIds.size());
-//                        }
-//                        updateService.add(s);
-//                    }else{
-//                        newService.add(result);
-//                    }
-//                }
-//                if(!CollectionUtils.isEmpty(updateService))
-//                    studentExtracurricularExercisesSituationDao.batchUpdate(updateService);
-//                if(!CollectionUtils.isEmpty(newService))
-//                    studentExtracurricularExercisesSituationDao.batchInsert(newService);
 
                 studentExtracurricularExercisesSituationDao.batchInsert(rows);
 

+ 18 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -24,6 +24,10 @@
         <result property="phone" column="phone_"/>
     </resultMap>
 
+    <resultMap id="ClassGroupStudentMapperDto" type="com.ym.mec.biz.dal.dto.ClassGroupStudentMapperDto" extends="ClassGroupStudentMapper">
+        <result property="teacherId" column="teacher_id_"/>
+    </resultMap>
+
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="ClassGroupStudentMapper">
 		SELECT * FROM class_group_student_mapper WHERE id_ = #{id} 
@@ -680,4 +684,18 @@
             AND cg.id_ IS NOT NULL
         ORDER BY cg.id_ DESC
     </select>
+    
+    <select id="queryByClassGroupType" resultMap="ClassGroupStudentMapperDto">
+    
+    	SELECT cgsm.*,cgtm.user_id_ teacher_id_ from class_group_student_mapper cgsm LEFT JOIN class_group cg on cgsm.class_group_id_ = cg.id_
+		LEFT JOIN class_group_teacher_mapper cgtm on cgsm.class_group_id_ = cgtm.class_group_id_
+		WHERE cgtm.music_group_id_ = #{musicGroupId} and cg.type_ = #{classGroupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} 
+        and cgtm.teacher_role_ = #{teacherRole,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} and cg.del_flag_ = 0 and cgsm.status_ = 'NORMAL'
+		and cgsm.user_id_ IN
+                <foreach collection="studentIdList" item="studentId" open="(" close=")" separator=",">
+                    #{studentId}
+                </foreach>
+        group by cgsm.user_id_
+        
+    </select>
 </mapper>

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -17,6 +17,7 @@
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
         <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="extracurricular_teacher_" property="extracurricularTeacher" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="bill_start_date_" property="billStartDate"/>
         <result column="improvent_classes_num_" property="improventClassesNum"/>
         <result column="enroll_classes_" property="enrollClasses"/>
@@ -107,7 +108,7 @@
                  settlement_type_, cooperation_organ_id_, enlightenment_course_time_,
                  parent_meeting_time_, img_, director_user_id_, is_classroom_lessons_, memo_, expect_start_group_date_,
                  ownership_type_, repair_user_id_, del_flag_, payment_valid_start_date_, payment_valid_end_date_,
-                 payment_pattern_, course_view_type_, transaction_teacher_id_,homework_push_flag_,member_course_show_flag_,tenant_id_,is_give_accessories_)
+                 payment_pattern_, course_view_type_, transaction_teacher_id_,homework_push_flag_,member_course_show_flag_,tenant_id_,is_give_accessories_,extracurricular_teacher_)
         VALUES (#{id}, #{name}, #{organId}, #{schoolId}, #{applyExpireDate}, #{preApplyExpireDate}, #{teamTeacherId},
                 #{educationalTeacherId},
                 #{chargeTypeId}, #{courseForm}, now(), now(),
@@ -119,7 +120,7 @@
                 #{isClassroomLessons}, #{memo}, #{expectStartGroupDate},
                 #{ownershipType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{repairUserId},
                 #{delFlag}, #{paymentValidStartDate}, #{paymentValidEndDate}, #{paymentPattern},
-                #{courseViewType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{transactionTeacherId},#{homeworkPushFlag},#{memberCourseShowFlag},#{tenantId},#{isGiveAccessories})
+                #{courseViewType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{transactionTeacherId},#{homeworkPushFlag},#{memberCourseShowFlag},#{tenantId},#{isGiveAccessories},#{extracurricularTeacher,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -234,6 +235,9 @@
             <if test="isGiveAccessories != null">
                 is_give_accessories_ = #{isGiveAccessories},
             </if>
+            <if test="extracurricularTeacher != null">
+                extracurricular_teacher_ = #{extracurricularTeacher,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>

+ 3 - 7
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -605,7 +605,6 @@
     <select id="getStudentFutureCourseInfo" resultMap="StudentServeCourseDto">
         SELECT
             cssp.user_id_ student_id_,
-            stu.teacher_id_ lead_teacher_id_,
             cs.id_ course_schedule_id_,
             cs.group_type_,
             cs.music_group_id_,
@@ -617,14 +616,11 @@
             cs.teach_mode_
         FROM course_schedule_student_payment cssp
             LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
-            LEFT JOIN student stu ON cssp.user_id_ = stu.user_id_
-        WHERE stu.service_tag_=1 and cssp.tenant_id_ = #{tenantId}
-            AND (stu.service_tag_update_time_ IS NULL OR stu.service_tag_update_time_&lt;#{nextMonday})
+        WHERE cssp.tenant_id_ = #{tenantId}
             AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
             AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
-            AND cs.class_date_&gt;=#{monday}
-            AND cs.type_ IN ('SINGLE', 'TRAINING_SINGLE', 'VIP', 'MIX', 'TRAINING_MIX', 'PRACTICE')
-            AND cssp.create_time_&lt;#{nextMonday}
+            AND cs.class_date_ between #{monday} and #{sunday}
+            AND cs.type_ IN ('SINGLE', 'TRAINING_SINGLE', 'MIX', 'TRAINING_MIX')
             <if test="studentIds!=null and studentIds.size()>0">
                 AND cssp.user_id_ IN
                 <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">

+ 8 - 0
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -1808,4 +1808,12 @@
         </foreach>
         GROUP BY sr.user_id_)
     </select>
+    
+    <select id="queryServiceStudentByMusicGroupStatus" resultMap="StudentRegistration">
+    	select sr.* from student_registration sr 
+    	left join music_group mg ON mg.id_ = sr.music_group_id_
+    	left join student s on s.user_id_ = sr.user_id_
+    	where s.service_tag_ = 1 AND (s.service_tag_update_time_ IS NULL OR s.service_tag_update_time_&lt;#{nextMonday})
+    	and sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS' and sr.tenant_id_ = #{tenantId}
+    </select>
 </mapper>

+ 51 - 23
mec-web/src/main/java/com/ym/mec/web/controller/ImportController.java

@@ -1,40 +1,55 @@
 package com.ym.mec.web.controller;
 
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.tomcat.util.http.fileupload.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.AppRedemptionCode;
 import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.enums.TemplateTypeEnum;
-import com.ym.mec.biz.service.*;
+import com.ym.mec.biz.service.AppRedemptionCodeService;
+import com.ym.mec.biz.service.FinancialExpenditureService;
+import com.ym.mec.biz.service.GoodsService;
+import com.ym.mec.biz.service.MusicGroupService;
+import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
+import com.ym.mec.biz.service.UploadFileService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.UploadReturnBean;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.util.date.DateUtil;
+import com.ym.mec.util.excel.POIUtil;
 import com.ym.mec.util.upload.UploadUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
-import org.redisson.liveobject.resolver.UUIDGenerator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.servlet.http.HttpServletResponse;
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
 
 @RequestMapping("import")
 @Api(tags = "数据导入服务")
@@ -53,6 +68,9 @@ public class ImportController extends BaseController {
     private AppRedemptionCodeService appRedemptionCodeService;
     @Autowired
     private UploadFileService uploadFileService;
+    
+    @Autowired
+    private MusicGroupService musicGroupService;
 
 
     @ApiOperation(value = "导入商品")
@@ -94,6 +112,16 @@ public class ImportController extends BaseController {
         return studentPaymentRouteOrderService.importRouteOrder(file);
     }
 
+    @ApiOperation(value = "导入学生至乐团中")
+    @PostMapping(value = "studentToMusicGroup")
+    @PreAuthorize("@pcs.hasPermissions('import/studentToMusicGroup')")
+    public HttpResponseResult<List<StudentPaymentRouteOrder>> importStudentToMusicGroup(String musicGroupId, @RequestParam("file") MultipartFile file) throws Exception {
+    	Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(file.getBytes()), 2, file.getOriginalFilename());
+        boolean result =  musicGroupService.importStudentToMusicGroup(musicGroupId, sheetsListMap);
+        
+        return result ? succeed() : failed();
+    }
+
     @PostMapping(value = "oaUploadFile")
     public Object uploadFile(@ApiParam(value = "上传的文件", required = true) @RequestParam("file") MultipartFile file,Integer processId) throws Exception {
         if (file != null && StringUtils.isNotBlank(file.getOriginalFilename())) {

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -364,7 +364,7 @@ public class TaskController extends BaseController {
 	@GetMapping("/exercisesSituationStatistics")
 	public void exercisesSituationStatistics(String monday){
 		TenantContextHolder.setTenantId(1);
-		studentServeService.exercisesSituationStatistics2(monday,null,1);
+		studentServeService.exercisesSituationStatistics2(monday,1);
 		TenantContextHolder.clearTenantId();
 //		studentServeService.exercisesSituationStatistics2(null,new ArrayList<>(Arrays.asList(1095257)));
 //		studentServeService.exercisesSituationStatistics(null);

二进制
mec-web/src/main/resources/excelTemplate/外部学生入团导入模板.xls


+ 98 - 78
mec-web/src/main/resources/logback-spring.xml

@@ -1,83 +1,103 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="10 seconds">
 
-	<property name="LOG_HOME" value="/mdata/logs/web-%d{yyyy-MM-dd_HH}-%i.log" />
-	<property name="CONSOLE_LOG_PATTERN"
-			  value="[%X{username} %X{ip} %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}] : %msg%n" />
-
-	<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
-		<encoder charset="UTF-8">
-			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
-		</encoder>
-	</appender>
-
-	<appender name="file"
-			  class="ch.qos.logback.core.rolling.RollingFileAppender">
-		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-			<FileNamePattern>${LOG_HOME}</FileNamePattern>
-			<MaxHistory>90</MaxHistory>
-			<TimeBasedFileNamingAndTriggeringPolicy
-					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
-				<MaxFileSize>20MB</MaxFileSize>
-			</TimeBasedFileNamingAndTriggeringPolicy>
-		</rollingPolicy>
-
-		<encoder>
-			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
-		</encoder>
-	</appender>
-
-	<appender name="messagefile"
-			  class="ch.qos.logback.core.rolling.RollingFileAppender">
-		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-			<FileNamePattern>/mdata/logs/web-message-%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
-			<MaxHistory>90</MaxHistory>
-			<TimeBasedFileNamingAndTriggeringPolicy
-					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
-				<MaxFileSize>20MB</MaxFileSize>
-			</TimeBasedFileNamingAndTriggeringPolicy>
-		</rollingPolicy>
-
-		<encoder>
-			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
-		</encoder>
-	</appender>
-
-	<logger name="com.ym.mec" level="INFO" />
-
-	<logger name="com.ym.mec.thirdparty" level="INFO"
-			additivity="false">
-		<appender-ref ref="messagefile" />
-	</logger>
-
-	<!--开发环境:打印控制台 -->
-	<springProfile name="dev">
-		<root level="INFO">
-			<appender-ref ref="stdout" />
-			<appender-ref ref="file" />
-		</root>
-	</springProfile>
-
-	<springProfile name="test">
-		<root level="INFO">
-			<appender-ref ref="stdout" />
-			<appender-ref ref="file" />
-		</root>
-	</springProfile>
-
-	<springProfile name="dev_server">
-		<root level="INFO">
-			<appender-ref ref="stdout" />
-			<appender-ref ref="file" />
-		</root>
-	</springProfile>
-
-	<!--生产环境:输出到文件 -->
-	<springProfile name="prod">
-		<root level="WARN">
-			<appender-ref ref="stdout" />
-			<appender-ref ref="file" />
-		</root>
-	</springProfile>
+    <property name="LOG_HOME" value="/mdata/logs/web-%d{yyyy-MM-dd_HH}-%i.log"/>
+    <property name="CONSOLE_LOG_PATTERN"
+              value="[%X{username} %X{ip} %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}] : %msg%n"/>
+
+    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="UTF-8">
+            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="file"
+              class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <FileNamePattern>${LOG_HOME}</FileNamePattern>
+            <MaxHistory>90</MaxHistory>
+            <TimeBasedFileNamingAndTriggeringPolicy
+                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <MaxFileSize>20MB</MaxFileSize>
+            </TimeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+
+        <encoder>
+            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="messagefile"
+              class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <FileNamePattern>/mdata/logs/web-message-%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
+            <MaxHistory>90</MaxHistory>
+            <TimeBasedFileNamingAndTriggeringPolicy
+                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <MaxFileSize>20MB</MaxFileSize>
+            </TimeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+
+        <encoder>
+            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="liveFile"
+              class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <FileNamePattern>/mdata/logs/web-live-%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
+            <MaxHistory>90</MaxHistory>
+            <TimeBasedFileNamingAndTriggeringPolicy
+                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <MaxFileSize>20MB</MaxFileSize>
+            </TimeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+
+        <encoder>
+            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
+        </encoder>
+    </appender>
+
+    <logger name="com.ym.mec" level="INFO"/>
+
+    <logger name="com.ym.mec.thirdparty" level="INFO" additivity="false">
+        <appender-ref ref="messagefile"/>
+    </logger>
+
+    <!--开发环境:打印控制台 -->
+    <logger name="com.ym.mec.biz.service.impl.ImLiveBroadcastRoomServiceImpl" level="INFO" additivity="false">
+        <appender-ref ref="liveFile"/>
+    </logger>
+
+    <!--开发环境:打印控制台 -->
+    <springProfile name="dev">
+        <root level="INFO">
+            <appender-ref ref="stdout"/>
+            <appender-ref ref="file"/>
+        </root>
+    </springProfile>
+
+    <springProfile name="test">
+        <root level="INFO">
+            <appender-ref ref="stdout"/>
+            <appender-ref ref="file"/>
+        </root>
+    </springProfile>
+
+    <springProfile name="dev_server">
+        <root level="INFO">
+            <appender-ref ref="stdout"/>
+            <appender-ref ref="file"/>
+        </root>
+    </springProfile>
+
+    <!--生产环境:输出到文件 -->
+    <springProfile name="prod">
+        <root level="WARN">
+            <appender-ref ref="stdout"/>
+            <appender-ref ref="file"/>
+        </root>
+    </springProfile>
 
 </configuration>