|
@@ -8,10 +8,13 @@ import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.taais.biz.constant.BizConstant;
|
|
|
import com.taais.biz.domain.TargetIdentificationSubtask;
|
|
|
import com.taais.biz.domain.TargetIdentificationSubtaskDetails;
|
|
|
import com.taais.biz.domain.vo.TargetIdentificationSubtaskVo;
|
|
|
+import com.taais.biz.service.impl.CommonAlgorithmConfigServiceImpl;
|
|
|
import com.taais.biz.service.impl.TargetIdentificationSubtaskServiceImpl;
|
|
|
import com.taais.biz.service.impl.TargetIdentificationTaskServiceImpl;
|
|
|
import com.taais.biz.utils.ZipDirectory;
|
|
@@ -36,6 +39,8 @@ import com.taais.biz.service.ITargetIdentificationSubtaskDetailsService;
|
|
|
|
|
|
import com.taais.common.core.core.page.PageResult;
|
|
|
|
|
|
+import static com.taais.biz.constant.BizConstant.TYPE_DATA_BIZ_PROCESS;
|
|
|
+
|
|
|
/**
|
|
|
* 目标识别子任务Controller
|
|
|
*
|
|
@@ -54,6 +59,9 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
|
|
|
@Resource
|
|
|
private TargetIdentificationSubtaskServiceImpl subtaskService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CommonAlgorithmConfigServiceImpl algorithmConfigService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询目标识别子任务列表
|
|
|
*/
|
|
@@ -127,6 +135,79 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
|
|
|
return CommonResult.success();
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/continueTask")
|
|
|
+ public CommonResult<Void> continueTask(@RequestBody Map<String, String> params) {
|
|
|
+ params.put("bizType", TYPE_DATA_BIZ_PROCESS);
|
|
|
+ if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
|
|
|
+ return CommonResult.fail("Error parameters");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String url = algorithmConfigService.getByAlgorithmName("多目标检测").getStartApi();
|
|
|
+ HttpUtil.post(url, JSONUtil.toJsonStr(params));
|
|
|
+
|
|
|
+ TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
|
|
|
+ details.setStatus(BizConstant.TASK_STATUS_PROCESSING);
|
|
|
+ details.setStartTime(new Date());
|
|
|
+ details.setEndTime(null);
|
|
|
+ targetIdentificationSubtaskDetailsService.updateById(details);
|
|
|
+
|
|
|
+ return CommonResult.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("target identify pause failure");
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return CommonResult.fail(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/pauseTask")
|
|
|
+ public CommonResult<Void> pauseTask(@RequestBody Map<String, String> params) {
|
|
|
+ params.put("bizType", TYPE_DATA_BIZ_PROCESS);
|
|
|
+ if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
|
|
|
+ return CommonResult.fail("Error parameters");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String url = algorithmConfigService.getByAlgorithmName("多目标检测").getPauseApi();
|
|
|
+ HttpUtil.post(url, JSONUtil.toJsonStr(params));
|
|
|
+
|
|
|
+ TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
|
|
|
+ details.setStatus(BizConstant.TASK_STATUS_PENDING);
|
|
|
+ details.setEndTime(new Date());
|
|
|
+ targetIdentificationSubtaskDetailsService.updateById(details);
|
|
|
+
|
|
|
+ return CommonResult.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("target identify pause failure");
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return CommonResult.fail(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/stopTask")
|
|
|
+ public CommonResult<Void> stopTask(@RequestBody Map<String, String> params) {
|
|
|
+ params.put("bizType", TYPE_DATA_BIZ_PROCESS);
|
|
|
+ if (!params.containsKey("bizType") || !params.containsKey("bizId")) {
|
|
|
+ return CommonResult.fail("Error parameters");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String url = algorithmConfigService.getByAlgorithmName("多目标检测").getTerminateApi();
|
|
|
+ HttpUtil.post(url, JSONUtil.toJsonStr(params));
|
|
|
+
|
|
|
+ TargetIdentificationSubtaskDetails details = targetIdentificationSubtaskDetailsService.getById(params.get("bizId"));
|
|
|
+ details.setStatus(BizConstant.TASK_STATUS_PENDING);
|
|
|
+ details.setEndTime(new Date());
|
|
|
+ targetIdentificationSubtaskDetailsService.updateById(details);
|
|
|
+
|
|
|
+ return CommonResult.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("target identify pause failure");
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return CommonResult.fail(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 执行训练任务
|
|
|
* @param params
|
|
@@ -143,6 +224,7 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
|
|
|
}
|
|
|
|
|
|
details.setStartTime(new Date());
|
|
|
+ details.setEndTime(null);
|
|
|
targetIdentificationSubtaskDetailsService.updateById(details);
|
|
|
subtaskService.executeOneTask(taskId);
|
|
|
return CommonResult.success();
|
|
@@ -187,6 +269,7 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
|
|
|
|
|
|
details.setStatus(BizConstant.TASK_STATUS_PENDING);
|
|
|
details.setStartTime(new Date());
|
|
|
+ details.setEndTime(null);
|
|
|
targetIdentificationSubtaskDetailsService.updateById(details);
|
|
|
|
|
|
subtaskService.executeOneTask(taskId);
|
|
@@ -202,7 +285,10 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
|
|
|
@GetMapping("/openDir")
|
|
|
public CommonResult<Void> openDir(String directory) throws IOException {
|
|
|
log.error("check dir: {}, {}", directory, profile + "/task" + directory);
|
|
|
- Desktop.getDesktop().open(new File(profile + "/task" + directory));
|
|
|
+ //Desktop.getDesktop().open(new File(profile + "/task" + directory));
|
|
|
+ String dir = profile + "/task" + directory;
|
|
|
+ ProcessBuilder pb = new ProcessBuilder("nautilus", dir);
|
|
|
+ Process p = pb.start();
|
|
|
return CommonResult.success();
|
|
|
}
|
|
|
|