mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
支持原煤配煤
This commit is contained in:
@@ -60,6 +60,18 @@ public class CoalBlendEntity extends OrgCommonEntity {
|
||||
+ " and i.code = blend_type)")
|
||||
private String blendTypeName;
|
||||
|
||||
@Comment("煤类型")
|
||||
private String coalType;
|
||||
|
||||
@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)")
|
||||
private String coalTypeName;
|
||||
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
|
||||
@@ -282,52 +294,83 @@ public class CoalBlendEntity extends OrgCommonEntity {
|
||||
});
|
||||
|
||||
IntVar[] percentValArr = percentVal.toJavaArray(IntVar[]::new);
|
||||
// 各个煤累加和 100
|
||||
model.addEquality(LinearExpr.sum(percentValArr), 100);
|
||||
|
||||
boolean isJM = StringUtils.isEmpty(coalType) || StringUtils.equalsIgnoreCase(coalType, "0");
|
||||
boolean isYM = StringUtils.equalsIgnoreCase(coalType, "2");
|
||||
if (isJM) {
|
||||
|
||||
// 各个煤累加和 100
|
||||
model.addEquality(LinearExpr.sum(percentValArr), 100);
|
||||
} else {
|
||||
if (isYM) {
|
||||
// 原煤配煤比例小于等于 100
|
||||
model.addLessOrEqual(LinearExpr.sum(percentValArr), 100);
|
||||
}
|
||||
}
|
||||
addBaseConstrain(model, percentValArr);
|
||||
|
||||
IntVar gcd = model.newIntVar(2, 100, "gcd");
|
||||
Stream<IntVar> gcdVal = null;
|
||||
|
||||
if (Objects.equals(blendType, "2")) {
|
||||
if (isJM) {
|
||||
|
||||
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));
|
||||
if (Objects.equals(blendType, "2")) {
|
||||
|
||||
model.addLessOrEqual(
|
||||
LinearExpr.sum(gcdVal.toJavaArray(IntVar[]::new)), 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));
|
||||
|
||||
if (StringUtils.isNotEmpty(targetParam)) {
|
||||
if (targetOrder == -1) {
|
||||
model.addLessOrEqual(
|
||||
LinearExpr.sum(gcdVal.toJavaArray(IntVar[]::new)), type2PercentSum);
|
||||
}
|
||||
|
||||
model.maximize(
|
||||
LinearExpr.weightedSum(
|
||||
percentValArr,
|
||||
coals.stream()
|
||||
.mapToLong(x -> (long) (x.getParam(targetParam) * 100))
|
||||
.toArray()));
|
||||
if (StringUtils.isNotEmpty(targetParam)) {
|
||||
if (targetOrder == -1) {
|
||||
|
||||
} else {
|
||||
model.maximize(
|
||||
LinearExpr.weightedSum(
|
||||
percentValArr,
|
||||
coals.stream()
|
||||
.mapToLong(x -> (long) (x.getParam(targetParam) * 100))
|
||||
.toArray()));
|
||||
|
||||
model.minimize(
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isYM){
|
||||
|
||||
|
||||
int coalSize = coals.size();
|
||||
long[] weightArr = new long[coalSize];
|
||||
|
||||
for (int i = 0; i < coalSize; i++) {
|
||||
|
||||
|
||||
weightArr[i] = (long) (Math.pow(100, coalSize - i));
|
||||
|
||||
}
|
||||
|
||||
model.maximize(LinearExpr.weightedSum(percentValArr, weightArr));
|
||||
}
|
||||
|
||||
stopWatch.stop();
|
||||
stopWatch.start("CpSolver");
|
||||
|
||||
|
||||
@@ -1930,6 +1930,22 @@
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
"code": "coalBlend.coalType",
|
||||
"name": "配煤-煤类型",
|
||||
"item": [
|
||||
{
|
||||
"code": "0",
|
||||
"name": "精煤"
|
||||
},
|
||||
{
|
||||
"code": "2",
|
||||
"name": "原煤"
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "inventoryCheck.type",
|
||||
"name": "库存盘点类型",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
update t_coal_blend set coal_type = '0' where coal_type is null;
|
||||
Reference in New Issue
Block a user