Commit c977460e authored by Tong Li's avatar Tong Li

Merge remote-tracking branch 'origin/master'

parents 2bf4f011 ffd1e0bc
......@@ -215,7 +215,8 @@ public class ChromosomeDataController {
*/
private boolean isFileEntity(String entityName) {
// 这里列出所有文件实体的名称
String[] fileEntities = {"order", "entry", "machine", "globaloperationinfo", "groupresult", "prodprocessexec", "machineoption"};
String[] fileEntities = {"order", "entry", "machine", "globaloperationinfo", "groupresult", "prodprocessexec", "machineoption",
"task"};
for (String fileEntity : fileEntities) {
if (fileEntity.equalsIgnoreCase(entityName)) {
return true;
......
......@@ -1936,6 +1936,18 @@ if(targetOp.getSequence()>1) {
}
resetDecodeMaterials(chromosome, baseMaterialsSnapshot);
// 重解码前重新初始化物料需求缓存,同时给MaterialRequirementService设置本次排产基准时间。
List<Material> decodeMaterials = chromosome.getMaterials() == null
? new ArrayList<>()
: new ArrayList<>(chromosome.getMaterials().values());
materialRequirementService.preloadRoutingCache(
chromosome.getScenarioID(),
baseTime,
chromosome.getOrders(),
decodeMaterials,
chromosome.getAllOperations(),
globalParam != null && globalParam.isIsCheckSf()
);
MachineSchedulerService machineScheduler = new MachineSchedulerService(baseTime);
chromosome.setMachines(ProductionDeepCopyUtil.deepCopyList(chromosome.getInitMachines(),Machine.class) );
......@@ -1943,8 +1955,9 @@ if(targetOp.getSequence()>1) {
chromosome.getResult().clear();
chromosome.setResult(new CopyOnWriteArrayList<>());
// BOM计算会使用decoder里的materials,自动插单重排也必须传入当前物料快照。
return new GeneticDecoder(globalParam,baseTime, chromosome.getMachines(),
chromosome.getOrders(), null, machineScheduler,materialRequirementService,chromosome.getScenarioID());
chromosome.getOrders(), chromosome.getMaterials(), machineScheduler,materialRequirementService,chromosome.getScenarioID());
}
private TreeMap<String, Material> resolveDecodeMaterials(Chromosome chromosome) {
......
......@@ -5,6 +5,8 @@ import com.aps.common.util.R;
import com.aps.entity.Algorithm.Chromosome;
import com.aps.entity.Algorithm.GAScheduleResult;
import com.aps.entity.Algorithm.OrderMaterialRequirement;
import com.aps.entity.Gantt.ResourceGanttVO;
import com.aps.entity.Gantt.TaskVO;
import com.aps.entity.ProdProcessExec;
import com.aps.entity.Algorithm.GlobalOperationInfo;
import com.aps.entity.Algorithm.IDAndChildID.GroupResult;
......@@ -307,6 +309,7 @@ public class ChromosomeDataService {
entityClassMap.put("prodprocessexec", ProdProcessExec.class);
entityClassMap.put("globaloperationinfo", GlobalOperationInfo.class);
entityClassMap.put("groupresult", GroupResult.class);
entityClassMap.put("task", TaskVO.class);
return entityClassMap.get(entityName.toLowerCase());
}
......@@ -1180,6 +1183,13 @@ public class ChromosomeDataService {
config.setEntityName(entityName);
config.setDataSource(DataSourceType.FILE);
config.setFieldName("orders");
}
// 特殊处理:当实体是Task时,取资源甘特图中的TaskVO列表。
else if ("task".equalsIgnoreCase(key)) {
config = new EntityConfig();
config.setEntityName(entityName);
config.setDataSource(DataSourceType.FILE);
config.setFieldName("task");
} else {
// 自动创建数据库配置(默认行为)
config = createDefaultDbConfig(entityName);
......@@ -1277,6 +1287,12 @@ public class ChromosomeDataService {
}
try {
if ("task".equalsIgnoreCase(config.getEntityName())) {
Object result = extractResourceGanttTasks(chromosome);
fileDataCache.put(cacheKey, result);
return result;
}
String fieldName = config.getFieldName();
// 特殊处理:当实体是MachineOption时,使用allOperations字段
......@@ -1303,6 +1319,22 @@ public class ChromosomeDataService {
throw new RuntimeException("访问Chromosome字段失败: " + e.getMessage(), e);
}
}
private List<TaskVO> extractResourceGanttTasks(Chromosome chromosome) {
if (chromosome == null) {
return new ArrayList<>();
}
List<Machine> machineList = planResultService.InitCalendarToAllMachines3(chromosome);
List<ResourceGanttVO> resourceGanttVOs = planResultService.convertToResourceGanttVO1(chromosome, machineList);
if (resourceGanttVOs == null || resourceGanttVOs.isEmpty()) {
return new ArrayList<>();
}
return resourceGanttVOs.stream()
.filter(Objects::nonNull)
.filter(vo -> vo.getList() != null)
.flatMap(vo -> vo.getList().stream())
.collect(Collectors.toList());
}
/**
* 从缓存中获取反射字段,避免重复反射操作
......
......@@ -27,6 +27,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.imageio.ImageIO;
import java.awt.Color;
......@@ -1463,13 +1464,9 @@ public class PlanResultService {
if (groupCode != null) {
launchOrder.setGroupCode(groupCode);
}
try {
launchOrder.setOrderDesc(new ObjectMapper().writeValueAsString(newOrderData));
} catch (Exception e) {
launchOrder.setOrderDesc(String.valueOf(newOrderData));
}
}
@Transactional(rollbackFor = Exception.class)
public Chromosome InsertOrderAuto(String sceneId, Map<String, Object> newOrderData) {
if (newOrderData == null) {
throw new RuntimeException("newOrder 不能为空");
......@@ -1560,6 +1557,11 @@ public class PlanResultService {
if (apsTimeConfig != null && apsTimeConfig.getBaseTime() != null) {
baseTime = apsTimeConfig.getBaseTime();
}
if (baseTime == null) {
throw new RuntimeException("自动插单失败:排产基准时间为空");
}
// 自动插单后会重解码,染色体里的基准时间也要同步,避免后续按空基准时间计算。
chromosome.setBaseTime(baseTime);
LocalDateTime anchorTime = baseTime.plusSeconds(Math.max(freezeSeconds, 0L));
// 5. 自动插单(占位后推 + 空挡前移)
......
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