|
@@ -6,9 +6,15 @@ import com.ym.mec.biz.dal.entity.*;
|
|
|
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.thirdparty.storage.StoragePluginContext;
|
|
|
+import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
|
|
|
+import com.ym.mec.util.upload.UploadUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
@@ -29,6 +35,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.system.ApplicationHome;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -129,6 +136,8 @@ public class ExportController extends BaseController {
|
|
|
private GoodsService goodsService;
|
|
|
@Autowired
|
|
|
private ClassGroupService classGroupService;
|
|
|
+ @Autowired
|
|
|
+ private StoragePluginContext storagePluginContext;
|
|
|
|
|
|
@ApiOperation(value = "班级列表导出")
|
|
|
@PostMapping("export/classGroup")
|
|
@@ -1076,7 +1085,7 @@ public class ExportController extends BaseController {
|
|
|
@ApiOperation(value = "订单列表导出")
|
|
|
@RequestMapping("export/orderList")
|
|
|
@PreAuthorize("@pcs.hasPermissions('export/orderList')")
|
|
|
- public void orderList(StudentPaymentOrderQueryInfo queryInfo, HttpServletResponse response) throws IOException {
|
|
|
+ public HttpResponseResult orderList(StudentPaymentOrderQueryInfo queryInfo) throws IOException {
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
Employee employee = employeeDao.get(sysUser.getId());
|
|
|
if (StringUtils.isEmpty(queryInfo.getRoutingOrganId()) && "3".equals(queryInfo.getOrderType())) {
|
|
@@ -1101,7 +1110,6 @@ public class ExportController extends BaseController {
|
|
|
if (studentPaymentOrderExportDtos.size() > 50000) {
|
|
|
throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
|
|
|
}
|
|
|
- OutputStream outputStream = response.getOutputStream();
|
|
|
long i = 1;
|
|
|
for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
|
|
|
if (row.getActualAmount() == null) {
|
|
@@ -1271,29 +1279,36 @@ public class ExportController extends BaseController {
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
+ String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath()+ "/";
|
|
|
+ File file = new File(basePath+"orderList-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
+ FileOutputStream fileOutputStream = new FileOutputStream(file);
|
|
|
+
|
|
|
+ HSSFWorkbook workbook = null;
|
|
|
try {
|
|
|
String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "应付金额", "现金支付", "余额支付", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "押金", "乐器", "教辅费用", "其它", "手续费", "到账时间",
|
|
|
"关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "备注"};
|
|
|
String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "expectAmount", "actualAmount", "balancePaymentAmount", "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "leaseFee", "musicalFee", "teachingFee", "otherFee", "transferFee", "payTime", "musicGroupId",
|
|
|
"groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "memo"};
|
|
|
- HSSFWorkbook workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
- response.setContentType("application/octet-stream");
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
- response.flushBuffer();
|
|
|
- outputStream = response.getOutputStream();
|
|
|
- workbook.write(outputStream);
|
|
|
- outputStream.flush();
|
|
|
+ workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
+ workbook.write(fileOutputStream);
|
|
|
+ fileOutputStream.getFD().sync();
|
|
|
+ fileOutputStream.close();
|
|
|
+
|
|
|
+ String folder = UploadUtil.getFileFloder();
|
|
|
+ String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME,"" + folder, file);
|
|
|
+ return succeed(url);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
- if (outputStream != null) {
|
|
|
try {
|
|
|
- outputStream.close();
|
|
|
+ fileOutputStream.close();
|
|
|
+ workbook.close();
|
|
|
+ file.delete();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- }
|
|
|
}
|
|
|
+ return failed("导出失败");
|
|
|
}
|
|
|
|
|
|
|