Kaynağa Gözat

数据面板,课表详情统计没有数据修复

dzx 8 ay önce
ebeveyn
işleme
ee6859d69d

+ 31 - 9
src/main/java/com/xjrsoft/module/databoard/controller/DatadetailController.java

@@ -794,15 +794,29 @@ public class DatadetailController {
     @SaCheckPermission("datadetail:detail")
     @XjrLog(value = "课表详情数据统计", saveResponseData = true)
     public RT<CourseStatisticsDetailVo> courseStatistics(@Valid StatisticsDetailDto dto) {
+        String startDate = null;
+        String endDate = null;
+        if(dto.getStartDate() != null &&  dto.getEndDate() != null){
+            startDate = dto.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            endDate = dto.getEndDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        }
         CourseStatisticsDetailVo result = new CourseStatisticsDetailVo();
-        String sql = "SELECT t1.id, t1.name,t4.name AS dept_name," +
-                " (SELECT GROUP_CONCAT(DISTINCT(course_name)) FROM course_table WHERE teacher_id like concat('%', t1.id,'%') ) AS course_names," +
-                " (SELECT COUNT(*) FROM course_table WHERE teacher_id like concat('%', t1.id,'%')) AS course_count FROM xjr_user t1" +
+        String sql = "SELECT t1.id, t1.name,t4.name AS dept_name,( " +
+                " SELECT GROUP_CONCAT(DISTINCT(course_name)) FROM course_table WHERE FIND_IN_SET(t1.id, teacher_id) > 0 ";
+        if(startDate != null){
+            sql += " and schedule_date between '" + startDate + "' and '" + endDate + "'";
+        }
+        sql += " ) AS course_names,(" +
+                "SELECT COUNT(*) FROM course_table WHERE FIND_IN_SET(t1.id, teacher_id) > 0 ";
+        if(startDate != null){
+            sql += " and schedule_date between '" + startDate + "' and '" + endDate + "'";
+        }
+        sql += " ) AS course_count FROM xjr_user t1" +
                 " INNER JOIN base_teacher t2 ON t1.id = t2.user_id" +
                 " INNER JOIN xjr_user_dept_relation t3 ON t1.id = t3.user_id" +
                 " INNER JOIN xjr_department t4 ON t3.dept_id = t4.id" +
-                " WHERE t1.delete_mark = 0 AND t4.is_major = 1" +
-                " ORDER BY course_count DESC LIMIT 5";
+                " WHERE t1.delete_mark = 0 AND t4.is_major = 1";
+        sql += " ORDER BY course_count DESC LIMIT 5";
         List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
         List<CourseCountListVo> courseCountList = new ArrayList<>();
         for (Map<String, Object> objectMap : list) {
@@ -812,18 +826,26 @@ public class DatadetailController {
         result.setCourseCountList(courseCountList);
 
         sql = "SELECT count(*) FROM course_table t1" +
-                " INNER JOIN base_teacher t2 ON t1.teacher_id like concat('%', t2.user_id,'%')" +
+                " INNER JOIN base_teacher t2 ON FIND_IN_SET(t2.user_id, t1.teacher_id) > 0" +
                 " INNER JOIN xjr_user_dept_relation t3 ON t2.user_id = t3.user_id" +
                 " INNER JOIN xjr_department t4 ON t4.id = t3.dept_id" +
                 " WHERE t4.delete_mark = 0 AND t2.delete_mark = 0" +
                 " AND t4.is_major = 1";
+        if(startDate != null){
+            sql += " and t1.schedule_date between '" + startDate + "' and '" + endDate + "'";
+        }
         long allCourseCount = SqlRunnerAdapter.db().selectCount(sql);
+
+
         sql = "SELECT name,(" +
                 " SELECT COUNT(*) FROM course_table t1" +
-                " INNER JOIN base_teacher t2 ON t1.teacher_id like concat('%', t2.user_id,'%')" +
+                " INNER JOIN base_teacher t2 ON FIND_IN_SET(t2.user_id, t1.teacher_id) > 0" +
                 " INNER JOIN xjr_user_dept_relation t3 ON t2.user_id = t3.user_id" +
-                " WHERE t3.dept_id = xjr_department.id" +
-                " ) AS course_count FROM xjr_department WHERE is_major = 1";
+                " WHERE t3.dept_id = xjr_department.id";
+        if(startDate != null){
+            sql += " and t1.schedule_date between '" + startDate + "' and '" + endDate + "'";
+        }
+        sql += " ) AS course_count FROM xjr_department WHERE is_major = 1";
         list = SqlRunnerAdapter.db().selectList(sql);
         List<ItemCountRatioVo> deptCourseList = new ArrayList<>();
         for (Map<String, Object> objectMap : list) {