|
@@ -26,6 +26,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.Duration;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicType.FIRST_FIT;
|
|
|
|
|
@@ -161,4 +162,84 @@ public class ApsServiceImpl implements ApsService {
|
|
|
SolverFactory<ApsSolution> solverFactory = SolverFactory.create(solverConfig);
|
|
|
return solverFactory;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退火炉作业提前合并
|
|
|
+ * @param productionScheduleVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ProductionProcesses> thProcessMerge(ProductionScheduleVo productionScheduleVo){
|
|
|
+ List<ProductionProcesses> processes = productionScheduleVo.getProcesses();
|
|
|
+ // 设备集合
|
|
|
+ List<Equipment> equipmentList = productionScheduleVo.getEquipmentList();
|
|
|
+ List<ProductionProcesses> mergeprocesses = new ArrayList<>();
|
|
|
+ // 所有作业集合
|
|
|
+ Map<String,ProductionProcesses> allProMap = new HashMap<>();
|
|
|
+ // 退火作业集合
|
|
|
+ Map<String,List<ProductionProcesses>> thproMap = new HashMap<>();
|
|
|
+ for (ProductionProcesses process : processes) {
|
|
|
+ if("成退".equals(process.getProcessType()) || "中退".equals(process.getProcessType()) || "小卷成退".equals(process.getProcessType())){
|
|
|
+ String bsproid = process.getBsProcessesId().get(0);
|
|
|
+ List<ProductionProcesses> bsprocess = thproMap.get(bsproid);
|
|
|
+ if(bsprocess == null){
|
|
|
+ bsprocess = new ArrayList<>();
|
|
|
+ }
|
|
|
+ bsprocess.add(process);
|
|
|
+ thproMap.put(bsproid,bsprocess);
|
|
|
+ }else{
|
|
|
+ mergeprocesses.add(process);
|
|
|
+ }
|
|
|
+ allProMap.put(process.getId(),process);
|
|
|
+ }
|
|
|
+ // 退火合并
|
|
|
+ if(thproMap != null && thproMap.size()>0){
|
|
|
+ thproMap.forEach((k,v)->{
|
|
|
+ if(v.size()>1){
|
|
|
+ // 作业卷数大于1,合并退火
|
|
|
+ List<Equipment> equipments = equipmentList.stream().filter(eq -> eq.getId().equals(v.get(0).getOptionalEquipments().get(0))).collect(Collectors.toList());
|
|
|
+ if(equipments != null && equipments.size()>0){
|
|
|
+ Equipment equipment = equipments.get(0);
|
|
|
+ // 根据承重计算最大几卷
|
|
|
+ int a = equipment.getEquipmentParameter().getEquipmentBearing().divide(v.get(0).getSinglerollweight(), 2, RoundingMode.HALF_UP).intValue();
|
|
|
+ // 根据宽度计算最大几卷
|
|
|
+ if("成退".equals(v.get(0).getProcessType()) || "中退".equals(v.get(0).getProcessType())){
|
|
|
+ int b = equipment.getEquipmentParameter().getEquipmentWidth().divide(v.get(0).getVolumeWidth().add(equipment.getEquipmentParameter().getFurnace()), 2, RoundingMode.HALF_UP).intValue();
|
|
|
+ if(b<a){
|
|
|
+ a = b;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 作业计划加工卷数是否大于一炉最大卷数
|
|
|
+ List<List<ProductionProcesses>> chunks = new ArrayList<>();
|
|
|
+ int listSize = v.size();
|
|
|
+ for (int i = 0; i < listSize; i += a) {
|
|
|
+ chunks.add(v.subList(i, Math.min(i + a, listSize)));
|
|
|
+ }
|
|
|
+ // 合并退火作业
|
|
|
+ for (List<ProductionProcesses> thps : chunks) {
|
|
|
+ for (int i = 0; i < thps.size(); i++) {
|
|
|
+ if(i>0){
|
|
|
+ // 退火前一道作业设置下一作业ID
|
|
|
+ ProductionProcesses prepro = allProMap.get(thps.get(i).getPreviousProcessesIds().get(0));
|
|
|
+ List<String> nextids = new ArrayList<>();
|
|
|
+ nextids.add(thps.get(0).getId());
|
|
|
+ prepro.setNextProcessesIds(nextids);
|
|
|
+ thps.get(0).getPreviousProcessesIds().add(prepro.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 取第一个作业作为合并作业
|
|
|
+ ProductionProcesses mergePro = thps.get(0);
|
|
|
+ mergePro.setVolumeWidth(mergePro.getVolumeWidth().multiply(new BigDecimal(thps.size())));
|
|
|
+ mergePro.setSinglerollweight(mergePro.getSinglerollweight().multiply(new BigDecimal(thps.size())));
|
|
|
+ mergePro.setOpeProducePcNum(thps.size());
|
|
|
+ mergeprocesses.add(mergePro);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ mergeprocesses.addAll(v);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return mergeprocesses;
|
|
|
+ }
|
|
|
}
|