add: 关联站点开发,代确认开发点
This commit is contained in:
@@ -381,7 +381,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
|||||||
/**
|
/**
|
||||||
* 申请任务
|
* 申请任务
|
||||||
*/
|
*/
|
||||||
public synchronized Boolean instruction_require() {
|
public synchronized Boolean
|
||||||
|
instruction_require() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package org.nl.acs.device_driver.basedriver.belt_with_station;
|
package org.nl.acs.device_driver.basedriver.belt_with_station;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.nl.acs.agv.server.NDCAgvService;
|
import org.nl.acs.agv.server.NDCAgvService;
|
||||||
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
@@ -25,14 +28,13 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
|
|||||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||||
import org.nl.acs.opc.DeviceAppService;
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
import org.nl.acs.route.service.RouteLineService;
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
|
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.nl.acs.task.service.dto.TaskDto;
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联驱动
|
* 关联驱动
|
||||||
@@ -129,7 +131,6 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
|
|||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//取关联设备 list 要求:先配置外侧的站点
|
//取关联设备 list 要求:先配置外侧的站点
|
||||||
//遍历
|
//遍历
|
||||||
List<String> sddjExtraCodeList = this.getExtraDeviceCodes("link_device_code");
|
List<String> sddjExtraCodeList = this.getExtraDeviceCodes("link_device_code");
|
||||||
@@ -143,71 +144,174 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
|
|||||||
doubleBeltConveyorDeviceDriver1 = (DoubleBeltConveyorDeviceDriver) sddjExtraCode1.getDeviceDriver();
|
doubleBeltConveyorDeviceDriver1 = (DoubleBeltConveyorDeviceDriver) sddjExtraCode1.getDeviceDriver();
|
||||||
doubleBeltConveyorDeviceDriver2 = (DoubleBeltConveyorDeviceDriver) sddjExtraCode2.getDeviceDriver();
|
doubleBeltConveyorDeviceDriver2 = (DoubleBeltConveyorDeviceDriver) sddjExtraCode2.getDeviceDriver();
|
||||||
//判断输送线是否有任务,有任务进行创建指令。
|
//判断输送线是否有任务,有任务进行创建指令。
|
||||||
List<TaskDto> taskDtos1 = taskServer.queryTaskByStartDeviceCode(doubleBeltConveyorDeviceDriver1.getDevice_code());
|
TaskDto taskDtos1 = taskServer.findByStartCodeAndReady(doubleBeltConveyorDeviceDriver1.getDevice_code());
|
||||||
List<TaskDto> taskDtos2 = taskServer.queryTaskByStartDeviceCode(doubleBeltConveyorDeviceDriver2.getDevice_code());
|
TaskDto taskDtos2 = taskServer.findByStartCodeAndReady(doubleBeltConveyorDeviceDriver1.getDevice_code());
|
||||||
if (CollectionUtil.isNotEmpty(taskDtos1) && CollectionUtil.isNotEmpty(taskDtos2)) {
|
if (ObjectUtil.isNotEmpty(taskDtos1) && ObjectUtil.isNotEmpty(taskDtos2)) {
|
||||||
if (doubleBeltConveyorDeviceDriver1.getMove() == 0) {
|
if (doubleBeltConveyorDeviceDriver1.getMove() == 0) {
|
||||||
requireSucess = false;
|
requireSucess = false;
|
||||||
}
|
}
|
||||||
if (doubleBeltConveyorDeviceDriver2.getMove() == 0) {
|
if (doubleBeltConveyorDeviceDriver2.getMove() == 0) {
|
||||||
requireSucess = false;
|
requireSucess = false;
|
||||||
}
|
}
|
||||||
|
//判断任务列是否相邻
|
||||||
|
String nextDeviceCode1 = taskDtos1.getNext_device_code();
|
||||||
|
String nextDeviceCode2 = taskDtos2.getNext_device_code();
|
||||||
|
if (StrUtil.contains(nextDeviceCode1, "-") && StrUtil.contains(nextDeviceCode2, "-")) {
|
||||||
|
String[] split1 = nextDeviceCode1.split("-");
|
||||||
|
String nextPointCodeDown = split1[0] + "-" + (Integer.parseInt(split1[1]) - 1) + "-" + split1[2];
|
||||||
|
String nextPointCodeUp = split1[0] + "-" + (Integer.parseInt(split1[1]) + 1) + "-" + split1[2];
|
||||||
|
if (!nextDeviceCode2.equals(nextPointCodeDown) || !nextDeviceCode2.equals(nextPointCodeUp)) {
|
||||||
|
//创建指令
|
||||||
|
if (ObjectUtil.isNotNull(taskDtos1) && "1".equals(taskDtos1.getTask_type())) {
|
||||||
|
creatInstruction(taskDtos1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
requireSucess = false;
|
||||||
|
}
|
||||||
|
|
||||||
//判断关联的输送线是否满足状态
|
//判断关联的输送线是否满足状态
|
||||||
if (doubleBeltConveyorDeviceDriver1.getMode() == 2 && doubleBeltConveyorDeviceDriver1.getMove() == 1 && !requireSucess &&doubleBeltConveyorDeviceDriver2.getMode() == 2 && doubleBeltConveyorDeviceDriver2.getMove() == 1
|
if (doubleBeltConveyorDeviceDriver1.getMode() == 2 && doubleBeltConveyorDeviceDriver1.getMove() == 1 && !requireSucess && doubleBeltConveyorDeviceDriver2.getMode() == 2 && doubleBeltConveyorDeviceDriver2.getMove() == 1) {
|
||||||
) {
|
//判断是否大于等待时间
|
||||||
|
|
||||||
|
|
||||||
//判断是否超过等待时间
|
|
||||||
if (System.currentTimeMillis() - doubleBeltConveyorDeviceDriver1.getInstruction_require_time().getTime()
|
if (System.currentTimeMillis() - doubleBeltConveyorDeviceDriver1.getInstruction_require_time().getTime()
|
||||||
> Integer.parseInt(this.getExtraValue().get("apply_time").toString()) * 1000) {
|
> Integer.parseInt(this.getExtraValue().get("apply_time").toString()) * 1000) {
|
||||||
//否则对接位单独申请任务
|
//创建指令
|
||||||
JSONObject reqParam = new JSONObject();
|
if (ObjectUtil.isNotNull(taskDtos1) && "1".equals(taskDtos1.getTask_type())) {
|
||||||
reqParam.put("type", StatusEnum.HAIROU_LIKU_REQ.getCode());
|
creatInstruction(taskDtos1);
|
||||||
reqParam.put("device_code_one", hailiangHrSsxDeviceDriver.getDevice_code());
|
}
|
||||||
reqParam.put("vehicle_code_one", hailiangHrSsxDeviceDriver.getBarcode());
|
}
|
||||||
log.info("单工位请求成功");
|
log.info("单工位请求成功");
|
||||||
requireSucess = true;
|
requireSucess = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//否则判断另一个位置
|
//创建指令
|
||||||
Device neiRouDevice = deviceAppservice.findDeviceByCode(haiRouDeviceCodeList.get(i+1));
|
if (ObjectUtil.isNotNull(taskDtos1) && "1".equals(taskDtos1.getTask_type())) {
|
||||||
if (neiRouDevice.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) {
|
creatInstruction(taskDtos1);
|
||||||
hailiangHrSsxDeviceDriver2 = (HailiangHrSsxDeviceDriver) neiRouDevice.getDeviceDriver();
|
}
|
||||||
if (hailiangHrSsxDeviceDriver2.getMode() == 2 &&
|
if (ObjectUtil.isNotNull(taskDtos2) && "1".equals(taskDtos1.getTask_type())) {
|
||||||
hailiangHrSsxDeviceDriver2.getMove() == 1 &&
|
creatInstruction(taskDtos2);
|
||||||
ObjectUtil.isNotEmpty(hailiangHrSsxDeviceDriver2.getBarcode())
|
}
|
||||||
) {
|
log.info("双工位指令创建成功");
|
||||||
JSONObject reqParam = new JSONObject();
|
|
||||||
//半成品库任务
|
|
||||||
reqParam.put("type", StatusEnum.HAIROU_LIKU_REQ.getCode());
|
|
||||||
//具体海柔出入库任务类型
|
|
||||||
reqParam.put("item_type", DeviceEnum.getTypeByCode(hailiangHrSsxDeviceDriver.getDevice_code()));
|
|
||||||
reqParam.put("device_code_one", hailiangHrSsxDeviceDriver.getDevice_code());
|
|
||||||
reqParam.put("vehicle_code_one", hailiangHrSsxDeviceDriver.getBarcode());
|
|
||||||
reqParam.put("device_code_two", hailiangHrSsxDeviceDriver2.getDevice_code());
|
|
||||||
reqParam.put("vehicle_code_two", hailiangHrSsxDeviceDriver2.getBarcode());
|
|
||||||
//向lms请求任务
|
|
||||||
// 联调时加上
|
|
||||||
// HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam);
|
|
||||||
// if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
|
||||||
// requireSucess = true;
|
|
||||||
// }
|
|
||||||
log.info("双工位请求成功");
|
|
||||||
requireSucess = true;
|
requireSucess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void creatInstruction(TaskDto taskDtos1) {
|
||||||
|
|
||||||
|
//判断当前任务号是否存在指令
|
||||||
|
String taskid = taskDtos1.getTask_id();
|
||||||
|
String taskcode = taskDtos1.getTask_code();
|
||||||
|
String priority = taskDtos1.getPriority();
|
||||||
|
String start_point_code = taskDtos1.getStart_point_code();
|
||||||
|
String start_device_code = taskDtos1.getStart_device_code();
|
||||||
|
String route_plan_code = taskDtos1.getRoute_plan_code();
|
||||||
|
String next_device_code = "";
|
||||||
|
/**
|
||||||
|
* 开始平均分配
|
||||||
|
*/
|
||||||
|
String this_coevice_code = taskServer.queryAssignedByDevice(device_code, taskDtos1.getNext_device_code());
|
||||||
|
if (StrUtil.isEmpty(this_coevice_code)) {
|
||||||
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, taskDtos1.getNext_device_code(), route_plan_code);
|
||||||
|
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||||
|
|
||||||
|
String path = routeLineDto.getPath();
|
||||||
|
String type = routeLineDto.getType();
|
||||||
|
String[] str = path.split("->");
|
||||||
|
|
||||||
|
List<String> pathlist = Arrays.asList(str);
|
||||||
|
int index = 0;
|
||||||
|
for (int m = 0; m < pathlist.size(); m++) {
|
||||||
|
if (pathlist.get(m).equals(start_device_code)) {
|
||||||
|
index = m + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next_device_code = pathlist.get(index);
|
||||||
} else {
|
} else {
|
||||||
//todo 输出不满足的原因
|
next_device_code = this_coevice_code;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//校验路由关系
|
||||||
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||||
|
if (ObjectUtils.isEmpty(shortPathsList) || shortPathsList.size() < 1) {
|
||||||
|
throw new RuntimeException("路由不通!");
|
||||||
}
|
}
|
||||||
|
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
|
||||||
|
String next_point_code;
|
||||||
|
if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||||
|
next_point_code = taskDtos1.getTo_x() + "-" + taskDtos1.getTo_y() + "-" + taskDtos1.getTo_z();
|
||||||
|
} else {
|
||||||
|
next_point_code = next_device_code;
|
||||||
}
|
}
|
||||||
|
Instruction instdto = new Instruction();
|
||||||
|
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
|
instdto.setRoute_plan_code(route_plan_code);
|
||||||
|
instdto.setRemark(taskDtos1.getRemark());
|
||||||
|
instdto.setMaterial(taskDtos1.getMaterial());
|
||||||
|
instdto.setQuantity(taskDtos1.getQuantity());
|
||||||
|
instdto.setTask_id(taskid);
|
||||||
|
instdto.setTask_code(taskcode);
|
||||||
|
String now = DateUtil.now();
|
||||||
|
instdto.setCreate_time(now);
|
||||||
|
instdto.setCreate_by("auto");
|
||||||
|
instdto.setStart_device_code(start_device_code);
|
||||||
|
instdto.setNext_device_code(next_device_code);
|
||||||
|
instdto.setStart_point_code(start_point_code);
|
||||||
|
instdto.setNext_point_code(next_point_code);
|
||||||
|
instdto.setPriority(priority);
|
||||||
|
instdto.setInstruction_status("0");
|
||||||
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
log.error("=================================,{}", instdto.getCreate_by());
|
||||||
|
try {
|
||||||
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("指令创建失败!", e.getMessage());
|
||||||
|
}
|
||||||
|
taskDtos1.setTask_status("1");
|
||||||
|
taskServer.update(taskDtos1);
|
||||||
|
requireSucess = true;
|
||||||
|
Map map = new HashMap();
|
||||||
|
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||||
|
map.put("to_target", next_addr);
|
||||||
|
map.put("to_task", instdto.getInstruction_code());
|
||||||
|
map.put("to_command", "1");
|
||||||
|
map.put("to_container_type", "1");
|
||||||
|
map.put("to_container_no", "1");
|
||||||
|
this.writing(map);
|
||||||
|
requireSucess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void writing(Map<String, Object> map) {
|
||||||
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||||
|
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||||
|
map.forEach((key, value) -> {
|
||||||
|
if (ObjectUtil.isNotEmpty(value)) {
|
||||||
|
itemMap.put(getToParam() + key, value);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||||
|
try {
|
||||||
|
this.checkcontrol(itemMap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
try {
|
||||||
|
this.checkcontrol(itemMap);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToParam() {
|
||||||
|
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//将扩展表中的字符串数据转换成集合
|
//将扩展表中的字符串数据转换成集合
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -595,14 +595,6 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task);
|
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task);
|
||||||
}
|
}
|
||||||
//当货物到达b点,实现完成指令
|
|
||||||
if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) || StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) {
|
|
||||||
if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
|
|
||||||
inst.setExecute_device_code(this.device_code);
|
|
||||||
finish_instruction();
|
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -683,7 +683,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
instructionMapper.updateById(entity);
|
instructionMapper.updateById(entity);
|
||||||
removeByCodeFromCache(dto.getInstruction_code());
|
removeByCodeFromCache(dto.getInstruction_code());
|
||||||
instructions.add(dto);
|
instructions.add(dto);
|
||||||
// this.reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user