Browse Source

复杂路径接口模版

main
maochaoying 2 years ago
parent
commit
06bf20827a
  1. 50
      src/main/java/com/iflytop/nuclear/controller/PathController.java
  2. 14
      src/main/java/com/iflytop/nuclear/mapper/PathMapper.java
  3. 17
      src/main/java/com/iflytop/nuclear/service/PathService.java
  4. 24
      src/main/java/com/iflytop/nuclear/service/impl/PathServiceImpl.java
  5. BIN
      uploadfiles/xlsx/20230707/堆芯模版-23.xlsx

50
src/main/java/com/iflytop/nuclear/controller/PathController.java

@ -0,0 +1,50 @@
package com.iflytop.nuclear.controller;
import com.alibaba.fastjson.JSONObject;
import com.iflytop.nuclear.model.Path;
import com.iflytop.nuclear.model.Task;
import com.iflytop.nuclear.service.PathService;
import com.iflytop.nuclear.service.TaskService;
import com.iflytop.nuclear.utils.ResponseData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author cool
* @date 2023/7/7 10:36
*/
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/path")
@PreAuthorize("hasRole('ADMIN')")
public class PathController {
@Autowired
TaskService taskService;
@Autowired
PathService pathService;
@GetMapping("/check/{id}")
public ResponseData check(@PathVariable(name = "id") int taskId) {
Task task = taskService.getById(taskId);
int status = task.getStatus();
if (status != 0) {
// 任务已经开始
return ResponseData.fail("当前任务已经在流程中,不可更改路径规划");
}
return ResponseData.success();
}
@PostMapping("/plan")
public ResponseData plan(@RequestBody List<Path> pathList) {
boolean b = pathService.plan(pathList);
JSONObject jsonObject = new JSONObject();
jsonObject.put("result", b);
return ResponseData.success(jsonObject);
}
}

14
src/main/java/com/iflytop/nuclear/mapper/PathMapper.java

@ -0,0 +1,14 @@
package com.iflytop.nuclear.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.iflytop.nuclear.model.Path;
import com.iflytop.nuclear.model.Task;
import org.apache.ibatis.annotations.Mapper;
/**
* @author cool
* @date 2023/7/7 10:50
*/
@Mapper
public interface PathMapper extends BaseMapper<Path> {
}

17
src/main/java/com/iflytop/nuclear/service/PathService.java

@ -0,0 +1,17 @@
package com.iflytop.nuclear.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.iflytop.nuclear.model.Path;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author cool
* @date 2023/7/7 10:48
*/
@Transactional
public interface PathService extends IService<Path> {
boolean plan(List<Path> pathList);
}

24
src/main/java/com/iflytop/nuclear/service/impl/PathServiceImpl.java

@ -0,0 +1,24 @@
package com.iflytop.nuclear.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iflytop.nuclear.mapper.PathMapper;
import com.iflytop.nuclear.mapper.TaskMapper;
import com.iflytop.nuclear.model.Path;
import com.iflytop.nuclear.model.Task;
import com.iflytop.nuclear.service.PathService;
import com.iflytop.nuclear.service.TaskService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author cool
* @date 2023/7/7 10:49
*/
@Service
public class PathServiceImpl extends ServiceImpl<PathMapper, Path> implements PathService {
@Override
public boolean plan(List<Path> pathList) {
return false;
}
}

BIN
uploadfiles/xlsx/20230707/堆芯模版-23.xlsx

Loading…
Cancel
Save