|
@@ -1575,7 +1575,7 @@ public class ApsConstraintListProvider implements ConstraintProvider {
|
|
|
* @param constraintFactory
|
|
|
* @return
|
|
|
*/
|
|
|
- private Constraint deliveryDate(ConstraintFactory constraintFactory) {
|
|
|
+ /*private Constraint deliveryDate(ConstraintFactory constraintFactory) {
|
|
|
return constraintFactory.forEach(Equipment.class)
|
|
|
.filter(equipment -> {
|
|
|
return true;
|
|
@@ -1585,10 +1585,10 @@ public class ApsConstraintListProvider implements ConstraintProvider {
|
|
|
List<ProductionProcesses> tasks = equipment.getTasks();
|
|
|
if(tasks != null && tasks.size()>0){
|
|
|
for (ProductionProcesses productionProcesses : tasks) {
|
|
|
- /*
|
|
|
+ *//*
|
|
|
获取最后一步工步的结束时间(最后一步工步的结束时间即此产品生产的实际结束时间)
|
|
|
并且获取结束时间大于生产订单的交货日期
|
|
|
- */
|
|
|
+ *//*
|
|
|
if(productionProcesses.getEndTime() == null){
|
|
|
continue;
|
|
|
}
|
|
@@ -1610,12 +1610,64 @@ public class ApsConstraintListProvider implements ConstraintProvider {
|
|
|
if(bol){
|
|
|
int i = (int) (DateUtil.between(deliveryMinDate, Date.from(productionProcesses.getEndTime().atZone(zoneId).toInstant()), DateUnit.MINUTE) + 1) * 10;
|
|
|
b = b + i;
|
|
|
+ if(i<0){
|
|
|
+ int testa = 0;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return b;
|
|
|
})
|
|
|
.asConstraint("deliveryDate");
|
|
|
+ }*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 软约束:交货日期,根据延迟交货日期的天数来做惩罚分数计算
|
|
|
+ * @param constraintFactory
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Constraint deliveryDate(ConstraintFactory constraintFactory) {
|
|
|
+ return constraintFactory.forEach(ProductionProcesses.class)
|
|
|
+ .filter(productionProcesses -> {
|
|
|
+ /*
|
|
|
+ 获取最后一步工步的结束时间(最后一步工步的结束时间即此产品生产的实际结束时间)
|
|
|
+ 并且获取结束时间大于生产订单的交货日期
|
|
|
+ */
|
|
|
+ if(productionProcesses.getEndTime() == null){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 取最小订单交货日期
|
|
|
+ Date deliveryMinDate = null;
|
|
|
+ for (ProduceOrder produceOrder : productionProcesses.getProduceOrder()) {
|
|
|
+ if(deliveryMinDate == null){
|
|
|
+ deliveryMinDate = produceOrder.getDeliveryDate();
|
|
|
+ }else{
|
|
|
+ if(deliveryMinDate.compareTo(produceOrder.getDeliveryDate())>0){
|
|
|
+ deliveryMinDate = produceOrder.getDeliveryDate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(deliveryMinDate == null){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Boolean bol = productionProcesses.getEndTime().atZone(zoneId).toInstant().toEpochMilli()>deliveryMinDate.getTime();
|
|
|
+ return bol;
|
|
|
+ })
|
|
|
+ .penalize(HardMediumSoftScore.ONE_MEDIUM,(productionProcesses) ->{
|
|
|
+ Date deliveryMinDate = null;
|
|
|
+ for (ProduceOrder produceOrder : productionProcesses.getProduceOrder()) {
|
|
|
+ if(deliveryMinDate == null){
|
|
|
+ deliveryMinDate = produceOrder.getDeliveryDate();
|
|
|
+ }else{
|
|
|
+ if(deliveryMinDate.compareTo(produceOrder.getDeliveryDate())>0){
|
|
|
+ deliveryMinDate = produceOrder.getDeliveryDate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int i = (int) (DateUtil.between(deliveryMinDate, Date.from(productionProcesses.getEndTime().atZone(zoneId).toInstant()), DateUnit.MINUTE) + 1) * 10;
|
|
|
+ return i;
|
|
|
+ })
|
|
|
+ .asConstraint("deliveryDate");
|
|
|
}
|
|
|
|
|
|
/**
|