Bladeren bron

课表数据统计

dzx 6 maanden geleden
bovenliggende
commit
f60c7cbb59

+ 32 - 0
src/main/java/com/xjrsoft/module/databoard/controller/DatadetailController.java

@@ -20,6 +20,7 @@ import com.xjrsoft.module.databoard.vo.DurationVo;
 import com.xjrsoft.module.databoard.vo.HealthItemCountVo;
 import com.xjrsoft.module.databoard.vo.HealthStatisticsDetailVo;
 import com.xjrsoft.module.databoard.vo.ItemCountAmountVo;
+import com.xjrsoft.module.databoard.vo.ItemCountRatioVo;
 import com.xjrsoft.module.databoard.vo.ItemCountVo;
 import com.xjrsoft.module.databoard.vo.ItemDoubleVo;
 import com.xjrsoft.module.databoard.vo.ProcessStatisticsDetailVo;
@@ -52,6 +53,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.Duration;
@@ -643,6 +646,35 @@ public class DatadetailController {
             courseCountList.add(listVo);
         }
         result.setCourseCountList(courseCountList);
+        
+        sql = "SELECT count(*) FROM course_table t1" +
+            " INNER JOIN base_teacher t2 ON t1.teacher_id = t2.user_id" +
+            " 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";
+        long allCourseCount = SqlRunnerAdapter.db().selectCount(sql);
+        sql = "SELECT name,(" +
+            " SELECT COUNT(*) FROM course_table t1" +
+            " INNER JOIN base_teacher t2 ON t1.teacher_id = t2.user_id" +
+            " 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";
+        list = SqlRunnerAdapter.db().selectList(sql);
+        List<ItemCountRatioVo> deptCourseList = new ArrayList<>();
+        for (Map<String, Object> objectMap : list) {
+            int courseCount = Integer.parseInt(objectMap.get("course_count").toString());
+            //计算出勤率
+            BigDecimal divide = BigDecimal.valueOf(courseCount).divide(BigDecimal.valueOf(allCourseCount), 4, RoundingMode.HALF_UP);
+            deptCourseList.add(
+                    new ItemCountRatioVo() {{
+                        setItem(objectMap.get("name").toString());
+                        setCount(courseCount);
+                        setRatio(divide.doubleValue());
+                    }}
+            );
+        }
+        result.setDeptCourseList(deptCourseList);
         return RT.ok(result);
     }
 

+ 2 - 2
src/main/java/com/xjrsoft/module/form/service/impl/FormExecuteServiceImpl.java

@@ -1010,7 +1010,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
                     if (childTableConfig.isPresent()) {
                         //删除子表单数据
                         // 查询是否有子表数据,如果有就删除,没有返回
-                        long count = SqlRunnerAdapter.db().selectCount("select * from " + tableMap.getKey() + " where " + childTableConfig.get().getRelationField() + " = " + keyValue2);
+                        long count = SqlRunnerAdapter.db().selectCount("select count(*) from " + tableMap.getKey() + " where " + childTableConfig.get().getRelationField() + " = " + keyValue2);
 
                         if (count > 0) {
                             Entity childDeleteWhere = Entity.create(tableMap.getKey()).set(childTableConfig.get().getRelationField(), keyValue2);
@@ -1297,7 +1297,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
                         //删除子表单数据
                         String keyValuesStr = "(" + keyValue + ")";
 
-                        long count = SqlRunnerAdapter.db().selectCount("select * from " + childTableConfig.get().getTableName() + " where " + childTableConfig.get().getRelationField() + " in " + keyValuesStr);
+                        long count = SqlRunnerAdapter.db().selectCount("select count(*) from " + childTableConfig.get().getTableName() + " where " + childTableConfig.get().getRelationField() + " in " + keyValuesStr);
                         if (count > 0) {
                             Entity childDeleteWhere = Entity.create(tableMap.getKey()).set(childTableConfig.get().getRelationField(), keyValue);
                             result = SqlRunnerAdapter.db().dynamicDelete(childTableConfig.get().getTableName(), childDeleteWhere);

+ 1 - 1
src/test/java/com/xjrsoft/module/oa/service/impl/NewsServiceImplTest.java

@@ -51,7 +51,7 @@ class NewsServiceImplTest {
         JSONObject data = new JSONObject();
 
         JSONObject data1 = new JSONObject();
-        data1.put("value", "关于调整2024年秋季学期开学及召开教职工大会的通知");
+        data1.put("value", "关于调整2024年秋季学期开学及召开教");
         data.put("thing23", data1);
 
         JSONObject data2 = new JSONObject();