Browse Source

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

# Conflicts:
#	mec-common/audit-log/pom.xml
Joburgess 4 years ago
parent
commit
97d0851ce5
21 changed files with 866 additions and 105 deletions
  1. 45 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentMusicScoreDao.java
  2. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java
  3. 96 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleStudentMusicScore.java
  4. 8 8
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentRegistration.java
  5. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentMusicScoreService.java
  6. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentMusicScoreServiceImpl.java
  7. 127 0
      mec-biz/src/main/resources/config/mybatis/courseScheduleStudentMusicScoreMapper.xml
  8. 6 0
      mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java
  9. 5 0
      mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java
  10. 7 7
      mec-common/audit-log/pom.xml
  11. 26 36
      mec-im/src/main/java/com/ym/controller/RoomController.java
  12. 43 0
      mec-im/src/main/java/com/ym/mec/im/message/MusicScoreDownloadMessageMessage.java
  13. 24 0
      mec-im/src/main/java/com/ym/mec/im/message/MusicScoreDownloadStatusMessage.java
  14. 2 3
      mec-im/src/main/java/com/ym/pojo/DeviceTypeEnum.java
  15. 49 0
      mec-im/src/main/java/com/ym/pojo/MusicScoreData.java
  16. 153 0
      mec-im/src/main/java/com/ym/pojo/MusicScoreMessage.java
  17. 14 3
      mec-im/src/main/java/com/ym/pojo/ReqDeviceControlData.java
  18. 194 43
      mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java
  19. 16 3
      mec-im/src/main/java/com/ym/service/RoomService.java
  20. 19 0
      mec-task/src/main/java/com/ym/mec/task/jobs/UpdateGradeTask.java
  21. 1 1
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/SysMusicScoreAccompanimentController.java

+ 45 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentMusicScoreDao.java

@@ -0,0 +1,45 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface CourseScheduleStudentMusicScoreDao extends BaseDAO<Integer, CourseScheduleStudentMusicScore> {
+
+    int updateByMusicScore(CourseScheduleStudentMusicScore courseScheduleStudentMusicScore);
+
+    List<CourseScheduleStudentMusicScore> queryByScoreIdAndCourseId(@Param("musicScoreAccompanimentId") Integer musicScoreAccompanimentId,
+                                                                    @Param("courseId") Long courseId,
+                                                                    @Param("userId") Integer userId,
+                                                                    @Param("downStatus") Integer downStatus,
+                                                                    @Param("userType") Integer userType);
+
+    int batchInsert(@Param("scheduleStudentMusicScores") List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores);
+
+    /**
+     * 关闭所有伴奏的播放
+     * @param scheduleId
+     * @param userId
+     */
+    void closePlayStatus(@Param("scheduleId") long scheduleId, @Param("userId") int userId, @Param("musicScoreAccompanimentId") Integer musicScoreAccompanimentId);
+
+    /**
+     * 开启原音播放
+     * @param scheduleId
+     * @param userId
+     * @param musicScoreAccompanimentId
+     * @return
+     */
+    int openPlayStatus(@Param("scheduleId") long scheduleId, @Param("userId") int userId, @Param("musicScoreAccompanimentId") Integer musicScoreAccompanimentId);
+
+    /**
+     * 开启伴奏播放
+     * @param scheduleId
+     * @param userId
+     * @param musicScoreAccompanimentId
+     * @return
+     */
+    int openAccompanimentPlayStatus(@Param("scheduleId") long scheduleId, @Param("userId") int userId, @Param("musicScoreAccompanimentId") Integer musicScoreAccompanimentId);
+}

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

@@ -16,7 +16,7 @@ import java.util.Map;
 import java.util.Set;
 
 public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Student> {
-
+	
 	Student getLocked(Integer userId);
 
     int lockUser(@Param("userId") Integer userId);

+ 96 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleStudentMusicScore.java

@@ -0,0 +1,96 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.util.Date;
+
+public class CourseScheduleStudentMusicScore {
+    private Integer id;
+    private Long courseScheduleId;
+    private Integer downStatus = 0;
+    private Integer userId;
+    private Integer userType = 0;
+    private Integer musicScoreAccompanimentId;
+    private Integer playStatus = 0;
+    private Integer speed;
+    private Date createTime;
+    private Date updateTime;
+
+    public Integer getUserType() {
+        return userType;
+    }
+
+    public void setUserType(Integer userType) {
+        this.userType = userType;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Long getCourseScheduleId() {
+        return courseScheduleId;
+    }
+
+    public void setCourseScheduleId(Long courseScheduleId) {
+        this.courseScheduleId = courseScheduleId;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getDownStatus() {
+        return downStatus;
+    }
+
+    public void setDownStatus(Integer downStatus) {
+        this.downStatus = downStatus;
+    }
+
+    public Integer getMusicScoreAccompanimentId() {
+        return musicScoreAccompanimentId;
+    }
+
+    public void setMusicScoreAccompanimentId(Integer musicScoreAccompanimentId) {
+        this.musicScoreAccompanimentId = musicScoreAccompanimentId;
+    }
+
+    public Integer getPlayStatus() {
+        return playStatus;
+    }
+
+    public void setPlayStatus(Integer playStatus) {
+        this.playStatus = playStatus;
+    }
+
+    public Integer getSpeed() {
+        return speed;
+    }
+
+    public void setSpeed(Integer speed) {
+        this.speed = speed;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 8 - 8
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentRegistration.java

@@ -430,14 +430,6 @@ public class StudentRegistration {
         this.currentGradeDate = currentGradeDate;
     }
 
-    public Integer getCurrentGradeNum() {
-        return currentGradeNum;
-    }
-
-    public void setCurrentGradeNum(Integer currentGradeNum) {
-        this.currentGradeNum = currentGradeNum;
-    }
-
     public Integer getIsMerge() {
         return isMerge;
     }
@@ -445,4 +437,12 @@ public class StudentRegistration {
     public void setIsMerge(Integer isMerge) {
         this.isMerge = isMerge;
     }
+
+    public Integer getCurrentGradeNum() {
+        return currentGradeNum;
+    }
+
+    public void setCurrentGradeNum(Integer currentGradeNum) {
+        this.currentGradeNum = currentGradeNum;
+    }
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentMusicScoreService.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore;
+import com.ym.mec.common.service.BaseService;
+
+public interface CourseScheduleStudentMusicScoreService extends BaseService<Integer, CourseScheduleStudentMusicScore> {
+
+}

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentMusicScoreServiceImpl.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentMusicScoreDao;
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore;
+import com.ym.mec.biz.service.CourseScheduleStudentMusicScoreService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CourseScheduleStudentMusicScoreServiceImpl extends BaseServiceImpl<Integer, CourseScheduleStudentMusicScore>  implements CourseScheduleStudentMusicScoreService {
+	
+	@Autowired
+	private CourseScheduleStudentMusicScoreDao courseScheduleStudentMusicScoreDao;
+
+	@Override
+	public BaseDAO<Integer, CourseScheduleStudentMusicScore> getDAO() {
+		return courseScheduleStudentMusicScoreDao;
+	}
+
+}

+ 127 - 0
mec-biz/src/main/resources/config/mybatis/courseScheduleStudentMusicScoreMapper.xml

@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.ym.mec.biz.dal.dao.CourseScheduleStudentMusicScoreDao">
+
+    <resultMap type="com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore" id="CourseScheduleStudentMusicScore">
+        <result column="id_" property="id"/>
+        <result column="course_schedule_id_" property="courseScheduleId"/>
+        <result column="user_id_" property="userId"/>
+        <result column="user_type_" property="userType"/>
+        <result column="down_status_" property="downStatus"/>
+        <result column="music_score_accompaniment_id_" property="musicScoreAccompanimentId"/>
+        <result column="play_status_" property="playStatus"/>
+        <result column="speed_" property="speed"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="CourseScheduleStudentMusicScore">
+		SELECT * FROM course_schedule_student_music_score WHERE id_ = #{id}
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="CourseScheduleStudentMusicScore">
+		SELECT * FROM course_schedule_student_music_score ORDER BY id_
+	</select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO course_schedule_student_music_score (course_schedule_id_,user_id_,user_type_,down_status_,music_score_accompaniment_id_,play_status_,speed_,create_time_,update_time_)
+        VALUES(#{courseScheduleId},#{userId},#{userType},#{downStatus},#{musicScoreAccompanimentId},#{playStatus},#{speed},now(),now())
+    </insert>
+    <insert id="batchInsert">
+        INSERT INTO course_schedule_student_music_score (course_schedule_id_,user_id_,user_type_,down_status_,music_score_accompaniment_id_,play_status_,speed_,create_time_,update_time_)
+        VALUE
+        <foreach collection="scheduleStudentMusicScores" item="item" separator=",">
+            (#{item.courseScheduleId},#{item.userId},#{item.userType},#{item.downStatus},#{item.musicScoreAccompanimentId},#{item.playStatus},#{item.speed},now(),now())
+        </foreach>
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore">
+        UPDATE course_schedule_student_music_score
+        <set>
+            <if test="downStatus != null">
+                down_status_ = #{downStatus},
+            </if>
+            <if test="playStatus != null">
+                play_status_ = #{playStatus},
+            </if>
+            <if test="speed != null">
+                speed_ = #{speed},
+            </if>
+            update_time_ = NOW()
+        </set>
+        WHERE id_ = #{id}
+    </update>
+
+    <update id="updateByMusicScore" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore">
+        UPDATE course_schedule_student_music_score
+        SET down_status_ = #{downStatus},play_status_ = #{playStatus},speed_ = #{speed},update_time_ = NOW()
+        WHERE course_schedule_id_ = #{courseScheduleId}
+        <if test="userId">
+            AND user_id_ = #{userId}
+        </if>
+        <if test="musicScoreAccompanimentId">
+            AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
+        </if>
+    </update>
+    <update id="closePlayStatus">
+        UPDATE course_schedule_student_music_score SET play_status_ = 0,accompaniment_play_status_ = 0,update_time_ = NOW()
+        WHERE course_schedule_id_ = #{scheduleId} AND user_id_ = #{userId}
+        <if test="musicScoreAccompanimentId">
+            AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
+        </if>
+    </update>
+    <update id="openPlayStatus">
+        UPDATE course_schedule_student_music_score SET play_status_ = 1,update_time_ = NOW()
+        WHERE course_schedule_id_ = #{scheduleId} AND user_id_ = #{userId} AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
+    </update>
+    <update id="openAccompanimentPlayStatus">
+        UPDATE course_schedule_student_music_score SET accompaniment_play_status_ = 1,update_time_ = NOW()
+        WHERE course_schedule_id_ = #{scheduleId} AND user_id_ = #{userId} AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+        DELETE FROM course_schedule_student_music_score WHERE id_ = #{id}
+	</delete>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="CourseScheduleStudentMusicScore" parameterType="map">
+        SELECT * FROM course_schedule_student_music_score
+        <include refid="global.limit" />
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM course_schedule_student_music_score
+	</select>
+    <select id="queryByScoreIdAndCourseId"
+            resultMap="CourseScheduleStudentMusicScore">
+        SELECT * FROM course_schedule_student_music_score
+        <where>
+            <if test="courseId != null">
+                AND course_schedule_id_ = #{courseId}
+            </if>
+            <if test="musicScoreAccompanimentId != null">
+                AND music_score_accompaniment_id_ = #{musicScoreAccompanimentId}
+            </if>
+            <if test="userType != null">
+                AND user_type_ = #{userType}
+            </if>
+            <if test="userId != null">
+                AND user_id_ = #{userId}
+            </if>
+            <if test="downStatus != null">
+                AND down_status_ = #{downStatus}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 6 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -159,4 +159,10 @@ public interface TaskRemoteService {
 	 */
 	@GetMapping("task/closeStudentServiceTag")
     void closeStudentServiceTag();
+
+	/**
+	 * 更新学生年级
+	 */
+	@GetMapping("task/updateGrade")
+	void updateGrade();
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -200,4 +200,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
 	public void closeStudentServiceTag() {
 		logger.info("学员服务指标关闭失败");
 	}
+
+	@Override
+	public void updateGrade() {
+		logger.info("学生年级更新失败");
+	}
 }

+ 7 - 7
mec-common/audit-log/pom.xml

@@ -21,11 +21,11 @@
 			<groupId>com.yonge.mongodb</groupId>
 			<artifactId>mongo-db</artifactId>
 		</dependency>
-        <dependency>
-            <groupId>io.swagger</groupId>
-            <artifactId>swagger-annotations</artifactId>
-            <version>1.5.20</version>
-            <scope>compile</scope>
-        </dependency>
-    </dependencies>
+		<dependency>
+			<groupId>io.swagger</groupId>
+			<artifactId>swagger-annotations</artifactId>
+			<version>1.5.20</version>
+			<scope>compile</scope>
+		</dependency>
+	</dependencies>
 </project>

+ 26 - 36
mec-im/src/main/java/com/ym/controller/RoomController.java

@@ -7,6 +7,7 @@ import com.ym.common.ErrorEnum;
 import com.ym.pojo.*;
 import com.ym.service.MessageService;
 import com.ym.service.RoomService;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -62,6 +63,13 @@ public class RoomController{
         return new BaseResponse<>();
     }
 
+    @ApiOperation(value = "老师通知学员下载伴奏")
+    @RequestMapping(value = "pushDownloadMusicScoreMsg", method = RequestMethod.POST)
+    public Object pushDownloadMusicScoreMsg(@RequestBody MusicScoreData musicScoreData) throws Exception {
+        roomService.pushDownloadMusicScoreMsg(musicScoreData);
+        return new BaseResponse<>();
+    }
+
     @RequestMapping(value = "joinRoomStatusNotify", method = RequestMethod.POST)
     public Object joinRoomStatusNotify(@RequestBody RoomStatusNotify roomStatusNotify) throws Exception {
         log.info("joinRoomStatusNotify: {}",JSONObject.toJSON(roomStatusNotify));
@@ -138,11 +146,12 @@ public class RoomController{
         return new BaseResponse<>(whiteboards);
     }
 
+    @ApiOperation(value = "通知学员打开,麦克风、摄像头等权限请求")
     @RequestMapping(value = "/device/approve", method = RequestMethod.POST)
     public Object approveControlDevice(@RequestBody ReqDeviceControlData data)
             throws Exception {
         boolean result;
-        result = roomService.approveControlDevice(data.getRoomId(), data.getTicket());
+        result = roomService.approveControlDevice(data);
         return new BaseResponse<>(result);
     }
 
@@ -154,57 +163,38 @@ public class RoomController{
         return new BaseResponse<>(result);
     }
 
+    @ApiOperation(value = "学员麦克风、摄像头等开关控制")
     @RequestMapping(value = "/device/control", method = RequestMethod.POST)
     public Object controlDevice(@RequestBody ReqDeviceControlData data)
             throws Exception {
-        boolean result;
-        if (data.getCameraOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.Camera, data.getCameraOn());
-        } else if (data.getMicrophoneOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.Microphone, data.getMicrophoneOn());
-        } else if (data.getMusicModeOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.MusicMode, data.getMusicModeOn());
-        } else if (data.getHandUpOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.HandUp, data.getHandUpOn());
-        }else if (data.getExamSongOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.ExamSong, data.getExamSongOn());
-        } else {
-            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
-        }
-        return new BaseResponse<>(result);
+        return new BaseResponse<>(roomService.controlDevice(data));
     }
 
+    @ApiOperation(value = "学员麦克风、摄像头等开关批量控制")
+    @RequestMapping(value = "/device/batchControl", method = RequestMethod.POST)
+    public Object batchControlDevice(@RequestBody ReqDeviceControlData data)throws Exception {
+        log.info("batchControl: {}",JSONObject.toJSON(data));
+        return new BaseResponse<>(roomService.batchControlDevice(data));
+    }
+
+    @ApiOperation(value = "学员伴奏下载状态回调")
     @RequestMapping(value = "adjustExamSong", method = RequestMethod.POST)
     public Object adjustExamSong(@RequestBody ExamSongData examSongData) throws Exception {
         roomService.adjustExamSong(examSongData.getRoomId(),examSongData.getStatus(),examSongData.getExamSongId());
         return new BaseResponse<>();
     }
 
-    @RequestMapping(value = "/device/batchControl", method = RequestMethod.POST)
-    public Object batchControlDevice(@RequestBody ReqDeviceControlData data)throws Exception {
-        log.info("batchControl: {}",JSONObject.toJSON(data));
-        boolean result = roomService.batchControlDevice(data);
-        return new BaseResponse<>(result);
+    @ApiOperation(value = "学员伴奏下载状态回调")
+    @RequestMapping(value = "adjustMusicScore", method = RequestMethod.POST)
+    public Object adjustMusicScore(@RequestBody MusicScoreData musicScoreData) throws Exception {
+        roomService.adjustMusicScore(musicScoreData);
+        return new BaseResponse<>();
     }
 
     @RequestMapping(value = "/device/sync", method = RequestMethod.POST)
     public Object syncDeviceState(@RequestBody ReqDeviceControlData data)
             throws Exception {
-        boolean result;
-        if (data.getCameraOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.Camera, data.getCameraOn());
-        } else if (data.getMicrophoneOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.Microphone, data.getMicrophoneOn());
-        } else if (data.getMusicModeOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.MusicMode, data.getMusicModeOn());
-        }  else if (data.getHandUpOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.HandUp, data.getHandUpOn());
-        }  else if (data.getExamSongOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.ExamSong, data.getExamSongOn());
-        } else {
-            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
-        }
-        return new BaseResponse<>(result);
+        return new BaseResponse<>(roomService.syncDeviceState(data));
     }
 
     @RequestMapping(value = "/whiteboard/turn-page", method = RequestMethod.POST)

+ 43 - 0
mec-im/src/main/java/com/ym/mec/im/message/MusicScoreDownloadMessageMessage.java

@@ -0,0 +1,43 @@
+package com.ym.mec.im.message;
+
+import com.ym.mec.im.BaseMessage;
+import com.ym.pojo.MusicScoreMessage;
+
+public class MusicScoreDownloadMessageMessage extends BaseMessage {
+    private MusicScoreMessage content;
+    private static final transient String TYPE = "DY:musicScoreDownloadMessage";
+
+    public MusicScoreDownloadMessageMessage(MusicScoreMessage content) {
+        this.content = content;
+    }
+
+    public MusicScoreMessage getContent() {
+        return content;
+    }
+
+    public void setContent(MusicScoreMessage content) {
+        this.content = content;
+    }
+
+    @Override
+    public String toString() {
+        return "{\"id\":\"" + content.getId() +
+                "\", \"examSongId\":\"" + content.getExamSongId() +
+                "\", \"subjectId\":\"" + content.getSubjectId() +
+                "\", \"subjectName\":\"" + content.getSubjectName() +
+                "\", \"mp3Url\":\"" + content.getMp3Url() +
+                "\", \"speed\":\"" + content.getSpeed() +
+                "\", \"xmlUrl\":\"" + content.getXmlUrl() +
+                "\", \"examSongName\":\"" + content.getExamSongName() +
+                "\", \"categoriesName\":\"" + content.getCategoriesName() +
+                "\", \"categoriesId\":\"" + content.getCategoriesId() +
+                "\", \"type\":\"" + content.getType() +
+                "\", \"url\":\"" + content.getUrl() +
+                "\"}";
+    }
+
+    @Override
+    public String getObjectName() {
+        return TYPE;
+    }
+}

+ 24 - 0
mec-im/src/main/java/com/ym/mec/im/message/MusicScoreDownloadStatusMessage.java

@@ -0,0 +1,24 @@
+package com.ym.mec.im.message;
+
+import com.ym.mec.im.BaseMessage;
+import lombok.Getter;
+import lombok.Setter;
+
+public class MusicScoreDownloadStatusMessage extends BaseMessage {
+    private @Setter @Getter Integer status;
+
+    private @Setter @Getter Integer studentId;
+
+    private @Setter @Getter Integer musicScoreAccompanimentId;
+
+    public MusicScoreDownloadStatusMessage(Integer status, Integer studentId, Integer musicScoreAccompanimentId) {
+        this.status = status;
+        this.studentId = studentId;
+        this.musicScoreAccompanimentId = musicScoreAccompanimentId;
+    }
+
+    @Override
+    public String getObjectName() {
+        return "DY:MSDSMsg";
+    }
+}

+ 2 - 3
mec-im/src/main/java/com/ym/pojo/DeviceTypeEnum.java

@@ -1,12 +1,11 @@
 package com.ym.pojo;
 
-/**
- * Created by weiqinxiao on 2019/3/19.
- */
 public enum DeviceTypeEnum {
     Microphone,
     Camera,
     MusicMode,
     HandUp,
     ExamSong,
+    MusicScore,
+    MusicScoreAccompaniment,
 }

+ 49 - 0
mec-im/src/main/java/com/ym/pojo/MusicScoreData.java

@@ -0,0 +1,49 @@
+package com.ym.pojo;
+
+public class MusicScoreData {
+	private Long roomId;
+	private Integer musicScoreAccompanimentId;
+	private Integer userId;
+	private Integer userType;
+	private Integer status;
+
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
+	public Integer getUserType() {
+		return userType;
+	}
+
+	public void setUserType(Integer userType) {
+		this.userType = userType;
+	}
+
+	public Integer getMusicScoreAccompanimentId() {
+		return musicScoreAccompanimentId;
+	}
+
+	public void setMusicScoreAccompanimentId(Integer musicScoreAccompanimentId) {
+		this.musicScoreAccompanimentId = musicScoreAccompanimentId;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Long getRoomId() {
+		return roomId;
+	}
+
+	public void setRoomId(Long roomId) {
+		this.roomId = roomId;
+	}
+}

+ 153 - 0
mec-im/src/main/java/com/ym/pojo/MusicScoreMessage.java

@@ -0,0 +1,153 @@
+package com.ym.pojo;
+
+public class MusicScoreMessage {
+    /**  */
+    private Integer id;
+
+    /**  */
+    private Integer examSongId;
+
+    /**  */
+    private Integer subjectId;
+
+    /**  */
+    private String subjectName;
+
+    /**  */
+    private String mp3Url;
+
+    /** 速度 */
+    private Integer speed;
+
+    /**  */
+    private String xmlUrl;
+
+    /**  */
+    private String examSongName;
+
+    /**  */
+    private String categoriesName;
+
+    /**  */
+    private Integer categoriesId;
+
+    /**  */
+    private String type;
+
+    /**  */
+    private String url;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getExamSongId() {
+        return examSongId;
+    }
+
+    public void setExamSongId(Integer examSongId) {
+        this.examSongId = examSongId;
+    }
+
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+
+    public String getMp3Url() {
+        return mp3Url;
+    }
+
+    public void setMp3Url(String mp3Url) {
+        this.mp3Url = mp3Url;
+    }
+
+    public Integer getSpeed() {
+        return speed;
+    }
+
+    public void setSpeed(Integer speed) {
+        this.speed = speed;
+    }
+
+    public String getXmlUrl() {
+        return xmlUrl;
+    }
+
+    public void setXmlUrl(String xmlUrl) {
+        this.xmlUrl = xmlUrl;
+    }
+
+    public String getExamSongName() {
+        return examSongName;
+    }
+
+    public void setExamSongName(String examSongName) {
+        this.examSongName = examSongName;
+    }
+
+    public String getCategoriesName() {
+        return categoriesName;
+    }
+
+    public void setCategoriesName(String categoriesName) {
+        this.categoriesName = categoriesName;
+    }
+
+    public Integer getCategoriesId() {
+        return categoriesId;
+    }
+
+    public void setCategoriesId(Integer categoriesId) {
+        this.categoriesId = categoriesId;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    @Override
+    public String toString() {
+        return "MusicScoreMessage{" +
+                "id=" + id +
+                ", examSongId=" + examSongId +
+                ", subjectId=" + subjectId +
+                ", subjectName='" + subjectName + '\'' +
+                ", mp3Url='" + mp3Url + '\'' +
+                ", speed=" + speed +
+                ", xmlUrl='" + xmlUrl + '\'' +
+                ", examSongName='" + examSongName + '\'' +
+                ", categoriesName='" + categoriesName + '\'' +
+                ", categoriesId=" + categoriesId +
+                ", type='" + type + '\'' +
+                ", url='" + url + '\'' +
+                '}';
+    }
+}

+ 14 - 3
mec-im/src/main/java/com/ym/pojo/ReqDeviceControlData.java

@@ -2,9 +2,6 @@ package com.ym.pojo;
 
 import lombok.Data;
 
-/**
- * Created by weiqinxiao on 2019/3/7.
- */
 @Data
 public class ReqDeviceControlData {
 	private Boolean cameraOn;
@@ -12,11 +9,25 @@ public class ReqDeviceControlData {
 	private Boolean musicModeOn;
 	private Boolean handUpOn;
 	private Boolean examSongOn;
+	//原音播放状态
+	private Boolean musicScoreOn;
+	//伴奏播放状态
+	private Boolean accompanimentOn;
+
 	private String roomId;
 	private String userId;
 	private String ticket;
 	private Integer status;
 	private Integer examSongId;
+	private Integer musicScoreAccompanimentId;
+
+	public Integer getMusicScoreAccompanimentId() {
+		return musicScoreAccompanimentId;
+	}
+
+	public void setMusicScoreAccompanimentId(Integer musicScoreAccompanimentId) {
+		this.musicScoreAccompanimentId = musicScoreAccompanimentId;
+	}
 
 	public Boolean getExamSongOn() {
 		return examSongOn;

+ 194 - 43
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -8,19 +8,15 @@ import com.ym.common.DisplayEnum;
 import com.ym.common.ErrorEnum;
 import com.ym.config.IMProperties;
 import com.ym.config.RoomProperties;
-import com.ym.dao.RoomDao;
-import com.ym.dao.RoomMemberDao;
-import com.ym.dao.UserDao;
-import com.ym.dao.WhiteboardDao;
+import com.ym.dao.*;
 import com.ym.job.ScheduleManager;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentMusicScoreDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.RongyunBasicUserDto;
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import com.ym.mec.biz.dal.entity.SysExamSong;
-import com.ym.mec.biz.dal.entity.Teacher;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.TeachModeEnum;
 import com.ym.mec.biz.service.StudentAttendanceService;
@@ -95,6 +91,10 @@ public class RoomServiceImpl implements RoomService {
     @Autowired
     private SysConfigDao sysConfigDao;
     @Autowired
+    private CourseScheduleStudentMusicScoreDao courseScheduleStudentMusicScoreDao;
+    @Autowired
+    private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
+    @Autowired
     private RedisTemplate<String,String> redisTemplate;
 
     @Override
@@ -687,10 +687,8 @@ public class RoomServiceImpl implements RoomService {
     @Transactional(rollbackFor = Exception.class)
     public String createWhiteBoard(String roomId) throws Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
-//        CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
         SysUser authUser = sysUserFeignService.queryUserInfo();
         String userId = authUser.getId().toString();
-//        CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, userId), "room member not exist");
 
         log.info("createWhiteBoard: roomId = {}", roomId);
 
@@ -805,10 +803,35 @@ public class RoomServiceImpl implements RoomService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean controlDevice(String roomId, String userId, DeviceTypeEnum typeEnum, boolean enable) throws Exception {
-        CheckUtils.checkArgument(roomId != null, "roomId must't be null");
-        CheckUtils.checkArgument(userId != null, "userId must't be null");
-        CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
+    public Boolean controlDevice(ReqDeviceControlData data) throws Exception {
+        String roomId = data.getRoomId();
+        String userId = data.getUserId();
+        DeviceTypeEnum typeEnum;
+        boolean enable;
+        if (data.getCameraOn() != null) {
+            typeEnum = DeviceTypeEnum.Camera;
+            enable = data.getCameraOn();
+        } else if (data.getMicrophoneOn() != null) {
+            typeEnum = DeviceTypeEnum.Microphone;
+            enable = data.getMicrophoneOn();
+        } else if (data.getMusicModeOn() != null) {
+            typeEnum = DeviceTypeEnum.MusicMode;
+            enable = data.getMusicModeOn();
+        } else if (data.getHandUpOn() != null) {
+            typeEnum = DeviceTypeEnum.HandUp;
+            enable = data.getHandUpOn();
+        }else if (data.getExamSongOn() != null) {
+            typeEnum = DeviceTypeEnum.ExamSong;
+            enable = data.getExamSongOn();
+        }else if (data.getMusicScoreOn() != null) {
+            typeEnum = DeviceTypeEnum.MusicScore;
+            enable = data.getMusicScoreOn();
+        }else if (data.getAccompanimentOn() != null) {
+            typeEnum = DeviceTypeEnum.MusicScoreAccompaniment;
+            enable = data.getAccompanimentOn();
+        } else {
+            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
+        }
         SysUser authUser = sysUserFeignService.queryUserInfo();
         log.info("controlDevice: userId={}, typeEnum={}, onOff={}", userId, typeEnum, enable);
 
@@ -827,6 +850,23 @@ public class RoomServiceImpl implements RoomService {
                 DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(typeEnum.ordinal(), enable);
                 deviceResourceMessage.setUserId(userId);
                 imHelper.publishMessage(authUser.getId().toString(), roomId, deviceResourceMessage, 1);
+            }else if(typeEnum.equals(DeviceTypeEnum.MusicScore)){
+                long scheduleId = Long.parseLong(roomId.substring(1));
+                //关闭所有曲目播放
+                courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,Integer.parseInt(userId),null);
+                //原音
+                courseScheduleStudentMusicScoreDao.openPlayStatus(scheduleId,authUser.getId(),data.getMusicScoreAccompanimentId());
+                DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(typeEnum.ordinal(), enable);
+                deviceResourceMessage.setUserId(userId);
+                imHelper.publishMessage(authUser.getId().toString(), roomId, deviceResourceMessage, 1);
+            }else if(typeEnum.equals(DeviceTypeEnum.MusicScoreAccompaniment)){
+                long scheduleId = Long.parseLong(roomId.substring(1));
+                //关闭所有曲目播放
+                courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,Integer.parseInt(userId),null);
+                courseScheduleStudentMusicScoreDao.openAccompanimentPlayStatus(scheduleId,authUser.getId(),data.getMusicScoreAccompanimentId());
+                DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(typeEnum.ordinal(), enable);
+                deviceResourceMessage.setUserId(userId);
+                imHelper.publishMessage(authUser.getId().toString(), roomId, deviceResourceMessage, 1);
             }else {
                 String ticket = IdentifierUtils.uuid();
                 ControlDeviceTaskInfo taskInfo = new ControlDeviceTaskInfo();
@@ -862,6 +902,14 @@ public class RoomServiceImpl implements RoomService {
                     msg.setEnable(enable);
                 }
                 courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,Integer.parseInt(userId),JSON.toJSONString(msg));
+            }else if(typeEnum.equals(DeviceTypeEnum.MusicScore)){
+                long scheduleId = Long.parseLong(roomId.substring(1));
+                //关闭所有曲目播放
+                courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,Integer.parseInt(userId),null);
+            }else if(typeEnum.equals(DeviceTypeEnum.MusicScoreAccompaniment)){
+                long scheduleId = Long.parseLong(roomId.substring(1));
+                //关闭所有曲目播放
+                courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,Integer.parseInt(userId),null);
             }else {
                 roomMemberDao.updateMusicByRidAndUid(roomId, userId, false);
             }
@@ -892,39 +940,33 @@ public class RoomServiceImpl implements RoomService {
         if(roomMembers.size() == 0){
             return false;
         }
-        boolean result = true;
-        if (data.getCameraOn() != null) {
-            for (RoomMember e:roomMembers) {
-                controlDevice(data.getRoomId(), e.getUid(), DeviceTypeEnum.Camera, data.getCameraOn());
-            }
-        } else if (data.getMicrophoneOn() != null) {
-            for (RoomMember e:roomMembers) {
-                controlDevice(data.getRoomId(), e.getUid(), DeviceTypeEnum.Microphone, data.getMicrophoneOn());
-            }
-        } else if (data.getMusicModeOn() != null) {
-            for (RoomMember e:roomMembers) {
-                controlDevice(data.getRoomId(), e.getUid(), DeviceTypeEnum.MusicMode, data.getMusicModeOn());
-            }
-        } else if (data.getExamSongOn() != null) {
+        if (data.getExamSongOn() != null) {
             if(StringUtils.isNotEmpty(data.getUserId())){
                 for (RoomMember e:roomMembers) {
-                    controlDevice(data.getRoomId(), e.getUid(), DeviceTypeEnum.ExamSong, data.getExamSongOn());
+                    data.setUserId(e.getUid());
+                    controlDevice(data);
                 }
             }else {
                 List<BasicUserDto> students = courseScheduleStudentPaymentDao.findStudents(Long.parseLong(data.getRoomId().substring(1)));
                 for (BasicUserDto e:students) {
-                    controlDevice(data.getRoomId(), e.getUserId().toString(), DeviceTypeEnum.ExamSong, data.getExamSongOn());
+                    data.setUserId(e.getUserId().toString());
+                    controlDevice(data);
                 }
             }
         } else {
-            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
+            for (RoomMember e:roomMembers) {
+                data.setUserId(e.getUid());
+                controlDevice(data);
+            }
         }
-        return result;
+        return true;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean approveControlDevice(String roomId, String ticket) throws Exception {
+    public Boolean approveControlDevice(ReqDeviceControlData data) throws Exception {
+        String ticket = data.getTicket();
+        String roomId = data.getRoomId();
         CheckUtils.checkArgument(ticket != null, "ticket must't be null");
         SysUser authUser = sysUserFeignService.queryUserInfo();
         String userId = authUser.getId().toString();
@@ -932,7 +974,7 @@ public class RoomServiceImpl implements RoomService {
         ControlDeviceTaskInfo taskInfo = (ControlDeviceTaskInfo) scheduleManager.executeTask(ticket);
         if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.Camera)) {
             roomMemberDao.updateCameraByRidAndUid(roomId, userId, taskInfo.isOnOff());
-        }if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.ExamSong)) {
+        }else if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.ExamSong)) {
             long scheduleId = Long.parseLong(roomId.substring(1));
             ExamSongDownloadData msg;
             String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(scheduleId, authUser.getId());
@@ -943,6 +985,14 @@ public class RoomServiceImpl implements RoomService {
                 msg.setEnable(true);
             }
             courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
+        }else if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.MusicScore)) {
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,authUser.getId(),null);
+            courseScheduleStudentMusicScoreDao.openPlayStatus(scheduleId,authUser.getId(), data.getMusicScoreAccompanimentId());
+        }else if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.MusicScoreAccompaniment)) {
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,authUser.getId(),null);
+            courseScheduleStudentMusicScoreDao.openAccompanimentPlayStatus(scheduleId,authUser.getId(), data.getMusicScoreAccompanimentId());
         } else {
             roomMemberDao.updateMicByRidAndUid(roomId, userId, taskInfo.isOnOff());
         }
@@ -977,20 +1027,46 @@ public class RoomServiceImpl implements RoomService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean syncDeviceState(String roomId, DeviceTypeEnum type, boolean enable) throws Exception {
-        CheckUtils.checkArgument(roomId != null, "roomId must't be null");
-        CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
+    public Boolean syncDeviceState(ReqDeviceControlData data) throws Exception {
+        String roomId = data.getRoomId();
+        DeviceTypeEnum type;
+        boolean enable;
+        if (data.getCameraOn() != null) {
+            type = DeviceTypeEnum.Camera;
+            enable = data.getCameraOn();
+        } else if (data.getMicrophoneOn() != null) {
+            type = DeviceTypeEnum.Camera;
+            enable = data.getCameraOn();
+        } else if (data.getMusicModeOn() != null) {
+            type = DeviceTypeEnum.MusicMode;
+            enable = data.getMusicModeOn();
+        }  else if (data.getHandUpOn() != null) {
+            type = DeviceTypeEnum.HandUp;
+            enable = data.getHandUpOn();
+        }  else if (data.getExamSongOn() != null) {
+            type = DeviceTypeEnum.ExamSong;
+            enable = data.getExamSongOn();
+            //原音
+        }  else if (data.getMusicScoreOn() != null) {
+            type = DeviceTypeEnum.MusicScore;
+            enable = data.getMusicScoreOn();
+            //伴奏
+        }  else if (data.getAccompanimentOn() != null) {
+            type = DeviceTypeEnum.MusicScoreAccompaniment;
+            enable = data.getAccompanimentOn();
+        } else {
+            throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
+        }
         SysUser authUser = sysUserFeignService.queryUserInfo();
         String userId = authUser.getId().toString();
 
-        int result;
         DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
         if (type.equals(DeviceTypeEnum.Camera)) {
-            result = roomMemberDao.updateCameraByRidAndUid(roomId, userId, enable);
+            roomMemberDao.updateCameraByRidAndUid(roomId, userId, enable);
         } else if (type.equals(DeviceTypeEnum.Microphone)){
-            result = roomMemberDao.updateMicByRidAndUid(roomId, userId, enable);
+            roomMemberDao.updateMicByRidAndUid(roomId, userId, enable);
         } else if (type.equals(DeviceTypeEnum.HandUp)){
-            result = roomMemberDao.updateHandByRidAndUid(roomId, userId, enable);
+            roomMemberDao.updateHandByRidAndUid(roomId, userId, enable);
         } else if (type.equals(DeviceTypeEnum.ExamSong)){
             long scheduleId = Long.parseLong(roomId.substring(1));
             ExamSongDownloadData msg;
@@ -1001,13 +1077,25 @@ public class RoomServiceImpl implements RoomService {
                 msg = JSON.parseObject(examJson, ExamSongDownloadData.class);
                 msg.setEnable(enable);
             }
-            result = courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
+            courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
+        } else if (type.equals(DeviceTypeEnum.MusicScore)){
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,authUser.getId(),null);
+            if(enable){
+                courseScheduleStudentMusicScoreDao.openPlayStatus(scheduleId,authUser.getId(),data.getMusicScoreAccompanimentId());
+            }
+        } else if (type.equals(DeviceTypeEnum.MusicScoreAccompaniment)){
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            courseScheduleStudentMusicScoreDao.closePlayStatus(scheduleId,authUser.getId(),null);
+            if(enable){
+                courseScheduleStudentMusicScoreDao.openAccompanimentPlayStatus(scheduleId,authUser.getId(),data.getMusicScoreAccompanimentId());
+            }
         }else {
-            result = roomMemberDao.updateMusicByRidAndUid(roomId, userId, enable);
+            roomMemberDao.updateMusicByRidAndUid(roomId, userId, enable);
         }
         deviceResourceMessage.setUserId(userId);
         imHelper.publishMessage(userId, roomId, deviceResourceMessage, 1);
-        log.info("syncDeviceState : {}, {}, result = {}", roomId, enable, result);
+        log.info("syncDeviceState : {}, {}, result = {}", roomId, enable);
         return true;
     }
 
@@ -1441,6 +1529,42 @@ public class RoomServiceImpl implements RoomService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
+    public void pushDownloadMusicScoreMsg(MusicScoreData musicScoreData) throws Exception {
+        SysUser authUser = sysUserFeignService.queryUserInfo();
+        Long courseScheduleId = musicScoreData.getRoomId();
+        List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores =
+                courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(musicScoreData.getMusicScoreAccompanimentId(),
+                        courseScheduleId,null,null,0);
+        SysMusicScoreAccompaniment accompaniment = sysMusicScoreAccompanimentDao.get(musicScoreData.getMusicScoreAccompanimentId());
+        if(scheduleStudentMusicScores.size() == 0){
+            //第一次下载,生成数据
+            List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseScheduleId);
+            Set<Integer> studentIds = courseScheduleStudentPayments.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
+            studentIds.forEach(e->{
+                CourseScheduleStudentMusicScore musicScore = new CourseScheduleStudentMusicScore();
+                musicScore.setMusicScoreAccompanimentId(accompaniment.getId());
+                musicScore.setSpeed(accompaniment.getSpeed());
+                musicScore.setCourseScheduleId(courseScheduleId);
+                musicScore.setUserId(e);
+                scheduleStudentMusicScores.add(musicScore);
+            });
+            //老师伴奏
+            CourseScheduleStudentMusicScore musicScore = new CourseScheduleStudentMusicScore();
+            musicScore.setMusicScoreAccompanimentId(accompaniment.getId());
+            musicScore.setSpeed(accompaniment.getSpeed());
+            musicScore.setCourseScheduleId(courseScheduleId);
+            musicScore.setUserId(authUser.getId());
+            musicScore.setUserType(1);
+            scheduleStudentMusicScores.add(musicScore);
+            courseScheduleStudentMusicScoreDao.batchInsert(scheduleStudentMusicScores);
+        }
+        MusicScoreMessage musicScoreMessage = JSON.parseObject(JSON.toJSONString(accompaniment), MusicScoreMessage.class);
+        MusicScoreDownloadMessageMessage msg = new MusicScoreDownloadMessageMessage(musicScoreMessage);
+        imHelper.publishMessage(authUser.getId().toString(), courseScheduleId.toString(), msg, 0);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
     public void pushDownloadExamSongMsg(String roomId, Integer examSongId) throws Exception {
         SysUser authUser = sysUserFeignService.queryUserInfo();
 
@@ -1471,6 +1595,33 @@ public class RoomServiceImpl implements RoomService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
+    public void adjustMusicScore(MusicScoreData musicScoreData) throws Exception {
+        SysUser authUser = sysUserFeignService.queryUserInfo();
+        Integer studentId = authUser.getId();
+        Long scheduleId = musicScoreData.getRoomId();
+        Integer status = musicScoreData.getStatus();
+        Integer accompanimentId = musicScoreData.getMusicScoreAccompanimentId();
+
+        SysMusicScoreAccompaniment accompaniment = sysMusicScoreAccompanimentDao.get(accompanimentId);
+        if(accompaniment == null){
+            throw new BizException("曲目信息不存在");
+        }
+        //修改下载状态
+        List<CourseScheduleStudentMusicScore> studentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(accompanimentId,scheduleId,studentId,null,null);
+        if(studentMusicScores == null || studentMusicScores.size() == 0){
+            throw new BizException("学员不存在此下载曲目");
+        }
+        CourseScheduleStudentMusicScore studentMusicScore = studentMusicScores.get(0);
+        studentMusicScore.setDownStatus(musicScoreData.getStatus());
+        courseScheduleStudentMusicScoreDao.update(studentMusicScore);
+        //给老师发送学员曲目下载状态
+        CourseSchedule courseSchedule = courseScheduleDao.get(scheduleId);
+        MusicScoreDownloadStatusMessage statusMessage = new MusicScoreDownloadStatusMessage(status,studentId,accompanimentId);
+        imHelper.publishMessage(studentId.toString(),courseSchedule.getActualTeacherId().toString(), scheduleId.toString(),statusMessage);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
     public void adjustExamSong(String roomId, Integer status,Integer examSongId) throws Exception {
         if(roomId == null || status == null || examSongId == null){
             throw new BizException("参数校验失败");

+ 16 - 3
mec-im/src/main/java/com/ym/service/RoomService.java

@@ -35,11 +35,11 @@ public interface RoomService {
 
     Boolean turnWhiteBoardPage(String roomId, String whiteBoardId, int page) throws Exception;
 
-    Boolean controlDevice(String roomId, String userId, DeviceTypeEnum type, boolean enable) throws Exception;
+    Boolean controlDevice(ReqDeviceControlData data) throws Exception;
 
     Boolean batchControlDevice(ReqDeviceControlData data) throws Exception;
 
-    Boolean approveControlDevice(String roomId, String ticket) throws Exception;
+    Boolean approveControlDevice(ReqDeviceControlData data) throws Exception;
 
     Boolean rejectControlDevice(String roomId, String ticket) throws Exception;
 
@@ -58,7 +58,7 @@ public interface RoomService {
     Boolean approveUpgradeRole(String roomId, String ticket) throws Exception;
     Boolean rejectUpgradeRole(String roomId, String ticket) throws Exception;
 
-    Boolean syncDeviceState(String roomId, DeviceTypeEnum type, boolean enable) throws Exception;
+    Boolean syncDeviceState(ReqDeviceControlData data) throws Exception;
 
     Boolean changeRole(String roomId, String userId, int role) throws Exception;
 
@@ -95,10 +95,23 @@ public interface RoomService {
     void adjustExamSong(String roomId,Integer status,Integer examSongId) throws Exception;
 
     /**
+     * 修改学员伴奏下载状态
+     * @author zouxuan
+     * @param musicScoreData
+     */
+    void adjustMusicScore(MusicScoreData musicScoreData) throws Exception;
+
+    /**
      * 移动端用户加入房间失败
      * @author zouxuan
      * @param roomId
      * @param userId
      */
     void joinRoomFailure(String roomId, String userId);
+
+    /**
+     * 通知学员下载伴奏
+     * @param musicScoreData
+     */
+    void pushDownloadMusicScoreMsg(MusicScoreData musicScoreData) throws Exception;
 }

+ 19 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/UpdateGradeTask.java

@@ -0,0 +1,19 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class UpdateGradeTask extends BaseTask {
+
+	@Autowired
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.updateGrade();
+	}
+}

+ 1 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/SysMusicScoreAccompanimentController.java

@@ -14,7 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 @RequestMapping("sysMusicScoreAccompaniment")
-@Api(tags = "曲库服务")
+@Api(tags = "曲库伴奏服务")
 @RestController
 public class SysMusicScoreAccompanimentController extends BaseController {