删除项目代码更新
This commit is contained in:
parent
9e8e54b284
commit
59d5675490
@ -183,11 +183,11 @@ public class ProjectController {
|
||||
* 5.1 导出项目工程(Excel 多 Sheet)
|
||||
* 输入参数:路径参数项目ID
|
||||
* 导出描述:返回 Excel 附件 `project_{id}.xlsx`,包含以下 Sheet:
|
||||
* - projects(项目)- project_id, code, name, description, topology,created_at, updated_at
|
||||
* - devices(设备)- device_id, project_id, code, type, name, size, volume, flow_rate, pulse_velocity, created_at, updated_at
|
||||
* - materials(物料)- material_id, project_id, name, u_concentration, uo2_density, u_enrichment, pu_concentration, puo2_density, pu_isotope, hno3_acidity, h2c2o4_concentration, organic_ratio, moisture_content, custom_attrs, created_at, updated_at
|
||||
* - scenarios(情景)- scenario_id, project_id, name, description, created_at, updated_at
|
||||
* - events(事件)- event_id, scenario_id, device_id, material_id, trigger_time, attr_changes, created_at
|
||||
* - projects(项目)- project_id, code, name, description, topology, visibility, creator, created_at, updated_at, modifier
|
||||
* - devices(设备)- device_id, project_id, code, type, name, size, volume, flow_rate, pulse_velocity, created_at, updated_at, modifier
|
||||
* - materials(物料)- material_id, project_id, name, u_concentration, uo2_density, u_enrichment, pu_concentration, puo2_density, pu_isotope, e_pu238, e_pu239, e_pu240, e_pu241, e_pu242, hno3_acidity, h2c2o4_concentration, organic_ratio, moisture_content, custom_attrs, icon_base64, created_at, updated_at, modifier
|
||||
* - scenarios(情景)- scenario_id, project_id, name, description, status, algorithm_type, keff_threshold, device_algo_config, fail_detail, created_at, updated_at, modifier
|
||||
* - events(事件)- event_id, scenario_id, device_id, material_id, trigger_time, attr_changes, created_at, updated_at, modifier
|
||||
* - scenario_results(情景结果)- scenario_id, device_id, step, keff_value, attr_state
|
||||
* 输出参数:附件字节流(application/octet-stream)
|
||||
* @param id 项目ID
|
||||
@ -207,7 +207,7 @@ public class ProjectController {
|
||||
|
||||
@Log(value = "导入项目工程", module = "项目管理")
|
||||
@PostMapping("/importProject")
|
||||
@Operation(summary = "导入项目工程(多Sheet)", description = "上传 Excel 工程文件;若项目ID存在且 overwrite=false 则返回提示;overwrite=true 将先删除再导入")
|
||||
@Operation(summary = "导入项目工程(多Sheet)", description = "上传 Excel 工程文件(与导出工程字段对齐,兼容旧版本缺少列);若项目ID存在且 overwrite=false 则返回提示;overwrite=true 将先删除再导入")
|
||||
public ResponseEntity<Map<String, Object>> importProject(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(defaultValue = "false") boolean overwrite) {
|
||||
var res = projectService.importProjectEngineeringExcel(file, overwrite);
|
||||
|
||||
@ -1247,7 +1247,7 @@ public class ProjectServiceImpl
|
||||
List<Event> events = scenarioIds.isEmpty()
|
||||
? List.of()
|
||||
: eventService.list(new QueryWrapper<Event>()
|
||||
.select("event_id","scenario_id","device_id","material_id","attr_changes","trigger_time","created_at","modifier")
|
||||
.select("event_id","scenario_id","device_id","material_id","attr_changes","trigger_time","created_at","updated_at","modifier")
|
||||
.in("scenario_id", scenarioIds)
|
||||
.orderByDesc("created_at"));
|
||||
List<ScenarioResult> results = scenarioIds.isEmpty()
|
||||
@ -1294,7 +1294,7 @@ public class ProjectServiceImpl
|
||||
for (int i=0;i<h2.length;i++) s2.autoSizeColumn(i);
|
||||
|
||||
Sheet s3 = wb.createSheet("materials");
|
||||
String[] h3 = {"material_id","project_id","name","u_concentration","uo2_density","u_enrichment","pu_concentration","puo2_density","pu_isotope","hno3_acidity","h2c2o4_concentration","organic_ratio","moisture_content","custom_attrs","created_at","updated_at","modifier"};
|
||||
String[] h3 = {"material_id","project_id","name","u_concentration","uo2_density","u_enrichment","pu_concentration","puo2_density","pu_isotope","e_pu238","e_pu239","e_pu240","e_pu241","e_pu242","hno3_acidity","h2c2o4_concentration","organic_ratio","moisture_content","custom_attrs","icon_base64","created_at","updated_at","modifier"};
|
||||
r = 0; Row rh3 = s3.createRow(r++); for (int i=0;i<h3.length;i++) rh3.createCell(i).setCellValue(h3[i]);
|
||||
for (Material m : materials) {
|
||||
Row row = s3.createRow(r++);
|
||||
@ -1307,19 +1307,25 @@ public class ProjectServiceImpl
|
||||
row.createCell(6).setCellValue(m.getPuConcentration()==null?"":m.getPuConcentration().toPlainString());
|
||||
row.createCell(7).setCellValue(m.getPuo2Density()==null?"":m.getPuo2Density().toPlainString());
|
||||
row.createCell(8).setCellValue(m.getPuIsotope()==null?"":m.getPuIsotope().toPlainString());
|
||||
row.createCell(9).setCellValue(m.getHno3Acidity()==null?"":m.getHno3Acidity().toPlainString());
|
||||
row.createCell(10).setCellValue(m.getH2c2o4Concentration()==null?"":m.getH2c2o4Concentration().toPlainString());
|
||||
row.createCell(11).setCellValue(m.getOrganicRatio()==null?"":m.getOrganicRatio().toPlainString());
|
||||
row.createCell(12).setCellValue(m.getMoistureContent()==null?"":m.getMoistureContent().toPlainString());
|
||||
row.createCell(13).setCellValue(m.getCustomAttrs()==null?"":m.getCustomAttrs());
|
||||
row.createCell(14).setCellValue(m.getCreatedAt()==null?"":fmt.format(m.getCreatedAt()));
|
||||
row.createCell(15).setCellValue(m.getUpdatedAt()==null?"":fmt.format(m.getUpdatedAt()));
|
||||
row.createCell(16).setCellValue(m.getModifier()==null?"":m.getModifier());
|
||||
row.createCell(9).setCellValue(m.getEPu238()==null?"":m.getEPu238().toPlainString());
|
||||
row.createCell(10).setCellValue(m.getEPu239()==null?"":m.getEPu239().toPlainString());
|
||||
row.createCell(11).setCellValue(m.getEPu240()==null?"":m.getEPu240().toPlainString());
|
||||
row.createCell(12).setCellValue(m.getEPu241()==null?"":m.getEPu241().toPlainString());
|
||||
row.createCell(13).setCellValue(m.getEPu242()==null?"":m.getEPu242().toPlainString());
|
||||
row.createCell(14).setCellValue(m.getHno3Acidity()==null?"":m.getHno3Acidity().toPlainString());
|
||||
row.createCell(15).setCellValue(m.getH2c2o4Concentration()==null?"":m.getH2c2o4Concentration().toPlainString());
|
||||
row.createCell(16).setCellValue(m.getOrganicRatio()==null?"":m.getOrganicRatio().toPlainString());
|
||||
row.createCell(17).setCellValue(m.getMoistureContent()==null?"":m.getMoistureContent().toPlainString());
|
||||
row.createCell(18).setCellValue(clampExcelCellText(m.getCustomAttrs()==null?"":m.getCustomAttrs()));
|
||||
row.createCell(19).setCellValue(clampExcelCellText(m.getIconBase64()==null?"":m.getIconBase64()));
|
||||
row.createCell(20).setCellValue(m.getCreatedAt()==null?"":fmt.format(m.getCreatedAt()));
|
||||
row.createCell(21).setCellValue(m.getUpdatedAt()==null?"":fmt.format(m.getUpdatedAt()));
|
||||
row.createCell(22).setCellValue(m.getModifier()==null?"":m.getModifier());
|
||||
}
|
||||
for (int i=0;i<h3.length;i++) s3.autoSizeColumn(i);
|
||||
|
||||
Sheet s4 = wb.createSheet("scenarios");
|
||||
String[] h4 = {"scenario_id","project_id","name","description","created_at","updated_at","modifier"};
|
||||
String[] h4 = {"scenario_id","project_id","name","description","status","algorithm_type","keff_threshold","device_algo_config","fail_detail","created_at","updated_at","modifier"};
|
||||
r = 0; Row rh4 = s4.createRow(r++); for (int i=0;i<h4.length;i++) rh4.createCell(i).setCellValue(h4[i]);
|
||||
for (Scenario sc : scenarios) {
|
||||
Row row = s4.createRow(r++);
|
||||
@ -1327,14 +1333,19 @@ public class ProjectServiceImpl
|
||||
row.createCell(1).setCellValue(sc.getProjectId());
|
||||
row.createCell(2).setCellValue(sc.getName()==null?"":sc.getName());
|
||||
row.createCell(3).setCellValue(sc.getDescription()==null?"":sc.getDescription());
|
||||
row.createCell(4).setCellValue(sc.getCreatedAt()==null?"":fmt.format(sc.getCreatedAt()));
|
||||
row.createCell(5).setCellValue(sc.getUpdatedAt()==null?"":fmt.format(sc.getUpdatedAt()));
|
||||
row.createCell(6).setCellValue(sc.getModifier()==null?"":sc.getModifier());
|
||||
row.createCell(4).setCellValue(sc.getStatus()==null?"":sc.getStatus());
|
||||
row.createCell(5).setCellValue(sc.getAlgorithmType()==null?"":sc.getAlgorithmType());
|
||||
row.createCell(6).setCellValue(sc.getKeffThreshold()==null?"":sc.getKeffThreshold().toPlainString());
|
||||
row.createCell(7).setCellValue(clampExcelCellText(sc.getDeviceAlgoConfig()==null?"":sc.getDeviceAlgoConfig()));
|
||||
row.createCell(8).setCellValue(clampExcelCellText(sc.getFailDetail()==null?"":sc.getFailDetail()));
|
||||
row.createCell(9).setCellValue(sc.getCreatedAt()==null?"":fmt.format(sc.getCreatedAt()));
|
||||
row.createCell(10).setCellValue(sc.getUpdatedAt()==null?"":fmt.format(sc.getUpdatedAt()));
|
||||
row.createCell(11).setCellValue(sc.getModifier()==null?"":sc.getModifier());
|
||||
}
|
||||
for (int i=0;i<h4.length;i++) s4.autoSizeColumn(i);
|
||||
|
||||
Sheet s5 = wb.createSheet("events");
|
||||
String[] h5 = {"event_id","scenario_id","device_id","material_id","trigger_time","attr_changes","created_at","modifier"};
|
||||
String[] h5 = {"event_id","scenario_id","device_id","material_id","trigger_time","attr_changes","created_at","updated_at","modifier"};
|
||||
r = 0; Row rh5 = s5.createRow(r++); for (int i=0;i<h5.length;i++) rh5.createCell(i).setCellValue(h5[i]);
|
||||
for (Event ev : events) {
|
||||
Row row = s5.createRow(r++);
|
||||
@ -1343,9 +1354,10 @@ public class ProjectServiceImpl
|
||||
row.createCell(2).setCellValue(ev.getDeviceId());
|
||||
row.createCell(3).setCellValue(ev.getMaterialId());
|
||||
row.createCell(4).setCellValue(ev.getTriggerTime()==null?0:ev.getTriggerTime());
|
||||
row.createCell(5).setCellValue(ev.getAttrChanges()==null?"":ev.getAttrChanges());
|
||||
row.createCell(5).setCellValue(clampExcelCellText(ev.getAttrChanges()==null?"":ev.getAttrChanges()));
|
||||
row.createCell(6).setCellValue(ev.getCreatedAt()==null?"":fmt.format(ev.getCreatedAt()));
|
||||
row.createCell(7).setCellValue(ev.getModifier()==null?"":ev.getModifier());
|
||||
row.createCell(7).setCellValue(ev.getUpdatedAt()==null?"":fmt.format(ev.getUpdatedAt()));
|
||||
row.createCell(8).setCellValue(ev.getModifier()==null?"":ev.getModifier());
|
||||
}
|
||||
for (int i=0;i<h5.length;i++) s5.autoSizeColumn(i);
|
||||
|
||||
@ -1486,11 +1498,17 @@ public class ProjectServiceImpl
|
||||
m.setPuConcentration(parseBigDecimal(cell(df, r, mh.get("pu_concentration"))));
|
||||
m.setPuo2Density(parseBigDecimal(cell(df, r, mh.get("puo2_density"))));
|
||||
m.setPuIsotope(parseBigDecimal(cell(df, r, mh.get("pu_isotope"))));
|
||||
m.setEPu238(parseBigDecimal(cell(df, r, mh.get("e_pu238"))));
|
||||
m.setEPu239(parseBigDecimal(cell(df, r, mh.get("e_pu239"))));
|
||||
m.setEPu240(parseBigDecimal(cell(df, r, mh.get("e_pu240"))));
|
||||
m.setEPu241(parseBigDecimal(cell(df, r, mh.get("e_pu241"))));
|
||||
m.setEPu242(parseBigDecimal(cell(df, r, mh.get("e_pu242"))));
|
||||
m.setHno3Acidity(parseBigDecimal(cell(df, r, mh.get("hno3_acidity"))));
|
||||
m.setH2c2o4Concentration(parseBigDecimal(cell(df, r, mh.get("h2c2o4_concentration"))));
|
||||
m.setOrganicRatio(parseBigDecimal(cell(df, r, mh.get("organic_ratio"))));
|
||||
m.setMoistureContent(parseBigDecimal(cell(df, r, mh.get("moisture_content"))));
|
||||
m.setCustomAttrs(cell(df, r, mh.get("custom_attrs")));
|
||||
m.setIconBase64(cell(df, r, mh.get("icon_base64")));
|
||||
m.setModifier(cell(df, r, mh.get("modifier")));
|
||||
String mCreated = cell(df, r, mh.get("created_at"));
|
||||
if (mCreated != null && !mCreated.isBlank()) {
|
||||
@ -1523,6 +1541,11 @@ public class ProjectServiceImpl
|
||||
sc.setProjectId(projectId);
|
||||
sc.setName(cell(df, r, sh.get("name")));
|
||||
sc.setDescription(cell(df, r, sh.get("description")));
|
||||
sc.setStatus(cell(df, r, sh.get("status")));
|
||||
sc.setAlgorithmType(cell(df, r, sh.get("algorithm_type")));
|
||||
sc.setKeffThreshold(parseBigDecimal(cell(df, r, sh.get("keff_threshold"))));
|
||||
sc.setDeviceAlgoConfig(normalizeJsonText(cell(df, r, sh.get("device_algo_config"))));
|
||||
sc.setFailDetail(normalizeJsonText(cell(df, r, sh.get("fail_detail"))));
|
||||
sc.setModifier(cell(df, r, sh.get("modifier")));
|
||||
String sCreated = cell(df, r, sh.get("created_at"));
|
||||
if (sCreated != null && !sCreated.isBlank()) {
|
||||
@ -1556,12 +1579,16 @@ public class ProjectServiceImpl
|
||||
ev.setDeviceId(cell(df, r, eh.get("device_id")));
|
||||
ev.setMaterialId(cell(df, r, eh.get("material_id")));
|
||||
ev.setTriggerTime(parseDoubleObj(cell(df, r, eh.get("trigger_time"))));
|
||||
ev.setAttrChanges(cell(df, r, eh.get("attr_changes")));
|
||||
ev.setAttrChanges(normalizeJsonText(cell(df, r, eh.get("attr_changes"))));
|
||||
ev.setModifier(cell(df, r, eh.get("modifier")));
|
||||
String eCreated = cell(df, r, eh.get("created_at"));
|
||||
if (eCreated != null && !eCreated.isBlank()) {
|
||||
try { ev.setCreatedAt(LocalDateTime.parse(eCreated, fmt)); } catch (Exception ignored) { }
|
||||
}
|
||||
String eUpdated = cell(df, r, eh.get("updated_at"));
|
||||
if (eUpdated != null && !eUpdated.isBlank()) {
|
||||
try { ev.setUpdatedAt(LocalDateTime.parse(eUpdated, fmt)); } catch (Exception ignored) { }
|
||||
}
|
||||
events.add(ev);
|
||||
}
|
||||
if (!events.isEmpty()) {
|
||||
@ -1652,6 +1679,12 @@ public class ProjectServiceImpl
|
||||
try { return new BigDecimal(s.trim()); } catch (Exception e) { return null; }
|
||||
}
|
||||
|
||||
private String normalizeJsonText(String s) {
|
||||
if (s == null) return null;
|
||||
String v = s.trim();
|
||||
return v.isEmpty() ? null : v;
|
||||
}
|
||||
|
||||
//运行项目模拟
|
||||
@Override
|
||||
public java.util.Map<String, Object> runSimulation(String projectId, String scenarioId, java.util.Map<String, Object> params) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user