Commit fad9c25a4624018be707cf305cd2323d4aa6a785

Authored by 房远帅
1 parent cc14c2ab

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

... ... @@ -16,6 +16,10 @@ import com.lframework.xingyun.sc.utils.CommonUtil;
16 16 import com.lframework.xingyun.sc.vo.statistics.orderDetail.QueryOrderDetailReportVo;
17 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 23 import java.util.List;
20 24 import java.util.stream.Collectors;
21 25
... ... @@ -53,10 +57,45 @@ public class OrderDetailReportExportTaskWorker implements
53 57 data.getLengthTolPos() != null ? data.getLengthTolPos().doubleValue() : null,
54 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 76 model.setThicknessTol(thicknessTol);
58 77 model.setWidthTol(widthTol);
59 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 99 return model;
61 100 }
62 101
... ... @@ -64,4 +103,27 @@ public class OrderDetailReportExportTaskWorker implements
64 103 public Class<OrderDetailStatisticsModel> getModelClass() {
65 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 1 package com.lframework.xingyun.sc.excel.statistics;
2 2
3 3 import com.alibaba.excel.annotation.ExcelProperty;
  4 +import com.alibaba.excel.annotation.format.DateTimeFormat;
  5 +import com.alibaba.excel.annotation.format.NumberFormat;
4 6 import com.lframework.starter.web.core.components.excel.ExcelModel;
5 7 import lombok.Data;
6 8 import java.math.BigDecimal;
  9 +import java.util.Date;
7 10
8 11 /**
9 12 * <p>
... ... @@ -18,25 +21,26 @@ public class OrderDetailStatisticsModel implements ExcelModel {
18 21 * 订货金额
19 22 */
20 23 @ExcelProperty("订货金额")
21   - private String amount;
  24 + private BigDecimal amount;
22 25
23 26 /**
24 27 * 超协金额
25 28 */
26 29 @ExcelProperty("超协金额")
27   - private String superCoordinationAmount;
  30 + private BigDecimal superCoordinationAmount;
28 31
29 32 /**
30 33 * 折65金额
31 34 */
32 35 @ExcelProperty("折65金额")
33   - private String discountAmount;
  36 + private BigDecimal discountAmount;
34 37
35 38 /**
36 39 * 订货日期
37 40 */
38 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 52 * 包装金额
49 53 */
50 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 64 * 订货日期
61 65 */
62 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 161 * 指导价
157 162 */
158 163 @ExcelProperty("指导价")
159   - private String suggestedPrice;
  164 + private BigDecimal suggestedPrice;
160 165
161 166 /**
162 167 * 发货日期
163 168 */
164 169 @ExcelProperty("发货日期")
165   - private String deliveryDate;
  170 + @DateTimeFormat("yyyy-MM-dd")
  171 + private Date deliveryDate;
166 172
167 173 /**
168 174 * 超协价
169 175 */
170 176 @ExcelProperty("超协价")
171   - private String assessmentExceedsAgreement;
  177 + private BigDecimal assessmentExceedsAgreement;
172 178
173 179 /**
174 180 * 当日南海H65
... ... @@ -180,7 +186,7 @@ public class OrderDetailStatisticsModel implements ExcelModel {
180 186 * 销售价
181 187 */
182 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 198 * 包装费
193 199 */
194 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 258 * 运费
253 259 */
254 260 @ExcelProperty("运费")
255   - private String shippingCost;
  261 + private BigDecimal shippingCost;
256 262
257 263 /**
258 264 * 回程运费
259 265 */
260 266 @ExcelProperty("回程运费")
261   - private String returnShippingCost;
  267 + private BigDecimal returnShippingCost;
262 268
263 269 /**
264 270 * 客户类型
... ...