更新
This commit is contained in:
@@ -13,6 +13,7 @@ import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.AgvUtil;
|
||||
import org.nl.acs.agv.server.XianGongAgvService;
|
||||
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.instruction.service.dto.Instruction;
|
||||
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.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -38,6 +37,9 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
private final AcsToWmsService acsToWmsService;
|
||||
Map<String, AgvDto> AGVDeviceStatus = new HashMap();
|
||||
|
||||
@Value("${agvToAcs.addr}")
|
||||
private String addr;
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public String waitPointRequest(String param) {
|
||||
@@ -236,17 +238,157 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
@Override
|
||||
public JSONArray createBlocksData(Instruction inst) {
|
||||
JSONArray ja = new JSONArray();
|
||||
//取货前等待
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("blockId", IdUtil.simpleUUID());
|
||||
jo.put("location",inst.getStart_point_code());
|
||||
jo.put("operation","JackLoad");
|
||||
jo.put("location", inst.getStart_point_code() + "INGET");
|
||||
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);
|
||||
|
||||
JSONObject jo1 = new JSONObject();
|
||||
jo1.put("blockId",IdUtil.simpleUUID());
|
||||
jo1.put("location",inst.getNext_point_code());
|
||||
jo1.put("operation","JackUnload");
|
||||
jo1.put("blockId", IdUtil.simpleUUID());
|
||||
jo1.put("location", inst.getStart_point_code());
|
||||
jo1.put("operation", "Jackload");
|
||||
ja.add(jo1);
|
||||
return ja;
|
||||
|
||||
//取货完成等待
|
||||
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;
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
|
||||
@@ -21,18 +21,7 @@ public enum DriverTypeEnum {
|
||||
|
||||
INSPECT_CONVEYOR_MONITOR(6, "standard_conveyor_monitor", "标准版-输送机-监控点", "conveyor"),
|
||||
|
||||
HAILIANG_SMART_PLC_TEST(7, "hailiang_smart_plc_test", "永裕共挤线-西门子SMART200PLC", "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");
|
||||
|
||||
MAGANG_CONVEYOR_CONTROL(7, "magang_conveyor_control", "马钢-输送机", "conveyor");
|
||||
|
||||
//驱动索引
|
||||
private int index;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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("请求失败,地址有误!");
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,16 @@ public class HFHandController {
|
||||
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")
|
||||
@Log("查询设备扩展属性")
|
||||
@ApiOperation("查询设备扩展属性")
|
||||
|
||||
@@ -112,4 +112,11 @@ public interface HFHandService {
|
||||
Map<String, Object> queryMaterial();
|
||||
|
||||
Map<String, Object> createTask2(Map<String, String> whereJson);
|
||||
|
||||
/**
|
||||
* 查询物料
|
||||
*
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryDevice();
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.MagicAgvService;
|
||||
import org.nl.acs.agv.server.impl.MagicAgvServiceImpl;
|
||||
import org.nl.acs.agv.server.XianGongAgvService;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.dto.DeviceDto;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
@@ -318,24 +317,24 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
// return resultJson;
|
||||
// }
|
||||
//判断起点有货,终点为空
|
||||
if (ObjectUtil.isEmpty(startDevice.getMaterial_type()) || Integer.parseInt(startDevice.getMaterial_type()) == 0) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("desc", "起点必须有货");
|
||||
resultJson.put("result", "");
|
||||
return resultJson;
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(nextDevice.getMaterial_type()) && !StrUtil.equals(nextDevice.getMaterial_type(), "0")) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("desc", "终点必须为空");
|
||||
resultJson.put("result", "");
|
||||
return resultJson;
|
||||
}
|
||||
if(Boolean.parseBoolean(startDevice.getIslock()) || Boolean.parseBoolean(nextDevice.getIslock())){
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("desc", "起点或终点设备已被锁定");
|
||||
resultJson.put("result", "");
|
||||
return resultJson;
|
||||
}
|
||||
// if (ObjectUtil.isEmpty(startDevice.getMaterial_type()) || Integer.parseInt(startDevice.getMaterial_type()) == 0) {
|
||||
// resultJson.put("code", "0");
|
||||
// resultJson.put("desc", "起点必须有货");
|
||||
// resultJson.put("result", "");
|
||||
// return resultJson;
|
||||
// }
|
||||
// if (!ObjectUtil.isEmpty(nextDevice.getMaterial_type()) && !StrUtil.equals(nextDevice.getMaterial_type(), "0")) {
|
||||
// resultJson.put("code", "0");
|
||||
// resultJson.put("desc", "终点必须为空");
|
||||
// resultJson.put("result", "");
|
||||
// return resultJson;
|
||||
// }
|
||||
// if (Boolean.parseBoolean(startDevice.getIslock()) || Boolean.parseBoolean(nextDevice.getIslock())) {
|
||||
// resultJson.put("code", "0");
|
||||
// resultJson.put("desc", "起点或终点设备已被锁定");
|
||||
// resultJson.put("result", "");
|
||||
// return resultJson;
|
||||
// }
|
||||
if (StrUtil.isEmpty(priority)) {
|
||||
priority = "1";
|
||||
}
|
||||
@@ -353,15 +352,17 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
dto.setIs_delete("0");
|
||||
dto.setMaterial(material_type);
|
||||
dto.setStart_point_code(start_devicecode);
|
||||
dto.setStart_device_code(start_devicecode);
|
||||
dto.setNext_point_code(next_devicecode);
|
||||
dto.setNext_device_code(next_devicecode);
|
||||
dto.setMaterial(material_type);
|
||||
dto.setTask_type(task_type);
|
||||
dto.setPriority(priority);
|
||||
dto.setVehicle_code(carrier);
|
||||
try {
|
||||
taskService.create(dto);
|
||||
startDevice.setIslock("true");
|
||||
nextDevice.setIslock("true");
|
||||
// startDevice.setIslock("true");
|
||||
// nextDevice.setIslock("true");
|
||||
} catch (Exception e) {
|
||||
resultJson.put("code", "2");
|
||||
resultJson.put("desc", e.getMessage());
|
||||
@@ -542,7 +543,7 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
}
|
||||
String task_id = instwo.getString("task_id");
|
||||
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);
|
||||
|
||||
/* 1 指令撤销
|
||||
@@ -553,11 +554,8 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
|
||||
try {
|
||||
//agvService.deleteAgvInst(instwo.getString("instruction_code"));
|
||||
if (StrUtil.isEmpty(instdto.getAgv_jobno())) {
|
||||
instructionService.cancelNOSendAgv(inst_uuid);
|
||||
} else {
|
||||
agvService.deleteAgvInst(instdto.getInstruction_code());
|
||||
}
|
||||
instructionService.cancel(inst_uuid);
|
||||
agvService.deleteXZAgvInst(instdto.getInstruction_code());
|
||||
|
||||
} catch (Exception e) {
|
||||
jo.put("code", "2");
|
||||
@@ -568,7 +566,7 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
}
|
||||
if (type.equals("2")) {
|
||||
try {
|
||||
agvService.sendAgvInstToMagic(instdto);
|
||||
agvService.sendOrderSequencesToXZ(instdto);
|
||||
} catch (Exception e) {
|
||||
jo.put("code", "2");
|
||||
jo.put("desc", "下发agv失败");
|
||||
@@ -677,7 +675,7 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
TaskDto acsTask = taskjo.toJavaObject(TaskDto.class);
|
||||
InstructionService instructionservice = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
InstructionDto instdto = instructionservice.findByTaskid(acsTask.getTask_id(), "instruction_status <2 ");
|
||||
if (instdto != null){
|
||||
if (instdto != null) {
|
||||
jo.put("code", "0");
|
||||
jo.put("desc", "有指令未完成!");
|
||||
jo.put("result", new JSONObject());
|
||||
@@ -764,5 +762,16 @@ public class HFHandServiceImpl implements HFHandService {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -55,10 +55,10 @@ public class AutoCreateInst {
|
||||
|
||||
String next_point_code = acsTask.getNext_point_code();
|
||||
|
||||
if(StrUtil.equals(is_send,"0")){
|
||||
if (StrUtil.equals(is_send, "0")) {
|
||||
continue;
|
||||
}
|
||||
if(StrUtil.equals(acsTask.getTask_type(),"1") || StrUtil.equals(acsTask.getTask_type(),"2")){
|
||||
if (StrUtil.equals(acsTask.getTask_type(), "1") || StrUtil.equals(acsTask.getTask_type(), "2")) {
|
||||
//校验路由关系
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||
|
||||
@@ -43,16 +43,16 @@ public class QueryXZAgvTaskStatus {
|
||||
JSONObject one = (JSONObject) ja.get(i);
|
||||
String inst_code = one.getString("id");
|
||||
Instruction inst = instructionService.findByInstCodeFromCache(inst_code);
|
||||
if (ObjectUtil.isEmpty(inst))
|
||||
continue;
|
||||
|
||||
if (ObjectUtil.isEmpty(inst)) continue;
|
||||
|
||||
//子任务状态 待以后处理
|
||||
JSONArray blocks = JSONArray.parseArray(one.getString("blocks"));
|
||||
for(int j=0;j<blocks.size();j++){
|
||||
for (int j = 0; j < blocks.size(); j++) {
|
||||
JSONObject blocksjo = (JSONObject) blocks.get(j);
|
||||
String blockId = blocksjo.getString("blockId");
|
||||
String device_code = blocksjo.getString("location");
|
||||
String state = blocksjo.getString("state");
|
||||
|
||||
}
|
||||
|
||||
String state = one.getString("state");
|
||||
@@ -60,7 +60,6 @@ public class QueryXZAgvTaskStatus {
|
||||
String carno = one.getString("vehicle");
|
||||
inst.setCarno(carno);
|
||||
}
|
||||
|
||||
// 已创建=CREATED,
|
||||
// 待分配=TOBEDISPATCHED,
|
||||
// 正在执行=RUNNING,
|
||||
@@ -69,9 +68,8 @@ public class QueryXZAgvTaskStatus {
|
||||
// 终止=STOPPED(被人为终止),
|
||||
// 无法执行=Error(参数错误),
|
||||
// 等待=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) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
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
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:P@ssw0rd}
|
||||
@@ -128,7 +128,7 @@ file:
|
||||
avatarMaxSize: 5
|
||||
logging:
|
||||
file:
|
||||
path: C:\log\wms
|
||||
path: C:\log\acs
|
||||
config: classpath:logback-spring.xml
|
||||
|
||||
# Sa-Token配置
|
||||
@@ -154,3 +154,6 @@ sa-token:
|
||||
loki:
|
||||
url: http://localhost:3100/loki/api/v1
|
||||
systemName: acs
|
||||
|
||||
agvToAcs:
|
||||
addr: http://127.0.0.1:8010
|
||||
|
||||
@@ -152,3 +152,6 @@ sa-token:
|
||||
loki:
|
||||
url: http://localhost:3100/loki/api/v1
|
||||
systemName: acs
|
||||
|
||||
agvToAcs:
|
||||
addr: http://127.0.0.1:8010
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
||||
Reference in New Issue
Block a user