|
@@ -0,0 +1,96 @@
|
|
|
+package com.rongwei.rwapsserver.aps.domain.taskassigning;
|
|
|
+
|
|
|
+import com.rongwei.rwapsserver.aps.domain.ApsAbstractPersistable;
|
|
|
+import com.rongwei.rwapsserver.aps.domain.Equipment;
|
|
|
+import com.rongwei.rwapsserver.aps.domain.ProductionProcesses;
|
|
|
+import lombok.*;
|
|
|
+import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty;
|
|
|
+import org.optaplanner.core.api.domain.solution.PlanningScore;
|
|
|
+import org.optaplanner.core.api.domain.solution.PlanningSolution;
|
|
|
+import org.optaplanner.core.api.domain.solution.ProblemFactCollectionProperty;
|
|
|
+import org.optaplanner.core.api.domain.valuerange.CountableValueRange;
|
|
|
+import org.optaplanner.core.api.domain.valuerange.ValueRangeFactory;
|
|
|
+import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider;
|
|
|
+import org.optaplanner.core.api.score.buildin.hardmediumsoft.HardMediumSoftScore;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@EqualsAndHashCode(callSuper = true)
|
|
|
+@Data
|
|
|
+@NoArgsConstructor
|
|
|
+@PlanningSolution
|
|
|
+public class ApsSolutionTa extends ApsAbstractPersistable {
|
|
|
+
|
|
|
+ @Getter(value = AccessLevel.NONE)
|
|
|
+ private List<ProductionProcesses> processesList;
|
|
|
+
|
|
|
+ @Getter(value = AccessLevel.NONE)
|
|
|
+ private List<Equipment> equipmentList;
|
|
|
+
|
|
|
+ @Getter(value = AccessLevel.NONE)
|
|
|
+ private HardMediumSoftScore score;
|
|
|
+
|
|
|
+ private Long incrementUnitAmount;
|
|
|
+
|
|
|
+ public LocalDateTime startTime;
|
|
|
+ // 每一步骤最优规划实体
|
|
|
+ private List<ProductionProcesses> stepBestProcessesList;
|
|
|
+ // 是否初始结束
|
|
|
+ private boolean constructionHeuristicEnd;
|
|
|
+
|
|
|
+ public ApsSolutionTa(String id, List<ProductionProcesses> processesList, List<Equipment> equipmentList) {
|
|
|
+ super(id);
|
|
|
+ this.processesList = processesList;
|
|
|
+ this.equipmentList = equipmentList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ValueRangeProvider(id="taskRange")
|
|
|
+ @PlanningEntityCollectionProperty
|
|
|
+ public List<ProductionProcesses> getProcessesList() {
|
|
|
+ return processesList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ProblemFactCollectionProperty
|
|
|
+ public List<Equipment> getEquipmentList() {
|
|
|
+ return equipmentList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ValueRangeProvider(id="timeRange")
|
|
|
+ public CountableValueRange<LocalDateTime> getxRange(){
|
|
|
+ Long produceTimeTotal = 0L;
|
|
|
+ for (ProductionProcesses productionProcesses : processesList) {
|
|
|
+ produceTimeTotal = produceTimeTotal + productionProcesses.getProduceTime();
|
|
|
+ }
|
|
|
+ LocalDateTime fromTime = LocalDateTime.now();
|
|
|
+ if(startTime != null){
|
|
|
+ fromTime = startTime;
|
|
|
+ }
|
|
|
+ Long incrementUnit = this.incrementUnitAmount;
|
|
|
+ if(incrementUnit == null){
|
|
|
+ incrementUnit = 5L;
|
|
|
+ }
|
|
|
+
|
|
|
+ long sy = produceTimeTotal % incrementUnit;
|
|
|
+ if(sy>0){
|
|
|
+ produceTimeTotal = produceTimeTotal - sy;
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("startTime:"+startTime);
|
|
|
+ return ValueRangeFactory.createLocalDateTimeValueRange(fromTime,fromTime.plusMinutes(produceTimeTotal),incrementUnit, ChronoUnit.MINUTES);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PlanningScore
|
|
|
+ public HardMediumSoftScore getScore() {
|
|
|
+ return score;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Long getIncrementUnitAmount() {
|
|
|
+ return incrementUnitAmount;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setIncrementUnitAmount(Long incrementUnitAmount) {
|
|
|
+ this.incrementUnitAmount = incrementUnitAmount;
|
|
|
+ }
|
|
|
+}
|