commit
This commit is contained in:
+36
-71
@@ -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,89 +149,53 @@ 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")));
|
||||||
|
Workbook workbook = new XSSFWorkbook();
|
||||||
|
userListMap.forEach((k, v) -> {
|
||||||
|
|
||||||
String fileName = "报名人员";
|
//查询课程
|
||||||
/**
|
TrainSignUpCourse course = courseMap.get(k);
|
||||||
* 创建临时文件夹
|
//查询课程类型
|
||||||
*/
|
TrainSignUpType trainSignUpType = dao.fetch(TrainSignUpType.class, Cnd.where("id", "=", course.getCourseType()));
|
||||||
String tmpPath = "tmp/" + R.UU32();
|
dao.fetchLinks(trainSignUpType, "^trainMobileSignColumnList$");
|
||||||
File tmpDir = new File(tmpPath + "/" + fileName);
|
|
||||||
tmpDir.mkdirs();
|
|
||||||
|
|
||||||
campus.forEach((key, value) -> {
|
ExcelExportService service = new ExcelExportService();
|
||||||
Map<String, List<NutMap>> userListMap = value.stream().collect(Collectors.groupingBy(v -> v.getString("courseId")));
|
ExportParams userExportParams = new ExportParams();
|
||||||
Workbook workbook = new XSSFWorkbook();
|
userExportParams.setTitle(course.getCourseName());
|
||||||
userListMap.forEach((k, v) -> {
|
userExportParams.setSheetName(course.getCourseName());
|
||||||
|
userExportParams.setType(ExcelType.XSSF);
|
||||||
|
|
||||||
//查询课程
|
List<ExcelExportEntity> currentEntities = new ArrayList<>();
|
||||||
TrainSignUpCourse course = courseMap.get(k);
|
currentEntities.addAll(excelCommonExportEntity);
|
||||||
//查询课程类型
|
//将课程类型配置的移动端动态字段添加到excel列中
|
||||||
TrainSignUpType trainSignUpType = dao.fetch(TrainSignUpType.class, Cnd.where("id", "=", course.getCourseType()));
|
List<TrainMobileSignColumn> trainMobileSignColumnList = trainSignUpType.getTrainMobileSignColumnList();
|
||||||
dao.fetchLinks(trainSignUpType, "^trainMobileSignColumnList$");
|
if(trainMobileSignColumnList != null && trainMobileSignColumnList.size() > 0) {
|
||||||
|
trainMobileSignColumnList.forEach(item -> {
|
||||||
|
currentEntities.add(new ExcelExportEntity(item.getColumnName(), item.getColumnCode(), 20));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ExcelExportService service = new ExcelExportService();
|
for (NutMap userSignData : v) {
|
||||||
ExportParams userExportParams = new ExportParams();
|
String mobileColumnsValueStr = userSignData.getString("mobileColumnsValue");
|
||||||
userExportParams.setTitle(course.getCourseName());
|
if(StrUtil.isNotBlank(mobileColumnsValueStr)){
|
||||||
userExportParams.setSheetName(course.getCourseName());
|
List<NutMap> mobileColumnsValue = Json.fromJsonAsList(NutMap.class,mobileColumnsValueStr);
|
||||||
userExportParams.setType(ExcelType.XSSF);
|
for (NutMap cv : mobileColumnsValue) {
|
||||||
|
if(cv.getString("columnFormType") != null && !cv.getString("columnFormType").equals("FILE")){
|
||||||
List<ExcelExportEntity> currentEntities = new ArrayList<>();
|
userSignData.addv(cv.getString("columnCode"), cv.getString("columnValue"));
|
||||||
currentEntities.addAll(excelCommonExportEntity);
|
|
||||||
//将课程类型配置的移动端动态字段添加到excel列中
|
|
||||||
List<TrainMobileSignColumn> trainMobileSignColumnList = trainSignUpType.getTrainMobileSignColumnList();
|
|
||||||
if(trainMobileSignColumnList != null && trainMobileSignColumnList.size() > 0) {
|
|
||||||
trainMobileSignColumnList.forEach(item -> {
|
|
||||||
currentEntities.add(new ExcelExportEntity(item.getColumnName(), item.getColumnCode(), 20));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (NutMap userSignData : v) {
|
|
||||||
String mobileColumnsValueStr = userSignData.getString("mobileColumnsValue");
|
|
||||||
if(StrUtil.isNotBlank(mobileColumnsValueStr)){
|
|
||||||
List<NutMap> mobileColumnsValue = Json.fromJsonAsList(NutMap.class,mobileColumnsValueStr);
|
|
||||||
for (NutMap cv : mobileColumnsValue) {
|
|
||||||
if(cv.getString("columnFormType") != null && !cv.getString("columnFormType").equals("FILE")){
|
|
||||||
userSignData.addv(cv.getString("columnCode"), cv.getString("columnValue"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
service.createSheetForMap(workbook, userExportParams, currentEntities, v);
|
|
||||||
});
|
|
||||||
FileOutputStream outputStream = null;
|
|
||||||
try {
|
|
||||||
outputStream = new FileOutputStream(tmpDir.getPath() + "/" + key + "报名人员.xlsx");
|
|
||||||
workbook.write(outputStream);
|
|
||||||
outputStream.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service.createSheetForMap(workbook, userExportParams, currentEntities, v);
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
String aimsDir = "zipTmp/" + R.UU32();
|
response.setHeader("Content-Disposition", "attachment;filename=" + new String((activity.getActivityName() + "报名人员名单.xlsx").getBytes("utf-8"), "ISO8859-1"));
|
||||||
String aimsName = fileName + ".zip";
|
workbook.write(response.getOutputStream());
|
||||||
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