Merge branch 'develop-business-css' of http://121.37.111.42:3000/ThbTech/JavaProjectRepo into develop-business-css

This commit is contained in:
limengnan 2026-05-18 16:23:14 +08:00
commit b2e250ac05
6 changed files with 75 additions and 16 deletions

View File

@ -27,7 +27,7 @@ export default ({ mode }: ConfigEnv): UserConfig => {
// 线上API地址 // 线上API地址
// target: 'http://192.168.1.166:8090/', // target: 'http://192.168.1.166:8090/',
// 本地API地址 // 本地API地址
target: 'http://192.168.1.166:8090', target: 'http://localhost:8090',
changeOrigin: true, changeOrigin: true,
ws: true, ws: true,
rewrite: path => rewrite: path =>

View File

@ -113,7 +113,7 @@ public class AlgorithmModelController {
} }
if (versionTag != null && !versionTag.isEmpty()) qw.eq("version_tag", versionTag); if (versionTag != null && !versionTag.isEmpty()) qw.eq("version_tag", versionTag);
if (isCurrent != null && !isCurrent.isEmpty()) qw.eq("is_current", isCurrent); if (isCurrent != null && !isCurrent.isEmpty()) qw.eq("is_current", isCurrent);
qw.orderByDesc("updated_at"); qw.orderByDesc("is_current").orderByDesc("updated_at");
Page<AlgorithmModel> page = new Page<>(pageNum, pageSize, true); Page<AlgorithmModel> page = new Page<>(pageNum, pageSize, true);
return algorithmModelService.page(page, qw); return algorithmModelService.page(page, qw);
} }

View File

@ -146,13 +146,14 @@ public class MaterialController {
@PreAuthorize("hasAuthority('material:export')") @PreAuthorize("hasAuthority('material:export')")
@Log(value = "导出物料", module = "物料管理") @Log(value = "导出物料", module = "物料管理")
@GetMapping("/export") @GetMapping("/export")
public ResponseEntity<byte[]> exportMaterialsV2(@RequestParam String projectId, public ResponseEntity<byte[]> exportMaterialsV2(@RequestParam(required = false) String projectId,
@RequestParam(required = false) List<String> ids, @RequestParam(required = false) List<String> ids,
@RequestParam(required = false) String nameLike) { @RequestParam(required = false) String nameLike) {
if (projectId != null && !projectId.isBlank() && !"-1".equals(projectId)) { String pid = (projectId == null || projectId.isBlank()) ? "-1" : projectId;
projectAccessHelper.assertCanReadProject(projectId); if (!"-1".equals(pid)) {
projectAccessHelper.assertCanReadProject(pid);
} }
byte[] bytes = materialService.exportMaterialsV2(projectId, ids, nameLike); byte[] bytes = materialService.exportMaterialsV2(pid, ids, nameLike);
String fn = "materials.xlsx"; String fn = "materials.xlsx";
return ResponseEntity.ok() return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fn) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fn)

View File

@ -21,6 +21,12 @@ import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("/scenario-results") @RequestMapping("/scenario-results")
@ -71,6 +77,28 @@ public class ScenarioResultController {
} }
Page<ScenarioResult> page = new Page<>(pageNum, pageSize); Page<ScenarioResult> page = new Page<>(pageNum, pageSize);
Page<ScenarioResult> data = scenarioResultService.page(page, qw.orderByAsc("step").orderByAsc("device_id")); Page<ScenarioResult> data = scenarioResultService.page(page, qw.orderByAsc("step").orderByAsc("device_id"));
List<ScenarioResult> records = data.getRecords();
if (records != null && !records.isEmpty()) {
Set<String> deviceIds = records.stream()
.map(ScenarioResult::getDeviceId)
.filter(id -> id != null && !id.isBlank())
.collect(Collectors.toSet());
if (!deviceIds.isEmpty()) {
List<Device> devices = deviceService.list(new QueryWrapper<Device>()
.select("device_id", "name", "type")
.in("device_id", deviceIds));
Map<String, Device> deviceMap = devices.stream()
.filter(d -> d.getDeviceId() != null && !d.getDeviceId().isBlank())
.collect(Collectors.toMap(Device::getDeviceId, d -> d, (a, b) -> a));
for (ScenarioResult r : records) {
Device d = deviceMap.get(r.getDeviceId());
if (d != null) {
r.setDeviceName(d.getName());
r.setDeviceType(d.getType());
}
}
}
}
return ResponseEntity.ok(java.util.Map.of( return ResponseEntity.ok(java.util.Map.of(
"code", 0, "code", 0,
"msg", "查询成功", "msg", "查询成功",
@ -121,6 +149,21 @@ public class ScenarioResultController {
} }
List<ScenarioResult> results = scenarioResultService.list(queryWrapper.orderByAsc("device_id").orderByAsc("step")); List<ScenarioResult> results = scenarioResultService.list(queryWrapper.orderByAsc("device_id").orderByAsc("step"));
Set<String> deviceIds = results.stream()
.map(ScenarioResult::getDeviceId)
.filter(id -> id != null && !id.isBlank())
.collect(Collectors.toSet());
Map<String, Device> deviceMap;
if (deviceIds.isEmpty()) {
deviceMap = java.util.Map.of();
} else {
List<Device> devices = deviceService.list(new QueryWrapper<Device>()
.select("device_id", "name", "type")
.in("device_id", deviceIds));
deviceMap = devices.stream()
.filter(d -> d.getDeviceId() != null && !d.getDeviceId().isBlank())
.collect(Collectors.toMap(Device::getDeviceId, d -> d, (a, b) -> a));
}
// 创建Excel工作簿 // 创建Excel工作簿
Workbook workbook = new XSSFWorkbook(); Workbook workbook = new XSSFWorkbook();
@ -149,11 +192,12 @@ public class ScenarioResultController {
dataStyle.setWrapText(true); dataStyle.setWrapText(true);
// 创建表头 // 创建表头
String[] headers = {"场景名称", "设备名称", "时点", "属性值", "Keff值"}; String[] headers = {"场景名称", "设备名称", "设备类型", "时点", "属性值", "Keff值"};
if (deviceId != null && !deviceId.isEmpty()) { if (deviceId != null && !deviceId.isEmpty()) {
Device dev = deviceService.getById(deviceId); Device dev = deviceMap.get(deviceId);
String deviceName = dev != null && dev.getName() != null ? dev.getName() : deviceId; String deviceName = dev != null && dev.getName() != null ? dev.getName() : deviceId;
String deviceType = dev != null && dev.getType() != null ? dev.getType() : "";
Sheet sheet = workbook.createSheet(deviceName); Sheet sheet = workbook.createSheet(deviceName);
Row headerRow = sheet.createRow(0); Row headerRow = sheet.createRow(0);
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
@ -171,14 +215,17 @@ public class ScenarioResultController {
cell1.setCellValue(deviceName); cell1.setCellValue(deviceName);
cell1.setCellStyle(dataStyle); cell1.setCellStyle(dataStyle);
Cell cell2 = row.createCell(2); Cell cell2 = row.createCell(2);
cell2.setCellValue(result.getStep()); cell2.setCellValue(deviceType);
cell2.setCellStyle(dataStyle); cell2.setCellStyle(dataStyle);
Cell cell3 = row.createCell(3); Cell cell3 = row.createCell(3);
cell3.setCellValue(result.getAttrState()); cell3.setCellValue(result.getStep());
cell3.setCellStyle(dataStyle); cell3.setCellStyle(dataStyle);
Cell cell4 = row.createCell(4); Cell cell4 = row.createCell(4);
cell4.setCellValue(result.getKeffValue() == null ? 0.0 : result.getKeffValue().doubleValue()); cell4.setCellValue(result.getAttrState());
cell4.setCellStyle(dataStyle); cell4.setCellStyle(dataStyle);
Cell cell5 = row.createCell(5);
cell5.setCellValue(result.getKeffValue() == null ? 0.0 : result.getKeffValue().doubleValue());
cell5.setCellStyle(dataStyle);
} }
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
sheet.autoSizeColumn(i); sheet.autoSizeColumn(i);
@ -196,8 +243,9 @@ public class ScenarioResultController {
} }
for (java.util.Map.Entry<String, java.util.List<ScenarioResult>> entry : byDevice.entrySet()) { for (java.util.Map.Entry<String, java.util.List<ScenarioResult>> entry : byDevice.entrySet()) {
String did = entry.getKey(); String did = entry.getKey();
Device dev = deviceService.getById(did); Device dev = deviceMap.get(did);
String deviceName = dev != null && dev.getName() != null ? dev.getName() : did; String deviceName = dev != null && dev.getName() != null ? dev.getName() : did;
String deviceType = dev != null && dev.getType() != null ? dev.getType() : "";
Sheet sheet = workbook.createSheet(deviceName); Sheet sheet = workbook.createSheet(deviceName);
Row headerRow = sheet.createRow(0); Row headerRow = sheet.createRow(0);
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
@ -215,14 +263,17 @@ public class ScenarioResultController {
cell1.setCellValue(deviceName); cell1.setCellValue(deviceName);
cell1.setCellStyle(dataStyle); cell1.setCellStyle(dataStyle);
Cell cell2 = row.createCell(2); Cell cell2 = row.createCell(2);
cell2.setCellValue(result.getStep()); cell2.setCellValue(deviceType);
cell2.setCellStyle(dataStyle); cell2.setCellStyle(dataStyle);
Cell cell3 = row.createCell(3); Cell cell3 = row.createCell(3);
cell3.setCellValue(result.getAttrState()); cell3.setCellValue(result.getStep());
cell3.setCellStyle(dataStyle); cell3.setCellStyle(dataStyle);
Cell cell4 = row.createCell(4); Cell cell4 = row.createCell(4);
cell4.setCellValue(result.getKeffValue() == null ? 0.0 : result.getKeffValue().doubleValue()); cell4.setCellValue(result.getAttrState());
cell4.setCellStyle(dataStyle); cell4.setCellStyle(dataStyle);
Cell cell5 = row.createCell(5);
cell5.setCellValue(result.getKeffValue() == null ? 0.0 : result.getKeffValue().doubleValue());
cell5.setCellStyle(dataStyle);
} }
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
sheet.autoSizeColumn(i); sheet.autoSizeColumn(i);

View File

@ -27,4 +27,10 @@ public class ScenarioResult implements Serializable {
@TableField("keff_value") @TableField("keff_value")
private BigDecimal keffValue; private BigDecimal keffValue;
@TableField(exist = false)
private String deviceName;
@TableField(exist = false)
private String deviceType;
} }

View File

@ -22,9 +22,10 @@ file-space:
model-path: D:/keff_dataSpace/models/ model-path: D:/keff_dataSpace/models/
dataset-path: D:/keff_dataSpace/datasets/ dataset-path: D:/keff_dataSpace/datasets/
upload-path: D:/keff_dataSpace/upload/ upload-path: D:/keff_dataSpace/upload/
# 安全配置 生产环境需要关闭permit
security: security:
dev: dev:
permit: true permit: false
# 注释掉这里的 file.name由 logback-spring.xml 接管,防止覆盖 # 注释掉这里的 file.name由 logback-spring.xml 接管,防止覆盖
# logging: # logging:
# file: # file: