解决导入明细接口的数值精度的bug
This commit is contained in:
@@ -1023,7 +1023,7 @@ public class DepotItemController {
|
||||
if("CGDD".equals(prefixNo) || "XSDD".equals(prefixNo)) {
|
||||
barCode = ExcelUtils.getContent(src, i, 0);
|
||||
num = ExcelUtils.getContent(src, i, 2);
|
||||
unitPrice = ExcelUtils.getContent(src, i, 3);
|
||||
unitPrice = ExcelUtils.getContentNumber(src, i, 3);
|
||||
taxRate = ExcelUtils.getContent(src, i, 4);
|
||||
remark = ExcelUtils.getContent(src, i, 5);
|
||||
}
|
||||
@@ -1031,7 +1031,7 @@ public class DepotItemController {
|
||||
depotName = ExcelUtils.getContent(src, i, 0);
|
||||
barCode = ExcelUtils.getContent(src, i, 1);
|
||||
num = ExcelUtils.getContent(src, i, 3);
|
||||
unitPrice = ExcelUtils.getContent(src, i, 4);
|
||||
unitPrice = ExcelUtils.getContentNumber(src, i, 4);
|
||||
taxRate = ExcelUtils.getContent(src, i, 5);
|
||||
remark = ExcelUtils.getContent(src, i, 6);
|
||||
}
|
||||
@@ -1039,7 +1039,7 @@ public class DepotItemController {
|
||||
depotName = ExcelUtils.getContent(src, i, 0);
|
||||
barCode = ExcelUtils.getContent(src, i, 1);
|
||||
num = ExcelUtils.getContent(src, i, 3);
|
||||
unitPrice = ExcelUtils.getContent(src, i, 4);
|
||||
unitPrice = ExcelUtils.getContentNumber(src, i, 4);
|
||||
remark = ExcelUtils.getContent(src, i, 5);
|
||||
}
|
||||
Map<String, String> materialMap = new HashMap<>();
|
||||
|
||||
@@ -1371,7 +1371,7 @@ public class DepotItemService {
|
||||
item.put("unitPrice", unitPrice);
|
||||
BigDecimal allPrice = BigDecimal.ZERO;
|
||||
if(unitPrice!=null && unitPrice.compareTo(BigDecimal.ZERO)!=0) {
|
||||
allPrice = unitPrice.multiply(operNumber);
|
||||
allPrice = unitPrice.multiply(operNumber).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
BigDecimal taxMoney = BigDecimal.ZERO;
|
||||
if(taxRate.compareTo(BigDecimal.ZERO) != 0) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.jsh.erp.utils;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
|
||||
import jxl.*;
|
||||
@@ -184,6 +185,22 @@ public class ExcelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getContentNumber(Sheet src, int rowNum, int colNum) {
|
||||
if(colNum < src.getRow(rowNum).length) {
|
||||
Cell cell = src.getCell(colNum, rowNum);
|
||||
if(cell.getType() == CellType.NUMBER) {
|
||||
NumberCell numCell = (NumberCell)cell;
|
||||
double value = numCell.getValue(); // 获取完整精度的数值
|
||||
DecimalFormat df = new DecimalFormat("#.######"); // 设置足够多的小数位
|
||||
return df.format(value);
|
||||
} else {
|
||||
return cell.getContents().trim(); // 获取原始字符串内容
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取真实的行数,剔除掉空白行
|
||||
* @param src
|
||||
|
||||
Reference in New Issue
Block a user