zouxuan 5 năm trước cách đây
mục cha
commit
2d0d97917d

+ 27 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/PracticeLessonApplyDao.java

@@ -1,7 +1,10 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.PracticeSumDto;
 import com.ym.mec.biz.dal.entity.PracticeLessonApply;
 
+import java.util.List;
+
 public interface PracticeLessonApplyDao extends com.ym.mec.common.dal.BaseDAO<Integer, PracticeLessonApply> {
 
 
@@ -11,4 +14,28 @@ public interface PracticeLessonApplyDao extends com.ym.mec.common.dal.BaseDAO<In
      * @return
      */
     PracticeLessonApply findByUserId(Integer userId);
+
+    /**
+     * 陪练课列表页
+     * @return
+     */
+    List<PracticeSumDto> practiceSum();
+
+    /**
+     * 获取学生总人数
+     * @return
+     */
+    Integer getTotalNum();
+
+    /**
+     * 激活总人数
+     * @return
+     */
+    Integer getActiveNum();
+
+    /**
+     * 预约总人数
+     * @return
+     */
+    Integer getMakeNum();
 }

+ 54 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeSumDto.java

@@ -0,0 +1,54 @@
+package com.ym.mec.biz.dal.dto;
+
+public class PracticeSumDto{
+
+    private String organName;
+
+    private Integer totalNum;
+
+    private Integer activeNum;
+
+    private Integer makeNum;
+
+    private float per;
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public Integer getTotalNum() {
+        return totalNum;
+    }
+
+    public void setTotalNum(Integer totalNum) {
+        this.totalNum = totalNum;
+    }
+
+    public Integer getActiveNum() {
+        return activeNum;
+    }
+
+    public void setActiveNum(Integer activeNum) {
+        this.activeNum = activeNum;
+    }
+
+    public Integer getMakeNum() {
+        return makeNum;
+    }
+
+    public void setMakeNum(Integer makeNum) {
+        this.makeNum = makeNum;
+    }
+
+    public float getPer() {
+        return per;
+    }
+
+    public void setPer(float per) {
+        this.per = per;
+    }
+}

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

@@ -3,6 +3,8 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.PracticeLessonApply;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.Map;
+
 public interface PracticeLessonApplyService extends BaseService<Integer, PracticeLessonApply>{
 
     /**
@@ -11,4 +13,10 @@ public interface PracticeLessonApplyService extends BaseService<Integer, Practic
      * @return
      */
     PracticeLessonApply findByUserId(Integer userId);
+
+    /**
+     * 预约人数列表页
+     * @return
+     */
+    Map<String, Object> practiceSum();
 }

+ 19 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeLessonApplyServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dto.PracticeSumDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -9,6 +10,10 @@ import com.ym.mec.biz.service.PracticeLessonApplyService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @Service
 public class PracticeLessonApplyServiceImpl extends BaseServiceImpl<Integer, PracticeLessonApply>  implements PracticeLessonApplyService {
 	
@@ -24,4 +29,18 @@ public class PracticeLessonApplyServiceImpl extends BaseServiceImpl<Integer, Pra
 	public PracticeLessonApply findByUserId(Integer userId) {
 		return practiceLessonApplyDao.findByUserId(userId);
 	}
+
+	@Override
+	public Map<String, Object> practiceSum() {
+		List<PracticeSumDto> practiceSumDtos = practiceLessonApplyDao.practiceSum();
+		Integer totalNum = practiceLessonApplyDao.getTotalNum();
+		Integer activeNum = practiceLessonApplyDao.getActiveNum();
+		Integer makeNum = practiceLessonApplyDao.getMakeNum();
+		Map<String,Object> map = new HashMap<>();
+		map.put("totalNum",totalNum);
+		map.put("activeNum",activeNum);
+		map.put("makeNum",makeNum);
+		map.put("practiceSumDtos",practiceSumDtos);
+		return map;
+	}
 }

+ 27 - 0
mec-biz/src/main/resources/config/mybatis/PracticeLessonApplyMapper.xml

@@ -43,4 +43,31 @@
     <select id="findByUserId" resultMap="PracticeLessonApply">
 		SELECT * FROM practice_lesson_apply WHERE user_id_ = #{userId} LIMIT 1
 	</select>
+	<resultMap id="practiceSumMap" type="com.ym.mec.biz.dal.dto.PracticeSumDto">
+		<result property="organName" column="organName"/>
+		<result property="per" column="per"/>
+		<result property="activeNum" column="activeNum"/>
+		<result property="makeNum" column="makeNum"/>
+		<result property="totalNum" column="totalNum"/>
+	</resultMap>
+    <select id="practiceSum" resultMap="practiceSumMap">
+		SELECT o.name_ organName,COUNT(su.id_) totalNum,COUNT(ps.id_) activeNum,COUNT(pla.user_id_) makeNum,COUNT(pla.user_id_) / COUNT(su.id_) per FROM sys_user su
+		LEFT JOIN practice_lesson_apply pla ON pla.user_id_ = su.id_
+		LEFT JOIN organization o ON o.id_ = su.organ_id_
+		LEFT JOIN sys_user ps ON ps.id_ = su.id_ AND ps.password_ IS NOT NULL
+		WHERE su.user_type_ LIKE 'STUDENT' AND su.organ_id_ NOT IN (36,38,39)
+		GROUP BY su.organ_id_
+		ORDER BY per DESC
+	</select>
+	<select id="getTotalNum" resultType="java.lang.Integer">
+		SELECT COUNT(su.id_) FROM sys_user su
+		WHERE su.user_type_ LIKE 'STUDENT' AND su.organ_id_ NOT IN (36,38,39)
+	</select>
+	<select id="getActiveNum" resultType="java.lang.Integer">
+		SELECT COUNT(su.id_) FROM sys_user su
+		WHERE su.user_type_ LIKE 'STUDENT' AND su.password_ IS NOT NULL AND su.organ_id_ NOT IN (36,38,39)
+	</select>
+	<select id="getMakeNum" resultType="java.lang.Integer">
+		SELECT COUNT(id_) FROM practice_lesson_apply
+	</select>
 </mapper>

+ 12 - 6
mec-web/src/main/java/com/ym/mec/web/controller/APIController.java

@@ -1,17 +1,15 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.service.PracticeLessonApplyService;
+import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
-import com.ym.mec.biz.dal.entity.SysUserCashAccount;
-import com.ym.mec.common.controller.BaseController;
-
 @RequestMapping("api")
 @Api(tags = "对外接口")
 @RestController
@@ -20,6 +18,9 @@ public class APIController extends BaseController {
 	@Autowired
 	private SysUserCashAccountDao sysUserCashAccountDao;
 
+	@Autowired
+	private PracticeLessonApplyService practiceLessonApplyService;
+
 	@GetMapping("/createCashAccount")
 	public Boolean createCashAccount(Integer userId) {
 		// 添加用户现金账户
@@ -28,4 +29,9 @@ public class APIController extends BaseController {
 		return true;
 	}
 
+	@GetMapping("/practiceSum")
+	public Object practiceSum() {
+		return practiceLessonApplyService.practiceSum();
+	}
+
 }