|
@@ -328,6 +328,11 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, PjGoodsDe
|
|
|
deptList = res.getData();
|
|
deptList = res.getData();
|
|
|
}
|
|
}
|
|
|
List<Dept> finalDeptList = deptList;
|
|
List<Dept> finalDeptList = deptList;
|
|
|
|
|
+ String cnames = data.stream().map(GoodsExcel::getCname).distinct().filter(Objects::nonNull).collect(Collectors.joining(","));
|
|
|
|
|
+ List<PjStockDesc> stockDescList = stockDescService.list(new LambdaQueryWrapper<PjStockDesc>()
|
|
|
|
|
+ .eq(PjStockDesc::getIsDeleted, 0)
|
|
|
|
|
+ .eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
|
|
+ .apply("find_in_set(cname,'" + cnames + "')"));
|
|
|
int q = 0;
|
|
int q = 0;
|
|
|
List<PjGoodsDesc> pjGoodsDescList = new ArrayList<>();
|
|
List<PjGoodsDesc> pjGoodsDescList = new ArrayList<>();
|
|
|
for (GoodsExcel e : data) {
|
|
for (GoodsExcel e : data) {
|
|
@@ -461,6 +466,11 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, PjGoodsDe
|
|
|
if (countName > 1) {
|
|
if (countName > 1) {
|
|
|
throw new ServiceException(goodsDesc.getCname() + "名称已存在");
|
|
throw new ServiceException(goodsDesc.getCname() + "名称已存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ BigDecimal balanceQuantity = stockDescList.stream().filter(item -> item.getCname().equals(e.getCname()))
|
|
|
|
|
+ .map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ if (balanceQuantity.compareTo(new BigDecimal("0")) != 0) {
|
|
|
|
|
+ goodsDesc.setWhether(null);
|
|
|
|
|
+ }
|
|
|
goodsDesc.setUpdateTime(new Date());
|
|
goodsDesc.setUpdateTime(new Date());
|
|
|
goodsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
goodsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
goodsDesc.setId(one.getId());
|
|
goodsDesc.setId(one.getId());
|
|
@@ -481,7 +491,7 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, PjGoodsDe
|
|
|
goodsTypeDescMapper.insert(goodsTypeDes);
|
|
goodsTypeDescMapper.insert(goodsTypeDes);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return R.success("ok");
|
|
|
|
|
|
|
+ return R.success("导入成功,请及时同步商品信息");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -498,6 +508,69 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, PjGoodsDe
|
|
|
return desc;
|
|
return desc;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R synchronization() {
|
|
|
|
|
+ List<PjGoodsDesc> goodsDescList = baseMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
|
|
|
+ .eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
|
|
+ .eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
|
|
+ .eq(PjGoodsDesc::getSalesCompanyId, AuthUtil.getDeptId()));
|
|
|
|
|
+ List<PjProductLaunch> pjProductLaunchList = new ArrayList<>();
|
|
|
|
|
+ List<PjProductLaunch> pjProductLaunchUpdateList = new ArrayList<>();
|
|
|
|
|
+ List<PjStockDesc> pjStockDescList = new ArrayList<>();
|
|
|
|
|
+ List<PjStockDesc> pjStockDescUpdateList = new ArrayList<>();
|
|
|
|
|
+ if (!goodsDescList.isEmpty()) {
|
|
|
|
|
+ List<Long> goodsId = goodsDescList.stream().map(PjGoodsDesc::getId).collect(Collectors.toList());
|
|
|
|
|
+ pjProductLaunchList = productLaunchService.list(new LambdaQueryWrapper<PjProductLaunch>()
|
|
|
|
|
+ .eq(PjProductLaunch::getTenantId, AuthUtil.getTenantId())
|
|
|
|
|
+ .eq(PjProductLaunch::getIsDeleted, 0)
|
|
|
|
|
+ .in(PjProductLaunch::getGoodsId, goodsId));
|
|
|
|
|
+ pjStockDescList = stockDescService.list(new LambdaQueryWrapper<PjStockDesc>()
|
|
|
|
|
+ .eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
|
|
+ .eq(PjStockDesc::getIsDeleted, 0)
|
|
|
|
|
+ .in(PjStockDesc::getGoodsId, goodsId));
|
|
|
|
|
+ for (PjGoodsDesc item : goodsDescList) {
|
|
|
|
|
+ if (!pjProductLaunchList.isEmpty()) {
|
|
|
|
|
+ PjProductLaunch productLaunch = pjProductLaunchList.stream().filter(e -> e.getGoodsId().equals(item.getId())).findFirst().orElse(null);
|
|
|
|
|
+ if (productLaunch != null) {
|
|
|
|
|
+ productLaunch.setCname(item.getCname());
|
|
|
|
|
+ productLaunch.setSpecificationAndModel(item.getSpecificationAndModel());
|
|
|
|
|
+ productLaunch.setBrandId(item.getBrandId());
|
|
|
|
|
+ productLaunch.setBrandName(item.getBrandName());
|
|
|
|
|
+ productLaunch.setBrandItem(item.getBrandItem());
|
|
|
|
|
+ productLaunch.setPlaceProduction(item.getPlaceProduction());
|
|
|
|
|
+ productLaunch.setCnameInt(item.getCnameInt());
|
|
|
|
|
+ productLaunch.setExplosionProof(item.getExplosionProof());
|
|
|
|
|
+ productLaunch.setOriginalFactory(item.getOriginalFactory());
|
|
|
|
|
+ productLaunch.setSelfRecovery(item.getSelfRecovery());
|
|
|
|
|
+ pjProductLaunchUpdateList.add(productLaunch);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!pjStockDescList.isEmpty()) {
|
|
|
|
|
+ PjStockDesc stock = pjStockDescList.stream().filter(e -> e.getGoodsId().equals(item.getId())).findFirst().orElse(null);
|
|
|
|
|
+ if (stock != null) {
|
|
|
|
|
+ stock.setCname(item.getCname());
|
|
|
|
|
+ stock.setCode(item.getCode());
|
|
|
|
|
+ stock.setTypeno(item.getSpecificationAndModel());
|
|
|
|
|
+ stock.setBrandId(item.getBrandId());
|
|
|
|
|
+ stock.setBrandName(item.getBrandName());
|
|
|
|
|
+ stock.setBrandItem(item.getBrandItem());
|
|
|
|
|
+ stock.setProductDescription(item.getGoodsDescription());
|
|
|
|
|
+ stock.setGoodsTypeId(item.getGoodsTypeId());
|
|
|
|
|
+ stock.setGoodsTypeName(item.getGoodsTypeName());
|
|
|
|
|
+ pjStockDescUpdateList.add(stock);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!pjProductLaunchUpdateList.isEmpty()) {
|
|
|
|
|
+ productLaunchService.updateBatchById(pjProductLaunchUpdateList);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!pjStockDescUpdateList.isEmpty()) {
|
|
|
|
|
+ stockDescService.updateBatchById(pjStockDescUpdateList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.data("操作成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 校验商品唯一性
|
|
* 校验商品唯一性
|
|
|
*
|
|
*
|