mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善
This commit is contained in:
@@ -466,6 +466,18 @@ public class CommonQuery {
|
||||
}
|
||||
|
||||
private static Predicate getPredicate(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService conversionService) {
|
||||
|
||||
if (x.key.contains(".")) {
|
||||
|
||||
Function4<Root, CriteriaBuilder, QueryItem, ConversionService, Predicate> function4 = map.get(Tuple.of(x.opt, String.class));
|
||||
|
||||
if (function4 == null) {
|
||||
throw new RuntimeException("无法识别的查询 " + x);
|
||||
}
|
||||
|
||||
return function4.apply(root, criteriaBuilder, x, conversionService);
|
||||
}
|
||||
|
||||
EntityType entityType = root.getModel();
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.lihongjie.coal.coalBlend.dto;
|
||||
|
||||
import cn.lihongjie.coal.coalBlend.entity.*;
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendCoalInfoEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendConstrainVo;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendResultInfoEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalParameterDefVo;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -29,10 +30,8 @@ public class CoalBlendDto extends OrgCommonDto {
|
||||
|
||||
private List<CoalBlendResultInfoEntity> results;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@NotNull()
|
||||
private CoalBlendType type;
|
||||
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.lihongjie.coal.coalBlend.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.coalBlend.entity.*;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendCoalInfoEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendConstrainVo;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendResultInfoEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalParameterDefVo;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -29,9 +30,8 @@ public class CreateCoalBlendDto extends OrgCommonDto {
|
||||
|
||||
private List<CoalBlendResultInfoEntity> results;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@NotNull()
|
||||
private CoalBlendType type;
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
|
||||
|
||||
@Comment("结果个数")
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.lihongjie.coal.coalBlend.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.coalBlend.entity.*;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendCoalInfoEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendConstrainVo;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendResultInfoEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalParameterDefVo;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -28,10 +29,8 @@ public class UpdateCoalBlendDto extends OrgCommonDto {
|
||||
private CoalBlendConstrainVo constrains;
|
||||
|
||||
private List<CoalBlendResultInfoEntity> results;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@NotNull()
|
||||
private CoalBlendType type;
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
|
||||
|
||||
@Comment("结果个数")
|
||||
|
||||
@@ -10,8 +10,11 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -21,6 +24,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@Entity
|
||||
@Data
|
||||
@Comment("配煤记录")
|
||||
@Slf4j
|
||||
public class CoalBlendEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@@ -44,6 +48,20 @@ public class CoalBlendEntity extends OrgCommonEntity {
|
||||
private CoalBlendType type;
|
||||
|
||||
|
||||
@Comment("配煤类型")
|
||||
private String blendType;
|
||||
|
||||
|
||||
@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 = 'blend_type'\n" +
|
||||
" and i.code = coal.blend_type)")
|
||||
private String blendTypeName;
|
||||
|
||||
|
||||
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
|
||||
@@ -68,216 +86,224 @@ public class CoalBlendEntity extends OrgCommonEntity {
|
||||
|
||||
public void blend() {
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
this.results = new ArrayList<>();
|
||||
|
||||
|
||||
stopWatch.start("check 1");
|
||||
long count1 = 0;
|
||||
count1 = coals.stream().map(x1 -> x1.getParam1()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param1 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param1.set(true);
|
||||
param1.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam2()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param2 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param2.set(true);
|
||||
param2.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam3()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param3 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param3.set(true);
|
||||
param3.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam4()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param4 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param4.set(true);
|
||||
param4.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam5()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param5 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param5.set(true);
|
||||
param5.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam6()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param6 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param6.set(true);
|
||||
param6.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam7()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param7 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param7.set(true);
|
||||
param7.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam8()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param8 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param8.set(true);
|
||||
param8.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam9()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param9 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param9.set(true);
|
||||
param9.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam10()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param10 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param10.set(true);
|
||||
param10.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam11()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param11 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param11.set(true);
|
||||
param11.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam12()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param12 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param12.set(true);
|
||||
param12.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam13()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param13 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param13.set(true);
|
||||
param13.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam14()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param14 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param14.set(true);
|
||||
param14.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam15()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param15 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param15.set(true);
|
||||
param15.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam16()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param16 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param16.set(true);
|
||||
param16.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam17()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param17 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param17.set(true);
|
||||
param17.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam18()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param18 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param18.set(true);
|
||||
param18.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam19()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param19 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param19.set(true);
|
||||
param19.set(count1>0);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam20()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param20 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
if (count1> 0 && count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param20.set(true);
|
||||
param20.set(count1>0);
|
||||
}
|
||||
|
||||
stopWatch.stop();
|
||||
stopWatch.start("loadNativeLibraries");
|
||||
|
||||
Loader.loadNativeLibraries();
|
||||
|
||||
stopWatch.stop();
|
||||
stopWatch.start("CpModel");
|
||||
CpModel model = new CpModel();
|
||||
|
||||
|
||||
Stream<IntVar> percentVal = Stream.ofAll(coals).zipWithIndex((c, i) -> model.newIntVar(c.getMinPercent(), c.getMaxPercent(), "x" + i));
|
||||
Stream<IntVar> percentVal = Stream.ofAll(coals).zipWithIndex((c, i) -> {
|
||||
return model.newIntVar(c.getMinPercent(), c.getMaxPercent(), "x" + i);
|
||||
});
|
||||
|
||||
IntVar[] percentValArr = percentVal.toJavaArray(IntVar[]::new);
|
||||
// 各个煤累加和 100
|
||||
model.addEquality(LinearExpr.sum(percentValArr), 100);
|
||||
|
||||
addBaseConstrain(model, percentValArr);
|
||||
|
||||
|
||||
IntVar gcd = model.newIntVar(1, 100, "gcd");
|
||||
Stream<IntVar> gcdVal = Stream.ofAll(coals).zipWithIndex((c, i) -> model.newIntVar(c.getMinPercent(), c.getMaxPercent(), "gcdX" + i));
|
||||
IntVar[] gcdValArr = percentVal.toJavaArray(IntVar[]::new);
|
||||
|
||||
if (type == CoalBlendType.TYPE2) {
|
||||
IntVar gcd = model.newIntVar(2, 100, "gcd");
|
||||
Stream<IntVar> gcdVal = null;
|
||||
|
||||
|
||||
percentVal.zip(gcdVal).forEach(t -> model.addModuloEquality(t._2, t._1, gcd));
|
||||
if (Objects.equals(blendType, "2")) {
|
||||
|
||||
model.addLessOrEqual(LinearExpr.sum(gcdValArr), type2PercentSum);
|
||||
gcdVal = Stream.ofAll(coals).zipWithIndex((c, i) -> model.newIntVar(c.getMinPercent(), c.getMaxPercent(), "gcdX" + i));
|
||||
percentVal.zip(gcdVal).forEach(t -> model.addDivisionEquality(t._2, t._1, gcd));
|
||||
percentVal.zip(gcdVal).forEach(t -> model.addModuloEquality(LinearExpr.constant(0), t._1, gcd));
|
||||
|
||||
model.addLessOrEqual(LinearExpr.sum(gcdVal.toJavaArray(IntVar[]::new)) , type2PercentSum);
|
||||
|
||||
}
|
||||
|
||||
@@ -286,64 +312,108 @@ public class CoalBlendEntity extends OrgCommonEntity {
|
||||
if (targetOrder == -1) {
|
||||
|
||||
model.maximize(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam(targetParam) * 100)).toArray()));
|
||||
|
||||
} else {
|
||||
|
||||
model.minimize(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam(targetParam) * 100)).toArray()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
stopWatch.stop();
|
||||
stopWatch.start("CpSolver");
|
||||
|
||||
// 初始化求解器
|
||||
CpSolver cpSolver = new CpSolver();
|
||||
SatParameters.Builder parameters = cpSolver.getParameters();
|
||||
parameters.setEnumerateAllSolutions(true);
|
||||
parameters.setMaxTimeInSeconds(this.getMaxTime());
|
||||
parameters.setLogSearchProgress(false);
|
||||
parameters.setLogSearchProgress(true);
|
||||
cpSolver.setLogCallback((x) -> {
|
||||
});
|
||||
parameters.setFillAdditionalSolutionsInResponse(true);
|
||||
|
||||
|
||||
cpSolver.solve(model, new CpSolverSolutionCallback() {
|
||||
Stream<IntVar> finalGcdVal = gcdVal;
|
||||
try {
|
||||
|
||||
@Override
|
||||
public void onSolutionCallback() {
|
||||
cpSolver.solve(model, new CpSolverSolutionCallback() {
|
||||
|
||||
CoalBlendResultInfoEntity vo = new CoalBlendResultInfoEntity();
|
||||
@Override
|
||||
public void onSolutionCallback() {
|
||||
|
||||
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());
|
||||
if (param1.get()) vo.setParam1(value(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);
|
||||
if (param3.get()) vo.setParam3(value(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);
|
||||
if (param5.get()) vo.setParam5(value(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);
|
||||
if (param7.get()) vo.setParam7(value(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);
|
||||
if (param9.get()) vo.setParam9(value(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);
|
||||
if (param11.get()) vo.setParam11(value(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);
|
||||
if (param13.get()) vo.setParam13(value(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);
|
||||
if (param15.get()) vo.setParam15(value(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);
|
||||
if (param17.get()) vo.setParam17(value(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);
|
||||
if (param19.get()) vo.setParam19(value(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);
|
||||
if (finalGcdVal != null) {
|
||||
|
||||
vo.setPercentInfos(Stream.ofAll(coals).zip(percentVal).zip(finalGcdVal).map(t -> new CoalPercentVo(t._1._1.getName(), ((double) (value(t._1._2))), (double) value(t._2))).toJavaList());
|
||||
} else {
|
||||
vo.setPercentInfos(Stream.ofAll(coals).zip(percentVal).zip(percentVal).map(t -> new CoalPercentVo(t._1._1.getName(), ((double) (value(t._1._2))), (double) value(t._2))).toJavaList());
|
||||
}
|
||||
if (param1.get())
|
||||
vo.setParam1(value(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);
|
||||
if (param3.get())
|
||||
vo.setParam3(value(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);
|
||||
if (param5.get())
|
||||
vo.setParam5(value(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);
|
||||
if (param7.get())
|
||||
vo.setParam7(value(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);
|
||||
if (param9.get())
|
||||
vo.setParam9(value(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);
|
||||
if (param11.get())
|
||||
vo.setParam11(value(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);
|
||||
if (param13.get())
|
||||
vo.setParam13(value(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);
|
||||
if (param15.get())
|
||||
vo.setParam15(value(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);
|
||||
if (param17.get())
|
||||
vo.setParam17(value(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);
|
||||
if (param19.get())
|
||||
vo.setParam19(value(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);
|
||||
|
||||
|
||||
CoalBlendEntity.this.results.add(vo);
|
||||
CoalBlendEntity.this.results.add(vo);
|
||||
|
||||
if (CoalBlendEntity.this.results.size() >= CoalBlendEntity.this.count) {
|
||||
stopSearch();
|
||||
if (CoalBlendEntity.this.results.size() >= CoalBlendEntity.this.count) {
|
||||
stopSearch();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Throwable e) {
|
||||
log.error("{}", e);
|
||||
|
||||
}finally {
|
||||
|
||||
if (stopWatch.isRunning()) {
|
||||
|
||||
stopWatch.stop();
|
||||
}
|
||||
});
|
||||
|
||||
log.info(stopWatch.prettyPrint());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import cn.lihongjie.coal.coalBlend.dto.UpdateCoalBlendDto;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendEntity;
|
||||
import cn.lihongjie.coal.coalBlend.mapper.CoalBlendMapper;
|
||||
import cn.lihongjie.coal.coalBlend.repository.CoalBlendRepository;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.RoundMapper;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -17,6 +18,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -86,13 +88,25 @@ public class CoalBlendService extends BaseService<CoalBlendEntity, CoalBlendRepo
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
RoundMapper roundMapper;
|
||||
|
||||
public CoalBlendDto blend(CreateCoalBlendDto dto) {
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
stopWatch.start("toEntity");
|
||||
CoalBlendEntity entity = this.mapper.toEntity(dto);
|
||||
|
||||
stopWatch.stop();
|
||||
stopWatch.start("blend");
|
||||
entity.blend();
|
||||
stopWatch.stop();
|
||||
stopWatch.start("toDto");
|
||||
CoalBlendDto blendDto = this.mapper.toDto(entity);
|
||||
|
||||
return this.mapper.toDto(entity);
|
||||
stopWatch.stop();
|
||||
|
||||
log.info(stopWatch.prettyPrint());
|
||||
return roundMapper.round(blendDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lihongjie.coal.coalWashingDailyAnalysis.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.coalBlend.dto.CoalBlendDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisItemVo;
|
||||
import org.mapstruct.Mapper;
|
||||
@@ -22,6 +23,7 @@ public interface RoundMapper {
|
||||
CoalWashingDailyAnalysisEntity round(CoalWashingDailyAnalysisEntity entity);
|
||||
|
||||
CoalWashingDailyAnalysisItemVo round(CoalWashingDailyAnalysisItemVo entity);
|
||||
CoalBlendDto round(CoalBlendDto entity);
|
||||
|
||||
|
||||
default Double formatDouble(Double d) {
|
||||
|
||||
@@ -106,5 +106,22 @@
|
||||
"name": "自动计算"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"code": "coal.blendType",
|
||||
"name": "配煤类型",
|
||||
|
||||
"item": [
|
||||
{
|
||||
"code": "1",
|
||||
"name": "称重配煤"
|
||||
},
|
||||
{
|
||||
"code": "2",
|
||||
"name": "铲车配煤"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
Reference in New Issue
Block a user