diff --git a/business-css/src/main/java/com/yfd/business/css/controller/ProjectController.java b/business-css/src/main/java/com/yfd/business/css/controller/ProjectController.java index 47168d3..70c8b15 100644 --- a/business-css/src/main/java/com/yfd/business/css/controller/ProjectController.java +++ b/business-css/src/main/java/com/yfd/business/css/controller/ProjectController.java @@ -246,9 +246,9 @@ public class ProjectController { * @param id 项目ID * @return 标准响应结构,data 为 List */ - @Operation(summary = "解析拓扑设备顺序", description = "根据 devices 出现顺序返回设备列表") + @Operation(summary = "解析拓扑设备顺序", description = "根据 devices 出现顺序返回设备与物料属性视图") public ResponseEntity> parseDeviceOrder(@PathVariable @Parameter(description = "项目ID", required = true) String id) { - var list = projectService.parseDeviceOrder(id); + Object list = projectService.parseDeviceOrderWithMaterials(id); return ResponseEntity.ok(Map.of( "code", 0, "msg", "解析成功", diff --git a/business-css/src/main/java/com/yfd/business/css/domain/Scenario.java b/business-css/src/main/java/com/yfd/business/css/domain/Scenario.java index f692bf3..d9740ba 100644 --- a/business-css/src/main/java/com/yfd/business/css/domain/Scenario.java +++ b/business-css/src/main/java/com/yfd/business/css/domain/Scenario.java @@ -35,4 +35,10 @@ public class Scenario implements Serializable { @TableField("modifier") private String modifier; + + @TableField("status") + private String status; + + @TableField("algorithm_type") + private String algorithmType; } diff --git a/business-css/src/main/java/com/yfd/business/css/service/ProjectService.java b/business-css/src/main/java/com/yfd/business/css/service/ProjectService.java index d2189dd..16cdf92 100644 --- a/business-css/src/main/java/com/yfd/business/css/service/ProjectService.java +++ b/business-css/src/main/java/com/yfd/business/css/service/ProjectService.java @@ -22,11 +22,6 @@ public interface ProjectService extends IService { */ com.yfd.business.css.dto.TopologyParseResult parseTopology(String projectId); - /** - * 解析指定项目的设备有序列表 - * @param projectId 项目ID - * @return List(按拓扑 devices 出现顺序返回) - */ java.util.List parseDeviceOrder(String projectId); /** @@ -38,4 +33,6 @@ public interface ProjectService extends IService { java.util.Map initSimulation(String projectId, String scenarioId, java.util.Map params); + java.util.List> parseDeviceOrderWithMaterials(String projectId); + } diff --git a/business-css/src/main/java/com/yfd/business/css/service/impl/ProjectServiceImpl.java b/business-css/src/main/java/com/yfd/business/css/service/impl/ProjectServiceImpl.java index b0a3b1d..a10d134 100644 --- a/business-css/src/main/java/com/yfd/business/css/service/impl/ProjectServiceImpl.java +++ b/business-css/src/main/java/com/yfd/business/css/service/impl/ProjectServiceImpl.java @@ -352,11 +352,6 @@ public class ProjectServiceImpl } @Override - /** - * 基于项目拓扑 devices,收集 deviceId 并返回对应设备列表(按出现顺序) - * @param projectId 项目ID - * @return List - */ public List parseDeviceOrder(String projectId) { try { Project p = this.getById(projectId); @@ -504,6 +499,102 @@ public class ProjectServiceImpl } } + @Override + public List> parseDeviceOrderWithMaterials(String projectId) { + try { + Project p = this.getById(projectId); + List> out = new ArrayList<>(); + if (p == null || p.getTopology() == null || p.getTopology().isBlank()) return out; + JsonNode root = objectMapper.readTree(p.getTopology()); + JsonNode devicesNode = root.path("devices"); + List deviceIds = new ArrayList<>(); + Map devToMat = new HashMap<>(); + Map> matTopo = new HashMap<>(); + if (devicesNode.isArray()) { + for (JsonNode dn : devicesNode) { + String did = optText(dn, "deviceId"); + if (did == null || did.isEmpty()) continue; + deviceIds.add(did); + String mid = null; + JsonNode mats = dn.path("materials"); + if (mats.isMissingNode() || mats.isNull()) mats = dn.path("material"); + if (mats.isArray()) { + for (JsonNode mn : mats) { + String m = optText(mn, "materialId"); + if (m != null && !m.isEmpty()) { mid = m; break; } + } + } else if (mats.isObject()) { + String m = optText(mats, "materialId"); + if (m != null && !m.isEmpty()) mid = m; + } + if (mid != null) devToMat.put(did, mid); + JsonNode mnode = mats.isArray() ? (mats.iterator().hasNext() ? mats.iterator().next() : null) : (mats.isObject() ? mats : null); + if (mnode != null) { + String topoMid = optText(mnode, "materialId"); + if (topoMid != null && !topoMid.isEmpty()) { + Map info = new HashMap<>(); + String mname = optText(mnode, "name"); + if (mname != null) info.put("materialName", mname); + JsonNode mstatic = mnode.path("static"); + if (mstatic.isObject()) { + if (mstatic.path("u_concentration").isNumber()) info.put("u_concentration", mstatic.path("u_concentration").numberValue()); + if (mstatic.path("u_enrichment").isNumber()) info.put("u_enrichment", mstatic.path("u_enrichment").numberValue()); + if (mstatic.path("pu_concentration").isNumber()) info.put("pu_concentration", mstatic.path("pu_concentration").numberValue()); + if (mstatic.path("pu_isotope").isNumber()) info.put("pu_isotope", mstatic.path("pu_isotope").numberValue()); + } + matTopo.put(topoMid, info); + } + } + } + } + List devs = deviceService.list(new QueryWrapper().in("device_id", deviceIds)); + Map devMap = new HashMap<>(); + for (Device d : devs) devMap.put(d.getDeviceId(), d); + Set matIds = new HashSet<>(devToMat.values()); + List mats = matIds.isEmpty() ? List.of() : materialService.list(new QueryWrapper().in("material_id", matIds)); + Map matMap = new HashMap<>(); + for (Material m : mats) matMap.put(m.getMaterialId(), m); + for (String did : deviceIds) { + Device d = devMap.get(did); + if (d == null) continue; + Map row = new HashMap<>(); + row.put("deviceId", d.getDeviceId()); + row.put("deviceName", d.getName()); + row.put("deviceType", d.getType()); + row.put("deviceCode", d.getCode()); + row.put("deviceSize", d.getSize()); + row.put("volume", d.getVolume()); + row.put("flow_rate", d.getFlowRate()); + row.put("pulse_velocity", d.getPulseVelocity()); + String mid = devToMat.get(did); + if (mid != null) { + Material m = matMap.get(mid); + row.put("materialId", mid); + if (m != null) { + row.put("materialName", m.getName()); + row.put("u_concentration", m.getUConcentration()); + row.put("u_enrichment", m.getUEnrichment()); + row.put("pu_concentration", m.getPuConcentration()); + row.put("pu_isotope", m.getPuIsotope()); + } else { + Map info = matTopo.get(mid); + if (info != null) { + if (info.get("materialName") != null) row.put("materialName", info.get("materialName")); + if (info.get("u_concentration") != null) row.put("u_concentration", info.get("u_concentration")); + if (info.get("u_enrichment") != null) row.put("u_enrichment", info.get("u_enrichment")); + if (info.get("pu_concentration") != null) row.put("pu_concentration", info.get("pu_concentration")); + if (info.get("pu_isotope") != null) row.put("pu_isotope", info.get("pu_isotope")); + } + } + } + out.add(row); + } + return out; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Override public Map initSimulation(String projectId, String scenarioId, Map params) { Map out = new HashMap<>();