Commit 411fba34 authored by DESKTOP-VKRD9QF\Administration's avatar DESKTOP-VKRD9QF\Administration
parents 6b4db4d5 e0ba6b7a
......@@ -72,5 +72,5 @@ public class OrderMaterialRequirement {
/**
* 创建或使用的半成品订单ID
*/
private List<Integer> productOrderID;
private List<String> productOrderID;
}
......@@ -4,6 +4,7 @@ import com.aps.entity.Algorithm.OperationDependency;
import com.aps.entity.RoutingDiscreteParam;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
......@@ -102,4 +103,21 @@ public class Entry {
*/
public Long EquipTypeID ;
/// <summary>
/// 当前工序依赖的前置工序ID(半成品工序→成品工序)
/// </summary>
public List<String> DependentOnOrderIds = new ArrayList<>();
/// <summary>
/// 关联的成品工序ID(核心:明确该半成品服务于哪个成品工序)
/// </summary>
public int TargetFinishedOperationId=0;
/// <summary>
/// 半成品最晚完工时间(即成品工序开始时间-1天)
/// </summary>
public LocalDateTime LatestCompletionTime ;
}
......@@ -4,6 +4,7 @@ import com.aps.common.util.DeepCopyUtil;
import com.aps.common.util.ProductionDeepCopyUtil;
import com.aps.entity.Algorithm.Chromosome;
import com.aps.entity.Algorithm.GlobalOperationInfo;
import com.aps.entity.Algorithm.IDAndChildID.GroupResult;
import com.aps.entity.Algorithm.Pair;
import com.aps.entity.Algorithm.ScheduleParams;
import com.aps.entity.basic.*;
......@@ -23,14 +24,16 @@ public class GeneticAlgorithm {
private final List<Order> orders;
private final List<Material> materials;
private static GlobalParam _GlobalParam;
private List<GroupResult> _entryRel;
public GeneticAlgorithm(GlobalParam globalParam,List<Machine> machines, List<Order> orders,
List<Material> materials, MachineSchedulerService machineScheduler) {
List<Material> materials, MachineSchedulerService machineScheduler,List<GroupResult> entryRel) {
this.machines = machines;
this.orders = orders;
this.materials = materials;
this.machineScheduler = machineScheduler;
_GlobalParam=globalParam;
_entryRel=entryRel;
}
public Chromosome Run(ScheduleParams param, List<Entry> allOperations) {
System.out.println("开始");
......@@ -134,6 +137,7 @@ public class GeneticAlgorithm {
best.setBaseTime(param.getBaseTime());
best.setInitMachines(ProductionDeepCopyUtil.deepCopyList(machines));
best.setOrders(orders);
best.setOperatRel(_entryRel);
// 步骤3:返回最优解
return best;
......
......@@ -3,15 +3,13 @@ package com.aps.service.Algorithm;
import com.aps.common.util.SnowFlackIdWorker;
import com.aps.entity.*;
import com.aps.entity.Algorithm.BOMBuildResult;
import com.aps.entity.Algorithm.IDAndChildID.GroupResult;
import com.aps.entity.Algorithm.OrderMaterialRequirement;
import com.aps.entity.basic.*;
import com.aps.mapper.RoutingHeaderMapper;
import com.aps.mapper.RoutingSupportingReplaceMapper;
import com.aps.mapper.RoutingsupportingMapper;
import com.aps.service.LanuchService;
import com.aps.service.ProdEquipSpecialCalService;
import com.aps.service.RoutingDetailConnectService;
import com.aps.service.RoutingHeaderService;
import com.aps.service.*;
import com.aps.service.impl.LanuchServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
......@@ -36,12 +34,19 @@ public class MaterialRequirementService {
private List<Entry> _allOperations;
private List<GroupResult> _entryRel;
private List<RoutingHeader> headers;
private List<Routingsupporting> routingsupportings;
private List<RoutingSupportingReplace> routingsupportingreplaces;
List<RoutingDetail> allRoutingDetails=new ArrayList<>();
List<RoutingDetailEquip> allroutingDetailEquips=new ArrayList<>();
List<RoutingDetailConnect> allroutingDetailconnections=new ArrayList<>();
List<RoutingDiscreteParam> allroutingDiscreteParams=new ArrayList<>();
@Autowired
RoutingDetailConnectService routingDetailConnectService;
......@@ -57,16 +62,21 @@ public class MaterialRequirementService {
@Autowired
RoutingsupportingMapper routingsupportingMapper;
@Autowired
RoutingDataService _routingDataService;
@Autowired
private RoutingDiscreteParamService _routingDiscreteParamService;
private LocalDateTime baseTime ;
public MaterialRequirementService(List<Material> materials,List<Order> _orders,List<Entry> allOperations)
public MaterialRequirementService(List<Material> materials,List<Order> _orders,List<Entry> allOperations,List<GroupResult> entryRel)
{
this.orders = _orders;
_allOperations=allOperations;
_materials=materials;
_entryRel=entryRel;
}
/**
......@@ -110,7 +120,7 @@ public class MaterialRequirementService {
}
// 递归展开BOM层级(通过结果对象接收out参数数据)
BOMBuildResult result = buildOrderBOM(demand.getRoutingId(),"", demand.getOrderId(), "",
BOMBuildResult result = buildOrderBOM(demand.getRoutingId(),"", demand.getOrderId(), demand.getOrderId(),
demand.getQuantity(), 0);
allRequirements.addAll(result.getMaterialRequirements());
childorders.addAll(result.getChildOrders());
......@@ -154,7 +164,7 @@ public class MaterialRequirementService {
// 遍历产品的工序,递归构建工序BOM
List<Entry> Operations= _allOperations.stream()
.filter(t->t.getOrderId()==mainorderId)
.filter(t->t.getOrderId()==childorderId)
.collect(Collectors.toList());
......@@ -183,17 +193,12 @@ public class MaterialRequirementService {
.eq(RoutingHeader::getIsDeleted, 0)
.eq(RoutingHeader::getApprovalStatus, 1); // 添加 is_deleted=0 过滤条件
RoutingHeader headers1 = routingHeaderMapper.selectOne(wrapper);
if(headers==null)
{
return;
}
if(headers==null)
{
return;
}
headers.add(headers1);
// List<Integer> routingIds = headers1.stream()
// .map(RoutingHeader::getId)
// .distinct()
// .collect(Collectors.toList());
Integer routingIds =headers1.getId();
LambdaQueryWrapper<Routingsupporting> routingsupportingwrapper = new LambdaQueryWrapper<>();
......@@ -202,6 +207,7 @@ if(headers==null)
List<Routingsupporting> routingsupportings1 = routingsupportingMapper.selectList(routingsupportingwrapper);
routingsupportings.addAll(routingsupportings1);
LambdaQueryWrapper<RoutingSupportingReplace> routingsupportingreplacewrapper = new LambdaQueryWrapper<>();
routingsupportingreplacewrapper.in(RoutingSupportingReplace::getStrsupid, routingIds)
.eq(RoutingSupportingReplace::getIsdeleted, 0);
......@@ -241,6 +247,24 @@ if(headers==null)
.map(connection -> lanuchService.createProcessRelation(prodOrderMain, connection, sceneId, routingDetailIdToExecIdMap))
.collect(Collectors.toList());
List<Long> routingDetailIds = RoutingDetails.stream()
.map(RoutingDetail::getId)
.distinct()
.collect(Collectors.toList());
List<RoutingDiscreteParam> routingDiscreteParams = _routingDiscreteParamService.lambdaQuery()
.in(RoutingDiscreteParam::getRoutingDetailId, routingDetailIds)
.eq(RoutingDiscreteParam::getIsDeleted, 0)
.list();
List<ProdLaunchOrder> ProdLaunchOrders=new ArrayList<>();
ProdLaunchOrders.add(prodOrderMain);
Map<Integer, Object> list=_routingDataService.CreateEntry( sceneId, ProdEquipmentList, ProdLaunchOrders, routingDiscreteParams, ProdOrderProcesslist, processExecList,_entryRel );
}
private ProdLaunchOrder convertToLaunchOrder(Order order, String sceneId) {
......@@ -378,7 +402,7 @@ if(headers==null)
order.setFinishOrderId(new ArrayList<>());
}
order.getFinishOrderId().add(orderId);
orderMaterial.getProductOrderID().add(order.getId());
orderMaterial.getProductOrderID().add(order.getOrderId());
double useq = Math.min(needed, order.getSYQuantity());
needed -= useq;
......@@ -392,6 +416,7 @@ if(headers==null)
order.getQuantity(), l);
materialRequirements.addAll(childResult.getMaterialRequirements());
_childorders.addAll(childResult.getChildOrders());
operation.getDependentOnOrderIds().add(order.getOrderId());
}
if (needed <= 0) {
......@@ -415,9 +440,9 @@ if(headers==null)
childorder.setFinishOrderId(new ArrayList<>());
childorder.getFinishOrderId().add(orderId);
_childorders.add(childorder);
orderMaterial.getProductOrderID().add(childorder.getId());
CreateChild(childorder,material.getId());
orderMaterial.getProductOrderID().add(OrderId);
operation.getDependentOnOrderIds().add(OrderId);
// 递归构建BOM
int l = level + 1;
BOMBuildResult childResult = buildOrderBOM(0, material.getId(),
......
......@@ -246,7 +246,7 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
}
GlobalParam globalParam=new GlobalParam();
// 5. 执行调度算法
GeneticAlgorithm scheduler =new GeneticAlgorithm(globalParam,machines,orders,null,machineScheduler); //new GeneticAlgorithm(products, machines, orders, machineScheduler);
GeneticAlgorithm scheduler =new GeneticAlgorithm(globalParam,machines,orders,null,machineScheduler,null); //new GeneticAlgorithm(products, machines, orders, machineScheduler);
Chromosome Chromosomes =scheduler.Run(param,allOperations);
WriteScheduleSummary(Chromosomes);
ScheduleOperationService ScheduleOperation=new ScheduleOperationService();
......@@ -308,9 +308,9 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
GlobalParam globalParam=new GlobalParam();
// 5. 执行调度算法
GeneticAlgorithm scheduler =new GeneticAlgorithm(globalParam,machines,orders,null,machineScheduler); //new GeneticAlgorithm(products, machines, orders, machineScheduler);
GeneticAlgorithm scheduler =new GeneticAlgorithm(globalParam,machines,orders,null,machineScheduler,entryRel); //new GeneticAlgorithm(products, machines, orders, machineScheduler);
Chromosome chromosome =scheduler.Run(param,entrys);
chromosome.setOperatRel(entryRel);
_sceneService.saveChromosomeToFile(chromosome, SceneId);
// Chromosomes.forEach(this::WriteScheduleSummary);
......@@ -522,7 +522,7 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
GlobalParam globalParam=new GlobalParam();
// 5. 执行调度算法
GeneticAlgorithm scheduler =new GeneticAlgorithm(globalParam,machines,orders,null,machineScheduler); //new GeneticAlgorithm(products, machines, orders, machineScheduler);
GeneticAlgorithm scheduler =new GeneticAlgorithm(globalParam,machines,orders,null,machineScheduler,entryRel); //new GeneticAlgorithm(products, machines, orders, machineScheduler);
Chromosome chromosomes =scheduler.Run(param,entrys);
chromosomes.setScenarioID(SceneId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment