소스 검색

教师获奖统计导出

dzx 1 주 전
부모
커밋
d40ec8757e

+ 32 - 0
src/main/java/com/xjrsoft/module/teacher/controller/TeacherAwardController.java

@@ -1,9 +1,13 @@
 package com.xjrsoft.module.teacher.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.support.ExcelTypeEnum;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
@@ -16,15 +20,22 @@ import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.teacher.service.ITeacherAwardItemService;
 import com.xjrsoft.module.teacher.service.ITeacherAwardService;
 import com.xjrsoft.module.teacher.vo.TeacherAwardDetailPageVo;
+import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsExcelVo;
 import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsPageVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springframework.http.ResponseEntity;
 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.io.ByteArrayOutputStream;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
 * @title: 教师奖项
@@ -77,4 +88,25 @@ public class TeacherAwardController {
         PageOutput<TeacherAwardDetailPageVo> pageOutput = ConventPage.getPageOutput(page, TeacherAwardDetailPageVo.class);
         return RT.ok(pageOutput);
     }
+
+    @PostMapping(value = "/export-query")
+    @ApiOperation(value="导出")
+    @SaCheckPermission("teacheraward:detail")
+    public ResponseEntity<byte[]> exportQuery(@Valid @RequestBody TeacherAwardStatisticsPageDto dto){
+        List<TeacherAwardStatisticsPageVo> list = teacherAwardItemService.getStatisticsList(dto);
+
+        List<Long> userIds = list.stream().map(TeacherAwardStatisticsPageVo::getId).collect(Collectors.toList());
+        List<TeacherAward> awardList = teacherAwardService.list(
+                new QueryWrapper<TeacherAward>().lambda()
+                        .eq(TeacherAward::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .in(TeacherAward::getApplicantUserId, userIds)
+                        .orderByAsc(TeacherAward::getCreateDate)
+        );
+
+
+        ByteArrayOutputStream bot = new ByteArrayOutputStream();
+        EasyExcel.write(bot, TeacherAwardStatisticsExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(list);
+
+        return RT.fileStream(bot.toByteArray(), "TeacherAward" + ExcelTypeEnum.XLSX.getValue());
+    }
 }

+ 5 - 0
src/main/java/com/xjrsoft/module/teacher/mapper/TeacherAwardItemMapper.java

@@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseMapper;
 import com.xjrsoft.module.teacher.dto.TeacherAwardStatisticsPageDto;
 import com.xjrsoft.module.teacher.entity.TeacherAwardItem;
+import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsExcelVo;
 import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsPageVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
 * @title: 教师奖项
 * @Author dzx
@@ -18,4 +21,6 @@ import org.apache.ibatis.annotations.Param;
 public interface TeacherAwardItemMapper extends MPJBaseMapper<TeacherAwardItem> {
 
     Page<TeacherAwardStatisticsPageVo> getStatisticsPage(Page<TeacherAwardStatisticsPageVo> page, @Param("dto") TeacherAwardStatisticsPageDto dto);
+
+    List<TeacherAwardStatisticsPageVo> getStatisticsList(@Param("dto") TeacherAwardStatisticsPageDto dto);
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/teacher/service/ITeacherAwardItemService.java

@@ -5,7 +5,9 @@ import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.teacher.dto.TeacherAwardStatisticsPageDto;
 import com.xjrsoft.module.teacher.entity.TeacherAwardItem;
 import com.xjrsoft.module.teacher.vo.TeacherAwardItemVo;
+import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsExcelVo;
 import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsPageVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -22,4 +24,6 @@ public interface ITeacherAwardItemService extends MPJBaseService<TeacherAwardIte
 
     List<TeacherAwardItemVo> getTeacherAwardItemTree(Integer isThesis);
 
+    List<TeacherAwardStatisticsPageVo> getStatisticsList(@Param("dto") TeacherAwardStatisticsPageDto dto);
+
 }

+ 6 - 0
src/main/java/com/xjrsoft/module/teacher/service/impl/TeacherAwardItemServiceImpl.java

@@ -12,6 +12,7 @@ import com.xjrsoft.module.teacher.mapper.TeacherAwardItemMapper;
 import com.xjrsoft.module.teacher.service.ITeacherAwardItemService;
 import com.xjrsoft.module.teacher.vo.TeacherAwardItemPageVo;
 import com.xjrsoft.module.teacher.vo.TeacherAwardItemVo;
+import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsExcelVo;
 import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsPageVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
@@ -48,4 +49,9 @@ public class TeacherAwardItemServiceImpl extends MPJBaseServiceImpl<TeacherAward
         return TreeUtil.build(itemVos);
     }
 
+    @Override
+    public List<TeacherAwardStatisticsPageVo> getStatisticsList(TeacherAwardStatisticsPageDto dto) {
+        return this.baseMapper.getStatisticsList(dto);
+    }
+
 }

+ 40 - 0
src/main/java/com/xjrsoft/module/teacher/vo/TeacherAwardStatisticsExcelVo.java

@@ -0,0 +1,40 @@
+package com.xjrsoft.module.teacher.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* @title: 教师奖项分页列表出参
+* @Author dzx
+* @Date: 2024-06-04
+* @Version 1.0
+*/
+@Data
+public class TeacherAwardStatisticsExcelVo {
+
+    @ExcelProperty("用户名")
+    @ApiModelProperty("用户名")
+    private String userName;
+
+    @ExcelProperty("姓名")
+    @ApiModelProperty("姓名")
+    private String name;
+
+    @ExcelProperty("编号")
+    @ApiModelProperty("编号")
+    private String code;
+
+    @ExcelProperty("性别")
+    @ApiModelProperty("性别")
+    private String genderCn;
+
+    @ExcelProperty("手机号")
+    @ApiModelProperty("手机号")
+    private String mobile;
+
+    @ExcelProperty("分数")
+    @ApiModelProperty("分数")
+    private Double score;
+
+}

+ 32 - 0
src/main/resources/mapper/teacher/TeacherAwardItemMapper.xml

@@ -28,4 +28,36 @@
         </if>
 
     </select>
+
+    <select id="getStatisticsList" parameterType="com.xjrsoft.module.teacher.dto.TeacherAwardStatisticsPageDto" resultType="com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsPageVo">
+        SELECT t1.id, t1.user_name, t1.name,t1.code,t3.name AS gender_cn,t1.mobile,
+        (SELECT SUM(a2.score) FROM teacher_award a1
+        INNER JOIN teacher_award_item a2 ON a1.teacher_award_item_id = a2.id
+        WHERE a1.status = 1 AND a1.delete_mark = 0 AND a2.delete_mark = 0
+        AND a1.applicant_user_id = t1.id
+        <if test="dto.awardDateStart != null and dto.awardDateEnd != null">
+            and a1.award_date between #{dto.awardDateStart} and #{dto.awardDateEnd}
+        </if>
+        ) AS score FROM xjr_user t1
+        INNER JOIN base_teacher t2 ON t1.id = t2.user_id
+        left join xjr_user_dept_relation t4 on t4.user_id = t1.id
+        LEFT JOIN xjr_dictionary_detail t3 ON t1.gender = t3.code
+        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
+        <if test="dto.userName != null and dto.userName != '' ">
+            and t1.user_name like concat('%', #{dto.userName}, '%')
+        </if>
+        <if test="dto.name != null and dto.name != '' ">
+            and t1.name like concat('%', #{dto.name}, '%')
+        </if>
+        <if test="dto.deptId != null">
+            and t4.dept_id = #{dto.deptId}
+        </if>
+    </select>
+
+    <select id="getAwardFileList" parameterType="com.xjrsoft.module.teacher.dto.TeacherAwardStatisticsPageDto" resultType="com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsPageVo">
+        SELECT t1.applicant_user_id,t3.file_name,t3.file_suffiex,t3.file_url FROM teacher_award t1
+        INNER JOIN xjr_workflow_form_relation t2 ON t1.id = t2.form_key_value
+        INNER JOIN xjr_file t3 ON t1.file_id = t3.folder_id
+        WHERE t1.delete_mark = 0 AND t2.current_state = 'COMPLETED'
+    </select>
 </mapper>