|
@@ -1,8 +1,13 @@
|
|
|
package com.charging.chargingparking.modules.backController;
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.io.resource.ClassPathResource;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.charging.chargingparking.dto.MessageResult;
|
|
|
+import com.charging.chargingparking.dto.PayDTO;
|
|
|
import com.charging.chargingparking.dto.PojoUtils;
|
|
|
import com.charging.chargingparking.entity.ParkingInfo;
|
|
|
import com.charging.chargingparking.entity.ParkingPay;
|
|
@@ -14,13 +19,19 @@ import com.charging.chargingparking.service.ParkingRecordService;
|
|
|
import com.charging.chargingparking.service.ParkingUserRelationService;
|
|
|
import com.charging.chargingparking.sys.service.UserService;
|
|
|
import com.charging.chargingparking.utils.StringUtils;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -169,6 +180,86 @@ public class BackParkingPayController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "导出支付记录")
|
|
|
+ @GetMapping(value = "exportPayList")
|
|
|
+ public void exportPayList(
|
|
|
+ String carNum, String payTimeRange, String parkingName, HttpServletResponse response,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.create_time", "desc"));
|
|
|
+ if (StringUtils.isNotEmpty(carNum)) {
|
|
|
+ searchParams.put("carNum", "%" + carNum + "%");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(parkingName)) {
|
|
|
+ searchParams.put("parkingName", parkingName);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(payTimeRange)) {
|
|
|
+ String[] timeRangeArray = payTimeRange.split(",");
|
|
|
+ String startTime = "";
|
|
|
+ String endTime = "";
|
|
|
+ if (timeRangeArray.length == 1) {
|
|
|
+ startTime = timeRangeArray[0];
|
|
|
+ //startTime += " 00:00:00";
|
|
|
+ } else if (timeRangeArray.length == 2) {
|
|
|
+ startTime = timeRangeArray[0];
|
|
|
+ endTime = timeRangeArray[1];
|
|
|
+ //startTime += " 00:00:00";
|
|
|
+ //endTime += " 23:59:59";
|
|
|
+ }
|
|
|
+
|
|
|
+ searchParams.put("pay_time_start", startTime);
|
|
|
+ searchParams.put("pay_time_end", endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!userService.hasRole(subject,"SYSADMIN")) {
|
|
|
+ searchParams.put("filterParkingList", parkingUserRelationService.findByUserId(subject));
|
|
|
+ }
|
|
|
+
|
|
|
+ com.github.pagehelper.Page<ParkingPay> page = parkingPayService.pageSearch(searchParams, 1, 100000, sortList);
|
|
|
+
|
|
|
+ List<ParkingPay> parkingPayList = page.getResult();
|
|
|
+ List<PayDTO> exportList = new ArrayList<>();
|
|
|
+ if (parkingPayList.size()>0){
|
|
|
+ for (ParkingPay parkingPay : parkingPayList){
|
|
|
+ PayDTO payDTO = new PayDTO();
|
|
|
+ BeanUtils.copyProperties(parkingPay,payDTO);
|
|
|
+ payDTO.setActualPayAmount(parkingPay.getPayAmount());
|
|
|
+ if ("wechat".equals(parkingPay.getPayName())){
|
|
|
+ payDTO.setPayNameStr("微信");
|
|
|
+ }
|
|
|
+ if ("alipay".equals(parkingPay.getPayName())){
|
|
|
+ payDTO.setPayNameStr("支付宝");
|
|
|
+ }
|
|
|
+ payDTO.setPayTimeStr(DateUtil.format(parkingPay.getPayTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ exportList.add(payDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Map map = Maps.newHashMap();
|
|
|
+ map.put("list", exportList);
|
|
|
+ //获取导出模板地址
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("static/payExcel.xls");
|
|
|
+ String path = classPathResource.getPath();
|
|
|
+ TemplateExportParams templateExportParams1 = new TemplateExportParams(path);
|
|
|
+ Workbook wb = ExcelExportUtil.exportExcel(templateExportParams1, map);
|
|
|
+ String fileName = "支付记录.xlsx";
|
|
|
+ try {
|
|
|
+ response.setContentType("application/octet-stream;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
|
|
|
+ response.flushBuffer();
|
|
|
+ wb.write(response.getOutputStream());
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation(value = "汇总")
|
|
|
@RequestMapping(value = "amountSummary", method = RequestMethod.POST)
|
|
|
public MessageResult<Map> amountSummary(
|