|
@ -2,6 +2,7 @@ package com.my.graphiteDigesterBg.diframe.api; |
|
|
import com.my.graphiteDigesterBg.diframe.*; |
|
|
import com.my.graphiteDigesterBg.diframe.*; |
|
|
import com.my.graphiteDigesterBg.diframe.model.DiMdbTaskExecution; |
|
|
import com.my.graphiteDigesterBg.diframe.model.DiMdbTaskExecution; |
|
|
import com.my.graphiteDigesterBg.diframe.model.DiMdbUser; |
|
|
import com.my.graphiteDigesterBg.diframe.model.DiMdbUser; |
|
|
|
|
|
import com.my.graphiteDigesterBg.diframe.util.DiClassHelper; |
|
|
import com.my.graphiteDigesterBg.model.MdbOperationLog; |
|
|
import com.my.graphiteDigesterBg.model.MdbOperationLog; |
|
|
import jakarta.annotation.Resource; |
|
|
import jakarta.annotation.Resource; |
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
import java.lang.reflect.Method; |
|
|
import java.lang.reflect.Method; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
@Controller |
|
|
@Controller |
|
|
public class DiApiTask extends DiApiControllerBase { |
|
|
public class DiApiTask extends DiApiControllerBase { |
|
@ -105,6 +108,40 @@ public class DiApiTask extends DiApiControllerBase { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ResponseBody |
|
|
@ResponseBody |
|
|
|
|
|
@PostMapping("/api/task/task-step-action-execute") |
|
|
|
|
|
public DiApiResponse taskStepActionExecute(@RequestBody Map<String,Object> params) { |
|
|
|
|
|
String id = (String)params.get("id"); |
|
|
|
|
|
String action = "action" + (String)params.get("action"); |
|
|
|
|
|
Object actionParams = params.get("params"); |
|
|
|
|
|
|
|
|
|
|
|
DiTaskExecutor executor = this.device.getTaskManager().getExecutor(); |
|
|
|
|
|
DiTask task = executor.getTaskByUUID(id); |
|
|
|
|
|
if ( null == task ) { |
|
|
|
|
|
return this.error("task not found"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var step = task.getStep(); |
|
|
|
|
|
if ( null == step ) { |
|
|
|
|
|
return this.error("no active step"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Object resultValue = null; |
|
|
|
|
|
try { |
|
|
|
|
|
resultValue = DiClassHelper.invokeMethod(step, action, List.of(actionParams)); |
|
|
|
|
|
} catch (NoSuchMethodException e) { |
|
|
|
|
|
try { |
|
|
|
|
|
resultValue = DiClassHelper.invokeMethod(step, action, List.of()); |
|
|
|
|
|
} catch (NoSuchMethodException ex) { |
|
|
|
|
|
return this.error("action method not found"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> result = new HashMap<>(); |
|
|
|
|
|
result.put("result", resultValue); |
|
|
|
|
|
return this.success(result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody |
|
|
@PostMapping("/api/task/execution-get") |
|
|
@PostMapping("/api/task/execution-get") |
|
|
public DiApiResponse executionGet(@RequestBody Map<String,Object> params) { |
|
|
public DiApiResponse executionGet(@RequestBody Map<String,Object> params) { |
|
|
String id = (String)params.get("id"); |
|
|
String id = (String)params.get("id"); |
|
|