|
|
@@ -2,7 +2,6 @@ package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
-import com.uas.platform.b2c.common.account.model.User;
|
|
|
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;
|
|
|
@@ -16,7 +15,11 @@ import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.ShortConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.*;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductPersonDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
|
@@ -26,7 +29,6 @@ import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
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.b2c.trade.presale.model.Collection;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.persistence.criteria.CriterionExpression;
|
|
|
@@ -123,15 +125,18 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @author hejq
|
|
|
*/
|
|
|
@Override
|
|
|
- public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson) {
|
|
|
+ public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport) {
|
|
|
// 是否上传个人物料
|
|
|
boolean isAPerson = false;
|
|
|
+ boolean isImport = false;
|
|
|
if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {
|
|
|
isAPerson = true;
|
|
|
selfSale = false;
|
|
|
}
|
|
|
+ if (null != repeatImport && IntegerConstant.YES_SHORT.equals(repeatImport)) {
|
|
|
+ isImport = true;
|
|
|
+ }
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
- Set<ReleaseProductByBatch> releaseProductByBatchs = new HashSet<>();
|
|
|
// 获取第一个工作表
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
@@ -149,6 +154,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
throw new IllegalOperatorException
|
|
|
("您上传的信息超过2000条,请拆分成2000以再在上传");
|
|
|
}
|
|
|
+ List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<>(rowNum);
|
|
|
String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
|
|
|
StoreIn storeIn = getStoreInfo(selfSale);
|
|
|
Row headerRow = sheet.getRow(0);
|
|
|
@@ -191,6 +197,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
releaseProductByBatch.setTag(null);
|
|
|
}
|
|
|
}
|
|
|
+ validateRepeatInExcel(releaseProductByBatchs, releaseProductByBatch, isImport);
|
|
|
}
|
|
|
// 简单验证数据,防止空行保存的情况
|
|
|
if (blankNum != 3) {
|
|
|
@@ -204,7 +211,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
List<ReleaseProductByBatch> addList = new ArrayList<>(releaseProductByBatchs.size());
|
|
|
addList.addAll(releaseProductByBatchs);
|
|
|
- resetRepeatData(addList, isAPerson);
|
|
|
+ resetRepeatData(addList, isImport, isAPerson);
|
|
|
if (isAPerson) {
|
|
|
for (ReleaseProductByBatch releaseProductByBatch : addList) {
|
|
|
List<Product> productList = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(enUU,releaseProductByBatch.getB2cCode(),
|
|
|
@@ -234,16 +241,49 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return modelMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 验证Excel中数据是否重复
|
|
|
+ *
|
|
|
+ * @param batchList
|
|
|
+ * @param aBatch
|
|
|
+ * @param isImport
|
|
|
+ */
|
|
|
+ private void validateRepeatInExcel(List<ReleaseProductByBatch> batchList, ReleaseProductByBatch aBatch, Boolean isImport) {
|
|
|
+ if (CollectionUtils.isEmpty(batchList) || !StringUtils.isEmpty(aBatch.getErrmsg()))
|
|
|
+ return ;
|
|
|
+ for (ReleaseProductByBatch each : batchList) {
|
|
|
+ if (StringUtils.isEmpty(each.getErrmsg()) && each.equals(aBatch)) {
|
|
|
+ if (!isImport) {
|
|
|
+ aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ if (GoodsUtil.compareWithQtyPrice(each.getPrices(), aBatch.getPrices(), each.getCurrency())) {
|
|
|
+ aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 判断是否重复,重复则重设状态
|
|
|
- * @param data
|
|
|
+ * @param data
|
|
|
+ * @param isImport
|
|
|
*/
|
|
|
- private void resetRepeatData(List<ReleaseProductByBatch> data, boolean isAPerson) {
|
|
|
+ private void resetRepeatData(List<ReleaseProductByBatch> data, Boolean isImport, boolean isAPerson) {
|
|
|
Long enuu = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
|
|
|
if (enuu == null) {
|
|
|
throw new IllegalOperatorException("企业enuu丢失");
|
|
|
}
|
|
|
for (ReleaseProductByBatch each : data) {
|
|
|
+ if (StringUtils.hasText(each.getErrmsg())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
List<Product> standardList = productDao.findMatchStandard(enuu, each.getBrandNameEn(), each.getCode(), IntegerConstant.YES_SHORT);
|
|
|
if (!CollectionUtils.isEmpty(standardList)) {
|
|
|
each.setB2cBranden(standardList.get(0).getPbranden());
|
|
|
@@ -256,6 +296,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (!CollectionUtils.isEmpty(productList)) {
|
|
|
List<Goods> goodsList = goodsDao.findRepeatGoodsInProductId(productList.get(0).getId(), each.getProductDate(), each.getPackaging(), each.getMinPackage(), each.getMinBuyQty(), each.getSelfMaxDelivery(), each.getSelfMinDelivery(), each.getUnit());
|
|
|
if (!CollectionUtils.isEmpty(goodsList)) {
|
|
|
+ if (!isImport) {
|
|
|
+ each.setErrmsg(ErrorInfoConstant.REPEAT_INFO.getInfo());
|
|
|
+ each.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
+ each.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
for (Goods goods1 : goodsList) {
|
|
|
if (GoodsUtil.compareWithQtyPrice(each.getPrices(), goods1.getPrices(), each.getCurrency())) {
|
|
|
each.setErrmsg(ErrorInfoConstant.REPEAT_INFO.getInfo());
|
|
|
@@ -274,7 +320,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param aProduct 单个产品
|
|
|
* @param productSet 产品列表
|
|
|
*/
|
|
|
- private Boolean validateTagInfo(ReleaseProductByBatch aProduct, Set<ReleaseProductByBatch> productSet) {
|
|
|
+ private Boolean validateTagInfo(ReleaseProductByBatch aProduct, List<ReleaseProductByBatch> productSet) {
|
|
|
for (ReleaseProductByBatch each : productSet) {
|
|
|
if (aProduct.getBrandNameEn().equals(each.getBrandNameEn()) && aProduct.getCode().equals(each.getCode())
|
|
|
&& aProduct.getTag().equals(each.getTag())) {
|