原煤配煤优化

This commit is contained in:
2024-02-19 21:53:21 +08:00
parent bfeca9c694
commit 6823acaf1b
6 changed files with 675 additions and 232 deletions

View File

@@ -31,6 +31,8 @@ public class CoalBlendCoalInfoDto extends OrgCommonDto {
@Range(groups = CoalBlendEntity.BlendGroup.class, min = 0, max = 100, message = "无效的比例")
private Integer maxPercent;
@Comment("原煤比例")
private Double ymPercent;
@Comment("参数 1 ")
@DecimalMin(
groups = CoalBlendEntity.BlendGroup.class,

View File

@@ -28,7 +28,7 @@ public class CoalBlendResultInfoDto extends OrgCommonDto {
private String name;
private List<CoalPercentVo> percentInfos;
private Double percentSum;
@Comment("参数 1 ")
@DecimalMin(
groups = CoalBlendEntity.BlendGroup.class,

View File

@@ -33,6 +33,10 @@ public class CoalBlendCoalInfoEntity extends OrgCommonEntity {
@Range(groups = CoalBlendEntity.BlendGroup.class, min = 0, max = 100, message = "无效的比例")
private Integer maxPercent;
@Comment("原煤比例")
private Double ymPercent;
@Comment("参数 1 ")
@DecimalMin(
groups = CoalBlendEntity.BlendGroup.class,

View File

@@ -21,6 +21,8 @@ import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.springframework.util.StopWatch;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -53,11 +55,11 @@ public class CoalBlendEntity extends OrgCommonEntity {
@Formula(
"(select i.name\n"
+ "from t_dictionary d,\n"
+ " t_dictionary_item i\n"
+ "where d.id = i.dictionary_id\n"
+ " and d.code = 'coalBlend.coalType'\n"
+ " and i.code = coal_type)")
+ "from t_dictionary d,\n"
+ " t_dictionary_item i\n"
+ "where d.id = i.dictionary_id\n"
+ " and d.code = 'coalBlend.coalType'\n"
+ " and i.code = coal_type)")
private String coalTypeName;
@Comment("配煤类型")
@@ -65,11 +67,11 @@ public class CoalBlendEntity extends OrgCommonEntity {
@Formula(
"(select i.name\n"
+ "from t_dictionary d,\n"
+ " t_dictionary_item i\n"
+ "where d.id = i.dictionary_id\n"
+ " and d.code = 'coal.blendType'\n"
+ " and i.code = blend_type)")
+ "from t_dictionary d,\n"
+ " t_dictionary_item i\n"
+ "where d.id = i.dictionary_id\n"
+ " and d.code = 'coal.blendType'\n"
+ " and i.code = blend_type)")
private String blendTypeName;
@Comment("结果个数")
@@ -276,6 +278,438 @@ public class CoalBlendEntity extends OrgCommonEntity {
param20.set(count1 > 0);
}
// 原煤配煤逻辑
if (StringUtils.equals(coalType, "2")) {
// 参与配比的煤的可能性 1 到 煤的数量之间
//<editor-fold desc="Description">
for (int i = 0; i < coals.size(); i++) {
// 针对第j个煤参与配比, 那么他的比例应该在0-煤j的比例之间, 步长为0.01
for (int j = 0; j <= i; j++) {
CoalBlendCoalInfoEntity coalJ = coals.get(j);
int maxP = (int) (coalJ.getYmPercent() * 100);
for (int k = 0; k <= maxP; k++) {
// 计算各个参数是否满足条件
CoalBlendResultInfoEntity vo = new CoalBlendResultInfoEntity();
if (param1.get()) {
Double min = constrains.getParam1Min();
Double max = constrains.getParam1Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam1() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam1() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam1(sum);
}
}
if (param2.get()) {
Double min = constrains.getParam2Min();
Double max = constrains.getParam2Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam2() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam2() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam2(sum);
}
}
if (param3.get()) {
Double min = constrains.getParam3Min();
Double max = constrains.getParam3Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam3() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam3() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam3(sum);
}
}
if (param4.get()) {
Double min = constrains.getParam4Min();
Double max = constrains.getParam4Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam4() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam4() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam4(sum);
}
}
if (param5.get()) {
Double min = constrains.getParam5Min();
Double max = constrains.getParam5Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam5() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam5() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam5(sum);
}
}
if (param6.get()) {
Double min = constrains.getParam6Min();
Double max = constrains.getParam6Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam6() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam6() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam6(sum);
}
}
if (param7.get()) {
Double min = constrains.getParam7Min();
Double max = constrains.getParam7Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam7() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam7() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam7(sum);
}
}
if (param8.get()) {
Double min = constrains.getParam8Min();
Double max = constrains.getParam8Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam8() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam8() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam8(sum);
}
}
if (param9.get()) {
Double min = constrains.getParam9Min();
Double max = constrains.getParam9Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam9() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam9() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam9(sum);
}
}
if (param10.get()) {
Double min = constrains.getParam10Min();
Double max = constrains.getParam10Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam10() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam10() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam10(sum);
}
}
if (param11.get()) {
Double min = constrains.getParam11Min();
Double max = constrains.getParam11Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam11() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam11() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam11(sum);
}
}
if (param12.get()) {
Double min = constrains.getParam12Min();
Double max = constrains.getParam12Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam12() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam12() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam12(sum);
}
}
if (param13.get()) {
Double min = constrains.getParam13Min();
Double max = constrains.getParam13Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam13() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam13() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam13(sum);
}
}
if (param14.get()) {
Double min = constrains.getParam14Min();
Double max = constrains.getParam14Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam14() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam14() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam14(sum);
}
}
if (param15.get()) {
Double min = constrains.getParam15Min();
Double max = constrains.getParam15Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam15() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam15() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam15(sum);
}
}
if (param16.get()) {
Double min = constrains.getParam16Min();
Double max = constrains.getParam16Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam16() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam16() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam16(sum);
}
}
if (param17.get()) {
Double min = constrains.getParam17Min();
Double max = constrains.getParam17Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam17() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam17() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam17(sum);
}
}
if (param18.get()) {
Double min = constrains.getParam18Min();
Double max = constrains.getParam18Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam18() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam18() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam18(sum);
}
}
if (param19.get()) {
Double min = constrains.getParam19Min();
Double max = constrains.getParam19Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam19() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam19() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam19(sum);
}
}
if (param20.get()) {
Double min = constrains.getParam20Min();
Double max = constrains.getParam20Max();
Double sum = 0.0;
for (int l = 0; l < j; l++) {
sum += coals.get(l).getParam20() * coals.get(l).getYmPercent() / 100.0;
}
sum += k * coalJ.getParam20() / 10000.0;
sum = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP).doubleValue();
if ((min != null && sum < min) || (max != null && sum > max)) {
continue;
} else {
vo.setParam20(sum);
}
}
// 生成配煤结果
ArrayList<CoalPercentVo> percentInfos = new ArrayList<>();
vo.setPercentInfos(percentInfos);
for (int l = 0; l < j; l++) {
percentInfos.add(
new CoalPercentVo(
coals.get(l).getName(),
coals.get(l).getYmPercent(),
0.0,
coals.get(l).getYmPercent()));
}
percentInfos.add(
new CoalPercentVo(coalJ.getName(), k / 100.0, null, k / 100.0));
if (results.isEmpty()) {
results = new ArrayList<>();
}
vo.setPercentSum(percentInfos.stream().mapToDouble(CoalPercentVo::getYmPercent).sum());
results.add(vo);
if (results.size() > count) {
break;
}
}
}
}
//</editor-fold>
return;
}
stopWatch.stop();
stopWatch.start("loadNativeLibraries");
@@ -398,283 +832,283 @@ public class CoalBlendEntity extends OrgCommonEntity {
if (param1.get())
vo.setParam1(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam1()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam1()
* 100))
.toArray()))
/ 10000.0);
if (param2.get())
vo.setParam2(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam2()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam2()
* 100))
.toArray()))
/ 10000.0);
if (param3.get())
vo.setParam3(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam3()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam3()
* 100))
.toArray()))
/ 10000.0);
if (param4.get())
vo.setParam4(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam4()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam4()
* 100))
.toArray()))
/ 10000.0);
if (param5.get())
vo.setParam5(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam5()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam5()
* 100))
.toArray()))
/ 10000.0);
if (param6.get())
vo.setParam6(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam6()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam6()
* 100))
.toArray()))
/ 10000.0);
if (param7.get())
vo.setParam7(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam7()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam7()
* 100))
.toArray()))
/ 10000.0);
if (param8.get())
vo.setParam8(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam8()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam8()
* 100))
.toArray()))
/ 10000.0);
if (param9.get())
vo.setParam9(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam9()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam9()
* 100))
.toArray()))
/ 10000.0);
if (param10.get())
vo.setParam10(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam10()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam10()
* 100))
.toArray()))
/ 10000.0);
if (param11.get())
vo.setParam11(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam11()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam11()
* 100))
.toArray()))
/ 10000.0);
if (param12.get())
vo.setParam12(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam12()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam12()
* 100))
.toArray()))
/ 10000.0);
if (param13.get())
vo.setParam13(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam13()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam13()
* 100))
.toArray()))
/ 10000.0);
if (param14.get())
vo.setParam14(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam14()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam14()
* 100))
.toArray()))
/ 10000.0);
if (param15.get())
vo.setParam15(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam15()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam15()
* 100))
.toArray()))
/ 10000.0);
if (param16.get())
vo.setParam16(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam16()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam16()
* 100))
.toArray()))
/ 10000.0);
if (param17.get())
vo.setParam17(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam17()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam17()
* 100))
.toArray()))
/ 10000.0);
if (param18.get())
vo.setParam18(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam18()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam18()
* 100))
.toArray()))
/ 10000.0);
if (param19.get())
vo.setParam19(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam19()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam19()
* 100))
.toArray()))
/ 10000.0);
if (param20.get())
vo.setParam20(
value(
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam20()
* 100))
.toArray()))
/ 10000.0);
LinearExpr.weightedSum(
percentValArr,
coals.stream()
.mapToLong(
x ->
(long)
(x
.getParam20()
* 100))
.toArray()))
/ 10000.0);
CoalBlendEntity.this.results.add(vo);

View File

@@ -27,6 +27,9 @@ public class CoalBlendResultInfoEntity extends OrgCommonEntity {
@ElementCollection private List<CoalPercentVo> percentInfos;
private Double percentSum;
@ManyToOne private CoalBlendEntity coal;
@Comment("参数 1 ")

View File

@@ -182,7 +182,7 @@ public class AuthFilter extends OncePerRequestFilter {
if (stopWatch.isRunning()) {
stopWatch.stop();
}
logger.info(stopWatch.prettyPrint());
logger.debug(stopWatch.prettyPrint());
}
}