Commit bc529e67 authored by Tong Li's avatar Tong Li

Merge remote-tracking branch 'origin/master'

parents a8b02830 85fa9adb
......@@ -65,7 +65,7 @@ public class ChromosomeDataController {
// 文件实体必须要有sceneId
if (isFileEntity(entityName) && (sceneId == null || sceneId.isEmpty())) {
return R.ok(null);
return ok(emptyPageResult(paged));
}
Map<String, Object> result = chromosomeDataService.queryChromosomeDataWithConditions(
......@@ -225,6 +225,15 @@ public class ChromosomeDataController {
return false;
}
private Map<String, Object> emptyPageResult(Paged paged) {
Map<String, Object> result = new java.util.HashMap<>();
result.put("records", Collections.emptyList());
result.put("totalCount", 0);
result.put("pageIndex", paged != null && paged.getPageIndex() != null ? Math.max(1, paged.getPageIndex()) : 1);
result.put("size", paged != null && paged.getPageSize() != null ? paged.getPageSize() : 10);
return result;
}
/**
* 批量查询接口(report)
* 支持在一个请求中查询多个实体
......
......@@ -1649,6 +1649,11 @@ public class ChromosomeDataService {
result.put("totalCount", total);
result.put("pageIndex", page);
result.put("size", size);
} else if (data == null) {
result.put("records", Collections.emptyList());
result.put("totalCount", 0);
result.put("pageIndex", page);
result.put("size", size);
} else {
result.put("records", data);
result.put("totalCount", 1);
......
......@@ -47,6 +47,7 @@ import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
......@@ -1566,6 +1567,7 @@ public class PlanResultService {
// 5. 自动插单(占位后推 + 空挡前移)
GlobalParam globalParam = buildGlobalParamFromSnapshot(sceneId, chromosome, true);
ensureAutoInsertMachines(chromosome, newProdEquipments, baseTime, globalParam);
ScheduleOperationService scheduleOperation = new ScheduleOperationService(materialRequirementService, this);
scheduleOperation.InsertOrderAuto(
chromosome,
......@@ -1584,6 +1586,59 @@ public class PlanResultService {
return chromosome;
}
private void ensureAutoInsertMachines(Chromosome chromosome, List<ProdEquipment> newProdEquipments,
LocalDateTime baseTime, GlobalParam globalParam) {
if (chromosome == null || newProdEquipments == null || newProdEquipments.isEmpty()) {
return;
}
if (chromosome.getMachines() == null) {
chromosome.setMachines(new ArrayList<>());
}
if (chromosome.getInitMachines() == null) {
chromosome.setInitMachines(new ArrayList<>());
}
Set<Long> existingMachineIds = chromosome.getMachines().stream()
.filter(Objects::nonNull)
.map(Machine::getId)
.collect(Collectors.toSet());
Set<Long> requiredMachineIds = newProdEquipments.stream()
.map(ProdEquipment::getEquipId)
.filter(Objects::nonNull)
.collect(Collectors.toCollection(LinkedHashSet::new));
requiredMachineIds.removeAll(existingMachineIds);
if (requiredMachineIds.isEmpty()) {
return;
}
// 自动插单可能引入当前场景原来没有用到的设备,需要按设备日历补进染色体设备池。
MachineSchedulerService machineScheduler = new MachineSchedulerService(baseTime);
List<Machine> allMachines = globalParam != null && !globalParam.isIsUseCalendar()
? _routingDataService.InitNoCalendarToAllMachines(machineScheduler, baseTime)
: _routingDataService.InitCalendarToAllMachines(machineScheduler, baseTime);
Map<Long, Machine> machineById = allMachines.stream()
.filter(Objects::nonNull)
.collect(Collectors.toMap(Machine::getId, Function.identity(), (existing, replacement) -> existing));
List<Long> missingMachineIds = new ArrayList<>();
for (Long machineId : requiredMachineIds) {
Machine machine = machineById.get(machineId);
if (machine == null) {
missingMachineIds.add(machineId);
continue;
}
Machine machineCopy = ProductionDeepCopyUtil.deepCopy(machine, Machine.class);
Machine initMachineCopy = ProductionDeepCopyUtil.deepCopy(machine, Machine.class);
chromosome.getMachines().add(machineCopy);
chromosome.getInitMachines().add(initMachineCopy);
}
if (!missingMachineIds.isEmpty()) {
throw new RuntimeException("自动插单失败:新工序设备未找到设备资源/日历配置: " + missingMachineIds);
}
log.info("自动插单补充设备到当前排产设备池: sceneId={}, machineIds={}", chromosome.getScenarioID(), requiredMachineIds);
}
public Chromosome Move(String SceneId,List<Integer> opId, LocalDateTime newStartTime,
Long newMachineId,int lockStartTime) {
......
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