Browse Source

保存CAD文件信息

yanguofeng 3 years ago
parent
commit
af93c2f90f

+ 2 - 2
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/controller/AdmFileController.java

@@ -6,12 +6,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.persagy.adm.server.custom.dto.CadFiles;
 import com.persagy.adm.server.custom.entity.CadFileQueryParam;
 import com.persagy.adm.server.custom.entity.db.AdmCad;
+import com.persagy.adm.server.custom.enums.MajorEnum;
 import com.persagy.adm.server.custom.service.IAdmCadService;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -62,7 +62,7 @@ public class AdmFileController {
             admCad.setBuildingId(cadFiles.getBuildingId());
             admCad.setFloorId(cadFiles.getFloorId());
             admCad.setMajorCode(cadFiles.getMajorCode());
-            admCad.setMajorName(cadFiles.getMajorName());
+            admCad.setMajorName(MajorEnum.getComment(cadFiles.getMajorCode()));
             admCad.setCheckStatus(false);
             admCad.setFileKey(file.getFileKey());
             admCad.setFileName(file.getFileName());

+ 3 - 4
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/dto/CadFiles.java

@@ -6,6 +6,7 @@ import lombok.Data;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
 import javax.validation.constraints.Size;
 import java.util.List;
 
@@ -16,11 +17,9 @@ public class CadFiles {
     @NotBlank(message = "buildingId不能为空")
     private String buildingId;
     @NotBlank(message = "majorCode不能为空")
+    @Pattern(regexp =  "CF|AC|WS|FF",message = "majorCode不正确")
     private String majorCode;
-    @NotBlank(message = "majorName不能为空")
-    private String majorName;
-
     @NotNull(message = "文件列表不能为空")
-    @Size(min = 0,max = 1000)
+    @Size(min = 1,max = 1000)
     private List<CadFileInfo> files;
 }

+ 23 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/enums/MajorEnum.java

@@ -0,0 +1,23 @@
+package com.persagy.adm.server.custom.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
+public enum MajorEnum {
+    CF("CF","土建精装"),AC("AC","空调"),WS("WS","给排水"),FF("FF","消防");
+    private String code;
+    private String comment;
+
+    public static String getComment(String code) {
+        switch (code){
+            case "CF": return CF.getComment();
+            case "AC": return AC.getComment();
+            case "WS": return WS.getComment();
+            case "FF": return FF.getComment();
+        }
+
+        return null;
+    }
+}