Преглед изворни кода

增加学生运营指标查询

周箭河 пре 5 година
родитељ
комит
97831e8ad2

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

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.Student4operating;
 import com.ym.mec.biz.dal.entity.Student;
 import org.apache.ibatis.annotations.Param;
 
@@ -13,5 +14,20 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
 
 
     List<SysUser> findStudents(Map<String, Object> params);
+
     int countStudents(Map<String, Object> params);
+
+    /**
+     * 查询运营学生列表
+     * @param params
+     * @return
+     */
+    List<Student4operating> getOperatingStudents(Map<String, Object> params);
+
+    /**
+     * 查询运营学生总数
+     * @param params
+     * @return
+     */
+    Integer countOperatingStudents(Map<String, Object> params);
 }

+ 102 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/Student4operating.java

@@ -0,0 +1,102 @@
+package com.ym.mec.biz.dal.dto;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+public class Student4operating {
+
+private String organName;
+private String organId;
+private String studentName;
+private Integer studentId;
+private String teacherId;
+private String teacherName;
+private Integer operatingTag;
+private Integer vipTimes;
+private Integer freePracticeTimes;
+private Integer buyPracticeTimes;
+
+	public String getOrganName() {
+		return organName;
+	}
+
+	public void setOrganName(String organName) {
+		this.organName = organName;
+	}
+
+	public String getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(String organId) {
+		this.organId = organId;
+	}
+
+	public String getStudentName() {
+		return studentName;
+	}
+
+	public void setStudentName(String studentName) {
+		this.studentName = studentName;
+	}
+
+	public Integer getStudentId() {
+		return studentId;
+	}
+
+	public void setStudentId(Integer studentId) {
+		this.studentId = studentId;
+	}
+
+	public String getTeacherId() {
+		return teacherId;
+	}
+
+	public void setTeacherId(String teacherId) {
+		this.teacherId = teacherId;
+	}
+
+	public String getTeacherName() {
+		return teacherName;
+	}
+
+	public void setTeacherName(String teacherName) {
+		this.teacherName = teacherName;
+	}
+
+	public Integer getOperatingTag() {
+		return operatingTag;
+	}
+
+	public void setOperatingTag(Integer operatingTag) {
+		this.operatingTag = operatingTag;
+	}
+
+	public Integer getVipTimes() {
+		return vipTimes;
+	}
+
+	public void setVipTimes(Integer vipTimes) {
+		this.vipTimes = vipTimes;
+	}
+
+	public Integer getFreePracticeTimes() {
+		return freePracticeTimes;
+	}
+
+	public void setFreePracticeTimes(Integer freePracticeTimes) {
+		this.freePracticeTimes = freePracticeTimes;
+	}
+
+	public Integer getBuyPracticeTimes() {
+		return buyPracticeTimes;
+	}
+
+	public void setBuyPracticeTimes(Integer buyPracticeTimes) {
+		this.buyPracticeTimes = buyPracticeTimes;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+}

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Student.java

@@ -16,6 +16,8 @@ public class Student {
 	private Integer serviceTag;
 
 	private Integer operatingTag;
+
+	private Integer teacherId;
 	
 	/**  */
 	private java.util.Date createTime;
@@ -83,9 +85,16 @@ public class Student {
 	public void setOperatingTag(Integer operatingTag) {
 		this.operatingTag = operatingTag;
 	}
+
+	public Integer getTeacherId() {
+		return teacherId;
+	}
+
+	public void setTeacherId(Integer teacherId) {
+		this.teacherId = teacherId;
+	}
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
-
 }

+ 77 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentOperatingQueryInfo.java

@@ -0,0 +1,77 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+
+public class StudentOperatingQueryInfo extends QueryInfo {
+    
+    @ApiModelProperty(value = "部门ID")
+    private String organId;
+
+    @ApiModelProperty(value = "指导老师")
+    private Integer teacherId;
+
+    @ApiModelProperty(value = "运营指标")
+    private Integer operatingTag;
+
+    @ApiModelProperty(value = "是否有VIP课")
+    private Integer hasVip;
+
+    @ApiModelProperty(value = "是否有免费网管课")
+    private Integer HasFreePractice;
+
+    @ApiModelProperty(value = "是否有收费网管课")
+    private Integer HasBuyPractice;
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+
+    public Integer getTeacherId() {
+        return teacherId;
+    }
+
+    public void setTeacherId(Integer teacherId) {
+        this.teacherId = teacherId;
+    }
+
+    public Integer getOperatingTag() {
+        return operatingTag;
+    }
+
+    public void setOperatingTag(Integer operatingTag) {
+        this.operatingTag = operatingTag;
+    }
+
+    public Integer getHasVip() {
+        return hasVip;
+    }
+
+    public void setHasVip(Integer hasVip) {
+        this.hasVip = hasVip;
+    }
+
+    public Integer getHasFreePractice() {
+        return HasFreePractice;
+    }
+
+    public void setHasFreePractice(Integer hasFreePractice) {
+        HasFreePractice = hasFreePractice;
+    }
+
+    public Integer getHasBuyPractice() {
+        return HasBuyPractice;
+    }
+
+    public void setHasBuyPractice(Integer hasBuyPractice) {
+        HasBuyPractice = hasBuyPractice;
+    }
+}

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentManageService.java

@@ -145,4 +145,11 @@ public interface StudentManageService {
      * @return
      */
     Map<String,Integer> sumStudentAttendance(Integer courseScheduleId);
+
+    /**
+     * 运营指标学生
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<Student4operating> getOperatingStudents(StudentOperatingQueryInfo queryInfo);
 }

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

@@ -61,6 +61,8 @@ public class StudentManageServiceImpl implements StudentManageService {
     private VipGroupDao vipGroupDao;
     @Autowired
     private SysUserCashAccountDao sysUserCashAccountDao;
+    @Autowired
+    private StudentDao studentDao;
 
     @Override
     public PageInfo<StudentManageListDto> findStudentsByOrganId(StudentManageQueryInfo queryInfo) {
@@ -450,4 +452,22 @@ public class StudentManageServiceImpl implements StudentManageService {
         sum.put("repliedNum",studentManageDao.countRepliedNum(courseScheduleId));
         return sum;
     }
+
+    @Override
+    public PageInfo<Student4operating> getOperatingStudents(StudentOperatingQueryInfo queryInfo) {
+        PageInfo<Student4operating> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+        params.put("offset", pageInfo.getOffset());
+        Integer count = studentDao.countOperatingStudents(params);
+
+        List<Student4operating> dataList = new ArrayList<>();
+
+        if(count > 0){
+            pageInfo.setTotal(count);
+            dataList = studentDao.getOperatingStudents(params);
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
 }

+ 213 - 97
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -5,104 +5,220 @@
 不要修改此文件。所有改动将在下次重新自动生成时丢失。
 -->
 <mapper namespace="com.ym.mec.biz.dal.dao.StudentDao">
-	
-	<resultMap type="com.ym.mec.biz.dal.entity.Student" id="Student">
-		<result column="user_id_" property="userId" />
-		<result column="subject_id_list_" property="subjectIdList" />
-		<result column="service_tag_" property="serviceTag" />
-		<result column="operating_tag_" property="operatingTag" />
-		<result column="create_time_" property="createTime" />
-		<result column="update_time_" property="updateTime" />
-	</resultMap>
 
-	<!-- 根据主键查询一条记录 -->
-	<select id="get" resultMap="Student">
-		SELECT * FROM student WHERE user_id_ = #{id}
-	</select>
+    <resultMap type="com.ym.mec.biz.dal.entity.Student" id="Student">
+        <result column="user_id_" property="userId"/>
+        <result column="subject_id_list_" property="subjectIdList"/>
+        <result column="service_tag_" property="serviceTag"/>
+        <result column="operating_tag_" property="operatingTag"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+    </resultMap>
 
-	<!-- 全查询 -->
-	<select id="findAll" resultMap="Student">
-		SELECT * FROM student
-	</select>
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="Student">
+        SELECT *
+        FROM student
+        WHERE user_id_ = #{id}
+    </select>
 
-	<select id="lockUser" resultType="int" useCache="false" flushCache="true">
-		SELECT id_ FROM sys_user WHERE id_=#{userId} FOR UPDATE
-	</select>
-	
-	<!-- 向数据库增加一条记录 -->
-	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Student" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO student (user_id_,subject_id_list_,
-		<if test="serviceTag != null">
-			service_tag_,
-		</if>
-		<if test="operatingTag != null">
-			operating_tag_,
-		</if>
-		create_time_,update_time_)
-		VALUES
-		(#{userId},#{subjectIdList},
-		<if test="serviceTag != null">
-			#{serviceTag},
-		</if>
-		<if test="operatingTag != null">
-			#{operatingTag},
-		</if>
-		NOW(),NOW())
-	</insert>
-	
-	<update id="update" parameterType="com.ym.mec.biz.dal.entity.Student">
-		UPDATE student
-		<set>
-			<if test="subjectIdList != null">
-				subject_id_list_ = #{subjectIdList},
-			</if>
-			<if test="serviceTag != null">
-				service_tag_ = #{serviceTag},
-			</if>
-			<if test="operatingTag != null">
-				operating_tag_ = #{operatingTag},
-			</if>
-			<if test="updateTime != null">
-				update_time_ = #{updateTime},
-			</if>
-			<if test="updateTime == null">
-				update_time_ = NOW()
-			</if>
-		</set>
-		WHERE user_id_ = #{userId}
-	</update>
-	
-	<!-- 分页查询 -->
-	<select id="queryPage" resultMap="Student" parameterType="map">
-		SELECT * FROM student <include refid="global.limit"/>
-	</select>
-	
-	<!-- 查询当前表的总记录数 -->
-	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM student
-	</select>
-	<select id="findStudents" resultMap="com.ym.mec.biz.dal.dao.TeacherDao.SysUser">
-		SELECT id_, username_, phone_,avatar_ FROM sys_user
-		<include refid="studentQueryCondition"/>
-		ORDER BY id_
-		<include refid="global.limit"/>
-	</select>
-	<select id="countStudents" resultType="int">
-		SELECT COUNT(id_) FROM sys_user
-		<include refid="studentQueryCondition"/>
-	</select>
-	<sql id="studentQueryCondition">
-		<where>
-			<if test="organIdList!=null">
-				organ_id_ IN
-				<foreach collection="organIdList" item="organId" open="(" close=")" separator=",">
-					#{organId}
-				</foreach>
-			</if>
-			<if test="search!=null">
-				AND (username_ LIKE CONCAT('%', #{search}, '%') OR phone_ LIKE CONCAT('%', #{search}, '%'))
-			</if>
-			AND FIND_IN_SET("STUDENT", user_type_)
-		</where>
-	</sql>
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="Student">
+        SELECT *
+        FROM student
+    </select>
+
+    <select id="lockUser" resultType="int" useCache="false" flushCache="true">
+        SELECT id_
+        FROM sys_user
+        WHERE id_ = #{userId} FOR
+        UPDATE
+    </select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Student" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO student (user_id_,subject_id_list_,
+        <if test="serviceTag != null">
+            service_tag_,
+        </if>
+        <if test="operatingTag != null">
+            operating_tag_,
+        </if>
+        create_time_,update_time_)
+        VALUES
+        (#{userId},#{subjectIdList},
+        <if test="serviceTag != null">
+            #{serviceTag},
+        </if>
+        <if test="operatingTag != null">
+            #{operatingTag},
+        </if>
+        NOW(),NOW())
+    </insert>
+
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.Student">
+        UPDATE student
+        <set>
+            <if test="subjectIdList != null">
+                subject_id_list_ = #{subjectIdList},
+            </if>
+            <if test="serviceTag != null">
+                service_tag_ = #{serviceTag},
+            </if>
+            <if test="operatingTag != null">
+                operating_tag_ = #{operatingTag},
+            </if>
+            <if test="updateTime != null">
+                update_time_ = #{updateTime},
+            </if>
+            <if test="updateTime == null">
+                update_time_ = NOW()
+            </if>
+        </set>
+        WHERE user_id_ = #{userId}
+    </update>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="Student" parameterType="map">
+        SELECT * FROM student
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*)
+        FROM student
+    </select>
+    <select id="findStudents" resultMap="com.ym.mec.biz.dal.dao.TeacherDao.SysUser">
+        SELECT id_, username_, phone_,avatar_ FROM sys_user
+        <include refid="studentQueryCondition"/>
+        ORDER BY id_
+        <include refid="global.limit"/>
+    </select>
+    <select id="countStudents" resultType="int">
+        SELECT COUNT(id_) FROM sys_user
+        <include refid="studentQueryCondition"/>
+    </select>
+    <sql id="studentQueryCondition">
+        <where>
+            <if test="organIdList!=null">
+                organ_id_ IN
+                <foreach collection="organIdList" item="organId" open="(" close=")" separator=",">
+                    #{organId}
+                </foreach>
+            </if>
+            <if test="search!=null">
+                AND (username_ LIKE CONCAT('%', #{search}, '%') OR phone_ LIKE CONCAT('%', #{search}, '%'))
+            </if>
+            AND FIND_IN_SET("STUDENT", user_type_)
+        </where>
+    </sql>
+
+    <resultMap id="student4operating" type="com.ym.mec.biz.dal.dto.Student4operating">
+        <result column="organ_name_" property="organName"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="student_name_" property="studentName"/>
+        <result column="student_id_" property="studentId"/>
+        <result column="teacher_id_" property="teacherId"/>
+        <result column="teacher_name_" property="teacherName"/>
+        <result column="operating_tag_" property="operatingTag"/>
+        <result column="vip_times_" property="vipTimes"/>
+        <result column="free_practice_times_" property="freePracticeTimes"/>
+        <result column="buy_practice_times_" property="buyPracticeTimes"/>
+    </resultMap>
+
+    <select id="getOperatingStudents" resultMap="student4operating">
+        SELECT su.organ_id_,
+               o.name_ organ_name_,
+               su.username_   student_name_,
+               s.user_id_     student_id_,
+               tsu.id_        teacher_id_,
+               tsu.real_name_ teacher_name_,
+               s.operating_tag_,
+               a.vip_times_,
+               a.buy_practice_times_,
+               p.free_practice_times_
+        FROM student s
+                 LEFT JOIN sys_user su ON s.user_id_ = su.id_
+                 LEFT JOIN sys_user tsu ON tsu.id_ = s.teacher_id_
+                 LEFT JOIN organization o ON o.id_ = su.organ_id_
+                 LEFT JOIN (
+            SELECT s.user_id_,
+                   SUM(case when (cs.group_type_ = 'VIP') then 1 ELSE 0 END) vip_times_,
+                   SUM(case when (pg.buy_months_ > 0) then 1 ELSE 0 END)     buy_practice_times_
+            FROM student s
+                     LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.user_id_
+                     LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+                     LEFT JOIN practice_group pg ON pg.`id_` = cs.`music_group_id_` AND cs.`group_type_` = 'PRACTICE'
+            WHERE cs.status_ = 'NOT_START'
+            GROUP BY s.user_id_
+        ) a on a.user_id_ = s.user_id_
+                 LEFT JOIN (
+            SELECT student_id_, count(id_) free_practice_times_
+            FROM practice_group
+            WHERE buy_months_ IS NULL
+            GROUP BY student_id_
+        ) p ON p.student_id_ = s.user_id_
+        <include refid="student4OperatingQueryCondition"/>
+        ORDER BY s.user_id_
+        <include refid="global.limit"/>
+    </select>
+
+    <select id="countOperatingStudents" resultType="int">
+        SELECT COUNT(s.user_id_) FROM student s
+        LEFT JOIN sys_user su ON s.user_id_ = su.id_
+        LEFT JOIN sys_user tsu ON tsu.id_ = s.teacher_id_
+        LEFT JOIN (
+        SELECT s.user_id_,
+        SUM(case when (cs.group_type_ = 'VIP') then 1 ELSE 0 END) vip_times_,
+        SUM(case when (pg.buy_months_ > 0) then 1 ELSE 0 END)     buy_practice_times_
+        FROM student s
+        LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.user_id_
+        LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+        LEFT JOIN practice_group pg ON pg.`id_` = cs.`music_group_id_` AND cs.`group_type_` = 'PRACTICE'
+        WHERE cs.status_ = 'NOT_START'
+        GROUP BY s.user_id_
+        ) a on a.user_id_ = s.user_id_
+        LEFT JOIN (
+        SELECT student_id_, count(id_) free_practice_times_
+        FROM practice_group
+        WHERE buy_months_ IS NULL
+        GROUP BY student_id_
+        ) p ON p.student_id_ = s.user_id_
+
+        <include refid="student4OperatingQueryCondition"/>
+    </select>
+
+    <sql id="student4OperatingQueryCondition">
+        <where>
+            <if test="organId != null and organId != ''">
+                AND FIND_IN_SET(su.organ_id_,#{organId})
+            </if>
+            <if test="teacherId!=null">
+                AND s.teacher_id_ = #{teacherId}
+            </if>
+            <if test="operatingTag !=null">
+                AND s.operating_tag_ = #{operatingTag}
+            </if>
+            <if test='hasVip != null and hasVip.toString()=="1".toString()'>
+                AND a.vip_times_ >=1
+            </if>
+            <if test='hasVip != null and hasVip.toString()=="0".toString()'>
+                AND (a.vip_times_ =0 OR a.vip_times_ IS NULL)
+            </if>
+            <if test='HasFreePractice != null and HasFreePractice.toString()=="1".toString()'>
+                AND p.free_practice_times_ >=1
+            </if>
+            <if test='HasFreePractice != null and HasFreePractice.toString()=="0".toString()'>
+                AND (p.free_practice_times_ =0 OR p.free_practice_times_ IS NULL)
+            </if>
+            <if test='HasBuyPractice != null and HasBuyPractice.toString()=="1".toString()'>
+                AND a.buy_practice_times_ >=1
+            </if>
+            <if test='HasBuyPractice != null and HasBuyPractice.toString()=="0".toString()'>
+                AND (a.buy_practice_times_ =0 OR a.buy_practice_times_ IS NULL)
+            </if>
+        </where>
+    </sql>
 </mapper>

+ 24 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentManageController.java

@@ -262,4 +262,28 @@ public class StudentManageController extends BaseController {
         }
         return succeed(studentManageService.sumStudentAttendance(courseScheduleId));
     }
+
+    @ApiOperation(value = "获取运营指标列表")
+    @GetMapping("/getOperatingStudents")
+    @PreAuthorize("@pcs.hasPermissions('studentManage/getOperatingStudents')")
+    public Object getOperatingStudents(StudentOperatingQueryInfo queryInfo){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        if(!sysUser.getIsSuperAdmin()){
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+                queryInfo.setOrganId(employee.getOrganIdList());
+            }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+                return failed("用户所在分部异常");
+            }else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                    return failed("非法请求");
+                }
+            }
+        }
+        return succeed(studentManageService.getOperatingStudents(queryInfo));
+    }
 }