|
|
|
@ -21,11 +21,14 @@ import java.time.LocalDateTime;
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.zhehekeji.web.service.KuKouService.setTrayCode;
|
|
|
|
import static com.zhehekeji.web.service.KuKouService.setTrayCode;
|
|
|
|
|
|
|
|
import static java.lang.Thread.sleep;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
public class CommandQueue {
|
|
|
|
public class CommandQueue {
|
|
|
|
// 增加queue
|
|
|
|
// 增加queue,固定延时3s
|
|
|
|
public static void addCommand(IndustrialCameraVO scTransmission) {
|
|
|
|
public static void addCommand(IndustrialCameraVO scTransmission) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scTransmission.setExecuteTime(System.currentTimeMillis() + 3000);
|
|
|
|
delayQueue.add(scTransmission);
|
|
|
|
delayQueue.add(scTransmission);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static ExecutorService exec = Executors.newFixedThreadPool(1);
|
|
|
|
private static ExecutorService exec = Executors.newFixedThreadPool(1);
|
|
|
|
@ -37,6 +40,26 @@ public class CommandQueue {
|
|
|
|
exec.execute(new Consumer(restTemplate, configProperties));
|
|
|
|
exec.execute(new Consumer(restTemplate, configProperties));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
|
|
ConfigProperties configProperties = new ConfigProperties();
|
|
|
|
|
|
|
|
configProperties.setKsec(new ConfigProperties.KSEC());
|
|
|
|
|
|
|
|
configProperties.getKsec().setReportHttp("http://127.0.0.1:8000");
|
|
|
|
|
|
|
|
sentHttp(new RestTemplate(),new ConfigProperties());
|
|
|
|
|
|
|
|
System.out.println(System.currentTimeMillis());
|
|
|
|
|
|
|
|
IndustrialCameraVO industrialCameraVO = new IndustrialCameraVO();
|
|
|
|
|
|
|
|
industrialCameraVO.setTrayCode("1321351351651351");
|
|
|
|
|
|
|
|
IndustrialCameraVO industrialCameraVO2 = new IndustrialCameraVO();
|
|
|
|
|
|
|
|
industrialCameraVO.setTrayCode("1321351351651351");
|
|
|
|
|
|
|
|
delayQueue.add(industrialCameraVO);
|
|
|
|
|
|
|
|
delayQueue.add(industrialCameraVO2);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
sleep(10000);
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static class Consumer implements Runnable {
|
|
|
|
private static class Consumer implements Runnable {
|
|
|
|
RestTemplate restTemplate ;
|
|
|
|
RestTemplate restTemplate ;
|
|
|
|
ConfigProperties configProperties;
|
|
|
|
ConfigProperties configProperties;
|
|
|
|
@ -54,6 +77,7 @@ public class CommandQueue {
|
|
|
|
IndustrialCameraVO scTransmission = delayQueue.take();
|
|
|
|
IndustrialCameraVO scTransmission = delayQueue.take();
|
|
|
|
if(scTransmission != null){
|
|
|
|
if(scTransmission != null){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(System.currentTimeMillis());
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
headers.set("Content-Type", "application/json");
|
|
|
|
headers.set("Content-Type", "application/json");
|
|
|
|
|