ソースを参照

处理修改批量上架的bug-如果是数字,获取出来是科学计数法。

yujia 8 年 前
コミット
c91b95c9c3

+ 10 - 3
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -27,6 +27,7 @@ import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.ReleaseStatus;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -326,7 +327,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 					}
 
 					// 最小包单价
-					Object priceMinPackQtyCellValue = readWorkBookCell(row.getCell(9), Cell.CELL_TYPE_STRING, r, 9);
+					Object priceMinPackQtyCellValue = readWorkBookCell(row.getCell(9), Cell.CELL_TYPE_NUMERIC, r, 9);
 					releaseProductByBatch.setMinPackPriceStr(StringUtilB2C.getStr(priceMinPackQtyCellValue));
 					if ((priceMinPackQtyCellValue != null)&&(isNumber(priceMinPackQtyCellValue.toString())) && (NumberUtil.compare(Double.valueOf(priceMinPackQtyCellValue.toString()), 0.0d) > 0)) {
 						Double price = Double.valueOf(priceMinPackQtyCellValue.toString());
@@ -573,7 +574,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
 				switch (cellType) {
 				case Cell.CELL_TYPE_STRING:
-					cell.setCellType(Cell.CELL_TYPE_STRING);
+					cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 					String str = cell.getStringCellValue().trim();
 //					Object data = getCellData(cell);
 //					String str = data == null ? "" : data.toString();
@@ -586,6 +587,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				case Cell.CELL_TYPE_NUMERIC:
 					cell.setCellType(Cell.CELL_TYPE_NUMERIC);
 					obj = cell.getNumericCellValue();
+					if(obj != null) {
+						if(obj.toString().indexOf("E") > 0) {
+							BigDecimal b = new BigDecimal(obj.toString());
+							obj = b.toPlainString();
+						}
+					}
 					break;
 				default:
 					if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
@@ -688,7 +695,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		Object endQtyCellValue = readWorkBookCell(cellQty, Cell.CELL_TYPE_STRING, r, num);
 		releaseProductByBatch.setFragmentQty(StringUtilB2C.getStr(endQtyCellValue), i);
 
-		Object priceCellValue = readWorkBookCell(cellPrice, Cell.CELL_TYPE_STRING, r, num + 1);
+		Object priceCellValue = readWorkBookCell(cellPrice, Cell.CELL_TYPE_NUMERIC, r, num + 1);
 		releaseProductByBatch.setFragmentPrice(StringUtilB2C.getStr(priceCellValue), i);
 		if ((endQtyCellValue != null)&&(isNumber(endQtyCellValue.toString())) && (NumberUtil.compare(Double.valueOf(endQtyCellValue.toString()), 0.0d) > 0)) {
 			Double end = Double.valueOf(endQtyCellValue.toString());