Browse Source

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/test/java/com/xjrsoft/module/job/JianyuekbScheduleTaskTest.java
#	src/test/java/com/xjrsoft/module/job/JianyuekbScheduleTaskTest2.java
大数据与最优化研究所 2 weeks ago
parent
commit
09eb42261e

+ 74 - 87
src/main/java/com/xjrsoft/module/databoard/controller/DatadetailController.java

@@ -35,6 +35,7 @@ import com.xjrsoft.module.workflow.entity.WorkflowExtra;
 import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
 import com.xjrsoft.module.workflow.entity.WorkflowSchema;
 import com.xjrsoft.module.workflow.service.IWorkflowExtraService;
+import com.xjrsoft.module.workflow.service.IWorkflowFormRelationService;
 import com.xjrsoft.module.workflow.utils.WorkFlowUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -71,7 +72,7 @@ import java.util.stream.Collectors;
 public class DatadetailController {
 
     private final HistoryService historyService;
-    private final IWorkflowExtraService extraService;
+    private final IWorkflowFormRelationService relationService;
     private final ITeacherbaseManagerService teacherService;
     private final IBaseStudentService studentService;
     private final IWfSubscriptionService subscriptionService;
@@ -82,98 +83,62 @@ public class DatadetailController {
     @SaCheckPermission("datadetail:detail")
     @XjrLog(value = "流程统计详情", saveResponseData = true)
     public RT<ProcessStatisticsDetailVo> processStatistics(@Valid StatisticsDetailDto dto) {
-        HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery();
-        if (dto.getUserId() != null) {
-            instanceQuery.variableValueEquals(WorkflowConstant.PROCESS_START_USER_ID_KEY, dto.getUserId());
-        }
-        LocalDateTime startTime = null;
-        LocalDateTime endTime = null;
-        if (dto.getStartDate() != null) {
-            startTime = dto.getStartDate().atStartOfDay();
-        }
-        if (dto.getEndDate() != null) {
-            endTime = dto.getEndDate().atStartOfDay().plusDays(1).plusNanos(-1);
-        }
-        if (!ObjectUtil.isNull(dto.getStartDate())) {
-            instanceQuery.startedAfter(WorkFlowUtil.getStartOfDay(dto.getStartDate()));
-        }
-        if (!ObjectUtil.isNull(dto.getEndDate())) {
-            instanceQuery.startedBefore(WorkFlowUtil.getEndOfDay(dto.getEndDate()));
+        ProcessStatisticsDetailVo result = new ProcessStatisticsDetailVo();
+        String sql = "SELECT DISTINCT t1.id,t2.schema_name,t1.start_time,t1.end_time,t1.current_state FROM xjr_workflow_form_relation t1" +
+                " INNER JOIN xjr_workflow_extra t2 ON t1.process_id = t2.process_id" +
+                " WHERE 1 = 1";
+        if (dto.getStartDate() != null && dto.getEndDate() != null) {
+            sql += " and DATE_FORMAT(t1.start_time, '%Y-%m-%d') BETWEEN '" + dto.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "'"
+                + " and '" + dto.getEndDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "'";
+        }
+        List<Map<String, Object>> dataList = SqlRunnerAdapter.db().selectList(sql);
+        result.setAllCount(dataList.stream().count());
+        Long uncompleteCount = 0L;
+        Long completeCount = 0L;
+
+        for (Map<String, Object> objectMap : dataList) {
+            String currentState = objectMap.get("current_state").toString();
+            if(HistoricProcessInstance.STATE_ACTIVE.equals(currentState)){
+                uncompleteCount ++;
+            }else{
+                completeCount ++;
+            }
         }
+        result.setCompleteCount(completeCount);
+        result.setUncompleteCount(uncompleteCount);
 
-        List<WorkflowExtra> workflowExtras = extraService.list(
-                new MPJLambdaWrapper<WorkflowExtra>()
-                        .between((startTime != null && endTime != null), WorkflowExtra::getLaunchTime, startTime, endTime)
-                        .select(WorkflowExtra::getId)
-                        .select(WorkflowExtra.class, x -> VoToColumnUtil.fieldsToColumns(WorkflowExtra.class).contains(x.getProperty()))
-                        .leftJoin(WorkflowSchema.class, WorkflowSchema::getId, WorkflowExtra::getSchemaId)
-                        .leftJoin(DictionaryDetail.class, DictionaryDetail::getId, WorkflowSchema::getCategory)
-        );
+        Set<String> itemSet = dataList.stream().map(x -> x.get("schema_name").toString()).collect(Collectors.toSet());
 
+        Map<String, Long> finishedMap = dataList.stream()
+                .filter(x -> !HistoricProcessInstance.STATE_ACTIVE.equals(x.get("current_state").toString()))
+                .collect(Collectors.groupingBy(x -> x.get("schema_name").toString(), Collectors.counting()));
+        Map<String, Long> unfinishedMap = dataList.stream()
+                .filter(x -> HistoricProcessInstance.STATE_ACTIVE.equals(x.get("current_state").toString()))
+                .collect(Collectors.groupingBy(x -> x.get("schema_name").toString(), Collectors.counting()));
 
-        ProcessStatisticsDetailVo result = new ProcessStatisticsDetailVo();
-        List<HistoricProcessInstance> list = instanceQuery.list();
-        List<WorkflowExtra> allCountList = new ArrayList<>();
-        for (HistoricProcessInstance historicProcessInstance : list) {
-            workflowExtras.stream()
-                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
-                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
-                    .ifPresent(e -> {
-                        allCountList.add(e);
-                    });
-        }
-        result.setAllCount(Long.parseLong(allCountList.size() + ""));
-
-        List<HistoricProcessInstance> finished = historyService.createHistoricProcessInstanceQuery().finished().list();
-        List<WorkflowExtra> completeCountList = new ArrayList<>();
-        for (HistoricProcessInstance historicProcessInstance : finished) {
-            workflowExtras.stream()
-                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()) && e.getEndTime() != null)
-                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
-                    .ifPresent(e -> {
-                        completeCountList.add(e);
-                    });
-        }
-        result.setCompleteCount(Long.parseLong(completeCountList.size() + ""));
-
-        List<HistoricProcessInstance> unfinished = historyService.createHistoricProcessInstanceQuery().unfinished().list();
-        List<WorkflowExtra> uncompleteCountList = new ArrayList<>();
-        for (HistoricProcessInstance historicProcessInstance : unfinished) {
-            workflowExtras.stream()
-                    .filter(e -> e.getProcessId().equals(historicProcessInstance.getId()))
-                    .max(Comparator.comparing(WorkflowExtra::getStartTime))
-                    .ifPresent(e -> {
-                        uncompleteCountList.add(e);
-                    });
-        }
-        result.setUncompleteCount(Long.parseLong(uncompleteCountList.size() + ""));
-
-        Map<String, Long> finishedMap = completeCountList.stream()
-                .collect(Collectors.groupingBy(WorkflowExtra::getSchemaName, Collectors.counting()));
-        Map<String, Long> unfinishedMap = uncompleteCountList.stream()
-                .collect(Collectors.groupingBy(WorkflowExtra::getSchemaName, Collectors.counting()));
-
-        Set<String> itemSet = new HashSet<>();
-        itemSet.addAll(finishedMap.keySet());
-        itemSet.addAll(unfinishedMap.keySet());
-        List<DistributionVo> distributionList = new ArrayList();
+        List<DistributionVo> distributionList = new ArrayList<>();
         for (String item : itemSet) {
-            Long uncompleteCount = unfinishedMap.get(item) == null ? 0L : unfinishedMap.get(item);
-            Long completeCount = finishedMap.get(item) == null ? 0L : finishedMap.get(item);
+            Long unfinishedCount = unfinishedMap.get(item) == null ? 0L : unfinishedMap.get(item);
+            Long finishedCount = finishedMap.get(item) == null ? 0L : finishedMap.get(item);
             distributionList.add(
                     new DistributionVo() {{
                         setItem(item);
-                        setCompleteCount(completeCount);
-                        setUncompleteCount(uncompleteCount);
+                        setCompleteCount(finishedCount);
+                        setUncompleteCount(unfinishedCount);
+                        setAllCount(unfinishedCount + finishedCount);
                     }}
             );
         }
+        distributionList.sort(Comparator.comparingLong(DistributionVo::getAllCount).reversed());
         result.setDistributionList(distributionList);
         List<DurationVo> durationList = new ArrayList<>();
 
         List<Long> secondList = new ArrayList<>();
-        completeCountList.stream().filter(el -> el.getEndTime() != null && el.getStartTime() != null).forEach(el -> {
-            Duration diff = Duration.between(el.getStartTime(), el.getEndTime());
+        List<Map<String, Object>> completeCountList = dataList.stream()
+                .filter(x -> HistoricProcessInstance.STATE_COMPLETED.equals(x.get("current_state").toString()))
+                .collect(Collectors.toList());
+        completeCountList.stream().forEach(el -> {
+            Duration diff = Duration.between((LocalDateTime)el.get("start_time"), (LocalDateTime)el.get("end_time"));
             secondList.add(diff.getSeconds());
         });
 
@@ -806,15 +771,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) {
@@ -824,18 +803,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) {

+ 4 - 0
src/main/java/com/xjrsoft/module/databoard/vo/DistributionVo.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.databoard.vo;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -26,4 +27,7 @@ public class DistributionVo {
     @ApiModelProperty("未完成数量")
     private Long uncompleteCount;
 
+    @ApiModelProperty("总数")
+    private Long allCount;
+
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/student/controller/BaseStudentAssessmentInspectionController.java

@@ -57,6 +57,10 @@ public class BaseStudentAssessmentInspectionController {
         if (roleList.size() == 2 && roleList.contains("TEACHER") && roleList.contains("CLASSTE")) {
             dto.setTeacherId(StpUtil.getLoginIdAsLong());
         }
+        if(!roleList.contains("BJKHGLY")){
+            dto.setCreateUserId(StpUtil.getLoginIdAsLong());
+        }
+
         Page<BaseStudentAssessmentInspectionPageVo> page = inspectionService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
         return RT.ok(ConventPage.getPageOutput(page, BaseStudentAssessmentInspectionPageVo.class));
     }

+ 3 - 0
src/main/java/com/xjrsoft/module/student/dto/BaseStudentAssessmentInspectionPageDto.java

@@ -42,4 +42,7 @@ public class BaseStudentAssessmentInspectionPageDto extends PageInput {
 
     @ApiModelProperty("教师id")
     private Long teacherId;
+
+    @ApiModelProperty("创建人id")
+    private Long createUserId;
 }

+ 1 - 1
src/main/resources/application.yml

@@ -5,7 +5,7 @@ server:
 spring:
   # 环 io境 dev|pre|prod
   profiles:
-    active: dev
+    active: pre
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

+ 3 - 0
src/main/resources/mapper/student/BaseStudentAssessmentInspectionMapper.xml

@@ -43,6 +43,9 @@
         <if test="dto.teacherId != null">
             and t7.teacher_id = #{dto.teacherId}
         </if>
+        <if test="dto.createUserId != null">
+            and t.create_user_id = #{dto.createUserId}
+        </if>
         order by t.id desc
     </select>
 

+ 1 - 1
src/main/resources/mapper/student/PbVXsxxsfytbMapper.xml

@@ -65,7 +65,7 @@
         GROUP BY t2.name
     </select>
     <select id="getClassQfPage" parameterType="com.xjrsoft.module.student.dto.PbVXsxxsfytbStatDto" resultType="com.xjrsoft.module.student.vo.ClassQfPageVo">
-        SELECT t1.id, t1.name AS grade_name,t2.name AS class_name,t3.name AS teacher_name,
+        SELECT t1.id, t1.name AS class_name,t2.name AS grade_name,t3.name AS teacher_name,
         (
         SELECT SUM(qfje) FROM pb_v_xsxxsfytb a1
         INNER JOIN xjr_user a2 ON a1.studentcode = a2.credential_number

+ 3 - 3
src/test/java/com/xjrsoft/module/job/JianyuekbScheduleTaskTest.java

@@ -284,9 +284,9 @@ class JianyuekbScheduleTaskTest {
         tableName = "base_classroom";
         Map<String, String> classroomMap = dataMap.get(tableName);
 
-//        Set<String> techerIds = dataUtil.insertCourseTableEntiy(scheduleInfo, classroomMap, courseMap, semesterMap,
-//                teacherMap, classMap, courseReceiveMsgId, startDate, endDate);
-//        sendMsg(techerIds, courseReceiveMsgId);
+        Set<String> techerIds = dataUtil.insertCourseTableEntiy(scheduleInfo, classroomMap, courseMap, semesterMap,
+                teacherMap, classMap, String.valueOf(courseReceiveMsgId), startDate, endDate);
+        sendMsg(techerIds, courseReceiveMsgId);
         dataUtil.insertClassTime(scheduleInfo);
     }
 

+ 3 - 3
src/test/java/com/xjrsoft/module/job/JianyuekbScheduleTaskTest2.java

@@ -282,9 +282,9 @@ class JianyuekbScheduleTaskTest2 {
         tableName = "base_classroom";
         Map<String, String> classroomMap = dataMap.get(tableName);
 
-//        Set<String> techerIds = dataUtil.insertCourseTableEntiy(scheduleInfo, classroomMap, courseMap, semesterMap, teacherMap, classMap, courseReceiveMsgId, null, null);
-//        sendMsg(techerIds, courseReceiveMsgId);
-//        dataUtil.insertClassTime(scheduleInfo);
+        Set<String> techerIds = dataUtil.insertCourseTableEntiy(scheduleInfo, classroomMap, courseMap, semesterMap, teacherMap, classMap, String.valueOf(courseReceiveMsgId), null, null);
+        sendMsg(techerIds, courseReceiveMsgId);
+        dataUtil.insertClassTime(scheduleInfo);
     }
 
     void sendMsg(Set<String> techerIds, Long courseReceiveMsgId){

+ 2 - 0
src/test/java/com/xjrsoft/xjrsoftboot/Test2.java

@@ -55,5 +55,7 @@ public class Test2 {
         LocalDateTime birthday = LocalDateTime.parse(dateStr, formatter);
         System.out.println(birthday);
 
+
+
     }
 }