记得上下班打卡 | git大法好,push需谨慎

Commit 1a1448f6 authored by wangyifan's avatar wangyifan

票务看板V2-导出按钮

parent d534dadd
......@@ -11,6 +11,7 @@ import com.liquidnet.client.admin.common.utils.poi.ExcelUtil;
import com.liquidnet.client.admin.zhengzai.kylin.dto.KylinPerformanceSubscribeTicketStatisticalExportDao;
import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceOrderStatisCountResp;
import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceTicketSalesDto;
import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceTicketSumDto;
import com.liquidnet.client.admin.zhengzai.kylin.service.IOpenDataService;
import com.liquidnet.client.admin.zhengzai.kylin.utils.DataSumUtils;
import com.liquidnet.commons.lang.util.JsonUtils;
......@@ -29,14 +30,20 @@ import com.liquidnet.service.kylin.entity.KylinOrderImport;
import com.liquidnet.service.kylin.service.admin.IKylinPerformancesAdminService;
import com.liquidnet.service.kylin.service.other.DamaiService;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -415,4 +422,111 @@ public class KylinPerformancesController extends BaseController {
List<KylinPerformancesVo> kylinPerformancesVoList = kylinPerformancesService.searchPerformanceByTitle(title);
return ResponseDto.success(kylinPerformancesVoList);
}
@GetMapping("/performance/export")
public void exportPerformance(@RequestParam(value = "performanceId") String performanceId, HttpServletResponse response) {
try {
PerformanceOrderStatisCountResp perCountResp = new PerformanceOrderStatisCountResp();
List<PerformanceOrderStatisticalDao> result = new ArrayList<>();
PerformanceTicketSalesDto ticketSalesInfo = openDataService.getPerformanceTicketSalesInfo(performanceId);
if (ticketSalesInfo != null) {
perCountResp.setPerformanceTitle(ticketSalesInfo.getPerformanceTitle());
perCountResp.setTotalSalePrice(new BigDecimal(ticketSalesInfo.getFullSalesAmountTotal()));
perCountResp.setSaleGeneral(new BigDecimal(ticketSalesInfo.getFullAudienceTicketTotal()));
perCountResp.setTotalGeneral(new BigDecimal(ticketSalesInfo.getFullTotalGeneral()));
perCountResp.setTotalRefundGeneral(new BigDecimal(ticketSalesInfo.getFullRefundTicketTotal()));
perCountResp.setTotalBuyUsers(new BigDecimal(ticketSalesInfo.getFullBuyTotal()));
List<PerformanceTicketSalesDto.TicketSales> fullTicketDataList = ticketSalesInfo.getFullTicketDataList();
if (!fullTicketDataList.isEmpty()) {
for (PerformanceTicketSalesDto.TicketSales ticketSales : fullTicketDataList) {
PerformanceOrderStatisticalDao statisticalDao = new PerformanceOrderStatisticalDao();
statisticalDao.setPerformancesId(ticketSalesInfo.getPerformanceId());
statisticalDao.setTicketsId(ticketSales.getTicketId());
statisticalDao.setTitle(ticketSales.getTicketTitle());
statisticalDao.setPrice(new BigDecimal(ticketSales.getTicketPrice()));
statisticalDao.setType(ticketSales.getTicketType());
statisticalDao.setTotalGeneral(new BigDecimal(ticketSales.getTotalGeneral()));
statisticalDao.setSaleGeneral(new BigDecimal(ticketSales.getAudienceTicketTotal()));
statisticalDao.setTotalRefundGeneral(new BigDecimal(ticketSales.getRefundTicketTotal()));
statisticalDao.setTotalPayingNumber(new BigDecimal(ticketSales.getPayingTotal()));
statisticalDao.setTimeId(ticketSales.getTimeId());
statisticalDao.setTimeTitle(ticketSales.getTimeTitle());
statisticalDao.setVipBuyTotal(ticketSales.getVipBuyTotal());
statisticalDao.setFullRefundTicketTotal(ticketSales.getFullRefundTicketTotal());
statisticalDao.setHandlingFeeRefundTicketTotal(ticketSales.getHandlingFeeRefundTicketTotal());
statisticalDao.setRefundFeeRevenueTotal(new BigDecimal(ticketSales.getRefundFeeRevenueTotal()));
statisticalDao.setAudienceSalesAmountTotal(new BigDecimal(ticketSales.getAudienceSalesAmountTotal()));
statisticalDao.setSurplusGeneral(new BigDecimal(ticketSales.getSurplusGeneral()));
result.add(statisticalDao);
}
}
}
// 汇总数据
PerformanceTicketSumDto sumResp = DataSumUtils.sumStatistics(result);
// 创建 Excel
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("演出数据");
// 表头
String[] headers = {
"场次", "票种类型", "票种名称", "票种价格", "库存数量", "销售数量", "余票数量",
"登登登VIP购票数量", "正在支付数量", "退票总数量", "全额退票数量",
"手续费退票数量", "退票手续费收益", "票面销售金额"
};
XSSFRow headerRow = sheet.createRow(0);
for (int i = 0; i < headers.length; i++) {
headerRow.createCell(i).setCellValue(headers[i]);
}
// 数据行
int rowNum = 1;
for (PerformanceOrderStatisticalDao item : result) {
XSSFRow row = sheet.createRow(rowNum++);
row.createCell(0).setCellValue(item.getTimeTitle());
row.createCell(1).setCellValue(item.getType().equals(1) ? "单日票" : "通票"); // 记得在后端先做字典翻译
row.createCell(2).setCellValue(item.getTitle());
row.createCell(3).setCellValue(item.getPrice().toPlainString());
row.createCell(4).setCellValue(item.getTotalGeneral().toPlainString());
row.createCell(5).setCellValue(item.getSaleGeneral().toPlainString());
row.createCell(6).setCellValue(item.getSurplusGeneral().toPlainString());
row.createCell(7).setCellValue(item.getVipBuyTotal());
row.createCell(8).setCellValue(item.getTotalPayingNumber().toPlainString());
row.createCell(9).setCellValue(item.getTotalRefundGeneral().toPlainString());
row.createCell(10).setCellValue(item.getFullRefundTicketTotal());
row.createCell(11).setCellValue(item.getHandlingFeeRefundTicketTotal());
row.createCell(12).setCellValue(item.getRefundFeeRevenueTotal().toPlainString());
row.createCell(13).setCellValue(item.getAudienceSalesAmountTotal().toPlainString());
}
// 合计行
XSSFRow totalRow = sheet.createRow(rowNum);
totalRow.createCell(0).setCellValue("总计");
totalRow.createCell(4).setCellValue(sumResp.getTotalGeneralSum().toPlainString());
totalRow.createCell(5).setCellValue(sumResp.getSaleGeneralSum().toPlainString());
totalRow.createCell(6).setCellValue(sumResp.getSurplusGeneralSum().toPlainString());
totalRow.createCell(7).setCellValue(sumResp.getVipBuyTotalSum().toPlainString());
totalRow.createCell(8).setCellValue(sumResp.getTotalPayingNumberSum().toPlainString());
totalRow.createCell(9).setCellValue(sumResp.getTotalRefundGeneralSum().toPlainString());
totalRow.createCell(10).setCellValue(sumResp.getFullRefundTicketTotalSum().toPlainString());
totalRow.createCell(11).setCellValue(sumResp.getHandlingFeeRefundTicketTotalSum().toPlainString());
totalRow.createCell(12).setCellValue(sumResp.getRefundFeeRevenueTotalSum().toPlainString());
totalRow.createCell(13).setCellValue(sumResp.getAudienceSalesAmountTotalSum().toPlainString());
// 响应头
String fileName = URLEncoder.encode("演出统计数据.xlsx", StandardCharsets.UTF_8.name());
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
// 写出文件
workbook.write(response.getOutputStream());
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -47,6 +47,10 @@
<div class="tab-content">
<div id="tab-1" class="tab-pane">
<div class="panel-body">
<!-- 导出按钮 -->
<div class="m-t-md" style="text-align: left; margin-bottom: 2px">
<button type="button" class="btn btn-primary" onclick="exportTableData()">导出数据</button>
</div>
<div id="tab-1" class="tab-pane">
<iframe id="tab_iframe_1" name="tab_iframe_1" marginwidth=0 marginheight=0 width=100%
height=800px frameborder=0></iframe>
......@@ -575,6 +579,15 @@
anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
});
}
/**
* 导出文件
*/
function exportTableData() {
var performancesId = '[[${kylinPerformanceMisVo.performancesId}]]'.replaceAll("\"", "")
var url = prefix + '/performance/export?performanceId=' + performancesId;
window.location.href = url; // 直接触发下载
}
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment