fix: 诺宝指令状态修复
This commit is contained in:
@@ -75,9 +75,10 @@ public class QueryAGVStatus {
|
||||
String carNo = json.getString("vehicle");
|
||||
String instructionCode = json.getString("id");
|
||||
if ("RUNNING".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
||||
if ("1".equals(instruction.getInstruction_status())) {
|
||||
TaskDto task = taskService.findById(instruction.getTask_id());
|
||||
if ("0".equals(instruction.getInstruction_status())&&"1".equals(task.getTask_status())) {
|
||||
instruction.setCarno(carNo);
|
||||
TaskDto task = new TaskDto();
|
||||
instruction.setInstruction_status("1");
|
||||
instructionService.update(instruction);
|
||||
task.setCarno(carNo);
|
||||
task.setTask_id(instruction.getTask_id());
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
package org.nl;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.unit.DataUnit;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 单元测试
|
||||
* @Date: 2023/5/15
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class ApplicationTest {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
|
||||
|
||||
private List<Person> persons = new CopyOnWriteArrayList();
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
Person person1 = new Person();
|
||||
Person person2 = new Person();
|
||||
Person person3 = new Person();
|
||||
String now1 = DateUtil.now();
|
||||
person1.setCreate_time(now1);
|
||||
String now2 = DateUtil.now();
|
||||
String now3 = DateUtil.now();
|
||||
person2.setCreate_time(now2);
|
||||
person3.setCreate_time(now3);
|
||||
person1.setNext_device_code("CK2042");
|
||||
person2.setNext_device_code("CK2042");
|
||||
person3.setNext_device_code("CK2042");
|
||||
person1.setInstruction_status("0");
|
||||
person2.setInstruction_status("0");
|
||||
person3.setInstruction_status("0");
|
||||
person1.setInstruction_type("6");
|
||||
person2.setInstruction_type("17");
|
||||
person3.setInstruction_type("7");
|
||||
persons.add(person1);
|
||||
persons.add(person2);
|
||||
persons.add(person3);
|
||||
Person person = findByNextDeviceCodeFromCache("CK2042");
|
||||
System.out.println(person);
|
||||
}
|
||||
|
||||
public Person findByNextDeviceCodeFromCache(String devicecode) {
|
||||
List<Person> personList = persons;
|
||||
ListUtil.sort(
|
||||
personList,
|
||||
new Comparator<Person>() {
|
||||
@Override
|
||||
public int compare(Person o1, Person o2) {
|
||||
return o1.getCreate_time().compareTo(o2.getCreate_time());
|
||||
}
|
||||
});
|
||||
Iterator<Person> it = persons.iterator();
|
||||
while (it.hasNext()) {
|
||||
Person person = it.next();
|
||||
if (StrUtil.equals(devicecode, person.getNext_device_code()) && Integer.parseInt(person.getInstruction_status()) <= Integer.parseInt(InstructionStatusEnum.BUSY.getIndex()) && !person.getInstruction_type().equals(TaskTypeEnum.Mxddhj_Task.getIndex())&& !person.getInstruction_type().equals(TaskTypeEnum.Truss_Task.getIndex())) {
|
||||
return person;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextLoads2() {
|
||||
int time = Integer.parseInt("137341");
|
||||
int hours = (time / (60 * 60)); // 整数小时
|
||||
int minutes = (time % (60 * 60)) / 60; // 剩余分钟
|
||||
System.out.println("hours:" + hours + " minutes:" + minutes);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Scheduled(cron = "0/5 * * * * ?")
|
||||
void testOrderTask() {
|
||||
logger.info(Thread.currentThread().getName() + "===task run");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void demo1() {
|
||||
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
Thread.sleep(3000); // 假设这是一个耗时的操作
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("Interrupted", e);
|
||||
}
|
||||
return "Result";
|
||||
});
|
||||
|
||||
try {
|
||||
String result = future.get(2, TimeUnit.SECONDS); // 设置超时时间为2秒
|
||||
System.out.println(result);
|
||||
} catch (CompletionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof TimeoutException) {
|
||||
System.out.println("Operation timed out");
|
||||
} else {
|
||||
throw e; // rethrow other exceptions
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user