Browse Source

考试培训系统优化改造

wangchangsheng 2 years ago
parent
commit
fc5f79e8f2

+ 4 - 1
exam-06173-api/src/main/java/com/gyee/exam/modules/course/dto/CourseDTO.java

@@ -129,9 +129,12 @@ public class CourseDTO implements Serializable {
     @ApiModelProperty(value = "更新时间", required=true)
     private Date updateTime;
 
-    @ApiModelProperty(value = "创建人", required=true)
+    @ApiModelProperty(value = "创建人id", required=true)
     private String createBy;
 
+    @ApiModelProperty(value = "创建人namer", required=true)
+    private String createName;
+
     @ApiModelProperty(value = "修改人", required=true)
     private String updateBy;
 

+ 10 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/course/service/impl/CourseServiceImpl.java

@@ -28,6 +28,8 @@ import com.gyee.exam.modules.course.enums.CourseState;
 import com.gyee.exam.modules.course.mapper.CourseMapper;
 import com.gyee.exam.modules.course.service.*;
 import com.gyee.exam.modules.sys.user.dto.SysUserDTO;
+import com.gyee.exam.modules.sys.user.entity.SysUser;
+import com.gyee.exam.modules.sys.user.service.SysUserService;
 import com.gyee.exam.modules.user.UserUtils;
 import com.gyee.exam.utils.DateRangeUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -77,6 +79,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
     @Autowired
     private  CourseFileLearnService courseFileLearnService;
 
+    @Autowired
+    private SysUserService baseService;
+
 
     @Override
     public IPage<CourseDTO> paging(PagingReqDTO<CourseDTO> reqDTO) {
@@ -114,6 +119,11 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
         //转换结果
         IPage<CourseDTO> pageData = JSON.parseObject(JSON.toJSONString(page), new TypeReference<Page<CourseDTO>>() {
         });
+
+        pageData.getRecords().stream().forEach(i->{
+            SysUser user = baseService.getById(i.getCreateBy());
+            i.setCreateName(user.getRealName());
+        });
         return pageData;
     }
 

+ 3 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/stat/course/dto/request/StatCourseLearnReqDTO.java

@@ -27,4 +27,7 @@ public class StatCourseLearnReqDTO implements Serializable {
     @ApiModelProperty(value = "用户姓名", required=true)
     private String realName;
 
+    @ApiModelProperty(value = "培训部门", required=true)
+    private String[] courseDeparts;
+
 }

+ 9 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/stat/course/dto/response/StatCourseLearnDTO.java

@@ -48,4 +48,13 @@ public class StatCourseLearnDTO implements Serializable {
     @ApiModelProperty(value = "学习状态")
     private Integer state;
 
+    @ApiModelProperty(value = "部门")
+    private String deptCode;
+
+    @ExcelField(title = "部门名称",sort = 5)
+    @ApiModelProperty(value = "部门名称")
+    private String  deptName;
+
+
+
 }

+ 15 - 1
exam-06173-api/src/main/java/com/gyee/exam/modules/stat/course/service/impl/StatCourseServiceImpl.java

@@ -12,9 +12,13 @@ import com.gyee.exam.modules.stat.course.dto.response.StatCourseFileDTO;
 import com.gyee.exam.modules.stat.course.dto.response.StatCourseLearnDTO;
 import com.gyee.exam.modules.stat.course.mapper.StatCourseMapper;
 import com.gyee.exam.modules.stat.course.service.StatCourseService;
+import com.gyee.exam.modules.sys.depart.entity.SysDepart;
+import com.gyee.exam.modules.sys.depart.service.SysDepartService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Map;
+
 /**
 * <p>
 * 考试总体统计业务实现类
@@ -33,6 +37,10 @@ public class StatCourseServiceImpl implements StatCourseService {
     private StatCourseMapper statCourseMapper;
 
 
+    @Autowired
+    private SysDepartService sysDepartService;
+
+
     @Override
     public StatCourseTotalDTO findOverview(String courseId) {
         Course course = courseService.getById(courseId);
@@ -48,7 +56,13 @@ public class StatCourseServiceImpl implements StatCourseService {
     public IPage<StatCourseLearnDTO> userStatPaging(PagingReqDTO<StatCourseLearnReqDTO> reqDTO) {
         StatCourseLearnReqDTO params = reqDTO.getParams();
         Course course = courseService.getById(params.getCourseId());
-        return statCourseMapper.userStatPaging(reqDTO.toPage(), course.getOpenType(), reqDTO.getParams());
+        IPage<StatCourseLearnDTO> list = statCourseMapper.userStatPaging(reqDTO.toPage(), course.getOpenType(), reqDTO.getParams());
+        Map<String ,SysDepart>  deptmap =  sysDepartService.getSysDepartGroupCode();
+        list.getRecords().stream().forEach(i -> {
+            SysDepart dept = deptmap.get(i.getDeptCode());
+            i.setDeptName(dept.getDeptName());
+        });
+        return list;
     }
 
     @Override

+ 8 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/sys/depart/service/SysDepartService.java

@@ -10,6 +10,7 @@ import com.gyee.exam.modules.sys.depart.dto.response.SysDepartTreeDTO;
 import com.gyee.exam.modules.sys.depart.entity.SysDepart;
 
 import java.util.List;
+import java.util.Map;
 
 /**
 * <p>
@@ -60,4 +61,11 @@ public interface SysDepartService extends IService<SysDepart> {
      * @param ids
      */
     void delete(List<String> ids);
+
+
+    /**
+     *
+     * @return
+     */
+    Map<String ,SysDepart> getSysDepartGroupCode();
 }

+ 13 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/sys/depart/service/impl/SysDepartServiceImpl.java

@@ -24,7 +24,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
 * <p>
@@ -219,6 +221,17 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
         this.removeByIds(ids);
     }
 
+    @Override
+    public Map<String ,SysDepart> getSysDepartGroupCode() {
+        Map<String ,SysDepart> map = new HashMap<>();
+        QueryWrapper<SysDepart> wrapper = new QueryWrapper<>();
+        List<SysDepart> list = baseMapper.selectList(wrapper);
+        list.stream().forEach(i->{
+            map.put(i.getDeptCode(),i);
+        });
+        return map;
+    }
+
     /**
      * 从上往下查找部门子节点
      * @param list

+ 1 - 1
exam-06173-api/src/main/resources/mapper/course/CourseMapper.xml

@@ -90,7 +90,7 @@
 
     <select id="userPaging" resultMap="UserCourseResultMap">
         SELECT
-        cs.id,cs.title,cs.content,cs.cover,cs.cat_id,cs.periods,cs.is_must,cs.is_pay,cs.price,
+        cs.id,cs.title,cs.content,cs.cover,cs.cat_id,cs.periods,cs.is_must,cs.is_pay,cs.price,cs.start_time,cs.end_time,
                (SELECT COUNT(0) FROM el_course_live WHERE course_id=cs.id) AS liveCount,
                cl.update_time,cl.learn_file,cl.total_file,cl.state
         FROM el_course cs

+ 17 - 2
exam-06173-api/src/main/resources/mapper/stat/course/StatCourseMapper.xml

@@ -114,6 +114,10 @@
         <if test="query.realName!=null and query.realName!=''">
             AND uc.real_name LIKE CONCAT('%', #{query.realName} , '%')
         </if>
+
+        <if test="query.courseDeparts!=null and query.courseDeparts!=''">
+            AND uc.dept_code in <foreach item="item" collection="query.courseDeparts" separator="," open="(" close=")" index="">'${item}'</foreach>
+        </if>
         ORDER BY cl.state DESC,totalMin DESC
     </sql>
 
@@ -125,7 +129,8 @@
         IFNULL(cl.learn_file, 0) AS learnFile,
         (SELECT COUNT(0) FROM el_course_ref_file WHERE course_id=dept.course_id) AS totalFile,
         uc.real_name AS realName,
-        (SELECT IFNULL(SUM(learn_min),0) FROM el_course_file_learn fl WHERE fl.course_id=cl.course_id AND fl.user_id=cl.user_id) AS totalMin
+        (SELECT IFNULL(SUM(learn_min),0) FROM el_course_file_learn fl WHERE fl.course_id=cl.course_id AND fl.user_id=cl.user_id) AS totalMin,
+        dept.dept_code deptCode
         FROM el_course_depart dept
         LEFT JOIN sys_user uc ON dept.dept_code=uc.dept_code
         LEFT JOIN el_course_learn cl ON cl.user_id=uc.id AND cl.course_id=dept.course_id
@@ -133,6 +138,11 @@
         <if test="query.realName!=null and query.realName!=''">
             AND (uc.real_name LIKE '%${query.realName}%' OR uc.user_name LIKE '%${query.realName}%')
         </if>
+
+        <if test="query.courseDeparts!=null and query.courseDeparts!=''">
+            AND dept.dept_code in <foreach item="item" collection="query.courseDeparts" separator="," open="(" close=")" index="">'${item}'</foreach>
+        </if>
+
         ORDER BY cl.state DESC,totalMin DESC
     </sql>
 
@@ -144,7 +154,8 @@
         IFNULL(cl.learn_file, 0) AS learnFile,
         (SELECT COUNT(0) FROM el_course_ref_file WHERE course_id=ps.course_id) AS totalFile,
         uc.real_name AS realName,
-        (SELECT IFNULL(SUM(learn_min),0) FROM el_course_file_learn fl WHERE fl.course_id=cl.course_id AND fl.user_id=cl.user_id) AS totalMin
+        (SELECT IFNULL(SUM(learn_min),0) FROM el_course_file_learn fl WHERE fl.course_id=cl.course_id AND fl.user_id=cl.user_id) AS totalMin,
+        uc.dept_code deptCode
         FROM el_course_person ps
         LEFT JOIN sys_user uc ON ps.user_id=uc.id
         LEFT JOIN el_course_learn cl ON cl.user_id=uc.id AND cl.course_id=ps.course_id
@@ -152,6 +163,10 @@
         <if test="query.realName!=null and query.realName!=''">
             AND (uc.real_name LIKE '%${query.realName}%' OR uc.user_name LIKE '%${query.realName}%')
         </if>
+
+        <if test="query.courseDeparts!=null and query.courseDeparts!=''">
+            AND uc.dept_code in <foreach item="item" collection="query.courseDeparts" separator="," open="(" close=")" index="">'${item}'</foreach>
+        </if>
         ORDER BY cl.state DESC,totalMin DESC
     </sql>