|
|
@@ -6,6 +6,7 @@ import com.uas.platform.b2c.core.constant.ReleaseStatus;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
|
|
|
@@ -105,8 +106,6 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
// 验证模板是否为商城模板
|
|
|
validateTemplate(headerRow, colNum);
|
|
|
- // 去重后的数据
|
|
|
- List<ReleaseProductByBatch> uniqueBatchList = new ArrayList<>();
|
|
|
// 为空的个数
|
|
|
int blankNum;
|
|
|
// 本次上传总数
|
|
|
@@ -128,16 +127,13 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
blankNum = convertValueToProduct(row, releaseProductByBatch, r);
|
|
|
if (blankNum != 4) {
|
|
|
// 验证表格中数据是否重复,重复的取第一条数据
|
|
|
- ReleaseProductByBatch uniquerProduct = validateRepeatInExcel(releaseProductByBatchArrayList, releaseProductByBatch);
|
|
|
- if (null != uniquerProduct) {
|
|
|
- uniqueBatchList.add(uniquerProduct);
|
|
|
- }
|
|
|
+ validateRepeatInExcel(releaseProductByBatchArrayList, releaseProductByBatch);
|
|
|
releaseProductByBatchArrayList.add(releaseProductByBatch);
|
|
|
total++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 保存临时表信息
|
|
|
+ // 保存验证不通过临时表信息
|
|
|
releaseProductByBatchDao.save(releaseProductByBatchArrayList);
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
// 验证数据信息是否重复
|
|
|
@@ -147,6 +143,8 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
assignmentProductInfo(enUU, modelMap, batch);
|
|
|
// 验证成功后进行绑定处理
|
|
|
Integer assignNumber = 0;
|
|
|
+ // 去重后的数据
|
|
|
+ List<ReleaseProductByBatch> uniqueBatchList = releaseProductByBatchDao.findByRelbatchidAndReleaseCode(batch, ReleaseStatus.unreleased.value());
|
|
|
if (!CollectionUtils.isEmpty(uniqueBatchList)) {
|
|
|
assignNumber = assignBatch(uniqueBatchList);
|
|
|
}
|
|
|
@@ -270,7 +268,7 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
private Integer assignBatch(List<ReleaseProductByBatch> uniqueBatchList) {
|
|
|
List<Product> productList = covert(uniqueBatchList);
|
|
|
try {
|
|
|
- String res = HttpUtil.doPost(productServiceIp + "/product/update/addToProductUser", FlexJsonUtils.toJsonDeep(productList));
|
|
|
+ String res = HttpUtil.doPost("http://10.1.51.24:8080" + "/product/update/addToProductUser", FlexJsonUtils.toJsonDeep(productList));
|
|
|
JSONObject response = JSON.parseObject(res);
|
|
|
if (TRUE_SIGN.equals(response.get(SUCCESS_CODE))) {
|
|
|
return Integer.valueOf(response.get("result").toString());
|
|
|
@@ -303,24 +301,23 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
* @param aBatch 单个数据
|
|
|
* @return 判断是否重复的数据
|
|
|
*/
|
|
|
- private ReleaseProductByBatch validateRepeatInExcel(List<ReleaseProductByBatch> batchList, ReleaseProductByBatch aBatch) {
|
|
|
- if (CollectionUtils.isEmpty(batchList) || !StringUtils.isEmpty(aBatch.getErrmsg())) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- for (ReleaseProductByBatch each : batchList) {
|
|
|
- // 返回符合标准的唯一的物料信息
|
|
|
- if (aBatch.compareSameProductTagInfo(each)) {
|
|
|
- aBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
- aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
- aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
- if (aBatch.getErrmsg().substring(0, 1).equals(",")) {
|
|
|
- aBatch.setErrmsg(aBatch.getErrmsg().substring(1));
|
|
|
+ private void validateRepeatInExcel(List<ReleaseProductByBatch> batchList, ReleaseProductByBatch aBatch) {
|
|
|
+ if (CollectionUtils.isNotEmpty(batchList) && StringUtils.isEmpty(aBatch.getErrmsg())) {
|
|
|
+ for (ReleaseProductByBatch each : batchList) {
|
|
|
+ // 返回符合标准的唯一的物料信息
|
|
|
+ if (aBatch.compareSameProductTagInfo(each)) {
|
|
|
+ aBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
+ if (aBatch.getErrmsg().substring(0, 1).equals(",")) {
|
|
|
+ aBatch.setErrmsg(aBatch.getErrmsg().substring(1));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.unreleased.getPhrase());
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.unreleased.value());
|
|
|
}
|
|
|
- } else {
|
|
|
- return aBatch;
|
|
|
}
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -334,12 +331,15 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
uniqueBatchList.forEach(batch -> {
|
|
|
Product product = new Product();
|
|
|
product.setSpec(batch.getSpec());
|
|
|
- product.setBrand(batch.getBrandNameEn() != null ? batch.getBrandNameEn() : batch.getBrandNameCn());
|
|
|
+ String brand = batch.getBrandNameEn() != null ? batch.getBrandNameEn() : batch.getBrandNameCn();
|
|
|
+ product.setBrand(brand);
|
|
|
+ product.setpBrand(brand);
|
|
|
product.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
- product.setCode(batch.getCode());
|
|
|
+ product.setCmpCode(batch.getCode());
|
|
|
+ product.setpCmpCode(batch.getCode());
|
|
|
// 没有编号设置编号
|
|
|
if (null == product.getCode()) {
|
|
|
- String code = "B2CPR" + StringUtilB2C.getRandomNumber(6);
|
|
|
+ String code = "PNUM" + StringUtilB2C.getRandomNumber(6);
|
|
|
product.setCode(code);
|
|
|
}
|
|
|
// 交期默认赋值为0
|
|
|
@@ -351,6 +351,8 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
|
|
|
product.setKind(batch.getKindName());
|
|
|
product.setUnit(batch.getUnit());
|
|
|
product.setTitle(batch.getKindName());
|
|
|
+ product.setId(batch.getProductid());
|
|
|
+ product.setSourceApp(StringConstant.SOURCE);
|
|
|
productList.add(product);
|
|
|
});
|
|
|
return productList;
|