Forráskód Böngészése

Merge remote-tracking branch 'origin/dev' into dev

大数据与最优化研究所 1 hete
szülő
commit
c81cb23ad6

+ 107 - 43
src/main/java/com/xjrsoft/module/teacher/controller/TeacherAwardController.java

@@ -1,32 +1,37 @@
 package com.xjrsoft.module.teacher.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.bean.BeanUtil;
 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.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.FileZipUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.module.system.entity.File;
 import com.xjrsoft.module.system.service.IFileService;
 import com.xjrsoft.module.teacher.dto.TeacherAwardDetailPageDto;
-import com.xjrsoft.module.teacher.dto.TeacherAwardFileListDto;
 import com.xjrsoft.module.teacher.dto.TeacherAwardStatisticsPageDto;
 import com.xjrsoft.module.teacher.entity.TeacherAward;
 import com.xjrsoft.module.teacher.entity.TeacherAwardItem;
 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.TeacherAwardDetailExcelVo;
 import com.xjrsoft.module.teacher.vo.TeacherAwardDetailPageVo;
-import com.xjrsoft.module.teacher.vo.TeacherAwardFileListVo;
 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 me.zhyd.oauth.log.Log;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -40,12 +45,10 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
 * @title: 教师奖项
@@ -107,50 +110,111 @@ public class TeacherAwardController {
     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());
-        TeacherAwardFileListDto listDto = new TeacherAwardFileListDto();
-        listDto.setApplicantUserIds(userIds);
-        List<TeacherAwardFileListVo> awardList = teacherAwardService.getAwardFileList(listDto);
-        Map<Long, List<TeacherAwardFileListVo>> filesMap = awardList.stream().collect(Collectors.groupingBy(TeacherAwardFileListVo::getApplicantUserId));
+        ByteArrayOutputStream bot = new ByteArrayOutputStream();
+        EasyExcel.write(bot, TeacherAwardStatisticsExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(list);
 
-        //声明一个Map,将所有文件装进去,map的key是完整的文件名
-        Map<String, byte[]> byteAryMap = new HashMap<>();
+        return RT.fileStream(bot.toByteArray(), "教师获奖登记" + ExcelTypeEnum.XLSX.getValue());
+    }
 
-        for (TeacherAwardStatisticsPageVo el : list) {
-            List<TeacherAwardFileListVo> fileList = filesMap.get(el.getId());
-            if(fileList == null){
-                continue;
-            }
-            for (int i = 0; i < fileList.size(); i++) {
-                try {
-                    URL url = new URL(fileList.get(i).getFileUrl());
-                    URLConnection conn = url.openConnection();
-                    InputStream in = conn.getInputStream();
-                    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-                    byte[] buffer = new byte[1024];
-                    int bytesRead;
-                    while ((bytesRead = in.read(buffer)) != -1) {
-                        outputStream.write(buffer, 0, bytesRead);
+
+    @PostMapping(value = "/detail-export-query")
+    @ApiOperation(value="教师获奖详情页")
+    @SaCheckPermission("teacheraward:detail")
+    public ResponseEntity<byte[]> detailExportQuery(@Valid @RequestBody TeacherAwardDetailPageDto dto){
+        try {
+            MPJLambdaWrapper<TeacherAward> teacherAwardMPJLambdaWrapper = new MPJLambdaWrapper<>();
+            teacherAwardMPJLambdaWrapper
+                    .disableSubLogicDel()
+                    .selectAs(TeacherAwardItem::getIsThesis, TeacherAwardDetailPageVo::getIsThesis)
+                    .selectAs(XjrUser::getName, TeacherAwardDetailPageVo::getApplicantUserIdCn)
+                    .select(TeacherAward.class,x -> VoToColumnUtil.fieldsToColumns(TeacherAwardDetailPageVo.class).contains(x.getProperty()))
+                    .leftJoin(TeacherAwardItem.class, TeacherAwardItem::getId, TeacherAward::getTeacherAwardItemId)
+                    .leftJoin(XjrUser.class, XjrUser::getId, TeacherAward::getApplicantUserId)
+                    .eq(dto.getApplicantUserId() != null && dto.getApplicantUserId() > 0,TeacherAward::getApplicantUserId, dto.getApplicantUserId())
+                    .eq(dto.getIsThesis() != null,TeacherAwardItem::getIsThesis, dto.getIsThesis())
+                    .like(dto.getApplicantUserIdCn() != null && !dto.getApplicantUserIdCn().equals(""), XjrUser::getName, dto.getApplicantUserIdCn())
+                    .like(dto.getWholeCompetitionName() != null && !dto.getWholeCompetitionName().equals(""),TeacherAward::getWholeCompetitionName, dto.getWholeCompetitionName())
+                    .eq(TeacherAward::getStatus, 1)
+                    .orderByDesc(TeacherAward::getCreateDate)
+            ;
+            List<TeacherAwardDetailPageVo> list = teacherAwardService.selectJoinList(TeacherAwardDetailPageVo.class, teacherAwardMPJLambdaWrapper);
+            List<TeacherAwardDetailExcelVo> excelList = new ArrayList<>();
+            int index = 1;
+            Map<String, byte[]> byteAryMap = new HashMap<>();
+            String folderName = "附件材料";
+            for (TeacherAwardDetailPageVo el : list) {
+                TeacherAwardDetailExcelVo rowData = BeanUtil.toBean(el, TeacherAwardDetailExcelVo.class);
+                if(el.getIsThesis() == 1){
+                    rowData.setIsThesis("是");
+                }else if(el.getIsThesis() == 0){
+                    rowData.setIsThesis("否");
+                }
+                List<File> fileList = fileService.list(
+                        new QueryWrapper<File>().lambda()
+                                .eq(File::getFolderId, el.getFileId())
+                                .eq(File::getDeleteMark, DeleteMark.NODELETE.getCode())
+                );
+
+                if(fileList.isEmpty()){
+                    excelList.add(rowData);
+                    continue;
+                }
+                String fileName = "佐证材料" + index;
+                if(fileList.size() == 1){
+                    try {
+                        File file = fileList.get(0);
+                        URL url = new URL(file.getFileUrl());
+                        URLConnection conn = url.openConnection();
+                        InputStream in = conn.getInputStream();
+                        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+                        byte[] buffer = new byte[1024];
+                        int bytesRead;
+                        while ((bytesRead = in.read(buffer)) != -1) {
+                            outputStream.write(buffer, 0, bytesRead);
+                        }
+                        byte[] byteArray = outputStream.toByteArray();
+                        byteAryMap.put(folderName + "\\" + fileName + file.getFileType(), byteArray);
+                        in.close();
+                        outputStream.close();
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                }else{
+                    for (int i = 0; i < fileList.size(); i++) {
+                        try {
+                            URL url = new URL(fileList.get(i).getFileUrl());
+                            URLConnection conn = url.openConnection();
+                            InputStream in = conn.getInputStream();
+                            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+                            byte[] buffer = new byte[1024];
+                            int bytesRead;
+                            while ((bytesRead = in.read(buffer)) != -1) {
+                                outputStream.write(buffer, 0, bytesRead);
+                            }
+                            byte[] byteArray = outputStream.toByteArray();
+                            byteAryMap.put(folderName + "\\" + fileName + "\\佐证材料" + (i + 1) + fileList.get(i).getFileType(), byteArray);
+                            in.close();
+                            outputStream.close();
+                        } catch (IOException e) {
+                            throw new RuntimeException(e);
+                        }
                     }
-                    byte[] byteArray = outputStream.toByteArray();
-                    byteAryMap.put(el.getName() + "\\佐证材料" + (i + 1) + fileList.get(i).getFileType(), byteArray);
-                    in.close();
-                    outputStream.close();
-                } catch (IOException e) {
-                    throw new RuntimeException(e);
                 }
-            }
-        }
-
 
-        ByteArrayOutputStream bot = new ByteArrayOutputStream();
-        EasyExcel.write(bot, TeacherAwardStatisticsExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(list);
-        byteAryMap.put("教师获奖登记" + ExcelTypeEnum.XLSX.getValue(), bot.toByteArray());
+                rowData.setFileName(fileName);
+                excelList.add(rowData);
+                index ++;
+            }
 
-        byte[] bytes = FileZipUtil.byteAryMap2Zip(byteAryMap);
-        LocalDateTime now = LocalDateTime.now();
-        String timeStr = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+            ByteArrayOutputStream bot = new ByteArrayOutputStream();
+            EasyExcel.write(bot, TeacherAwardDetailExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(excelList);
+            byteAryMap.put("教师获奖登记" + ExcelTypeEnum.XLSX.getValue(), bot.toByteArray());
 
-        return RT.fileStream(bytes, "教师获奖登记" + timeStr + ".zip");
+            byte[] bytes = FileZipUtil.byteAryMap2Zip(byteAryMap);
+            return RT.fileStream(bytes, "detailExportQuery.zip");
+        }catch (Exception e){
+            Log.error(e.getMessage(), e);
+            throw new MyException("导出出错,请联系管理员");
+        }
     }
 }

+ 62 - 0
src/main/java/com/xjrsoft/module/teacher/vo/TeacherAwardDetailExcelVo.java

@@ -0,0 +1,62 @@
+package com.xjrsoft.module.teacher.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+* @title: 教师奖项分页列表出参
+* @Author dzx
+* @Date: 2024年11月13日
+* @Version 1.0
+*/
+@Data
+public class TeacherAwardDetailExcelVo {
+
+
+    @ExcelProperty("教师名称")
+    @ApiModelProperty("教师名称")
+    private String applicantUserIdCn;
+
+    @ExcelProperty("奖项名称")
+    @ApiModelProperty("奖项名称")
+    private String competitionName;
+
+    @ExcelProperty("是否论文")
+    @ApiModelProperty("是否论文")
+    private String isThesis;
+
+    @ExcelProperty("作品名称")
+    @ApiModelProperty("作品名称")
+    private String paperName;
+
+    @ExcelProperty("媒体名称")
+    @ApiModelProperty("媒体名称")
+    private String journalName;
+
+    @ExcelProperty("媒体类型")
+    @ApiModelProperty("媒体类型")
+    private String mediaType;
+
+    @ExcelProperty("国内统一刊号")
+    @ApiModelProperty("国内统一刊号CN")
+    private String journalNumber;
+
+    @ExcelProperty("期刊级别")
+    @ApiModelProperty("期刊级别(核心期刊、一般期刊、(校级、内部论文))")
+    private String journalLevel;
+
+    @ExcelProperty("发表/获奖时间")
+    @ApiModelProperty("发表时间")
+    private Date issueDate;
+
+    @ExcelProperty("备注")
+    @ApiModelProperty("备注")
+    private String remark;
+
+    @ExcelProperty("附件名称")
+    @ApiModelProperty("附件名称")
+    private String fileName;
+}

+ 1 - 1
src/main/resources/mapper/evaluate/EvaluateResultMapper.xml

@@ -125,7 +125,7 @@
             t.problem,
             t.topic,
             t1.score as actualScore,
-            t1.opinion,t1.option_json
+            t1.opinion,t1.option_content
         from evaluate_manage_item t
                  left join evaluate_result t1 on t1.evaluate_item_id = t.id
         where t.delete_mark = 0