Pārlūkot izejas kodu

评价管理维护功能

dzx 1 gadu atpakaļ
vecāks
revīzija
4dce07d2df

+ 62 - 0
src/main/java/com/xjrsoft/module/evaluate/controller/EvaluateObjectController.java

@@ -0,0 +1,62 @@
+package com.xjrsoft.module.evaluate.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.xjrsoft.common.model.result.RT;
+import com.xjrsoft.module.evaluate.dto.AddEvaluateObjectDto;
+import com.xjrsoft.module.evaluate.dto.EvaluateObjectListDto;
+import com.xjrsoft.module.evaluate.service.IEvaluateObjectService;
+import com.xjrsoft.module.evaluate.vo.EvaluateObjectListVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+* @title: 评价管理
+* @Author dzx
+* @Date: 2024-01-16
+* @Version 1.0
+*/
+@RestController
+@RequestMapping("/evaluate" + "/evaluateobject")
+@Api(value = "/evaluate"  + "/evaluateobject",tags = "被评对象管理代码")
+@AllArgsConstructor
+public class EvaluateObjectController {
+
+
+    private final IEvaluateObjectService evaluateObjectService;
+
+    @GetMapping(value = "/object-list")
+    @ApiOperation(value="评价对象列表(已生成数据)")
+    @SaCheckPermission("evaluateobject:detail")
+    public RT<List<EvaluateObjectListVo>> objectList(@Valid EvaluateObjectListDto dto){
+        List<EvaluateObjectListVo> list = evaluateObjectService.getObjectList(dto.getEvaluateManageId());
+        return RT.ok(list);
+    }
+
+    @PostMapping
+    @ApiOperation(value = "评价对象保存")
+    @SaCheckPermission("evaluateobject:save")
+    public RT<Boolean> save(@Valid @RequestBody AddEvaluateObjectDto dto){
+        boolean isSuccess = evaluateObjectService.save(dto);
+        return RT.ok(isSuccess);
+    }
+
+
+    @GetMapping(value = "/use-object-list")
+    @ApiOperation(value="评价对象列表(用于选择的数据)")
+    @SaCheckPermission("evaluateobject:detail")
+    public RT<List<EvaluateObjectListVo>> useObjectList(@Valid EvaluateObjectListDto dto){
+        List<EvaluateObjectListVo> list = evaluateObjectService.getNewObjectList(dto);
+        return RT.ok(list);
+    }
+
+
+}

+ 27 - 0
src/main/java/com/xjrsoft/module/evaluate/dto/EvaluateObjectListDto.java

@@ -0,0 +1,27 @@
+package com.xjrsoft.module.evaluate.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+* @title: 评价管理分页查询入参
+* @Author dzx
+* @Date: 2024-01-16
+* @Version 1.0
+*/
+@Data
+public class EvaluateObjectListDto implements Serializable {
+
+    @ApiModelProperty("评价管理id,添加时不用传")
+    private Long evaluateManageId;
+
+    @ApiModelProperty("参评的人数(all:全部, random15:随机15名),添加时传入使用")
+    private String executerCount;
+
+    @ApiModelProperty("年级id,添加时传入使用")
+    private Long gradeId;
+
+}

+ 14 - 1
src/main/java/com/xjrsoft/module/evaluate/mapper/EvaluateObjectMapper.java

@@ -1,9 +1,15 @@
 package com.xjrsoft.module.evaluate.mapper;
 
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.evaluate.dto.EvaluateObjectListDto;
 import com.xjrsoft.module.evaluate.entity.EvaluateObject;
+import com.xjrsoft.module.evaluate.vo.EvaluateExecuterVo;
+import com.xjrsoft.module.evaluate.vo.EvaluateObjectListVo;
+import com.xjrsoft.module.evaluate.vo.EvaluateObjectVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
 * @title: 被评价对象
@@ -13,5 +19,12 @@ import org.apache.ibatis.annotations.Mapper;
 */
 @Mapper
 public interface EvaluateObjectMapper extends MPJBaseMapper<EvaluateObject> {
+    List<EvaluateObjectListVo> getObjectList(Long id);
+
+    List<EvaluateExecuterVo> getExecuterList(Long id);
+
+
+    List<EvaluateObjectListVo> getNewObjectList(@Param("dto") EvaluateObjectListDto dto);
 
+    List<EvaluateExecuterVo> getNewExecuterList(@Param("dto") EvaluateObjectListDto dto);
 }

+ 26 - 0
src/main/java/com/xjrsoft/module/evaluate/service/IEvaluateObjectService.java

@@ -0,0 +1,26 @@
+package com.xjrsoft.module.evaluate.service;
+
+import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.evaluate.dto.AddEvaluateObjectDto;
+import com.xjrsoft.module.evaluate.dto.EvaluateObjectListDto;
+import com.xjrsoft.module.evaluate.entity.EvaluateObject;
+import com.xjrsoft.module.evaluate.vo.EvaluateObjectListVo;
+import com.xjrsoft.module.evaluate.vo.EvaluateObjectVo;
+
+import java.util.List;
+
+/**
+* @title: 评价管理
+* @Author dzx
+* @Date: 2024-01-16
+* @Version 1.0
+*/
+
+public interface IEvaluateObjectService extends MPJBaseService<EvaluateObject> {
+
+    List<EvaluateObjectListVo> getObjectList(Long id);
+
+    Boolean save(AddEvaluateObjectDto dto);
+
+    List<EvaluateObjectListVo> getNewObjectList(EvaluateObjectListDto dto);
+}

+ 91 - 0
src/main/java/com/xjrsoft/module/evaluate/service/impl/EvaluateObjectServiceImpl.java

@@ -0,0 +1,91 @@
+package com.xjrsoft.module.evaluate.service.impl;
+
+import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.module.evaluate.dto.AddEvaluateObjectDto;
+import com.xjrsoft.module.evaluate.dto.EvaluateObjectListDto;
+import com.xjrsoft.module.evaluate.entity.EvaluateObject;
+import com.xjrsoft.module.evaluate.mapper.EvaluateExecuterMapper;
+import com.xjrsoft.module.evaluate.mapper.EvaluateManageMapper;
+import com.xjrsoft.module.evaluate.mapper.EvaluateObjectMapper;
+import com.xjrsoft.module.evaluate.service.IEvaluateObjectService;
+import com.xjrsoft.module.evaluate.vo.EvaluateExecuterVo;
+import com.xjrsoft.module.evaluate.vo.EvaluateObjectListVo;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+/**
+* @title: 评价管理
+* @Author dzx
+* @Date: 2024-01-16
+* @Version 1.0
+*/
+@Service
+@AllArgsConstructor
+public class EvaluateObjectServiceImpl extends MPJBaseServiceImpl<EvaluateObjectMapper, EvaluateObject> implements IEvaluateObjectService {
+    private final EvaluateManageMapper evaluateManageMapper;
+
+    private final EvaluateObjectMapper evaluateObjectMapper;
+    private final EvaluateExecuterMapper evaluateExecuterMapper;
+
+
+    @Override
+    public List<EvaluateObjectListVo> getObjectList(Long id) {
+        List<EvaluateObjectListVo> objectList = evaluateObjectMapper.getObjectList(id);
+        List<EvaluateExecuterVo> allExecuterList = evaluateObjectMapper.getExecuterList(id);
+        for (EvaluateObjectListVo objectVo : objectList) {
+            List<EvaluateExecuterVo> executerList = new ArrayList<>();
+            for (EvaluateExecuterVo executerVo : allExecuterList) {
+                if(objectVo.getId().equals(executerVo.getEvaluateObjectId())){
+                    executerList.add(executerVo);
+                }
+            }
+
+            objectVo.setExecuterCount(executerList.size());
+            objectVo.setExecuterList(executerList);
+        }
+        return objectList;
+    }
+
+    @Override
+    public Boolean save(AddEvaluateObjectDto dto) {
+        return null;
+    }
+
+    @Override
+    public List<EvaluateObjectListVo> getNewObjectList(EvaluateObjectListDto dto) {
+        List<EvaluateObjectListVo> newObjectList = evaluateObjectMapper.getNewObjectList(dto);
+        List<EvaluateExecuterVo> newExecuterList = evaluateObjectMapper.getNewExecuterList(dto);
+
+        for (EvaluateObjectListVo objectListVo : newObjectList) {
+            List<EvaluateExecuterVo> dataList = new ArrayList<>();
+            for (EvaluateExecuterVo executerVo : newExecuterList) {
+                if(!executerVo.getClassId().equals(objectListVo.getClassId())){
+                    continue;
+                }
+                dataList.add(executerVo);
+            }
+            List<EvaluateExecuterVo> executerList = new ArrayList<>();
+            if("random15".equals(dto.getExecuterCount()) && dataList.size() > 0){
+                List<Integer> randomList = new ArrayList<>();
+                Random random = new Random();
+                while(randomList.size() < 15){
+                    int nextInt = random.nextInt(dataList.size());
+                    if(!randomList.contains(nextInt) && nextInt >= 0){
+                        randomList.add(nextInt);
+                    }
+                }
+                for (Integer i : randomList) {
+                    executerList.add(dataList.get(i));
+                }
+            }else{
+                executerList.addAll(dataList);
+            }
+            objectListVo.setExecuterList(executerList);
+        }
+        return newObjectList;
+    }
+}

+ 9 - 4
src/main/java/com/xjrsoft/module/evaluate/vo/EvaluateExecuterVo.java

@@ -22,7 +22,7 @@ public class EvaluateExecuterVo {
     * 主键编号
     */
     @ApiModelProperty("主键编号")
-    private Long id;
+    private String id;
     /**
     * 序号
     */
@@ -32,18 +32,23 @@ public class EvaluateExecuterVo {
     * 评价管理编号
     */
     @ApiModelProperty("评价管理编号")
-    private Long evaluateManageId;
+    private String evaluateManageId;
     /**
     * 被评对象id
     */
     @ApiModelProperty("被评对象id")
-    private Long evaluateObjectId;
+    private String evaluateObjectId;
     /**
     * 参加评价的人id
     */
     @ApiModelProperty("参加评价的人id")
-    private Long userId;
+    private String executerId;
 
+    @ApiModelProperty("参加评价的人名称")
+    private String executerName;
 
 
+    @ApiModelProperty("班级id")
+    private String classId;
+
 }

+ 60 - 0
src/main/java/com/xjrsoft/module/evaluate/vo/EvaluateObjectListVo.java

@@ -0,0 +1,60 @@
+package com.xjrsoft.module.evaluate.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+* @title: 被评价对象表单出参
+* @Author dzx
+* @Date: 2024-01-16
+* @Version 1.0
+*/
+@Data
+public class EvaluateObjectListVo {
+
+    /**
+    * 主键编号
+    */
+    @ApiModelProperty("主键编号")
+    private String id;
+    /**
+    * 年级id
+    */
+    @ApiModelProperty("年级id")
+    private String baseGradeId;
+    /**
+     * 年级名称
+     */
+    @ApiModelProperty("年级名称")
+    private String gradeName;
+
+    /**
+    * 被评价对象id
+    */
+    @ApiModelProperty("被评价对象id")
+    private String objectId;
+
+    /**
+     * 被评价对象名称
+     */
+    @ApiModelProperty("被评价对象名称")
+    private String objectName;
+
+    /**
+    * 参与评价的人数
+    */
+    @ApiModelProperty("参与评价的人数")
+    private Integer executerCount;
+
+
+    @ApiModelProperty("参与评价的人")
+    private List<EvaluateExecuterVo> executerList;
+
+    /**
+     * 被评价对象id
+     */
+    @ApiModelProperty("班级id")
+    private String classId;
+}

+ 0 - 2
src/main/java/com/xjrsoft/module/evaluate/vo/EvaluateObjectVo.java

@@ -54,6 +54,4 @@ public class EvaluateObjectVo {
     @ApiModelProperty("被评价对象类别(teacher:老师,class:班级,student:学生)")
     private String objectType;
 
-
-
 }

+ 37 - 0
src/main/resources/mapper/evaluate/EvaluateObjectMapper.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xjrsoft.module.evaluate.mapper.EvaluateObjectMapper">
+    <select id="getObjectList" resultType="com.xjrsoft.module.evaluate.vo.EvaluateObjectListVo">
+        SELECT t1.id,t1.base_grade_id,t2.name AS grade_name,t1.object_id,t3.name AS object_name
+        FROM evaluate_object t1
+        LEFT JOIN base_grade t2 ON t2.id = t1.base_grade_id
+        LEFT JOIN xjr_user t3 ON t3.id = t1.object_id
+        WHERE t1.delete_mark = 0 and t1.evaluate_manage_id = #{id}
+        ORDER BY t1.id
+    </select>
+    <select id="getExecuterList" resultType="com.xjrsoft.module.evaluate.vo.EvaluateExecuterVo">
+        SELECT t1.evaluate_object_id,t2.name AS user_name,t1.user_id FROM evaluate_executer t1
+        LEFT JOIN xjr_user t2 ON t1.user_id = t2.id
+        WHERE t1.delete_mark = 0 and t1.evaluate_manage_id = #{id}
+    </select>
+
+    <select id="getNewObjectList" parameterType="com.xjrsoft.module.evaluate.dto.EvaluateObjectListDto" resultType="com.xjrsoft.module.evaluate.vo.EvaluateObjectListVo">
+        SELECT t1.id AS class_id,t2.id AS object_id,t2.name AS object_name,t1.id as class_id FROM base_class t1
+        LEFT JOIN xjr_user t2 ON t1.teacher_id = t2.id
+        WHERE t1.delete_mark = 0
+        <if test="dto.gradeId != null">
+            and t1.grade_id = #{dto.gradeId}
+        </if>
+    </select>
+
+    <select id="getNewExecuterList" parameterType="com.xjrsoft.module.evaluate.dto.EvaluateObjectListDto" resultType="com.xjrsoft.module.evaluate.vo.EvaluateExecuterVo">
+        SELECT t2.id as executer_id,t2.name as executer_name,t1.class_id FROM base_student_school_roll t1
+        LEFT JOIN xjr_user t2 ON t1.user_id = t2.id
+        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
+        <if test="dto.gradeId != null">
+            and t1.grade_id = #{dto.gradeId}
+        </if>
+    </select>
+</mapper>