Procházet zdrojové kódy

取消电梯类型必传项。根据电梯类别判断电梯类型

wang-hai-cheng před 5 roky
rodič
revize
272665c7be

+ 4 - 4
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/Lift.java

@@ -7,7 +7,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
-import javax.validation.constraints.*;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 
@@ -48,9 +51,6 @@ public class Lift extends BaseEntity {
      * 电梯类型(1:直梯;2:扶梯)
      */
     @FieldName(name = "电梯类型")
-    @Min(value = 1, message = "电梯类型错误")
-    @Max(value = 2, message = "电梯类型错误")
-    @NotNull(message = "电梯类型不能为空")
     private Integer liftType;
 
     /**

+ 14 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java

@@ -296,6 +296,13 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
             }
             LocalDate lastDay = lift.getAnnualInspectionDate().with(TemporalAdjusters.lastDayOfMonth());
             lift.setAnnualInspectionDate(lastDay);
+            //根据电梯类别判断电梯类型
+            Integer category = lift.getCategory();
+            if (category == 1 || category == 2 || category == 3) {
+                lift.setLiftType(1);
+            } else {
+                lift.setLiftType(2);
+            }
             //新增电梯表
             boolean liftResult = save(lift);
             if (!liftResult)
@@ -431,6 +438,13 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
 //        }
         LocalDate lastDay = lift.getAnnualInspectionDate().with(TemporalAdjusters.lastDayOfMonth());
         lift.setAnnualInspectionDate(lastDay);
+        //根据电梯类别判断电梯类型
+        Integer category = lift.getCategory();
+        if (category == 1 || category == 2 || category == 3) {
+            lift.setLiftType(1);
+        } else {
+            lift.setLiftType(2);
+        }
         boolean result = updateById(lift);
         if (!result)
             return RestResponse.fail(MessageUtils.get("msg.modify.fail"));