yangdamao пре 1 месец
родитељ
комит
6e0f4a496c

+ 3 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseController.java

@@ -1,5 +1,8 @@
 package com.zhongzheng.controller.course;
 
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.*;
 import java.util.stream.Collectors;
 

+ 0 - 2
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/poi/ExcelUtil.java

@@ -18,9 +18,7 @@ import com.zhongzheng.common.utils.DictUtils;
 import com.zhongzheng.common.utils.file.FileTypeUtils;
 import com.zhongzheng.common.utils.file.ImageUtils;
 import com.zhongzheng.common.utils.reflect.ReflectUtils;
-import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddressList;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFClientAnchor;

+ 101 - 99
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserSubscribeServiceImpl.java

@@ -24,14 +24,12 @@ import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.common.utils.file.FileUtils;
-import com.zhongzheng.common.utils.file.ImageUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
 import com.zhongzheng.common.utils.poi.ExcelUtil;
 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;
@@ -59,13 +57,11 @@ import com.zhongzheng.modules.exam.vo.ExamApplyVo;
 import com.zhongzheng.modules.exam.vo.ExamSessionVo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
-import com.zhongzheng.modules.goods.domain.QuestionMerchant;
 import com.zhongzheng.modules.goods.service.IGoodsQuestionRelService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.domain.ClassGradeUser;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
-import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
 import com.zhongzheng.modules.inform.bo.InformUserAddBo;
 import com.zhongzheng.modules.inform.service.IInformRemindService;
@@ -83,7 +79,6 @@ import com.zhongzheng.modules.system.service.ISysConfigService;
 import com.zhongzheng.modules.system.service.ISysTaskService;
 import com.zhongzheng.modules.system.service.ISysTenantService;
 import com.zhongzheng.modules.system.vo.SysTaskVo;
-import com.zhongzheng.modules.tencentcloud.service.IFaceOcrService;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.User;
 import com.zhongzheng.modules.user.domain.UserExamGoods;
@@ -96,17 +91,20 @@ import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
 import com.zhongzheng.modules.user.service.IUserSubscribeService;
 import com.zhongzheng.modules.user.vo.*;
 import com.zhongzheng.modules.wx.service.IWxLoginService;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.multipart.MultipartFile;
 import org.thymeleaf.util.StringUtils;
 
 import javax.imageio.ImageIO;
 import javax.xml.bind.DatatypeConverter;
 import java.awt.*;
+import java.awt.Color;
+import java.awt.Font;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URL;
@@ -2193,7 +2191,7 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         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<UserExamApplyExport> examApplyExports = new ArrayList<>();
+        List<UserSubApplyExport> examApplyExports = new ArrayList<>();
 
         collect.forEach((k, v) -> {
             String majorPath = destDirPath + "/" + k;
@@ -2261,108 +2259,20 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
                     e.printStackTrace();
                 }
 
-                //身份证
-                try {
-                    String idCardPath = photoPath + "/身份证";
-                    File dirw3 = new File(idCardPath);
-                    if (!dirw3.exists()) {
-                        dirw3.mkdirs();
-                    }
-
-                    InputStream inputStream = ossService.getStreamByObject(user.getIdCardImg1());
-                    //写入本地文件
-                    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();
-                }
-
-                try {
-                    String idCardPath = photoPath + "/身份证";
-                    File dirw3 = new File(idCardPath);
-                    if (!dirw3.exists()) {
-                        dirw3.mkdirs();
-                    }
-
-                    InputStream inputStream = ossService.getStreamByObject(user.getIdCardImg2());
-                    //写入本地文件
-                    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();
-                }
-
-                try {
-                    String idCardPath = photoPath + "/承诺书";
-                    File dirw3 = new File(idCardPath);
-                    if (!dirw3.exists()) {
-                        dirw3.mkdirs();
-                    }
-                    String commitmentSeal = getUserProfileValue(keyValue, "commitment_seal");
-                    InputStream inputStream = ossService.getStreamByObject(commitmentSeal);
-                    //写入本地文件
-                    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();
-                }
-
                 //测试计划
-                UserExamApplyExport export = new UserExamApplyExport();
-                export.setUserName(user.getRealname());
-                export.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
-                export.setPhone(EncryptHandler.decrypt(user.getTelphone()));
-                export.setPostName(getUserProfileValue(keyValue, "apply_post"));
-                export.setApplyName(
-                        String.format("%s测试%s-%s", DateUtils.timestampToDateFormat(item.getApplySiteExamTime(), "yyyy.MM.dd")
-                                , applyTimeTransition(item.getApplySiteStartTime()), applyTimeTransition(item.getApplySiteEndTime())));
-                examApplyExports.add(export);
+                examApplyExports.add(applyExport);
             });
-            //打包zip
-            String zipPath = majorPath + "/" + String.format("%s.zip",schoolName);
-            FileUtils.toZip(zipPath, photoPath, true);
-            //删除本地资源
-            Path pathStr = Paths.get(photoPath);
-            try (Stream<Path> walk = Files.walk(pathStr)) {
-                walk.sorted(Comparator.reverseOrder())
-                        .forEach(FileUtils::deleteDirectoryStream);
-            } catch (IOException e) {
-                log.error("删除本地资源失败:" + DateUtils.getNowTime());
-            }
             //报考资料
             if (CollectionUtils.isNotEmpty(applyExports)) {
-                ExcelUtil<UserSubApplyExport> util = new ExcelUtil<UserSubApplyExport>(UserSubApplyExport.class);
                 String path = majorPath + "/" + String.format("%s报名信息表", k) + ".xlsx";
-                util.exportEasyExcelStudy(util.exportEasyData(applyExports), path);
+                createCompleteExcel(path,applyExports);
             }
         });
 
         //测试计划
         if (CollectionUtils.isNotEmpty(examApplyExports)) {
-            ExcelUtil<UserExamApplyExport> util = new ExcelUtil<UserExamApplyExport>(UserExamApplyExport.class);
             String path = destDirPath + "/测试计划.xlsx";
-            util.exportEasyExcelStudy(util.exportEasyData(examApplyExports), path);
+            createCompleteExcel(path,examApplyExports);
         }
 
         //打包zip 上传oss
@@ -2473,6 +2383,98 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         return map;
     }
 
+
+    private static void createCompleteExcel(String path,  List<UserSubApplyExport> applyExports) {
+        Workbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("Sheet1");
+
+        // 创建样式
+        CellStyle noteStyle = createNoteStyle(workbook);
+        CellStyle headerStyle = createHeaderStyle(workbook);
+
+        // 第1行:注意事项
+        Row noteRow = sheet.createRow(0);
+        Cell noteCell = noteRow.createCell(0);
+        noteCell.setCellValue("模板内容皆为必填,身份证号不可以是这种‘1.10101E+17’格式,性别、学历信息请从列表中选择,‘工作单位’填写工作单位的全称,请按要求填写");
+        noteCell.setCellStyle(noteStyle);
+        // 设置水平对齐 - 靠左
+        noteStyle.setAlignment(HorizontalAlignment.LEFT);
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 7));
+
+        // 第2行:表头
+        Row headerRow = sheet.createRow(1);
+        String[] headers = {"姓名", "性别", "身份证号", "手机号", "学历", "工作单位", "岗位"};
+        for (int i = 0; i < headers.length; i++) {
+            Cell cell = headerRow.createCell(i);
+            cell.setCellValue(headers[i]);
+            cell.setCellStyle(headerStyle);
+            sheet.setColumnWidth(i, 15 * 450);
+        }
+
+        // 添加数据
+        int rowNum = 2;
+        for (UserSubApplyExport emp : applyExports) {
+            Row row = sheet.createRow(rowNum++);
+
+            Cell cell0 = row.createCell(0);
+            cell0.setCellValue(emp.getUserName());
+
+            Cell cell1 = row.createCell(1);
+            cell1.setCellValue(emp.getSex());
+
+            Cell cell2 = row.createCell(2);
+            cell2.setCellValue(emp.getIdCard());
+
+            Cell cell3 = row.createCell(3);
+            cell3.setCellValue(emp.getPhone());
+
+            Cell cell4 = row.createCell(4);
+            cell4.setCellValue(emp.getEducation());
+
+            Cell cell5 = row.createCell(5);
+            cell5.setCellValue(emp.getCompanyName());
+
+            Cell cell6 = row.createCell(6);
+            cell6.setCellValue(emp.getPostName());
+
+        }
+
+        // 设置行高
+        noteRow.setHeightInPoints(30);
+        headerRow.setHeightInPoints(20);
+
+        // 写入文件
+        try (FileOutputStream fos = new FileOutputStream(path)) {
+            workbook.write(fos);
+            workbook.close();
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private static CellStyle createNoteStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        style.setFillForegroundColor(IndexedColors.SEA_GREEN.getIndex());
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+
+        return style;
+    }
+
+    private static CellStyle createHeaderStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setAlignment(HorizontalAlignment.CENTER);
+
+        return style;
+    }
+
     @Override
     public Map<String, Object> listSignExport(UserSubscribeQueryBo bo) {
         Map<String, Object> map = new HashMap<>();

+ 31 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserSubExportVo.java

@@ -0,0 +1,31 @@
+package com.zhongzheng.modules.user.vo;
+
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 用户预约考试视图对象 mall_package
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+public class UserSubExportVo implements Serializable {
+
+	private String userName;
+
+	private String sex;
+
+	private String idCard;
+
+	private String phone;
+
+	private String education;
+
+	private String companyName;
+
+	private String postName;
+}