Compare commits
6 Commits
v1.1_20240
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c1d54c3e3 | |||
| 5a08c9f11a | |||
| 23bbbe3abb | |||
| 747e9120b3 | |||
| 4ac7e7fa60 | |||
| 50a3d20a14 |
3
acs/nladmin-system/package-lock.json
generated
3
acs/nladmin-system/package-lock.json
generated
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"lockfileVersion": 1
|
||||
}
|
||||
@@ -57,6 +57,12 @@
|
||||
<artifactId>org.openscada.jinterop.deps</artifactId>
|
||||
<version>1.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.54</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.utgard</groupId>
|
||||
<artifactId>org.openscada.opc.dcom</artifactId>
|
||||
@@ -415,7 +421,33 @@
|
||||
<artifactId>ik-analyzer</artifactId>
|
||||
<version>${lucene.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.jinterop</groupId>
|
||||
<artifactId>org.openscada.jinterop.core</artifactId>
|
||||
<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.apache.lucene</groupId>
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
package org.nl.acs.agv.server;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.common.StandardOrdinarySiteDevice;
|
||||
import org.nl.acs.device_driver.RequestMethodEnum;
|
||||
import org.nl.acs.device_driver.basedriver.agv_conveyor.AgvConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.nl4.station.NL4StationDeviceDriver;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -90,7 +94,7 @@ public class AgvWaitUtil {
|
||||
}
|
||||
|
||||
//取货完成等待
|
||||
public JSONObject waitOutGet(String deviceCode) {
|
||||
public JSONObject waitOutGet(String deviceCode, TaskDto task) {
|
||||
log.info("仙工AGV取货完成后请求离开,设备号 - {}", deviceCode);
|
||||
boolean flag = false;
|
||||
|
||||
@@ -119,6 +123,22 @@ public class AgvWaitUtil {
|
||||
String message = "允许AGV取货后离开。";
|
||||
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message);
|
||||
flag = true;
|
||||
} else if (device.getDeviceDriver() instanceof AgvConveyorDeviceDriver) {
|
||||
// agv下料完成后写信号
|
||||
String executeCode = task.getExecute_code();
|
||||
if (StrUtil.isNotEmpty(executeCode)) {
|
||||
Device executeDevice = this.deviceAppService.findDeviceByCode(executeCode);
|
||||
if (executeDevice.getDeviceDriver() instanceof AgvConveyorDeviceDriver) {
|
||||
AgvConveyorDeviceDriver driver = (AgvConveyorDeviceDriver) executeDevice.getDeviceDriver();
|
||||
if ("down".equals(task.getExecute_message())) {
|
||||
driver.writing("to_down_finished", 1);
|
||||
log.info(deviceCode, "", "", "下料完成");
|
||||
}
|
||||
}
|
||||
flag = true;
|
||||
}else {
|
||||
log.info(deviceCode, "", "", "执行设备不是agv上下料驱动");
|
||||
}
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
@@ -244,8 +264,7 @@ public class AgvWaitUtil {
|
||||
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (RequestMethodEnum.CHANNEL_STEEL_MATERIAL_FINISHED.getCode().equals(task.getDirection())) {
|
||||
} else if (RequestMethodEnum.CHANNEL_STEEL_MATERIAL_FINISHED.getCode().equals(task.getDirection())) {
|
||||
// 槽钢上料完成任务
|
||||
if (deviceCode.equals(task.getNext_device_code2())) {
|
||||
// 如果是放满点,需要把取满点的信息写入再请求离开。
|
||||
@@ -278,8 +297,7 @@ public class AgvWaitUtil {
|
||||
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
driver.writing("to_command", 4);
|
||||
if (driver.getMode() != 0) {
|
||||
String message = "允许AGV放货后离开。";
|
||||
@@ -297,7 +315,32 @@ public class AgvWaitUtil {
|
||||
// 普通站点驱动
|
||||
String message = "允许AGV放货后离开。";
|
||||
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message);
|
||||
flag = true;
|
||||
//人工放货位到缓存区需要将货位信息写入缓存区
|
||||
if (task.getStart_device_code().startsWith("R_")&& deviceCode.endsWith("CH_")){
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_device_runpoint");
|
||||
JSONObject json = wo.query("device_code ='" + task.getStart_device_code() + "'").uniqueResult(0);
|
||||
if (MapUtil.isNotEmpty(json)) {
|
||||
JSONObject rpUpdate = new JSONObject();
|
||||
rpUpdate.put("material_type", json.get("material_type"));
|
||||
WQLObject.getWQLObject("acs_device_runpoint").update(rpUpdate, "device_code = '" + deviceCode + "'");
|
||||
}
|
||||
}
|
||||
} else if (device.getDeviceDriver() instanceof AgvConveyorDeviceDriver) {
|
||||
// agv上料完成后写信号
|
||||
String executeCode = task.getExecute_code();
|
||||
if (StrUtil.isNotEmpty(executeCode)) {
|
||||
Device executeDevice = this.deviceAppService.findDeviceByCode(executeCode);
|
||||
if (executeDevice.getDeviceDriver() instanceof AgvConveyorDeviceDriver) {
|
||||
AgvConveyorDeviceDriver driver = (AgvConveyorDeviceDriver) executeDevice.getDeviceDriver();
|
||||
if ("up".equals(task.getExecute_message())) {
|
||||
driver.writing("to_up_finished", 1);
|
||||
log.info(deviceCode, "", "", "上料完成");
|
||||
}
|
||||
}
|
||||
flag = true;
|
||||
}else {
|
||||
log.info(deviceCode, "", "", "执行设备不是agv上下料驱动");
|
||||
}
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@@ -722,7 +722,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
}
|
||||
|
||||
if (address.contains("GET")) {
|
||||
return agvWaitUtil.waitOutGet(deviceCodeNow);
|
||||
return agvWaitUtil.waitOutGet(deviceCodeNow,task);
|
||||
} else if (address.contains("PUT")) {
|
||||
return agvWaitUtil.waitOutPut(deviceCodeNow, task);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import com.alibaba.fastjson.JSONObject;
|
||||
public enum DriverTypeEnum {
|
||||
ORDINARY_SITE(1, "standard_ordinary_site", "普通站点", "station"),
|
||||
|
||||
NL4_STATION(2, "nl4_station", "诺力四期-对接位", "station");
|
||||
NL4_STATION(2, "nl4_station", "诺力四期-对接位", "station"),
|
||||
STANDAR_ORDINARY_SITE(3, "agv_conveyor", "上下料agv对接位", "conveyor");
|
||||
//驱动索引
|
||||
private int index;
|
||||
//驱动编码
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.nl.acs.device_driver.basedriver.agv_conveyor;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDTO;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.definition.OpcDeviceDriverDefinition;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AGV上料下料
|
||||
*/
|
||||
@Service
|
||||
public class AgvConveyorDefinition implements OpcDeviceDriverDefinition {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "agv_conveyor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "AGV上料下料";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "AGV上料下料";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new AgvConveyorDeviceDriver()).setDevice(device).setDriverDefinition(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return AgvConveyorDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDTO> getReadableItemDTOs() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDTO> getWriteableItemDTOs() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package org.nl.acs.device_driver.basedriver.agv_conveyor;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.acs.agv.server.AgvService;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
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.dto.TaskDto;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* AGV上料下料
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class AgvConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
|
||||
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
|
||||
|
||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
|
||||
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
||||
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
|
||||
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
|
||||
|
||||
private final DeviceExecuteLogService deviceExecuteLogService = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
|
||||
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
private Date instruction_apply_time = new Date();
|
||||
private int instruction_require_time_out = 3000;
|
||||
|
||||
int heartbeat = 0;
|
||||
int error = 0;
|
||||
int task = 0;
|
||||
int on_off_site;
|
||||
int tray_Information;
|
||||
int down_request;
|
||||
int up_request;
|
||||
|
||||
String on_off_site_str;
|
||||
String tray_Information_str;
|
||||
|
||||
Boolean isonline = true;
|
||||
|
||||
Boolean iserror = false;
|
||||
|
||||
|
||||
|
||||
int last_error = 0;
|
||||
|
||||
String device_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
//请求成功标记
|
||||
Boolean requireSucess = false;
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
String message = null;
|
||||
|
||||
device_code = this.getDeviceCode();
|
||||
on_off_site = this.itemProtocol.getItem_on_off_site();
|
||||
tray_Information = this.itemProtocol.getItem_tray_Information();
|
||||
down_request = this.itemProtocol.getItem_down_request();
|
||||
up_request = this.itemProtocol.getItem_up_request();
|
||||
on_off_site_str = String.valueOf(on_off_site);
|
||||
tray_Information_str = String.valueOf(tray_Information);
|
||||
|
||||
|
||||
|
||||
if (error != last_error) {
|
||||
}
|
||||
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
//未联机
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "未联机");
|
||||
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
if ((down_request == 1 || up_request == 1) && StringUtils.isNoneEmpty(on_off_site_str)){
|
||||
task_apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public synchronized boolean task_apply() 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;
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_device_runpoint");
|
||||
//上料设备
|
||||
List<String> putDeviceCodeList = this.getExtraDeviceCodes("put_device_code");
|
||||
//下料设备
|
||||
List<String> getDeviceCodeList = this.getExtraDeviceCodes("get_device_code");
|
||||
|
||||
//请求下料
|
||||
if (down_request == 1){
|
||||
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(on_off_site_str);
|
||||
if (CollUtil.isNotEmpty(taskDtos)){
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "已存在"+on_off_site_str+"为起点就绪或执行的任务");
|
||||
return false;
|
||||
}
|
||||
String nextCode = null;
|
||||
//下料点要有货,终点要无货
|
||||
JSONObject json = wo.query("device_code ='" + on_off_site_str + "'").uniqueResult(0);
|
||||
if (MapUtil.isNotEmpty(json) && "0".equals(json.get("hasgoods"))){
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", on_off_site_str + "下料点无货物");
|
||||
return false;
|
||||
}
|
||||
if (CollUtil.isNotEmpty(getDeviceCodeList)){
|
||||
//查找无货的防货点
|
||||
for (String deviceCode : getDeviceCodeList) {
|
||||
JSONObject jsonEnd = wo.query("device_code ='" + deviceCode + "'").uniqueResult(0);
|
||||
if (MapUtil.isNotEmpty(jsonEnd) && "0".equals(jsonEnd.get("hasgoods"))){
|
||||
nextCode = deviceCode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nextCode == null){
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "终点货物占满");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TaskDto taskDto = new TaskDto();
|
||||
taskDto.setStart_device_code(on_off_site_str);
|
||||
taskDto.setNext_device_code(nextCode);
|
||||
taskDto.setStart_point_code(on_off_site_str);
|
||||
taskDto.setNext_point_code(nextCode);
|
||||
taskDto.setExecute_code(this.device_code);
|
||||
taskDto.setExecute_message("down");
|
||||
taskDto.setTask_type("3");
|
||||
taskserver.create(taskDto);
|
||||
}
|
||||
//请求上料
|
||||
if (up_request == 1){
|
||||
String startCode = null;
|
||||
List<TaskDto> taskDtos = taskserver.queryTaskByEndDeviceCodeAndStatus(on_off_site_str);
|
||||
if (CollUtil.isNotEmpty(taskDtos)){
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "已存在"+on_off_site_str+"为终点就绪或执行的任务");
|
||||
return false;
|
||||
}
|
||||
//起点要有货,上料点要无货
|
||||
JSONObject json = wo.query("device_code ='" + on_off_site_str + "'").uniqueResult(0);
|
||||
if (MapUtil.isNotEmpty(json) && "1".equals(json.get("hasgoods"))){
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", on_off_site_str + "上料点存在货物");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(putDeviceCodeList)){
|
||||
//查找无货的防货点
|
||||
for (String deviceCode : putDeviceCodeList) {
|
||||
JSONObject jsonStar = wo.query("device_code ='" + deviceCode + "'").uniqueResult(0);
|
||||
if (MapUtil.isNotEmpty(jsonStar) && "1".equals(jsonStar.get("hasgoods")) && tray_Information_str.equals(jsonStar.get("material_type"))){
|
||||
startCode = deviceCode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startCode == null){
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "起点无货物可取或者物料类型不匹配");
|
||||
return false;
|
||||
}
|
||||
|
||||
TaskDto taskDto = new TaskDto();
|
||||
taskDto.setStart_device_code(startCode);
|
||||
taskDto.setNext_device_code(on_off_site_str);
|
||||
taskDto.setStart_point_code(startCode);
|
||||
taskDto.setNext_point_code(on_off_site_str);
|
||||
taskDto.setExecute_code(this.device_code);
|
||||
taskDto.setExecute_message("up");
|
||||
taskDto.setTask_type("3");
|
||||
taskserver.create(taskDto);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void writing(String param, Object value) {
|
||||
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." +
|
||||
this.getDevice().getOpc_plc_code() + "." +
|
||||
this.getDevice().getDevice_code() + "." +
|
||||
param;
|
||||
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put(to_param, value);
|
||||
this.control(itemMap);
|
||||
|
||||
this.deviceExecuteLogService.deviceExecuteLog(device_code, "", "", param + " 写入 " + value);
|
||||
}
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String mode = "";
|
||||
String action = "";
|
||||
String move = "";
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("action", action);
|
||||
jo.put("isOnline", this.getIsonline());
|
||||
jo.put("error", this.getError());
|
||||
jo.put("isError", this.getIserror());
|
||||
jo.put("task", this.getTask());
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package org.nl.acs.device_driver.basedriver.agv_conveyor;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_on_off_site = "on_off_site";
|
||||
public static String item_tray_Information = "tray_Information";
|
||||
public static String item_down_request = "down_request";
|
||||
public static String item_up_request = "up_request";
|
||||
public static String item_to_up_finished = "to_up_finished";
|
||||
public static String item_to_down_finished = "to_down_finished";
|
||||
|
||||
|
||||
|
||||
private AgvConveyorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(AgvConveyorDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getItem_on_off_site() {
|
||||
return this.getOpcIntegerValue(item_on_off_site);
|
||||
}
|
||||
|
||||
public int getItem_tray_Information() {
|
||||
return this.getOpcIntegerValue(item_tray_Information);
|
||||
}
|
||||
|
||||
public int getItem_down_request() {
|
||||
return this.getOpcIntegerValue(item_down_request);
|
||||
}
|
||||
public int getItem_up_request() {
|
||||
return this.getOpcIntegerValue(item_up_request);
|
||||
}
|
||||
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error("读取错误!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static List<ItemDTO> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDTO(item_on_off_site, "上下站点", "VW2"));
|
||||
list.add(new ItemDTO(item_tray_Information, "料盘信息", "VW4"));
|
||||
list.add(new ItemDTO(item_down_request, "下料请求", "VW6"));
|
||||
list.add(new ItemDTO(item_up_request, "上料请求", "VW8"));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDTO> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDTO(item_to_up_finished, "上料完成", "VW102"));
|
||||
list.add(new ItemDTO(item_to_down_finished, "下料完成", "VW104"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -183,8 +183,11 @@ public interface RouteLineService {
|
||||
*/
|
||||
public List<RouteLineDto> getPathLinesByCode(String device_code, String plan_code);
|
||||
|
||||
public List<RouteLineDto> getsByCode(String device_code, String plan_code);
|
||||
|
||||
public List<RouteLineDto> getSuperiorShortPathLinesByCode(String device_code, String plan_code);
|
||||
|
||||
public JSONArray getActivePathLine(String device_code, String next_device_code, String plan_code);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -554,6 +554,22 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
|
||||
return newresult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RouteLineDto> getsByCode(String device_code, String plan_code) {
|
||||
List list = this.routeLines.get(plan_code);
|
||||
List result = new ArrayList();
|
||||
Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RouteLineDto routeLineDto = (RouteLineDto) iterator.next();
|
||||
if (StrUtil.equals(routeLineDto.getDevice_code(), device_code)) {
|
||||
result.add(routeLineDto);
|
||||
}
|
||||
}
|
||||
List<RouteLineDto> newresult = (List<RouteLineDto>) result.stream().sorted(Comparator.comparing(RouteLineDto::getWeights)).collect(Collectors.toList());
|
||||
|
||||
return newresult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RouteLineDto> getSuperiorShortPathLinesByCode(String device_code, String plan_code) {
|
||||
List list = this.routeLines.get(plan_code);
|
||||
@@ -570,6 +586,7 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void autoInitial() throws Exception {
|
||||
this.reload();
|
||||
@@ -610,4 +627,8 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn
|
||||
JSONArray newresult = WQL.getWO("QROUTE").addParamMap(map).process().getResultJSONArray(0);
|
||||
return newresult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -242,4 +242,11 @@ public interface TaskService {
|
||||
*/
|
||||
List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code);
|
||||
|
||||
/**
|
||||
* 根据终点设备号和任务状态查询
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
List<TaskDto> queryTaskByEndDeviceCodeAndStatus(String device_code);
|
||||
|
||||
}
|
||||
|
||||
@@ -728,10 +728,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
rpUpdate.put("update_time", DateUtil.now());
|
||||
String device_code3 = "";
|
||||
String device_code4 = "";
|
||||
if (device3 != null){
|
||||
if (device3 != null) {
|
||||
device_code3 = device3.getDevice_code();
|
||||
}
|
||||
if (device4 != null){
|
||||
if (device4 != null) {
|
||||
device_code4 = device4.getDevice_code();
|
||||
}
|
||||
WQLObject.getWQLObject("acs_device_runpoint").update(rpUpdate, "device_code IN ('" + device1.getDevice_code() + "', '" + device2.getDevice_code() + "', '" + device_code3 + "', '" + device_code4 + "')");
|
||||
@@ -1226,11 +1226,22 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "1")) {
|
||||
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
list.add(task);
|
||||
}
|
||||
if (task.getStart_device_code().equals(device_code) && (StrUtil.equals(task.getTask_status(), "1") || StrUtil.equals(task.getTask_status(), "0"))) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByEndDeviceCodeAndStatus(String device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getNext_device_code().equals(device_code) && (StrUtil.equals(task.getTask_status(), "1") || StrUtil.equals(task.getTask_status(), "0"))) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
package org.nl.hand.amb.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -28,6 +30,7 @@ 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;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.acs.task.service.impl.TaskServiceImpl;
|
||||
@@ -44,10 +47,7 @@ import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@@ -63,6 +63,10 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
private final DeviceService deviceService;
|
||||
private final DeviceAppService deviceAppService;
|
||||
private final DictService dictService;
|
||||
private final TaskService taskserver;
|
||||
private final RouteLineService routeLineService;
|
||||
|
||||
|
||||
InstructionService instructionService = null;
|
||||
|
||||
|
||||
@@ -83,7 +87,7 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
throw new BadRequestException("区域不能为空!");
|
||||
}
|
||||
|
||||
JSONArray devices = WQLObject.getWQLObject("acs_device").query("region = '" + region + "' AND device_type = 'station' AND is_config = 'true' ", "seq_num").getResultJSONArray(0);
|
||||
JSONArray devices = WQLObject.getWQLObject("acs_device").query("region = '" + region + "' AND (device_type = 'station' || device_type = 'conveyor') AND is_config = 'true' ", "seq_num").getResultJSONArray(0);
|
||||
JSONArray resultArr = new JSONArray();
|
||||
for (int i = 0; i < devices.size(); i++) {
|
||||
JSONObject device = devices.getJSONObject(i);
|
||||
|
||||
@@ -6,9 +6,9 @@ spring:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nl4_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:siqi}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:password}
|
||||
password: ${DB_PWD:123456}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接数
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
||||
@@ -3,7 +3,7 @@ window.g = {
|
||||
VUE_APP_BASE_API: 'http://127.0.0.1:8010'
|
||||
},
|
||||
prod: {
|
||||
VUE_APP_BASE_API: 'http://10.93.41.198:8010'
|
||||
VUE_APP_BASE_API: 'http://188.188.69.101:8010'
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
data() {
|
||||
|
||||
@@ -103,6 +103,7 @@ import conveyor_ssx_barcode from '@/views/acs/device/driver/lnsh/conveyor_ssx_ba
|
||||
import conveyor_press_station from '@/views/acs/device/driver/lnsh/conveyor_press_station'
|
||||
import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one'
|
||||
import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two'
|
||||
import agv_conveyor from './driver/agv_conveyor.vue'
|
||||
import package_site from './driver/lnsh/package_site.vue'
|
||||
import nl4_station from '@/views/acs/device/driver/nl4/nl4_station.vue'
|
||||
|
||||
@@ -113,7 +114,7 @@ export default {
|
||||
standard_conveyor_control, standard_conveyor_monitor, lnsh_mixing_mill, lnsh_press, lnsh_palletizing_manipulator, lnsh_fold_disc_site, lnsh_kiln_lane, lnsh_kiln_truss,
|
||||
lnsh_package_line, lnsh_out_kiln_truss, lnsh_package_pallet_manipulator, lnsh_pallet_storage, lnsh_labeling_machine, lnsh_split_manipulator, lnsh_rgv,
|
||||
lnsh_station, lnsh_Laminating_machine, lnsh_package_site, lnsh_crusher, lnsh_palletizing_manipulator_site, conveyor_ssx_barcode, conveyor_press_station,
|
||||
agv_ndc_one, agv_ndc_two, package_site, nl4_station },
|
||||
agv_ndc_one, agv_ndc_two, package_site, nl4_station, agv_conveyor },
|
||||
dicts: ['device_type'],
|
||||
mixins: [crud],
|
||||
data() {
|
||||
|
||||
471
acs/nladmin-ui/src/views/acs/device/driver/agv_conveyor.vue
Normal file
471
acs/nladmin-ui/src/views/acs/device/driver/agv_conveyor.vue
Normal file
@@ -0,0 +1,471 @@
|
||||
<template>
|
||||
<!--上下料位-->
|
||||
<div>
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">设备协议:</span>
|
||||
</div>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
OpcServer:
|
||||
<el-select
|
||||
v-model="opc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
filterable
|
||||
@change="changeOpc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcservers"
|
||||
:key="item.opc_id"
|
||||
:label="item.opc_name"
|
||||
:value="item.opc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
PLC:
|
||||
<el-select
|
||||
v-model="plc_id"
|
||||
placeholder="无"
|
||||
clearable
|
||||
filterable
|
||||
@change="changePlc"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataOpcPlcs"
|
||||
:key="item.plc_id"
|
||||
:label="item.plc_name"
|
||||
:value="item.plc_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">输送系统:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="电气调度号" label-width="150px">
|
||||
<el-input v-model="form.address" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">指令相关:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
|
||||
<el-row>
|
||||
|
||||
<el-col :span="10">
|
||||
<el-form-item label="下料配置" prop="device_code">
|
||||
<el-select
|
||||
v-model="form.get_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-col :span="10">
|
||||
<el-form-item label="上料配置" prop="device_code">
|
||||
<el-select
|
||||
v-model="form.put_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-row />
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">AGV相关:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="取货">
|
||||
<el-switch v-model="form.is_pickup" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="放货">
|
||||
<el-switch v-model="form.is_release" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC读取字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data1"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data1[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishReadEdit(data1[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbr_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">PLC写入字段:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||
<el-table
|
||||
v-loading="false"
|
||||
:data="data2"
|
||||
:max-height="550"
|
||||
size="small"
|
||||
style="width: 100%;margin-bottom: 15px"
|
||||
>
|
||||
|
||||
<el-table-column prop="name" label="用途" />
|
||||
<el-table-column prop="code" label="别名要求" />
|
||||
<el-table-column prop="db" label="DB块">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="data2[scope.$index].db"
|
||||
size="mini"
|
||||
class="edit-input"
|
||||
@input="finishWriteEdit(data2[scope.$index])"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbr_value2">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_read2()">测试读</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data2[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dbw_value">
|
||||
<template slot="header">
|
||||
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span" />
|
||||
<el-button
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
type="primary"
|
||||
@click="doSubmit"
|
||||
>保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
queryDriverConfig,
|
||||
updateConfig,
|
||||
testRead,
|
||||
testwrite
|
||||
} from '@/api/acs/device/driverConfig'
|
||||
import { selectOpcList } from '@/api/acs/device/opc'
|
||||
import { selectPlcList } from '@/api/acs/device/opcPlc'
|
||||
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
|
||||
|
||||
import crud from '@/mixins/crud'
|
||||
import deviceCrud from '@/api/acs/device/device'
|
||||
|
||||
export default {
|
||||
name: 'StandardConveyorControl',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
type: Object,
|
||||
require: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
device_code: '',
|
||||
device_id: '',
|
||||
plc_id: '',
|
||||
plc_code: '',
|
||||
address: '',
|
||||
opc_id: '',
|
||||
opc_code: '',
|
||||
configLoading: false,
|
||||
dataOpcservers: [],
|
||||
dataOpcPlcs: [],
|
||||
deviceList: [],
|
||||
data1: [],
|
||||
data2: [],
|
||||
form: {
|
||||
inspect_in_stocck: true,
|
||||
ignore_pickup_check: true,
|
||||
ignore_release_check: true,
|
||||
apply_task: true,
|
||||
link_three_lamp: '',
|
||||
manual_create_task: true,
|
||||
is_pickup: true,
|
||||
is_release: true,
|
||||
link_device_code: '',
|
||||
get_device_code: [],
|
||||
put_device_code: []
|
||||
},
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
// 从父表单获取设备编码
|
||||
this.device_id = this.$props.parentForm.device_id
|
||||
this.device_code = this.$props.parentForm.device_code
|
||||
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.form) {
|
||||
const arr = Object.keys(data.form)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.form = data.form
|
||||
}
|
||||
}
|
||||
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.parentForm) {
|
||||
const arr = Object.keys(data.parentForm)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.opc_code = data.parentForm.opc_code
|
||||
this.plc_code = data.parentForm.plc_code
|
||||
}
|
||||
}
|
||||
this.data1 = data.rs
|
||||
this.data2 = data.ws
|
||||
this.sliceItem()
|
||||
})
|
||||
selectPlcList().then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = this.$props.parentForm.opc_plc_id
|
||||
})
|
||||
selectOpcList().then(data => {
|
||||
this.dataOpcservers = data
|
||||
this.opc_id = this.$props.parentForm.opc_server_id
|
||||
})
|
||||
deviceCrud.selectDeviceList().then(data => {
|
||||
this.deviceList = data
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
finishReadEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('mode') !== -1) {
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.substring(0, 2)
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.substring(2)
|
||||
for (const val in this.data1) {
|
||||
if (this.data1[val].code.indexOf('move') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 2)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('number') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 4)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('container_type') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 6)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('error') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 8)
|
||||
}
|
||||
if (this.data1[val].code.indexOf('task') !== -1) {
|
||||
this.data1[val].db = beforeStr + (parseInt(afterStr) + 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
finishWriteEdit(data) {
|
||||
// 编辑的是code列,并且值包含mode
|
||||
if (data.code.indexOf('to_command') !== -1) {
|
||||
const dbValue = data.db
|
||||
// .之前的字符串
|
||||
const beforeStr = dbValue.substring(0, 2)
|
||||
// .之后的字符串
|
||||
const afterStr = dbValue.substring(2)
|
||||
for (const val in this.data2) {
|
||||
if (this.data2[val].code.indexOf('to_target') !== -1) {
|
||||
this.data2[val].db = beforeStr + (parseInt(afterStr) + 2)
|
||||
}
|
||||
if (this.data2[val].code.indexOf('to_task') !== -1) {
|
||||
this.data2[val].db = beforeStr + (parseInt(afterStr) + 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
changeOpc(val) {
|
||||
this.dataOpcservers.forEach(item => {
|
||||
if (item.opc_id === val) {
|
||||
this.opc_code = item.opc_code
|
||||
}
|
||||
})
|
||||
|
||||
selectListByOpcID(val).then(data => {
|
||||
this.dataOpcPlcs = data
|
||||
this.plc_id = ''
|
||||
this.plc_code = ''
|
||||
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
|
||||
this.plc_id = this.dataOpcPlcs[0].plc_id
|
||||
this.plc_code = this.dataOpcPlcs[0].plc_code
|
||||
}
|
||||
this.sliceItem()
|
||||
})
|
||||
},
|
||||
changePlc(val) {
|
||||
this.dataOpcPlcs.forEach(item => {
|
||||
if (item.plc_id === val) {
|
||||
this.plc_code = item.plc_code
|
||||
this.sliceItem()
|
||||
return
|
||||
}
|
||||
})
|
||||
},
|
||||
test_read1() {
|
||||
testRead(this.data1, this.opc_id).then(data => {
|
||||
this.data1 = data
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
test_write1() {
|
||||
testwrite(this.data2, this.opc_id).then(data => {
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
test_read2() {
|
||||
testRead(this.data2, this.opc_id).then(data => {
|
||||
this.data2 = data
|
||||
console.log(this.data2)
|
||||
this.notify('操作成功!', 'success')
|
||||
}).catch(err => {
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
},
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.configLoading = true
|
||||
// 根据驱动类型判断是否为路由设备
|
||||
const parentForm = this.parentForm
|
||||
parentForm.is_route = true
|
||||
parentForm.plc_id = this.plc_id
|
||||
parentForm.opc_id = this.opc_id
|
||||
updateConfig(parentForm, this.form, this.modeform, this.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
sliceItem() { // 拼接DB的Item值
|
||||
this.data1.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
this.data2.forEach(item => {
|
||||
const str = item.code
|
||||
// 是否包含.
|
||||
if (str.search('.') !== -1) {
|
||||
// 截取最后一位
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||
} else {
|
||||
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user