|
|
@@ -1,6 +1,15 @@
|
|
|
package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
|
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
+import com.uas.platform.b2c.common.account.service.EnterpriseService;
|
|
|
+import com.uas.platform.b2c.common.base.dao.CommonDao;
|
|
|
+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;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
@@ -8,16 +17,15 @@ import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
|
-import com.uas.platform.b2c.common.base.dao.CommonDao;
|
|
|
-import com.uas.platform.b2c.core.config.SysConf;
|
|
|
+import com.uas.platform.b2c.prod.commodity.type.ReleaseConstant;
|
|
|
import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
|
|
|
-import com.uas.platform.b2c.prod.store.dao.StoreInDao;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
-import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
+import com.uas.platform.b2c.prod.store.model.StoreStatus;
|
|
|
+import com.uas.platform.b2c.prod.store.service.StoreInService;
|
|
|
+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.*;
|
|
|
@@ -60,11 +68,14 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
private CommonDao commonDao;
|
|
|
|
|
|
@Autowired
|
|
|
- private StoreInDao storeInDao;
|
|
|
+ private StoreInService storeInService;
|
|
|
|
|
|
@Autowired
|
|
|
private SysConf SysConf;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private EnterpriseService enterpriseService;
|
|
|
+
|
|
|
@Override
|
|
|
public ReleaseProductByBatch save(ReleaseProductByBatch releaseProductByBatch) {
|
|
|
return releaseProductByBatch;
|
|
|
@@ -76,355 +87,288 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @author hejq
|
|
|
*/
|
|
|
@Override
|
|
|
- public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale) {
|
|
|
+ public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency) {
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<ReleaseProductByBatch>();
|
|
|
+ Pattern codePattern = Pattern.compile(RegexConstant.EnglishAnDigitAndSpecialCharacter);
|
|
|
+ Pattern chineseAndEnglishPattern = Pattern.compile(RegexConstant.chineseAndEnglish);
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
- if(colNum != 25) {
|
|
|
+ if(colNum != 19 && colNum != 20) {
|
|
|
throw new IllegalOperatorException("您上传的信息列信息不正确,请与模板的列做比较");
|
|
|
}
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
|
|
|
- String storeid = null;
|
|
|
- if(selfSale) {
|
|
|
- List<StoreIn> storeIns = storeInDao.findByEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- if(CollectionUtils.isEmpty(storeIns)) {
|
|
|
- throw new IllegalOperatorException("您还没有开店铺,不能选择店铺自营。");
|
|
|
- }else {
|
|
|
- storeid = storeIns.get(0).getUuid();
|
|
|
- }
|
|
|
- }else {
|
|
|
- storeid = SysConf.getStoreid();
|
|
|
- }
|
|
|
+ StoreIn storeIn = getStoreInfo(selfSale);
|
|
|
+ String storeid = storeIn.getUuid(), storeName = storeIn.getStoreName();
|
|
|
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);
|
|
|
// 英文品牌名称
|
|
|
- total++;
|
|
|
if (row != null && row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
+ total++;
|
|
|
ReleaseProductByBatch releaseProductByBatch = new ReleaseProductByBatch();
|
|
|
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) || "UAS1".equals(cellValue) || "UAS2".equals(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("示例优软商城品牌1".equals(brandNameCnCellValue) || "示例优软商城品牌2".equals(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) || "B2C1".equals(brandNameCnCellValue) || "B2C2".equals(brandNameCnCellValue)) {
|
|
|
- continue;
|
|
|
+ releaseProductByBatch.setCode(String.valueOf(codeCellValue));
|
|
|
+ if(!StringUtils.isEmpty(codeCellValue)) {
|
|
|
+ String code = codeCellValue.toString();
|
|
|
+ Matcher matcher = codePattern.matcher(code);
|
|
|
+ if(!matcher.find()) {
|
|
|
+ releaseProductByBatch.addErrmsg("3:产品型号仅限英文、数字、特殊字符");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 可拆卖
|
|
|
+ Object breakUpCellValue = readWorkBookCell(row.getCell(3), Cell.CELL_TYPE_STRING, r, 3);
|
|
|
+ releaseProductByBatch.setBreakUpStr(String.valueOf(breakUpCellValue));
|
|
|
+ if (!StringUtils.isEmpty(breakUpCellValue)&&(ReleaseConstant.YES.equals(breakUpCellValue.toString()))) {
|
|
|
+ releaseProductByBatch.setBreakUp(Boolean.TRUE);
|
|
|
}else {
|
|
|
- releaseProductByBatch.setCode(codeCellValue.toString());
|
|
|
+ releaseProductByBatch.setBreakUp(Boolean.FALSE);
|
|
|
}
|
|
|
|
|
|
// 库存类型
|
|
|
- Object originialCellValue = readWorkBookCell(row.getCell(3), Cell.CELL_TYPE_STRING, r, 3);
|
|
|
- if (StringUtils.isEmpty(originialCellValue)
|
|
|
- || ((!"现货".equals(originialCellValue)) && (!"呆滞库存".equals(originialCellValue)))) {
|
|
|
- releaseProductByBatch.addErrmsg("4:库存类型为空,或者没有选择现货或者呆滞库存");
|
|
|
- } 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(4), Cell.CELL_TYPE_NUMERIC, r, 4);
|
|
|
- if (reserveCellValue == null || Double.valueOf(reserveCellValue.toString()).doubleValue() <= 0) {
|
|
|
- releaseProductByBatch.addErrmsg("5:发布数量为空或者小于等于0");
|
|
|
+ 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("5:发布数量为空或者不是数字");
|
|
|
} else {
|
|
|
reserve = Double.valueOf(reserveCellValue.toString());
|
|
|
- int compareTo = reserve.compareTo(99999999d);
|
|
|
+ int compareTo = reserve.compareTo(DoubleConstant.maxReserve);
|
|
|
if(compareTo > 0) {
|
|
|
- releaseProductByBatch.addErrmsg("5:发布数量大于了我们设置的最大值99999999");
|
|
|
+ releaseProductByBatch.addErrmsg("6:发布数量大于了我们设置的最大值99999999");
|
|
|
+ }else if(NumberUtil.compare(reserve, DoubleConstant.zero) < 1) {
|
|
|
+ releaseProductByBatch.addErrmsg("6:发布数量必须大于0");
|
|
|
}
|
|
|
releaseProductByBatch.setReserve(reserve);
|
|
|
}
|
|
|
|
|
|
+ // 生产日期
|
|
|
+ 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(5), Cell.CELL_TYPE_STRING, r, 5);
|
|
|
+ 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("6:包装方式不能为空");
|
|
|
+ releaseProductByBatch.addErrmsg("7:包装方式不能为空");
|
|
|
} else {
|
|
|
- releaseProductByBatch.setPackaging(packagingCellValue.toString());
|
|
|
+ packaging = packagingCellValue.toString();
|
|
|
+ Matcher matcher = chineseAndEnglishPattern.matcher(packaging);
|
|
|
+ if(!matcher.find()) {
|
|
|
+ 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);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// // 这个是没有输入数据默认为null
|
|
|
+// releaseProductByBatch.setMinPackage((double) 0);
|
|
|
+// }
|
|
|
+
|
|
|
//封装方式
|
|
|
- Object encapsulationCellValue = readWorkBookCell(row.getCell(6), Cell.CELL_TYPE_STRING, r, 6);
|
|
|
- releaseProductByBatch.setEncapsulation(String.valueOf(encapsulationCellValue));
|
|
|
-
|
|
|
- Double sample = null;
|
|
|
- Object sampleObj = readWorkBookCell(row.getCell(7), Cell.CELL_TYPE_NUMERIC, r, 7);
|
|
|
- if (sampleObj != null) {
|
|
|
- sample = Double.valueOf(sampleObj.toString());
|
|
|
- if (sample <= 0) {
|
|
|
- // 这个是存在输入数据后再删除就会默认成0
|
|
|
- releaseProductByBatch.setSampleqty((double) 0);
|
|
|
- } else {
|
|
|
- releaseProductByBatch.setSampleqty(sample);
|
|
|
+// 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 minBuyCellValue = readWorkBookCell(row.getCell(8), Cell.CELL_TYPE_NUMERIC, r, 8);
|
|
|
- if (minBuyCellValue != null) {
|
|
|
+ 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("9:最小起订量的数量不能是负数");
|
|
|
- } 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("9:最小起订量的数量不能大于库存的数量");
|
|
|
+ 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("9:最小起订量的数量不可以为空");
|
|
|
- }
|
|
|
-
|
|
|
- // 最小包装量
|
|
|
- Object minPackQtyCellValue = readWorkBookCell(row.getCell(9), Cell.CELL_TYPE_NUMERIC, r, 9);
|
|
|
- if (minPackQtyCellValue != null) {
|
|
|
- Double minPackQty = Double.valueOf(minPackQtyCellValue.toString());
|
|
|
- if (minPackQty <= 0) {
|
|
|
- // 输入负数
|
|
|
- releaseProductByBatch.addErrmsg("10:最小包装量的数量不能是负数");
|
|
|
- } else {
|
|
|
- releaseProductByBatch.setMinPackage(minPackQty);
|
|
|
}
|
|
|
}else {
|
|
|
- releaseProductByBatch.addErrmsg("10:最小包装量不可以为空");
|
|
|
- }
|
|
|
-
|
|
|
- // 最小包单价(人民币)
|
|
|
- Object rmbPriceMinPackQtyCellValue = readWorkBookCell(row.getCell(10), Cell.CELL_TYPE_NUMERIC, r, 10);
|
|
|
- if (rmbPriceMinPackQtyCellValue != null) {
|
|
|
- Double rmbPrice = Double.valueOf(rmbPriceMinPackQtyCellValue.toString());
|
|
|
- rmbPrice = fractionNumCeil(rmbPrice, 6);
|
|
|
- releaseProductByBatch.setRmbMinPackPrice(rmbPrice);
|
|
|
- }
|
|
|
-
|
|
|
- // 最小包单价(美元)
|
|
|
- Object usdPriceMinPackQtyCellValue = readWorkBookCell(row.getCell(11), Cell.CELL_TYPE_NUMERIC, r, 11);
|
|
|
- if (usdPriceMinPackQtyCellValue != null) {
|
|
|
- Double usdPrice = Double.valueOf(usdPriceMinPackQtyCellValue.toString());
|
|
|
- usdPrice = fractionNumCeil(usdPrice, 6);
|
|
|
- releaseProductByBatch.setUsdMinPackPrice(usdPrice);
|
|
|
+ releaseProductByBatch.setMinBuyQty(releaseProductByBatch.getMinPackage());
|
|
|
}
|
|
|
|
|
|
// 确认币别
|
|
|
- Double rmbMinPackPrice = releaseProductByBatch.getRmbMinPackPrice();
|
|
|
- Double usdMinPackPrice = releaseProductByBatch.getUsdMinPackPrice();
|
|
|
- if (rmbMinPackPrice == null && usdMinPackPrice == null) {
|
|
|
- releaseProductByBatch.addErrmsg("10-11:最小包单价至少填一种价格");
|
|
|
- } else if (rmbMinPackPrice != null && usdMinPackPrice == null) {
|
|
|
- releaseProductByBatch.setCurrency("RMB");
|
|
|
- releaseProductByBatch.setRmbTaxRate(0.17d);
|
|
|
- } else if (rmbMinPackPrice == null && usdMinPackPrice != null) {
|
|
|
+ if(Currency.USD.equals(currency)) {
|
|
|
releaseProductByBatch.setCurrency("USD");
|
|
|
releaseProductByBatch.setUsdTaxRate(0d);
|
|
|
- } else {
|
|
|
- releaseProductByBatch.setCurrency("RMB-USD");
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setCurrency("RMB");
|
|
|
releaseProductByBatch.setRmbTaxRate(0.17d);
|
|
|
- releaseProductByBatch.setUsdTaxRate(0d);
|
|
|
- }
|
|
|
-
|
|
|
- // 生产日期
|
|
|
- Object produceDateCellValue = readWorkBookCell(row.getCell(12), Cell.CELL_TYPE_STRING, r, 12);
|
|
|
- if (produceDateCellValue == null) {
|
|
|
- releaseProductByBatch.addErrmsg("13:产品生产日期不可以为空");
|
|
|
- } else {
|
|
|
- releaseProductByBatch.setProductDate(String.valueOf(produceDateCellValue));
|
|
|
}
|
|
|
|
|
|
- //交期时间
|
|
|
- if(releaseProductByBatch.getCurrency() != null) {
|
|
|
- Object deliveryCellValue = readWorkBookCell(row.getCell(13), Cell.CELL_TYPE_STRING, r, 13);
|
|
|
- if (!StringUtils.isEmpty(deliveryCellValue)) {
|
|
|
- Short[] delivers = splitDeliveryString(deliveryCellValue.toString());
|
|
|
- if (delivers != null) {
|
|
|
- releaseProductByBatch.setB2cMinDelivery(delivers[0]);
|
|
|
- releaseProductByBatch.setB2cMaxDelivery(delivers[1]);
|
|
|
-
|
|
|
- Boolean aBoolean = deliveryTimeBetween(releaseProductByBatch.getB2cMaxDelivery(), (short) 0, (short) 9);
|
|
|
- if(!aBoolean) {
|
|
|
- releaseProductByBatch.addErrmsg("14:交期的不在(0,9]天");
|
|
|
- }
|
|
|
- Boolean bBoolean = deliveryTimeBetween(releaseProductByBatch.getB2cMinDelivery(), (short) 0, (short) 9);
|
|
|
- if(!bBoolean) {
|
|
|
- releaseProductByBatch.addErrmsg("14:交期的不在(0,9]天");
|
|
|
- }
|
|
|
- }
|
|
|
+ // 最小包单价
|
|
|
+ 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);
|
|
|
+ if(Currency.USD.equals(currency)) {
|
|
|
+ releaseProductByBatch.setUsdMinPackPrice(price);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setRmbMinPackPrice(price);
|
|
|
}
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.addErrmsg("10:最小包单价信息为空");
|
|
|
}
|
|
|
|
|
|
-// // 大陆交期
|
|
|
-// if(releaseProductByBatch.getCurrency() != null && releaseProductByBatch.getCurrency().contains("RMB")) {
|
|
|
-// Object deliveryCellValue = readWorkBookCell(row.getCell(13), Cell.CELL_TYPE_STRING, r, 13);
|
|
|
-// if (!StringUtils.isEmpty(deliveryCellValue)) {
|
|
|
-// Short[] delivers = splitDeliveryString(deliveryCellValue.toString());
|
|
|
-// if (delivers != null) {
|
|
|
-// releaseProductByBatch.setMindeliveryDemTime(delivers[0]);
|
|
|
-// releaseProductByBatch.setMaxdeliveryDemTime(delivers[1]);
|
|
|
-//
|
|
|
-// Boolean aBoolean = deliveryTimeBetween(releaseProductByBatch.getMaxdeliveryDemTime(), (short) 0, (short) 9);
|
|
|
-// if(!aBoolean) {
|
|
|
-// releaseProductByBatch.addErrmsg("14:大陆交期的不在(0,9]天");
|
|
|
-// }
|
|
|
-// Boolean bBoolean = deliveryTimeBetween(releaseProductByBatch.getMindeliveryDemTime(), (short) 0, (short) 9);
|
|
|
-// if(!bBoolean) {
|
|
|
-// releaseProductByBatch.addErrmsg("14:大陆交期的不在(0,9]天");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 香港交期
|
|
|
-// if(releaseProductByBatch.getCurrency() != null && releaseProductByBatch.getCurrency().contains("USD")) {
|
|
|
-// Object deliveryhkCellValue = readWorkBookCell(row.getCell(14), Cell.CELL_TYPE_STRING, r, 14);
|
|
|
-// if (!StringUtils.isEmpty(deliveryhkCellValue)) {
|
|
|
-// Short[] deliverys = splitDeliveryString(deliveryhkCellValue.toString());
|
|
|
-// if (deliverys != null) {
|
|
|
-// releaseProductByBatch.setMindeliveryHKTime(deliverys[0]);
|
|
|
-// releaseProductByBatch.setMaxdeliveryHKTime(deliverys[1]);
|
|
|
-//
|
|
|
-// Boolean aBoolean = deliveryTimeBetween(releaseProductByBatch.getMindeliveryHKTime(), (short) 0, (short) 9);
|
|
|
-// if(!aBoolean) {
|
|
|
-// releaseProductByBatch.addErrmsg("15:香港交期的不在(0,9]天");
|
|
|
-// }
|
|
|
-// Boolean bBoolean = deliveryTimeBetween(releaseProductByBatch.getMaxdeliveryHKTime(), (short) 0, (short) 9);
|
|
|
-// if(!bBoolean) {
|
|
|
-// releaseProductByBatch.addErrmsg("15:香港交期的不在(0,9]天");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
- if (releaseProductByBatch.getB2cMaxDelivery() == null) {
|
|
|
- releaseProductByBatch.addErrmsg("14-15:您必须填写交期时间");
|
|
|
+ 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("11-12:存在交期的信息为空");
|
|
|
+ }else {
|
|
|
+ setDeliveryTime(releaseProductByBatch, deliveryMinCellValue, deliveryMaxCellValue);
|
|
|
}
|
|
|
|
|
|
-// if("RMB-USD".equals(releaseProductByBatch.getCurrency())) {
|
|
|
-// if(releaseProductByBatch.getMaxdeliveryDemTime() == null || releaseProductByBatch.getMaxdeliveryHKTime() == null) {
|
|
|
-// releaseProductByBatch.addErrmsg("14-15:您上架的币别是人民币和美金,所以香港和大陆的交期都需要填写");
|
|
|
-// }
|
|
|
-// }else if("RMB".equals(releaseProductByBatch.getCurrency())) {
|
|
|
-// if(releaseProductByBatch.getMaxdeliveryDemTime() == null) {
|
|
|
-// releaseProductByBatch.addErrmsg("14-15:您上架的币别是人民币,所以大陆交期需要填写");
|
|
|
-// }
|
|
|
-// }else if("USD".equals(releaseProductByBatch.getCurrency())) {
|
|
|
-// if(releaseProductByBatch.getMaxdeliveryHKTime() == null) {
|
|
|
-// releaseProductByBatch.addErrmsg("14-15:您上架的币别是美金,所以香港交期需要填写");
|
|
|
-// }
|
|
|
-// }else {
|
|
|
-// if(releaseProductByBatch.getMaxdeliveryHKTime() == null && releaseProductByBatch.getMaxdeliveryHKTime() == null) {
|
|
|
-// releaseProductByBatch.addErrmsg("14-15:您必须要填写一个类型的交期");
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
// 分段数量
|
|
|
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(15 + 3 * i), row.getCell(16 + 3 * i), row.getCell(17 + 3 * i),
|
|
|
- prices, releaseProductByBatch, r, (15 + 3 * 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)) {
|
|
|
- double start = -1;
|
|
|
- for (int j = 0; j < prices.size(); j++) {
|
|
|
- GoodsQtyPrice price = prices.get(j);
|
|
|
- if(j == 0) {
|
|
|
- int val = price.getStart().compareTo(releaseProductByBatch.getMinBuyQty());
|
|
|
- if(val != 0) {
|
|
|
- releaseProductByBatch.addErrmsg("16:第一个分段数量的起始值与最小起订量不相等");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 判断输入的后一个分段是否大于前一个分段
|
|
|
- if (start < price.getStart()) {
|
|
|
- start = price.getStart();
|
|
|
- } else {
|
|
|
- releaseProductByBatch.addErrmsg("16:分段数量起始值存在后一个分段的开始值小于前一个分段的开始值");
|
|
|
- }
|
|
|
-
|
|
|
- if (j < prices.size() - 1) {
|
|
|
- price.setEnd(prices.get(j + 1).getStart() - 1);
|
|
|
- }
|
|
|
- if (j == prices.size() - 1) {
|
|
|
- price.setEnd(reserve);
|
|
|
- }
|
|
|
- }
|
|
|
+ prices = setPricesQty(prices, releaseProductByBatch);
|
|
|
} else {
|
|
|
// 如果未填分段价格,默认为最小包装量价格
|
|
|
GoodsQtyPrice qtyPrice = new GoodsQtyPrice();
|
|
|
- qtyPrice.setStart(releaseProductByBatch.getMinBuyQty());
|
|
|
- if (rmbMinPackPrice != null) {
|
|
|
- qtyPrice.setRMBPrice(rmbMinPackPrice);
|
|
|
- BigDecimal priceNum = new BigDecimal(rmbMinPackPrice);
|
|
|
- BigDecimal taxNum = new BigDecimal(releaseProductByBatch.getRmbTaxRate() + 1);
|
|
|
- qtyPrice.setRMBNTPrice(priceNum.divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
- priceMaxMinPrice[0] = rmbMinPackPrice;
|
|
|
- priceMaxMinPrice[1] = rmbMinPackPrice;
|
|
|
- }
|
|
|
- if (usdMinPackPrice != null) {
|
|
|
- qtyPrice.setUSDPrice(usdMinPackPrice);
|
|
|
- qtyPrice.setUSDNTPrice(usdMinPackPrice);
|
|
|
- priceMaxMinPrice[2] = usdMinPackPrice;
|
|
|
- priceMaxMinPrice[3] = usdMinPackPrice;
|
|
|
+ qtyPrice.setStart(DoubleConstant.minReserve);
|
|
|
+ if(Currency.USD.equals(releaseProductByBatch.getCurrency())) {
|
|
|
+ Double usdMinPackPrice = releaseProductByBatch.getUsdMinPackPrice();
|
|
|
+ if(usdMinPackPrice != null) {
|
|
|
+ qtyPrice.setUSDPrice(usdMinPackPrice);
|
|
|
+ qtyPrice.setUSDNTPrice(usdMinPackPrice);
|
|
|
+ priceMaxMinPrice[0] = usdMinPackPrice;
|
|
|
+ priceMaxMinPrice[1] = usdMinPackPrice;
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ Double rmbMinPackPrice = releaseProductByBatch.getRmbMinPackPrice();
|
|
|
+ if(rmbMinPackPrice != null) {
|
|
|
+ qtyPrice.setRMBPrice(rmbMinPackPrice);
|
|
|
+ BigDecimal priceNum = new BigDecimal(rmbMinPackPrice);
|
|
|
+ BigDecimal taxNum = new BigDecimal(releaseProductByBatch.getRmbTaxRate() + 1);
|
|
|
+ qtyPrice.setRMBNTPrice(priceNum.divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
+ 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)) {
|
|
|
- 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]);
|
|
|
+ if(Currency.USD.equals(releaseProductByBatch.getCurrency())) {
|
|
|
+ if(NumberUtil.compare(priceMaxMinPrice[0], Double.MAX_VALUE) == 0) {
|
|
|
+ releaseProductByBatch.setMinPriceUSD(null);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setMinPriceUSD(priceMaxMinPrice[0]);
|
|
|
+ }
|
|
|
+ if(NumberUtil.compare(priceMaxMinPrice[1], Double.MIN_VALUE) == 0) {
|
|
|
+ releaseProductByBatch.setMaxPriceUSD(null);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setMaxPriceUSD(priceMaxMinPrice[1]);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(NumberUtil.compare(priceMaxMinPrice[0], Double.MAX_VALUE) == 0) {
|
|
|
+ releaseProductByBatch.setMinPriceRMB(null);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setMinPriceRMB(priceMaxMinPrice[0]);
|
|
|
+ }
|
|
|
+ if(NumberUtil.compare(priceMaxMinPrice[1], Double.MIN_VALUE) == 0) {
|
|
|
+ releaseProductByBatch.setMaxPriceRMB(null);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.setMaxPriceRMB(priceMaxMinPrice[1]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 备注
|
|
|
- Object remarkCellValue = readWorkBookCell(row.getCell(23), Cell.CELL_TYPE_STRING, r, 23);
|
|
|
+ Object remarkCellValue = readWorkBookCell(row.getCell(20), Cell.CELL_TYPE_STRING, r, 20);
|
|
|
if (!StringUtils.isEmpty(remarkCellValue)) {
|
|
|
String remark = remarkCellValue.toString();
|
|
|
releaseProductByBatch.setRemark(remark);
|
|
|
@@ -435,13 +379,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
releaseProductByBatch.setPublisherTel(SystemSession.getUser().getUserTel());
|
|
|
releaseProductByBatch.setPublisherUu(SystemSession.getUser().getUserUU());
|
|
|
releaseProductByBatch.setStoreid(storeid);
|
|
|
- StoreIn storeIn = storeInDao.findByUuid(storeid);
|
|
|
- if (storeIn == null) {
|
|
|
- throw new IllegalOperatorException("店铺不存在");
|
|
|
-
|
|
|
+ releaseProductByBatch.setStoreName(storeName);
|
|
|
+ if(!StringUtils.isEmpty(releaseProductByBatch.getErrmsg())) {
|
|
|
+ releaseProductByBatch.setReleaseCode(ReleaseStatus.failure.value());
|
|
|
+ releaseProductByBatch.setReleaseStatus(ReleaseStatus.failure.getPhrase());
|
|
|
}
|
|
|
- releaseProductByBatch.setStoreName(storeIn.getStoreName());
|
|
|
-
|
|
|
releaseProductByBatch.setUnit("PCS");
|
|
|
releaseProductByBatch.setCreateDate(new Date());
|
|
|
releaseProductByBatchs.add(releaseProductByBatch);
|
|
|
@@ -462,6 +404,112 @@ 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) > 0) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取店铺的信息
|
|
|
+ * @param selfSale
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private StoreIn getStoreInfo(Boolean selfSale) {
|
|
|
+ StoreIn storeIn = null;
|
|
|
+ if(selfSale) {
|
|
|
+ storeIn = storeInService.findByEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ if((storeIn == null) || (storeIn.getStatus() != StoreStatus.OPENED)) {
|
|
|
+ throw new IllegalOperatorException("您的公司还为开店,不能选择自营");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ storeIn = storeInService.findByUuid(SysConf.getStoreid());
|
|
|
+ }
|
|
|
+ return storeIn;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean isNumber(String str) {
|
|
|
+ Pattern numberPattern = Pattern.compile(RegexConstant.NumberData);
|
|
|
+ Matcher matcher = numberPattern.matcher(str);
|
|
|
+ if(matcher.find()) {
|
|
|
+ return true;
|
|
|
+ }else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置交期的信息
|
|
|
+ */
|
|
|
+ private void setDeliveryTime(ReleaseProductByBatch releaseProductByBatch, Object minDelivery, Object maxDelivery) {
|
|
|
+ minDelivery = minDelivery == null ? maxDelivery : minDelivery;
|
|
|
+ maxDelivery = maxDelivery == null ? minDelivery : maxDelivery;
|
|
|
+ Pattern intMinP = Pattern.compile(RegexConstant.Integer);
|
|
|
+ Matcher intMinM = intMinP.matcher(minDelivery.toString());
|
|
|
+ Short min = null, max = null;
|
|
|
+ if(intMinM.find()) {
|
|
|
+ String g = intMinM.group();
|
|
|
+ min = Short.valueOf(g);
|
|
|
+ }
|
|
|
+ Pattern intMaxP = Pattern.compile(RegexConstant.Integer);
|
|
|
+ Matcher intMaxM = intMaxP.matcher(maxDelivery.toString());
|
|
|
+ if(intMaxM.find()) {
|
|
|
+ String g = intMaxM.group();
|
|
|
+ max = Short.valueOf(g);
|
|
|
+ }
|
|
|
+ if((min != null) || (max != null)) {
|
|
|
+ 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("11-12:交期的信息必须为正整数并且小于" + ShortConstant.maxDelivery);
|
|
|
+ }else {
|
|
|
+ if(min.shortValue() > max.shortValue()) {
|
|
|
+ Short delivery = max;
|
|
|
+ max = min;
|
|
|
+ min = delivery;
|
|
|
+ }
|
|
|
+ releaseProductByBatch.setSelfMinDelivery(min);
|
|
|
+ releaseProductByBatch.setSelfMaxDelivery(max);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.addErrmsg("11-12:交期的信息必须为正整数并且小于" + ShortConstant.maxDelivery);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 创建时间 :2016年12月11日 下午2:02:16
|
|
|
*
|
|
|
* @author yujia
|
|
|
@@ -574,8 +622,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
*
|
|
|
* @author yujia
|
|
|
* @param cellQty
|
|
|
- * @param cellPriceRMB
|
|
|
- * @param cellPriceUSD
|
|
|
+ * @param cellPrice
|
|
|
* @param prices
|
|
|
* @param releaseProductByBatch
|
|
|
* @param r
|
|
|
@@ -585,85 +632,41 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* 获取每一个分段的的数量
|
|
|
*
|
|
|
*/
|
|
|
- private void readSectionPrice(Cell cellQty, Cell cellPriceRMB, Cell cellPriceUSD, List<GoodsQtyPrice> prices,
|
|
|
- ReleaseProductByBatch releaseProductByBatch, int r, int num, Double[] priceMaxMinPrice) {
|
|
|
+ private void readSectionPrice(Cell cellQty, Cell cellPrice, List<GoodsQtyPrice> prices,
|
|
|
+ ReleaseProductByBatch releaseProductByBatch, int r, int num, Double[] priceMaxMinPrice, int i) {
|
|
|
// 先跟据币别判断对应的价格是否有空值
|
|
|
- Object startQtyCellValue = readWorkBookCell(cellQty, Cell.CELL_TYPE_NUMERIC, r, num);
|
|
|
- if (startQtyCellValue != null) {
|
|
|
- Double start = Double.valueOf(startQtyCellValue.toString());
|
|
|
+ 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 (start > releaseProductByBatch.getReserve() || start <= 0) {
|
|
|
- releaseProductByBatch.addErrmsg("11: 分段数量存在起始值大于库存量或者开始数量小于0");
|
|
|
- }
|
|
|
- qtyPrice.setStart(start);
|
|
|
-
|
|
|
- String currency = releaseProductByBatch.getCurrency();
|
|
|
-
|
|
|
- // 人民币价格
|
|
|
- if(currency != null && currency.contains("RMB")) {
|
|
|
- Double pricermb = null;
|
|
|
- Object pricermbReadWorkBookCellValue = readWorkBookCell(cellPriceRMB, Cell.CELL_TYPE_NUMERIC, r, num+1);
|
|
|
- if (pricermbReadWorkBookCellValue != null) {
|
|
|
- pricermb = Double.valueOf(pricermbReadWorkBookCellValue.toString());
|
|
|
- }
|
|
|
- if (pricermb != null && pricermb > 0.0) {
|
|
|
- pricermb = fractionNumCeil(pricermb, 6);
|
|
|
- qtyPrice.setRMBPrice(pricermb);
|
|
|
- BigDecimal taxNum = new BigDecimal(releaseProductByBatch.getRmbTaxRate() + 1);
|
|
|
- qtyPrice.setRMBNTPrice(new BigDecimal(pricermb).divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
- if(priceMaxMinPrice[0] > pricermb) {
|
|
|
- priceMaxMinPrice[0] = pricermb;
|
|
|
- }
|
|
|
- if(priceMaxMinPrice[1] < pricermb) {
|
|
|
- priceMaxMinPrice[1] = pricermb;
|
|
|
- }
|
|
|
- }
|
|
|
+ // 分段结束值 与最小库存比较
|
|
|
+ if (NumberUtil.compare(end, DoubleConstant.minReserve) < 1) {
|
|
|
+ return ;
|
|
|
}
|
|
|
+ qtyPrice.setEnd(end);
|
|
|
|
|
|
- if(currency != null && currency.contains("USD")) {
|
|
|
- // 美金价格
|
|
|
- Double priceusd = null;
|
|
|
- Object priceusdReadWorkBookCellValue = readWorkBookCell(cellPriceUSD, Cell.CELL_TYPE_NUMERIC, r, num+2);
|
|
|
- if (priceusdReadWorkBookCellValue != null) {
|
|
|
- priceusd = Double.valueOf(priceusdReadWorkBookCellValue.toString());
|
|
|
- }
|
|
|
- if (priceusd != null && priceusd > 0) {
|
|
|
- priceusd = fractionNumCeil(priceusd, 6);
|
|
|
- qtyPrice.setUSDPrice(priceusd);
|
|
|
- qtyPrice.setUSDNTPrice(priceusd);
|
|
|
- if(priceMaxMinPrice[2] > priceusd) {
|
|
|
- priceMaxMinPrice[2] = priceusd;
|
|
|
- }
|
|
|
- if(priceMaxMinPrice[3] < priceusd) {
|
|
|
- priceMaxMinPrice[3] = priceusd;
|
|
|
- }
|
|
|
- }
|
|
|
+ Double price = null;
|
|
|
+ if((priceCellValue != null)&&(isNumber(priceCellValue.toString()))) {
|
|
|
+ price = Double.valueOf(priceCellValue.toString());
|
|
|
}
|
|
|
-
|
|
|
- // 验证信息的一致性
|
|
|
- Double rmbPrice = qtyPrice.getRMBPrice();
|
|
|
- Double usdPrice = qtyPrice.getUSDPrice();
|
|
|
-
|
|
|
- boolean isUnit = true;
|
|
|
- if ("RMB".equalsIgnoreCase(currency)) {
|
|
|
- if (rmbPrice == null) {
|
|
|
- isUnit = false;
|
|
|
- }
|
|
|
- } else if ("RMB-USD".equalsIgnoreCase(currency)) {
|
|
|
- if (rmbPrice == null || usdPrice == null) {
|
|
|
- isUnit = false;
|
|
|
- }
|
|
|
- } else if ("USD".equalsIgnoreCase(currency)) {
|
|
|
- if (usdPrice == null) {
|
|
|
- isUnit = false;
|
|
|
+ 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);
|
|
|
+ }else {
|
|
|
+ qtyPrice.setRMBPrice(price);
|
|
|
+ BigDecimal taxNum = new BigDecimal(releaseProductByBatch.getRmbTaxRate() + 1);
|
|
|
+ qtyPrice.setRMBNTPrice(new BigDecimal(price).divide(taxNum, 6, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
}
|
|
|
+ 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);
|
|
|
}
|
|
|
- if (!isUnit) {
|
|
|
- releaseProductByBatch.addErrmsg("11: 前后的价格信息不一致,例如最小包单价填了人民币和美金,后面的分段只填了人民币");
|
|
|
- }
|
|
|
-
|
|
|
- prices.add(qtyPrice);
|
|
|
}
|
|
|
}
|
|
|
|