ソースを参照

添加练习统计

yuanliang 1 年間 前
コミット
122e3a1b84

+ 98 - 0
mec-application/src/main/java/com/ym/mec/student/controller/StudentCoursewarePlayRecordController.java

@@ -0,0 +1,98 @@
+package com.ym.mec.student.controller;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.StudentCoursewarePlayRecord;
+import com.ym.mec.biz.dal.wrapper.StudentCoursewarePlayRecordWrapper;
+import com.ym.mec.biz.service.StudentCoursewarePlayRecordService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.PageUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("${app-config.url.student:}/studentCoursewarePlayRecord")
+@Api(tags = "学生课件播放统计记录")
+public class StudentCoursewarePlayRecordController extends BaseController {
+
+    @Resource
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private StudentCoursewarePlayRecordService studentCoursewarePlayRecordService;
+
+    @ApiOperation(value = "详情", notes = "学生课件播放统计记录-根据详情ID查询单条, 传入id")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/detail')")
+//    @GetMapping("/detail/{id}")
+    public HttpResponseResult<StudentCoursewarePlayRecord> detail(@PathVariable("id") Long id) {
+
+        StudentCoursewarePlayRecord wrapper = studentCoursewarePlayRecordService.detail(id);
+
+        return succeed(wrapper);
+    }
+
+    @ApiOperation(value = "查询分页", notes = "学生课件播放统计记录- 传入 StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/page')")
+//    @PostMapping("/page")
+    public HttpResponseResult<PageInfo<StudentCoursewarePlayRecord>> page(@RequestBody StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery query) {
+
+        IPage<StudentCoursewarePlayRecord> pages = studentCoursewarePlayRecordService.selectPage(QueryInfo.getPage(query), query);
+
+        return succeed(PageUtil.pageInfo(pages));
+    }
+
+    @ApiOperation(value = "新增", notes = "学生课件播放统计记录- 传入 StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/save')")
+    @PostMapping("/save")
+    public HttpResponseResult<JSONObject> add(@Validated @RequestBody StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordSave studentCoursewarePlayRecord) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        studentCoursewarePlayRecord.setUserId(sysUser.getId());
+        studentCoursewarePlayRecord.setOrganizationId(sysUser.getOrganId());
+        // 新增数据
+        studentCoursewarePlayRecordService.save(studentCoursewarePlayRecord);
+
+        return succeed();
+    }
+
+    @ApiOperation(value = "修改", notes = "学生课件播放统计记录- 传入 StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/update')")
+//    @PostMapping("/update")
+    public HttpResponseResult<JSONObject> update(@Validated @RequestBody StudentCoursewarePlayRecord studentCoursewarePlayRecord) {
+
+        // 更新数据
+        studentCoursewarePlayRecordService.updateById(studentCoursewarePlayRecord);
+
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除", notes = "学生课件播放统计记录- 传入id")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/remove')")
+//    @PostMapping("/remove")
+    public HttpResponseResult<Boolean> remove(@RequestParam Long id) {
+
+        return succeed(studentCoursewarePlayRecordService.removeById(id));
+    }
+}

+ 102 - 0
mec-application/src/main/java/com/ym/mec/web/controller/StudentCoursewarePlayRecordController.java

@@ -0,0 +1,102 @@
+package com.ym.mec.web.controller;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.ym.mec.biz.dal.entity.StudentCoursewarePlayRecord;
+import com.ym.mec.biz.dal.wrapper.StudentCoursewarePlayRecordWrapper;
+import com.ym.mec.biz.service.StudentCoursewarePlayRecordService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.PageUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("${app-config.url.web:}/studentCoursewarePlayRecord")
+@Api(tags = "学生课件播放统计记录")
+public class StudentCoursewarePlayRecordController extends BaseController {
+
+    @Autowired
+    private StudentCoursewarePlayRecordService studentCoursewarePlayRecordService;
+
+    @ApiOperation(value = "详情", notes = "学生课件播放统计记录-根据详情ID查询单条, 传入id")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/detail')")
+//    @GetMapping("/detail/{id}")
+    public HttpResponseResult<StudentCoursewarePlayRecord> detail(@PathVariable("id") Long id) {
+
+        StudentCoursewarePlayRecord wrapper = studentCoursewarePlayRecordService.detail(id);
+
+        return succeed(wrapper);
+    }
+
+    @ApiOperation(value = "查询分页", notes = "学生课件播放统计记录- 传入 StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/page')")
+//    @PostMapping("/page")
+    public HttpResponseResult<PageInfo<StudentCoursewarePlayRecord>> page(@RequestBody StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery query) {
+
+        IPage<StudentCoursewarePlayRecord> pages = studentCoursewarePlayRecordService.selectPage(QueryInfo.getPage(query), query);
+
+        return succeed(PageUtil.pageInfo(pages));
+    }
+
+    @ApiOperation(value = "新增", notes = "学生课件播放统计记录- 传入 StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/save')")
+//    @PostMapping("/save")
+    public HttpResponseResult<JSONObject> add(@Validated @RequestBody StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord studentCoursewarePlayRecord) {
+        return succeed();
+    }
+
+    @ApiOperation(value = "修改", notes = "学生课件播放统计记录- 传入 StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/update')")
+//    @PostMapping("/update")
+    public HttpResponseResult<JSONObject> update(@Validated @RequestBody StudentCoursewarePlayRecord studentCoursewarePlayRecord) {
+
+        // 更新数据
+        studentCoursewarePlayRecordService.updateById(studentCoursewarePlayRecord);
+
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除", notes = "学生课件播放统计记录- 传入id")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/remove')")
+//    @PostMapping("/remove")
+    public HttpResponseResult<Boolean> remove(@RequestParam Long id) {
+
+        return succeed(studentCoursewarePlayRecordService.removeById(id));
+    }
+
+    /**
+     * 练习统计
+     */
+    @PostMapping("/statList")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/statList')")
+    public HttpResponseResult<List<StudentCoursewarePlayRecordWrapper.StatQueryData>> statList(@RequestBody StudentCoursewarePlayRecordWrapper.StatQuery statQuery) {
+        return succeed(studentCoursewarePlayRecordService.statList(statQuery));
+    }
+
+    /**
+     * 练习详情统计
+     */
+    @PostMapping("/statDetailPage")
+    @PreAuthorize("@pcs.hasPermissions('studentCoursewarePlayRecord/statDetailPage')")
+    public HttpResponseResult<PageInfo<StudentCoursewarePlayRecordWrapper.StatQueryData>> statDetailPage(@RequestBody StudentCoursewarePlayRecordWrapper.StatQuery statQuery) {
+        return succeed(PageUtil.pageInfo(studentCoursewarePlayRecordService.statDetailPage(statQuery)));
+    }
+}

+ 47 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentCoursewarePlayRecord.java

@@ -0,0 +1,47 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 学生课件播放统计记录
+ * 2024-07-04 14:48:14
+ */
+@Data
+@ApiModel(" StudentCoursewarePlayRecord-学生课件播放统计记录")
+@TableName("student_courseware_play_record")
+public class StudentCoursewarePlayRecord implements Serializable {
+
+    @ApiModelProperty("主键ID")
+    @TableId(value = "id_")
+    private Long id;
+
+    @ApiModelProperty("分部ID")
+    @TableField(value = "organization_id_")
+    private Integer organizationId;
+
+    @ApiModelProperty("用户编号")
+    @TableField(value = "user_id_")
+    private Integer userId;
+
+    @ApiModelProperty("播放时长,单位为秒")
+    @TableField(value = "play_time_")
+    private Float playTime;
+
+    @ApiModelProperty("更新时间")
+    @TableField(value = "update_time_")
+    private Date updateTime;
+
+    @ApiModelProperty("创建时间")
+    @TableField(value = "create_time_")
+    private Date createTime;
+
+}

+ 34 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/mapper/StudentCoursewarePlayRecordMapper.java

@@ -0,0 +1,34 @@
+package com.ym.mec.biz.dal.mapper;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+import com.ym.mec.biz.dal.entity.StudentCoursewarePlayRecord;
+import com.ym.mec.biz.dal.wrapper.StudentCoursewarePlayRecordWrapper;
+
+/**
+ * 学生课件播放统计记录
+ * 2024-07-04 14:48:14
+ */
+@Repository
+public interface StudentCoursewarePlayRecordMapper extends BaseMapper<StudentCoursewarePlayRecord> {
+
+    /**
+     * 分页查询
+     *
+     * @param page  IPage<StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord>
+     * @param param StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery
+     * @return List<StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord>
+     */
+    List<StudentCoursewarePlayRecord> selectPage(@Param("page") IPage<StudentCoursewarePlayRecord> page, @Param("param") StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery param);
+
+    void save(@Param("record") StudentCoursewarePlayRecord record);
+
+    List<StudentCoursewarePlayRecordWrapper.StatQueryData> statList(@Param("statQuery") StudentCoursewarePlayRecordWrapper.StatQuery statQuery);
+
+    List<StudentCoursewarePlayRecordWrapper.StatQueryData> statDetailPage(@Param("page") IPage<StudentCoursewarePlayRecordWrapper.StatQueryData> page,
+                                                                          @Param("statQuery") StudentCoursewarePlayRecordWrapper.StatQuery statQuery);
+}

+ 170 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/StudentCoursewarePlayRecordWrapper.java

@@ -0,0 +1,170 @@
+package com.ym.mec.biz.dal.wrapper;
+
+import com.alibaba.fastjson.JSON;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * 学生课件播放统计记录
+ * 2024-07-04 14:48:14
+ */
+@ApiModel(value = "StudentCoursewarePlayRecordWrapper对象", description = "学生课件播放统计记录查询对象")
+public class StudentCoursewarePlayRecordWrapper {
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel(" StudentCoursewarePlayRecordQuery-学生课件播放统计记录")
+    public static class StudentCoursewarePlayRecordQuery implements QueryInfo {
+
+        @ApiModelProperty("当前页")
+        private Integer page;
+
+        @ApiModelProperty("分页行数")
+        private Integer rows;
+
+        @ApiModelProperty("关键字匹配")
+        private String keyword;
+
+        public String getKeyword() {
+            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
+        }
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static StudentCoursewarePlayRecordQuery from(String json) {
+            return JSON.parseObject(json, StudentCoursewarePlayRecordQuery.class);
+        }
+    }
+
+
+    @Data
+    @ApiModel(" StudentCoursewarePlayRecord-学生课件播放统计记录")
+    public static class StudentCoursewarePlayRecord {
+
+        @ApiModelProperty("乐团ID")
+        private String musicGroupId;
+
+        @ApiModelProperty("用户编号")
+        private Long userId;
+
+        @ApiModelProperty("在读状态")
+        private Boolean readingStatus;
+
+        @ApiModelProperty("播放时长,单位为秒")
+        private Float playTime;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static StudentCoursewarePlayRecord from(String json) {
+            return JSON.parseObject(json, StudentCoursewarePlayRecord.class);
+        }
+    }
+
+    @Data
+    @ApiModel(" StudentCoursewarePlayRecord-学生课件播放统计记录")
+    public static class StudentCoursewarePlayRecordSave {
+
+        @ApiModelProperty(value = "用户编号",hidden = true)
+        private Integer userId;
+
+        @ApiModelProperty(hidden = true)
+        private Integer organizationId;
+
+        @ApiModelProperty("播放时长,单位为秒")
+        @NotNull
+        private Float playTime;
+
+    }
+
+
+    @Data
+    @ApiModel("云课堂观看统计查询")
+    public static class StatQuery implements QueryInfo {
+
+        @ApiModelProperty("开始时间")
+        private Date startTime;
+
+        @ApiModelProperty("结束时间")
+        private Date endTime;
+
+        @ApiModelProperty("分部ID")
+        private Long organizationId;
+
+        @ApiModelProperty("排序值,1:在读,2:无练习,3:10分钟,4:60分钟,5:120分钟,6:240分钟,7:>240分钟,8:平均时长")
+        private Integer sort = 1;
+
+        @ApiModelProperty("声降序,true:升序,false:降序")
+        private Boolean asc = false;
+
+        @ApiModelProperty(hidden = true)
+        private String sortBy;
+
+        @ApiModelProperty(hidden = true)
+        private static List<String> sortKeys = Arrays.asList("readingNum", "noPlayNum", "playTimeLess10", "playTimeLess60", "playTimeLess120", "playTimeLess240", "playTimeRather240", "avgPlayTime");
+
+        public String getSortBy() {
+            String key = sortKeys.get(getSort() > sortKeys.size() ? 0 : getSort() - 1);
+            return key + (asc ? " asc" : " desc");
+        }
+    }
+
+    @Data
+    @ApiModel("云课堂观看统计查询结果")
+    public static class StatQueryData {
+
+        @ApiModelProperty("分部ID")
+        private Long organizationId;
+
+        @ApiModelProperty("分部名称")
+        private String organizationName;
+
+        @ApiModelProperty("声部老师")
+        private String teacherName;
+
+        @ApiModelProperty("会员数量")
+        private Integer memberNum;
+
+        @ApiModelProperty("无练习人数")
+        private Integer noPlayNum;
+
+        @ApiModelProperty("练习时长少于等于10分钟")
+        private Integer playTimeLess10;
+
+        @ApiModelProperty("练习时长少于等于60分钟")
+        private Integer playTimeLess60;
+
+        @ApiModelProperty("练习时长少于等于120分钟")
+        private Integer playTimeLess120;
+
+        @ApiModelProperty("练习时长少于等于240")
+        private Integer playTimeLess240;
+
+        @ApiModelProperty("练习时长大于240")
+        private Integer playTimeRather240;
+
+        @ApiModelProperty("平均练习时长")
+        private Float avgPlayTime;
+
+    }
+
+}

+ 50 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentCoursewarePlayRecordService.java

@@ -0,0 +1,50 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.wrapper.StudentCoursewarePlayRecordWrapper;
+import com.ym.mec.biz.dal.entity.StudentCoursewarePlayRecord;
+
+import java.util.List;
+
+/**
+ * 学生课件播放统计记录
+ * 2024-07-04 14:48:14
+ */
+public interface StudentCoursewarePlayRecordService extends IService<StudentCoursewarePlayRecord>  {
+
+    /**
+     * 查询详情
+     * @param id 详情ID
+     * @return StudentCoursewarePlayRecord
+     */
+    StudentCoursewarePlayRecord detail(Long id);
+
+    /**
+     * 分页查询
+     * @param page IPage<StudentCoursewarePlayRecord>
+     * @param query StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery
+     * @return IPage<StudentCoursewarePlayRecord>
+     */
+    IPage<StudentCoursewarePlayRecord> selectPage(IPage<StudentCoursewarePlayRecord> page, StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery query);
+
+    /**
+     * 添加
+     * @param studentCoursewarePlayRecord StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord
+     * @return Boolean
+     */
+    Boolean add(StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord studentCoursewarePlayRecord);
+
+    /**
+     * 更新
+     * @param studentCoursewarePlayRecord StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord
+     * @return Boolean
+     */
+    Boolean update(StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord studentCoursewarePlayRecord);
+
+    void save(StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordSave studentCoursewarePlayRecord);
+
+    List<StudentCoursewarePlayRecordWrapper.StatQueryData> statList(StudentCoursewarePlayRecordWrapper.StatQuery statQuery);
+
+    IPage<StudentCoursewarePlayRecordWrapper.StatQueryData> statDetailPage(StudentCoursewarePlayRecordWrapper.StatQuery statQuery);
+}

+ 123 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCoursewarePlayRecordServiceImpl.java

@@ -0,0 +1,123 @@
+package com.ym.mec.biz.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.entity.Student;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.service.StudentServeService;
+import com.ym.mec.common.page.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import lombok.extern.slf4j.Slf4j;
+import com.ym.mec.biz.dal.entity.StudentCoursewarePlayRecord;
+import com.ym.mec.biz.dal.wrapper.StudentCoursewarePlayRecordWrapper;
+import com.ym.mec.biz.dal.mapper.StudentCoursewarePlayRecordMapper;
+import com.ym.mec.biz.service.StudentCoursewarePlayRecordService;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * 学生课件播放统计记录
+ * 2024-07-04 14:48:14
+ */
+@Slf4j
+@Service
+public class StudentCoursewarePlayRecordServiceImpl extends ServiceImpl<StudentCoursewarePlayRecordMapper, StudentCoursewarePlayRecord> implements StudentCoursewarePlayRecordService {
+
+    @Autowired
+    private StudentDao studentDao;
+
+    @Autowired
+    private StudentRegistrationDao studentRegistrationDao;
+
+    @Autowired
+    private MusicGroupDao musicGroupDao;
+
+    /**
+     * 查询详情
+     *
+     * @param id 详情ID
+     * @return StudentCoursewarePlayRecord
+     */
+    @Override
+    public StudentCoursewarePlayRecord detail(Long id) {
+
+        return baseMapper.selectById(id);
+    }
+
+    /**
+     * 分页查询
+     *
+     * @param page  IPage<StudentCoursewarePlayRecord>
+     * @param query StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery
+     * @return IPage<StudentCoursewarePlayRecord>
+     */
+    @Override
+    public IPage<StudentCoursewarePlayRecord> selectPage(IPage<StudentCoursewarePlayRecord> page, StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordQuery query) {
+
+        return page.setRecords(baseMapper.selectPage(page, query));
+    }
+
+    /**
+     * 添加
+     *
+     * @param studentCoursewarePlayRecord StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord
+     * @return Boolean
+     */
+    @Override
+    public Boolean add(StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord studentCoursewarePlayRecord) {
+
+        return this.save(JSON.parseObject(studentCoursewarePlayRecord.jsonString(), StudentCoursewarePlayRecord.class));
+    }
+
+    /**
+     * 更新
+     *
+     * @param studentCoursewarePlayRecord StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord
+     * @return Boolean
+     */
+    @Override
+    public Boolean update(StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecord studentCoursewarePlayRecord) {
+
+        return this.updateById(JSON.parseObject(studentCoursewarePlayRecord.jsonString(), StudentCoursewarePlayRecord.class));
+    }
+
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void save(StudentCoursewarePlayRecordWrapper.StudentCoursewarePlayRecordSave studentCoursewarePlayRecord) {
+        Integer userId = studentCoursewarePlayRecord.getUserId();
+        Student student = studentDao.get(userId);
+        if (student == null) {
+            return;
+        }
+
+        StudentCoursewarePlayRecord record = new StudentCoursewarePlayRecord();
+        record.setOrganizationId(studentCoursewarePlayRecord.getOrganizationId());
+        record.setUserId(Long.valueOf(studentCoursewarePlayRecord.getUserId()));
+        record.setPlayTime(studentCoursewarePlayRecord.getPlayTime());
+        baseMapper.save(record);
+    }
+
+    @Override
+    public List<StudentCoursewarePlayRecordWrapper.StatQueryData> statList(StudentCoursewarePlayRecordWrapper.StatQuery statQuery) {
+        return baseMapper.statList(statQuery);
+    }
+
+    @Override
+    public IPage<StudentCoursewarePlayRecordWrapper.StatQueryData> statDetailPage(StudentCoursewarePlayRecordWrapper.StatQuery statQuery) {
+        IPage<StudentCoursewarePlayRecordWrapper.StatQueryData> page = QueryInfo.getPage(statQuery);
+        List<StudentCoursewarePlayRecordWrapper.StatQueryData> statQueryData = baseMapper.statDetailPage(page, statQuery);
+        page.setRecords(statQueryData);
+        return page;
+    }
+}

+ 54 - 0
mec-biz/src/main/resources/config/mybatis/StudentCoursewarePlayRecordMapper.xml

@@ -0,0 +1,54 @@
+<?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.mapper.StudentCoursewarePlayRecordMapper">
+    <select id="selectPage" resultType="com.ym.mec.biz.dal.entity.StudentCoursewarePlayRecord">
+        SELECT t.*
+        FROM student_courseware_play_record t
+    </select>
+
+    <insert id="save" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+        INSERT INTO student_courseware_play_record (organization_id_, user_id_, play_time_, update_time_, create_time_)
+        VALUES (#{record.organizationId},#{record.userId}, #{record.playTime}, NOW(), NOW())
+        ON DUPLICATE KEY UPDATE play_time_ = VALUES(ifnull(play_time_, 0) + #{record.playTime})
+    </insert>
+
+    <select id="statList" resultType="com.ym.mec.biz.dal.wrapper.StudentCoursewarePlayRecordWrapper$StatQueryData">
+        select o.id_                                                                                         as organizationId
+             , o.name_                                                                                       as organizationName
+             , count(if(s.membership_end_time_ >= now(), 1, 0))                                              as memberNum
+             , (count(distinct s.user_id_) - count(distinct pr.user_id_))                                    as noPlayNum
+             , count(distinct if(10 * 60 >= pr.play_time_, pr.user_id_, null))                               as playTimeLess10
+             , count(distinct if(pr.play_time_ > 10 * 60 and 600 * 60 >= pr.play_time_, pr.user_id_, null))  as playTimeLess60
+             , count(distinct if(pr.play_time_ > 10 * 60 and 120 * 60 >= pr.play_time_, pr.user_id_, null))  as playTimeLess120
+             , count(distinct if(pr.play_time_ > 120 * 60 and 240 * 60 >= pr.play_time_, pr.user_id_, null)) as playTimeLess240
+             , count(distinct if(pr.play_time_ > 240 * 60, pr.user_id_, null))                               as playTimeRather240
+             , (sum(pr.play_time_) / (count(distinct pr.user_id_)))                                          as avgPlayTime
+        from organization o
+                 left join student s on s.cooperation_organ_id_ = o.id_
+                 left join student_courseware_play_record pr on s.user_id_ = pr.user_id_ and pr.create_time_ > #{statQuery.startTime} and #{statQuery.endTime} > pr.create_time_
+        group by o.id_
+        order by #{statQuery.sortBy}
+    </select>
+    <select id="statDetailPage" resultType="com.ym.mec.biz.dal.wrapper.StudentCoursewarePlayRecordWrapper$StatQueryData">
+        select o.id_                                                                                         as organizationId
+             , o.name_                                                                                       as organizationName
+             , su.username_                                                                                  as teacherName
+             , count(distinct sr.user_id_)                                                                   as memberNum
+             , (count(distinct sr.user_id_) - count(distinct pr.user_id_))                                   as noPlayNum
+             , count(distinct if(10 * 60 >= pr.play_time_, pr.user_id_, null))                               as playTimeLess10
+             , count(distinct if(pr.play_time_ > 10 * 60 and 600 * 60 >= pr.play_time_, pr.user_id_, null))  as playTimeLess60
+             , count(distinct if(pr.play_time_ > 10 * 60 and 120 * 60 >= pr.play_time_, pr.user_id_, null))  as playTimeLess120
+             , count(distinct if(pr.play_time_ > 120 * 60 and 240 * 60 >= pr.play_time_, pr.user_id_, null)) as playTimeLess240
+             , count(distinct if(pr.play_time_ > 240 * 60, pr.user_id_, null))                               as playTimeRather240
+             , (sum(pr.play_time_) / (count(distinct pr.user_id_)))                                          as avgPlayTime
+        from organization o
+                 left join student s on s.cooperation_organ_id_ = o.id_
+                 left join student_registration sr on sr.user_id_ = s.user_id_
+                 left join student_teacher_mapper stm on stm.student_id_ = sr.user_id_
+                 left join sys_user su on su.id_ = stm.teacher_id_
+                 left join student_courseware_play_record pr on sr.user_id_ = pr.user_id_ and pr.create_time_ > #{statQuery.startTime} and #{statQuery.endTime} > pr.create_time_
+        where o.id_ = #{statQuery.organizationId}
+        group by stm.teacher_id_
+        order by #{statQuery.sortBy}
+    </select>
+</mapper>