|
@@ -1,14 +1,28 @@
|
|
|
package com.yijia.station.controller;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
+import com.yijia.common.config.YiJiaConfig;
|
|
|
import com.yijia.common.core.domain.entity.SysDept;
|
|
|
import com.yijia.common.core.domain.model.LoginUser;
|
|
|
+import com.yijia.common.exception.CustomException;
|
|
|
import com.yijia.common.utils.SecurityUtils;
|
|
|
+import com.yijia.station.domain.StationClassStructure;
|
|
|
+import com.yijia.station.domain.StationClassesSummary;
|
|
|
import com.yijia.system.service.ISysDeptService;
|
|
|
import com.yijia.system.service.ISysUserService;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -38,6 +52,7 @@ import com.yijia.common.core.page.TableDataInfo;
|
|
|
@RequestMapping("/station/order")
|
|
|
public class PayOrderController extends BaseController
|
|
|
{
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(PayOrderController.class);
|
|
|
@Autowired
|
|
|
private IPayOrderService payOrderService;
|
|
|
@Autowired
|
|
@@ -410,4 +425,375 @@ public class PayOrderController extends BaseController
|
|
|
{
|
|
|
return toAjax(payOrderService.deletePayOrderByIds(orderIds));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询订单支付列表
|
|
|
+ */
|
|
|
+ @GetMapping("/LNGDeptList")
|
|
|
+ public TableDataInfo LNGDeptList(PayOrder payOrder)
|
|
|
+ {
|
|
|
+ List<String> list = deptService.levelDeptList(payOrder.getLevelId());
|
|
|
+ if(list!=null && list.size()>0){
|
|
|
+ payOrder.setStationIdList(list);
|
|
|
+ payOrder.setStationId(null);
|
|
|
+ }
|
|
|
+ startPage();
|
|
|
+ payOrder.setStatus("1");
|
|
|
+ List<PayOrder> payOrderList = payOrderService.LNGDeptList(payOrder);
|
|
|
+ return getDataTable(payOrderList);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 查询订单支付列表
|
|
|
+ */
|
|
|
+ @GetMapping("/LNGlist")
|
|
|
+ public TableDataInfo LNGlist(PayOrder payOrder)
|
|
|
+ {
|
|
|
+ List<String> list = deptService.levelDeptList(payOrder.getLevelId());
|
|
|
+ if(list!=null && list.size()>0){
|
|
|
+ payOrder.setStationIdList(list);
|
|
|
+ payOrder.setStationId(null);
|
|
|
+ }
|
|
|
+ startPage();
|
|
|
+ payOrder.setStatus("1");
|
|
|
+ List<PayOrder> payOrderList = payOrderService.selectLNGPayOrderExport(payOrder);
|
|
|
+ return getDataTable(payOrderList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "导出LNG", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/LNGExport")
|
|
|
+ public AjaxResult LNGExport(PayOrder payOrder)
|
|
|
+ {
|
|
|
+ List<String> list = deptService.levelDeptList(payOrder.getLevelId());
|
|
|
+ if(list!=null && list.size()>0){
|
|
|
+ payOrder.setStationIdList(list);
|
|
|
+ payOrder.setStationId(null);
|
|
|
+ }
|
|
|
+ payOrder.setStatus("1");
|
|
|
+ List<PayOrder> payOrderList = payOrderService.selectLNGPayOrderExport(payOrder);
|
|
|
+ AjaxResult ss = exportExcel(payOrderList, "导出订单信息");
|
|
|
+ return ss;
|
|
|
+ }
|
|
|
+
|
|
|
+ private AjaxResult exportExcel(List<PayOrder> payOrderList, String sheetName) {
|
|
|
+ OutputStream out = null;
|
|
|
+ Workbook wb= new SXSSFWorkbook(500);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Sheet sheet = wb.createSheet(sheetName);
|
|
|
+ sheet.setDefaultColumnWidth(20);//默认列宽20
|
|
|
+ CellStyle style = wb.createCellStyle();
|
|
|
+ CreationHelper createHelper = wb.getCreationHelper();
|
|
|
+ style.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-mm-dd hh:mm:ss"));
|
|
|
+ int rows =payOrderList.size()+1;
|
|
|
+ Cell cell =null;
|
|
|
+ Row row =null;
|
|
|
+ for (int i = 0; i < rows; i++) {
|
|
|
+ if(i == 0) {
|
|
|
+ row = sheet.createRow(i);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue("油站名称");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue("油品");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue("订单号");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue("枪标价");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(4);
|
|
|
+ cell.setCellValue("结算价");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(5);
|
|
|
+ cell.setCellValue("司机价");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(6);
|
|
|
+ cell.setCellValue("升数");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(7);
|
|
|
+ cell.setCellValue("应付金额");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(8);
|
|
|
+ cell.setCellValue("结算金额");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(9);
|
|
|
+ cell.setCellValue("司机金额");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(10);
|
|
|
+ cell.setCellValue("支付时间");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(11);
|
|
|
+ cell.setCellValue("手机号");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ }else {
|
|
|
+ row = sheet.createRow(i);
|
|
|
+ int j =i-1;
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getStationName());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getOilName());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getOrderNo());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getOilPirce()+"");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(4);
|
|
|
+ if(payOrderList.get(j).getSellOilPrice()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getSellOilPrice()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(5);
|
|
|
+ if(payOrderList.get(j).getDriverOilPrice()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getDriverOilPrice()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(6);
|
|
|
+ if(payOrderList.get(j).getOrderLiters()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getOrderLiters()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(7);
|
|
|
+ if(payOrderList.get(j).getReceivableAmt()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getReceivableAmt()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(8);
|
|
|
+ if(payOrderList.get(j).getSellAmt()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getSellAmt()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(9);
|
|
|
+ if(payOrderList.get(j).getAmt()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getAmt()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(10);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getPayDate());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(11);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getMobilePhone());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String filename = encodingFilename(sheetName);
|
|
|
+ out = new FileOutputStream(getAbsoluteFile(filename));
|
|
|
+ wb.write(out);
|
|
|
+ return AjaxResult.success(filename);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ log.error("导出Excel异常{}", e.getMessage());
|
|
|
+ throw new CustomException("导出Excel失败,请联系网站管理员!");
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ if (wb != null)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ wb.close();
|
|
|
+ }
|
|
|
+ catch (IOException e1)
|
|
|
+ {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (out != null)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ catch (IOException e1)
|
|
|
+ {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private String encodingFilename(String filename) {
|
|
|
+ filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx";
|
|
|
+ return filename;
|
|
|
+ }
|
|
|
+ public String getAbsoluteFile(String filename)
|
|
|
+ {
|
|
|
+ String downloadPath = YiJiaConfig.getDownloadPath() + filename;
|
|
|
+ File desc = new File(downloadPath);
|
|
|
+ if (!desc.getParentFile().exists())
|
|
|
+ {
|
|
|
+ desc.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ return downloadPath;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "导出LNG站点", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/LNGDeptExport")
|
|
|
+ public AjaxResult LNGDeptExport(PayOrder payOrder)
|
|
|
+ {
|
|
|
+ List<String> list = deptService.levelDeptList(payOrder.getLevelId());
|
|
|
+ if(list!=null && list.size()>0){
|
|
|
+ payOrder.setStationIdList(list);
|
|
|
+ payOrder.setStationId(null);
|
|
|
+ }
|
|
|
+ payOrder.setStatus("1");
|
|
|
+ List<PayOrder> payOrderList = payOrderService.LNGDeptList(payOrder);
|
|
|
+ AjaxResult ss = exportDeptExcel(payOrderList, "导出订单信息");
|
|
|
+ return ss;
|
|
|
+ }
|
|
|
+
|
|
|
+ private AjaxResult exportDeptExcel(List<PayOrder> payOrderList, String sheetName) {
|
|
|
+ OutputStream out = null;
|
|
|
+ Workbook wb= new SXSSFWorkbook(500);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Sheet sheet = wb.createSheet(sheetName);
|
|
|
+ sheet.setDefaultColumnWidth(20);//默认列宽20
|
|
|
+ CellStyle style = wb.createCellStyle();
|
|
|
+ CreationHelper createHelper = wb.getCreationHelper();
|
|
|
+ style.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-mm-dd hh:mm:ss"));
|
|
|
+ int rows =payOrderList.size()+1;
|
|
|
+ Cell cell =null;
|
|
|
+ Row row =null;
|
|
|
+ for (int i = 0; i < rows; i++) {
|
|
|
+ if(i == 0) {
|
|
|
+ row = sheet.createRow(i);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue("油站名称");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue("订单号");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue("油品");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue("枪标价");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(4);
|
|
|
+ cell.setCellValue("结算价");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(5);
|
|
|
+ cell.setCellValue("升数");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(6);
|
|
|
+ cell.setCellValue("应付金额");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(7);
|
|
|
+ cell.setCellValue("结算金额");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(8);
|
|
|
+ cell.setCellValue("结算优惠金额");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(9);
|
|
|
+ cell.setCellValue("支付时间");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(10);
|
|
|
+ cell.setCellValue("手机号");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ }else {
|
|
|
+ row = sheet.createRow(i);
|
|
|
+ int j =i-1;
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getStationName());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getOrderNo());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getOilName());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getOilPirce()+"");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(4);
|
|
|
+ if(payOrderList.get(j).getSellOilPrice()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getSellOilPrice()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(5);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getOrderLiters() + "");
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(6);
|
|
|
+ if(payOrderList.get(j).getReceivableAmt()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getReceivableAmt()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(7);
|
|
|
+ if(payOrderList.get(j).getSellAmt()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getSellAmt()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(8);
|
|
|
+ if(payOrderList.get(j).getSellDiscountAmt()!=null){
|
|
|
+ cell.setCellValue(payOrderList.get(j).getSellDiscountAmt()+"");
|
|
|
+ }else{
|
|
|
+ cell.setCellValue("0");
|
|
|
+ }
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(9);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getPayDate());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ cell = row.createCell(10);
|
|
|
+ cell.setCellValue(payOrderList.get(j).getMobilePhone());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String filename = encodingFilename(sheetName);
|
|
|
+ out = new FileOutputStream(getAbsoluteFile(filename));
|
|
|
+ wb.write(out);
|
|
|
+ return AjaxResult.success(filename);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ log.error("导出Excel异常{}", e.getMessage());
|
|
|
+ throw new CustomException("导出Excel失败,请联系网站管理员!");
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ if (wb != null)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ wb.close();
|
|
|
+ }
|
|
|
+ catch (IOException e1)
|
|
|
+ {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (out != null)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ catch (IOException e1)
|
|
|
+ {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|