瀏覽代碼

网络教室伴奏

zouxuan 4 年之前
父節點
當前提交
19d8d5af3a

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

@@ -0,0 +1,23 @@
+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> findByCourseId(Long courseId);
+
+    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);
+
+}

+ 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 - 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;
+	}
+
+}

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

@@ -0,0 +1,112 @@
+<?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>
+
+    <!-- 根据主键删除一条记录 -->
+    <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>

+ 17 - 1
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);
     }
 
@@ -180,6 +189,13 @@ public class RoomController{
         return new BaseResponse<>();
     }
 
+    @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/batchControl", method = RequestMethod.POST)
     public Object batchControlDevice(@RequestBody ReqDeviceControlData data)throws Exception {
         log.info("batchControl: {}",JSONObject.toJSON(data));

+ 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";
+    }
+}

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

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

+ 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 + '\'' +
+                '}';
+    }
+}

+ 9 - 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;
@@ -17,6 +14,15 @@ public class ReqDeviceControlData {
 	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;

+ 87 - 9
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
@@ -827,6 +827,9 @@ 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));
+
             }else {
                 String ticket = IdentifierUtils.uuid();
                 ControlDeviceTaskInfo taskInfo = new ControlDeviceTaskInfo();
@@ -924,7 +927,9 @@ public class RoomServiceImpl implements RoomService {
 
     @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 +937,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 +948,16 @@ 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));
+            //学员伴奏播放状态修改为播放
+            List<CourseScheduleStudentMusicScore> studentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(data.getMusicScoreAccompanimentId(), scheduleId, authUser.getId(), null, null);
+            if(studentMusicScores == null || studentMusicScores.size() == 0){
+                throw new BizException("学员伴奏信息异常");
+            }
+            CourseScheduleStudentMusicScore studentMusicScore = studentMusicScores.get(0);
+            studentMusicScore.setPlayStatus(1);
+            courseScheduleStudentMusicScoreDao.update(studentMusicScore);
         } else {
             roomMemberDao.updateMicByRidAndUid(roomId, userId, taskInfo.isOnOff());
         }
@@ -1441,6 +1456,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 +1522,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("参数校验失败");

+ 14 - 1
mec-im/src/main/java/com/ym/service/RoomService.java

@@ -39,7 +39,7 @@ public interface RoomService {
 
     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;
 
@@ -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;
 }

+ 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 {