计划变量不支持Collect



我有一个问题,一个订单有很多手工艺品,其中一个手工艺品需要两个或多个人才能完成,所以在计划实体中,我使用了一个列表对象作为计划变量,但当我启动应用程序时,它出现了错误,请给我一些想法,谢谢!

@PlanningSolution
public class ScheduleSolution extends AbstractPersistable {
@ProblemFactCollectionProperty
private List<Order> orderList;
@ProblemFactCollectionProperty
private List<ProductBom> productBomList;
@PlanningEntityCollectionProperty
private List<JobAssignment> jobAssignmentList;
@ProblemFactCollectionProperty
@ValueRangeProvider(id = "resourceRange")
List<Resource> resourceList;
@PlanningScore
private HardSoftScore score;
}
@PlanningEntity
public class JobAssignment extends AbstractPersistable {
private ProductBom productBom;
@PlanningVariable(valueRangeProviderRefs = { "resourceRange" })
private List<Resource> resourceList;
}

由以下原因引起:java.lang.IllegalArgumentException:entityClass(class com.demo.domain.repaign.JobAssignment(具有PlanningVariable注释属性(resourceList(,该属性引用ValueRangeProvider注释成员(字段java.util.List com.demo.doomain.repaign.ScheduleSolution.resourceList(,此成员返回具有类型(class com.Dem.domain.reassigne.Resource(元素的Collection无法分配给PlanningVariable的类型(接口java.util.List(。位于org.optaplanner.core.impl.domain.valuerange.descriptor.AbstractFromPropertyValueRangeDescriptor.processValueRangeProviderAnnotation(AbstractFromPropertyValue RangeDescriptor.ja:136(

@PlanningVariable不能是List,直到有一天我们支持@PlanningVariableCollection。可能的解决方案:

@PlanningEntity
public class JobAssignment extends AbstractPersistable {
private ProductBom productBom;
@PlanningVariable(valueRangeProviderRefs = { "resourceRange" })
private Resource resource;
}

最新更新