diff --git a/acs/nladmin-system/pom.xml b/acs/nladmin-system/pom.xml index 80f2473..e94f0c6 100644 --- a/acs/nladmin-system/pom.xml +++ b/acs/nladmin-system/pom.xml @@ -68,12 +68,28 @@ org.openscada.jinterop org.openscada.jinterop.core - 2.1.8 + 2.1.8 + + org.bouncycastle + bcprov-jdk15on + + org.openscada.jinterop org.openscada.jinterop.deps 1.5.0 + + + org.bouncycastle + bcprov-jdk15on + + + + + org.bouncycastle + bcprov-jdk15on + 1.50 org.openscada.utgard diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls index 665ebb7..64abf0a 100644 Binary files a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls and b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls differ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index c0bd72c..cc060e1 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/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); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java index 70654b0..71260a0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java +++ b/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 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 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(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 42f5660..72bafcf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/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; diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index e575119..48994d2 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/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 list = taskserver.queryAll("task_status = '0'"); + List list = taskserver.queryAll("task_status = '0' ORDER BY create_time ASC"); + List list2 = taskserver.queryAll("task_status = '1' ORDER BY create_time ASC"); + Map> collect = list.stream().sorted(Comparator.comparing(TaskDto::getCreate_time)) + .collect(Collectors.groupingBy(TaskDto::getPriority)); + TreeMap> treeMap = new TreeMap<>(new Comparator() { + @Override + public int compare(String o1, String o2) { + return o2.compareTo(o1); + } + }); + treeMap.putAll(collect); + for (List 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(), "-") ){ + 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 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 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 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 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 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); - } } -} +} \ No newline at end of file diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index e9a67a5..112f764 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/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 diff --git a/acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue b/acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue index 0cd0926..05b533f 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue @@ -102,6 +102,24 @@ + + + + + + + @@ -179,7 +197,8 @@ export default { station_manager: true, auto_clean_task: true, input_material: true, - reqWms: true + reqWms: true, + link_device_code: [] }, rules: {} } diff --git a/acs/nladmin-ui/src/views/acs/task/index.vue b/acs/nladmin-ui/src/views/acs/task/index.vue index 8302850..89d10eb 100644 --- a/acs/nladmin-ui/src/views/acs/task/index.vue +++ b/acs/nladmin-ui/src/views/acs/task/index.vue @@ -72,6 +72,7 @@