|
@@ -6,6 +6,8 @@ import lombok.Getter;
|
|
import lombok.Setter;
|
|
import lombok.Setter;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
|
+import java.lang.reflect.Field;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -20,6 +22,7 @@ public class UnitDto {
|
|
* 机型编号
|
|
* 机型编号
|
|
*/
|
|
*/
|
|
@ApiModelProperty("机型编号")
|
|
@ApiModelProperty("机型编号")
|
|
|
|
+ @NotNull(message = "机型编号不能为空")
|
|
private String millTypeCode;
|
|
private String millTypeCode;
|
|
|
|
|
|
@ApiModelProperty("主轴相关参数")
|
|
@ApiModelProperty("主轴相关参数")
|
|
@@ -40,7 +43,7 @@ public class UnitDto {
|
|
@Setter
|
|
@Setter
|
|
@Getter
|
|
@Getter
|
|
@ApiModel
|
|
@ApiModel
|
|
- public static class UnitGearDto{
|
|
|
|
|
|
+ public static class UnitGearDto {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 主键
|
|
* 主键
|
|
@@ -78,8 +81,49 @@ public class UnitDto {
|
|
@ApiModelProperty("齿轮箱结构集合")
|
|
@ApiModelProperty("齿轮箱结构集合")
|
|
List<UnitGearboxStructureDto> unitGearboxStructureDtoList;
|
|
List<UnitGearboxStructureDto> unitGearboxStructureDtoList;
|
|
|
|
|
|
|
|
+ // 判断所有属性是否都为空
|
|
|
|
+ public boolean allPropertiesAreNull() {
|
|
|
|
+ return (this.id == null || this.id == 0) &&
|
|
|
|
+ (this.code == null || this.code.isEmpty()) &&
|
|
|
|
+ (this.lubricantBrand == null || this.lubricantBrand.isEmpty()) &&
|
|
|
|
+ (this.lubricantModel == null || this.lubricantModel.isEmpty()) &&
|
|
|
|
+ (CollectionUtils.isEmpty(this.unitGearboxBearingsDtoList)) &&
|
|
|
|
+ (CollectionUtils.isEmpty(this.unitGearboxStructureDtoList));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 判断齿轮箱轴承集合所有属性是否都为空
|
|
|
|
+ public boolean allPropertiesGearboxBearingsListNull() {
|
|
|
|
+ List<UnitGearboxBearingsDto> list = this.unitGearboxBearingsDtoList;
|
|
|
|
+ for(int i =0;i<list.size();i++){
|
|
|
|
+ UnitGearboxBearingsDto unitGearboxBearingsDto = list.get(i);
|
|
|
|
+ if(unitGearboxBearingsDto.allPropertiesAreNull()){
|
|
|
|
+ list.remove(i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(list.size()<=0){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 判断齿轮箱结构集合所有属性是否都为空
|
|
|
|
+ public boolean allPropertiesGearboxStructureListNull() {
|
|
|
|
+ List<UnitGearboxStructureDto> list = this.unitGearboxStructureDtoList;
|
|
|
|
+ for(int i =0;i<list.size();i++){
|
|
|
|
+ UnitGearboxStructureDto unitGearboxStructureDto = list.get(i);
|
|
|
|
+ if(unitGearboxStructureDto.allPropertiesAreNull()){
|
|
|
|
+ list.remove(i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(list.size()<=0){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 数据校验
|
|
* 数据校验
|
|
|
|
+ *
|
|
* @param unitGearDto
|
|
* @param unitGearDto
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -87,7 +131,6 @@ public class UnitDto {
|
|
if (unitGearDto == null) {
|
|
if (unitGearDto == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (unitGearDto.getId() == null) {
|
|
if (unitGearDto.getId() == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -116,6 +159,8 @@ public class UnitDto {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -124,7 +169,7 @@ public class UnitDto {
|
|
@Setter
|
|
@Setter
|
|
@Getter
|
|
@Getter
|
|
@ApiModel
|
|
@ApiModel
|
|
- public static class UnitGearboxStructureDto{
|
|
|
|
|
|
+ public static class UnitGearboxStructureDto {
|
|
|
|
|
|
@ApiModelProperty("主键")
|
|
@ApiModelProperty("主键")
|
|
private Integer id;
|
|
private Integer id;
|
|
@@ -197,6 +242,7 @@ public class UnitDto {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 数据校验
|
|
* 数据校验
|
|
|
|
+ *
|
|
* @param dto
|
|
* @param dto
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -204,7 +250,6 @@ public class UnitDto {
|
|
if (dto == null) {
|
|
if (dto == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (dto.getId() == null) {
|
|
if (dto.getId() == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -264,6 +309,23 @@ public class UnitDto {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 判断所有属性是否都为空
|
|
|
|
+ public boolean allPropertiesAreNull() {
|
|
|
|
+ return (this.id == null || this.id == 0) &&
|
|
|
|
+ (this.gearboxCode == null || this.gearboxCode.isEmpty()) &&
|
|
|
|
+ (this.gearboxStructure == null || this.gearboxStructure == 0) &&
|
|
|
|
+ (this.planetaryGearGrade == null || this.planetaryGearGrade == 0) &&
|
|
|
|
+ (this.largeGearTeethCount == null || this.largeGearTeethCount.isEmpty()) &&
|
|
|
|
+ (this.smallGearTeethCount == null || this.smallGearTeethCount.isEmpty()) &&
|
|
|
|
+ (this.bearingBrand == null || this.bearingBrand.isEmpty()) &&
|
|
|
|
+ (this.bearingModel == null || this.bearingModel.isEmpty()) &&
|
|
|
|
+ (this.gearRingTeethCount == null || this.gearRingTeethCount.isEmpty()) &&
|
|
|
|
+ (this.sunWheelTeethCount == null || this.sunWheelTeethCount.isEmpty()) &&
|
|
|
|
+ (this.planetWheelCount == null || this.planetWheelCount.isEmpty()) &&
|
|
|
|
+ (this.planetWheelTeethCount == null || this.planetWheelTeethCount.isEmpty()) &&
|
|
|
|
+ (this.sunWheelBearingBrand == null || this.sunWheelBearingBrand.isEmpty()) &&
|
|
|
|
+ (this.sunWheelBearingModel == null || this.sunWheelBearingModel.isEmpty());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -273,7 +335,7 @@ public class UnitDto {
|
|
@Setter
|
|
@Setter
|
|
@Getter
|
|
@Getter
|
|
@ApiModel
|
|
@ApiModel
|
|
- public static class UnitGearboxBearingsDto{
|
|
|
|
|
|
+ public static class UnitGearboxBearingsDto {
|
|
|
|
|
|
@ApiModelProperty("主键")
|
|
@ApiModelProperty("主键")
|
|
private Integer id;
|
|
private Integer id;
|
|
@@ -337,6 +399,7 @@ public class UnitDto {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 数据校验
|
|
* 数据校验
|
|
|
|
+ *
|
|
* @param gearboxBearing
|
|
* @param gearboxBearing
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -344,7 +407,6 @@ public class UnitDto {
|
|
if (gearboxBearing == null) {
|
|
if (gearboxBearing == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (gearboxBearing.getId() == null) {
|
|
if (gearboxBearing.getId() == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -396,9 +458,26 @@ public class UnitDto {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // 判断所有属性是否都为空
|
|
|
|
+ public boolean allPropertiesAreNull() {
|
|
|
|
+ return (this.id == null || this.id == 0) &&
|
|
|
|
+ (this.gearboxCode == null || this.gearboxCode.isEmpty()) &&
|
|
|
|
+ (this.parallelWheelGrade == null || this.parallelWheelGrade == 0) &&
|
|
|
|
+ (this.gearboxBearingNumber == null || this.gearboxBearingNumber.isEmpty()) &&
|
|
|
|
+ (this.gearboxBearingLevel == null || this.gearboxBearingLevel.isEmpty()) &&
|
|
|
|
+ (this.bearingBrand == null || this.bearingBrand.isEmpty()) &&
|
|
|
|
+ (this.bearingModel == null || this.bearingModel.isEmpty()) &&
|
|
|
|
+ (this.gearRingTeethCount == null || this.gearRingTeethCount.isEmpty()) &&
|
|
|
|
+ (this.bearingRsBrand == null || this.bearingRsBrand.isEmpty()) &&
|
|
|
|
+ (this.bearingRsModel == null || this.bearingRsModel.isEmpty()) &&
|
|
|
|
+ (this.bearingGsBrand == null || this.bearingGsBrand.isEmpty()) &&
|
|
|
|
+ (this.bearingGsModel == null || this.bearingGsModel.isEmpty());
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 主轴相关参数
|
|
* 主轴相关参数
|
|
@@ -453,14 +532,15 @@ public class UnitDto {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 数据验证
|
|
* 数据验证
|
|
|
|
+ *
|
|
* @param component
|
|
* @param component
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public static boolean isValid(UnitBearingsDto component) {
|
|
public static boolean isValid(UnitBearingsDto component) {
|
|
|
|
+
|
|
if (component == null) {
|
|
if (component == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (component.getId() == null) {
|
|
if (component.getId() == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -496,6 +576,18 @@ public class UnitDto {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 判断所有属性是否都为空
|
|
|
|
+ public boolean allPropertiesAreNull() {
|
|
|
|
+ return (this.id == null || this.id == 0) &&
|
|
|
|
+ (this.code == null || this.code.isEmpty()) &&
|
|
|
|
+ (this.lubricantBrand == null || this.lubricantBrand.isEmpty()) &&
|
|
|
|
+ (this.lubricantModel == null || this.lubricantModel.isEmpty()) &&
|
|
|
|
+ (this.frontBearingBrand == null || this.frontBearingBrand.isEmpty()) &&
|
|
|
|
+ (this.frontBearingModel == null || this.frontBearingModel.isEmpty()) &&
|
|
|
|
+ (this.rearBearingBrand == null || this.rearBearingBrand.isEmpty()) &&
|
|
|
|
+ (this.rearBearingModel == null || this.rearBearingModel.isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -556,6 +648,7 @@ public class UnitDto {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 数据校验
|
|
* 数据校验
|
|
|
|
+ *
|
|
* @param motor
|
|
* @param motor
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -563,7 +656,6 @@ public class UnitDto {
|
|
if (motor == null) {
|
|
if (motor == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (motor.getId() == null) {
|
|
if (motor.getId() == null) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -603,6 +695,64 @@ public class UnitDto {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 判断所有属性是否都为空
|
|
|
|
+ public boolean allPropertiesAreNull() {
|
|
|
|
+ return (this.id == null || this.id == 0) &&
|
|
|
|
+ (this.polePairs == null || this.polePairs == 0) &&
|
|
|
|
+ (this.coolingMethod == null || this.coolingMethod == 0) &&
|
|
|
|
+ (this.lubricantBrand == null || this.lubricantBrand.isEmpty()) &&
|
|
|
|
+ (this.lubricantModel == null || this.lubricantModel.isEmpty()) &&
|
|
|
|
+ (this.driveEndBearingBrand == null || this.driveEndBearingBrand.isEmpty()) &&
|
|
|
|
+ (this.driveEndBearingModel == null || this.driveEndBearingModel.isEmpty()) &&
|
|
|
|
+ (this.nonDriveEndBearingBrand == null || this.nonDriveEndBearingBrand.isEmpty()) &&
|
|
|
|
+ (this.nonDriveEndBearingModel == null || this.nonDriveEndBearingModel.isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 通用方法:传入一个对象,当对象中的字符串属性为空时将其设置为null
|
|
|
|
+ public static <T> T validateAndSetEmptyToNull(T obj) {
|
|
|
|
+ if (obj == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ boolean allFieldsNull = true;
|
|
|
|
+ Field[] fields = obj.getClass().getDeclaredFields();
|
|
|
|
+ for (Field field : fields) {
|
|
|
|
+ try {
|
|
|
|
+ field.setAccessible(true);
|
|
|
|
+ Object value = field.get(obj);
|
|
|
|
+
|
|
|
|
+ if (value instanceof String) {
|
|
|
|
+ String strValue = (String) value;
|
|
|
|
+ if (strValue != null && !strValue.trim().isEmpty()) {
|
|
|
|
+ allFieldsNull = false;
|
|
|
|
+ }else{
|
|
|
|
+ field.set(obj, null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (value instanceof Integer) {
|
|
|
|
+ Integer strValue = (Integer) value;
|
|
|
|
+ if (strValue != null && strValue > 0) {
|
|
|
|
+ allFieldsNull = false;
|
|
|
|
+ }else{
|
|
|
|
+ field.set(obj, null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (allFieldsNull) {
|
|
|
|
+ try {
|
|
|
|
+ return (T) obj.getClass().newInstance();
|
|
|
|
+ } catch (InstantiationException | IllegalAccessException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return obj;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|