|
|
@@ -359,7 +359,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
// 分段数量
|
|
|
List<GoodsQtyPrice> prices = new ArrayList<GoodsQtyPrice>();
|
|
|
Double[] priceMaxMinPrice = {Double.MAX_VALUE, Double.MIN_VALUE}; //最小价格,最大价格
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
+ for(int i = 0; i < 3; i++) {
|
|
|
//起始量必须等于最小起定量
|
|
|
readSectionPrice(row.getCell(12 + 2 * i), row.getCell(13 + 2 * i),
|
|
|
prices, releaseProductByBatch, r, (12 + 2 * i), priceMaxMinPrice, i);
|
|
|
@@ -462,37 +462,23 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* 分析分段的价格
|
|
|
*/
|
|
|
private List<GoodsQtyPrice> setPricesQty(List<GoodsQtyPrice> prices, ReleaseProductByBatch productByBatch) {
|
|
|
- GoodsQtyPrice[] array = new GoodsQtyPrice[prices.size()];
|
|
|
- prices.toArray(array);
|
|
|
- Arrays.sort(array, new Comparator<GoodsQtyPrice>() {
|
|
|
- @Override
|
|
|
- public int compare(GoodsQtyPrice o1, GoodsQtyPrice o2) {
|
|
|
- return NumberUtil.compare(o1.getEnd(), o2.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) > -1) {
|
|
|
- price.setStart(DoubleConstant.minReserve);
|
|
|
- prices2.add(price);
|
|
|
- }
|
|
|
- }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);
|
|
|
+ for (int j = 0; j < prices.size(); j++) {
|
|
|
+ GoodsQtyPrice price = prices.get(j);
|
|
|
+ if(j == prices.size() - 1) {
|
|
|
+ if(NumberUtil.compare(price.getStart(), DoubleConstant.maxReserve) > 0) {
|
|
|
+ productByBatch.addErrmsg("12:分段数量超过了我们设置的最大值");
|
|
|
}
|
|
|
- }else if (j == prices1.size() - 1) {
|
|
|
price.setEnd(DoubleConstant.maxReserve);
|
|
|
- if(prices1.size() == 1) {
|
|
|
- price.setStart(DoubleConstant.minReserve);
|
|
|
+ prices2.add(price);
|
|
|
+ }else if(j < prices.size() - 1) {
|
|
|
+ GoodsQtyPrice qtyPrice = prices.get(j + 1);
|
|
|
+ if(NumberUtil.compare(qtyPrice.getStart(), price.getStart()) > 0) {
|
|
|
+ price.setStart(NumberUtil.sub(qtyPrice.getStart(), 1.0d));
|
|
|
+ prices2.add(price);
|
|
|
}else {
|
|
|
- price.setStart(NumberUtil.add(prices1.get(j - 1).getEnd(), 1.0d));
|
|
|
+ productByBatch.addErrmsg("8-12:后一个分段数量的起始值必须大于前一个分段的起始值");
|
|
|
}
|
|
|
- prices2.add(price);
|
|
|
}
|
|
|
}
|
|
|
return prices2;
|
|
|
@@ -697,19 +683,29 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
private void readSectionPrice(Cell cellQty, Cell cellPrice, List<GoodsQtyPrice> prices,
|
|
|
ReleaseProductByBatch releaseProductByBatch, int r, int num, Double[] priceMaxMinPrice, int i) {
|
|
|
// 先跟据币别判断对应的价格是否有空值
|
|
|
- Object endQtyCellValue = readWorkBookCell(cellQty, Cell.CELL_TYPE_STRING, r, num);
|
|
|
- releaseProductByBatch.setFragmentQty(StringUtilB2C.getStr(endQtyCellValue), i);
|
|
|
+ Object startQtyCellValue = readWorkBookCell(cellQty, Cell.CELL_TYPE_STRING, r, num);
|
|
|
+ releaseProductByBatch.setFragmentQty(StringUtilB2C.getStr(startQtyCellValue), i);
|
|
|
|
|
|
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());
|
|
|
+ if ((startQtyCellValue != null)&&(isNumber(startQtyCellValue.toString())) && (NumberUtil.compare(Double.valueOf(startQtyCellValue.toString()), 0.0d) > 0)) {
|
|
|
+ Double start = Double.valueOf(startQtyCellValue.toString());
|
|
|
GoodsQtyPrice qtyPrice = new GoodsQtyPrice();
|
|
|
// 分段结束值 与最小库存比较
|
|
|
- if (NumberUtil.compare(end, DoubleConstant.minReserve) < 0) {
|
|
|
- return ;
|
|
|
+ if(releaseProductByBatch.getMinBuyQty() != null) {
|
|
|
+ if ((NumberUtil.compare(start, releaseProductByBatch.getMinBuyQty()) < 0) && (i != 0)) {
|
|
|
+ releaseProductByBatch.addErrmsg((num + 1) + ":分段数量必须大于起订量");
|
|
|
+ }else if((i == 0) && (NumberUtil.compare(start, releaseProductByBatch.getMinBuyQty()) > 0)) {
|
|
|
+ releaseProductByBatch.addErrmsg((num + 1) + ":分段数量必须小于等于起订量");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(NumberUtil.compare(start, DoubleConstant.minReserve) < 0) {
|
|
|
+ releaseProductByBatch.addErrmsg((num + 1) + ":分段数量必须大于" + 1);
|
|
|
+ }else if(NumberUtil.compare(start, DoubleConstant.maxReserve) > 0){
|
|
|
+ releaseProductByBatch.addErrmsg((num + 1) + ":分段数量必须小于" + DoubleConstant.maxReserve);
|
|
|
}
|
|
|
- qtyPrice.setEnd(end);
|
|
|
+
|
|
|
+ qtyPrice.setStart(start);
|
|
|
|
|
|
Double price = null;
|
|
|
if((priceCellValue != null)&&(isNumber(priceCellValue.toString()))) {
|