Jelajahi Sumber

课表课时统计

dzx 3 hari lalu
induk
melakukan
2f0368aa5e

+ 2 - 1
src/main/java/com/xjrsoft/module/classtime/controller/ClassTimeStatisticsController.java

@@ -76,6 +76,7 @@ public class ClassTimeStatisticsController {
                 .orderByDesc(ClassTimeStatistics::getId)
                 .eq(dto.getYear() != null, ClassTimeStatistics::getYear, dto.getYear())
                 .eq(dto.getMonth() != null, ClassTimeStatistics::getMonth, dto.getMonth())
+                .eq(ClassTimeStatistics::getCategory, 1)
                 .select(ClassTimeStatistics.class,x -> VoToColumnUtil.fieldsToColumns(ClassTimeStatisticsPageVo.class).contains(x.getProperty()));
         IPage<ClassTimeStatistics> page = classTimeStatisticsService.page(ConventPage.getPage(dto), queryWrapper);
         PageOutput<ClassTimeStatisticsPageVo> pageOutput = ConventPage.getPageOutput(page, ClassTimeStatisticsPageVo.class);
@@ -152,7 +153,7 @@ public class ClassTimeStatisticsController {
     @SaCheckPermission("classtimestatisticsset:detail")
     public RT<LocalDate> lastInfo(){
         List<ClassTimeStatistics> list = classTimeStatisticsService.list(
-                new QueryWrapper<ClassTimeStatistics>().lambda().orderByDesc(ClassTimeStatistics::getEndDate)
+                new QueryWrapper<ClassTimeStatistics>().lambda().eq(ClassTimeStatistics::getCategory, 1).orderByDesc(ClassTimeStatistics::getEndDate)
         );
         if (list.isEmpty()) {
             return RT.ok();

+ 177 - 0
src/main/java/com/xjrsoft/module/classtime/controller/CourseClassTimeStatisticsController.java

@@ -0,0 +1,177 @@
+package com.xjrsoft.module.classtime.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.model.result.RT;
+import com.xjrsoft.common.page.ConventPage;
+import com.xjrsoft.common.page.PageOutput;
+import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.module.activity.dto.ChangeStatusDto;
+import com.xjrsoft.module.classtime.dto.AddClassTimeStatisticsDto;
+import com.xjrsoft.module.classtime.dto.ClassTimeStatisticsPageDto;
+import com.xjrsoft.module.classtime.dto.RefreshStatisticsDto;
+import com.xjrsoft.module.classtime.dto.UpdateClassTimeStatisticsDto;
+import com.xjrsoft.module.classtime.entity.ClassTimeStatistics;
+import com.xjrsoft.module.classtime.entity.ClassTimeStatisticsSet;
+import com.xjrsoft.module.classtime.service.IClassTimeStatisticsService;
+import com.xjrsoft.module.classtime.service.IClassTimeStatisticsSetService;
+import com.xjrsoft.module.classtime.vo.ClassTimeStatisticsPageVo;
+import com.xjrsoft.module.classtime.vo.ClassTimeStatisticsRecordVo;
+import com.xjrsoft.module.classtime.vo.ClassTimeStatisticsVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.List;
+
+/**
+* @title: 课时统计
+* @Author dzx
+* @Date: 2024年11月19日
+* @Version 1.0
+*/
+@RestController
+@RequestMapping("/courseClasstime" + "/classTimeStatistics")
+@Api(value = "/courseClasstime"  + "/classTimeStatistics",tags = "课表课时统计代码")
+@AllArgsConstructor
+public class CourseClassTimeStatisticsController {
+
+    private final IClassTimeStatisticsSetService statisticsSetService;
+    private final IClassTimeStatisticsService classTimeStatisticsService;
+
+    @GetMapping(value = "/page")
+    @ApiOperation(value="课时统计列表(分页)")
+    @SaCheckPermission("classtimestatistics:detail")
+    public RT<PageOutput<ClassTimeStatisticsPageVo>> page(@Valid ClassTimeStatisticsPageDto dto){
+
+        LambdaQueryWrapper<ClassTimeStatistics> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper
+                .orderByDesc(ClassTimeStatistics::getId)
+                .eq(dto.getYear() != null, ClassTimeStatistics::getYear, dto.getYear())
+                .eq(dto.getMonth() != null, ClassTimeStatistics::getMonth, dto.getMonth())
+                .eq(ClassTimeStatistics::getCategory, 2)
+                .select(ClassTimeStatistics.class,x -> VoToColumnUtil.fieldsToColumns(ClassTimeStatisticsPageVo.class).contains(x.getProperty()));
+        IPage<ClassTimeStatistics> page = classTimeStatisticsService.page(ConventPage.getPage(dto), queryWrapper);
+        PageOutput<ClassTimeStatisticsPageVo> pageOutput = ConventPage.getPageOutput(page, ClassTimeStatisticsPageVo.class);
+        return RT.ok(pageOutput);
+    }
+
+    @GetMapping(value = "/info")
+    @ApiOperation(value="根据id查询课时统计信息")
+    @SaCheckPermission("classtimestatistics:detail")
+    public RT<ClassTimeStatisticsVo> info(@RequestParam Long id){
+        ClassTimeStatistics classTimeStatistics = classTimeStatisticsService.getByIdDeep(id);
+        if (classTimeStatistics == null) {
+           return RT.error("找不到此数据!");
+        }
+        return RT.ok(BeanUtil.toBean(classTimeStatistics, ClassTimeStatisticsVo.class));
+    }
+
+    @PostMapping
+    @ApiOperation(value = "新增课时统计")
+    @SaCheckPermission("classtimestatistics:add")
+    public RT<Boolean> add(@Valid @RequestBody AddClassTimeStatisticsDto dto){
+        boolean isSuccess = classTimeStatisticsService.addCourse(dto);
+        return RT.ok(isSuccess);
+    }
+
+    @PutMapping
+    @ApiOperation(value = "修改课时统计")
+    @SaCheckPermission("classtimestatistics:edit")
+    public RT<Boolean> update(@Valid @RequestBody UpdateClassTimeStatisticsDto dto){
+        ClassTimeStatistics classTimeStatistics = BeanUtil.toBean(dto, ClassTimeStatistics.class);
+        return RT.ok(classTimeStatisticsService.update(classTimeStatistics));
+    }
+
+    @DeleteMapping
+    @ApiOperation(value = "删除课时统计")
+    @SaCheckPermission("classtimestatistics:delete")
+    public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
+        return RT.ok(classTimeStatisticsService.delete(ids));
+
+    }
+
+    @PostMapping(value = "/change-status")
+    @ApiOperation(value="修改状态")
+    @SaCheckPermission("classtimestatistics:detail")
+    public RT<Boolean> changeStatus(@Valid @RequestBody ChangeStatusDto dto) throws Exception {
+        ClassTimeStatistics statistics = classTimeStatisticsService.getById(dto.getId());
+        if(statistics == null){
+            throw new MyException("未能查到数据");
+        }
+        statistics.setStatus(dto.getStatus());
+        classTimeStatisticsService.updateById(statistics);
+        if(dto.getStatus() != null && dto.getStatus() == 3){
+            classTimeStatisticsService.lockData(dto.getId());
+        }
+        return RT.ok(true);
+    }
+
+    @GetMapping(value = "/last-date")
+    @ApiOperation(value="查询最新统计的结束日期")
+    @SaCheckPermission("classtimestatisticsset:detail")
+    public RT<LocalDate> lastInfo(){
+        List<ClassTimeStatistics> list = classTimeStatisticsService.list(
+                new QueryWrapper<ClassTimeStatistics>().lambda().eq(ClassTimeStatistics::getCategory, 2).orderByDesc(ClassTimeStatistics::getEndDate)
+        );
+        if (list.isEmpty()) {
+            return RT.ok();
+        }
+        ClassTimeStatistics result = list.get(0);
+        return RT.ok(result.getEndDate());
+    }
+
+    @PostMapping("/refresh-statistics")
+    @ApiOperation(value = "刷新课表课时统计")
+    @SaCheckPermission("classtimestatistics:detail")
+    public RT<Boolean> refreshStatistics(@Valid @RequestBody RefreshStatisticsDto dto){
+
+        ClassTimeStatistics classTimeStatistics = classTimeStatisticsService.getById(dto.getId());
+        classTimeStatistics.setStatus(0);
+        classTimeStatistics.setModifyDate(new Date());
+
+        //查询最新权重并保存到统计中
+        Integer category = 3;
+        List<ClassTimeStatisticsSet> list = statisticsSetService.list(
+                new QueryWrapper<ClassTimeStatisticsSet>().lambda()
+                        .eq(ClassTimeStatisticsSet::getCategory, category)
+                        .orderByDesc(ClassTimeStatisticsSet::getCreateDate)
+        );
+        if(list.isEmpty()){
+            throw new MyException("请先设置权重并进行保存");
+        }
+        classTimeStatistics.setWeightSetJson(list.get(0).getJsonContent());
+
+        classTimeStatistics.setCostSetJson(list.get(0).getJsonContent());
+        Boolean aBoolean = classTimeStatisticsService.updateById(classTimeStatistics);
+
+        classTimeStatisticsService.refreshCourseRecord(classTimeStatistics);
+
+        return RT.ok(aBoolean);
+    }
+
+
+    @GetMapping(value = "/record-list")
+    @ApiOperation(value="课时统计详情列表")
+    @SaCheckPermission("classtimestatistics:detail")
+    public RT<List<ClassTimeStatisticsRecordVo>> recordPage(@Valid RefreshStatisticsDto dto){
+        List<ClassTimeStatisticsRecordVo> recordList = classTimeStatisticsService.getRecordList(dto.getId());
+        return RT.ok(recordList);
+    }
+
+}

+ 1 - 1
src/main/java/com/xjrsoft/module/classtime/dto/AddClassTimeStatisticsSetDto.java

@@ -26,7 +26,7 @@ public class AddClassTimeStatisticsSetDto implements Serializable {
     /**
     * 类别(1:权重 2:费用设置)
     */
-    @ApiModelProperty("类别(1:权重 2:费用设置)")
+    @ApiModelProperty("类别(1:权重 2:费用设置 3:课时量权重)")
     private Integer category;
 
 }

+ 2 - 1
src/main/java/com/xjrsoft/module/classtime/entity/ClassTimeStatistics.java

@@ -127,5 +127,6 @@ public class ClassTimeStatistics implements Serializable {
     @ApiModelProperty("权重json")
     private String costSetJson;
 
-
+    @ApiModelProperty("课时统计类型(1:全课时 2:课表课时)")
+    private Integer category;
 }

+ 1 - 1
src/main/java/com/xjrsoft/module/classtime/entity/ClassTimeStatisticsSet.java

@@ -77,7 +77,7 @@ public class ClassTimeStatisticsSet implements Serializable {
     /**
     * 类别(1:权重 2:费用设置)
     */
-    @ApiModelProperty("类别(1:权重 2:费用设置)")
+    @ApiModelProperty("类别(1:权重 2:费用设置 3:课时量权重)")
     private Integer category;
 
 

+ 9 - 0
src/main/java/com/xjrsoft/module/classtime/service/IClassTimeStatisticsService.java

@@ -25,6 +25,12 @@ public interface IClassTimeStatisticsService extends MPJBaseService<ClassTimeSta
     */
     Boolean add(ClassTimeStatistics classTimeStatistics);
 
+
+    /**
+     * 新增,只统计课表课时
+     */
+    Boolean addCourse(AddClassTimeStatisticsDto dto);
+
     /**
     * 更新
     *
@@ -65,4 +71,7 @@ public interface IClassTimeStatisticsService extends MPJBaseService<ClassTimeSta
      * @return
      */
     byte[] recordExport(Long id) throws IOException;
+
+
+    Boolean refreshCourseRecord(ClassTimeStatistics statistics);
 }

+ 34 - 2
src/main/java/com/xjrsoft/module/classtime/service/impl/ClassTimeStatisticsServiceImpl.java

@@ -90,6 +90,34 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
         return true;
     }
 
+    @Override
+    public Boolean addCourse(AddClassTimeStatisticsDto dto) {
+        ClassTimeStatistics classTimeStatistics = BeanUtil.toBean(dto, ClassTimeStatistics.class);
+        classTimeStatistics.setStatus(0);
+        classTimeStatistics.setCategory(2);
+        classTimeStatistics.setCreateDate(new Date());
+
+        //查询最新权重并保存到统计中
+        Integer category = 3;
+        List<ClassTimeStatisticsSet> list = statisticsSetService.list(
+                new QueryWrapper<ClassTimeStatisticsSet>().lambda()
+                        .eq(ClassTimeStatisticsSet::getCategory, category)
+                        .orderByDesc(ClassTimeStatisticsSet::getCreateDate)
+        );
+        if(list.isEmpty()){
+            throw new MyException("请先设置权重并进行保存");
+        }
+        classTimeStatistics.setWeightSetJson(list.get(0).getJsonContent());
+
+        this.save(classTimeStatistics);
+
+        CompletableFuture.runAsync(() -> {
+            refreshCourseRecord(classTimeStatistics);
+        });
+
+        return true;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean update(ClassTimeStatistics classTimeStatistics) {
@@ -111,6 +139,7 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
     public Boolean add(AddClassTimeStatisticsDto dto) {
         ClassTimeStatistics classTimeStatistics = BeanUtil.toBean(dto, ClassTimeStatistics.class);
         classTimeStatistics.setStatus(0);
+        classTimeStatistics.setCategory(1);
         classTimeStatistics.setCreateDate(new Date());
 
         //查询最新权重并保存到统计中
@@ -541,8 +570,6 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
 
     /**
      * 导出课时统计明细
-     * @param id
-     * @return
      */
     @Override
     public byte[] recordExport(Long id) {
@@ -698,6 +725,11 @@ public class ClassTimeStatisticsServiceImpl extends MPJBaseServiceImpl<ClassTime
         }
     }
 
+    @Override
+    public Boolean refreshCourseRecord(ClassTimeStatistics statistics) {
+        return null;
+    }
+
     /**
      * 生成第二行表头
      * 前端固定表头:序号、工号、姓名、教研会、督导听课、临近三年退休政策、出题、阅卷、周末培优、早自习、正课(含调顶课时)、晚辅(含调顶课时)、顶课、调课