|
@@ -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) {
|