Просмотр исходного кода

导出excel,暴露自定义header

yzc 2 лет назад
Родитель
Сommit
90d4b698f4

+ 1 - 0
sckw-common/sckw-common-excel/src/main/java/com/sckw/excel/utils/ExcelUtil.java

@@ -104,6 +104,7 @@ public class ExcelUtil {
         fileName = URLEncoder.encode(fileName + "-" + DateUtil.dateToStr(LocalDate.now()), "UTF-8").replaceAll("\\+", "%20");
         response.setContentType("application/vnd.ms-excel");
         response.setCharacterEncoding("UTF-8");
+        response.setHeader("Access-Control-Expose-Headers", "Content-disposition");
         response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
     }
 

+ 6 - 2
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java

@@ -89,12 +89,16 @@ public class KwOrderService {
         List<OrderListRes> result = new ArrayList<>();
         list.forEach(e -> {
             OrderListRes order = BeanUtils.copyProperties(e, OrderListRes.class);
+            String loadCityName = Objects.isNull(e.getLoadCityName()) ? "" : e.getLoadCityName();
+            String unloadCityName = Objects.isNull(e.getUnloadCityName()) ? "" : e.getUnloadCityName();
+            String loadDetailAddress = Objects.isNull(e.getLoadDetailAddress()) ? "" : e.getLoadDetailAddress();
+            String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
             order.setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
                     .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
                     .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
                     .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
-                    .setLoadDetailAddressInfo(e.getLoadCityName() + e.getUnloadDetailAddress())
-                    .setUnloadDetailAddressInfo(e.getUnloadCityName() + e.getUnloadDetailAddress())
+                    .setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
+                    .setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
                     .setConsignmentStatus(Objects.isNull(e.getEntrustAmount()) || e.getEntrustAmount().compareTo(e.getAmount()) < 0 ? "待托运" : "已托运")
                     .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()));
             result.add(order);