|
|
@@ -7,6 +7,7 @@ import com.uas.platform.b2c.core.config.SysConf;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
import com.uas.platform.b2c.core.utils.RegexConstant;
|
|
|
+import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.ShortConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
@@ -25,7 +26,6 @@ import com.uas.platform.b2c.trade.order.StringConstant.Currency;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.model.ReleaseStatus;
|
|
|
-import com.uas.platform.core.model.Type;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
@@ -48,7 +48,6 @@ import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
import static com.uas.platform.b2c.core.utils.NumberUtil.fractionNumCeil;
|
|
|
-import static java.util.Collections.emptyList;
|
|
|
|
|
|
@Service
|
|
|
public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchService {
|
|
|
@@ -95,7 +94,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
Pattern chineseAndEnglishPattern = Pattern.compile(RegexConstant.chineseAndEnglish);
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
- if(colNum != 21) {
|
|
|
+ if(colNum != 19 && colNum != 20) {
|
|
|
throw new IllegalOperatorException("您上传的信息列信息不正确,请与模板的列做比较");
|
|
|
}
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
@@ -105,13 +104,13 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
Row headerRow = sheet.getRow(0);
|
|
|
int total = 0;
|
|
|
if (headerRow != null) {
|
|
|
- Cell cellHead = headerRow.getCell(0);
|
|
|
- Object readWorkBookCell = readWorkBookCell(cellHead, Cell.CELL_TYPE_STRING, 0, 0);
|
|
|
- Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
|
|
- Matcher m = p.matcher(readWorkBookCell.toString());
|
|
|
- String str = m.replaceAll("");
|
|
|
- if(StringUtils.isEmpty(str) || !("中文产品品牌".equals(str))) {
|
|
|
- throw new IllegalOperatorException("上传的文件信息第一列的表头为空,或第一列的表头名称不为中文产品品牌");
|
|
|
+ if(colNum == 20) {
|
|
|
+ Cell errorCell = headerRow.getCell(19);
|
|
|
+ Object errorCellObj = readWorkBookCell(errorCell, Cell.CELL_TYPE_STRING, 0, 0);
|
|
|
+ String errorHead = StringUtilB2C.replaceLineBreak(String.valueOf(errorCellObj));
|
|
|
+ if(StringUtils.isEmpty(errorHead) || !("错误提示".equals(errorHead))) {
|
|
|
+ throw new IllegalOperatorException("您上传的信息列信息不正确,请与模板的列做比较");
|
|
|
+ }
|
|
|
}
|
|
|
for (int r = 1; r <= rowNum; r++) {
|
|
|
Row row = sheet.getRow(r);
|
|
|
@@ -122,29 +121,20 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
releaseProductByBatch.setReleaseCode(ReleaseStatus.success.value());
|
|
|
releaseProductByBatch.setReleaseStatus(ReleaseStatus.success.getPhrase());
|
|
|
releaseProductByBatch.setRelbatchid(batch);
|
|
|
+
|
|
|
Cell cell = row.getCell(1);
|
|
|
Object cellValue = readWorkBookCell(cell, Cell.CELL_TYPE_STRING, r, 1);
|
|
|
- if(StringUtils.isEmpty(cellValue)) {
|
|
|
- continue;
|
|
|
- }else {
|
|
|
- releaseProductByBatch.setBrandNameEn(String.valueOf(cellValue));
|
|
|
- }
|
|
|
+ releaseProductByBatch.setBrandNameEn(String.valueOf(cellValue));
|
|
|
|
|
|
// 中文品牌名
|
|
|
Object brandNameCnCellValue = readWorkBookCell(row.getCell(0), Cell.CELL_TYPE_STRING, r, 0);
|
|
|
- if(StringUtils.isEmpty(brandNameCnCellValue)) {
|
|
|
- continue;
|
|
|
- }else {
|
|
|
- releaseProductByBatch.setBrandNameCn(String.valueOf(brandNameCnCellValue));
|
|
|
- }
|
|
|
+ releaseProductByBatch.setBrandNameCn(String.valueOf(brandNameCnCellValue));
|
|
|
|
|
|
// 产品型号
|
|
|
Object codeCellValue = readWorkBookCell(row.getCell(2), Cell.CELL_TYPE_STRING, r, 2);
|
|
|
- if(StringUtils.isEmpty(codeCellValue)) {
|
|
|
- continue;
|
|
|
- }else {
|
|
|
+ releaseProductByBatch.setCode(String.valueOf(codeCellValue));
|
|
|
+ if(!StringUtils.isEmpty(codeCellValue)) {
|
|
|
String code = codeCellValue.toString();
|
|
|
- releaseProductByBatch.setCode(code);
|
|
|
Matcher matcher = codePattern.matcher(code);
|
|
|
if(!matcher.find()) {
|
|
|
releaseProductByBatch.addErrmsg("3:产品型号仅限英文、数字、特殊字符");
|
|
|
@@ -161,106 +151,123 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
|
|
|
// 库存类型
|
|
|
- Object originialCellValue = readWorkBookCell(row.getCell(4), Cell.CELL_TYPE_STRING, r, 4);
|
|
|
- if (StringUtils.isEmpty(originialCellValue)
|
|
|
- || ((!"现货".equals(originialCellValue)) && (!"呆滞库存".equals(originialCellValue)))) {
|
|
|
- releaseProductByBatch.addErrmsg("5:库存类型为空,或者没有选择现货或者呆滞库存");
|
|
|
- } else {
|
|
|
- if ("现货".equals(originialCellValue)) {
|
|
|
- releaseProductByBatch.setOriginal(Type.Goods_Original_Code.value());
|
|
|
- } else if ("呆滞库存".equals(originialCellValue)) {
|
|
|
- releaseProductByBatch.setOriginal(Type.Goods_Inaction_Stock.value());
|
|
|
- }
|
|
|
- }
|
|
|
+// Object originialCellValue = readWorkBookCell(row.getCell(4), Cell.CELL_TYPE_STRING, r, 4);
|
|
|
+// if (StringUtils.isEmpty(originialCellValue)
|
|
|
+// || ((!"现货".equals(originialCellValue)) && (!"呆滞库存".equals(originialCellValue)))) {
|
|
|
+// releaseProductByBatch.addErrmsg("5:库存类型为空,或者没有选择现货或者呆滞库存");
|
|
|
+// } else {
|
|
|
+// if ("现货".equals(originialCellValue)) {
|
|
|
+// releaseProductByBatch.setOriginal(Type.Goods_Original_Code.value());
|
|
|
+// } else if ("呆滞库存".equals(originialCellValue)) {
|
|
|
+// releaseProductByBatch.setOriginal(Type.Goods_Inaction_Stock.value());
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
// 发布库存量
|
|
|
Double reserve = null;
|
|
|
- Object reserveCellValue = readWorkBookCell(row.getCell(5), Cell.CELL_TYPE_STRING, r, 5);
|
|
|
+ Object reserveCellValue = readWorkBookCell(row.getCell(4), Cell.CELL_TYPE_STRING, r, 4);
|
|
|
+ releaseProductByBatch.setReserveStr(String.valueOf(reserveCellValue));
|
|
|
if (reserveCellValue == null || !isNumber(reserveCellValue.toString())) {
|
|
|
- releaseProductByBatch.addErrmsg("6:发布数量为空或者不是数字");
|
|
|
+ releaseProductByBatch.addErrmsg("5:发布数量为空或者不是数字");
|
|
|
} else {
|
|
|
reserve = Double.valueOf(reserveCellValue.toString());
|
|
|
- int compareTo = reserve.compareTo(99999999d);
|
|
|
+ int compareTo = reserve.compareTo(DoubleConstant.maxReserve);
|
|
|
if(compareTo > 0) {
|
|
|
releaseProductByBatch.addErrmsg("6:发布数量大于了我们设置的最大值99999999");
|
|
|
- }else if(NumberUtil.compare(reserve, 0.0) < 1) {
|
|
|
+ }else if(NumberUtil.compare(reserve, DoubleConstant.zero) < 1) {
|
|
|
releaseProductByBatch.addErrmsg("6:发布数量必须大于0");
|
|
|
}
|
|
|
releaseProductByBatch.setReserve(reserve);
|
|
|
}
|
|
|
|
|
|
// 生产日期
|
|
|
- Object produceDateCellValue = readWorkBookCell(row.getCell(6), Cell.CELL_TYPE_STRING, r, 6);
|
|
|
- if (produceDateCellValue == null) {
|
|
|
- releaseProductByBatch.addErrmsg("7:产品生产日期不可以为空");
|
|
|
- } else {
|
|
|
- releaseProductByBatch.setProductDate(String.valueOf(produceDateCellValue));
|
|
|
+ Object produceDateCellValue = readWorkBookCell(row.getCell(5), Cell.CELL_TYPE_STRING, r, 5);
|
|
|
+ releaseProductByBatch.setProductDate(String.valueOf(produceDateCellValue));
|
|
|
+ if (StringUtils.isEmpty(produceDateCellValue)) {
|
|
|
+ releaseProductByBatch.addErrmsg("6:产品生产日期不可以为空");
|
|
|
}
|
|
|
|
|
|
//包装方式
|
|
|
String packaging = null;
|
|
|
- Object packagingCellValue = readWorkBookCell(row.getCell(7), Cell.CELL_TYPE_STRING, r, 7);
|
|
|
+ Object packagingCellValue = readWorkBookCell(row.getCell(6), Cell.CELL_TYPE_STRING, r, 6);
|
|
|
+ releaseProductByBatch.setPackaging(String.valueOf(packagingCellValue));
|
|
|
if (packagingCellValue == null || StringUtils.isEmpty(packagingCellValue.toString())) {
|
|
|
- releaseProductByBatch.addErrmsg("8:包装方式不能为空");
|
|
|
+ releaseProductByBatch.addErrmsg("7:包装方式不能为空");
|
|
|
} else {
|
|
|
packaging = packagingCellValue.toString();
|
|
|
- releaseProductByBatch.setPackaging(packaging);
|
|
|
Matcher matcher = chineseAndEnglishPattern.matcher(packaging);
|
|
|
if(!matcher.find()) {
|
|
|
- releaseProductByBatch.addErrmsg("8:包装方式仅限中文或英文");
|
|
|
+ releaseProductByBatch.addErrmsg("7:包装方式仅限中文或英文");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Double sample = null;
|
|
|
- Object sampleObj = readWorkBookCell(row.getCell(8), Cell.CELL_TYPE_STRING, r, 8);
|
|
|
- if ((sampleObj != null)&&(isNumber(sampleObj.toString()))) {
|
|
|
- sample = Double.valueOf(sampleObj.toString());
|
|
|
- if (sample <= 0) {
|
|
|
- // 这个是存在输入数据后再删除就会默认成0
|
|
|
- releaseProductByBatch.setSampleqty((double) 0);
|
|
|
- } else {
|
|
|
- releaseProductByBatch.setSampleqty(sample);
|
|
|
+// Double sample = null;
|
|
|
+// Object sampleObj = readWorkBookCell(row.getCell(8), Cell.CELL_TYPE_STRING, r, 8);
|
|
|
+// if ((sampleObj != null)&&(isNumber(sampleObj.toString()))) {
|
|
|
+// sample = Double.valueOf(sampleObj.toString());
|
|
|
+// if (sample <= 0) {
|
|
|
+// // 这个是存在输入数据后再删除就会默认成0
|
|
|
+// releaseProductByBatch.setSampleqty((double) 0);
|
|
|
+// } else {
|
|
|
+// releaseProductByBatch.setSampleqty(sample);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// // 这个是没有输入数据默认为null
|
|
|
+// releaseProductByBatch.setMinPackage((double) 0);
|
|
|
+// }
|
|
|
+
|
|
|
+ //封装方式
|
|
|
+// Object encapsulationCellValue = readWorkBookCell(row.getCell(6), Cell.CELL_TYPE_STRING, r, 6);
|
|
|
+// releaseProductByBatch.setEncapsulation(String.valueOf(encapsulationCellValue));
|
|
|
+
|
|
|
+ // 最小包装量
|
|
|
+ Object minPackQtyCellValue = readWorkBookCell(row.getCell(8), Cell.CELL_TYPE_STRING, r, 8);
|
|
|
+ releaseProductByBatch.setMinPackageStr(String.valueOf(minPackQtyCellValue));
|
|
|
+ if ((minPackQtyCellValue != null)&&(isNumber(minPackQtyCellValue.toString()))) {
|
|
|
+ Double minPackQty = Double.valueOf(minPackQtyCellValue.toString());
|
|
|
+ if (minPackQty <= 0) {
|
|
|
+ // 输入负数,默认为1
|
|
|
+ releaseProductByBatch.setMinPackage(DoubleConstant.minReserve);
|
|
|
+ }else if(NumberUtil.compare(minPackQty, DoubleConstant.maxMinPackageQty) > 0){
|
|
|
+ releaseProductByBatch.setMinPackage(DoubleConstant.maxMinPackageQty);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setMinPackage(minPackQty);
|
|
|
}
|
|
|
- } else {
|
|
|
- // 这个是没有输入数据默认为null
|
|
|
- releaseProductByBatch.setMinPackage((double) 0);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setMinPackage(DoubleConstant.minReserve);
|
|
|
}
|
|
|
|
|
|
- //封装方式
|
|
|
- Object encapsulationCellValue = readWorkBookCell(row.getCell(6), Cell.CELL_TYPE_STRING, r, 6);
|
|
|
- releaseProductByBatch.setEncapsulation(String.valueOf(encapsulationCellValue));
|
|
|
-
|
|
|
// 最小起订量
|
|
|
- Object minBuyCellValue = readWorkBookCell(row.getCell(9), Cell.CELL_TYPE_STRING, r, 9);
|
|
|
+ Object minBuyCellValue = readWorkBookCell(row.getCell(7), Cell.CELL_TYPE_STRING, r, 7);
|
|
|
+ releaseProductByBatch.setMinBuyQtyStr(String.valueOf(minBuyCellValue));
|
|
|
if ((minBuyCellValue != null)&&(isNumber(minBuyCellValue.toString()))) {
|
|
|
Double minBuy = Double.valueOf(minBuyCellValue.toString());
|
|
|
if (minBuy <= 0) {
|
|
|
// 输入负数
|
|
|
- releaseProductByBatch.addErrmsg("10:最小起订量的数量不能是负数");
|
|
|
- } else {
|
|
|
+ releaseProductByBatch.setMinBuyQty(releaseProductByBatch.getMinPackage());
|
|
|
+ }else {
|
|
|
Double rel_reserve = releaseProductByBatch.getReserve() == null ? 0 : releaseProductByBatch.getReserve();
|
|
|
int relVal = minBuy.compareTo(rel_reserve);
|
|
|
if(relVal > 0) {
|
|
|
- releaseProductByBatch.addErrmsg("10:最小起订量的数量不能大于库存的数量");
|
|
|
+ releaseProductByBatch.setMinBuyQty(releaseProductByBatch.getReserve());
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setMinBuyQty(minBuy);
|
|
|
+ }
|
|
|
+ if(!releaseProductByBatch.getBreakUp()) {
|
|
|
+ double v = releaseProductByBatch.getMinBuyQty() % releaseProductByBatch.getMinPackage();
|
|
|
+ if(NumberUtil.compare(v, 0.0) != 0) {
|
|
|
+ double sub = NumberUtil.sub(releaseProductByBatch.getMinBuyQty(), v);
|
|
|
+ double add = NumberUtil.add(sub, releaseProductByBatch.getMinPackage());
|
|
|
+ if(NumberUtil.compare(add, releaseProductByBatch.getReserve()) > 0) {
|
|
|
+ releaseProductByBatch.setMinBuyQty(sub);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setMinBuyQty(add);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- releaseProductByBatch.setMinBuyQty(minBuy);
|
|
|
- }
|
|
|
- }else {
|
|
|
- releaseProductByBatch.addErrmsg("10:最小起订量的数量不可以为空且只能是数字");
|
|
|
- }
|
|
|
-
|
|
|
- // 最小包装量
|
|
|
- Object minPackQtyCellValue = readWorkBookCell(row.getCell(10), Cell.CELL_TYPE_STRING, r, 10);
|
|
|
- if ((minPackQtyCellValue != null)&&(isNumber(minPackQtyCellValue.toString()))) {
|
|
|
- Double minPackQty = Double.valueOf(minPackQtyCellValue.toString());
|
|
|
- if (minPackQty <= 0) {
|
|
|
- // 输入负数
|
|
|
- releaseProductByBatch.addErrmsg("11:最小包装量的数量不能是负数");
|
|
|
- } else {
|
|
|
- releaseProductByBatch.setMinPackage(minPackQty);
|
|
|
}
|
|
|
}else {
|
|
|
- releaseProductByBatch.addErrmsg("11:最小包装量不可以为空且只能是数字");
|
|
|
+ releaseProductByBatch.setMinBuyQty(releaseProductByBatch.getMinPackage());
|
|
|
}
|
|
|
|
|
|
// 确认币别
|
|
|
@@ -273,7 +280,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
|
|
|
// 最小包单价
|
|
|
- Object priceMinPackQtyCellValue = readWorkBookCell(row.getCell(11), Cell.CELL_TYPE_STRING, r, 11);
|
|
|
+ Object priceMinPackQtyCellValue = readWorkBookCell(row.getCell(9), Cell.CELL_TYPE_STRING, r, 9);
|
|
|
+ releaseProductByBatch.setMinPackPriceStr(String.valueOf(priceMinPackQtyCellValue));
|
|
|
if ((priceMinPackQtyCellValue != null)&&(isNumber(priceMinPackQtyCellValue.toString()))) {
|
|
|
Double price = Double.valueOf(priceMinPackQtyCellValue.toString());
|
|
|
price = fractionNumCeil(price, 6);
|
|
|
@@ -283,37 +291,39 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
releaseProductByBatch.setRmbMinPackPrice(price);
|
|
|
}
|
|
|
}else {
|
|
|
- releaseProductByBatch.addErrmsg("最小包单价信息为空");
|
|
|
+ releaseProductByBatch.addErrmsg("10:最小包单价信息为空");
|
|
|
}
|
|
|
|
|
|
- Object deliveryMinCellValue = readWorkBookCell(row.getCell(12), Cell.CELL_TYPE_STRING, r, 12);
|
|
|
- Object deliveryMaxCellValue = readWorkBookCell(row.getCell(13), Cell.CELL_TYPE_STRING, r, 13);
|
|
|
+ Object deliveryMinCellValue = readWorkBookCell(row.getCell(10), Cell.CELL_TYPE_STRING, r, 10);
|
|
|
+ Object deliveryMaxCellValue = readWorkBookCell(row.getCell(11), Cell.CELL_TYPE_STRING, r, 11);
|
|
|
+ releaseProductByBatch.setSelfMinDeliveryStr(String.valueOf(deliveryMinCellValue));
|
|
|
+ releaseProductByBatch.setSelfMaxDeliveryStr(String.valueOf(deliveryMaxCellValue));
|
|
|
if(StringUtils.isEmpty(deliveryMinCellValue) && StringUtils.isEmpty(deliveryMaxCellValue)) {
|
|
|
- releaseProductByBatch.addErrmsg("13-14:存在交期的信息为空");
|
|
|
+ releaseProductByBatch.addErrmsg("11-12:存在交期的信息为空");
|
|
|
}else {
|
|
|
setDeliveryTime(releaseProductByBatch, deliveryMinCellValue, deliveryMaxCellValue);
|
|
|
}
|
|
|
|
|
|
// 分段数量
|
|
|
List<GoodsQtyPrice> prices = new ArrayList<GoodsQtyPrice>();
|
|
|
- Double[] priceMaxMinPrice = {Double.MAX_VALUE, Double.MIN_VALUE, Double.MAX_VALUE, Double.MIN_VALUE}; //最小人民币价格,最大人民币价格,最小美金价格,最大美金价格
|
|
|
+ Double[] priceMaxMinPrice = {Double.MAX_VALUE, Double.MIN_VALUE}; //最小价格,最大价格
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
- // 起始量必须等于最小起定量
|
|
|
- readSectionPrice(row.getCell(14 + 2 * i), row.getCell(15 + 2 * i),
|
|
|
- prices, releaseProductByBatch, r, (14 + 2 * i), priceMaxMinPrice);
|
|
|
+ //起始量必须等于最小起定量
|
|
|
+ readSectionPrice(row.getCell(12 + 2 * i), row.getCell(13 + 2 * i),
|
|
|
+ prices, releaseProductByBatch, r, (12 + 2 * i), priceMaxMinPrice, i);
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(prices)) {
|
|
|
- setPricesQty(prices, releaseProductByBatch);
|
|
|
+ prices = setPricesQty(prices, releaseProductByBatch);
|
|
|
} else {
|
|
|
// 如果未填分段价格,默认为最小包装量价格
|
|
|
GoodsQtyPrice qtyPrice = new GoodsQtyPrice();
|
|
|
- qtyPrice.setStart(releaseProductByBatch.getMinBuyQty());
|
|
|
+ qtyPrice.setStart(DoubleConstant.minReserve);
|
|
|
if(Currency.USD.equals(releaseProductByBatch.getCurrency())) {
|
|
|
Double usdMinPackPrice = releaseProductByBatch.getUsdMinPackPrice();
|
|
|
qtyPrice.setUSDPrice(usdMinPackPrice);
|
|
|
qtyPrice.setUSDNTPrice(usdMinPackPrice);
|
|
|
- priceMaxMinPrice[2] = usdMinPackPrice;
|
|
|
- priceMaxMinPrice[3] = usdMinPackPrice;
|
|
|
+ priceMaxMinPrice[0] = usdMinPackPrice;
|
|
|
+ priceMaxMinPrice[1] = usdMinPackPrice;
|
|
|
}else {
|
|
|
Double rmbMinPackPrice = releaseProductByBatch.getRmbMinPackPrice();
|
|
|
qtyPrice.setRMBPrice(rmbMinPackPrice);
|
|
|
@@ -323,22 +333,18 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
priceMaxMinPrice[0] = rmbMinPackPrice;
|
|
|
priceMaxMinPrice[1] = rmbMinPackPrice;
|
|
|
}
|
|
|
- qtyPrice.setEnd(reserve);
|
|
|
+ qtyPrice.setEnd(DoubleConstant.maxReserve);
|
|
|
prices.add(qtyPrice);
|
|
|
}
|
|
|
releaseProductByBatch.setPrices(prices);
|
|
|
- if(!priceMaxMinPrice[0].equals(Double.MAX_VALUE)) {
|
|
|
+ if(Currency.USD.equals(releaseProductByBatch.getCurrency())) {
|
|
|
+ releaseProductByBatch.setMinPriceUSD(priceMaxMinPrice[0]);
|
|
|
+ releaseProductByBatch.setMaxPriceUSD(priceMaxMinPrice[1]);
|
|
|
+ }else {
|
|
|
releaseProductByBatch.setMinPriceRMB(priceMaxMinPrice[0]);
|
|
|
- }
|
|
|
- if(!priceMaxMinPrice[1].equals(Double.MIN_VALUE)) {
|
|
|
releaseProductByBatch.setMaxPriceRMB(priceMaxMinPrice[1]);
|
|
|
}
|
|
|
- if(!priceMaxMinPrice[2].equals(Double.MAX_VALUE)) {
|
|
|
- releaseProductByBatch.setMinPriceUSD(priceMaxMinPrice[2]);
|
|
|
- }
|
|
|
- if(!priceMaxMinPrice[3].equals(Double.MIN_VALUE)) {
|
|
|
- releaseProductByBatch.setMaxPriceUSD(priceMaxMinPrice[3]);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
// 备注
|
|
|
Object remarkCellValue = readWorkBookCell(row.getCell(20), Cell.CELL_TYPE_STRING, r, 20);
|
|
|
@@ -379,8 +385,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
/**
|
|
|
* 分析分段的价格
|
|
|
*/
|
|
|
- private void setPricesQty(List<GoodsQtyPrice> prices, ReleaseProductByBatch productByBatch) {
|
|
|
- double end = -1;
|
|
|
+ private List<GoodsQtyPrice> setPricesQty(List<GoodsQtyPrice> prices, ReleaseProductByBatch productByBatch) {
|
|
|
GoodsQtyPrice[] array = new GoodsQtyPrice[prices.size()];
|
|
|
prices.toArray(array);
|
|
|
Arrays.sort(array, new Comparator<GoodsQtyPrice>() {
|
|
|
@@ -389,23 +394,32 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return NumberUtil.compare(o1.getEnd(), o2.getEnd());
|
|
|
}
|
|
|
});
|
|
|
- List<GoodsQtyPrice> priceList = Collections.<GoodsQtyPrice>emptyList();
|
|
|
- for (int j = 0; j < priceList.size(); j++) {
|
|
|
- GoodsQtyPrice price = priceList.get(j);
|
|
|
- if(NumberUtil.compare(end, -1d) == 0) {
|
|
|
- if(NumberUtil.compare(price.getEnd(), productByBatch.getMinBuyQty()) > 0) {
|
|
|
- price.setStart(productByBatch.getMinBuyQty());
|
|
|
- end = price.getEnd();
|
|
|
+ List<GoodsQtyPrice> prices1 = Arrays.asList(array);
|
|
|
+ List<GoodsQtyPrice> prices2 = new ArrayList<>();
|
|
|
+ for (int j = 0; j < prices1.size(); j++) {
|
|
|
+ GoodsQtyPrice price = prices1.get(j);
|
|
|
+ if(j == 0) {
|
|
|
+ if(NumberUtil.compare(price.getEnd(), DoubleConstant.minReserve) > 0) {
|
|
|
+ price.setStart(DoubleConstant.minReserve);
|
|
|
+ prices2.add(price);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if (j < prices.size() - 1) {
|
|
|
- price.setEnd(prices.get(j - 1).getStart() - 1);
|
|
|
- }
|
|
|
- if (j == prices.size() - 1) {
|
|
|
+ }else if (j < prices1.size() - 1) {
|
|
|
+ GoodsQtyPrice qtyPrice = prices1.get(j - 1);
|
|
|
+ if(NumberUtil.compare(qtyPrice.getEnd(), price.getEnd()) < 0 ) {
|
|
|
+ price.setStart(NumberUtil.add(qtyPrice.getEnd(), 1.0d));
|
|
|
+ prices2.add(price);
|
|
|
+ }
|
|
|
+ }else if (j == prices1.size() - 1) {
|
|
|
price.setEnd(DoubleConstant.maxReserve);
|
|
|
+ if(prices1.size() == 1) {
|
|
|
+ price.setStart(DoubleConstant.minReserve);
|
|
|
+ }else {
|
|
|
+ price.setStart(NumberUtil.add(prices1.get(j - 1).getEnd(), 1.0d));
|
|
|
+ }
|
|
|
+ prices2.add(price);
|
|
|
}
|
|
|
}
|
|
|
+ return prices2;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -459,7 +473,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
min = min == null ? max : min;
|
|
|
max = max == null ? min : max;
|
|
|
if(min.shortValue() > ShortConstant.maxDelivery || min.shortValue() < 0 || max.shortValue() > Short.MAX_VALUE || max.shortValue() < 0){
|
|
|
- releaseProductByBatch.addErrmsg("13-14:交期的信息必须为正整数并且小于" + ShortConstant.maxDelivery);
|
|
|
+ releaseProductByBatch.addErrmsg("11-12:交期的信息必须为正整数并且小于" + ShortConstant.maxDelivery);
|
|
|
}else {
|
|
|
if(min.shortValue() > max.shortValue()) {
|
|
|
Short delivery = max;
|
|
|
@@ -470,7 +484,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
releaseProductByBatch.setSelfMaxDelivery(max);
|
|
|
}
|
|
|
}else {
|
|
|
- releaseProductByBatch.addErrmsg("13-14:交期的信息必须为正整数并且小于" + ShortConstant.maxDelivery);
|
|
|
+ releaseProductByBatch.addErrmsg("11-12:交期的信息必须为正整数并且小于" + ShortConstant.maxDelivery);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -587,8 +601,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
*
|
|
|
* @author yujia
|
|
|
* @param cellQty
|
|
|
- * @param cellPriceRMB
|
|
|
- * @param cellPriceUSD
|
|
|
+ * @param cellPrice
|
|
|
* @param prices
|
|
|
* @param releaseProductByBatch
|
|
|
* @param r
|
|
|
@@ -599,45 +612,38 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
*
|
|
|
*/
|
|
|
private void readSectionPrice(Cell cellQty, Cell cellPrice, List<GoodsQtyPrice> prices,
|
|
|
- ReleaseProductByBatch releaseProductByBatch, int r, int num, Double[] priceMaxMinPrice) {
|
|
|
+ ReleaseProductByBatch releaseProductByBatch, int r, int num, Double[] priceMaxMinPrice, int i) {
|
|
|
// 先跟据币别判断对应的价格是否有空值
|
|
|
Object endQtyCellValue = readWorkBookCell(cellQty, Cell.CELL_TYPE_STRING, r, num);
|
|
|
+ releaseProductByBatch.setFragmentQty(String.valueOf(endQtyCellValue), i);
|
|
|
+
|
|
|
+ Object priceCellValue = readWorkBookCell(cellPrice, Cell.CELL_TYPE_STRING, r, num + 1);
|
|
|
+ releaseProductByBatch.setFragmentPrice(String.valueOf(priceCellValue), i);
|
|
|
if ((endQtyCellValue != null)&&(isNumber(endQtyCellValue.toString()))) {
|
|
|
Double end = Double.valueOf(endQtyCellValue.toString());
|
|
|
GoodsQtyPrice qtyPrice = new GoodsQtyPrice();
|
|
|
- // 分段数量start不得大于库存量
|
|
|
- if (end > releaseProductByBatch.getReserve() || end <= 0) {
|
|
|
- releaseProductByBatch.addErrmsg(num + ": 分段数量存在结束值大于库存量或者结束值小于0");
|
|
|
+ // 分段结束值 与最小库存比较
|
|
|
+ if (NumberUtil.compare(end, DoubleConstant.minReserve) < 1) {
|
|
|
+ return ;
|
|
|
}
|
|
|
qtyPrice.setEnd(end);
|
|
|
|
|
|
Double price = null;
|
|
|
- Object priceCellValue = readWorkBookCell(cellPrice, Cell.CELL_TYPE_STRING, r, num + 1);
|
|
|
- if ((priceCellValue != null)&&(isNumber(priceCellValue.toString()))) {
|
|
|
+ if((priceCellValue != null)&&(isNumber(priceCellValue.toString()))) {
|
|
|
price = Double.valueOf(priceCellValue.toString());
|
|
|
}
|
|
|
- if (price != null && price > 0.0) {
|
|
|
+ if ((price != null) && (NumberUtil.compare(price, DoubleConstant.zero) > 0)) {
|
|
|
price = fractionNumCeil(price, 6);
|
|
|
if(Currency.USD.equals(releaseProductByBatch.getCurrency())) {
|
|
|
qtyPrice.setUSDPrice(price);
|
|
|
qtyPrice.setUSDNTPrice(price);
|
|
|
- if(priceMaxMinPrice[2] > price) {
|
|
|
- priceMaxMinPrice[2] = price;
|
|
|
- }
|
|
|
- if(priceMaxMinPrice[3] < price) {
|
|
|
- priceMaxMinPrice[3] = price;
|
|
|
- }
|
|
|
}else {
|
|
|
qtyPrice.setRMBPrice(price);
|
|
|
BigDecimal taxNum = new BigDecimal(releaseProductByBatch.getRmbTaxRate() + 1);
|
|
|
qtyPrice.setRMBNTPrice(new BigDecimal(price).divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
- if(priceMaxMinPrice[0] > price) {
|
|
|
- priceMaxMinPrice[0] = price;
|
|
|
- }
|
|
|
- if(priceMaxMinPrice[1] < price) {
|
|
|
- priceMaxMinPrice[1] = price;
|
|
|
- }
|
|
|
}
|
|
|
+ priceMaxMinPrice[0] = NumberUtil.compare(priceMaxMinPrice[0], price) > 0 ? price : priceMaxMinPrice[0];
|
|
|
+ priceMaxMinPrice[1] = NumberUtil.compare(priceMaxMinPrice[1], price) < 0 ? price : priceMaxMinPrice[1];
|
|
|
prices.add(qtyPrice);
|
|
|
}
|
|
|
}
|