Browse Source

add 改订单的下载方式

周箭河 4 years ago
parent
commit
826e6cb90d

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ManagerDownload.java

@@ -31,7 +31,7 @@ public class ManagerDownload {
      * 状态
      */
     @ApiModelProperty(value = "状态")
-    private Integer status;
+    private Integer status=0;
 
     /**
      * 创建时间

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ExportService.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.entity.ManagerDownload;
+
 import java.util.Map;
 
 
@@ -10,5 +12,5 @@ public interface ExportService {
      * @param params
      * @throws Exception
      */
-    void orderList(Map<String, Object> params) throws Exception;
+    void orderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception;
 }

+ 15 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -52,10 +52,12 @@ public class ExportServiceImpl implements ExportService {
     private MusicGroupDao musicGroupDao;
     @Autowired
     private StoragePluginContext storagePluginContext;
+    @Autowired
+    private ManagerDownloadDao managerDownloadDao;
 
     @Override
     @Async
-    public void orderList(Map<String, Object> params) throws Exception {
+    public void orderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception {
         List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
         long i = 1;
         for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
@@ -83,7 +85,7 @@ public class ExportServiceImpl implements ExportService {
             }
             row.setTransferFee(transferFee);
 
-            String goodsName = "";
+            String goodsName = "" ;
             if (row.getOrderDetailList() != null) {
                 for (StudentPaymentOrderDetail orderDetail : row.getOrderDetailList()) {
                     switch (orderDetail.getType()) {
@@ -212,22 +214,22 @@ public class ExportServiceImpl implements ExportService {
             if (row.getMusicGroupId() != null && row.getMusicGroupId().equals("null")) {
                 row.setMusicGroupId("");
             }
-            String paymentChannel = "";
+            String paymentChannel = "" ;
             if (row.getPaymentChannel() == null) {
             } else if (row.getPaymentChannel().equals("YQPAY")) {
-                paymentChannel = "双乾";
+                paymentChannel = "双乾" ;
             } else if (row.getPaymentChannel().equals("ADAPAY")) {
-                paymentChannel = "汇付";
+                paymentChannel = "汇付" ;
             } else if (row.getPaymentChannel().equals("BALANCE")) {
-                paymentChannel = "余额";
+                paymentChannel = "余额" ;
             }
             row.setPaymentChannel(paymentChannel);
             row.setId(i);
             i++;
         }
 
-        String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath() + "/";
-        File file = new File(basePath + "orderList-" + DateUtil.getDate(new Date()) + ".xls");
+        String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath();
+        File file = new File(basePath + "/" + managerDownload.getName());
         FileOutputStream fileOutputStream = new FileOutputStream(file);
 
         HSSFWorkbook workbook = null;
@@ -241,10 +243,12 @@ public class ExportServiceImpl implements ExportService {
             fileOutputStream.getFD().sync();
             fileOutputStream.close();
 
-            String folder = UploadUtil.getFileFloder();
-            String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, "download/" + folder, file);
+            String folder = "download/" + UploadUtil.getFileFloder();
+            String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, folder, file);
             //把记录插入下载表
-
+            managerDownload.setFileUrl(url);
+            managerDownload.setStatus(1);
+            managerDownloadDao.update(managerDownload);
         } catch (Exception e) {
             e.printStackTrace();
         } finally {

+ 17 - 2
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.service.IdGeneratorService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -130,6 +131,10 @@ public class ExportController extends BaseController {
     private ClassGroupService classGroupService;
     @Autowired
     private ExportService exportService;
+    @Autowired
+    private ManagerDownloadDao managerDownloadDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
 
     @ApiOperation(value = "班级列表导出")
     @PostMapping("export/classGroup")
@@ -1096,7 +1101,7 @@ public class ExportController extends BaseController {
         queryInfo.setPage(1);
         queryInfo.setRows(50000);
         queryInfo.setIsExport(true);
-        Map<String, Object> params = new HashMap<String, Object>();
+        Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
         int count = studentPaymentOrderDao.queryCount(params);
         if (count <= 0) {
@@ -1106,7 +1111,17 @@ public class ExportController extends BaseController {
         if (count > 50000) {
             return failed("数据集太大,不能导出.最大数据集不能超过50000");
         }
-        exportService.orderList(params);
+        Date nowDate = new Date();
+        String no = idGeneratorService.generatorId("download") + "" ;
+        String fileName = "orderList-"+no+"-" + DateUtil.getDate(nowDate) + ".xls" ;
+        ManagerDownload managerDownload = new ManagerDownload();
+        managerDownload.setUserId(sysUser.getId());
+        managerDownload.setName(fileName);
+        managerDownload.setFileUrl("");
+        managerDownload.setCreateTime(nowDate);
+        managerDownload.setUpdateTime(nowDate);
+        managerDownloadDao.insert(managerDownload);
+        exportService.orderList(params,managerDownload);
         return succeed("导出成功,请到下载列表查看");
     }