|
|
@@ -30,6 +30,7 @@ import com.zhongzheng.modules.alioss.bo.OssRequest;
|
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.alioss.vo.FileBean;
|
|
|
import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
|
|
|
+import com.zhongzheng.modules.base.bo.UserProfileFit;
|
|
|
import com.zhongzheng.modules.base.domain.UserProfile;
|
|
|
import com.zhongzheng.modules.base.service.IUserProfileService;
|
|
|
import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
|
@@ -2183,182 +2184,185 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
+//
|
|
|
+// String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
+// SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
|
|
|
+// String schoolName = ObjectUtils.isNotNull(sysTenant.getSchoolName()) ? sysTenant.getSchoolName() : "广东省祥粤建设职业培训学校";
|
|
|
+// Map<String, List<UserVo>> collect = list.stream().collect(Collectors.groupingBy(UserVo::getJob));
|
|
|
+// String zhiyuan = System.getProperty("user.dir");
|
|
|
+// String destDirPath = zhiyuan + "/zhongzheng-admin/src/main/resources/"
|
|
|
+// + String.format("%s预约考试%s", DateUtils.timestampToDateFormat(bo.getApplySiteExamTime(), "yyyy-MM-dd"), DateUtils.getNowTime());
|
|
|
+// List<UserSubApplyExport> examApplyExports = new ArrayList<>();
|
|
|
+//
|
|
|
+// collect.forEach((k, v) -> {
|
|
|
+// String majorPath = destDirPath + "/" + k;
|
|
|
+// File dirw = new File(majorPath);
|
|
|
+// if (!dirw.exists()) {
|
|
|
+// dirw.mkdirs();
|
|
|
+// }
|
|
|
+// String photoPath = majorPath + "/" + schoolName;
|
|
|
+// File dirw2 = new File(photoPath);
|
|
|
+// if (!dirw2.exists()) {
|
|
|
+// dirw2.mkdirs();
|
|
|
+// }
|
|
|
+// List<UserSubApplyExport> applyExports = new ArrayList<>();
|
|
|
+// //学员头像
|
|
|
+// v.forEach(item -> {
|
|
|
+// User user = iUserService.getByIdNoTenant(item.getUserId());
|
|
|
+// //报考资料
|
|
|
+// UserProfile profile = iUserProfileService.getByOrderGoodsIdNoTenant(item.getOrderGoodsId());
|
|
|
+// if (ObjectUtils.isNull(profile)) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// UserSubApplyExport applyExport = new UserSubApplyExport();
|
|
|
+// applyExport.setUserName(user.getRealname());
|
|
|
+// applyExport.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
|
|
|
+// applyExport.setPhone(EncryptHandler.decrypt(user.getTelphone()));
|
|
|
+//
|
|
|
+// String keyValue = profile.getKeyValue();
|
|
|
+// applyExport.setSex(getUserProfileValue(keyValue, "sex"));
|
|
|
+// String education = getUserProfileValue(keyValue, "education");
|
|
|
+// if(education.equals("小学")||education.equals("中学")||education.equals("高中")||education.equals("中职(含技工学校)")){
|
|
|
+// applyExport.setEducation("中职(含技工学校)");
|
|
|
+// }
|
|
|
+// else if(education.equals("本科")||education.equals("硕士研究生")||education.equals("博士研究生")||education.equals("本科及以上")){
|
|
|
+// applyExport.setEducation("本科及以上");
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// applyExport.setEducation("专科(含高职和技师学院)");
|
|
|
+// }
|
|
|
+// applyExport.setCompanyName(getUserProfileValue(keyValue, "work_unit"));
|
|
|
+// applyExport.setPostName(getUserProfileValue(keyValue, "apply_post"));
|
|
|
+// applyExport.setMajorName(getUserProfileValue(keyValue, "major"));
|
|
|
+// applyExport.setAge(getUserProfileValue(keyValue, "working_years"));
|
|
|
+// applyExport.setGraduateTime(getUserProfileValue(keyValue, "graduation_time"));
|
|
|
+// applyExports.add(applyExport);
|
|
|
+//
|
|
|
+// //个人近照
|
|
|
+// try {
|
|
|
+// String idCardPath = photoPath + "/个人照";
|
|
|
+// File dirw3 = new File(idCardPath);
|
|
|
+// if (!dirw3.exists()) {
|
|
|
+// dirw3.mkdirs();
|
|
|
+// }
|
|
|
+// InputStream inputStream = ossService.getStreamByObject(user.getOneInchPhotos());
|
|
|
+// //写入本地文件
|
|
|
+// String inchPath = idCardPath + "/" + String.format("%s$头像.jpg", EncryptHandler.decrypt(user.getRealname()));
|
|
|
+// FileOutputStream fileOutputStream = new FileOutputStream(inchPath);
|
|
|
+// byte[] buffer = new byte[1024];
|
|
|
+// int len = 0;
|
|
|
+// while ((len = inputStream.read(buffer)) != -1) {
|
|
|
+// fileOutputStream.write(buffer, 0, len);
|
|
|
+// }
|
|
|
+// inputStream.close();
|
|
|
+// fileOutputStream.close();
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// //测试计划
|
|
|
+// examApplyExports.add(applyExport);
|
|
|
+// });
|
|
|
+// //报考资料
|
|
|
+// if (CollectionUtils.isNotEmpty(applyExports)) {
|
|
|
+// String path = majorPath + "/" + String.format("%s报名信息表", k) + ".xlsx";
|
|
|
+// createCompleteExcel(path,applyExports);
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// //测试计划
|
|
|
+// if (CollectionUtils.isNotEmpty(examApplyExports)) {
|
|
|
+// String path = destDirPath + "/测试计划.xlsx";
|
|
|
+// createCompleteExcel(path,examApplyExports);
|
|
|
+// }
|
|
|
+//
|
|
|
+// String filename = FileUtils.encodingZipFilename("学员信息数据");
|
|
|
+// String zipFile = FileUtils.getZipAbsoluteFile(filename);
|
|
|
+// FileUtils.toZip(zipFile, destDirPath, true);
|
|
|
+// try {
|
|
|
+// //删除本地资源
|
|
|
+// Path pathStr = Paths.get(destDirPath);
|
|
|
+// try (Stream<Path> walk = Files.walk(pathStr)) {
|
|
|
+// walk.sorted(Comparator.reverseOrder())
|
|
|
+// .forEach(FileUtils::deleteDirectoryStream);
|
|
|
+// } catch (IOException e) {
|
|
|
+// log.error("删除本地资源失败:" + DateUtils.getNowTime());
|
|
|
+// }
|
|
|
+//
|
|
|
+// map.put("zip", AjaxResult.success(filename));
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
|
|
|
- String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
- SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
|
|
|
- String schoolName = ObjectUtils.isNotNull(sysTenant.getSchoolName()) ? sysTenant.getSchoolName() : "广东省祥粤建设职业培训学校";
|
|
|
- Map<String, List<UserVo>> collect = list.stream().collect(Collectors.groupingBy(UserVo::getJob));
|
|
|
- String zhiyuan = System.getProperty("user.dir");
|
|
|
- String destDirPath = zhiyuan + "/zhongzheng-admin/src/main/resources/"
|
|
|
- + String.format("%s预约考试%s", DateUtils.timestampToDateFormat(bo.getApplySiteExamTime(), "yyyy-MM-dd"), DateUtils.getNowTime());
|
|
|
- List<UserSubApplyExport> examApplyExports = new ArrayList<>();
|
|
|
|
|
|
- collect.forEach((k, v) -> {
|
|
|
- String majorPath = destDirPath + "/" + k;
|
|
|
- File dirw = new File(majorPath);
|
|
|
- if (!dirw.exists()) {
|
|
|
- dirw.mkdirs();
|
|
|
- }
|
|
|
- String photoPath = majorPath + "/" + schoolName;
|
|
|
- File dirw2 = new File(photoPath);
|
|
|
- if (!dirw2.exists()) {
|
|
|
- dirw2.mkdirs();
|
|
|
- }
|
|
|
- List<UserSubApplyExport> applyExports = new ArrayList<>();
|
|
|
- //学员头像
|
|
|
- v.forEach(item -> {
|
|
|
- User user = iUserService.getByIdNoTenant(item.getUserId());
|
|
|
- //报考资料
|
|
|
- UserProfile profile = iUserProfileService.getByOrderGoodsIdNoTenant(item.getOrderGoodsId());
|
|
|
- if (ObjectUtils.isNull(profile)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- UserSubApplyExport applyExport = new UserSubApplyExport();
|
|
|
- applyExport.setUserName(user.getRealname());
|
|
|
- applyExport.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
|
|
|
- applyExport.setPhone(EncryptHandler.decrypt(user.getTelphone()));
|
|
|
|
|
|
- String keyValue = profile.getKeyValue();
|
|
|
- applyExport.setSex(getUserProfileValue(keyValue, "sex"));
|
|
|
- String education = getUserProfileValue(keyValue, "education");
|
|
|
- if(education.equals("小学")||education.equals("中学")||education.equals("高中")||education.equals("中职(含技工学校)")){
|
|
|
- applyExport.setEducation("中职(含技工学校)");
|
|
|
+ List<UserSubscribeStudentExportVo> list1 = new ArrayList<>();
|
|
|
+ List<FileBean> fileBeanList = new ArrayList<>(); //图片列表
|
|
|
+ String filename = FileUtils.encodingZipFilename("学员信息数据");
|
|
|
+ String zipFile = FileUtils.getZipAbsoluteFile(filename);
|
|
|
+ try {
|
|
|
+ ZipOutputStream outStream = new ZipOutputStream(new FileOutputStream(zipFile));
|
|
|
+ for (UserVo vo : list) {
|
|
|
+ UserSubscribeStudentExportVo item = BeanUtil.toBean(vo, UserSubscribeStudentExportVo.class);
|
|
|
+ if (Validator.isNotEmpty(vo.getSex())) {
|
|
|
+ if (vo.getSex() == 1) {
|
|
|
+ item.setSex("男");
|
|
|
+ }
|
|
|
+ if (vo.getSex() == 2) {
|
|
|
+ item.setSex("女");
|
|
|
+ }
|
|
|
}
|
|
|
- else if(education.equals("本科")||education.equals("硕士研究生")||education.equals("博士研究生")||education.equals("本科及以上")){
|
|
|
- applyExport.setEducation("本科及以上");
|
|
|
+ if (ObjectUtils.isNotNull(vo.getApplySiteExamTime())) {
|
|
|
+ String format = String.format("%s %s-%s", DateUtils.timestampToDateFormat(vo.getApplySiteExamTime(), "yyyy-MM-dd"), vo.getApplySiteStartTime(), vo.getApplySiteEndTime());
|
|
|
+ item.setApplyTime(format);
|
|
|
}
|
|
|
- else{
|
|
|
- applyExport.setEducation("专科(含高职和技师学院)");
|
|
|
+ if (ObjectUtils.isNotNull(vo.getSubscribeId())) {
|
|
|
+ UserSubscribe subscribe = getById(vo.getSubscribeId());
|
|
|
+ Goods goods = iGoodsService.getById(subscribe.getGoodsId());
|
|
|
+ if (ObjectUtils.isNotNull(goods.getMajorId())) {
|
|
|
+ Major major = iMajorService.getById(goods.getMajorId());
|
|
|
+ item.setMajorName(major.getCategoryName());
|
|
|
+ }
|
|
|
}
|
|
|
- applyExport.setCompanyName(getUserProfileValue(keyValue, "work_unit"));
|
|
|
- applyExport.setPostName(getUserProfileValue(keyValue, "apply_post"));
|
|
|
- applyExport.setMajorName(getUserProfileValue(keyValue, "major"));
|
|
|
- applyExport.setAge(getUserProfileValue(keyValue, "working_years"));
|
|
|
- applyExport.setGraduateTime(getUserProfileValue(keyValue, "graduation_time"));
|
|
|
- applyExports.add(applyExport);
|
|
|
+ list1.add(item);
|
|
|
|
|
|
- //个人近照
|
|
|
- try {
|
|
|
- String idCardPath = photoPath + "/个人照";
|
|
|
- File dirw3 = new File(idCardPath);
|
|
|
- if (!dirw3.exists()) {
|
|
|
- dirw3.mkdirs();
|
|
|
- }
|
|
|
- InputStream inputStream = ossService.getStreamByObject(user.getOneInchPhotos());
|
|
|
- //写入本地文件
|
|
|
- String inchPath = idCardPath + "/" + String.format("%s$头像.jpg", EncryptHandler.decrypt(user.getRealname()));
|
|
|
- FileOutputStream fileOutputStream = new FileOutputStream(inchPath);
|
|
|
- byte[] buffer = new byte[1024];
|
|
|
- int len = 0;
|
|
|
- while ((len = inputStream.read(buffer)) != -1) {
|
|
|
- fileOutputStream.write(buffer, 0, len);
|
|
|
- }
|
|
|
- inputStream.close();
|
|
|
- fileOutputStream.close();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ if (Validator.isNotEmpty(vo.getIdCardImg1())) {
|
|
|
+ FileBean f1 = new FileBean();
|
|
|
+ String idCardImg1 = vo.getIdCardImg1();
|
|
|
+ f1.setPath(idCardImg1);
|
|
|
+ f1.setFileName("身份证/" + vo.getIdCard() + "_0$身份证.jpg");
|
|
|
+ FileBean f2 = new FileBean();
|
|
|
+ String idCardImg2 = vo.getIdCardImg2();
|
|
|
+ f2.setPath(idCardImg2);
|
|
|
+ f2.setFileName("身份证/" + vo.getIdCard() + "_1$身份证.jpg");
|
|
|
+ fileBeanList.add(f1);
|
|
|
+ fileBeanList.add(f2);
|
|
|
}
|
|
|
|
|
|
- //测试计划
|
|
|
- examApplyExports.add(applyExport);
|
|
|
- });
|
|
|
- //报考资料
|
|
|
- if (CollectionUtils.isNotEmpty(applyExports)) {
|
|
|
- String path = majorPath + "/" + String.format("%s报名信息表", k) + ".xlsx";
|
|
|
- createCompleteExcel(path,applyExports);
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- //测试计划
|
|
|
- if (CollectionUtils.isNotEmpty(examApplyExports)) {
|
|
|
- String path = destDirPath + "/测试计划.xlsx";
|
|
|
- createCompleteExcel(path,examApplyExports);
|
|
|
- }
|
|
|
+ if (Validator.isNotEmpty(vo.getOneInchPhotos())) {
|
|
|
+ FileBean f3 = new FileBean();
|
|
|
+ String oneInchPhotos = vo.getOneInchPhotos();
|
|
|
+ f3.setPath(oneInchPhotos);
|
|
|
+ f3.setFileName("证件照/" + vo.getIdCard() + "$头像.jpg");
|
|
|
+ fileBeanList.add(f3);
|
|
|
+ }
|
|
|
|
|
|
- String filename = FileUtils.encodingZipFilename("学员信息数据");
|
|
|
- String zipFile = FileUtils.getZipAbsoluteFile(filename);
|
|
|
- FileUtils.toZip(zipFile, destDirPath, true);
|
|
|
- try {
|
|
|
- //删除本地资源
|
|
|
- Path pathStr = Paths.get(destDirPath);
|
|
|
- try (Stream<Path> walk = Files.walk(pathStr)) {
|
|
|
- walk.sorted(Comparator.reverseOrder())
|
|
|
- .forEach(FileUtils::deleteDirectoryStream);
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("删除本地资源失败:" + DateUtils.getNowTime());
|
|
|
+ if (Validator.isNotEmpty(vo.getKeyValue())) {
|
|
|
+ Map<String, String> maps = JSONObject.parseObject(vo.getKeyValue(), Map.class);
|
|
|
+ String commitment_seal = JSONObject.parseObject(String.valueOf(maps.get("commitment_seal")), UserProfileFit.class).getValue();
|
|
|
+ FileBean f4 = new FileBean();
|
|
|
+ f4.setPath(commitment_seal);
|
|
|
+ f4.setFileName("承诺书/" + vo.getIdCard() + "$承诺书.jpg");
|
|
|
+ fileBeanList.add(f4);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- map.put("zip", AjaxResult.success(filename));
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ ossService.zipWisdomDownload(fileBeanList, outStream);
|
|
|
+ outStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
}
|
|
|
-// List<UserSubscribeStudentExportVo> list1 = new ArrayList<>();
|
|
|
-// List<FileBean> fileBeanList = new ArrayList<>(); //图片列表
|
|
|
-// String filename = FileUtils.encodingZipFilename("学员信息数据");
|
|
|
-// String zipFile = FileUtils.getZipAbsoluteFile(filename);
|
|
|
-// try {
|
|
|
-// ZipOutputStream outStream = new ZipOutputStream(new FileOutputStream(zipFile));
|
|
|
-// for (UserVo vo : list) {
|
|
|
-// UserSubscribeStudentExportVo item = BeanUtil.toBean(vo, UserSubscribeStudentExportVo.class);
|
|
|
-// if (Validator.isNotEmpty(vo.getSex())) {
|
|
|
-// if (vo.getSex() == 1) {
|
|
|
-// item.setSex("男");
|
|
|
-// }
|
|
|
-// if (vo.getSex() == 2) {
|
|
|
-// item.setSex("女");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (ObjectUtils.isNotNull(vo.getApplySiteExamTime())) {
|
|
|
-// String format = String.format("%s %s-%s", DateUtils.timestampToDateFormat(vo.getApplySiteExamTime(), "yyyy-MM-dd"), vo.getApplySiteStartTime(), vo.getApplySiteEndTime());
|
|
|
-// item.setApplyTime(format);
|
|
|
-// }
|
|
|
-// if (ObjectUtils.isNotNull(vo.getSubscribeId())) {
|
|
|
-// UserSubscribe subscribe = getById(vo.getSubscribeId());
|
|
|
-// Goods goods = iGoodsService.getById(subscribe.getGoodsId());
|
|
|
-// if (ObjectUtils.isNotNull(goods.getMajorId())) {
|
|
|
-// Major major = iMajorService.getById(goods.getMajorId());
|
|
|
-// item.setMajorName(major.getCategoryName());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// list1.add(item);
|
|
|
-//
|
|
|
-// if (Validator.isNotEmpty(vo.getIdCardImg1())) {
|
|
|
-// FileBean f1 = new FileBean();
|
|
|
-// String idCardImg1 = vo.getIdCardImg1();
|
|
|
-// f1.setPath(idCardImg1);
|
|
|
-// f1.setFileName("身份证/" + vo.getIdCard() + "_0$身份证.jpg");
|
|
|
-// FileBean f2 = new FileBean();
|
|
|
-// String idCardImg2 = vo.getIdCardImg2();
|
|
|
-// f2.setPath(idCardImg2);
|
|
|
-// f2.setFileName("身份证/" + vo.getIdCard() + "_1$身份证.jpg");
|
|
|
-// fileBeanList.add(f1);
|
|
|
-// fileBeanList.add(f2);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// if (Validator.isNotEmpty(vo.getOneInchPhotos())) {
|
|
|
-// FileBean f3 = new FileBean();
|
|
|
-// String oneInchPhotos = vo.getOneInchPhotos();
|
|
|
-// f3.setPath(oneInchPhotos);
|
|
|
-// f3.setFileName("证件照/" + vo.getIdCard() + "$头像.jpg");
|
|
|
-// fileBeanList.add(f3);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (Validator.isNotEmpty(vo.getKeyValue())) {
|
|
|
-// Map<String, String> maps = JSONObject.parseObject(vo.getKeyValue(), Map.class);
|
|
|
-// String commitment_seal = JSONObject.parseObject(String.valueOf(maps.get("commitment_seal")), UserProfileFit.class).getValue();
|
|
|
-// FileBean f4 = new FileBean();
|
|
|
-// f4.setPath(commitment_seal);
|
|
|
-// f4.setFileName("承诺书/" + vo.getIdCard() + "$承诺书.jpg");
|
|
|
-// fileBeanList.add(f4);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// ossService.zipWisdomDownload(fileBeanList, outStream);
|
|
|
-// outStream.close();
|
|
|
-// } catch (IOException e) {
|
|
|
-// }
|
|
|
-// map.put("list", list1);
|
|
|
-// map.put("zip", AjaxResult.success(filename));
|
|
|
+ map.put("list", list1);
|
|
|
+ map.put("zip", AjaxResult.success(filename));
|
|
|
return map;
|
|
|
}
|
|
|
|