feat(order): 调整订单金额显示逻辑及Excel导出功能
- 修改approve.html和edit.html中总代进货金额和出货金额的显示条件 - 更新order.html中金额列的显示逻辑,根据订单状态切换显示字段 - 在ProjectOrderInfoServiceImpl中设置默认实际采购金额 -优化Excel导出功能,支持BigDecimal和String类型数据导出 - 调整buildExcelData方法返回值类型为List<Object>- 修改processProducts和addBasicFields等方法参数类型- 更新产品信息行的数据添加逻辑,直接使用数值类型而非字符串转换dev_1.0.0
parent
6545b50582
commit
a7b772e99d
|
|
@ -254,18 +254,18 @@
|
|||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
|
||||
th:value="${dict.dictValue}"></option>
|
||||
</select></td>
|
||||
<td th:if="${projectOrderInfo.processTemplate=='1'}">总代进货金额</td>
|
||||
<td th:if="${projectOrderInfo.processTemplate=='1'}"><input type="hidden" id="actualPurchaseAmount" name="actualPurchaseAmount"
|
||||
<td >总代进货金额</td>
|
||||
<td th:colspan="${projectOrderInfo.processTemplate=='1'?1:3}"><input type="hidden" id="actualPurchaseAmount" name="actualPurchaseAmount"
|
||||
th:field="*{actualPurchaseAmount}"
|
||||
class="form-control">
|
||||
class="form-control">
|
||||
<input type="text" required id="displayactualPurchaseAmount" class="form-control"
|
||||
placeholder="输入金额"
|
||||
oninput="this.value = this.value.replace(/[^0-9.]/g,'').replace(/(\..*)\./g, '$1');"
|
||||
onfocus="this.value=document.getElementById('actualPurchaseAmount').value"
|
||||
onblur="updateShipmentAmountValue('actualPurchaseAmount')">
|
||||
</td>
|
||||
<td class="shortTd">总代出货金额</td>
|
||||
<td th:colspan="${projectOrderInfo.processTemplate=='1'?1:3}"><input name="shipmentAmount" id="shipmentAmount" th:field="*{shipmentAmount}"
|
||||
<td class="shortTd" th:styleappend="${projectOrderInfo.processTemplate=='1'?'':'display:none'}">总代出货金额</td>
|
||||
<td th:colspan="${projectOrderInfo.processTemplate=='1'?1:3}" th:styleappend="${projectOrderInfo.processTemplate=='1'?'':'display:none'}"><input name="shipmentAmount" id="shipmentAmount" th:field="*{shipmentAmount}"
|
||||
class="form-control"
|
||||
type="hidden"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -250,18 +250,20 @@
|
|||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
|
||||
th:value="${dict.dictValue}"></option>
|
||||
</select></td>
|
||||
<td th:if="${projectOrderInfo.processTemplate=='1'}">总代进货金额</td>
|
||||
<td th:if="${projectOrderInfo.processTemplate=='1'}"><input type="hidden" id="actualPurchaseAmount" name="actualPurchaseAmount"
|
||||
th:field="*{actualPurchaseAmount}"
|
||||
class="form-control">
|
||||
<td th:if="${projectOrderInfo.processTemplate=='1' ||(projectOrderInfo.processTemplate!='1' &&( projectOrderInfo.orderStatus=='1'||projectOrderInfo.orderStatus=='2'))}"> 总代进货金额</td>
|
||||
<td th:if="${projectOrderInfo.processTemplate=='1' ||(projectOrderInfo.processTemplate!='1' &&( projectOrderInfo.orderStatus=='1'||projectOrderInfo.orderStatus=='2')) }"
|
||||
th:colspan="${(projectOrderInfo.processTemplate!='1' &&( projectOrderInfo.orderStatus=='1'||projectOrderInfo.orderStatus=='2'))?3:1}">
|
||||
<input type="hidden" id="actualPurchaseAmount" name="actualPurchaseAmount" th:field="*{actualPurchaseAmount}" class="form-control">
|
||||
<input type="text" required id="displayactualPurchaseAmount" class="form-control"
|
||||
placeholder="输入金额"
|
||||
oninput="this.value = this.value.replace(/[^0-9.]/g,'').replace(/(\..*)\./g, '$1');"
|
||||
onfocus="this.value=document.getElementById('actualPurchaseAmount').value"
|
||||
onblur="updateShipmentAmountValue('actualPurchaseAmount')">
|
||||
</td>
|
||||
<td class="shortTd">总代出货金额</td>
|
||||
<td th:colspan="${projectOrderInfo.processTemplate=='1'?1:3}"><input name="shipmentAmount" id="shipmentAmount" th:field="*{shipmentAmount}"
|
||||
<td class="shortTd" th:styleappend="${(projectOrderInfo.processTemplate!='1' &&( projectOrderInfo.orderStatus=='1'||projectOrderInfo.orderStatus=='2'))?'display:none':''}">总代出货金额</td>
|
||||
<td th:colspan="${projectOrderInfo.processTemplate=='1'?1:3}"
|
||||
th:styleappend="${(projectOrderInfo.processTemplate!='1' &&( projectOrderInfo.orderStatus=='1'||projectOrderInfo.orderStatus=='2'))?'display:none':''}"
|
||||
><input name="shipmentAmount" id="shipmentAmount" th:field="*{shipmentAmount}"
|
||||
class="form-control"
|
||||
type="hidden"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<ProjectProductInfo> 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<List<String>> header = buildExcelHeader(maxCounts);
|
||||
List<List<String>> data = buildExcelData(projectInfos, maxCounts);
|
||||
List<List<Object>> 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<List<String>> header, List<List<String>> data) {
|
||||
private String writeExcelToFile(List<List<String>> header, List<List<Object>> data) {
|
||||
ExcelUtil<ProjectInfo> 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<List<String>> buildExcelData(List<ProjectOrderInfo> projectInfos, List<Integer> maxCounts) {
|
||||
public List<List<Object>> buildExcelData(List<ProjectOrderInfo> projectInfos, List<Integer> 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<List<String>> dataList = new ArrayList<>();
|
||||
List<List<Object>> dataList = new ArrayList<>();
|
||||
for (ProjectOrderInfo info : projectInfos) {
|
||||
List<String> row = new ArrayList<>();
|
||||
List<Object> 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<ProjectProductInfo> products, int maxCount, List<String> row, BigDecimal currentTotal) {
|
||||
private BigDecimal processProducts(List<ProjectProductInfo> products, int maxCount, List<Object> 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<String> row) {
|
||||
private void addBasicFields(ProjectOrderInfo info, List<Object> 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<String> row, BigDecimal totalPrice) {
|
||||
private static BigDecimal addProductRow(ProjectProductInfo productInfo, List<Object> 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<String> row, Integer index) {
|
||||
private int addProductRowByIndex(ProjectProductInfo productInfo, List<Object> 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue