Переглянути джерело

Merge branch 'master' of http://124.70.43.205:3000/GYEE_R.D/exam

chenminghua 2 роки тому
батько
коміт
99146097d9

+ 36 - 4
exam-06173-api/src/main/java/com/gyee/exam/modules/course/controller/CourseController.java

@@ -18,15 +18,17 @@ import com.gyee.exam.modules.course.dto.request.UserCourseReqDTO;
 import com.gyee.exam.modules.course.dto.response.UserCourseRespDTO;
 import com.gyee.exam.modules.course.entity.Course;
 import com.gyee.exam.modules.course.service.CourseService;
+import com.gyee.exam.modules.qu.service.QuService;
+import com.gyee.exam.modules.tmpl.service.TmplService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.shiro.authz.annotation.Logical;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
-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.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
 
 /**
 * <p>
@@ -44,6 +46,12 @@ public class CourseController extends BaseController {
     @Autowired
     private CourseService baseService;
 
+    @Autowired
+    private TmplService tmplService;
+
+    @Autowired
+    private QuService quService;
+
     /**
     * 添加或修改
     * @param reqDTO
@@ -150,4 +158,28 @@ public class CourseController extends BaseController {
         IPage<UserCourseRespDTO> page = baseService.userPaging(reqDTO);
         return super.success(page);
     }
+
+
+    /**
+     * 统计课程,题目、试卷总数
+     * @return
+     */
+    @ApiOperation(value = "统计总课程数")
+    @GetMapping("/ctt-total")
+    public ApiRest courseAllTotal() {
+        Map map = new HashMap<>();
+
+        int coursetotal = baseService.courseAllTotal();
+        int tmpltotal = tmplService.tmplTotal();
+        int titletotal = quService.titleTotal();
+
+        map.put("course",coursetotal);
+        map.put("tmpl",tmpltotal);
+        map.put("title",titletotal);
+
+        return super.success(map);
+    }
+
+
+
 }

+ 7 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/course/service/CourseService.java

@@ -62,4 +62,11 @@ public interface CourseService extends IService<Course> {
      */
     Course findSimple(String courseId);
 
+
+    /**
+     * 统计课程总数
+     * @return
+     */
+    int courseAllTotal();
+
 }

+ 11 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/course/service/impl/CourseServiceImpl.java

@@ -290,4 +290,15 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
         return this.getOne(wrapper, false);
     }
 
+    @Override
+    public int courseAllTotal() {
+
+        //查询条件
+        QueryWrapper<Course> wrapper = new QueryWrapper<>();
+        //查询总数量
+        Integer count = baseMapper.selectCount(wrapper);
+
+        return count;
+    }
+
 }

+ 12 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/qu/controller/QuController.java

@@ -298,4 +298,16 @@ public class QuController extends BaseController {
         }
 
     }
+
+
+    /**
+     * 查询题目总数
+     * @return
+     */
+    @ApiOperation(value = "查询题目总数")
+    @GetMapping("/title-total")
+    public ApiRest titleTotal() {
+        int count = baseService.titleTotal();
+        return super.success(count);
+    }
 }

+ 5 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/qu/mapper/QuMapper.java

@@ -44,5 +44,10 @@ public interface QuMapper extends BaseMapper<Qu> {
      */
     List<QuDetailDTO> listByRand(@Param("query") QuQueryReqDTO quDTO, @Param("size") Integer size);
 
+    /**
+     * 统计查询题目总数
+     * @return
+     */
+    int titleTotal();
 
 }

+ 8 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/qu/service/QuService.java

@@ -161,4 +161,12 @@ public interface QuService extends IService<Qu> {
      * @return
      */
     List<QuDetailDTO> listSub(String quId);
+
+
+    /**
+     * 统计查询题目总数
+     * @return
+     */
+    int titleTotal();
+
 }

+ 7 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/qu/service/impl/QuServiceImpl.java

@@ -474,4 +474,11 @@ public class QuServiceImpl extends ServiceImpl<QuMapper, Qu> implements QuServic
         quAnswerService.removeByQuIds(subIds);
 
     }
+
+    @Override
+    public int titleTotal() {
+
+        int count = baseMapper.titleTotal();
+        return count;
+    }
 }

+ 13 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/tmpl/controller/TmplController.java

@@ -132,4 +132,17 @@ public class TmplController extends BaseController {
         IPage<TmplDTO> page = baseService.paging(reqDTO);
         return super.success(page);
     }
+
+
+    /**
+     * 统计试卷数量
+     * @return
+     */
+    @ApiOperation(value = "统计试卷数量")
+    @GetMapping("/tmpl-total")
+    public ApiRest tmplTotal() {
+        int  count = baseService.tmplTotal();
+        return super.success(count);
+    }
+
 }

+ 6 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/tmpl/service/TmplService.java

@@ -75,4 +75,10 @@ public interface TmplService extends IService<Tmpl> {
      * @param ids
      */
     void deleteByIds(List<String> ids);
+
+    /**
+     * 统计试卷数量
+     * @return
+     */
+    int tmplTotal();
 }

+ 9 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/tmpl/service/impl/TmplServiceImpl.java

@@ -330,4 +330,13 @@ public class TmplServiceImpl extends ServiceImpl<TmplMapper, Tmpl> implements Tm
         }
     }
 
+
+    @Override
+    public int tmplTotal() {
+        QueryWrapper<Tmpl> wrapper = new QueryWrapper<>();
+        Integer count = baseMapper.selectCount(wrapper);
+        return count;
+    }
+
+
 }

+ 1 - 1
exam-06173-api/src/main/resources/mapper/course/CourseMapper.xml

@@ -134,7 +134,7 @@
         cs.title,
         SUM(rf.need_learn) needLearn,
         SUM(CASE WHEN fl.learn_min > rf.need_learn  THEN rf.need_learn ELSE fl.learn_min END) learnMin,
-        CASE WHEN Round(SUM(fl.learn_min)/SUM(rf.need_learn),2) >1 THEN  1 ELSE Round(SUM(fl.learn_min)/SUM(rf.need_learn),2) END AS proportion
+        SUM(CASE WHEN fl.learn_min > rf.need_learn THEN rf.need_learn ELSE fl.learn_min END)/SUM(rf.need_learn) AS proportion
         FROM el_course  cs
         LEFT JOIN el_course_ref_dir rd on cs.id = rd.course_id
         LEFT JOIN el_course_ref_file rf on rf.dir_id = rd.id

+ 7 - 0
exam-06173-api/src/main/resources/mapper/qu/QuMapper.xml

@@ -138,4 +138,11 @@
        ORDER BY RAND() LIMIT ${size}
     </select>
 
+    <select id="titleTotal" resultType="java.lang.Integer">
+        SELECT
+        COUNT(IF(qu.child=0, 1, NULL)) AS quCount
+        FROM el_repo repo
+        LEFT JOIN el_qu qu ON qu.repo_id=repo.id
+    </select>
+
 </mapper>