package com.ruoyi.web.controller.api;
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
import cn.hutool.core.io.resource.ClassPathResource;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.ruoyi.common.basic.PageInfo;
|
import com.ruoyi.common.constant.OrderNumConstants;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.WebUtils;
|
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.system.domain.TDataGenerator;
|
import com.ruoyi.system.domain.TOrderSaleGoods;
|
import com.ruoyi.system.domain.TOrderStockGoods;
|
import com.ruoyi.system.dto.OrderMealGeneratorDTO;
|
import com.ruoyi.system.dto.OrderSaleGeneratorDTO;
|
import com.ruoyi.system.export.*;
|
import com.ruoyi.system.query.TDataGeneratorMealQuery;
|
import com.ruoyi.system.query.TDataGeneratorQuery;
|
import com.ruoyi.system.query.TDataGeneratorSaleQuery;
|
import com.ruoyi.system.query.TDataGeneratorStockQuery;
|
import com.ruoyi.system.service.TDataGeneratorService;
|
import com.ruoyi.system.service.TOrderMealService;
|
import com.ruoyi.system.service.TOrderSaleService;
|
import com.ruoyi.system.service.TOrderStockService;
|
import com.ruoyi.system.vo.*;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.ServletOutputStream;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.math.BigDecimal;
|
import java.net.URLEncoder;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* <p>
|
* 营业数据生成 前端控制器
|
* </p>
|
*
|
* @author xiaochen
|
* @since 2024-08-27
|
*/
|
@Api(tags = "数据生成管理")
|
@RestController
|
@RequestMapping("/t-data-generator")
|
public class TDataGeneratorController {
|
|
private final TOrderMealService orderMealService;
|
private final TOrderSaleService orderSaleService;
|
private final TOrderStockService orderStockService;
|
private final TDataGeneratorService dataGeneratorService;
|
private final TokenService tokenService;
|
private final RedisCache redisCache;
|
|
@Autowired
|
public TDataGeneratorController(TOrderMealService orderMealService, TOrderSaleService orderSaleService, TOrderStockService orderStockService, TDataGeneratorService dataGeneratorService, TokenService tokenService, RedisCache redisCache) {
|
this.orderMealService = orderMealService;
|
this.orderSaleService = orderSaleService;
|
this.orderStockService = orderStockService;
|
this.dataGeneratorService = dataGeneratorService;
|
this.tokenService = tokenService;
|
this.redisCache = redisCache;
|
}
|
|
@ApiOperation( value = "餐饮数据生成")
|
@PostMapping(value = "/mealDataGenerator")
|
public AjaxResult<String> mealDataGenerator(@RequestBody OrderMealGeneratorDTO dto) {
|
dto.setUserId(tokenService.getLoginUser().getUserId());
|
dto.setNickName(tokenService.getLoginUser().getNickName());
|
dataGeneratorService.mealDataGenerator(dto);
|
return AjaxResult.success();
|
}
|
|
@ApiOperation( value = "销售数据生成")
|
@PostMapping(value = "/saleDataGenerator")
|
public AjaxResult<String> saleDataGenerator(@RequestBody OrderSaleGeneratorDTO dto) {
|
dto.setUserId(tokenService.getLoginUser().getUserId());
|
dto.setNickName(tokenService.getLoginUser().getNickName());
|
dataGeneratorService.saleDataGenerator(dto);
|
return AjaxResult.success();
|
}
|
|
@ApiOperation( value = "数据生成分页")
|
@PostMapping(value = "/pageList")
|
public AjaxResult<PageInfo<TDataGeneratorVO>> pageList(@Validated @RequestBody TDataGeneratorQuery query) {
|
return AjaxResult.success(dataGeneratorService.pageList(query));
|
}
|
|
@ApiOperation( value = "数据生成删除")
|
@DeleteMapping(value = "/deleteById")
|
public AjaxResult<String> deleteById(@RequestParam("id") Long id) {
|
dataGeneratorService.removeById(id);
|
return AjaxResult.success();
|
}
|
|
@ApiOperation( value = "数据覆盖")
|
@GetMapping(value = "/dataCoverage")
|
public AjaxResult<String> dataCoverage(@RequestParam(value = "id") Long id) {
|
dataGeneratorService.dataCoverage(id);
|
return AjaxResult.success();
|
}
|
|
@ApiOperation( value = "数据生成终止 shopId=店铺id type: 1=餐饮 2=进货")
|
@GetMapping(value = "/stopGenerator")
|
public AjaxResult<String> stopGenerator(@RequestParam(value = "shopId") Long shopId,
|
@RequestParam(value = "type") Integer type) {
|
if(type == 1){
|
redisCache.setCacheObject(OrderNumConstants.MEAL+"_"+shopId,shopId);
|
}else {
|
redisCache.setCacheObject(OrderNumConstants.STOCK+"_"+shopId,shopId);
|
}
|
return AjaxResult.success();
|
}
|
|
@ApiOperation( value = "餐饮生成数据详情")
|
@PostMapping(value = "/mealGeneratorDataDetail")
|
public AjaxResult<TDataGeneratorMealDetailVO> mealGeneratorDataDetail(@Validated @RequestBody TDataGeneratorMealQuery query) {
|
return AjaxResult.success(dataGeneratorService.mealGeneratorDataDetail(query));
|
}
|
|
@ApiOperation( value = "销售生成数据详情")
|
@PostMapping(value = "/saleGeneratorDataDetail")
|
public AjaxResult<TDataGeneratorSaleDetailVO> saleGeneratorDataDetail(@Validated @RequestBody TDataGeneratorSaleQuery query) {
|
return AjaxResult.success(dataGeneratorService.saleGeneratorDataDetail(query));
|
}
|
|
@ApiOperation( value = "进货生成数据详情")
|
@PostMapping(value = "/stockGeneratorDataDetail")
|
public AjaxResult<TDataGeneratorStockDetailVO> stockGeneratorDataDetail(@Validated @RequestBody TDataGeneratorStockQuery query) {
|
return AjaxResult.success(dataGeneratorService.stockGeneratorDataDetail(query));
|
}
|
|
// @ApiOperation( value = "餐饮生成数据详情导出")
|
// @PostMapping(value = "/mealGeneratorExport")
|
// public void mealGeneratorExport(@Validated @RequestBody TDataGeneratorMealQuery query) {
|
// List<TOrderMealVO> list = orderMealService.mealGeneratorExport(query);
|
// List<TOrderMealExportExcel> orderMeals = new ArrayList<>();
|
// for (TOrderMealVO orderMealVO : list) {
|
// TOrderMealExportExcel tOrderMealExportExcel = new TOrderMealExportExcel();
|
// BeanUtils.copyProperties(orderMealVO, tOrderMealExportExcel);
|
// tOrderMealExportExcel.setCreateStrTime(DateUtils.localDateToString(orderMealVO.getMealTime()));
|
// tOrderMealExportExcel.setGoodsList(orderMealVO.getGoodsList().stream().collect(Collectors.joining("\n")));
|
// tOrderMealExportExcel.setPersonCount(orderMealVO.getMealPerson());
|
// orderMeals.add(tOrderMealExportExcel);
|
// }
|
// Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderMealExportExcel.class, orderMeals);
|
// HttpServletResponse response = WebUtils.response();
|
// response.setContentType("application/vnd.ms-excel");
|
// response.setCharacterEncoding("utf-8");
|
// ServletOutputStream outputStream = null;
|
// try {
|
// String fileName = URLEncoder.encode("餐饮生成列表.xls", "utf-8");
|
// response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
// response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
// response.setHeader("Pragma", "no-cache");
|
// response.setHeader("Cache-Control", "no-cache");
|
// outputStream = response.getOutputStream();
|
// workbook.write(outputStream);
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// } finally {
|
// try {
|
// outputStream.close();
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// }
|
// }
|
@ApiOperation( value = "餐饮生成数据详情导出")
|
@PostMapping(value = "/mealGeneratorExport")
|
public void mealGeneratorExport(@Validated @RequestBody TDataGeneratorMealQuery query) {
|
Map<String, Object> result = new HashMap<>();
|
TDataGenerator dataGenerator = dataGeneratorService.getById(query.getGeneratorId());
|
List<TOrderMealVO> list = orderMealService.mealGeneratorExport(query);
|
MealGeneratorClient mealGeneratorClient = new MealGeneratorClient();
|
// 统计
|
Map<String, Double> map = orderMealService.getDataGeneratorMealDetail(query);
|
BigDecimal money = new BigDecimal(map.get("moneyPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal card = new BigDecimal(map.get("cardPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal weiXin = new BigDecimal(map.get("weiXinPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal ali = new BigDecimal(map.get("aliPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal other = new BigDecimal(map.get("otherPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
Map<String, Double> map1 = orderMealService.getDataGeneratorMealDetailOrderMoney(query);
|
BigDecimal money1 = new BigDecimal(map1.get("moneyPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal card1 = new BigDecimal(map1.get("cardPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal weiXin1 = new BigDecimal(map1.get("weiXinPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal ali1 = new BigDecimal(map1.get("aliPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal other1 = new BigDecimal(map1.get("otherPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
if(Objects.nonNull(query.getStartTime())){
|
mealGeneratorClient.setGeneratorTime(DateUtils.localDateToString(DateUtils.stringToLocalDateTime(query.getStartTime()).toLocalDate()) + "零时 ~ " + DateUtils.localDateToString(DateUtils.stringToLocalDateTime(query.getStartTime()).toLocalDate().plusDays(1)) + "零时");
|
}else {
|
mealGeneratorClient.setGeneratorTime(DateUtils.localDateToString(dataGenerator.getStartTime()) + " 零时 ~ " + DateUtils.localDateToString(dataGenerator.getEndTime().plusDays(1)) + " 零时");
|
}
|
mealGeneratorClient.setAllMoney(money.add(card).add(weiXin).add(ali).add(other));
|
mealGeneratorClient.setAllOrderMoney(money1.add(card1).add(weiXin1).add(ali1).add(other1));
|
mealGeneratorClient.setWeiXinPayAmount(weiXin);
|
mealGeneratorClient.setAliPayAmount(ali);
|
mealGeneratorClient.setCardPayAmount(card);
|
mealGeneratorClient.setMoneyPayAmount(money);
|
mealGeneratorClient.setOtherPayAmount(other);
|
|
List<TOrderMealExportExcelTempLate> orderMeals = new ArrayList<>();
|
for (TOrderMealVO orderMealVO : list) {
|
TOrderMealExportExcelTempLate tOrderMealExportExcel = new TOrderMealExportExcelTempLate();
|
BeanUtils.copyProperties(orderMealVO, tOrderMealExportExcel);
|
tOrderMealExportExcel.setCreateStrTime(DateUtils.localDateToString(orderMealVO.getMealTime()));
|
tOrderMealExportExcel.setGoodsList(orderMealVO.getGoodsList().stream().collect(Collectors.joining("\n")));
|
tOrderMealExportExcel.setPersonCount(orderMealVO.getMealPerson());
|
switch (orderMealVO.getPayType()){
|
case 1:
|
tOrderMealExportExcel.setPayType("现金");
|
break;
|
case 2:
|
tOrderMealExportExcel.setPayType("支付宝");
|
break;
|
case 3:
|
tOrderMealExportExcel.setPayType("微信");
|
break;
|
case 4:
|
tOrderMealExportExcel.setPayType("银行卡");
|
break;
|
default:
|
tOrderMealExportExcel.setPayType("其他");
|
}
|
switch (orderMealVO.getMealType()){
|
case 1:
|
tOrderMealExportExcel.setMealType("散客");
|
break;
|
case 2:
|
tOrderMealExportExcel.setMealType("宴席");
|
break;
|
}
|
switch (orderMealVO.getStatus()){
|
case 1:
|
tOrderMealExportExcel.setStatus("待付款");
|
break;
|
case 2:
|
tOrderMealExportExcel.setStatus("已付款");
|
break;
|
}
|
orderMeals.add(tOrderMealExportExcel);
|
}
|
mealGeneratorClient.setOrderMeals(orderMeals);
|
|
result.put("mealGeneratorClient",mealGeneratorClient);
|
|
//1.获取excel模板
|
ClassPathResource classPathResource = new ClassPathResource("template/餐饮数据列表.xls");
|
TemplateExportParams params = new TemplateExportParams(classPathResource.getPath());
|
Workbook workbook = ExcelExportUtil.exportExcel(params, result);
|
HttpServletResponse response = WebUtils.response();
|
response.setContentType("application/vnd.ms-excel");
|
response.setCharacterEncoding("utf-8");
|
ServletOutputStream outputStream = null;
|
try {
|
String fileName = URLEncoder.encode("餐饮数据列表.xls", "utf-8");
|
response.setHeader("Content-dispodition", "attachment;filename=" + fileName);
|
outputStream = response.getOutputStream();
|
workbook.write(outputStream);
|
} catch (IOException e) {
|
e.printStackTrace();
|
} finally {
|
try {
|
outputStream.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
@ApiOperation( value = "销售生成数据详情导出")
|
@PostMapping(value = "/saleGeneratorExport")
|
public void saleGeneratorExport(@Validated @RequestBody TDataGeneratorSaleQuery query) {
|
|
Map<String, Object> result = new HashMap<>();
|
TDataGenerator dataGenerator = dataGeneratorService.getById(query.getGeneratorId());
|
SaleGeneratorClient saleGeneratorClient = new SaleGeneratorClient();
|
|
// 统计
|
Map<String, Double> map = orderSaleService.getDataGeneratorSaleDetail(query);
|
BigDecimal money = new BigDecimal(map.get("moneyPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal card = new BigDecimal(map.get("cardPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal weiXin = new BigDecimal(map.get("weiXinPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal ali = new BigDecimal(map.get("aliPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal other = new BigDecimal(map.get("otherPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
Map<String, Double> map1 = orderSaleService.getDataGeneratorSaleDetailOrderMoney(query);
|
BigDecimal money1 = new BigDecimal(map1.get("moneyPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal card1 = new BigDecimal(map1.get("cardPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal weiXin1 = new BigDecimal(map1.get("weiXinPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal ali1 = new BigDecimal(map1.get("aliPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
BigDecimal other1 = new BigDecimal(map1.get("otherPay")).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
if(Objects.nonNull(query.getStartTime())){
|
saleGeneratorClient.setGeneratorTime(DateUtils.localDateToString(DateUtils.stringToLocalDateTime(query.getStartTime()).toLocalDate()) + "零时 ~ " + DateUtils.localDateToString(DateUtils.stringToLocalDateTime(query.getStartTime()).toLocalDate().plusDays(1)) + "零时");
|
}else {
|
saleGeneratorClient.setGeneratorTime(DateUtils.localDateToString(dataGenerator.getStartTime()) + " 零时 ~ " + DateUtils.localDateToString(dataGenerator.getEndTime().plusDays(1)) + " 零时");
|
}
|
saleGeneratorClient.setAllMoney(money.add(card).add(weiXin).add(ali).add(other));
|
saleGeneratorClient.setAllOrderMoney(money1.add(card1).add(weiXin1).add(ali1).add(other1));
|
saleGeneratorClient.setWeiXinPayAmount(weiXin);
|
saleGeneratorClient.setAliPayAmount(ali);
|
saleGeneratorClient.setCardPayAmount(card);
|
saleGeneratorClient.setMoneyPayAmount(money);
|
saleGeneratorClient.setOtherPayAmount(other);
|
|
List<TOrderSaleVO> list = orderSaleService.saleGeneratorExport(query);
|
List<TOrderSaleAndGoodsExportExcelTemplate> orderMeals = new ArrayList<>();
|
for (TOrderSaleVO orderSaleVO : list) {
|
TOrderSaleAndGoodsExportExcelTemplate orderSaleExportExcel = new TOrderSaleAndGoodsExportExcelTemplate();
|
BeanUtils.copyProperties(orderSaleVO, orderSaleExportExcel);
|
orderSaleExportExcel.setCreateStrTime(DateUtils.localDateTimeToString(orderSaleVO.getCreateTime()));
|
orderSaleExportExcel.setGoodsAmount(orderSaleVO.getOrderSaleGoods().stream().map(TOrderSaleGoods::getThisSalePrice).reduce(BigDecimal::add).get());
|
switch (orderSaleVO.getPayType()){
|
case 1:
|
orderSaleExportExcel.setPayType("现金");
|
break;
|
case 2:
|
orderSaleExportExcel.setPayType("支付宝");
|
break;
|
case 3:
|
orderSaleExportExcel.setPayType("微信");
|
break;
|
case 4:
|
orderSaleExportExcel.setPayType("银行卡");
|
break;
|
default:
|
orderSaleExportExcel.setPayType("其他");
|
}
|
orderMeals.add(orderSaleExportExcel);
|
}
|
|
saleGeneratorClient.setOrderMeals(orderMeals);
|
|
result.put("saleGeneratorClient",saleGeneratorClient);
|
|
//1.获取excel模板
|
ClassPathResource classPathResource = new ClassPathResource("template/销售数据列表.xls");
|
TemplateExportParams params = new TemplateExportParams(classPathResource.getPath());
|
Workbook workbook = ExcelExportUtil.exportExcel(params, result);
|
HttpServletResponse response = WebUtils.response();
|
response.setContentType("application/vnd.ms-excel");
|
response.setCharacterEncoding("utf-8");
|
ServletOutputStream outputStream = null;
|
try {
|
String fileName = URLEncoder.encode("销售数据列表.xls", "utf-8");
|
response.setHeader("Content-dispodition", "attachment;filename=" + fileName);
|
outputStream = response.getOutputStream();
|
workbook.write(outputStream);
|
} catch (IOException e) {
|
e.printStackTrace();
|
} finally {
|
try {
|
outputStream.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
// @ApiOperation( value = "销售生成数据详情导出")
|
// @PostMapping(value = "/saleGeneratorExport")
|
// public void saleGeneratorExport(@Validated @RequestBody TDataGeneratorSaleQuery query) {
|
// List<TOrderSaleVO> list = orderSaleService.saleGeneratorExport(query);
|
// List<TOrderSaleAndGoodsExportExcel> orderMeals = new ArrayList<>();
|
// for (TOrderSaleVO orderSaleVO : list) {
|
// TOrderSaleAndGoodsExportExcel orderSaleExportExcel = new TOrderSaleAndGoodsExportExcel();
|
// BeanUtils.copyProperties(orderSaleVO, orderSaleExportExcel);
|
// orderSaleExportExcel.setCreateStrTime(DateUtils.localDateTimeToString(orderSaleVO.getCreateTime()));
|
// orderSaleExportExcel.setGoodsAmount(orderSaleVO.getOrderSaleGoods().stream().map(TOrderSaleGoods::getThisSalePrice).reduce(BigDecimal::add).get());
|
// orderMeals.add(orderSaleExportExcel);
|
// }
|
// Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderSaleAndGoodsExportExcel.class, orderMeals);
|
// HttpServletResponse response = WebUtils.response();
|
// response.setContentType("application/vnd.ms-excel");
|
// response.setCharacterEncoding("utf-8");
|
// ServletOutputStream outputStream = null;
|
// try {
|
// String fileName = URLEncoder.encode("销售生成列表.xls", "utf-8");
|
// response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
// response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
// response.setHeader("Pragma", "no-cache");
|
// response.setHeader("Cache-Control", "no-cache");
|
// outputStream = response.getOutputStream();
|
// workbook.write(outputStream);
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// } finally {
|
// try {
|
// outputStream.close();
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// }
|
// }
|
|
@ApiOperation( value = "进货生成数据详情导出")
|
@PostMapping(value = "/stockGeneratorExport")
|
public void stockGeneratorExport(@Validated @RequestBody TDataGeneratorStockQuery query) {
|
List<TOrderStockVO> list = orderStockService.stockGeneratorExport(query);
|
List<TOrderStockExportExcel> orderStockExportExcels = new ArrayList<>();
|
for (TOrderStockVO orderStockVO : list) {
|
TOrderStockExportExcel orderStockExportExcel = new TOrderStockExportExcel();
|
BeanUtils.copyProperties(orderStockVO, orderStockExportExcel);
|
orderStockExportExcel.setStockTime(DateUtils.localDateToString(orderStockVO.getStockTime()));
|
orderStockExportExcels.add(orderStockExportExcel);
|
}
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderStockExportExcel.class, orderStockExportExcels);
|
HttpServletResponse response = WebUtils.response();
|
response.setContentType("application/vnd.ms-excel");
|
response.setCharacterEncoding("utf-8");
|
ServletOutputStream outputStream = null;
|
try {
|
String fileName = URLEncoder.encode("进货生成列表.xls", "utf-8");
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
response.setHeader("Pragma", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
outputStream = response.getOutputStream();
|
workbook.write(outputStream);
|
} catch (IOException e) {
|
e.printStackTrace();
|
} finally {
|
try {
|
outputStream.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
@ApiOperation( value = "餐饮数据生成列表导出")
|
@PostMapping(value = "/mealGeneratorListExport")
|
public void mealGeneratorListExport(@RequestBody TDataGeneratorQuery query) {
|
List<TDataGeneratorVO> list = orderMealService.mealGeneratorListExport(query);
|
List<MealGeneratorListExport> mealGeneratorListExports = new ArrayList<>();
|
for (TDataGeneratorVO dataGeneratorVO : list) {
|
MealGeneratorListExport mealGeneratorListExport = new MealGeneratorListExport();
|
BeanUtils.copyProperties(dataGeneratorVO, mealGeneratorListExport);
|
mealGeneratorListExport.setGeneratorTime(DateUtils.localDateTimeToString(dataGeneratorVO.getCreateTime()));
|
mealGeneratorListExport.setStartTimeStr(DateUtils.localDateToString(dataGeneratorVO.getStartTime()) + " ~ " + DateUtils.localDateToString(dataGeneratorVO.getEndTime()));
|
mealGeneratorListExport.setRevenueRange(dataGeneratorVO.getMinMoney() + " ~ " + dataGeneratorVO.getMaxMoney());
|
mealGeneratorListExports.add(mealGeneratorListExport);
|
}
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), MealGeneratorListExport.class, mealGeneratorListExports);
|
HttpServletResponse response = WebUtils.response();
|
response.setContentType("application/vnd.ms-excel");
|
response.setCharacterEncoding("utf-8");
|
ServletOutputStream outputStream = null;
|
try {
|
String fileName = URLEncoder.encode("餐饮数据生成列表.xls", "utf-8");
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
response.setHeader("Pragma", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
outputStream = response.getOutputStream();
|
workbook.write(outputStream);
|
} catch (IOException e) {
|
e.printStackTrace();
|
} finally {
|
try {
|
outputStream.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
@ApiOperation( value = "销售数据生成列表导出")
|
@PostMapping(value = "/saleGeneratorListExport")
|
public void saleGeneratorListExport(@RequestBody TDataGeneratorQuery query) {
|
List<TDataGeneratorVO> list = orderSaleService.saleGeneratorListExport(query);
|
List<SaleGeneratorListExport> saleGeneratorListExports = new ArrayList<>();
|
for (TDataGeneratorVO dataGeneratorVO : list) {
|
SaleGeneratorListExport saleGeneratorListExport = new SaleGeneratorListExport();
|
BeanUtils.copyProperties(dataGeneratorVO, saleGeneratorListExport);
|
saleGeneratorListExport.setGeneratorTime(DateUtils.localDateTimeToString(dataGeneratorVO.getCreateTime()));
|
saleGeneratorListExport.setStartTimeStr(DateUtils.localDateToString(dataGeneratorVO.getStartTime()) + " ~ " + DateUtils.localDateToString(dataGeneratorVO.getEndTime()));
|
saleGeneratorListExports.add(saleGeneratorListExport);
|
}
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), SaleGeneratorListExport.class, saleGeneratorListExports);
|
HttpServletResponse response = WebUtils.response();
|
response.setContentType("application/vnd.ms-excel");
|
response.setCharacterEncoding("utf-8");
|
ServletOutputStream outputStream = null;
|
try {
|
String fileName = URLEncoder.encode("销售数据生成列表.xls", "utf-8");
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
response.setHeader("Pragma", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
outputStream = response.getOutputStream();
|
workbook.write(outputStream);
|
} catch (IOException e) {
|
e.printStackTrace();
|
} finally {
|
try {
|
outputStream.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
}
|