he2802 3 жил өмнө
parent
commit
f0be717ffe

+ 3 - 2
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -59,10 +59,11 @@ public class CommonController
             response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             FileUtils.setAttachmentResponseHeader(response, realFileName);
             FileUtils.writeBytes(filePath, response.getOutputStream());
-            if (delete)
+           /* if (delete)
             {
                 FileUtils.deleteFile(filePath);
-            }
+            }*/
+            FileUtils.deleteFile(filePath);
         }
         catch (Exception e)
         {

+ 49 - 8
zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserSubscribeController.java

@@ -1,8 +1,10 @@
 package com.zhongzheng.controller.user;
 
-import java.util.List;
-import java.util.Arrays;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
 
+import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.hutool.core.lang.Validator;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -12,11 +14,10 @@ import com.zhongzheng.modules.bank.vo.QuestionImport;
 import com.zhongzheng.modules.base.vo.UserProfileExportGaiVo;
 import com.zhongzheng.modules.exam.vo.ExamApplyVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
+import com.zhongzheng.modules.grade.vo.ClassPeriodStudentExportVo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.service.IUserExamGoodsService;
-import com.zhongzheng.modules.user.vo.UserExamGoodsVo;
-import com.zhongzheng.modules.user.vo.UserSubscribeIdsImport;
-import com.zhongzheng.modules.user.vo.UserSubscribeImport;
+import com.zhongzheng.modules.user.vo.*;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +33,6 @@ import com.zhongzheng.common.annotation.Log;
 import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.enums.BusinessType;
-import com.zhongzheng.modules.user.vo.UserSubscribeVo;
 import com.zhongzheng.modules.user.service.IUserSubscribeService;
 import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.common.core.page.TableDataInfo;
@@ -177,7 +177,48 @@ public class UserSubscribeController extends BaseController {
     @PreAuthorize("@ss.hasPermi('system:profile:export')")
     @Log(title = "导出新增预约模板", businessType = BusinessType.EXPORT)
     @GetMapping("/exportNew")
-    public AjaxResult<UserProfileExportGaiVo> exportNew(UserSubscribeQueryBo bo) {
-        return null;
+    public AjaxResult<Object> exportNew(UserSubscribeExportBo bo) {
+        if(Validator.isEmpty(bo.getApplySiteAddressTrain())){
+            UserSubscribeExport export = new UserSubscribeExport();
+            export.setRemark("导入时,请把示例删除");
+            export.setUserName("李小米");
+            export.setIdCard("44086921356895125365");
+            export.setApplyName(bo.getApplyName());
+            export.setApplySiteAddress(bo.getApplySiteAddress());
+            export.setApplySiteExamTime("2021/10/21");
+            export.setApplySiteTime("9:00-12:00");
+            export.setCode("SP6415428604");
+            export.setGoodsName("一级建造师继续教育(必修课+机电工程)");
+
+            List<UserSubscribeExport> list = new ArrayList<>();
+            list.add(export);
+            ExcelUtil<UserSubscribeExport> util = new ExcelUtil<UserSubscribeExport>(UserSubscribeExport.class);
+            String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            return util.exportEasyExcel(util.exportEasyData(list), "新增预约模板"+timeStr);
+        }else{
+            //有考培地点
+            UserSubscribeTrainExport export = new UserSubscribeTrainExport();
+            export.setRemark("导入时,请把示例删除");
+            export.setUserName("李小米");
+            export.setIdCard("44086921356895125365");
+            export.setApplyName(bo.getApplyName());
+            export.setApplySiteAddress(bo.getApplySiteAddress());
+            export.setApplySiteExamTime("2021/10/21");
+            export.setApplySiteTime("9:00-12:00");
+            export.setCode("SP6415428604");
+            export.setGoodsName("一级建造师继续教育(必修课+机电工程)");
+
+            export.setApplySiteAddressTrain(bo.getApplySiteAddressTrain());
+            export.setApplySiteExamTrainTime("2021/10/21");
+            export.setApplySiteTrainTime("9:00-12:00");
+
+            List<UserSubscribeTrainExport> list = new ArrayList<>();
+            list.add(export);
+            ExcelUtil<UserSubscribeTrainExport> util = new ExcelUtil<UserSubscribeTrainExport>(UserSubscribeTrainExport.class);
+            String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            return util.exportEasyExcel(util.exportEasyData(list), "新增预约模板"+timeStr);
+        }
+
+
     }
 }

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

@@ -1,6 +1,7 @@
 package com.zhongzheng.common.utils.poi;
 
 import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
@@ -311,14 +312,26 @@ public class ExcelUtil<T>
         return exportExcel();
     }
 
+    public List<Map<String, Object>> exportEasyData(List<T> list)
+    {
+        List<Map<String, Object>> sheetsList = new ArrayList<>();
+        ExportParams deptExportParams = new ExportParams();
+        deptExportParams.setSheetName("表1");
+        Map<String, Object> deptExportMap = new HashMap<>();
+        deptExportMap.put("title", deptExportParams);
+        deptExportMap.put("entity", clazz);
+        // sheet中要填充得数据
+        deptExportMap.put("data", list);
+        sheetsList.add(deptExportMap);
+        return sheetsList;
+    }
+
     public AjaxResult exportEasyExcel(List<Map<String, Object>> sheetsList, String sheetName)
     {
         OutputStream out = null;
    //     Workbook workbook = null;
         try
         {
-            System.out.println(sheetsList);
-            System.out.println(23);
             Workbook workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
             String filename = encodingFilename(sheetName);
             out = new FileOutputStream(getAbsoluteFile(filename));

+ 37 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserSubscribeExportBo.java

@@ -0,0 +1,37 @@
+package com.zhongzheng.modules.user.bo;
+
+import com.zhongzheng.common.annotation.Excel;
+import com.zhongzheng.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 用户预约考试分页查询对象 user_subscribe
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel("用户预约考试导出模板对象")
+public class UserSubscribeExportBo extends BaseEntity {
+
+	/** 考试标题 */
+	@Excel(name = "考试标题")
+	@ApiModelProperty("考试标题")
+	private String applyName;
+
+	/** 考试地点 */
+	@Excel(name = "考试地点")
+	@ApiModelProperty("考试地点")
+	private String applySiteAddress;
+
+	/** 考试地点 */
+	@Excel(name = "考培地点")
+	@ApiModelProperty("考培地点")
+	private String applySiteAddressTrain;
+}

+ 16 - 51
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserSubscribeExport.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.user.vo;
 
-import com.zhongzheng.common.annotation.Excel;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
 
@@ -19,73 +20,37 @@ import java.util.Date;
 public class UserSubscribeExport {
 	private static final long serialVersionUID = 1L;
 
+	@Excel(name = "备注说明")
+	private String remark;
+
 	/** $column.columnComment */
-	@Excel(name = "*学员姓名")
+	@Excel(name = "*学员姓名",width = 30)
 	private String userName;
 
-	@Excel(name = "*学员身份证" )
-	private Long idCard;
+	@Excel(name = "*学员身份证" ,width = 30)
+	private String idCard;
 
 	/** 考试标题 */
-	@Excel(name = "*考试标题")
+	@Excel(name = "*考试标题",width = 30)
 	private String applyName;
 
-	@Excel(name = "*考试日期")
-	private Date applySiteExamTime;
-
 	/** 考试地点 */
-	@Excel(name = "*考试地点")
+	@Excel(name = "*考试地点",width = 30)
 	private String applySiteAddress;
 
+	@Excel(name = "*考试日期",width = 30)
+	private String applySiteExamTime;
+
 	/** 考试开始时间段 */
-	@Excel(name = "*考试时间段")
+	@Excel(name = "*考试时间段",width = 30)
 	private String applySiteTime;
 
 	/** 考试开始时间段 */
-	@Excel(name = "*商品编码")
+	@Excel(name = "*商品编码",width = 30)
 	private String code;
 
 	/** 考试开始时间段 */
-	@Excel(name = "*所购商品")
+	@Excel(name = "*商品名称",width = 30)
 	private String goodsName;
 
-
-	/** 1非补考学员 2补考学员 */
-	@Excel(name = "*学员报名类型")
-	private String studentTypeName;
-
-	@Excel(name = "前培标题")
-	private String beforeName;
-
-	@Excel(name = "前培标记")
-	private String beforeStatus;
-
-	@Excel(name = "考培地址")
-	private String applySiteAddressTrain;
-
-	@Excel(name = "考培日期")
-	private Date applySiteExamTrainTime;
-
-	@Excel(name = "考培时间段")
-	private String applySiteTrainTime;
-
-	/** 1正常 2取消 */
-	@Excel(name = "*预约状态")
-	private String subscribeStatus;
-
-	@Excel(name = "*考试登记")
-	private String examStatus;
-
-	@Excel(name = "考试成绩")
-	private BigDecimal performance;
-
-	/** 1通过 0不通过 */
-	@Excel(name = "考试结果")
-	private String result;
-
-	@Excel(name = "证书编号")
-	private String certificateCode;
-
-	@Excel(name = "失败原因")
-	private String cause;
 }

+ 62 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserSubscribeTrainExport.java

@@ -0,0 +1,62 @@
+package com.zhongzheng.modules.user.vo;
+
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+
+/**
+ * 用户预约考试视图对象 mall_package
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+@ApiModel("用户预约考试导出模板对象")
+public class UserSubscribeTrainExport {
+	private static final long serialVersionUID = 1L;
+
+	@Excel(name = "备注说明")
+	private String remark;
+
+	/** $column.columnComment */
+	@Excel(name = "*学员姓名",width = 30)
+	private String userName;
+
+	@Excel(name = "*学员身份证" ,width = 30)
+	private String idCard;
+
+	/** 考试标题 */
+	@Excel(name = "*考试标题",width = 30)
+	private String applyName;
+
+	/** 考试地点 */
+	@Excel(name = "*考试地点",width = 30)
+	private String applySiteAddress;
+
+	@Excel(name = "*考试日期",width = 30)
+	private String applySiteExamTime;
+
+	/** 考试开始时间段 */
+	@Excel(name = "*考试时间段",width = 30)
+	private String applySiteTime;
+
+	/** 考试开始时间段 */
+	@Excel(name = "*商品编码",width = 30)
+	private String code;
+
+	/** 考试开始时间段 */
+	@Excel(name = "*商品名称",width = 30)
+	private String goodsName;
+
+	@Excel(name = "*考培地点",width = 30)
+	private String applySiteAddressTrain;
+
+	@Excel(name = "*考培日期",width = 30)
+	private String applySiteExamTrainTime;
+
+	@Excel(name = "*考培时间段",width = 30)
+	private String applySiteTrainTime;
+
+}