add:彩涂机组逻辑
This commit is contained in:
@@ -51,6 +51,25 @@ public class RouteUtil {
|
||||
list.add(first_device_code + "02");
|
||||
list.add(first_device_code + "01");
|
||||
map.put(first_device_code + "01", list);
|
||||
} else if (StrUtil.equals(next_device_code, "E02")) {
|
||||
list = new ArrayList<>();
|
||||
list.add("E03");
|
||||
list.add("E04");
|
||||
list.add("E02");
|
||||
list.add("E03");
|
||||
list.add("E04");
|
||||
list.add("D01");
|
||||
map.put(first_device_code + "01", list);
|
||||
list = new ArrayList<>();
|
||||
list.add("E02");
|
||||
list.add("E03");
|
||||
list.add("E04");
|
||||
list.add("D01");
|
||||
map.put(first_device_code + "02", list);
|
||||
list = new ArrayList<>();
|
||||
list.add("E04");
|
||||
list.add("D01");
|
||||
map.put(first_device_code + "04", list);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
||||
@@ -168,9 +168,15 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
//1#2#5#重机卷组申请任务
|
||||
if (mode == 3 && !requireSucess) {
|
||||
instruction_require();
|
||||
}
|
||||
|
||||
//3#彩涂机组申请任务
|
||||
if (mode == 4 && !requireSucess) {
|
||||
instruction_require2();
|
||||
}
|
||||
}
|
||||
|
||||
last_mode = mode;
|
||||
@@ -179,6 +185,72 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
last_action = action;
|
||||
}
|
||||
|
||||
public synchronized boolean instruction_require2() throws Exception {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
List<String> link_device_codes = this.getExtraDeviceCodes("link_device_code");
|
||||
String next_device_code = "";
|
||||
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver;
|
||||
Device device = null;
|
||||
|
||||
for (int i = 0; i < link_device_codes.size(); i++) {
|
||||
String link_device_code = link_device_codes.get(i);
|
||||
device = deviceAppservice.findDeviceByCode(link_device_code);
|
||||
if (device.getDeviceDriver() instanceof MaGangConveyorDeviceDriver && !link_device_code.startsWith("D")) {
|
||||
maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver();
|
||||
if (maGangConveyorDeviceDriver.getMove() == 0) {
|
||||
next_device_code = link_device_code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//查询任务表中是否有同一起点和终点的任务
|
||||
List<TaskDto> taskDtos = taskserver.queryTaskByStartAndNextDeviceCode(this.getDevice_code(), next_device_code);
|
||||
//如果有就不生成任务
|
||||
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
||||
return false;
|
||||
}
|
||||
String taskType = String.valueOf(device.getExtraValue().get("taskType"));
|
||||
String start_device_code = this.getDevice().getDevice_code();
|
||||
if (StrUtil.isEmpty(next_device_code)) {
|
||||
return false;
|
||||
}
|
||||
if (StrUtil.equals(taskType, "null") || StrUtil.isEmpty(taskType)) {
|
||||
taskType = "0";
|
||||
}
|
||||
TaskDto taskDto = new TaskDto();
|
||||
String now = DateUtil.now();
|
||||
taskDto.setTask_id(IdUtil.simpleUUID());
|
||||
taskDto.setTask_code("-" + CodeUtil.getNewCode("TASK_NO"));
|
||||
taskDto.setTask_type(taskType);
|
||||
taskDto.setRoute_plan_code("normal");
|
||||
taskDto.setTask_status("0");
|
||||
taskDto.setPriority("101");
|
||||
taskDto.setAgv_system_type("1");
|
||||
taskDto.setStart_device_code(start_device_code);
|
||||
taskDto.setStart_point_code(start_device_code);
|
||||
taskDto.setNext_point_code(next_device_code);
|
||||
taskDto.setNext_point_code(next_device_code);
|
||||
taskDto.setCreate_by(start_device_code);
|
||||
taskDto.setUpdate_by(start_device_code);
|
||||
taskDto.setUpdate_time(now);
|
||||
taskDto.setCreate_time(now);
|
||||
try {
|
||||
taskserver.create(taskDto);
|
||||
} catch (Exception e) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", this.device_code + ":创建任务失败," + String.valueOf(e.getMessage()));
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", this.device_code + ":创建任务成功");
|
||||
this.writing(1);
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean instruction_require() throws Exception {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
@@ -186,12 +258,6 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
//查询任务表中是否有同一起点的任务
|
||||
List<TaskDto> taskDtos = taskserver.queryTaskByStartDeviceCode(this.getDevice_code());
|
||||
//如果有就不生成任务
|
||||
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
||||
return false;
|
||||
}
|
||||
List<String> link_device_codes = this.getExtraDeviceCodes("link_device_code");
|
||||
String next_device_code = "";
|
||||
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver;
|
||||
@@ -206,6 +272,12 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
}
|
||||
}
|
||||
}
|
||||
//查询任务表中是否有同一起点和终点的任务
|
||||
List<TaskDto> taskDtos = taskserver.queryTaskByStartAndNextDeviceCode(this.getDevice_code(), next_device_code);
|
||||
//如果有就不生成任务
|
||||
if (ObjectUtil.isNotEmpty(taskDtos)) {
|
||||
return false;
|
||||
}
|
||||
String taskType = String.valueOf(this.getExtraValue().get("taskType"));
|
||||
String start_device_code = this.getDevice().getDevice_code();
|
||||
if (StrUtil.isEmpty(next_device_code)) {
|
||||
|
||||
@@ -111,6 +111,8 @@ public interface TaskService {
|
||||
*/
|
||||
List<TaskDto> queryTaskByStartDeviceCode(String device_code);
|
||||
|
||||
List<TaskDto> queryTaskByStartAndNextDeviceCode(String start_device_code,String next_device_code);
|
||||
|
||||
/**
|
||||
* 根据关联编号查询非立刻下发的关联任务
|
||||
*/
|
||||
|
||||
@@ -55,6 +55,7 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
@@ -286,6 +287,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByStartAndNextDeviceCode(String start_device_code, String next_device_code) {
|
||||
return Optional.ofNullable(tasks)
|
||||
.orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.filter(taskDto -> taskDto.getStart_device_code().equals(start_device_code) && taskDto.getNext_device_code().equals(next_device_code))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto queryTaskByLinkNum(String link_num) {
|
||||
return null;
|
||||
|
||||
@@ -44,11 +44,6 @@ public class QueryXZAgvDeviceStatus {
|
||||
JSONObject body = JSONObject.parseObject(response.body());
|
||||
JSONArray ja = body.getJSONArray("report");
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
System.out.println(ja.getJSONObject(1));
|
||||
if (i == 1) {
|
||||
System.out.println(i);
|
||||
}
|
||||
System.out.println("此刻i=" + i);
|
||||
JSONObject jo = ja.getJSONObject(i);
|
||||
//机器人编码
|
||||
String agv_code = jo.getString("uuid");
|
||||
|
||||
Reference in New Issue
Block a user