| | |
| | | import com.mes.device.service.DeviceInteractionService; |
| | | 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 io.swagger.annotations.ApiParam; |
| | | import lombok.Data; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | | @RequestMapping("device/interaction") |
| | | @Tag(name = "设备交互", description = "设备交互逻辑执行接口") |
| | | @Api(tags = "设备交互") |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | public class DeviceInteractionController { |
| | |
| | | private final DeviceInteractionService deviceInteractionService; |
| | | |
| | | @PostMapping("/glass-feed") |
| | | @Operation(summary = "玻璃上料写入") |
| | | @ApiOperation("玻璃上料写入") |
| | | public Result<DevicePlcVO.OperationResult> feedGlass(@Valid @RequestBody DeviceGlassFeedRequest request) { |
| | | return Result.success(deviceInteractionService.feedGlass(request)); |
| | | } |
| | | |
| | | @PostMapping("/execute") |
| | | @ApiOperation("执行设备逻辑操作") |
| | | public Result<DevicePlcVO.OperationResult> executeOperation( |
| | | @Valid @RequestBody DeviceOperationRequest request) { |
| | | return Result.success(deviceInteractionService.executeOperation( |
| | | request.getDeviceId(), |
| | | request.getOperation(), |
| | | request.getParams() |
| | | )); |
| | | } |
| | | |
| | | /** |
| | | * 设备操作请求 |
| | | */ |
| | | @Data |
| | | public static class DeviceOperationRequest { |
| | | @NotNull(message = "设备ID不能为空") |
| | | @ApiParam(value = "设备ID", required = true) |
| | | private Long deviceId; |
| | | |
| | | @NotNull(message = "操作类型不能为空") |
| | | @ApiParam(value = "操作类型(如:feedGlass, triggerRequest, triggerReport等)", required = true) |
| | | private String operation; |
| | | |
| | | @ApiParam(value = "操作参数") |
| | | private Map<String, Object> params; |
| | | } |
| | | } |
| | | |