Commit fad9c25a4624018be707cf305cd2323d4aa6a785

Authored by 房远帅
1 parent cc14c2ab

订单明细报表导出:数字类型格式修改

@@ -16,6 +16,10 @@ import com.lframework.xingyun.sc.utils.CommonUtil; @@ -16,6 +16,10 @@ import com.lframework.xingyun.sc.utils.CommonUtil;
16 import com.lframework.xingyun.sc.vo.statistics.orderDetail.QueryOrderDetailReportVo; 16 import com.lframework.xingyun.sc.vo.statistics.orderDetail.QueryOrderDetailReportVo;
17 import com.lframework.xingyun.sc.vo.statistics.shipmentDetail.QueryShipmentDetailStatisticsVo; 17 import com.lframework.xingyun.sc.vo.statistics.shipmentDetail.QueryShipmentDetailStatisticsVo;
18 18
  19 +import java.math.BigDecimal;
  20 +import java.time.LocalDate;
  21 +import java.time.ZoneId;
  22 +import java.util.Date;
19 import java.util.List; 23 import java.util.List;
20 import java.util.stream.Collectors; 24 import java.util.stream.Collectors;
21 25
@@ -53,10 +57,45 @@ public class OrderDetailReportExportTaskWorker implements @@ -53,10 +57,45 @@ public class OrderDetailReportExportTaskWorker implements
53 data.getLengthTolPos() != null ? data.getLengthTolPos().doubleValue() : null, 57 data.getLengthTolPos() != null ? data.getLengthTolPos().doubleValue() : null,
54 data.getLengthTolNeg() != null ? data.getLengthTolNeg().doubleValue() : null); 58 data.getLengthTolNeg() != null ? data.getLengthTolNeg().doubleValue() : null);
55 59
56 - OrderDetailStatisticsModel model = JsonUtil.parseObject(JsonUtil.toJsonString(data), OrderDetailStatisticsModel.class); 60 + OrderDetailStatisticsModel model = new OrderDetailStatisticsModel();
  61 + model.setOrderNo(data.getOrderNo());
  62 + model.setOrderDate1(toDate(data.getOrderDate()));
  63 + model.setOrderDate(toDate(data.getOrderDate()));
  64 + model.setWorkshopName(data.getWorkshopName());
  65 + model.setDeptName(data.getDeptName());
  66 + model.setRegionName(data.getRegionName());
  67 + model.setOrderingUnitName(data.getOrderingUnitName());
  68 + model.setIndustry(data.getIndustry());
  69 + model.setBrand(data.getBrand());
  70 + model.setThickness(data.getThickness());
  71 + model.setWidth(data.getWidth());
  72 + model.setLength(data.getLength());
  73 + model.setStatus(data.getStatus());
  74 + model.setQuantity(data.getQuantity());
  75 + model.setDeliveryDate(toDate(data.getDeliveryDate()));
57 model.setThicknessTol(thicknessTol); 76 model.setThicknessTol(thicknessTol);
58 model.setWidthTol(widthTol); 77 model.setWidthTol(widthTol);
59 model.setLengthTol(lengthTol); 78 model.setLengthTol(lengthTol);
  79 + model.setSuggestedPrice(stringToBigDecimal(data.getSuggestedPrice()));
  80 + model.setAssessmentExceedsAgreement(stringToBigDecimal(data.getAssessmentExceedsAgreement()));
  81 + model.setSalesPrice(stringToBigDecimal(data.getSalesPrice()));
  82 + model.setPriceListNo(data.getPriceListNo());
  83 + model.setPackagingFee(stringToBigDecimal(data.getPackagingFee()));
  84 + model.setInvoicingStatus(data.getInvoicingStatus());
  85 + model.setPieceWeightHeader(data.getPieceWeightHeader());
  86 + model.setSurface(data.getSurface());
  87 + model.setTolerance(data.getTolerance());
  88 + model.setPerformance(data.getPerformance());
  89 + model.setPackaging(data.getPackaging());
  90 + model.setSpecialRequirements(data.getSpecialRequirements());
  91 + model.setRemarks(data.getRemarks());
  92 + model.setShippingCost(stringToBigDecimal(data.getShippingCost()));
  93 + model.setReturnShippingCost(stringToBigDecimal(data.getReturnShippingCost()));
  94 + model.setCustomerType(data.getCustomerType());
  95 + model.setQuality(data.getQuality());
  96 + model.setContractType(data.getContractType());
  97 + model.setStockUpCompanyName(data.getStockUpCompanyName());
  98 + model.setOrderType(data.getOrderType());
60 return model; 99 return model;
61 } 100 }
62 101
@@ -64,4 +103,27 @@ public class OrderDetailReportExportTaskWorker implements @@ -64,4 +103,27 @@ public class OrderDetailReportExportTaskWorker implements
64 public Class<OrderDetailStatisticsModel> getModelClass() { 103 public Class<OrderDetailStatisticsModel> getModelClass() {
65 return OrderDetailStatisticsModel.class; 104 return OrderDetailStatisticsModel.class;
66 } 105 }
  106 +
  107 + private static Date toDate(LocalDate date) {
  108 + if (date == null) {
  109 + return null;
  110 + }
  111 + return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
  112 + }
  113 +
  114 + public static BigDecimal stringToBigDecimal(String str) {
  115 + // 1. 判空处理:如果为 null 或去除空格后为空字符串,直接返回 null
  116 + if (str == null || str.trim().isEmpty()) {
  117 + return null;
  118 + }
  119 +
  120 + // 2. 尝试转换
  121 + try {
  122 + // 建议先 trim() 去除首尾空格,避免 " 100 " 这种格式报错
  123 + return new BigDecimal(str.trim());
  124 + } catch (NumberFormatException e) {
  125 + // 3. 如果字符串格式不合法(如 "abc"),根据业务需求处理,这里同样返回 null
  126 + return null;
  127 + }
  128 + }
67 } 129 }
1 package com.lframework.xingyun.sc.excel.statistics; 1 package com.lframework.xingyun.sc.excel.statistics;
2 2
3 import com.alibaba.excel.annotation.ExcelProperty; 3 import com.alibaba.excel.annotation.ExcelProperty;
  4 +import com.alibaba.excel.annotation.format.DateTimeFormat;
  5 +import com.alibaba.excel.annotation.format.NumberFormat;
4 import com.lframework.starter.web.core.components.excel.ExcelModel; 6 import com.lframework.starter.web.core.components.excel.ExcelModel;
5 import lombok.Data; 7 import lombok.Data;
6 import java.math.BigDecimal; 8 import java.math.BigDecimal;
  9 +import java.util.Date;
7 10
8 /** 11 /**
9 * <p> 12 * <p>
@@ -18,25 +21,26 @@ public class OrderDetailStatisticsModel implements ExcelModel { @@ -18,25 +21,26 @@ public class OrderDetailStatisticsModel implements ExcelModel {
18 * 订货金额 21 * 订货金额
19 */ 22 */
20 @ExcelProperty("订货金额") 23 @ExcelProperty("订货金额")
21 - private String amount; 24 + private BigDecimal amount;
22 25
23 /** 26 /**
24 * 超协金额 27 * 超协金额
25 */ 28 */
26 @ExcelProperty("超协金额") 29 @ExcelProperty("超协金额")
27 - private String superCoordinationAmount; 30 + private BigDecimal superCoordinationAmount;
28 31
29 /** 32 /**
30 * 折65金额 33 * 折65金额
31 */ 34 */
32 @ExcelProperty("折65金额") 35 @ExcelProperty("折65金额")
33 - private String discountAmount; 36 + private BigDecimal discountAmount;
34 37
35 /** 38 /**
36 * 订货日期 39 * 订货日期
37 */ 40 */
38 @ExcelProperty("订货日期") 41 @ExcelProperty("订货日期")
39 - private String orderDate1; 42 + @DateTimeFormat("yyyy-MM-dd")
  43 + private Date orderDate1;
40 44
41 /** 45 /**
42 * 订单编号 46 * 订单编号
@@ -48,7 +52,7 @@ public class OrderDetailStatisticsModel implements ExcelModel { @@ -48,7 +52,7 @@ public class OrderDetailStatisticsModel implements ExcelModel {
48 * 包装金额 52 * 包装金额
49 */ 53 */
50 @ExcelProperty("包装金额") 54 @ExcelProperty("包装金额")
51 - private String packagingAmount; 55 + private BigDecimal packagingAmount;
52 56
53 /** 57 /**
54 * 当日电铜 58 * 当日电铜
@@ -60,7 +64,8 @@ public class OrderDetailStatisticsModel implements ExcelModel { @@ -60,7 +64,8 @@ public class OrderDetailStatisticsModel implements ExcelModel {
60 * 订货日期 64 * 订货日期
61 */ 65 */
62 @ExcelProperty("订货日期") 66 @ExcelProperty("订货日期")
63 - private String orderDate; 67 + @DateTimeFormat("yyyy-MM-dd")
  68 + private Date orderDate;
64 69
65 /** 70 /**
66 * 生产厂 71 * 生产厂
@@ -156,19 +161,20 @@ public class OrderDetailStatisticsModel implements ExcelModel { @@ -156,19 +161,20 @@ public class OrderDetailStatisticsModel implements ExcelModel {
156 * 指导价 161 * 指导价
157 */ 162 */
158 @ExcelProperty("指导价") 163 @ExcelProperty("指导价")
159 - private String suggestedPrice; 164 + private BigDecimal suggestedPrice;
160 165
161 /** 166 /**
162 * 发货日期 167 * 发货日期
163 */ 168 */
164 @ExcelProperty("发货日期") 169 @ExcelProperty("发货日期")
165 - private String deliveryDate; 170 + @DateTimeFormat("yyyy-MM-dd")
  171 + private Date deliveryDate;
166 172
167 /** 173 /**
168 * 超协价 174 * 超协价
169 */ 175 */
170 @ExcelProperty("超协价") 176 @ExcelProperty("超协价")
171 - private String assessmentExceedsAgreement; 177 + private BigDecimal assessmentExceedsAgreement;
172 178
173 /** 179 /**
174 * 当日南海H65 180 * 当日南海H65
@@ -180,7 +186,7 @@ public class OrderDetailStatisticsModel implements ExcelModel { @@ -180,7 +186,7 @@ public class OrderDetailStatisticsModel implements ExcelModel {
180 * 销售价 186 * 销售价
181 */ 187 */
182 @ExcelProperty("销售价") 188 @ExcelProperty("销售价")
183 - private String salesPrice; 189 + private BigDecimal salesPrice;
184 190
185 /** 191 /**
186 * 价格表编号 192 * 价格表编号
@@ -192,7 +198,7 @@ public class OrderDetailStatisticsModel implements ExcelModel { @@ -192,7 +198,7 @@ public class OrderDetailStatisticsModel implements ExcelModel {
192 * 包装费 198 * 包装费
193 */ 199 */
194 @ExcelProperty("包装费") 200 @ExcelProperty("包装费")
195 - private String packagingFee; 201 + private BigDecimal packagingFee;
196 202
197 /** 203 /**
198 * 开票要求 204 * 开票要求
@@ -252,13 +258,13 @@ public class OrderDetailStatisticsModel implements ExcelModel { @@ -252,13 +258,13 @@ public class OrderDetailStatisticsModel implements ExcelModel {
252 * 运费 258 * 运费
253 */ 259 */
254 @ExcelProperty("运费") 260 @ExcelProperty("运费")
255 - private String shippingCost; 261 + private BigDecimal shippingCost;
256 262
257 /** 263 /**
258 * 回程运费 264 * 回程运费
259 */ 265 */
260 @ExcelProperty("回程运费") 266 @ExcelProperty("回程运费")
261 - private String returnShippingCost; 267 + private BigDecimal returnShippingCost;
262 268
263 /** 269 /**
264 * 客户类型 270 * 客户类型