| | |
| | | import com.mes.device.service.DevicePlcOperationService; |
| | | import com.mes.device.vo.DevicePlcVO; |
| | | import com.mes.vo.Result; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("device/plc") |
| | | @Tag(name = "设备PLC操作", description = "多设备PLC写入与状态查询接口") |
| | | @Api(tags = "设备PLC操作") |
| | | public class DevicePlcController { |
| | | |
| | | private final DevicePlcOperationService devicePlcOperationService; |
| | | |
| | | @PostMapping("/requests") |
| | | @Operation(summary = "批量触发PLC请求", description = "对指定设备发送PLC请求字") |
| | | @ApiOperation("批量触发PLC请求") |
| | | public Result<List<DevicePlcVO.OperationResult>> triggerRequests( |
| | | @Valid @RequestBody DevicePlcBatchRequest request) { |
| | | return Result.success(devicePlcOperationService.triggerRequest(request.getDeviceIds())); |
| | | } |
| | | |
| | | @PostMapping("/reports") |
| | | @Operation(summary = "批量模拟PLC汇报", description = "对指定设备模拟PLC任务完成汇报") |
| | | @ApiOperation("批量模拟PLC汇报") |
| | | public Result<List<DevicePlcVO.OperationResult>> triggerReports( |
| | | @Valid @RequestBody DevicePlcBatchRequest request) { |
| | | return Result.success(devicePlcOperationService.triggerReport(request.getDeviceIds())); |
| | | } |
| | | |
| | | @PostMapping("/resets") |
| | | @Operation(summary = "批量重置PLC状态", description = "重置指定设备关联PLC的关键字段") |
| | | @ApiOperation("批量重置PLC状态") |
| | | public Result<List<DevicePlcVO.OperationResult>> resetPlc( |
| | | @Valid @RequestBody DevicePlcBatchRequest request) { |
| | | return Result.success(devicePlcOperationService.resetDevices(request.getDeviceIds())); |
| | | } |
| | | |
| | | @PostMapping("/groups/{groupId}/request") |
| | | @Operation(summary = "设备组触发PLC请求", description = "对设备组内所有设备发送PLC请求字") |
| | | @ApiOperation("设备组触发PLC请求") |
| | | public Result<List<DevicePlcVO.OperationResult>> triggerGroupRequest( |
| | | @PathVariable Long groupId) { |
| | | return Result.success(devicePlcOperationService.triggerRequestByGroup(groupId)); |
| | | } |
| | | |
| | | @PostMapping("/groups/{groupId}/report") |
| | | @Operation(summary = "设备组模拟PLC汇报", description = "对设备组内所有设备模拟任务完成汇报") |
| | | @ApiOperation("设备组模拟PLC汇报") |
| | | public Result<List<DevicePlcVO.OperationResult>> triggerGroupReport( |
| | | @PathVariable Long groupId) { |
| | | return Result.success(devicePlcOperationService.triggerReportByGroup(groupId)); |
| | | } |
| | | |
| | | @GetMapping("/status/{deviceId}") |
| | | @Operation(summary = "查询设备PLC状态", description = "读取单台设备的PLC数据") |
| | | @ApiOperation("查询设备PLC状态") |
| | | public Result<DevicePlcVO.StatusInfo> readStatus(@PathVariable Long deviceId) { |
| | | return Result.success(devicePlcOperationService.readStatus(deviceId)); |
| | | } |
| | | |
| | | @GetMapping("/groups/{groupId}/status") |
| | | @Operation(summary = "查询设备组PLC状态", description = "读取设备组内所有设备的PLC数据") |
| | | @ApiOperation("查询设备组PLC状态") |
| | | public Result<List<DevicePlcVO.StatusInfo>> readGroupStatus(@PathVariable Long groupId) { |
| | | return Result.success(devicePlcOperationService.readStatusByGroup(groupId)); |
| | | } |