add:强制完成添加

This commit is contained in:
2024-04-10 17:20:04 +08:00
parent 8496323445
commit 0bcffd1d63
8 changed files with 89 additions and 45 deletions

View File

@@ -33,8 +33,10 @@ import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
import org.nl.acs.task.TaskInstructionLock;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.dto.TaskIdAndStatusDTO;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.FileUtil;
import org.nl.modules.common.utils.RedisUtils;
@@ -988,7 +990,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
//中转为空
if(StrUtil.isEmpty(obj.getPut_device_code())){
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
taskService.finish(taskIdAndStatusDTO);
} else {
finishAndCreateNextInst(entity);
}
@@ -996,13 +1001,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
finishAndCreateHXInst(entity);
} else if (StrUtil.equals(obj.getPut_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
taskService.finish(taskIdAndStatusDTO);
}
}
} else {
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
taskService.finish(taskIdAndStatusDTO);
} else {
finishAndCreateNextInst(entity);
}
@@ -1035,7 +1046,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
//中转为空
if(StrUtil.isEmpty(obj.getPut_device_code())){
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
taskService.finish(taskIdAndStatusDTO);
} else {
finishAndCreateNextInst(dto);
}
@@ -1043,13 +1057,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
finishAndCreateHXInst(dto);
} else if (StrUtil.equals(obj.getPut_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
taskService.finish(taskIdAndStatusDTO);
}
}
} else {
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
taskService.finish(obj.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
taskService.finish(taskIdAndStatusDTO);
} else {
finishAndCreateNextInst(dto);
}

View File

@@ -10,7 +10,9 @@ import com.alibaba.fastjson.JSONObject;
public enum TaskStatusEnum {
READY(1, "READY", "就绪"),
BUSY(2, "BUSY", "执行中"),
FINISHED(3, "FINISHED", "完成");
FINISHED(3, "FINISHED", "完成"),
FORCED_COMPLETION(4, "FORCED_COMPLETION", "强制完成");
//索引

View File

@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.dto.TaskIdAndStatusDTO;
import org.nl.modules.logging.annotation.Log;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
@@ -38,7 +39,7 @@ public class TaskController {
@GetMapping
@Log("查询任务")
//@PreAuthorize("@el.check('task:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK);
@@ -46,7 +47,7 @@ public class TaskController {
@GetMapping("/reload")
@Log("数据同步")
@SaIgnore
//@PreAuthorize("@el.check('task:list')")
public ResponseEntity<Object> reload() {
@@ -56,14 +57,14 @@ public class TaskController {
@GetMapping("/getAll")
@Log("历史查询任务")
//@PreAuthorize("@el.check('task:list')")
public ResponseEntity<Object> get(@RequestParam Map whereJson, Pageable page) {
return new ResponseEntity<>(taskService.getAll(whereJson, page), HttpStatus.OK);
}
@Log("导出历史任务")
@GetMapping(value = "/getAll/download")
//@PreAuthorize("@el.check('task:list')")
public void getAllDownload(HttpServletResponse response, Map whereJson) throws IOException {
@@ -72,7 +73,7 @@ public class TaskController {
@PostMapping
@Log("新增任务")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> create(@Validated @RequestBody TaskDto dto) throws Exception {
taskService.create(dto);
@@ -81,7 +82,7 @@ public class TaskController {
@PostMapping(value = "/adds")
@Log("常规任务保存")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> ordinaryTaskCreate(@RequestBody JSONObject json) throws Exception {
@@ -91,7 +92,7 @@ public class TaskController {
@PostMapping(value = "/addes")
@Log("特殊任务保存")
public ResponseEntity<Object> specialTaskCreate(@RequestBody JSONObject json) throws Exception {
taskService.specialTaskCreate(json);
return new ResponseEntity<>(HttpStatus.CREATED);
@@ -99,7 +100,7 @@ public class TaskController {
@PutMapping
@Log("修改任务")
//@PreAuthorize("@el.check('task:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody TaskDto dto) {
taskService.update(dto);
@@ -107,7 +108,7 @@ public class TaskController {
}
@Log("删除任务")
//@PreAuthorize("@el.check('task:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody String[] ids) throws Exception {
@@ -116,15 +117,14 @@ public class TaskController {
}
@Log("完成任务")
@PostMapping(value = "/finish/{id}")
public ResponseEntity<Object> finish(@RequestBody String id) {
taskService.finish(id);
@PostMapping(value = "/finish")
public ResponseEntity<Object> finish(@RequestBody TaskIdAndStatusDTO taskIdAndStatus) {
taskService.finish(taskIdAndStatus);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("取消任务")
@PostMapping(value = "/cancel/{id}")
public ResponseEntity<Object> cancel(@RequestBody String id) throws Exception {
taskService.cancel(id);
@@ -132,7 +132,7 @@ public class TaskController {
}
@Log("手动创建指令")
@PostMapping(value = "/createInst/{id}")
public ResponseEntity<Object> createInst(@RequestBody String id) throws Exception {
taskService.createInst(id);
@@ -140,7 +140,7 @@ public class TaskController {
}
@Log("导出任务")
@GetMapping(value = "/download")
//@PreAuthorize("@el.check('task:list')")
public void download(HttpServletResponse response, Map whereJson) throws IOException {
@@ -148,7 +148,7 @@ public class TaskController {
}
@Log("一体机触发任务")
@PostMapping("/createTaskByClick")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> createTaskByClick(@RequestBody JSONObject json) {
@@ -158,7 +158,7 @@ public class TaskController {
@SaIgnore
@Log("查询缓存所有任务")
@PostMapping(value = "/findAllTaskFromCache")
public ResponseEntity<Object> findAllTaskFromCache() {
return new ResponseEntity<>(taskService.findAllTaskFromCache(), HttpStatus.OK);

View File

@@ -5,6 +5,7 @@ package org.nl.acs.task.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.dto.TaskIdAndStatusDTO;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
@@ -200,9 +201,9 @@ public interface TaskService {
/**
* 完成任务
*
* @param ids
* @param taskIdAndStatus
*/
void finish(String ids);
void finish(TaskIdAndStatusDTO taskIdAndStatus);
/**
* 取消任务

View File

@@ -0,0 +1,10 @@
package org.nl.acs.task.service.dto;
import lombok.Data;
@Data
public class TaskIdAndStatusDTO {
private String task_id;
private String task_status;
}

View File

@@ -1,20 +1,16 @@
package org.nl.acs.task.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.InternalJSONUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.XianGongAgvService;
@@ -39,7 +35,7 @@ import org.nl.acs.task.TaskInstructionLock;
import org.nl.acs.task.service.TaskFeedbackService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.dto.TaskFeedbackDto;
import org.nl.acs.task.service.dto.TaskIdAndStatusDTO;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.FileUtil;
import org.nl.modules.common.utils.RedisUtils;
@@ -60,7 +56,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -808,11 +803,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Override
@Transactional(rollbackFor = Exception.class)
public void finish(String id) {
TaskDto entity = this.findById(id);
public void finish(TaskIdAndStatusDTO taskIdAndStatus) {
TaskDto entity = this.findById(taskIdAndStatus.getTask_id());
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 ");
InstructionDto instdto = instructionservice.findByTaskid(taskIdAndStatus.getTask_id(), "instruction_status <2 ");
if (instdto != null) throw new BadRequestException("有指令未完成!");
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();