Browse Source

复杂路径sql

main
maochaoying 2 years ago
parent
commit
7bdf1ca17e
  1. 6
      src/main/java/com/iflytop/nuclear/controller/PathController.java
  2. 14
      src/main/java/com/iflytop/nuclear/model/Path.java
  3. 5
      src/main/java/com/iflytop/nuclear/service/PathService.java
  4. 27
      src/main/java/com/iflytop/nuclear/service/impl/PathServiceImpl.java

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

@ -40,9 +40,9 @@ public class PathController {
return ResponseData.success(); return ResponseData.success();
} }
@PostMapping("/plan")
public ResponseData plan(@RequestBody List<Path> pathList) {
boolean b = pathService.plan(pathList);
@PostMapping("/plan/{id}")
public ResponseData plan(@PathVariable(name = "id") int taskId, @RequestBody List<Path> pathList) {
boolean b = pathService.plan(taskId, pathList);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("result", b); jsonObject.put("result", b);
return ResponseData.success(jsonObject); return ResponseData.success(jsonObject);

14
src/main/java/com/iflytop/nuclear/model/Path.java

@ -21,12 +21,12 @@ public class Path {
@TableId @TableId
private int id; private int id;
@TableField("order")
private String order;
@TableField("coord")
private String coord;
/**
* 规则的路径可以通过代码实现得出下一个坐标不规则的则需要记录
*/
@TableField("path")
private String path;
@TableField("task_id")
private int taskId;
@TableField("order")
private int order;
} }

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

@ -13,5 +13,8 @@ import java.util.List;
@Transactional @Transactional
public interface PathService extends IService<Path> { public interface PathService extends IService<Path> {
boolean plan(List<Path> pathList);
boolean plan(int taskId, List<Path> pathList);
} }

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

@ -1,12 +1,17 @@
package com.iflytop.nuclear.service.impl; package com.iflytop.nuclear.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iflytop.nuclear.mapper.PathMapper; import com.iflytop.nuclear.mapper.PathMapper;
import com.iflytop.nuclear.mapper.TaskMapper; import com.iflytop.nuclear.mapper.TaskMapper;
import com.iflytop.nuclear.model.NuclearCoreConfig;
import com.iflytop.nuclear.model.Path; import com.iflytop.nuclear.model.Path;
import com.iflytop.nuclear.model.Task; import com.iflytop.nuclear.model.Task;
import com.iflytop.nuclear.service.NuclearCoreConfigService;
import com.iflytop.nuclear.service.PathService; import com.iflytop.nuclear.service.PathService;
import com.iflytop.nuclear.service.TaskService; import com.iflytop.nuclear.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -17,8 +22,28 @@ import java.util.List;
*/ */
@Service @Service
public class PathServiceImpl extends ServiceImpl<PathMapper, Path> implements PathService { public class PathServiceImpl extends ServiceImpl<PathMapper, Path> implements PathService {
@Autowired
TaskService taskService;
@Autowired
NuclearCoreConfigService nuclearCoreConfigService;
@Override @Override
public boolean plan(List<Path> pathList) {
public boolean plan(int taskId, List<Path> pathList) {
// 更改task表中的order为2
UpdateWrapper<Task> taskUpdateWrapper = new UpdateWrapper<>();
taskUpdateWrapper.eq("id", taskId);
Task task = Task.builder()
.checkOrder(2)
.build();
boolean updateResult = taskService.update(task, taskUpdateWrapper);
// 删除已经上传的config
QueryWrapper<NuclearCoreConfig> nuclearCoreConfigQueryWrapper = new QueryWrapper<>();
nuclearCoreConfigQueryWrapper.eq("task_id", taskId);
boolean remove = nuclearCoreConfigService.remove(nuclearCoreConfigQueryWrapper);
// 保存自定义路径
return false; return false;
} }
} }
Loading…
Cancel
Save