From b1074436898489628e9a2b99fd3c08d14dd93d85 Mon Sep 17 00:00:00 2001 From: zhangyue Date: Tue, 10 Mar 2026 10:56:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=BA=BA=E4=B8=80?= =?UTF-8?q?=E6=A1=A3=E6=89=B9=E9=87=8F=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edu/web/archives/ArchivesController.java | 6 + .../query/archives/ArchivesQueryExe.java | 141 +++++++++++++++++- .../service/archives/ArchivesServiceImpl.java | 7 + .../edu/api/archives/ArchivesServiceI.java | 1 + .../zcloud/edu/dto/archives/ArchivesQry.java | 1 + .../edu/dto/clientobject/study/StudentCO.java | 4 + .../zcloud/edu/dto/study/ClassPageQry.java | 1 + .../dataobject/study/StudentDO.java | 7 + .../resources/mapper/study/ClassMapper.xml | 25 +++- .../resources/mapper/study/StudentMapper.xml | 15 +- 10 files changed, 199 insertions(+), 9 deletions(-) diff --git a/web-adapter/src/main/java/com/zcloud/edu/web/archives/ArchivesController.java b/web-adapter/src/main/java/com/zcloud/edu/web/archives/ArchivesController.java index 64f804c..e1e13bc 100644 --- a/web-adapter/src/main/java/com/zcloud/edu/web/archives/ArchivesController.java +++ b/web-adapter/src/main/java/com/zcloud/edu/web/archives/ArchivesController.java @@ -77,6 +77,12 @@ public class ArchivesController { archivesService.downloadPersonArchives(qry); return Response.buildSuccess(); } + @ApiOperation("下载一人一档批量") + @PostMapping("/downloadPersonArchivesList") + public Response downloadPersonArchivesList(@RequestBody ArchivesQry qry) { + archivesService.downloadPersonArchivesList(qry); + return Response.buildSuccess(); + } @ApiOperation("下载一期一档") @PostMapping("/downloadClassArchives") public Response downloadClassArchives(@RequestBody ArchivesQry qry) { diff --git a/web-app/src/main/java/com/zcloud/edu/command/query/archives/ArchivesQueryExe.java b/web-app/src/main/java/com/zcloud/edu/command/query/archives/ArchivesQueryExe.java index 723fe17..4ce935b 100644 --- a/web-app/src/main/java/com/zcloud/edu/command/query/archives/ArchivesQueryExe.java +++ b/web-app/src/main/java/com/zcloud/edu/command/query/archives/ArchivesQueryExe.java @@ -3,6 +3,7 @@ package com.zcloud.edu.command.query.archives; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.alibaba.cola.dto.PageResponse; +import com.alibaba.cola.exception.BizException; import com.alibaba.cola.statemachine.impl.SysOutVisitor; import com.deepoove.poi.data.PictureRenderData; import com.deepoove.poi.data.PictureType; @@ -231,6 +232,138 @@ public class ArchivesQueryExe { } } + + public List downloadPersonArchivesList(ArchivesQry qry){ + List personArchivesDTOList = new ArrayList(); + for(Long stuId : qry.getStuIdList()){ + ClassE classE = null; + List classCurList = new ArrayList(); + List classChapterEList = new ArrayList(); + List studentSignEList = new ArrayList(); + HashMap params = new HashMap(); + + // 学员信息 + StudentDO studentDO = studentRepository.getById(stuId); + byte[] userIdCardBytes = Base64.getDecoder().decode(studentDO.getUserIdCard()); + String userIdCardString = new String(userIdCardBytes); + studentDO.setUserIdCard(userIdCardString); + StudentE studentE = new StudentE(); + BeanUtils.copyProperties(studentDO, studentE); + + // 班级信息 + ClassDO classDO = classRepository.getByClassId(studentDO.getClassId()); + classE = new ClassE(); + BeanUtils.copyProperties(classDO, classE); + + if (qry.getTypeList().contains(2) || qry.getTypeList().contains(3) || qry.getTypeList().contains(4)) { + + + params.put("classId", studentDO.getClassId()); + // 课程信息 + List curEList = classCurriculumRepository.listAll(params); + classCurList = BeanUtil.copyToList(curEList, ClassCurriculumE.class); + } + + if (qry.getTypeList().contains(2)) { + // 课件信息 + List classChapterList = classCurriculumChapterRepository.listVideoByClassId(classE.getClassId()); + classChapterEList = BeanUtil.copyToList(classChapterList, ClassCurriculumChapterE.class); + } + if (qry.getTypeList().contains(3)) { + // 学员人脸记录 + StudentDO studentUrl = studentRepository.findFaceUrlByPhone(studentDO.getPhone()); + if (studentUrl != null) { + studentE.setUserAvatarUrl(studentUrl.getUserAvatarUrl()); + } + } + if (qry.getTypeList().contains(4)) { + // 签到照片 + params.put("studentId", studentDO.getStudentId()); + List studentSignList = studentSignRepository.listAllByStudentId(params); + studentSignEList = BeanUtil.copyToList(studentSignList, StudentSignE.class); + } + + PersonArchivesE personArchivesE = new PersonArchivesE(); + personArchivesE.initDownload(studentE, + classE, + classCurList, + classChapterEList, + studentSignEList); + PersonArchivesDTO personArchivesDTO = new PersonArchivesDTO(); + BeanUtils.copyProperties(personArchivesE, personArchivesDTO); + if (qry.getTypeList().contains(5)) { + StudentExamRecordDO studentExamRecordDO = studentExamRecordRepository.getInfoByStudentId(studentDO.getStudentId()); + if(studentExamRecordDO != null){ + StudentExamRecordCO studentExamRecordCO = new StudentExamRecordCO(); + BeanUtils.copyProperties(studentExamRecordDO, studentExamRecordCO); + List recordList = studentExamRecordItemRepository.listByExamRecordId(studentExamRecordDO.getStudentExamRecordId()); + List recordCoList = studentExamRecordItemCoConvertor.converDOsToCOs(recordList); + studentExamRecordCO.setExamRecordItemList(recordCoList); + personArchivesDTO.setStudentExamRecord(studentExamRecordCO); + } + + } + personArchivesDTOList.add(personArchivesDTO); + } +// String studentIds = personArchivesDTOList.stream().map(PersonArchivesDTO::getStudentId).collect(Collectors.joining(",")); + // 新增档案下载记录 + + ArchivesPdfFileE archivesPdfFileE = new ArchivesPdfFileE(); + archivesPdfFileE.init("student",personArchivesDTOList.get(0).getPhone() , 1, AuthContext.getTenantId(), personArchivesDTOList.get(0).getName()+"-"); + ArchivesPdfFileDO archivesPdfFileDO = new ArchivesPdfFileDO(); + BeanUtils.copyProperties(archivesPdfFileE, archivesPdfFileDO); + archivesPdfFileRepository.save(archivesPdfFileDO); + personArchivesDTOList.get(0).setArchivesPdfFileId(archivesPdfFileDO.getId()); + return personArchivesDTOList; + } + @Async("archivesAsyncExecutor") + public void execteGeneratePdfList(ArchivesQry qry, List personArchivesDTOList){ + String archivesDate = DateUtil.getSdfTimes(); + String tempDir = System.getProperty("java.io.tmpdir"); + List stringList = new ArrayList<>(); + try { + for (PersonArchivesDTO params : personArchivesDTOList){ + + + List byteArrayList = new ArrayList<>(); + if (qry.getTypeList().contains(1)){ + byteArrayList.add(execteHomepage(params)); + System.out.println("1-------------------------------------------------------------"); + } + if (qry.getTypeList().contains(2)){ + byteArrayList.add(execteAttendanceRecord(params)); + System.out.println("2------------------------------------------------------------"); + } + if (qry.getTypeList().contains(3)){ + byteArrayList.add(execteStudentRecord(params)); + System.out.println("3-------------------------------------------------------------"); + } + if (qry.getTypeList().contains(4)){ + byteArrayList.add(execteStudyRecord(params)); + System.out.println("4-------------------------------------------------------------"); + } + if (qry.getTypeList().contains(5)){ + byteArrayList.add(execteExamRecord(params)); + System.out.println("5-------------------------------------------------------------"); + } + byte[] pdf = WordToPdfUtil.mergeWordToPdf(byteArrayList); + Files.write(Paths.get(tempDir+"/"+params.getClassName()+"-一人一档-"+DateUtil.getSdfTimes()+".pdf"), pdf); + stringList.add(new File(tempDir+"/"+params.getClassName()+"-一人一档-"+DateUtil.getSdfTimes()+".pdf")); + } + FileZip.zipList(tempDir+"/"+personArchivesDTOList.get(0).getName()+"-"+ archivesDate+"一人一档.zip", stringList); + File file = new File(tempDir+"/"+personArchivesDTOList.get(0).getName()+"-"+ archivesDate+"一人一档.zip"); + byte[] bytes = Files.readAllBytes(file.toPath()); + String filepath = zcloudImgFilesFacade.saveFile(bytes, personArchivesDTOList.get(0).getName()+"-"+ archivesDate+"一人一档.zip","personArchives", personArchivesDTOList.get(0).getClassCorpinfoId()); + ArchivesPdfFileE archivesPdfFileE = new ArchivesPdfFileE(); + archivesPdfFileE.initEdit(personArchivesDTOList.get(0).getArchivesPdfFileId(), filepath, 1, null); + ArchivesPdfFileDO archivesPdfFileDO = new ArchivesPdfFileDO(); + BeanUtils.copyProperties(archivesPdfFileE, archivesPdfFileDO); + archivesPdfFileRepository.updateById(archivesPdfFileDO); + } catch (Exception e) { + e.printStackTrace(); +// throw new BizException("导出失败"); + } + } public byte[] execteHomepage(PersonArchivesDTO params){ try { Map workItem = PropertyUtils.describe( params); @@ -277,7 +410,7 @@ public class ArchivesQueryExe { } - if (!ObjectUtils.isEmpty(params.getExamSignFlag())) { + if (!ObjectUtils.isEmpty(params.getExamSignFaceUrl())) { PictureRenderData examSignFacePicture = Pictures.ofUrl(fileUrlConfig.getPrefixUrl() + params.getExamSignFaceUrl(), PictureType.JPEG).size(100, 100).create();//网络图片地址 workItem.put("examSignFacePicture", examSignFacePicture); // String imageUrl = fileUrlConfig.getPrefixUrl() + params.getExamSignFaceUrl(); @@ -313,7 +446,7 @@ public class ArchivesQueryExe { } public byte[] execteExamRecord(PersonArchivesDTO params){ try { - Map workItem = PropertyUtils.describe( params.getStudentExamRecord()); + Map workItem = BeanUtil.beanToMap(params.getStudentExamRecord()); ArrayList workList = CollUtil.newArrayList(); AtomicInteger atomicIndex = new AtomicInteger(1); params.getStudentExamRecord().getExamRecordItemList().forEach(item -> { @@ -355,7 +488,9 @@ public class ArchivesQueryExe { ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem); return outputStream.toByteArray(); } catch (Exception e) { - throw new RuntimeException(e); + e.printStackTrace(); + return null; +// throw new BizException("导出失败"); } } diff --git a/web-app/src/main/java/com/zcloud/edu/service/archives/ArchivesServiceImpl.java b/web-app/src/main/java/com/zcloud/edu/service/archives/ArchivesServiceImpl.java index 5915e9e..a6d6acd 100644 --- a/web-app/src/main/java/com/zcloud/edu/service/archives/ArchivesServiceImpl.java +++ b/web-app/src/main/java/com/zcloud/edu/service/archives/ArchivesServiceImpl.java @@ -55,6 +55,13 @@ public class ArchivesServiceImpl implements ArchivesServiceI { } + @Override + public void downloadPersonArchivesList(ArchivesQry qry) { + List personArchivesDTOList = archivesQueryExe.downloadPersonArchivesList(qry); + + archivesQueryExe.execteGeneratePdfList(qry,personArchivesDTOList); + } + @Override public void downloadClassArchives(ArchivesQry qry) { ClassArchivesDTO classArchivesDTO = archivesQueryExe.downloadClassArchives(qry); diff --git a/web-client/src/main/java/com/zcloud/edu/api/archives/ArchivesServiceI.java b/web-client/src/main/java/com/zcloud/edu/api/archives/ArchivesServiceI.java index 2691c8a..3024722 100644 --- a/web-client/src/main/java/com/zcloud/edu/api/archives/ArchivesServiceI.java +++ b/web-client/src/main/java/com/zcloud/edu/api/archives/ArchivesServiceI.java @@ -16,6 +16,7 @@ import com.zcloud.edu.dto.clientobject.archives.ArchivesReviewCO; */ public interface ArchivesServiceI { void downloadPersonArchives(ArchivesQry qry); + void downloadPersonArchivesList(ArchivesQry qry); void downloadClassArchives(ArchivesQry qry); void downloadReviewRevision(ArchivesQry qry); void downloadClassCur(ArchivesQry qry); diff --git a/web-client/src/main/java/com/zcloud/edu/dto/archives/ArchivesQry.java b/web-client/src/main/java/com/zcloud/edu/dto/archives/ArchivesQry.java index f21fc87..f20a796 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/archives/ArchivesQry.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/archives/ArchivesQry.java @@ -28,6 +28,7 @@ public class ArchivesQry { private List typeList; private String studentId; private Long stuId; + private List stuIdList; private String classId; private List classCurriculumIds; private Long classCurriculumIdLong; diff --git a/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentCO.java b/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentCO.java index 83c4cbc..b99eff9 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentCO.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/clientobject/study/StudentCO.java @@ -190,6 +190,10 @@ public class StudentCO extends ClientObject { private Integer numberofexams; + // 考试状态( 0-待考试 1-已通过 2-不考试 -1 - 待考试) + @ApiModelProperty(value = "考试状态( 0-待考试 1-已通过 2-不考试 -1 - 待考试)") + @TableField(exist = false) + private Integer examState; // 学员统计数量 @ApiModelProperty(value = "学员统计数量") @TableField(exist = false) diff --git a/web-client/src/main/java/com/zcloud/edu/dto/study/ClassPageQry.java b/web-client/src/main/java/com/zcloud/edu/dto/study/ClassPageQry.java index 9fa9a4f..1da283c 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/study/ClassPageQry.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/study/ClassPageQry.java @@ -36,6 +36,7 @@ public class ClassPageQry extends PageQuery { private Long eqCorpinfoId; private String phone; private String signFlag; + private String examState; private String examination; private String menuPath; diff --git a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentDO.java b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentDO.java index 8fc785f..c470fcb 100644 --- a/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentDO.java +++ b/web-infrastructure/src/main/java/com/zcloud/edu/persistence/dataobject/study/StudentDO.java @@ -186,6 +186,13 @@ public class StudentDO extends BaseDO { @ApiModelProperty(value = "1考试0不考试") @TableField(exist = false) private Integer examination; + // 考试状态( 0-待考试 1-已通过 2-不考试 -1 - 待考试) + @ApiModelProperty(value = "考试状态( 0-待考试 1-已通过 2-不考试 -1 - 待考试)") + @TableField(exist = false) + private Integer examState; + + + //考试次数只有考试时候有用 @ApiModelProperty(value = "考试次数只有考试时候有用") @TableField(exist = false) diff --git a/web-infrastructure/src/main/resources/mapper/study/ClassMapper.xml b/web-infrastructure/src/main/resources/mapper/study/ClassMapper.xml index 98f44fc..b1b4148 100644 --- a/web-infrastructure/src/main/resources/mapper/study/ClassMapper.xml +++ b/web-infrastructure/src/main/resources/mapper/study/ClassMapper.xml @@ -193,6 +193,14 @@ when c.state = 2 and c.end_time <= now() then 4 end class_state, + + case when c.examination = 1 and s.state = 0 and c.end_time > now() then 0 + when c.examination = 1 and s.state = 1 then 1 + when c.examination = 1 and s.state = 0 and c.end_time < now() then -1 + when c.examination = 0 then 2 + end exam_state, + + c.valid_start_time, c.valid_end_time, c.examination, @@ -217,8 +225,23 @@ and s.sign_flag = #{params.signFlag} - and s.exam_sign_flag = #{params.examination} + and c.examination = #{params.examination} + + + and c.examination = 1 and s.state = 0 and c.end_time > now() + + + and c.examination = 1 and s.state = 1 + + + and c.examination = 1 and s.state = 0 and c.end_time < now() + + + and c.examination = 0 + + + and c.state = 1 diff --git a/web-infrastructure/src/main/resources/mapper/study/StudentMapper.xml b/web-infrastructure/src/main/resources/mapper/study/StudentMapper.xml index 26af522..f43c5d8 100644 --- a/web-infrastructure/src/main/resources/mapper/study/StudentMapper.xml +++ b/web-infrastructure/src/main/resources/mapper/study/StudentMapper.xml @@ -210,7 +210,8 @@ case when s.state = 1 then 1 when s.state = 0 and c.start_time > now() then 0 when s.state = 0 and c.start_time <= now() and c.end_time >= now() then 2 - when s.state = 0 and c.end_time <= now() then 3 + when s.sign_flag = 0 and c.end_time <= now() then 3 + when s.state = 0 and c.end_time <= now() then 4 end as state, s.interested_ids, s.interested_names, @@ -241,19 +242,23 @@ and DATE(c.end_time) =]]> #{params.endTime} - + and s.state = 0 and c.start_time > now() - + and s.state = #{params.state} - + and s.state = 0 and c.start_time <= now() and c.end_time >= now() - + + and s.sign_flag = 0 + and c.end_time <= now() + + and s.state = 0 and c.end_time <= now()