6 changed files with 236 additions and 1 deletions
-
77src/main/java/com/iflytop/gd/app/controller/DeviceParamController.java
-
4src/main/java/com/iflytop/gd/app/model/entity/DeviceParamConfig.java
-
36src/main/java/com/iflytop/gd/app/model/vo/DeviceParamGroupVO.java
-
18src/main/java/com/iflytop/gd/app/model/vo/ModuleIdVO.java
-
16src/main/java/com/iflytop/gd/app/model/vo/RegIndexVO.java
-
86src/main/java/com/iflytop/gd/app/service/DeviceParamConfigService.java
@ -0,0 +1,77 @@ |
|||||
|
package com.iflytop.gd.app.controller; |
||||
|
|
||||
|
import com.iflytop.gd.app.model.entity.DeviceParamConfig; |
||||
|
import com.iflytop.gd.app.model.vo.DeviceParamGroupVO; |
||||
|
import com.iflytop.gd.app.model.vo.ModuleIdVO; |
||||
|
import com.iflytop.gd.app.model.vo.RegIndexVO; |
||||
|
import com.iflytop.gd.app.service.DeviceParamConfigService; |
||||
|
import com.iflytop.gd.common.result.Result; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import jakarta.validation.Valid; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 设备参数配置 |
||||
|
*/ |
||||
|
@Tag(name = "设备参数配置") |
||||
|
@RestController |
||||
|
@RequestMapping("/api/device-param") |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
public class DeviceParamController { |
||||
|
|
||||
|
private final DeviceParamConfigService deviceParamConfigService; |
||||
|
|
||||
|
@Operation(summary = "获取所有设备配置") |
||||
|
@GetMapping("/list") |
||||
|
public Result<List<DeviceParamGroupVO>> listGroupedParams() { |
||||
|
List<DeviceParamGroupVO> vos = deviceParamConfigService.listGroupedByModule(); |
||||
|
return Result.success(vos); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "获取所有设备模块") |
||||
|
@GetMapping("/modules") |
||||
|
public Result<List<ModuleIdVO>> listAllModules() { |
||||
|
List<ModuleIdVO> vos = deviceParamConfigService.listAllModuleIds(); |
||||
|
return Result.success(vos); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "获取所有设备模块配置项") |
||||
|
@GetMapping("/reg-indices") |
||||
|
public Result<List<RegIndexVO>> listAllRegIndices() { |
||||
|
List<RegIndexVO> vos = deviceParamConfigService.listAllRegIndices(); |
||||
|
return Result.success(vos); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Operation(summary = "添加新配置") |
||||
|
@PostMapping("") |
||||
|
public Result<String> add(@Valid @RequestBody DeviceParamConfig deviceParamConfig) { |
||||
|
deviceParamConfigService.save(deviceParamConfig); |
||||
|
return Result.success(); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "修改配置") |
||||
|
@PutMapping("") |
||||
|
public Result<String> update(@Valid @RequestBody DeviceParamConfig deviceParamConfig) { |
||||
|
deviceParamConfigService.updateById(deviceParamConfig); |
||||
|
return Result.success(); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "删除配置") |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public Result<String> deleteOres(@Parameter(description = "矿石ID,多个以英文逗号(,)分割") @PathVariable String ids) { |
||||
|
boolean isSuccess = deviceParamConfigService.deleteDeviceParam(ids); |
||||
|
if (isSuccess) { |
||||
|
return Result.success(); |
||||
|
} |
||||
|
return Result.failed(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.iflytop.gd.app.model.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 按模块分组的设备参数视图 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Schema(description = "按模块分组的设备参数") |
||||
|
public class DeviceParamGroupVO { |
||||
|
|
||||
|
@Schema(description = "模块标识(ModuleId.name),如 DoorM") |
||||
|
private String mid; |
||||
|
|
||||
|
@Schema(description = "该模块下的所有寄存器项") |
||||
|
private List<ParamItem> reg; |
||||
|
|
||||
|
public DeviceParamGroupVO(String mid, List<ParamItem> reg) { |
||||
|
this.mid = mid; |
||||
|
this.reg = reg; |
||||
|
} |
||||
|
|
||||
|
@AllArgsConstructor |
||||
|
@Data |
||||
|
@Schema(description = "单个寄存器项") |
||||
|
public static class ParamItem { |
||||
|
@Schema(description = "寄存器索引名,如 kreg_step_motor_pos") |
||||
|
private String name; |
||||
|
@Schema(description = "值") |
||||
|
private Integer value; |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.iflytop.gd.app.model.vo; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* ModuleId 的展示视图 |
||||
|
*/ |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@Schema(description = "ModuleId 的展示视图") |
||||
|
public class ModuleIdVO { |
||||
|
@Schema(description = "枚举常量名称,如 DoorM") |
||||
|
private String name; |
||||
|
|
||||
|
@Schema(description = "枚举描述") |
||||
|
private String description; |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.iflytop.gd.app.model.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* RegIndex 的展示视图 |
||||
|
*/ |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@Schema(description = "RegIndex 的展示视图") |
||||
|
public class RegIndexVO { |
||||
|
@Schema(description = "枚举常量名称,如 kreg_step_motor_pos") |
||||
|
private String name; |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue