Explorar o código

模型算法,校验

Gaokun Wang hai 4 meses
pai
achega
a1b8e9970e

+ 28 - 9
als-modules/agile-assurance/src/main/java/org/eco/als/controller/ModelController.java

@@ -1,16 +1,20 @@
 package org.eco.als.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
 import org.eco.als.domain.bo.ModelBo;
-import org.eco.als.domain.vo.*;
+import org.eco.als.domain.vo.ModelImportVo;
+import org.eco.als.domain.vo.ModelVo;
 import org.eco.als.listener.ModelImportListener;
 import org.eco.als.service.IModelService;
 import org.eco.common.core.core.domain.CommonResult;
 import org.eco.common.core.core.domain.model.LoginUser;
 import org.eco.common.core.core.page.PageResult;
+import org.eco.common.core.exception.BusinessException;
 import org.eco.common.excel.core.ExcelResult;
 import org.eco.common.excel.utils.ExcelUtil;
 import org.eco.common.log.annotation.Log;
@@ -19,14 +23,7 @@ import org.eco.common.security.utils.LoginHelper;
 import org.eco.common.web.annotation.RepeatSubmit;
 import org.eco.common.web.core.BaseController;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.ArrayList;
@@ -99,6 +96,17 @@ public class ModelController extends BaseController {
     @RepeatSubmit()
     @PostMapping
     public CommonResult<Void> add(@Validated @RequestBody ModelBo modelBo) {
+        if (StrUtil.containsAny(modelBo.getType(), "4", "5", "6")) {
+            if (StrUtil.isBlank(modelBo.getPartId())) {
+                return  CommonResult.fail("部件不能为空.");
+            }
+            ModelBo modelBo1 = new ModelBo();
+            modelBo1.setPartId(modelBo.getPartId());
+            List<ModelVo> modelVos = modelService.selectList(modelBo1);
+            if (CollUtil.isNotEmpty(modelVos)) {
+                return  CommonResult.fail("模型算法添加重复,请重新输入部件");
+            }
+        }
         boolean inserted = modelService.insert(modelBo);
         if (!inserted) {
             return CommonResult.fail("新增模型信息记录失败!");
@@ -114,6 +122,17 @@ public class ModelController extends BaseController {
     @RepeatSubmit()
     @PutMapping
     public CommonResult<Void> edit(@Validated @RequestBody ModelBo modelBo) {
+        if (StrUtil.containsAny(modelBo.getType(), "4", "5", "6")) {
+            if (StrUtil.isBlank(modelBo.getPartId())) {
+                return  CommonResult.fail("部件不能为空.");
+            }
+            ModelBo modelBo1 = new ModelBo();
+            modelBo1.setPartId(modelBo.getPartId());
+            List<ModelVo> modelVos = modelService.selectList(modelBo1);
+            if (CollUtil.isNotEmpty(modelVos)) {
+                return  CommonResult.fail("模型算法添加重复,请重新输入部件");
+            }
+        }
         boolean updated = modelService.update(modelBo);
         if (!updated) {
             return CommonResult.fail("修改模型信息记录失败!");

+ 1 - 0
als-modules/agile-assurance/src/main/java/org/eco/als/domain/bo/ModelBo.java

@@ -53,6 +53,7 @@ public class ModelBo extends BaseEntity {
     /**
      * 数据列
      */
+    @NotBlank(message = "数据列不能为空")
     private String columnData;
 
     /**