//package com.friday.tooldriver.controller;
//
//import com.friday.tooldriver.dto.smartrpa.SmartJobDto;
//import com.friday.tooldriver.dto.smartrpa.SmartRobotDto;
//import com.friday.tooldriver.service.rpa.supplier.smartrpa.JobExecManager;
//import com.friday.tooldriver.service.rpa.supplier.smartrpa.RobotManager;
//import com.friday.base.common.response.DubboResult;
//import com.friday.base.web.response.ResponseAspect;
//import com.friday.operation.api.distributor.dto.StandardRpaInput;
//import com.friday.operation.api.keepalive.dto.smartrpa.HeartbeatReq;
//import com.friday.operation.api.keepalive.dto.smartrpa.HeartbeatResp;
//import com.friday.operation.api.tooldriver.service.ISmartRPAHeartbeatService;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//@RestController
//@RequestMapping(value = "driver/smart-rpa/execute")
//@Slf4j
//public class SmartRpaController {
//
//    @Autowired
//    private ResponseAspect responseAspect;
//    @Autowired
//    private ISmartRPAHeartbeatService heartbeatService;
//    @Autowired
//    private JobExecManager jobExecManager;
//    @Autowired
//    private RobotManager robotManager;
//
//    @ApiOperation(value = "心跳")
//    @RequestMapping(value = "/heartbeat", method = RequestMethod.POST)
//    public Object heartbeat(@RequestBody HeartbeatReq heartBeat) {
//        DubboResult<HeartbeatResp> result = heartbeatService.heartbeat(heartBeat);
//        if (result.success()){
//            return this.responseAspect.success(result.getObject());
//        }
//        return this.responseAspect.success();
//    }
//
//    @ApiOperation(value = "新增任务")
//    @RequestMapping(value = "/addJob", method = RequestMethod.POST)
//    public Object addJob(@RequestBody SmartJobDto jobDto) {
//        return jobExecManager.startJob(jobDto);
//    }
//
//    @ApiOperation(value = "停止任务")
//    @RequestMapping(value = "/stopJob", method = RequestMethod.POST)
//    public void stopJob(@RequestParam String jobId) {
//        jobExecManager.stopJob(Integer.parseInt(jobId));
//    }
//
//    @ApiOperation(value = "暂停任务")
//    @RequestMapping(value = "/pauseJob", method = RequestMethod.POST)
//    public void pauseJob(@RequestParam String jobId) {
//        jobExecManager.pauseJob(Integer.parseInt(jobId));
//    }
//
//    @ApiOperation(value = "恢复任务")
//    @RequestMapping(value = "/resumeJob", method = RequestMethod.POST)
//    public void resumeJob(@RequestParam String jobId) {
//        jobExecManager.resumeJob(Integer.parseInt(jobId));
//    }
//
//    @ApiOperation(value = "创建机器人")
//    @RequestMapping(value = "/addRobot", method = RequestMethod.POST)
//    public Object addRobot(@RequestBody SmartRobotDto robotDto) {
//        return robotManager.createRobot(robotDto);
//    }
//
//    @ApiOperation(value = "收发许可")
//    @RequestMapping(value = "/distributeLicense", method = RequestMethod.POST)
//    public void distributeLicense(@RequestParam String robotKey, @RequestParam Boolean enable) {
//        robotManager.distributeLicense(robotKey, enable);
//    }
//
//    @ApiOperation(value = "设置机器人状态")
//    @RequestMapping(value = "/setRobotState", method = RequestMethod.POST)
//    public void setRobotState(@RequestParam String robotKey, @RequestParam String state) {
//        robotManager.setRobotState(robotKey, state);
//    }
//
//    @ApiOperation(value = "获取任务详情")
//    @RequestMapping(value = "/jobDetail", method = RequestMethod.GET)
//    public Object queryJobDetail(@RequestParam(name = "jobId") String jobId) {
//        DubboResult<StandardRpaInput> jobResult = heartbeatService.getJobDetail(jobId);
//        return responseAspect.success(jobResult.getObject());
//    }
//
//    @ApiOperation(value = "获取robot状态缓存")
//    @RequestMapping(value = "/getRobotStateCache", method = RequestMethod.POST)
//    public Object getRobotStateCache(@RequestParam(name = "robotKey") String robotKey) {
//        return robotManager.getRobotStateCache(robotKey);
//    }
//
//    @ApiOperation(value = "清除robot状态缓存")
//    @RequestMapping(value = "/clearRobotStateCache", method = RequestMethod.POST)
//    public Object clearRobotStateCache(@RequestParam(name = "all") boolean all, @RequestParam(name = "robotKey") String robotKey) {
//        return robotManager.clearRobotStateCache(all, robotKey);
//    }
//}