commit
This commit is contained in:
+6
-41
@@ -1,5 +1,6 @@
|
|||||||
package io.v.nutz.trainSignUp.controller.statistics;
|
package io.v.nutz.trainSignUp.controller.statistics;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||||
@@ -148,19 +149,8 @@ public class TrainSignUpActivityStatisticsController {
|
|||||||
List<TrainSignUpCourse> courseList = dao.query(TrainSignUpCourse.class, Cnd.where("activityId", "=", activityId));
|
List<TrainSignUpCourse> courseList = dao.query(TrainSignUpCourse.class, Cnd.where("activityId", "=", activityId));
|
||||||
Map<String, TrainSignUpCourse> courseMap = courseList.stream().collect(Collectors.toMap(o -> o.getId(), o -> o));
|
Map<String, TrainSignUpCourse> courseMap = courseList.stream().collect(Collectors.toMap(o -> o.getId(), o -> o));
|
||||||
|
|
||||||
//按校区分组
|
//按课程分组
|
||||||
Map<String, List<NutMap>> campus = userList.stream().collect(Collectors.groupingBy(o -> o.getString("campus")));
|
Map<String, List<NutMap>> userListMap = userList.stream().collect(Collectors.groupingBy(v -> v.getString("courseId")));
|
||||||
|
|
||||||
String fileName = "报名人员";
|
|
||||||
/**
|
|
||||||
* 创建临时文件夹
|
|
||||||
*/
|
|
||||||
String tmpPath = "tmp/" + R.UU32();
|
|
||||||
File tmpDir = new File(tmpPath + "/" + fileName);
|
|
||||||
tmpDir.mkdirs();
|
|
||||||
|
|
||||||
campus.forEach((key, value) -> {
|
|
||||||
Map<String, List<NutMap>> userListMap = value.stream().collect(Collectors.groupingBy(v -> v.getString("courseId")));
|
|
||||||
Workbook workbook = new XSSFWorkbook();
|
Workbook workbook = new XSSFWorkbook();
|
||||||
userListMap.forEach((k, v) -> {
|
userListMap.forEach((k, v) -> {
|
||||||
|
|
||||||
@@ -200,37 +190,12 @@ public class TrainSignUpActivityStatisticsController {
|
|||||||
|
|
||||||
service.createSheetForMap(workbook, userExportParams, currentEntities, v);
|
service.createSheetForMap(workbook, userExportParams, currentEntities, v);
|
||||||
});
|
});
|
||||||
FileOutputStream outputStream = null;
|
|
||||||
try {
|
try {
|
||||||
outputStream = new FileOutputStream(tmpDir.getPath() + "/" + key + "报名人员.xlsx");
|
response.setContentType("application/octet-stream");
|
||||||
workbook.write(outputStream);
|
response.setHeader("Content-Disposition", "attachment;filename=" + new String((activity.getActivityName() + "报名人员名单.xlsx").getBytes("utf-8"), "ISO8859-1"));
|
||||||
outputStream.close();
|
workbook.write(response.getOutputStream());
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
|
|
||||||
String aimsDir = "zipTmp/" + R.UU32();
|
|
||||||
String aimsName = fileName + ".zip";
|
|
||||||
String aimsPath = aimsDir + "/" + aimsName;
|
|
||||||
FileUtil.compressToZip(tmpDir.getPath(), aimsDir, aimsName);
|
|
||||||
|
|
||||||
response.setHeader("content-disposition", "attachment;filename="
|
|
||||||
+ URLEncoder.encode(aimsName, "UTF-8"));
|
|
||||||
|
|
||||||
File aimsFile = new File(aimsPath);
|
|
||||||
FileInputStream inputStream = new FileInputStream(aimsFile);
|
|
||||||
IOUtils.copy(inputStream, response.getOutputStream());
|
|
||||||
inputStream.close();
|
|
||||||
aimsFile.delete();
|
|
||||||
|
|
||||||
FileUtil.deleteDir(new File(tmpPath));
|
|
||||||
FileUtil.deleteDir(new File(aimsDir));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ layout("/mobile/platform.html"){
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div v-if="o.campus">
|
||||||
<span class="train-title">校  区:</span>
|
<span class="train-title">校  区:</span>
|
||||||
<span>{{o.campus}}</span>
|
<span>{{o.campus}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ layout("/layouts/platform.html"){
|
|||||||
const valid = await this.$refs['form'].validate()
|
const valid = await this.$refs['form'].validate()
|
||||||
if (valid) {
|
if (valid) {
|
||||||
const courseValid = this.formData.courseList.some((v, i) => {
|
const courseValid = this.formData.courseList.some((v, i) => {
|
||||||
const basicValid = v.courseName && v.coursePeopleNumber && v.campus
|
const basicValid = v.courseName && v.coursePeopleNumber
|
||||||
&& v.courseLocation && v.courseInstructor && v.courseType
|
&& v.courseLocation && v.courseInstructor && v.courseType
|
||||||
const timeValid = v.courseTimeList.length > 0 && v.courseTimeList.every(x => {
|
const timeValid = v.courseTimeList.length > 0 && v.courseTimeList.every(x => {
|
||||||
return x.courseStartTime && x.courseEndTime && (x.courseStartTime < x.courseEndTime)
|
return x.courseStartTime && x.courseEndTime && (x.courseStartTime < x.courseEndTime)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<vi-title2 :title="trainType + '信息'">
|
<vi-title2 :title="trainType + '信息(如不需要校区信息,填写时忽略即可)'">
|
||||||
<template #func>
|
<template #func>
|
||||||
<el-button @click="addCourse" size="small" type="primary">
|
<el-button @click="addCourse" size="small" type="primary">
|
||||||
添加{{ trainType }}
|
添加{{ trainType }}
|
||||||
|
|||||||
@@ -137,9 +137,17 @@ layout("/layouts/platform.html"){
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
exportSignPerson() {
|
exportSignPerson() {
|
||||||
|
if(!this.pageForm.activityId) {
|
||||||
|
this.$message.warning('请先选择活动')
|
||||||
|
return
|
||||||
|
}
|
||||||
this.exportPro(loc() + '/exportSignPerson', {activityId: this.pageForm.activityId})
|
this.exportPro(loc() + '/exportSignPerson', {activityId: this.pageForm.activityId})
|
||||||
},
|
},
|
||||||
exportGiftPerson() {
|
exportGiftPerson() {
|
||||||
|
if(!this.pageForm.activityId) {
|
||||||
|
this.$message.warning('请先选择活动')
|
||||||
|
return
|
||||||
|
}
|
||||||
this.exportPro(loc() + '/exportGiftPerson', {activityId: this.pageForm.activityId})
|
this.exportPro(loc() + '/exportGiftPerson', {activityId: this.pageForm.activityId})
|
||||||
},
|
},
|
||||||
exportPro(url, param) {
|
exportPro(url, param) {
|
||||||
|
|||||||
Reference in New Issue
Block a user