Merge branch 'develop-business-css' of http://121.37.111.42:3000/ThbTech/JavaProjectRepo into develop-business-css
This commit is contained in:
commit
a9b5057d9d
@ -246,9 +246,9 @@ public class ProjectController {
|
||||
* @param id 项目ID
|
||||
* @return 标准响应结构,data 为 List<Device>
|
||||
*/
|
||||
@Operation(summary = "解析拓扑设备顺序", description = "根据 devices 出现顺序返回设备列表")
|
||||
@Operation(summary = "解析拓扑设备顺序", description = "根据 devices 出现顺序返回设备与物料属性视图")
|
||||
public ResponseEntity<Map<String, Object>> 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", "解析成功",
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -22,11 +22,6 @@ public interface ProjectService extends IService<Project> {
|
||||
*/
|
||||
com.yfd.business.css.dto.TopologyParseResult parseTopology(String projectId);
|
||||
|
||||
/**
|
||||
* 解析指定项目的设备有序列表
|
||||
* @param projectId 项目ID
|
||||
* @return List<Device>(按拓扑 devices 出现顺序返回)
|
||||
*/
|
||||
java.util.List<com.yfd.business.css.domain.Device> parseDeviceOrder(String projectId);
|
||||
|
||||
/**
|
||||
@ -38,4 +33,6 @@ public interface ProjectService extends IService<Project> {
|
||||
|
||||
java.util.Map<String, Object> initSimulation(String projectId, String scenarioId, java.util.Map<String, Object> params);
|
||||
|
||||
java.util.List<java.util.Map<String, Object>> parseDeviceOrderWithMaterials(String projectId);
|
||||
|
||||
}
|
||||
|
||||
@ -352,11 +352,6 @@ public class ProjectServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 基于项目拓扑 devices,收集 deviceId 并返回对应设备列表(按出现顺序)
|
||||
* @param projectId 项目ID
|
||||
* @return List<Device>
|
||||
*/
|
||||
public List<Device> parseDeviceOrder(String projectId) {
|
||||
try {
|
||||
Project p = this.getById(projectId);
|
||||
@ -504,6 +499,102 @@ public class ProjectServiceImpl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> parseDeviceOrderWithMaterials(String projectId) {
|
||||
try {
|
||||
Project p = this.getById(projectId);
|
||||
List<Map<String, Object>> 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<String> deviceIds = new ArrayList<>();
|
||||
Map<String, String> devToMat = new HashMap<>();
|
||||
Map<String, Map<String, Object>> 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<String, Object> 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<Device> devs = deviceService.list(new QueryWrapper<Device>().in("device_id", deviceIds));
|
||||
Map<String, Device> devMap = new HashMap<>();
|
||||
for (Device d : devs) devMap.put(d.getDeviceId(), d);
|
||||
Set<String> matIds = new HashSet<>(devToMat.values());
|
||||
List<Material> mats = matIds.isEmpty() ? List.of() : materialService.list(new QueryWrapper<Material>().in("material_id", matIds));
|
||||
Map<String, Material> 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<String, Object> 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<String, Object> 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<String, Object> initSimulation(String projectId, String scenarioId, Map<String, Object> params) {
|
||||
Map<String, Object> out = new HashMap<>();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user