添加一人一档批量下载
parent
84270b39cb
commit
b107443689
|
|
@ -77,6 +77,12 @@ public class ArchivesController {
|
||||||
archivesService.downloadPersonArchives(qry);
|
archivesService.downloadPersonArchives(qry);
|
||||||
return Response.buildSuccess();
|
return Response.buildSuccess();
|
||||||
}
|
}
|
||||||
|
@ApiOperation("下载一人一档批量")
|
||||||
|
@PostMapping("/downloadPersonArchivesList")
|
||||||
|
public Response downloadPersonArchivesList(@RequestBody ArchivesQry qry) {
|
||||||
|
archivesService.downloadPersonArchivesList(qry);
|
||||||
|
return Response.buildSuccess();
|
||||||
|
}
|
||||||
@ApiOperation("下载一期一档")
|
@ApiOperation("下载一期一档")
|
||||||
@PostMapping("/downloadClassArchives")
|
@PostMapping("/downloadClassArchives")
|
||||||
public Response downloadClassArchives(@RequestBody ArchivesQry qry) {
|
public Response downloadClassArchives(@RequestBody ArchivesQry qry) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.zcloud.edu.command.query.archives;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.alibaba.cola.dto.PageResponse;
|
import com.alibaba.cola.dto.PageResponse;
|
||||||
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.alibaba.cola.statemachine.impl.SysOutVisitor;
|
import com.alibaba.cola.statemachine.impl.SysOutVisitor;
|
||||||
import com.deepoove.poi.data.PictureRenderData;
|
import com.deepoove.poi.data.PictureRenderData;
|
||||||
import com.deepoove.poi.data.PictureType;
|
import com.deepoove.poi.data.PictureType;
|
||||||
|
|
@ -231,6 +232,138 @@ public class ArchivesQueryExe {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<PersonArchivesDTO> downloadPersonArchivesList(ArchivesQry qry){
|
||||||
|
List<PersonArchivesDTO> personArchivesDTOList = new ArrayList<PersonArchivesDTO>();
|
||||||
|
for(Long stuId : qry.getStuIdList()){
|
||||||
|
ClassE classE = null;
|
||||||
|
List<ClassCurriculumE> classCurList = new ArrayList<ClassCurriculumE>();
|
||||||
|
List<ClassCurriculumChapterE> classChapterEList = new ArrayList<ClassCurriculumChapterE>();
|
||||||
|
List<StudentSignE> studentSignEList = new ArrayList<StudentSignE>();
|
||||||
|
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
// 学员信息
|
||||||
|
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<ClassCurriculumDO> curEList = classCurriculumRepository.listAll(params);
|
||||||
|
classCurList = BeanUtil.copyToList(curEList, ClassCurriculumE.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qry.getTypeList().contains(2)) {
|
||||||
|
// 课件信息
|
||||||
|
List<ClassCurriculumChapterDO> 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<StudentSignDO> 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<StudentExamRecordItemDO> recordList = studentExamRecordItemRepository.listByExamRecordId(studentExamRecordDO.getStudentExamRecordId());
|
||||||
|
List<StudentExamRecordItemCO> 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<PersonArchivesDTO> personArchivesDTOList){
|
||||||
|
String archivesDate = DateUtil.getSdfTimes();
|
||||||
|
String tempDir = System.getProperty("java.io.tmpdir");
|
||||||
|
List<File> stringList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
for (PersonArchivesDTO params : personArchivesDTOList){
|
||||||
|
|
||||||
|
|
||||||
|
List<byte[]> 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){
|
public byte[] execteHomepage(PersonArchivesDTO params){
|
||||||
try {
|
try {
|
||||||
Map<String, Object> workItem = PropertyUtils.describe( params);
|
Map<String, Object> 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();//网络图片地址
|
PictureRenderData examSignFacePicture = Pictures.ofUrl(fileUrlConfig.getPrefixUrl() + params.getExamSignFaceUrl(), PictureType.JPEG).size(100, 100).create();//网络图片地址
|
||||||
workItem.put("examSignFacePicture", examSignFacePicture);
|
workItem.put("examSignFacePicture", examSignFacePicture);
|
||||||
// String imageUrl = fileUrlConfig.getPrefixUrl() + params.getExamSignFaceUrl();
|
// String imageUrl = fileUrlConfig.getPrefixUrl() + params.getExamSignFaceUrl();
|
||||||
|
|
@ -313,7 +446,7 @@ public class ArchivesQueryExe {
|
||||||
}
|
}
|
||||||
public byte[] execteExamRecord(PersonArchivesDTO params){
|
public byte[] execteExamRecord(PersonArchivesDTO params){
|
||||||
try {
|
try {
|
||||||
Map<String, Object> workItem = PropertyUtils.describe( params.getStudentExamRecord());
|
Map<String, Object> workItem = BeanUtil.beanToMap(params.getStudentExamRecord());
|
||||||
ArrayList<Object> workList = CollUtil.newArrayList();
|
ArrayList<Object> workList = CollUtil.newArrayList();
|
||||||
AtomicInteger atomicIndex = new AtomicInteger(1);
|
AtomicInteger atomicIndex = new AtomicInteger(1);
|
||||||
params.getStudentExamRecord().getExamRecordItemList().forEach(item -> {
|
params.getStudentExamRecord().getExamRecordItemList().forEach(item -> {
|
||||||
|
|
@ -355,7 +488,9 @@ public class ArchivesQueryExe {
|
||||||
ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem);
|
ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem);
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
// throw new BizException("导出失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,13 @@ public class ArchivesServiceImpl implements ArchivesServiceI {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadPersonArchivesList(ArchivesQry qry) {
|
||||||
|
List<PersonArchivesDTO> personArchivesDTOList = archivesQueryExe.downloadPersonArchivesList(qry);
|
||||||
|
|
||||||
|
archivesQueryExe.execteGeneratePdfList(qry,personArchivesDTOList);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadClassArchives(ArchivesQry qry) {
|
public void downloadClassArchives(ArchivesQry qry) {
|
||||||
ClassArchivesDTO classArchivesDTO = archivesQueryExe.downloadClassArchives(qry);
|
ClassArchivesDTO classArchivesDTO = archivesQueryExe.downloadClassArchives(qry);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import com.zcloud.edu.dto.clientobject.archives.ArchivesReviewCO;
|
||||||
*/
|
*/
|
||||||
public interface ArchivesServiceI {
|
public interface ArchivesServiceI {
|
||||||
void downloadPersonArchives(ArchivesQry qry);
|
void downloadPersonArchives(ArchivesQry qry);
|
||||||
|
void downloadPersonArchivesList(ArchivesQry qry);
|
||||||
void downloadClassArchives(ArchivesQry qry);
|
void downloadClassArchives(ArchivesQry qry);
|
||||||
void downloadReviewRevision(ArchivesQry qry);
|
void downloadReviewRevision(ArchivesQry qry);
|
||||||
void downloadClassCur(ArchivesQry qry);
|
void downloadClassCur(ArchivesQry qry);
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public class ArchivesQry {
|
||||||
private List<Integer> typeList;
|
private List<Integer> typeList;
|
||||||
private String studentId;
|
private String studentId;
|
||||||
private Long stuId;
|
private Long stuId;
|
||||||
|
private List<Long> stuIdList;
|
||||||
private String classId;
|
private String classId;
|
||||||
private List<String> classCurriculumIds;
|
private List<String> classCurriculumIds;
|
||||||
private Long classCurriculumIdLong;
|
private Long classCurriculumIdLong;
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,10 @@ public class StudentCO extends ClientObject {
|
||||||
private Integer numberofexams;
|
private Integer numberofexams;
|
||||||
|
|
||||||
|
|
||||||
|
// 考试状态( 0-待考试 1-已通过 2-不考试 -1 - 待考试)
|
||||||
|
@ApiModelProperty(value = "考试状态( 0-待考试 1-已通过 2-不考试 -1 - 待考试)")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer examState;
|
||||||
// 学员统计数量
|
// 学员统计数量
|
||||||
@ApiModelProperty(value = "学员统计数量")
|
@ApiModelProperty(value = "学员统计数量")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ public class ClassPageQry extends PageQuery {
|
||||||
private Long eqCorpinfoId;
|
private Long eqCorpinfoId;
|
||||||
private String phone;
|
private String phone;
|
||||||
private String signFlag;
|
private String signFlag;
|
||||||
|
private String examState;
|
||||||
private String examination;
|
private String examination;
|
||||||
private String menuPath;
|
private String menuPath;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,13 @@ public class StudentDO extends BaseDO {
|
||||||
@ApiModelProperty(value = "1考试0不考试")
|
@ApiModelProperty(value = "1考试0不考试")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Integer examination;
|
private Integer examination;
|
||||||
|
// 考试状态( 0-待考试 1-已通过 2-不考试 -1 - 待考试)
|
||||||
|
@ApiModelProperty(value = "考试状态( 0-待考试 1-已通过 2-不考试 -1 - 待考试)")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer examState;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//考试次数只有考试时候有用
|
//考试次数只有考试时候有用
|
||||||
@ApiModelProperty(value = "考试次数只有考试时候有用")
|
@ApiModelProperty(value = "考试次数只有考试时候有用")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,14 @@
|
||||||
when c.state = 2 and c.end_time <= now() then 4
|
when c.state = 2 and c.end_time <= now() then 4
|
||||||
|
|
||||||
end class_state,
|
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_start_time,
|
||||||
c.valid_end_time,
|
c.valid_end_time,
|
||||||
c.examination,
|
c.examination,
|
||||||
|
|
@ -217,8 +225,23 @@
|
||||||
and s.sign_flag = #{params.signFlag}
|
and s.sign_flag = #{params.signFlag}
|
||||||
</if>
|
</if>
|
||||||
<if test="params.examination != null and params.examination !='' ">
|
<if test="params.examination != null and params.examination !='' ">
|
||||||
and s.exam_sign_flag = #{params.examination}
|
and c.examination = #{params.examination}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="params.examState != null and params.examState !='' ">
|
||||||
|
<if test = "params.examState == 0"><!-- 待考试:班级结束前,且未通过考试 -->
|
||||||
|
and c.examination = 1 and s.state = 0 and c.end_time > now()
|
||||||
|
</if>
|
||||||
|
<if test = "params.examState == 1"><!-- 已通过-->
|
||||||
|
and c.examination = 1 and s.state = 1
|
||||||
|
</if>
|
||||||
|
<if test = "params.examState == -1"><!-- 未通过:班级已结束,且未通过考试 -->
|
||||||
|
and c.examination = 1 and s.state = 0 and c.end_time < now()
|
||||||
|
</if>
|
||||||
|
<if test = "params.examState == 2"><!-- 不考试 -->
|
||||||
|
and c.examination = 0
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="params.eqState != null ">
|
<if test="params.eqState != null ">
|
||||||
<if test = "params.eqState == 1">
|
<if test = "params.eqState == 1">
|
||||||
and c.state = 1
|
and c.state = 1
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,8 @@
|
||||||
case when s.state = 1 then 1
|
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() then 0
|
||||||
when s.state = 0 and c.start_time <= now() and c.end_time >= now() then 2
|
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,
|
end as state,
|
||||||
s.interested_ids,
|
s.interested_ids,
|
||||||
s.interested_names,
|
s.interested_names,
|
||||||
|
|
@ -241,19 +242,23 @@
|
||||||
and DATE(c.end_time) <![CDATA[>=]]> #{params.endTime}
|
and DATE(c.end_time) <![CDATA[>=]]> #{params.endTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="params.state != null ">
|
<if test="params.state != null ">
|
||||||
<if test="params.state == 0">
|
<if test="params.state == 0"><!-- 待培训 -->
|
||||||
and s.state = 0
|
and s.state = 0
|
||||||
and c.start_time > now()
|
and c.start_time > now()
|
||||||
</if>
|
</if>
|
||||||
<if test="params.state == 1">
|
<if test="params.state == 1"><!-- 培训通过 -->
|
||||||
and s.state = #{params.state}
|
and s.state = #{params.state}
|
||||||
</if>
|
</if>
|
||||||
<if test="params.state == 2">
|
<if test="params.state == 2"> <!-- 培训中 -->
|
||||||
and s.state = 0
|
and s.state = 0
|
||||||
and c.start_time <= now()
|
and c.start_time <= now()
|
||||||
and c.end_time >= now()
|
and c.end_time >= now()
|
||||||
</if>
|
</if>
|
||||||
<if test="params.state == 3">
|
<if test="params.state == 3"><!-- 未培训 -->
|
||||||
|
and s.sign_flag = 0
|
||||||
|
and c.end_time <= now()
|
||||||
|
</if>
|
||||||
|
<if test="params.state == 4"><!-- 培训不通过 -->
|
||||||
and s.state = 0
|
and s.state = 0
|
||||||
and c.end_time <= now()
|
and c.end_time <= now()
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue