From d2b1a724f2a480fca2bd1b92e4d4a175eb634875 Mon Sep 17 00:00:00 2001
From: rain <1679827795@qq.com>
Date: Wed, 14 Jan 2026 09:19:42 +0800
Subject: [PATCH] 设备配置表信息
---
drone-service/drone-fw/src/main/java/org/sxkj/fw/detection/controller/FwDeviceConfigController.java | 89 ++++++++++++++++++++++++++++++++------------
1 files changed, 65 insertions(+), 24 deletions(-)
diff --git a/drone-service/drone-fw/src/main/java/org/sxkj/fw/detection/controller/FwDeviceConfigController.java b/drone-service/drone-fw/src/main/java/org/sxkj/fw/detection/controller/FwDeviceConfigController.java
index e2af4cd..121a901 100644
--- a/drone-service/drone-fw/src/main/java/org/sxkj/fw/detection/controller/FwDeviceConfigController.java
+++ b/drone-service/drone-fw/src/main/java/org/sxkj/fw/detection/controller/FwDeviceConfigController.java
@@ -64,9 +64,18 @@
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
- @ApiOperation(value = "详情", notes = "传入fwDeviceConfig")
- public R<FwDeviceConfigVO> detail(FwDeviceConfigEntity fwDeviceConfig) {
- FwDeviceConfigEntity detail = fwDeviceConfigService.getOne(Condition.getQueryWrapper(fwDeviceConfig));
+ @ApiOperation(value = "详情", notes = "传入deviceId")
+ public R<FwDeviceConfigVO> detail(@ApiParam(value = "设备id", required = true) @RequestParam Long deviceId) {
+ if (deviceId == null) {
+ return R.fail("设备id不能为空");
+ }
+ FwDeviceConfigEntity detail = fwDeviceConfigService.selectLatestByDeviceId(deviceId);
+ if (detail == null) {
+ detail = fwDeviceConfigService.selectLatestVersionByDeviceId(deviceId);
+ }
+ if (detail == null) {
+ return R.fail("数据不存在");
+ }
return R.data(FwDeviceConfigWrapper.build().entityVO(detail));
}
/**
@@ -90,26 +99,26 @@
IPage<FwDeviceConfigVO> pages = fwDeviceConfigService.selectFwDeviceConfigPage(Condition.getPage(query), fwDeviceConfig);
return R.data(pages);
}
-
- /**
- * 设备配置表 新增
- */
- @PostMapping("/save")
- @ApiOperationSupport(order = 4)
- @ApiOperation(value = "新增", notes = "传入fwDeviceConfig")
- public R save(@Valid @RequestBody FwDeviceConfigEntity fwDeviceConfig) {
- return R.status(fwDeviceConfigService.save(fwDeviceConfig));
- }
-
- /**
- * 设备配置表 修改
- */
- @PostMapping("/update")
- @ApiOperationSupport(order = 5)
- @ApiOperation(value = "修改", notes = "传入fwDeviceConfig")
- public R update(@Valid @RequestBody FwDeviceConfigEntity fwDeviceConfig) {
- return R.status(fwDeviceConfigService.updateById(fwDeviceConfig));
- }
+//
+// /**
+// * 设备配置表 新增
+// */
+// @PostMapping("/save")
+// @ApiOperationSupport(order = 4)
+// @ApiOperation(value = "新增", notes = "传入fwDeviceConfig")
+// public R save(@Valid @RequestBody FwDeviceConfigEntity fwDeviceConfig) {
+// return saveOrUpdateConfig(fwDeviceConfig);
+// }
+//
+// /**
+// * 设备配置表 修改
+// */
+// @PostMapping("/update")
+// @ApiOperationSupport(order = 5)
+// @ApiOperation(value = "修改", notes = "传入fwDeviceConfig")
+// public R update(@Valid @RequestBody FwDeviceConfigEntity fwDeviceConfig) {
+// return saveOrUpdateConfig(fwDeviceConfig);
+// }
/**
* 设备配置表 新增或修改
@@ -118,7 +127,7 @@
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入fwDeviceConfig")
public R submit(@Valid @RequestBody FwDeviceConfigEntity fwDeviceConfig) {
- return R.status(fwDeviceConfigService.saveOrUpdate(fwDeviceConfig));
+ return saveOrUpdateConfig(fwDeviceConfig);
}
/**
@@ -148,4 +157,36 @@
ExcelUtil.export(response, "设备配置表数据" + DateUtil.time(), "设备配置表数据表", list, FwDeviceConfigExcel.class);
}
+ private R saveOrUpdateConfig(FwDeviceConfigEntity fwDeviceConfig) {
+ if (fwDeviceConfig == null || fwDeviceConfig.getDeviceId() == null) {
+ return R.fail("设备id不能为空");
+ }
+ Long deviceId = fwDeviceConfig.getDeviceId();
+ FwDeviceConfigEntity existing = null;
+ if (fwDeviceConfig.getId() != null) {
+ existing = fwDeviceConfigService.getById(fwDeviceConfig.getId());
+ if (existing == null) {
+ return R.fail("数据不存在");
+ }
+ }
+ if (existing == null) {
+ Integer maxVersion = fwDeviceConfigService.selectMaxConfigVersion(deviceId);
+ fwDeviceConfig.setConfigVersion(maxVersion == null ? 1 : maxVersion + 1);
+ fwDeviceConfig.setIsLatest((byte) 1);
+ fwDeviceConfigService.resetLatestByDeviceId(deviceId, null);
+ return R.status(fwDeviceConfigService.save(fwDeviceConfig));
+ }
+
+ if (fwDeviceConfig.getConfigVersion() == null) {
+ fwDeviceConfig.setConfigVersion(existing.getConfigVersion());
+ }
+ if (fwDeviceConfig.getIsLatest() == null) {
+ fwDeviceConfig.setIsLatest(existing.getIsLatest());
+ }
+ if (fwDeviceConfig.getIsLatest() != null && fwDeviceConfig.getIsLatest() == 1) {
+ fwDeviceConfigService.resetLatestByDeviceId(deviceId, fwDeviceConfig.getId());
+ }
+ return R.status(fwDeviceConfigService.updateById(fwDeviceConfig));
+ }
+
}
--
Gitblit v1.9.3