From a7b772e99d7488b2d86bd3b5093fdfddbed3fd11 Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 23 Oct 2025 16:57:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(order):=20=E8=B0=83=E6=95=B4=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=87=91=E9=A2=9D=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=8F=8AExcel=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改approve.html和edit.html中总代进货金额和出货金额的显示条件 - 更新order.html中金额列的显示逻辑,根据订单状态切换显示字段 - 在ProjectOrderInfoServiceImpl中设置默认实际采购金额 -优化Excel导出功能,支持BigDecimal和String类型数据导出 - 调整buildExcelData方法返回值类型为List- 修改processProducts和addBasicFields等方法参数类型- 更新产品信息行的数据添加逻辑,直接使用数值类型而非字符串转换 --- .../templates/project/order/approve.html | 10 +-- .../templates/project/order/edit.html | 14 +++-- .../templates/project/order/order.html | 6 +- .../impl/ProjectOrderInfoServiceImpl.java | 63 ++++++++++--------- 4 files changed, 50 insertions(+), 43 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/project/order/approve.html b/ruoyi-admin/src/main/resources/templates/project/order/approve.html index 87b429f7..6ba77a3c 100644 --- a/ruoyi-admin/src/main/resources/templates/project/order/approve.html +++ b/ruoyi-admin/src/main/resources/templates/project/order/approve.html @@ -254,18 +254,18 @@ - 总代进货金额 - 总代进货金额 + + class="form-control"> - 总代出货金额 - 总代出货金额 + diff --git a/ruoyi-admin/src/main/resources/templates/project/order/edit.html b/ruoyi-admin/src/main/resources/templates/project/order/edit.html index 77dec61c..98d1fdf4 100644 --- a/ruoyi-admin/src/main/resources/templates/project/order/edit.html +++ b/ruoyi-admin/src/main/resources/templates/project/order/edit.html @@ -250,18 +250,20 @@ - 总代进货金额 - + 总代进货金额 + + - 总代出货金额 - 总代出货金额 + diff --git a/ruoyi-admin/src/main/resources/templates/project/order/order.html b/ruoyi-admin/src/main/resources/templates/project/order/order.html index 6e3d4df6..e56449c1 100644 --- a/ruoyi-admin/src/main/resources/templates/project/order/order.html +++ b/ruoyi-admin/src/main/resources/templates/project/order/order.html @@ -218,12 +218,14 @@ width:200 }, { - field: 'shipmentAmount', + field: 'actualPurchaseAmount', title: '金额(¥)', sortable: true, width:100, formatter: function (value, row, index) { - return value?formatAmountNumber(value):''; + let actualPurchaseAmount = value ? formatAmountNumber(value) : ''; + let shipmentAmount = row.shipmentAmount ? formatAmountNumber(row.shipmentAmount) : ''; + return (row.orderStatus == 1 || row.orderStatus == 2) ? actualPurchaseAmount : shipmentAmount; } }, { diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java index e8a8d543..f02a78c3 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java @@ -16,6 +16,8 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Dict; import cn.hutool.core.util.StrUtil; import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.converters.bigdecimal.BigDecimalNumberConverter; +import com.alibaba.excel.converters.string.StringNumberConverter; import com.alibaba.excel.metadata.CellData; import com.alibaba.excel.metadata.Head; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; @@ -396,6 +398,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To List projectProductInfos = productInfoService.selectProjectProductInfoListByProjectId(Collections.singletonList(projectOrderInfo.getProjectId())); BigDecimal bigDecimal = projectProductInfos.stream().map(ProjectProductInfo::getAllPrice).filter(Objects::nonNull).reduce(BigDecimal::add).get(); projectOrderInfo.setShipmentAmount(bigDecimal); + projectOrderInfo.setActualPurchaseAmount(bigDecimal); //处理文件 String deleteFileId = projectOrderInfo.getDeleteFileId(); if (StringUtils.isNotEmpty(deleteFileId)) { @@ -525,7 +528,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To // 构建 Excel 表头和数据 List> header = buildExcelHeader(maxCounts); - List> data = buildExcelData(projectInfos, maxCounts); + List> data = buildExcelData(projectInfos, maxCounts); // 导出 Excel 文件 return writeExcelToFile(header, data); @@ -714,7 +717,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To return Arrays.asList(maxSoftware, maxHardware, maxMaintenance, maxMaintenanceService, maxDeploy, maxOne, maxNvidia); } - private String writeExcelToFile(List> header, List> data) { + private String writeExcelToFile(List> header, List> data) { ExcelUtil util = new ExcelUtil<>(ProjectInfo.class); String fileName = util.encodingFilename("订单信息"); String filePath = util.getAbsoluteFile(fileName); @@ -864,7 +867,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To } } - public List> buildExcelData(List projectInfos, List maxCounts) { + public List> buildExcelData(List projectInfos, List maxCounts) { int maxSoftware = maxCounts.get(0); int maxHardware = maxCounts.get(1); int maxMaintenance = maxCounts.get(2); @@ -873,9 +876,9 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To int maxOne = maxCounts.get(5); int maxNvidia = maxCounts.get(6); - List> dataList = new ArrayList<>(); + List> dataList = new ArrayList<>(); for (ProjectOrderInfo info : projectInfos) { - List row = new ArrayList<>(); + List row = new ArrayList<>(); // 添加基础字段 addBasicFields(info, row); @@ -951,14 +954,14 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To //添加维保 totalPrice = processProducts(maintenanceList, maxMaintenanceService, row, totalPrice); int insertIndex=20; - row.add(insertIndex++, wssDto.getQuantity().toString()); - row.add(insertIndex++, wssDto.getAllPrice().toString()); + row.add(insertIndex++, wssDto.getQuantity()); + row.add(insertIndex++, wssDto.getAllPrice()); row.add(insertIndex++, wssDto.getTaxRate()); - row.add(insertIndex++, wspDto.getQuantity().toString()); - row.add(insertIndex++, wspDto.getAllPrice().toString()); + row.add(insertIndex++, wspDto.getQuantity()); + row.add(insertIndex++, wspDto.getAllPrice()); row.add(insertIndex++, wspDto.getTaxRate()); - row.add(insertIndex++, lsDto.getQuantity().toString()); - row.add(insertIndex++, lsDto.getAllPrice().toString()); + row.add(insertIndex++, lsDto.getQuantity()); + row.add(insertIndex++, lsDto.getAllPrice()); row.add(insertIndex++, lsDto.getTaxRate()); for (int i = 0; i < maxOne; i++) { ProjectProductInfo projectProductInfo = i < oneList.size() ? oneList.get(i) : null; @@ -974,26 +977,26 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To // row.add(17, nVIDIADto.getAllPrice().toString()); // row.add(StrUtil.toStringOrNull(info.getOrderChannel().equals(ProjectOrderInfo.OrderChannelEnum.TOTAL_GENERATION.getCode()) ? // info.getShipmentAmount() : info.getActualPurchaseAmount())); - row.add(info.getShipmentAmount() != null ? info.getShipmentAmount().toString() : ""); - row.add(totalPrice.toString()); + row.add(info.getShipmentAmount() != null ? info.getShipmentAmount() : ""); + row.add(totalPrice); //维保金额 - row.add(maintenancePrice.toString()); - row.add(StrUtil.toStringOrNull(info.getSoftwareProjectProductInfoList() == null ? 0 : + row.add(maintenancePrice); + row.add(info.getSoftwareProjectProductInfoList() == null ? 0 : // info.getSoftwareProjectProductInfoList().stream() // .map(item -> item.getPrice().multiply(info.getDiscountFold() == null ||info.getOrderStatus().equals(ProjectOrderInfo.OrderStatus.WAIT_APPROVE.getCode()) ? BigDecimal.ONE : info.getDiscountFold()).setScale(2,RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(item.getQuantity()))) // .reduce(BigDecimal.ZERO, BigDecimal::add))); - info.getSoftwareProjectProductInfoList().stream().map(ProjectProductInfo::getAllPrice).reduce(BigDecimal.ZERO, BigDecimal::add))); - row.add(StrUtil.toStringOrNull(info.getHardwareProjectProductInfoList() == null ? 0 : - info.getHardwareProjectProductInfoList().stream().map(ProjectProductInfo::getAllPrice).reduce(BigDecimal.ZERO, BigDecimal::add))); - row.add(StrUtil.toStringOrNull(info.getMaintenanceProjectProductInfoList() == null ? 0 : - info.getMaintenanceProjectProductInfoList().stream().map(ProjectProductInfo::getAllPrice).reduce(BigDecimal.ZERO, BigDecimal::add))); + info.getSoftwareProjectProductInfoList().stream().map(ProjectProductInfo::getAllPrice).reduce(BigDecimal.ZERO, BigDecimal::add)); + row.add(info.getHardwareProjectProductInfoList() == null ? 0 : + info.getHardwareProjectProductInfoList().stream().map(ProjectProductInfo::getAllPrice).reduce(BigDecimal.ZERO, BigDecimal::add)); + row.add(info.getMaintenanceProjectProductInfoList() == null ? 0 : + info.getMaintenanceProjectProductInfoList().stream().map(ProjectProductInfo::getAllPrice).reduce(BigDecimal.ZERO, BigDecimal::add)); dataList.add(row); } return dataList; } - private BigDecimal processProducts(List products, int maxCount, List row, BigDecimal currentTotal) { + private BigDecimal processProducts(List products, int maxCount, List row, BigDecimal currentTotal) { for (int i = 0; i < maxCount; i++) { if (CollUtil.isNotEmpty(products) && i < products.size()) { ProjectProductInfo product = products.get(i); @@ -1004,7 +1007,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To } return currentTotal; } - private void addBasicFields(ProjectOrderInfo info, List row) { + private void addBasicFields(ProjectOrderInfo info, List row) { row.add(info.getProjectCode()); row.add(DateUtil.format(info.getEstimatedOrderTime(), "yyyy-MM-dd")); row.add(info.getOrderCode()); @@ -1071,7 +1074,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To return "0".equals(value) ? "否" : "是"; } - private static BigDecimal addProductRow(ProjectProductInfo productInfo, List row, BigDecimal totalPrice) { + private static BigDecimal addProductRow(ProjectProductInfo productInfo, List row, BigDecimal totalPrice) { if (productInfo == null) { row.add(""); row.add(""); @@ -1082,16 +1085,16 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To } row.add(productInfo.getProductBomCode()); row.add(productInfo.getModel()); - row.add(productInfo.getQuantity() == null ? "" : productInfo.getQuantity().toString()); - row.add(productInfo.getAllPrice() == null ? "" : productInfo.getAllPrice().toString()); - row.add(productInfo.getTaxRate() == null ? "" : productInfo.getTaxRate().toString()); + row.add(productInfo.getQuantity() == null ? "" : productInfo.getQuantity()); + row.add(productInfo.getAllPrice() == null ? "" : productInfo.getAllPrice()); + row.add(productInfo.getTaxRate() == null ? "" : productInfo.getTaxRate()); if (productInfo.getAllPrice() != null) { totalPrice = totalPrice.add(productInfo.getAllPrice()); } return totalPrice; } - private int addProductRowByIndex(ProjectProductInfo productInfo, List row, Integer index) { + private int addProductRowByIndex(ProjectProductInfo productInfo, List row, Integer index) { if (productInfo == null) { row.add(index++, ""); row.add(index++, ""); @@ -1102,9 +1105,9 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To } row.add(index++, productInfo.getProductBomCode()); row.add(index++, productInfo.getModel()); - row.add(index++, productInfo.getQuantity() == null ? "" : productInfo.getQuantity().toString()); - row.add(index++, productInfo.getAllPrice() == null ? "" : productInfo.getAllPrice().toString()); - row.add(index++, productInfo.getTaxRate() == null ? "" : productInfo.getTaxRate().toString()); + row.add(index++, productInfo.getQuantity() == null ? "" : productInfo.getQuantity()); + row.add(index++, productInfo.getAllPrice() == null ? "" : productInfo.getAllPrice()); + row.add(index++, productInfo.getTaxRate() == null ? "" : productInfo.getTaxRate()); return index; }