|
@@ -53,22 +53,22 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
@Resource
|
|
|
private IBizMaterialBaseService bizMaterialBaseService;
|
|
|
public static final String PAGE_SIZE = "pageSize";
|
|
|
- @ApiOperation("获取物料详细")
|
|
|
+// @ApiOperation("获取物料详细")
|
|
|
@GetMapping("/list")
|
|
|
- public AjaxResult list(BizProductAccessoriesMaterial bizProductAccessoriesMaterial) throws NoSuchFieldException, IllegalAccessException
|
|
|
+ public TableDataInfo list(BizProductAccessoriesMaterial bizProductAccessoriesMaterial) throws NoSuchFieldException, IllegalAccessException
|
|
|
{
|
|
|
//判断类别
|
|
|
if(bizProductAccessoriesMaterial.getCategory() == null){
|
|
|
- return error("查询失败,类别不能为空");
|
|
|
+ throw new RuntimeException("查询失败,类别不能为空");
|
|
|
}
|
|
|
if(bizProductAccessoriesMaterial.getCategory() != 1 && bizProductAccessoriesMaterial.getCategory() != 2 && bizProductAccessoriesMaterial.getCategory() != 3){
|
|
|
- return error("查询失败,类别只能为1、2、3");
|
|
|
+ throw new RuntimeException("查询失败,类别只能为1、2、3");
|
|
|
}
|
|
|
//判断厂别
|
|
|
if(bizProductAccessoriesMaterial.getTenantId() != null){
|
|
|
List<BizTenant> tenantList = bizTenantService.query().eq("id", bizProductAccessoriesMaterial.getTenantId()).list();
|
|
|
if(tenantList.isEmpty()){
|
|
|
- return error("查询失败,租户ID不存在");
|
|
|
+ throw new RuntimeException("查询失败,租户ID不存在");
|
|
|
}
|
|
|
}
|
|
|
String pageSizeStr = ServletUtils.getParameter(PAGE_SIZE);
|
|
@@ -84,7 +84,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
if(bizProductAccessoriesMaterial.getProductCode() != null && bizProductAccessoriesMaterial.getProductCode() != ""){
|
|
|
bizProduct.setProductCode(bizProductAccessoriesMaterial.getProductCode());
|
|
|
}
|
|
|
- return success(bizProductService.getList(bizProduct));
|
|
|
+ return getDataTable(bizProductService.getList(bizProduct));
|
|
|
}
|
|
|
//类别为2 accessories
|
|
|
if(bizProductAccessoriesMaterial.getCategory() == 2){
|
|
@@ -95,7 +95,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
if(bizProductAccessoriesMaterial.getAccessoriesCode() != null && bizProductAccessoriesMaterial.getAccessoriesCode() != ""){
|
|
|
bizAccessories.setAccessoriesCode(bizProductAccessoriesMaterial.getAccessoriesCode());
|
|
|
}
|
|
|
- return success(bizAccessoriesService.getList(bizAccessories));
|
|
|
+ return getDataTable(bizAccessoriesService.getList(bizAccessories));
|
|
|
}
|
|
|
//类别为3 material
|
|
|
if(bizProductAccessoriesMaterial.getCategory() == 3){
|
|
@@ -106,9 +106,9 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
if(bizProductAccessoriesMaterial.getMaterialCode() != null && bizProductAccessoriesMaterial.getMaterialCode() != ""){
|
|
|
bizMaterialBase.setMaterialCode(bizProductAccessoriesMaterial.getMaterialCode());
|
|
|
}
|
|
|
- return success(bizMaterialBaseService.getList(bizMaterialBase));
|
|
|
+ return getDataTable(bizMaterialBaseService.getList(bizMaterialBase));
|
|
|
}
|
|
|
- return success();
|
|
|
+ return getDataTable(new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
@PostMapping
|
|
@@ -162,7 +162,7 @@ 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.getProductCode() == null)) {
|
|
|
+ if (productCollect.stream().anyMatch(material -> material.getProductCode() == null || material.getProductCode() == "")) {
|
|
|
throw new RuntimeException("新增失败,产品编码不能为空");
|
|
|
}
|
|
|
//判断产品编码是否有重复
|
|
@@ -177,7 +177,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
//判断数据库是否存在相同的产品编码
|
|
|
List<BizProduct> bizProductList = bizProductService.query().in("product_code", productCodes).list();
|
|
|
if (!bizProductList.isEmpty()){
|
|
|
- return error("新增失败,存在重复的产品编码");
|
|
|
+ throw new RuntimeException("新增失败,存在重复的产品编码");
|
|
|
}else{
|
|
|
List<BizProduct> productList = new ArrayList<>();
|
|
|
for (BizProductAccessoriesMaterial product : productCollect) {
|
|
@@ -226,7 +226,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
//辅料
|
|
|
List<BizProductAccessoriesMaterial> accessoriesCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 2).collect(Collectors.toList());
|
|
|
if(!accessoriesCollect.isEmpty()){
|
|
|
- if (accessoriesCollect.stream().anyMatch(material -> material.getAccessoriesCode() == null)) {
|
|
|
+ if (accessoriesCollect.stream().anyMatch(material -> material.getAccessoriesCode() == null || material.getAccessoriesCode() == "")) {
|
|
|
throw new RuntimeException("新增失败,辅料编码不能为空");
|
|
|
}
|
|
|
//判断辅料编码是否有重复
|
|
@@ -286,7 +286,7 @@ 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.getMaterialCode() == null)) {
|
|
|
+ if (materialCollect.stream().anyMatch(material -> material.getMaterialCode() == null || material.getMaterialCode() == "")) {
|
|
|
throw new RuntimeException("新增失败,材料编码不能为空");
|
|
|
}
|
|
|
//判断原材料编码是否有重复
|
|
@@ -517,7 +517,7 @@ 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)) {
|
|
|
+ if (productCollect.stream().anyMatch(material -> material.getHistoryProductCode()== null || material.getHistoryProductCode()== "")) {
|
|
|
throw new RuntimeException("修改失败,产品原始编码不能为空");
|
|
|
}
|
|
|
if (productCollect.stream().anyMatch(material -> material.getProductCode()== "")) {
|
|
@@ -530,7 +530,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
|
|
|
boolean hasDuplicate = productCodeMap.values().stream()
|
|
|
.anyMatch(list -> list.size() > 1 &&
|
|
|
- list.stream().map(BizProductAccessoriesMaterial::getId).distinct().count() > 1);
|
|
|
+ list.stream().map(BizProductAccessoriesMaterial::getHistoryProductCode).distinct().count() > 1);
|
|
|
|
|
|
if (hasDuplicate) {
|
|
|
throw new RuntimeException("修改失败,产品编码不能重复");
|
|
@@ -546,7 +546,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
for (BizProductAccessoriesMaterial material : productCollect) {
|
|
|
for (BizProduct product : bizProductList) {
|
|
|
if (Objects.equals(material.getProductCode(), product.getProductCode()) &&
|
|
|
- !Objects.equals(material.getId(), product.getId())) {
|
|
|
+ !Objects.equals(material.getHistoryProductCode(), product.getProductCode())) {
|
|
|
// 如果找到匹配的项,则抛出错误
|
|
|
throw new RuntimeException("修改失败,产品编码不能重复");
|
|
|
}
|
|
@@ -674,7 +674,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
//辅料
|
|
|
List<BizProductAccessoriesMaterial> accessoriesCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 2).collect(Collectors.toList());
|
|
|
if (!accessoriesCollect.isEmpty()) {
|
|
|
- if (accessoriesCollect.stream().anyMatch(material -> material.getHistoryAccessoriesCode()== null)) {
|
|
|
+ if (accessoriesCollect.stream().anyMatch(material -> material.getHistoryAccessoriesCode()== null || material.getHistoryAccessoriesCode()== "")) {
|
|
|
throw new RuntimeException("修改失败,辅料原始编码不能为空");
|
|
|
}
|
|
|
if (accessoriesCollect.stream().anyMatch(material -> material.getAccessoriesCode() == "")) {
|
|
@@ -687,7 +687,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
|
|
|
boolean hasDuplicate = accessoriesCodeMap.values().stream()
|
|
|
.anyMatch(list -> list.size() > 1 &&
|
|
|
- list.stream().map(BizProductAccessoriesMaterial::getId).distinct().count() > 1);
|
|
|
+ list.stream().map(BizProductAccessoriesMaterial::getHistoryMaterialCode).distinct().count() > 1);
|
|
|
|
|
|
if (hasDuplicate) {
|
|
|
throw new RuntimeException("修改失败,辅料编码不能重复");
|
|
@@ -702,7 +702,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
for (BizProductAccessoriesMaterial material : accessoriesCollect) {
|
|
|
for (BizAccessories accessories : bizAccessoriesList) {
|
|
|
if (Objects.equals(material.getAccessoriesCode(), accessories.getAccessoriesCode()) &&
|
|
|
- !Objects.equals(material.getId(), accessories.getId())) {
|
|
|
+ !Objects.equals(material.getHistoryAccessoriesCode(), accessories.getAccessoriesCode())) {
|
|
|
// 如果找到匹配的项,则抛出错误
|
|
|
throw new RuntimeException("修改失败,辅料编码不能重复");
|
|
|
}
|
|
@@ -817,7 +817,7 @@ 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)) {
|
|
|
+ if (materialCollect.stream().anyMatch(material -> material.getHistoryMaterialCode()== null || material.getHistoryMaterialCode()== "")) {
|
|
|
throw new RuntimeException("修改失败,原材料原始编码不能为空");
|
|
|
}
|
|
|
if (materialCollect.stream().anyMatch(material -> material.getMaterialCode() == "")) {
|
|
@@ -830,7 +830,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
|
|
|
boolean hasDuplicate = materialCodeMap.values().stream()
|
|
|
.anyMatch(list -> list.size() > 1 &&
|
|
|
- list.stream().map(BizProductAccessoriesMaterial::getId).distinct().count() > 1);
|
|
|
+ list.stream().map(BizProductAccessoriesMaterial::getHistoryAccessoriesCode).distinct().count() > 1);
|
|
|
|
|
|
if (hasDuplicate) {
|
|
|
throw new RuntimeException("修改失败,原材料编码不能重复");
|
|
@@ -845,7 +845,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
|
|
|
for (BizProductAccessoriesMaterial material : materialCollect) {
|
|
|
for (BizMaterialBase materials : bizMaterialList) {
|
|
|
if (Objects.equals(material.getMaterialCode(), materials.getMaterial()) &&
|
|
|
- !Objects.equals(material.getId(), materials.getId())) {
|
|
|
+ !Objects.equals(material.getHistoryMaterialCode(), materials.getMaterialCode())) {
|
|
|
// 如果找到匹配的项,则抛出错误
|
|
|
throw new RuntimeException("修改失败,原材料编码不能重复");
|
|
|
}
|