diff --git a/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendCoalInfoEntity.java b/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendCoalInfoEntity.java index 0b25e18a..5adcd455 100644 --- a/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendCoalInfoEntity.java +++ b/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendCoalInfoEntity.java @@ -29,11 +29,7 @@ public class CoalBlendCoalInfoEntity extends OrgCommonEntity { private CoalBlendEntity coal; - @ElementCollection - private List percentInfos; - @ManyToOne - private CoalBlendEntity result; @Comment("比例最小值") diff --git a/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendEntity.java b/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendEntity.java index 7662c485..5cc69f7b 100644 --- a/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendEntity.java +++ b/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendEntity.java @@ -37,7 +37,7 @@ public class CoalBlendEntity extends OrgCommonEntity { private CoalBlendConstrainVo constrains; @OneToMany(mappedBy = "result") - private List results; + private List results; @Enumerated(value = EnumType.STRING) @NotNull() @@ -308,7 +308,7 @@ public class CoalBlendEntity extends OrgCommonEntity { @Override public void onSolutionCallback() { - CoalBlendCoalInfoEntity vo = new CoalBlendCoalInfoEntity(); + CoalBlendResultInfoEntity vo = new CoalBlendResultInfoEntity(); vo.setPercentInfos(Stream.ofAll(coals).zip(percentVal).zip(gcdVal).map(t -> new CoalPercentVo(t._1._1.getName(), ((double) (value(t._1._2))), (double) value(t._2))).toJavaList()); diff --git a/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendResultInfoEntity.java b/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendResultInfoEntity.java new file mode 100644 index 00000000..515b6b06 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/coalBlend/entity/CoalBlendResultInfoEntity.java @@ -0,0 +1,106 @@ +package cn.lihongjie.coal.coalBlend.entity; + +import cn.lihongjie.coal.base.entity.OrgCommonEntity; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.DecimalMin; +import jakarta.validation.constraints.NotEmpty; +import lombok.*; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.hibernate.annotations.Comment; +import org.hibernate.validator.constraints.Range; + +import java.util.List; + +@Data +@AllArgsConstructor + +@NoArgsConstructor +@With +@Entity +public class CoalBlendResultInfoEntity extends OrgCommonEntity { + + @NotEmpty(message = "煤名称不能为空") + private String name; + + + + + @ElementCollection + private List percentInfos; + + @ManyToOne + private CoalBlendEntity result; + + + + + @Comment("参数 1 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param1; + @Comment("参数 2 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param2; + @Comment("参数 3 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param3; + @Comment("参数 4 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param4; + @Comment("参数 5 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param5; + @Comment("参数 6 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param6; + @Comment("参数 7 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param7; + @Comment("参数 8 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param8; + @Comment("参数 9 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param9; + @Comment("参数 10 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param10; + @Comment("参数 11 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param11; + @Comment("参数 12 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param12; + @Comment("参数 13 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param13; + @Comment("参数 14 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param14; + @Comment("参数 15 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param15; + @Comment("参数 16 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param16; + @Comment("参数 17 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param17; + @Comment("参数 18 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param18; + @Comment("参数 19 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param19; + @Comment("参数 20 ") + @DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1") + private Double param20; + + + @SneakyThrows + public Double getParam(String param) { + return (Double) FieldUtils.getField(this.getClass(), param, true).get(this); + } + +}