Browse Source

add: 添加创建指令策略

master
yanps 8 months ago
parent
commit
fceece174b
  1. 18
      acs/nladmin-system/pom.xml
  2. BIN
      acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls
  3. 10
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java
  4. 19
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java
  5. 1
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  6. 131
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java
  7. 4
      acs/nladmin-system/src/main/resources/config/application-dev.yml
  8. 21
      acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue
  9. 1
      acs/nladmin-ui/src/views/acs/task/index.vue

18
acs/nladmin-system/pom.xml

@ -68,12 +68,28 @@
<dependency>
<groupId>org.openscada.jinterop</groupId>
<artifactId>org.openscada.jinterop.core</artifactId>
<version>2.1.8</version>
<version>2.1.8</version><exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.openscada.jinterop</groupId>
<artifactId>org.openscada.jinterop.deps</artifactId>
<version>1.5.0</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.50</version>
</dependency>
<dependency>
<groupId>org.openscada.utgard</groupId>

BIN
acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls

Binary file not shown.

10
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java

@ -186,6 +186,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject resp = JSONObject.parseObject(httpResponse.body());
if (resp.getInteger("status") == 200) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
inst.setExecute_status("1");
log.info("指令号:{},acs请求wms取货申请成功,wms允许agv申请取货,已反馈agv允许取货", inst.getInstruction_code());
} else {
log.warn("指令号:{},acs请求wms取货申请失败,wms不允许agv取货,未反馈agv允许取货", inst.getInstruction_code());
@ -195,6 +196,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
} else {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
inst.setExecute_status("1");
}
}
//取货完毕
@ -255,6 +257,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject resp = JSONObject.parseObject(httpResponse.body());
if (resp.getInteger("status") == 200) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
inst.setExecute_status("2");
log.info("指令号:{},acs反馈wms取货完成离开成功,wms允许agv取货完成离开,已反馈agv取货完成离开", inst.getInstruction_code());
} else {
log.warn("指令号:{},acs反馈wms取货完成离开失败,wms不允许agv取货完成离开,未反馈agv取货完成离开", inst.getInstruction_code());
@ -264,6 +267,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
} else {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
inst.setExecute_status("2");
}
}
//到达放货点
@ -321,6 +325,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject resp = JSONObject.parseObject(httpResponse.body());
if (resp.getInteger("status") == 200) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
inst.setExecute_status("3");
log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code());
} else {
log.warn("指令号:{},acs请求wms放货申请失败,wms不允许agv放货,未反馈agv允许放货", inst.getInstruction_code());
@ -330,6 +335,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
} else {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
inst.setExecute_status("3");
}
}
@ -388,6 +394,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject resp = JSONObject.parseObject(httpResponse.body());
if (resp.getInteger("status") == 200) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
inst.setExecute_status("4");
log.info("指令号:{},acs请求wms放货完成申请成功,wms允许agv放货完成,已反馈agv放货完成", inst.getInstruction_code());
} else {
log.warn("指令号:{},acs请求wms放货完成离开失败,wms不允许agv放货完成离开,未反馈agv放货完成离开", inst.getInstruction_code());
@ -397,9 +404,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
} else {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
inst.setExecute_status("4");
}
}
}
//到达位置点
//(需要WCS反馈)
@ -431,6 +438,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
phase = 0;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data));
log.info("{},{}", device_code, "agvphase:" + phase + "反馈:" + Bytes2HexString(data));
instructionService.update(inst);
OneNDCSocketConnectionAutoRun.write(data);
}
}

19
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java

@ -1,6 +1,7 @@
package org.nl.acs.device_driver.basedriver.standard_ordinary_site;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@ -24,7 +25,9 @@ import org.nl.acs.task.service.TaskService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -186,6 +189,22 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
}
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
if (StrUtil.isEmpty(extraValue)) {
return new ArrayList<>();
}
String devicesString = extraValue.substring(1, extraValue.length() - 1);
List<String> devicesList = new ArrayList<>();
String[] devices = devicesString.split(",");
for (int i = 0; i < devices.length; i++) {
String s = devices[i].replace("\"", "").replace("\"", "");
devicesList.add(s);
}
return devicesList;
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();

1
acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -145,6 +145,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (!StrUtil.isEmpty(is_over)) {
map.put("is_over", is_over);
}
map.put("create", "DESC");
final JSONObject jo =
WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "");
return jo;

131
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

@ -1,12 +1,17 @@
package org.nl.modules.quartz.task;
import cn.hutool.core.collection.CollUtil;
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.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
@ -16,8 +21,9 @@ import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* 自动创建指令
@ -26,6 +32,8 @@ import java.util.List;
@Component
public class AutoCreateInst {
/**
* 根据任务状态创建指令生成下一条指令
* 创建指令前需要判断是否条件具备起始位置是否有货目标位置是否有货
@ -35,13 +43,120 @@ public class AutoCreateInst {
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
List<TaskDto> list = taskserver.queryAll("task_status = '0'");
List<TaskDto> list = taskserver.queryAll("task_status = '0' ORDER BY create_time ASC");
List<TaskDto> list2 = taskserver.queryAll("task_status = '1' ORDER BY create_time ASC");
Map<String, List<TaskDto>> collect = list.stream().sorted(Comparator.comparing(TaskDto::getCreate_time))
.collect(Collectors.groupingBy(TaskDto::getPriority));
TreeMap<String, List<TaskDto>> treeMap = new TreeMap<>(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o2.compareTo(o1);
}
});
treeMap.putAll(collect);
for (List<TaskDto> value : treeMap.values()) {
list = value;
if(CollUtil.isNotEmpty(list)){
break;
}
}
for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i);
if (StrUtil.equals(acsTask.getTask_type(), "7") && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
Device startDevice = appService.findDeviceByCode(acsTask.getStart_device_code());
Device nextDevice = appService.findDeviceByCode(acsTask.getNext_device_code());
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (i > 0 && acsTask.getTask_type().equals(list.get(i - 1).getTask_type())) {
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver();
List<String> link_device_code = standardOrdinarySiteDeviceDriver.getExtraDeviceCodes("link_device_code");
Boolean flag = false;
for (String s : link_device_code) {
if (s.equals(list.get(i - 1).getStart_device_code())) {
flag = true;
log.error("当前任务号{},已创建同列起点导致创建指令失败,起点为{},终点为{}", acsTask.getTask_code(), acsTask.getStart_device_code(), acsTask.getNext_device_code());
break;
}
}
if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask);
continue;
}
} else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextDevice.getDeviceDriver();
List<String> link_device_code = standardOrdinarySiteDeviceDriver.getExtraDeviceCodes("link_device_code");
Boolean flag = false;
for (String s : link_device_code) {
if (s.equals(list.get(i - 1).getNext_device_code())) {
flag = true;
log.error("当前任务号{},已创建同列起点导致创建指令失败,起点为{},终点为{}", acsTask.getTask_code(), acsTask.getStart_device_code(), acsTask.getNext_device_code());
break;
}
}
if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask);
continue;
}
}
}
Boolean flag2 = false;
if (CollUtil.isNotEmpty(list2)) {
for (TaskDto taskDto : list2) {
if (taskDto.getTask_type().equals(acsTask.getTask_type())) {
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver();
List<String> link_device_code = standardOrdinarySiteDeviceDriver.getExtraDeviceCodes("link_device_code");
Boolean flag = false;
for (String s : link_device_code) {
if (s.equals(taskDto.getStart_device_code())) {
Instruction instruction = instructionService.findByTaskid(taskDto.getTask_id(), "instruction_status < 2");
if (ObjectUtil.isEmpty(instruction) || (Integer.parseInt(StrUtil.isNotBlank
(instruction.getExecute_status()) ? instruction.getExecute_status() : "0") < 2)) {
flag = true;
log.error("当前任务号{},已创建同列起点导致创建指令失败,起点为{},终点为{}", acsTask.getTask_code(), acsTask.getStart_device_code(), acsTask.getNext_device_code());
break;
}
}
}
if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask);
flag2 = true;
break;
}
} else if (nextDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextDevice.getDeviceDriver();
List<String> link_device_code = standardOrdinarySiteDeviceDriver.getExtraDeviceCodes("link_device_code");
Boolean flag = false;
for (String s : link_device_code) {
if (s.equals(taskDto.getNext_device_code())) {
Instruction instruction = instructionService.findByTaskid(taskDto.getTask_id(), "instruction_status < 2");
if (ObjectUtil.isEmpty(instruction) || (Integer.parseInt(StrUtil.isNotBlank
(instruction.getExecute_status()) ? instruction.getExecute_status() : "0") <4)) {
flag = true;
log.error("当前任务号{},已创建同列起点导致创建指令失败,起点为{},终点为{}", acsTask.getTask_code(), acsTask.getStart_device_code(), acsTask.getNext_device_code());
break;
}
}
}
if (flag) {
acsTask.setRemark("同列起点已存在,创建指令失败");
taskserver.update(acsTask);
flag2 = true;
break;
}
}
}
}
if (flag2) {
continue;
}
}
acsTask.setRemark("");
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
String task_type = acsTask.getTask_type();
@ -92,14 +207,14 @@ public class AutoCreateInst {
String type = routeLineDto.getType();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
int index1 = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
index1 = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
next_device_code = pathlist.get(index1);
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
@ -151,8 +266,8 @@ public class AutoCreateInst {
}
//创建指令后修改任务状态
acsTask.setTask_status("1");
acsTask.setRemark("");
taskserver.update(acsTask);
}
}
}

4
acs/nladmin-system/src/main/resources/config/application-dev.yml

@ -13,11 +13,11 @@ spring:
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:wzgj_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lbkd_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
username: ${DB_USER:root}
# password: ${DB_PWD:P@ssw0rd}
# password: ${DB_PWD:Root.123456}
password: ${DB_PWD:password}
password: ${DB_PWD:123456}
# 初始连接数
initial-size: 5

21
acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue

@ -102,6 +102,24 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="关联设备" prop="device_code">
<el-select
v-model="form.link_device_code"
filterable
multiple
clearable
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
@ -179,7 +197,8 @@ export default {
station_manager: true,
auto_clean_task: true,
input_material: true,
reqWms: true
reqWms: true,
link_device_code: []
},
rules: {}
}

1
acs/nladmin-ui/src/views/acs/task/index.vue

@ -72,6 +72,7 @@
<crudOperation :permission="permission">
<el-button
slot="left"
v-permission="['admin','task:add']"
class="filter-item"
size="mini"
type="primary"

Loading…
Cancel
Save