Browse Source

更新

master
gengby 2 years ago
parent
commit
b6fd4ac69e
  1. 158
      acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java
  2. 13
      acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java
  3. 69
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/RouteUtil.java
  4. 82
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/ItemProtocol.java
  5. 60
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDefination.java
  6. 305
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java
  7. 37
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AgvToAcsController.java
  8. 17
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AgvToAcsService.java
  9. 87
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java
  10. 10
      acs/nladmin-system/src/main/java/org/nl/hand/amb/rest/HFHandController.java
  11. 7
      acs/nladmin-system/src/main/java/org/nl/hand/amb/service/HFHandService.java
  12. 67
      acs/nladmin-system/src/main/java/org/nl/hand/amb/service/impl/HFHandServiceImpl.java
  13. 8
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java
  14. 7
      acs/nladmin-system/src/main/resources/config/application-dev.yml
  15. 3
      acs/nladmin-system/src/main/resources/config/application-prod.yml
  16. 2
      acs/nladmin-system/src/main/resources/config/application.yml
  17. 4
      acs/nladmin-ui/src/views/acs/device/config.vue
  18. 502
      acs/nladmin-ui/src/views/acs/device/driver/magang_conveyor_control.vue
  19. 2
      acs/nladmin-ui/src/views/login.vue

158
acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java

@ -13,6 +13,7 @@ import org.nl.acs.AcsConfig;
import org.nl.acs.agv.AgvUtil; import org.nl.acs.agv.AgvUtil;
import org.nl.acs.agv.server.XianGongAgvService; import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.agv.server.dto.AgvDto; import org.nl.acs.agv.server.dto.AgvDto;
import org.nl.acs.device_driver.RouteUtil;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.LokiLog; import org.nl.acs.log.LokiLog;
@ -22,12 +23,10 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceType; import org.nl.acs.opc.DeviceType;
import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.ParamService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@Service @Service
@ -38,6 +37,9 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
private final AcsToWmsService acsToWmsService; private final AcsToWmsService acsToWmsService;
Map<String, AgvDto> AGVDeviceStatus = new HashMap(); Map<String, AgvDto> AGVDeviceStatus = new HashMap();
@Value("${agvToAcs.addr}")
private String addr;
@LokiLog(type = LokiLogType.AGV) @LokiLog(type = LokiLogType.AGV)
@Override @Override
public String waitPointRequest(String param) { public String waitPointRequest(String param) {
@ -236,16 +238,156 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
@Override @Override
public JSONArray createBlocksData(Instruction inst) { public JSONArray createBlocksData(Instruction inst) {
JSONArray ja = new JSONArray(); JSONArray ja = new JSONArray();
//取货前等待
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
jo.put("blockId", IdUtil.simpleUUID()); jo.put("blockId", IdUtil.simpleUUID());
jo.put("location",inst.getStart_point_code()); jo.put("location", inst.getStart_point_code() + "INGET");
jo.put("operation","JackLoad"); jo.put("operation", "script");
jo.put("id", inst.getStart_point_code() + "INGET");
jo.put("script_name", "userpy/interact.py");
JSONObject script_args = new JSONObject();
script_args.put("addr", addr);
JSONObject data = new JSONObject();
JSONObject reach = new JSONObject();
reach.put("task_code", inst.getInstruction_code());
reach.put("address", inst.getStart_point_code() + "INGET");
data.put("reach", reach);
script_args.put("data", data);
script_args.put("protocol", "HTTP");
jo.put("script_args", script_args);
ja.add(jo); ja.add(jo);
JSONObject jo1 = new JSONObject(); JSONObject jo1 = new JSONObject();
jo1.put("blockId", IdUtil.simpleUUID()); jo1.put("blockId", IdUtil.simpleUUID());
jo1.put("location",inst.getNext_point_code()); jo1.put("location", inst.getStart_point_code());
jo1.put("operation","JackUnload"); jo1.put("operation", "Jackload");
ja.add(jo1); ja.add(jo1);
//取货完成等待
JSONObject jo2 = new JSONObject();
jo2.put("blockId", IdUtil.simpleUUID());
jo2.put("location", inst.getStart_point_code() + "OUTGET");
jo2.put("operation", "script");
jo2.put("id", inst.getStart_point_code() + "OUTGET");
jo2.put("script_name", "userpy/interact.py");
JSONObject script_args2 = new JSONObject();
script_args2.put("addr", addr);
JSONObject data2 = new JSONObject();
JSONObject reach2 = new JSONObject();
reach2.put("task_code", inst.getInstruction_code());
reach2.put("address", inst.getStart_point_code() + "OUTGET");
data2.put("reach", reach2);
script_args2.put("data", data2);
script_args2.put("protocol", "HTTP");
jo2.put("script_args", script_args2);
ja.add(jo2);
//放货前等待
JSONObject jo3 = new JSONObject();
jo3.put("blockId", IdUtil.simpleUUID());
jo3.put("location", inst.getNext_point_code() + "INPUT");
jo3.put("operation", "script");
jo3.put("id", inst.getNext_point_code() + "INPUT");
jo3.put("script_name", "userpy/interact.py");
JSONObject script_args3 = new JSONObject();
script_args3.put("addr", addr);
JSONObject data3 = new JSONObject();
JSONObject reach3 = new JSONObject();
reach3.put("task_code", inst.getInstruction_code());
reach3.put("address", inst.getNext_point_code() + "INPUT");
data3.put("reach", reach3);
script_args3.put("data", data3);
script_args3.put("protocol", "HTTP");
jo3.put("script_args", script_args3);
ja.add(jo3);
JSONObject jo4 = new JSONObject();
jo4.put("blockId", IdUtil.simpleUUID());
jo4.put("location", inst.getNext_point_code());
jo4.put("operation", "JackUnload");
ja.add(jo4);
//放货完成等待
JSONObject jo5 = new JSONObject();
jo5.put("blockId", IdUtil.simpleUUID());
jo5.put("location", inst.getNext_point_code() + "OUTPUT");
jo5.put("operation", "script");
jo5.put("id", inst.getNext_point_code() + "OUTPUT");
jo5.put("script_name", "userpy/interact.py");
JSONObject script_args5 = new JSONObject();
script_args5.put("addr", addr);
JSONObject data5 = new JSONObject();
JSONObject reach5 = new JSONObject();
reach5.put("task_code", inst.getInstruction_code());
reach5.put("address", inst.getNext_point_code() + "OUTPUT");
data5.put("reach", reach5);
script_args5.put("data", data5);
script_args5.put("protocol", "HTTP");
jo5.put("script_args", script_args5);
ja.add(jo5);
//根据任务起点终点获取后续的路线
List<String> routeList = RouteUtil.getRouteList(inst.getStart_device_code(), inst.getNext_device_code());
if (ObjectUtil.isNotEmpty(routeList)) {
for (int i = 0; i < routeList.size(); i++) {
String loadStyle = "";
String getOrPut = "";
if (i % 2 == 0) {
//取货
loadStyle = "JackLoad";
getOrPut = "GET";
} else {
//放货
loadStyle = "JackUnload";
getOrPut = "PUT";
}
//取/放货前等待
JSONObject joi1 = new JSONObject();
joi1.put("blockId", IdUtil.simpleUUID());
joi1.put("location", routeList.get(i) + "IN" + getOrPut);
joi1.put("operation", "script");
joi1.put("id", routeList.get(i) + "IN" + getOrPut);
joi1.put("script_name", "userpy/interact.py");
JSONObject script_argsi1 = new JSONObject();
script_argsi1.put("addr", addr);
JSONObject datai1 = new JSONObject();
JSONObject reachi1 = new JSONObject();
reachi1.put("task_code", inst.getInstruction_code());
reachi1.put("address", routeList.get(i) + "IN" + getOrPut);
data.put("reach", reachi1);
script_argsi1.put("data", datai1);
script_argsi1.put("protocol", "HTTP");
joi1.put("script_args", script_argsi1);
ja.add(joi1);
JSONObject joi2 = new JSONObject();
joi2.put("blockId", IdUtil.simpleUUID());
joi2.put("location", routeList.get(i));
joi2.put("operation", loadStyle);
ja.add(joi2);
//取/放货后等待
JSONObject joi3 = new JSONObject();
joi3.put("blockId", IdUtil.simpleUUID());
joi3.put("location", routeList.get(i) + "OUT" + getOrPut);
joi3.put("operation", "script");
joi3.put("id", routeList.get(i) + "OUT" + getOrPut);
joi3.put("script_name", "userpy/interact.py");
JSONObject script_argsi3 = new JSONObject();
script_argsi3.put("addr", addr);
JSONObject datai3 = new JSONObject();
JSONObject reachi3 = new JSONObject();
reachi3.put("task_code", inst.getInstruction_code());
reachi3.put("address", routeList.get(i) + "OUT" + getOrPut);
datai3.put("reach", reachi3);
script_argsi3.put("data", datai3);
script_argsi3.put("protocol", "HTTP");
joi3.put("script_args", script_argsi3);
ja.add(joi3);
}
}
System.out.println(ja.toString());
return ja; return ja;
} }

13
acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java

@ -21,18 +21,7 @@ public enum DriverTypeEnum {
INSPECT_CONVEYOR_MONITOR(6, "standard_conveyor_monitor", "标准版-输送机-监控点", "conveyor"), INSPECT_CONVEYOR_MONITOR(6, "standard_conveyor_monitor", "标准版-输送机-监控点", "conveyor"),
HAILIANG_SMART_PLC_TEST(7, "hailiang_smart_plc_test", "永裕共挤线-西门子SMART200PLC", "conveyor"), MAGANG_CONVEYOR_CONTROL(7, "magang_conveyor_control", "马钢-输送机", "conveyor");
EMPTY_VEHICLE_STACKING_POSITION(8, "empty_vehicle_stacking_position", "永裕叠盘位-西门子SMART200PLC", "conveyor"),
CARGO_LIFT_CONVEYOR(9, "cargo_lift_conveyor", "货梯对接线", "conveyor"),
INSPECT_CONVEYOR_CONTROL_WITH_SCANNER(10, "standard_conveyor_control_with_scanner", "货梯对接线-关联扫码", "conveyor"),
HAOKAI_AUTO_CONVEYOR(11, "haokai_auto_conveyor", "豪恺自动线对接位", "conveyor"),
PAINT_CONVEYOR(12, "paint_conveyor", "油漆线", "conveyor");
//驱动索引 //驱动索引
private int index; private int index;

69
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/RouteUtil.java

@ -0,0 +1,69 @@
package org.nl.acs.device_driver;
import cn.hutool.core.util.StrUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author: geng by
* @createDate: 2022/11/17
*/
public class RouteUtil {
public static List<String> getRouteList(String start_device_code, String next_device_code) {
Map<String, List<String>> listMap = getRouteByCode(start_device_code, next_device_code);
return listMap.get(start_device_code);
}
public static Map<String, List<String>> getRouteByCode(String start_device_code, String next_device_code) {
String first_device_code = start_device_code.substring(0, 1);
Map<String, List<String>> map = new HashMap<>();
List<String> list = new ArrayList<>();
if (!StrUtil.equals(first_device_code, "D")) {
list.add(first_device_code + "03");
list.add(first_device_code + "04");
list.add(first_device_code + "02");
list.add(first_device_code + "03");
list.add(first_device_code + "04");
list.add(first_device_code + "01");
map.put(first_device_code + "01", list);
list = new ArrayList<>();
list.add(first_device_code + "02");
list.add(first_device_code + "03");
list.add(first_device_code + "04");
list.add(first_device_code + "01");
map.put(first_device_code + "03", list);
list = new ArrayList<>();
list.add(first_device_code + "04");
list.add(first_device_code + "01");
map.put(first_device_code + "02", list);
} else {
if (StrUtil.equals(next_device_code, "D02")) {
list = new ArrayList<>();
list.add(first_device_code + "03");
list.add(first_device_code + "01");
map.put(first_device_code + "01", list);
} else if (StrUtil.equals(next_device_code, "D03")) {
list = new ArrayList<>();
list.add(first_device_code + "02");
list.add(first_device_code + "01");
map.put(first_device_code + "01", list);
}
}
return map;
}
public static String getDeviceCode(String address) {
String device_code = "";
if (address.contains("INGET") || address.contains("INPUT")) {
device_code = address.substring(0, address.length() - 5);
} else if (address.contains("OUTGET") || address.contains("OUTPUT")) {
device_code = address.substring(0, address.length() - 6);
}
return device_code;
}
}

82
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/ItemProtocol.java

@ -0,0 +1,82 @@
package org.nl.acs.device_driver.maGang;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Data
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_action = "action";
public static String item_error = "error";
public static String item_to_command = "to_command";
private MaGangConveyorDeviceDriver driver;
public ItemProtocol(MaGangConveyorDeviceDriver driver) {
this.driver = driver;
}
public int getItem_heartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getItem_mode() {
return this.getOpcIntegerValue(item_mode);
}
public int getItem_move() {
return this.getOpcIntegerValue(item_move);
}
public int getItem_error() {
return this.getOpcIntegerValue(item_error);
}
public int getItem_action() {
return this.getOpcIntegerValue(item_action);
}
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 static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB600.B2"));
list.add(new ItemDto(item_move, "光电信号", "DB600.B3"));
list.add(new ItemDto(item_action, "取放信号", "DB600.B4"));
list.add(new ItemDto(item_error, "故障", "DB600.B5"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2"));
return list;
}
}

60
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDefination.java

@ -0,0 +1,60 @@
package org.nl.acs.device_driver.maGang;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
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;
/**
* 马钢输送站点
*/
@Service
public class MaGangConveyorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "magang_conveyor_control";
}
@Override
public String getDriverName() {
return "马钢输送站点";
}
@Override
public String getDriverDescription() {
return "马钢输送站点";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new MaGangConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return MaGangConveyorDeviceDriver.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();
}
}

305
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java

@ -0,0 +1,305 @@
package org.nl.acs.device_driver.maGang;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
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.instruction.service.dto.Instruction;
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.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
/**
* 马钢输送站点
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
@Autowired
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.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 mode = 0;
int last_mode = 0;
//光电信号
int move = 0;
int last_move = 0;
//动作信号
int action = 0;
int last_action = 0;
//报警信号
int error = 0;
int last_error = 0;
Boolean isonline = true;
Boolean iserror = false;
//1-执行任务;2-取货完成;3-放货完成;
int flag;
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();
heartbeat = this.itemProtocol.getItem_heartbeat();
mode = this.itemProtocol.getItem_mode();
move = this.itemProtocol.getItem_move();
action = this.itemProtocol.getItem_action();
error = this.itemProtocol.getItem_error();
if (mode != last_mode) {
if (mode == 3){
this.setRequireSucess(false);
}
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
}
if (action != last_action) {
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
message = "";
Instruction instruction = null;
List toInstructions;
if (mode == 3 && !requireSucess){
instruction_require();
}
}
last_mode = mode;
last_move = move;
last_error = error;
last_action = action;
}
public synchronized boolean instruction_require() throws Exception {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
List<String> link_device_codes = this.getExtraDeviceCodes("link_device_code");
String next_device_code = "";
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver;
for (int i = 0; i < link_device_codes.size(); i++) {
String link_device_code = link_device_codes.get(i);
Device device = deviceAppservice.findDeviceByCode(link_device_code);
if (device.getDeviceDriver() instanceof MaGangConveyorDeviceDriver){
maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver();
if (maGangConveyorDeviceDriver.getMove() == 0){
next_device_code = link_device_code;
break;
}
}
}
if (StrUtil.isEmpty(next_device_code)){
return false;
}
TaskDto taskDto = new TaskDto();
String now = DateUtil.now();
taskDto.setTask_id(IdUtil.simpleUUID());
taskDto.setTask_code(CodeUtil.getNewCode("TASK_NO"));
taskDto.setTask_type("1");
taskDto.setRoute_plan_code("normal");
taskDto.setTask_status("0");
taskDto.setPriority("101");
taskDto.setAgv_system_type("1");
taskDto.setStart_device_code(this.getDevice().getDevice_code());
taskDto.setStart_point_code(this.getDevice().getDevice_code());
taskDto.setNext_point_code(next_device_code);
taskDto.setNext_point_code(next_device_code);
taskDto.setCreate_by(this.getDevice().getDevice_code());
taskDto.setUpdate_by(this.getDevice().getDevice_code());
taskDto.setUpdate_time(now);
taskDto.setCreate_time(now);
try {
taskserver.create(taskDto);
} catch (Exception e) {
logServer.deviceExecuteLog(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage()));
}
logServer.deviceExecuteLog(this.device_code, "", "", device_code + ":创建任务成功");
this.writing(1);
this.setRequireSucess(true);
return true;
}
}
protected void thingToNothing() {
}
//将扩展表中的字符串数据转换成集合
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
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;
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
}
public void writing(int type, int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) {
itemMap.put(to_command, command);
log.info("设备:" + device_code + ",下发PLC信号" + to_command + ",value:" + command);
}
ReadUtil.write(itemMap, server);
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
String action = "";
String move = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "单机";
} else if (this.getMode() == 2) {
mode = "联机";
} else if (this.getMode() == 3) {
mode = "运行中";
}
if (this.getAction() == 0) {
action = "禁止取放";
} else if (this.getAction() == 1) {
action = "允许取货";
} else if (this.getAction() == 2) {
action = "允许放货";
} else if (this.getAction() == 3) {
action = "允许取放";
}
if (this.getMove() == 0) {
move = "无货";
} else if (this.getMove() == 1) {
move = "有货";
} else if (this.getMove() == 2) {
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());
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

37
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AgvToAcsController.java

@ -0,0 +1,37 @@
package org.nl.acs.ext.wms.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.ext.wms.service.AgvToAcsService;
import org.nl.modules.logging.annotation.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
*
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "wms接口")
@RequestMapping("api/agv")
@Slf4j
@CrossOrigin
public class AgvToAcsController {
private final AgvToAcsService agvToAcsService;
@PostMapping("/waitpointRequest")
@Log("AGV到等待点请求继续执行")
@ApiOperation("AGV到等待点请求继续执行")
@SaIgnore
public ResponseEntity<Object> createFromWms(@RequestBody JSONObject param) {
return new ResponseEntity<>(agvToAcsService.waitpointRequest(param), HttpStatus.OK);
}
}

17
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AgvToAcsService.java

@ -0,0 +1,17 @@
package org.nl.acs.ext.wms.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
public interface AgvToAcsService {
/**
* 创建任务
*
* @param jsonObject 条件
* @return
*/
Map<String, Object> waitpointRequest(JSONObject jsonObject);
}

87
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java

@ -0,0 +1,87 @@
package org.nl.acs.ext.wms.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device_driver.RouteUtil;
import org.nl.acs.device_driver.maGang.MaGangConveyorDeviceDriver;
import org.nl.acs.ext.wms.service.AgvToAcsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.modules.common.exception.BadRequestException;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Service
@RequiredArgsConstructor
@Slf4j
public class AgvToAcsServiceImpl implements AgvToAcsService {
private final DeviceAppService deviceAppService;
private final InstructionService instructionService;
private final DeviceExecuteLogService logService;
@Override
public Map<String, Object> waitpointRequest(JSONObject param) {
//指令号
String inst_code = param.getString("task_code");
//站点
String address = param.getString("address");
//车号
String vehicle_code = param.getString("device_code");
String deviceCode = RouteUtil.getDeviceCode(address);
Instruction instructionDto = instructionService.findByCode(inst_code);
if (ObjectUtil.isEmpty(instructionDto)) {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:指令任务号不存在! 指令号:" + inst_code);
throw new BadRequestException("请求失败,指令任务号不存在!");
}
Device device = deviceAppService.findDeviceByCode(deviceCode);
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver();
Map<String, Object> map = new HashMap<>();
map.put("status", 200);
map.put("message", "操作成功");
if (address.contains("INGET")) {
if (maGangConveyorDeviceDriver.getMove() == 1) {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString());
return map;
} else {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:取货前-取货点无货!");
throw new BadRequestException("请求失败,取货前-取货点无货!");
}
} else if (address.contains("OUTGET")) {
if (maGangConveyorDeviceDriver.getMove() == 0) {
maGangConveyorDeviceDriver.writing(2);
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString());
return map;
} else {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:取货完成后-取货点有货!");
throw new BadRequestException("请求失败,取货完成后-取货点有货!");
}
} else if (address.contains("INPUT")) {
if (maGangConveyorDeviceDriver.getMove() == 0) {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString());
return map;
} else {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:放货前-放货点有货!");
throw new BadRequestException("请求失败,放货前-放货点有货!");
}
} else if (address.contains("OUTPUT")) {
if (maGangConveyorDeviceDriver.getMove() == 1) {
maGangConveyorDeviceDriver.writing(3);
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString());
return map;
} else {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:放货完成后-放货点无货!");
throw new BadRequestException("请求失败,放货完成后-放货点无货!");
}
}
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:请求失败,地址有误! 地址:" + address);
throw new BadRequestException("请求失败,地址有误!");
}
}

10
acs/nladmin-system/src/main/java/org/nl/hand/amb/rest/HFHandController.java

@ -50,6 +50,16 @@ public class HFHandController {
return new ResponseEntity<>(HandService.queryPointByArea(region), HttpStatus.OK); return new ResponseEntity<>(HandService.queryPointByArea(region), HttpStatus.OK);
} }
@PostMapping("/queryDevice")
@Log("查询设备起点和终点")
@ApiOperation("查询设备起点和终点")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryDevice() {
return new ResponseEntity<>(HandService.queryDevice(), HttpStatus.OK);
}
@PostMapping("/point/storage") @PostMapping("/point/storage")
@Log("查询设备扩展属性") @Log("查询设备扩展属性")
@ApiOperation("查询设备扩展属性") @ApiOperation("查询设备扩展属性")

7
acs/nladmin-system/src/main/java/org/nl/hand/amb/service/HFHandService.java

@ -112,4 +112,11 @@ public interface HFHandService {
Map<String, Object> queryMaterial(); Map<String, Object> queryMaterial();
Map<String, Object> createTask2(Map<String, String> whereJson); Map<String, Object> createTask2(Map<String, String> whereJson);
/**
* 查询物料
*
* @return Map<String, Object>
*/
Map<String, Object> queryDevice();
} }

67
acs/nladmin-system/src/main/java/org/nl/hand/amb/service/impl/HFHandServiceImpl.java

@ -11,8 +11,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.MagicAgvService; import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.agv.server.impl.MagicAgvServiceImpl;
import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.dto.DeviceDto; import org.nl.acs.device.service.dto.DeviceDto;
import org.nl.acs.device.service.impl.DeviceServiceImpl; import org.nl.acs.device.service.impl.DeviceServiceImpl;
@ -318,24 +317,24 @@ public class HFHandServiceImpl implements HFHandService {
// return resultJson; // return resultJson;
// } // }
//判断起点有货,终点为空 //判断起点有货,终点为空
if (ObjectUtil.isEmpty(startDevice.getMaterial_type()) || Integer.parseInt(startDevice.getMaterial_type()) == 0) { // if (ObjectUtil.isEmpty(startDevice.getMaterial_type()) || Integer.parseInt(startDevice.getMaterial_type()) == 0) {
resultJson.put("code", "0"); // resultJson.put("code", "0");
resultJson.put("desc", "起点必须有货"); // resultJson.put("desc", "起点必须有货");
resultJson.put("result", ""); // resultJson.put("result", "");
return resultJson; // return resultJson;
} // }
if (!ObjectUtil.isEmpty(nextDevice.getMaterial_type()) && !StrUtil.equals(nextDevice.getMaterial_type(), "0")) { // if (!ObjectUtil.isEmpty(nextDevice.getMaterial_type()) && !StrUtil.equals(nextDevice.getMaterial_type(), "0")) {
resultJson.put("code", "0"); // resultJson.put("code", "0");
resultJson.put("desc", "终点必须为空"); // resultJson.put("desc", "终点必须为空");
resultJson.put("result", ""); // resultJson.put("result", "");
return resultJson; // return resultJson;
} // }
if(Boolean.parseBoolean(startDevice.getIslock()) || Boolean.parseBoolean(nextDevice.getIslock())){ // if (Boolean.parseBoolean(startDevice.getIslock()) || Boolean.parseBoolean(nextDevice.getIslock())) {
resultJson.put("code", "0"); // resultJson.put("code", "0");
resultJson.put("desc", "起点或终点设备已被锁定"); // resultJson.put("desc", "起点或终点设备已被锁定");
resultJson.put("result", ""); // resultJson.put("result", "");
return resultJson; // return resultJson;
} // }
if (StrUtil.isEmpty(priority)) { if (StrUtil.isEmpty(priority)) {
priority = "1"; priority = "1";
} }
@ -353,15 +352,17 @@ public class HFHandServiceImpl implements HFHandService {
dto.setIs_delete("0"); dto.setIs_delete("0");
dto.setMaterial(material_type); dto.setMaterial(material_type);
dto.setStart_point_code(start_devicecode); dto.setStart_point_code(start_devicecode);
dto.setStart_device_code(start_devicecode);
dto.setNext_point_code(next_devicecode); dto.setNext_point_code(next_devicecode);
dto.setNext_device_code(next_devicecode);
dto.setMaterial(material_type); dto.setMaterial(material_type);
dto.setTask_type(task_type); dto.setTask_type(task_type);
dto.setPriority(priority); dto.setPriority(priority);
dto.setVehicle_code(carrier); dto.setVehicle_code(carrier);
try { try {
taskService.create(dto); taskService.create(dto);
startDevice.setIslock("true"); // startDevice.setIslock("true");
nextDevice.setIslock("true"); // nextDevice.setIslock("true");
} catch (Exception e) { } catch (Exception e) {
resultJson.put("code", "2"); resultJson.put("code", "2");
resultJson.put("desc", e.getMessage()); resultJson.put("desc", e.getMessage());
@ -542,7 +543,7 @@ public class HFHandServiceImpl implements HFHandService {
} }
String task_id = instwo.getString("task_id"); String task_id = instwo.getString("task_id");
Instruction instdto = (Instruction) instwo.toJavaObject(Instruction.class); Instruction instdto = (Instruction) instwo.toJavaObject(Instruction.class);
MagicAgvService agvService = SpringContextHolder.getBean(MagicAgvServiceImpl.class); XianGongAgvService agvService = SpringContextHolder.getBean(XianGongAgvService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
/* 1 指令撤销 /* 1 指令撤销
@ -553,11 +554,8 @@ public class HFHandServiceImpl implements HFHandService {
try { try {
//agvService.deleteAgvInst(instwo.getString("instruction_code")); //agvService.deleteAgvInst(instwo.getString("instruction_code"));
if (StrUtil.isEmpty(instdto.getAgv_jobno())) { instructionService.cancel(inst_uuid);
instructionService.cancelNOSendAgv(inst_uuid); agvService.deleteXZAgvInst(instdto.getInstruction_code());
} else {
agvService.deleteAgvInst(instdto.getInstruction_code());
}
} catch (Exception e) { } catch (Exception e) {
jo.put("code", "2"); jo.put("code", "2");
@ -568,7 +566,7 @@ public class HFHandServiceImpl implements HFHandService {
} }
if (type.equals("2")) { if (type.equals("2")) {
try { try {
agvService.sendAgvInstToMagic(instdto); agvService.sendOrderSequencesToXZ(instdto);
} catch (Exception e) { } catch (Exception e) {
jo.put("code", "2"); jo.put("code", "2");
jo.put("desc", "下发agv失败"); jo.put("desc", "下发agv失败");
@ -764,5 +762,16 @@ public class HFHandServiceImpl implements HFHandService {
return jo; return jo;
} }
@Override
public Map<String, Object> queryDevice() {
WQLObject wo = WQLObject.getWQLObject("acs_device");
JSONArray resultJSONArray = wo.query("1 = 1", "device_code").getResultJSONArray(0);
JSONObject jo = new JSONObject();
jo.put("code", "1");
jo.put("desc", "查询成功");
jo.put("result", resultJSONArray);
return jo;
}
} }

8
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java

@ -43,8 +43,9 @@ public class QueryXZAgvTaskStatus {
JSONObject one = (JSONObject) ja.get(i); JSONObject one = (JSONObject) ja.get(i);
String inst_code = one.getString("id"); String inst_code = one.getString("id");
Instruction inst = instructionService.findByInstCodeFromCache(inst_code); Instruction inst = instructionService.findByInstCodeFromCache(inst_code);
if (ObjectUtil.isEmpty(inst))
continue; if (ObjectUtil.isEmpty(inst)) continue;
//子任务状态 待以后处理 //子任务状态 待以后处理
JSONArray blocks = JSONArray.parseArray(one.getString("blocks")); JSONArray blocks = JSONArray.parseArray(one.getString("blocks"));
for (int j = 0; j < blocks.size(); j++) { for (int j = 0; j < blocks.size(); j++) {
@ -52,7 +53,6 @@ public class QueryXZAgvTaskStatus {
String blockId = blocksjo.getString("blockId"); String blockId = blocksjo.getString("blockId");
String device_code = blocksjo.getString("location"); String device_code = blocksjo.getString("location");
String state = blocksjo.getString("state"); String state = blocksjo.getString("state");
} }
String state = one.getString("state"); String state = one.getString("state");
@ -60,7 +60,6 @@ public class QueryXZAgvTaskStatus {
String carno = one.getString("vehicle"); String carno = one.getString("vehicle");
inst.setCarno(carno); inst.setCarno(carno);
} }
// 已创建=CREATED, // 已创建=CREATED,
// 待分配=TOBEDISPATCHED, // 待分配=TOBEDISPATCHED,
// 正在执行=RUNNING, // 正在执行=RUNNING,
@ -69,7 +68,6 @@ public class QueryXZAgvTaskStatus {
// 终止=STOPPED(被人为终止), // 终止=STOPPED(被人为终止),
// 无法执行=Error(参数错误), // 无法执行=Error(参数错误),
// 等待=WAITING // 等待=WAITING
//执行中 //执行中
if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) { if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
if (inst != null) { if (inst != null) {

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

@ -6,7 +6,7 @@ spring:
druid: druid:
db-type: com.alibaba.druid.pool.DruidDataSource db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:ndxy3_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:magang_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:ndxy3_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:ndxy3_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:root} username: ${DB_USER:root}
password: ${DB_PWD:P@ssw0rd} password: ${DB_PWD:P@ssw0rd}
@ -128,7 +128,7 @@ file:
avatarMaxSize: 5 avatarMaxSize: 5
logging: logging:
file: file:
path: C:\log\wms path: C:\log\acs
config: classpath:logback-spring.xml config: classpath:logback-spring.xml
# Sa-Token配置 # Sa-Token配置
@ -154,3 +154,6 @@ sa-token:
loki: loki:
url: http://localhost:3100/loki/api/v1 url: http://localhost:3100/loki/api/v1
systemName: acs systemName: acs
agvToAcs:
addr: http://127.0.0.1:8010

3
acs/nladmin-system/src/main/resources/config/application-prod.yml

@ -152,3 +152,6 @@ sa-token:
loki: loki:
url: http://localhost:3100/loki/api/v1 url: http://localhost:3100/loki/api/v1
systemName: acs systemName: acs
agvToAcs:
addr: http://127.0.0.1:8010

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

@ -2,7 +2,7 @@ spring:
freemarker: freemarker:
check-template-location: false check-template-location: false
profiles: profiles:
active: prod active: dev
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
data: data:

4
acs/nladmin-ui/src/views/acs/device/config.vue

@ -85,6 +85,7 @@ import paint_conveyor from '@/views/acs/device/driver/paint_conveyor'
import haokai_auto_conveyor from '@/views/acs/device/driver/haokai_auto_conveyor' import haokai_auto_conveyor from '@/views/acs/device/driver/haokai_auto_conveyor'
import cargo_lift_conveyor from '@/views/acs/device/driver/cargo_lift_conveyor' import cargo_lift_conveyor from '@/views/acs/device/driver/cargo_lift_conveyor'
import empty_vehicle_stacking_position from '@/views/acs/device/driver/empty_vehicle_stacking_position' import empty_vehicle_stacking_position from '@/views/acs/device/driver/empty_vehicle_stacking_position'
import magang_conveyor_control from '@/views/acs/device/driver/magang_conveyor_control'
export default { export default {
name: 'DeviceConfig', name: 'DeviceConfig',
@ -100,7 +101,8 @@ export default {
paint_conveyor, paint_conveyor,
haokai_auto_conveyor, haokai_auto_conveyor,
cargo_lift_conveyor, cargo_lift_conveyor,
empty_vehicle_stacking_position empty_vehicle_stacking_position,
magang_conveyor_control
}, },
dicts: ['device_type'], dicts: ['device_type'],
mixins: [crud], mixins: [crud],

502
acs/nladmin-ui/src/views/acs/device/driver/magang_conveyor_control.vue

@ -0,0 +1,502 @@
<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
@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
@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="8">
<el-form-item label="检验有货">
<el-switch v-model="form.inspect_in_stocck" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽视取货校验" label-width="150px">
<el-switch v-model="form.ignore_pickup_check" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽视放货校验" label-width="150px">
<el-switch v-model="form.ignore_release_check" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="呼叫">
<el-switch v-model="form.apply_task" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="响应" label-width="150px">
<el-switch v-model="form.manual_create_task" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="关联设备" prop="device_code">
<el-select
v-model="form.link_device_code"
filterable
multiple
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="8">
<el-form-item label="关联三色灯" prop="device_code" label-width="100px">
<el-select
v-model="form.link_three_lamp"
filterable
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="8">
<el-form-item label="是否输入物料" label-width="150px">
<el-switch v-model="form.input_material" />
</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">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="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: []
},
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.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
const endNumber = afterStr.substring(1)
//
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data1) {
if (this.data1[val].code.indexOf('move') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
}
if (this.data1[val].code.indexOf('action') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data1[val].code.indexOf('ioaction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 3)
}
if (this.data1[val].code.indexOf('height') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
}
if (this.data1[val].code.indexOf('error') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 5)
}
if (this.data1[val].code.indexOf('direction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 6)
}
if (this.data1[val].code.indexOf('operation_type') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 7)
}
if (this.data1[val].code.indexOf('task') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 21)
}
}
}
},
finishWriteEdit(data) {
// code,mode
if (data.code.indexOf('to_command') !== -1) {
const dbValue = data.db
// .
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .
const afterStr = dbValue.match(/\.(\S*)/)[1]
//
const endNumber = afterStr.substring(1)
//
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data2) {
if (this.data2[val].code.indexOf('to_target') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data2[val].code.indexOf('to_task') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 6)
}
}
}
},
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)
})
},
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.data1, this.data2).then(res => {
this.notify('保存成功', 'success')
this.configLoading = false
}).catch(err => {
this.configLoading = false
console.log(err.response.data.message)
})
}
})
},
sliceItem() { // DBItem
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>

2
acs/nladmin-ui/src/views/login.vue

@ -45,7 +45,7 @@ import { encrypt } from '@/utils/rsaEncrypt'
import Config from '@/settings' import Config from '@/settings'
import { getCodeImg } from '@/api/login' import { getCodeImg } from '@/api/login'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import Background from '@/assets/images/background.jpg' import Background from '@/assets/images/background2.jpg'
export default { export default {
name: 'Login', name: 'Login',
data() { data() {

Loading…
Cancel
Save