diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderCsVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderCsVo.java
index ca7cee6e3..c44275c98 100644
--- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderCsVo.java
+++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderCsVo.java
@@ -13,13 +13,8 @@ import lombok.Data;
import java.math.BigDecimal;
@Data
-@HeadRowHeight(40)
-@ColumnWidth(50)
-@ContentRowHeight(20)
-@ExcelIgnoreUnannotated
public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface {
- @ExcelProperty("设备名称")
@Schema(description = "设备id")
private Long hardId;
@@ -29,7 +24,6 @@ public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface {
@Schema(description = "设备类型")
private String hardType;
- @ExcelProperty("所属商户")
@Schema(description = "商户名")
private String merchantName;
@@ -39,11 +33,9 @@ public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface {
@Schema(description = "商户id")
private Long merchantId;
- @ExcelProperty("总消费金额")
@Schema(description = "总消费金额")
private BigDecimal totalPayPrice;
- @ExcelProperty("总消费次数")
@Schema(description = "总消费次数")
private BigDecimal totalPayCount;
diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderSbVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderSbVo.java
index d37d8f00f..62fcda01c 100644
--- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderSbVo.java
+++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderSbVo.java
@@ -1,6 +1,7 @@
package com.bsd.pjcloud.hard.api.vo.order;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
@@ -12,36 +13,30 @@ import lombok.Data;
import java.math.BigDecimal;
@Data
-@HeadRowHeight(40)
-@ColumnWidth(50)
-@ContentRowHeight(20)
-@ExcelIgnoreUnannotated
public class HardOrderSbVo implements BaseMchInterface, BaseHardInterface {
@Schema(description = "设备id")
private Long hardId;
+ @Schema(description = "设备名称")
+ private String hardName;
+
+ @Schema(description = "设备类型")
+ private String hardType;
+
@Schema(description = "商户id")
private Long merchantId;
- @Schema(description = "总消费金额")
+ @Schema(description = "商户名称")
+ private String merchantName;
+
+ @Schema(description = "商户logo")
+ private String logoPic;
+
+ @Schema(description = "总消费金额(元)")
private BigDecimal totalPayPrice;
@Schema(description = "总消费次数")
private BigDecimal totalPayCount;
- /**
- * 商户相关
- */
- private String merchantName;
-
- private String logoPic;
-
- /**
- * 设备相关
- */
- private String hardName;
-
- private String hardType;
-
}
diff --git a/pjcloud-hardware/pjcloud-hardware-biz/pom.xml b/pjcloud-hardware/pjcloud-hardware-biz/pom.xml
index 3d004fc74..d4793a906 100644
--- a/pjcloud-hardware/pjcloud-hardware-biz/pom.xml
+++ b/pjcloud-hardware/pjcloud-hardware-biz/pom.xml
@@ -175,4 +175,24 @@
boot
+
+
+
+ src/main/resources
+ true
+
+ **/*.xlsx
+ **/*.xls
+
+
+
+ src/main/resources
+ false
+
+ **/*.xlsx
+ **/*.xls
+
+
+
+
diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java
index 1f3bac005..7e3511f83 100644
--- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java
+++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java
@@ -1,25 +1,37 @@
package com.bsd.pjcloud.hard.controller.order;
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.LocalDateTimeUtil;
+import cn.hutool.core.io.resource.ResourceUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
-import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
+import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
import com.bsd.pjcloud.hard.service.HardOrderTotalService;
-import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletTransactionTkExcelVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
@RestController
@RequiredArgsConstructor
@@ -44,24 +56,80 @@ public class HardOrderTotalController {
return R.ok(HardOrderTotalService.pageListCs(page, dto));
}
- @ResponseExcel
@Operation(summary = "设备交易记录导出", description = "退款导出")
@GetMapping("/export-sb")
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_sb')")
- public List exportSb(HardOrderDto dto) {
+ public void exportSb(HttpServletResponse response, HardOrderDto dto) throws IOException {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
List list = HardOrderTotalService.listSb(dto);
- return BeanUtils.toBean(list, WalletTransactionTkExcelVo.class);
+ try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/设备交易金额汇总.xlsx")).build()) {
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
+ FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
+ Map map = new HashMap();
+ if (ObjectUtil.isNotEmpty(dto.getPayTimeList())) {
+ map.put("timeSpan", " 到 ");
+ map.put("startTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
+ map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
+ }
+ if (ObjectUtil.isNotEmpty(list)) {
+ BigDecimal priceTotal = BigDecimal.ZERO;
+ BigDecimal countTotal = BigDecimal.ZERO;
+ for (HardOrderSbVo v : list) {
+ if (ObjectUtil.isNotEmpty(v.getHardType())) {
+ v.setHardType(HardTypeEnum.valueOfByType(v.getHardType()).getDescription());
+ }
+ if (ObjectUtil.isNotEmpty(v.getTotalPayPrice())) {
+ priceTotal = priceTotal.add(v.getTotalPayPrice());
+ v.setTotalPayPrice(v.getTotalPayPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
+ }
+ if (ObjectUtil.isNotEmpty(v.getTotalPayCount())) {
+ countTotal = countTotal.add(v.getTotalPayCount());
+ }
+ }
+ map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
+ map.put("computeTotalPayCount", countTotal.toString());
+ }
+ excelWriter.fill(map, writeSheet);
+ excelWriter.fill(list, fillConfig, writeSheet);
+ }
}
- @ResponseExcel
@Operation(summary = "商户交易记录导出", description = "退款导出")
@GetMapping("/export-cs")
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_cs')")
- public List exportTk(HardOrderDto dto) {
+ public void exportTk(HttpServletResponse response, HardOrderDto dto) throws IOException {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
List list = HardOrderTotalService.listCs(dto);
- return BeanUtils.toBean(list, WalletTransactionTkExcelVo.class);
+ try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/商户交易金额汇总.xlsx")).build()) {
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
+ FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
+ Map map = new HashMap();
+ if (ObjectUtil.isNotEmpty(dto.getPayTimeList())) {
+ map.put("timeSpan", " 到 ");
+ map.put("startTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
+ map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
+ }
+ if (ObjectUtil.isNotEmpty(list)) {
+ BigDecimal priceTotal = BigDecimal.ZERO;
+ BigDecimal countTotal = BigDecimal.ZERO;
+ for (HardOrderCsVo v : list) {
+ if (ObjectUtil.isNotEmpty(v.getHardType())) {
+ v.setHardType(HardTypeEnum.valueOfByType(v.getHardType()).getDescription());
+ }
+ if (ObjectUtil.isNotEmpty(v.getTotalPayPrice())) {
+ priceTotal = priceTotal.add(v.getTotalPayPrice());
+ v.setTotalPayPrice(v.getTotalPayPrice().divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
+ }
+ if (ObjectUtil.isNotEmpty(v.getTotalPayCount())) {
+ countTotal = countTotal.add(v.getTotalPayCount());
+ }
+ }
+ map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
+ map.put("computeTotalPayCount", countTotal.toString());
+ }
+ excelWriter.fill(map, writeSheet);
+ excelWriter.fill(list, fillConfig, writeSheet);
+ }
}
}
diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/商户交易金额汇总.xlsx b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/商户交易金额汇总.xlsx
new file mode 100644
index 000000000..a410a1968
Binary files /dev/null and b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/商户交易金额汇总.xlsx differ
diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/设备交易金额汇总.xlsx b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/设备交易金额汇总.xlsx
new file mode 100644
index 000000000..1ee074fd0
Binary files /dev/null and b/pjcloud-hardware/pjcloud-hardware-biz/src/main/resources/file/设备交易金额汇总.xlsx differ