| | |
| | | |
| | | 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.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.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 java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | 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); |
| | | List<TOrderMealExportExcel> orderMeals = new ArrayList<>(); |
| | | 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) { |
| | | TOrderMealExportExcel tOrderMealExportExcel = new TOrderMealExportExcel(); |
| | | 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); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderMealExportExcel.class, orderMeals); |
| | | 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-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | String fileName = URLEncoder.encode("餐饮数据列表.xls", "utf-8"); |
| | | response.setHeader("Content-dispodition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | |
| | | @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<TOrderSaleAndGoodsExportExcel> orderMeals = new ArrayList<>(); |
| | | List<TOrderSaleAndGoodsExportExcelTemplate> orderMeals = new ArrayList<>(); |
| | | for (TOrderSaleVO orderSaleVO : list) { |
| | | TOrderSaleAndGoodsExportExcel orderSaleExportExcel = new TOrderSaleAndGoodsExportExcel(); |
| | | 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); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrderSaleAndGoodsExportExcel.class, orderMeals); |
| | | |
| | | 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-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | String fileName = URLEncoder.encode("销售数据列表.xls", "utf-8"); |
| | | response.setHeader("Content-dispodition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | |
| | | } |
| | | } |
| | | } |
| | | // @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") |