Procházet zdrojové kódy

乐队指导训练营新增删除标识

zouxuan před 5 měsíci
rodič
revize
f56bae220a

+ 35 - 5
mec-application/src/main/java/com/ym/mec/web/controller/TempDirectorTrainingCampDetailController.java

@@ -16,9 +16,12 @@ import com.ym.mec.biz.service.TempDirectorTrainingCampService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.util.date.DateUtil;
+import com.ym.mec.util.excel.POIUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.joda.time.DateTime;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -26,8 +29,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.text.MessageFormat;
+import java.util.Date;
 import java.util.List;
 
 @Api(tags = "乐队指导训练营活动")
@@ -58,9 +65,9 @@ public class TempDirectorTrainingCampDetailController extends BaseController {
 
     @ApiOperation(value = "导出")
     @PostMapping("/export")
-    public HttpResponseResult<TempDirectorTrainingCampDetailWrapper.DownloadInfo> export(@RequestBody TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetailQuery queryInfo){
+    public void export(HttpServletResponse response, @RequestBody TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetailQuery queryInfo) throws IOException {
         if (queryInfo.getTempDirectorTrainingCampId()==null) {
-            return failed("训练营编号不能为空");
+            throw new BizException("训练营编号不能为空");
         }
         TempDirectorTrainingCamp trainingCamp = tempDirectorTrainingCampService.lambdaQuery()
                 .eq(TempDirectorTrainingCamp::getId, queryInfo.getTempDirectorTrainingCampId())
@@ -72,10 +79,33 @@ public class TempDirectorTrainingCampDetailController extends BaseController {
         IPage<TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetail> tempDirectorTrainingCampIPage = tempDirectorTrainingCampDetailService.queryPage(new Page<>(1,-1), queryInfo);
         List<TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetail> records = tempDirectorTrainingCampIPage.getRecords();
         if (records.size()==0) {
-            return failed("没有可导出数据");
+            throw new BizException("没有可导出数据");
+        }
+        OutputStream outputStream = response.getOutputStream();
+        try {
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"姓名", "联系电话", "身份证号", "所在城市", "缴费状态", "缴费金额", "缴费时间", "目前从事职业"
+                    , "第一主专业", "之前乐队指导学习基础", "目标效果", "需求或建议"}, new String[]{
+                    "username", "mobile", "cardNo", "cityInfo", "paymentStatusName", "paymentAmount", "paymentDateStr",
+                    "job", "subjectName", "study"
+                    , "studyTarget", "suggestion"}, records);
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attac:wq" +
+                    "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");
+
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+            outputStream.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
         }
-        TempDirectorTrainingCampDetailWrapper.DownloadInfo downloadInfo = generateExportExcelFile(records, TempDirectorTrainingCampDetailWrapper.TempDirectorTrainingCampDetail.class, trainingCamp.getName()+"导出", trainingCamp.getName()+"导出");
-        return succeed(downloadInfo);
     }
 
     @ApiOperation(value = "统计")

+ 2 - 2
mec-biz/pom.xml

@@ -35,11 +35,11 @@
 			<artifactId>mec-thirdparty</artifactId>
 		</dependency>
 
-        <dependency>
+<!--        <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>easyexcel</artifactId>
             <version>2.2.6</version>
-        </dependency>
+        </dependency>-->
 		<dependency>
 			<groupId>com.ym</groupId>
 			<artifactId>snakerflowy</artifactId>

+ 2 - 25
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/TempDirectorTrainingCampDetailWrapper.java

@@ -169,101 +169,78 @@ public class TempDirectorTrainingCampDetailWrapper {
 
 
         @ApiModelProperty(value = "主键")
-        @ExcelIgnore
         private Integer id;
 
         @ApiModelProperty(value = "训练营编号")
-        @ExcelIgnore
         private Integer tempDirectorTrainingCampId;
 
         @ApiModelProperty(value = "姓名")
-        @ExcelProperty(value = "姓名",order = 1)
         private String username;
 
         @ApiModelProperty(value = "手机号")
-        @ExcelProperty(value = "联系电话",order = 2)
         private String mobile;
 
         @ApiModelProperty(value = "身份证号")
-        @ExcelProperty(value = "身份证号",order = 3)
         private String cardNo;
 
         @ApiModelProperty(value = "省份")
-        @ExcelIgnore
         private String province;
 
         @ApiModelProperty(value = "省份")
-        @ExcelIgnore
         private String provinceCode;
 
         @ApiModelProperty(value = "城市")
-        @ExcelIgnore
         private String cityCode;
 
         @ApiModelProperty(value = "城市")
-        @ExcelIgnore
         private String city;
 
         @ApiModelProperty(value = "区县")
-        @ExcelIgnore
         private String regionCode;
 
         @ApiModelProperty(value = "区县")
-        @ExcelIgnore
         private String region;
 
-        @ExcelProperty(value = "所在城市",order = 4)
+        @ApiModelProperty(value = "所在城市")
         private String cityInfo;
 
         @ApiModelProperty(value = "已缴费 PAID,未缴费 NO,已退费 REFUND")
-        @ExcelIgnore
         private String paymentStatus = "NO";
 
-        @ExcelProperty(value = "缴费状态",order = 10)
+        @ApiModelProperty(value = "缴费状态")
         private String paymentStatusName;
 
         @ApiModelProperty(value = "缴费金额")
-        @ExcelProperty(value = "缴费金额",order = 11)
         private String paymentAmount;
 
         @ApiModelProperty(value = "是否早鸟报名")
-        @ExcelIgnore
         private Boolean birdFlag = false;
 
         @ApiModelProperty(value = "缴费时间")
-        @ExcelIgnore
         private Date paymentDate;
 
         @ApiModelProperty(value = "缴费时间")
-        @ExcelProperty(value = "缴费时间",order = 12)
         private String paymentDateStr;
 
         @ApiModelProperty(value = "职业")
-        @ExcelProperty(value = "目前从事职业",order = 5)
         private String job;
 
         @ApiModelProperty(value = "声部")
-        @ExcelProperty(value = "第一主专业",order = 6)
         private String subjectName;
 
         @ApiModelProperty(value = "之前乐队指导学习基础")
-        @ExcelProperty(value = "之前乐队指导学习基础",order = 7)
         private String study;
 
         @ApiModelProperty(value = "目标效果")
-        @ExcelProperty(value = "目标效果",order = 8)
         private String studyTarget;
 
         @ApiModelProperty(value = "需求或建议")
-        @ExcelProperty(value = "需求或建议",order = 9)
         private String suggestion;
 
         @ApiModelProperty(value = "创建时间")
-        @ExcelIgnore
         private Date createTime;
 
         @ApiModelProperty(value = "修改时间")
-        @ExcelIgnore
         private Date updateTime;
     }
 

+ 1 - 1
mec-mall/mall-admin/pom.xml

@@ -47,7 +47,7 @@
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>easyexcel</artifactId>
-            <version>2.2.6</version>
+            <version>3.2.1</version>
         </dependency>
         <dependency>
             <groupId>com.ym</groupId>