|
@@ -164,22 +164,31 @@ public class BizProductAccessoriesMaterialController extends BaseController {
|
|
|
if (productCollect.stream().anyMatch(material -> material.getProductCode() == null || material.getProductCode() == "")) {
|
|
|
throw new RuntimeException("新增失败,产品编码不能为空");
|
|
|
}
|
|
|
+ if (productCollect.stream().anyMatch(material -> material.getTenantId() == null)) {
|
|
|
+ throw new RuntimeException("新增失败,厂别不能为空");
|
|
|
+ }
|
|
|
if (productCollect.stream().anyMatch(material -> material.getJdId() == null)) {
|
|
|
throw new RuntimeException("新增失败,金蝶id不能为空");
|
|
|
}
|
|
|
- //判断产品编码是否有重复
|
|
|
+ //判断产品编码和厂别是否有重复
|
|
|
List<String> productCodes = productCollect.stream()
|
|
|
.map(BizProductAccessoriesMaterial::getProductCode)
|
|
|
.collect(Collectors.toList());
|
|
|
- Set<String> uniqueProductCodes = new HashSet<>(productCodes);
|
|
|
+ Set<String> uniqueProductCodes = productCollect.stream()
|
|
|
+ .map(material -> material.getProductCode() + "-" + material.getTenantId())
|
|
|
+ .collect(Collectors.toSet());
|
|
|
if (productCodes.size() != uniqueProductCodes.size()) {
|
|
|
throw new RuntimeException("新增失败,产品编码不能重复");
|
|
|
} else {
|
|
|
//新增的产品编码没有重复
|
|
|
- //判断数据库是否存在相同的产品编码
|
|
|
+ //判断数据库是否存在相同的产品编码和厂别
|
|
|
List<BizProduct> bizProductList = bizProductService.query().in("product_code", productCodes).list();
|
|
|
if (!bizProductList.isEmpty()) {
|
|
|
- throw new RuntimeException("新增失败,存在重复的产品编码");
|
|
|
+ for(BizProductAccessoriesMaterial product : productCollect){
|
|
|
+ if(bizProductList.stream().anyMatch(v->v.getProductCode().equals(product.getProductCode()) && v.getTenantId().equals(product.getTenantId()))){
|
|
|
+ throw new RuntimeException("新增失败,存在重复的产品编码");
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
List<BizProduct> productList = new ArrayList<>();
|
|
|
for (BizProductAccessoriesMaterial product : productCollect) {
|
|
@@ -313,6 +322,9 @@ public class BizProductAccessoriesMaterialController extends BaseController {
|
|
|
if (materialCollect.stream().anyMatch(material -> material.getMaterialCode() == null || material.getMaterialCode() == "")) {
|
|
|
throw new RuntimeException("新增失败,材料编码不能为空");
|
|
|
}
|
|
|
+ if (materialCollect.stream().anyMatch(material -> material.getTenantId() == null)) {
|
|
|
+ throw new RuntimeException("新增失败,厂别不能为空");
|
|
|
+ }
|
|
|
if (materialCollect.stream().anyMatch(material -> material.getJdId() == null)) {
|
|
|
throw new RuntimeException("新增失败,金碟id不能为空");
|
|
|
}
|
|
@@ -320,7 +332,9 @@ public class BizProductAccessoriesMaterialController extends BaseController {
|
|
|
List<String> materialCodes = materialCollect.stream()
|
|
|
.map(BizProductAccessoriesMaterial::getMaterialCode)
|
|
|
.collect(Collectors.toList());
|
|
|
- Set<String> uniqueMaterialCodes = new HashSet<>(materialCodes);
|
|
|
+ Set<String> uniqueMaterialCodes = materialCollect.stream()
|
|
|
+ .map(material -> material.getMaterialCode() + "-" + material.getTenantId())
|
|
|
+ .collect(Collectors.toSet());
|
|
|
if (uniqueMaterialCodes.size() != materialCodes.size()) {
|
|
|
throw new RuntimeException("新增失败,原材料编码不能重复");
|
|
|
} else {
|
|
@@ -328,7 +342,11 @@ public class BizProductAccessoriesMaterialController extends BaseController {
|
|
|
//判断数据库是否存在相同的原材料编码
|
|
|
List<BizMaterialBase> bizMaterialList = bizMaterialBaseService.query().in("material_code", materialCodes).list();
|
|
|
if (!bizMaterialList.isEmpty()) {
|
|
|
- throw new RuntimeException("新增失败,存在重复的原材料编码");
|
|
|
+ for(BizProductAccessoriesMaterial material : materialCollect){
|
|
|
+ if(bizMaterialList.stream().anyMatch(v->v.getMaterialCode().equals(material.getMaterialCode()) && v.getTenantId().equals(material.getTenantId()))){
|
|
|
+ throw new RuntimeException("新增失败,存在重复的原材料编码");
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
List<BizMaterialBase> materialList = new ArrayList<>();
|
|
|
for (BizProductAccessoriesMaterial material : materialCollect) {
|
|
@@ -554,20 +572,22 @@ public class BizProductAccessoriesMaterialController extends BaseController {
|
|
|
//产品
|
|
|
List<BizProductAccessoriesMaterial> productCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 1).collect(Collectors.toList());
|
|
|
if (!productCollect.isEmpty()) {
|
|
|
- if (productCollect.stream().anyMatch(material -> material.getHistoryProductCode() == null || material.getHistoryProductCode() == "")) {
|
|
|
- throw new RuntimeException("修改失败,产品原始编码不能为空");
|
|
|
+ if (productCollect.stream().anyMatch(material -> material.getId() == null)) {
|
|
|
+ throw new RuntimeException("修改失败,产品id不能为空");
|
|
|
}
|
|
|
- if (productCollect.stream().anyMatch(material -> material.getProductCode() == "")) {
|
|
|
- throw new RuntimeException("修改失败,产品目标编码不能为空");
|
|
|
+ if (productCollect.stream().anyMatch(material -> material.getTenantId() == null)) {
|
|
|
+ throw new RuntimeException("修改失败,厂别id不能为空");
|
|
|
+ }
|
|
|
+ if (productCollect.stream().anyMatch(material ->material.getProductCode() == null || material.getProductCode() == "")) {
|
|
|
+ throw new RuntimeException("修改失败,产品编码不能为空");
|
|
|
}
|
|
|
//判断产品编码是否有重复(可能存在相同的id和编码写了多次
|
|
|
Map<String, List<BizProductAccessoriesMaterial>> productCodeMap = productCollect.stream()
|
|
|
- .filter(material -> material.getProductCode() != null)
|
|
|
- .collect(Collectors.groupingBy(BizProductAccessoriesMaterial::getProductCode));
|
|
|
+ .filter(material -> material.getProductCode() != null && material.getTenantId() != null)
|
|
|
+ .collect(Collectors.groupingBy(material -> material.getProductCode() + "-" + material.getTenantId() + "-" + material.getId()));
|
|
|
|
|
|
boolean hasDuplicate = productCodeMap.values().stream()
|
|
|
- .anyMatch(list -> list.size() > 1 &&
|
|
|
- list.stream().map(BizProductAccessoriesMaterial::getHistoryProductCode).distinct().count() > 1);
|
|
|
+ .anyMatch(list -> list.size() > 1);
|
|
|
|
|
|
if (hasDuplicate) {
|
|
|
throw new RuntimeException("修改失败,产品编码不能重复");
|
|
@@ -582,21 +602,21 @@ public class BizProductAccessoriesMaterialController extends BaseController {
|
|
|
List<BizProduct> bizProductList = bizProductService.query().in("product_code", productCodes).list();
|
|
|
for (BizProductAccessoriesMaterial material : productCollect) {
|
|
|
for (BizProduct product : bizProductList) {
|
|
|
- if (Objects.equals(material.getProductCode(), product.getProductCode()) &&
|
|
|
- !Objects.equals(material.getHistoryProductCode(), product.getProductCode())) {
|
|
|
+ if (Objects.equals(material.getProductCode(), product.getProductCode()) && Objects.equals(material.getTenantId(), product.getTenantId())
|
|
|
+ && !Objects.equals(material.getId(), product.getId())) {
|
|
|
// 如果找到匹配的项,则抛出错误
|
|
|
throw new RuntimeException("修改失败,产品编码不能重复");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<BizProduct> productList = bizProductService.query().in("product_code", productCollect.stream()
|
|
|
- .map(BizProductAccessoriesMaterial::getHistoryProductCode)
|
|
|
+ List<BizProduct> productList = bizProductService.query().in("id", productCollect.stream()
|
|
|
+ .map(BizProductAccessoriesMaterial::getId)
|
|
|
.collect(Collectors.toList())).list();
|
|
|
for (BizProductAccessoriesMaterial product : productCollect) {
|
|
|
- BizProduct bizProduct = productList.stream().filter(item -> item.getProductCode().equals(product.getHistoryProductCode())).findFirst().orElse(null);
|
|
|
+ BizProduct bizProduct = productList.stream().filter(item -> item.getId().equals(product.getId())).findFirst().orElse(null);
|
|
|
if (bizProduct == null) {
|
|
|
- throw new RuntimeException("修改失败,产品编码不存在");
|
|
|
+ throw new RuntimeException("修改失败,产品id不存在");
|
|
|
}
|
|
|
if (product.getTenantId() != null) {
|
|
|
bizProduct.setTenantId(product.getTenantId());
|
|
@@ -870,20 +890,22 @@ public class BizProductAccessoriesMaterialController extends BaseController {
|
|
|
//原材料
|
|
|
List<BizProductAccessoriesMaterial> materialCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 3).collect(Collectors.toList());
|
|
|
if (!materialCollect.isEmpty()) {
|
|
|
- if (materialCollect.stream().anyMatch(material -> material.getHistoryMaterialCode() == null || material.getHistoryMaterialCode() == "")) {
|
|
|
- throw new RuntimeException("修改失败,原材料原始编码不能为空");
|
|
|
- }
|
|
|
- if (materialCollect.stream().anyMatch(material -> material.getMaterialCode() == "")) {
|
|
|
+ if (materialCollect.stream().anyMatch(material -> material.getMaterialCode() == null || material.getMaterialCode() == "")) {
|
|
|
throw new RuntimeException("修改失败,原材料编码不能为空");
|
|
|
}
|
|
|
+ if (materialCollect.stream().anyMatch(material -> material.getId() == null)) {
|
|
|
+ throw new RuntimeException("修改失败,原材料id不能为空");
|
|
|
+ }
|
|
|
+ if (materialCollect.stream().anyMatch(material -> material.getTenantId() == null)) {
|
|
|
+ throw new RuntimeException("修改失败,厂别id不能为空");
|
|
|
+ }
|
|
|
//判断原材料编码是否有重复(可能存在相同的id和编码写了多次
|
|
|
Map<String, List<BizProductAccessoriesMaterial>> materialCodeMap = materialCollect.stream()
|
|
|
- .filter(material -> material.getMaterialCode() != null)
|
|
|
- .collect(Collectors.groupingBy(BizProductAccessoriesMaterial::getMaterialCode));
|
|
|
+ .filter(material -> material.getMaterialCode() != null && material.getTenantId() != null)
|
|
|
+ .collect(Collectors.groupingBy(material -> material.getMaterialCode() + "-" + material.getTenantId() + "-" + material.getId()));
|
|
|
|
|
|
boolean hasDuplicate = materialCodeMap.values().stream()
|
|
|
- .anyMatch(list -> list.size() > 1 &&
|
|
|
- list.stream().map(BizProductAccessoriesMaterial::getHistoryAccessoriesCode).distinct().count() > 1);
|
|
|
+ .anyMatch(list -> list.size() > 1);
|
|
|
|
|
|
if (hasDuplicate) {
|
|
|
throw new RuntimeException("修改失败,原材料编码不能重复");
|
|
@@ -897,21 +919,21 @@ public class BizProductAccessoriesMaterialController extends BaseController {
|
|
|
List<BizMaterialBase> bizMaterialList = bizMaterialBaseService.query().in("material_code", materialCodes).list();
|
|
|
for (BizProductAccessoriesMaterial material : materialCollect) {
|
|
|
for (BizMaterialBase materials : bizMaterialList) {
|
|
|
- if (Objects.equals(material.getMaterialCode(), materials.getMaterial()) &&
|
|
|
- !Objects.equals(material.getHistoryMaterialCode(), materials.getMaterialCode())) {
|
|
|
+ if (Objects.equals(material.getMaterialCode(), materials.getMaterialCode()) && Objects.equals(material.getTenantId(), materials.getTenantId())
|
|
|
+ && !Objects.equals(material.getId(), materials.getId())) {
|
|
|
// 如果找到匹配的项,则抛出错误
|
|
|
throw new RuntimeException("修改失败,原材料编码不能重复");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<BizMaterialBase> materialList = bizMaterialBaseService.query().in("material_code", materialCollect.stream()
|
|
|
- .map(BizProductAccessoriesMaterial::getHistoryMaterialCode)
|
|
|
+ List<BizMaterialBase> materialList = bizMaterialBaseService.query().in("id", materialCollect.stream()
|
|
|
+ .map(BizProductAccessoriesMaterial::getId)
|
|
|
.collect(Collectors.toList())).list();
|
|
|
for (BizProductAccessoriesMaterial material : materialCollect) {
|
|
|
- BizMaterialBase bizMaterialBase = materialList.stream().filter(item -> item.getMaterialCode().equals(material.getHistoryMaterialCode())).findFirst().orElse(null);
|
|
|
+ BizMaterialBase bizMaterialBase = materialList.stream().filter(item -> item.getId().equals(material.getId())).findFirst().orElse(null);
|
|
|
if (bizMaterialBase == null) {
|
|
|
- throw new RuntimeException("修改失败,原材料编码不存在");
|
|
|
+ throw new RuntimeException("修改失败,原材料id不存在");
|
|
|
}
|
|
|
|
|
|
if (material.getMaterialCode() != null) {
|