更新
This commit is contained in:
@@ -461,7 +461,9 @@ public class MagicAgvServiceImpl implements MagicAgvService {
|
|||||||
//请求放货
|
//请求放货
|
||||||
} else if ("Unload".equals(action)) {
|
} else if ("Unload".equals(action)) {
|
||||||
inst.setExecute_status("3");
|
inst.setExecute_status("3");
|
||||||
is_feedback = true;
|
if (!instructionService.hasInstInOneRow(inst)) {
|
||||||
|
is_feedback = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,7 +608,6 @@ public class MagicAgvServiceImpl implements MagicAgvService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
|
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
|
||||||
flag = true;
|
flag = true;
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package org.nl.acs.device_driver.driver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ldjun
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2023年02月01日 11:21
|
||||||
|
* @desc desc
|
||||||
|
*/
|
||||||
|
public class ItemValue {
|
||||||
|
private String item_code;
|
||||||
|
private Object item_value;
|
||||||
|
|
||||||
|
public ItemValue() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemValue(String item_code, Object item_value) {
|
||||||
|
this.item_code = item_code;
|
||||||
|
this.item_value = item_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItem_code() {
|
||||||
|
return this.item_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem_code(String item_code) {
|
||||||
|
this.item_code = item_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getItem_value() {
|
||||||
|
return this.item_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem_value(Object item_value) {
|
||||||
|
this.item_value = item_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -244,4 +244,6 @@ public interface InstructionService {
|
|||||||
|
|
||||||
boolean removeByCodeFromCache(String code);
|
boolean removeByCodeFromCache(String code);
|
||||||
|
|
||||||
|
boolean hasInstInOneRow(Instruction inst);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ldjun
|
* @author ldjun
|
||||||
@@ -217,7 +218,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
@Override
|
@Override
|
||||||
public Instruction findByTaskcodeToWms(String code) {
|
public Instruction findByTaskcodeToWms(String code) {
|
||||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||||
JSONObject json = wo.query("task_code ='" + code + "'","create_time desc").uniqueResult(0);
|
JSONObject json = wo.query("task_code ='" + code + "'", "create_time desc").uniqueResult(0);
|
||||||
if (ObjectUtil.isNotEmpty(json))
|
if (ObjectUtil.isNotEmpty(json))
|
||||||
return json.toJavaObject(Instruction.class);
|
return json.toJavaObject(Instruction.class);
|
||||||
return null;
|
return null;
|
||||||
@@ -1078,4 +1079,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
|
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
|
||||||
return pattern.matcher(str).matches();
|
return pattern.matcher(str).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断库位同一排里是否有库位在他之前的指令
|
||||||
|
*
|
||||||
|
* @param inst 指令实体对象
|
||||||
|
* @return 有 true 没有 false
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean hasInstInOneRow(Instruction inst) {
|
||||||
|
return instructions
|
||||||
|
.stream()
|
||||||
|
.anyMatch(i -> !i.getInstruction_id().equals(inst.getInstruction_id())
|
||||||
|
&& i.getTo_x().equals(inst.getTo_x())
|
||||||
|
&& Integer.parseInt(i.getTo_y()) < Integer.parseInt(inst.getTo_y()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,19 +4,28 @@ import cn.hutool.core.util.NumberUtil;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jinterop.dcom.common.JIException;
|
import org.jinterop.dcom.common.JIException;
|
||||||
import org.jinterop.dcom.core.*;
|
import org.jinterop.dcom.core.*;
|
||||||
|
import org.nl.acs.device_driver.driver.ItemValue;
|
||||||
import org.nl.exception.BadRequestException;
|
import org.nl.exception.BadRequestException;
|
||||||
import org.nl.exception.WDKException;
|
import org.nl.exception.WDKException;
|
||||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||||
import org.openscada.opc.lib.da.*;
|
import org.openscada.opc.lib.da.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class OpcUtl {
|
public class OpcUtl {
|
||||||
private static int timeout = 180000;
|
private static int timeout = 1*60*1000;
|
||||||
private static String key = "rpc.socketTimeout";
|
private static String key = "rpc.socketTimeout";
|
||||||
|
public static int successNum=0;
|
||||||
|
public static int errNum=0;
|
||||||
|
|
||||||
|
static {
|
||||||
|
checkTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkTimeout() {
|
public static void checkTimeout() {
|
||||||
if (Integer.getInteger(key, 0).intValue() != timeout) {
|
if (Integer.getInteger(key, 0).intValue() != timeout) {
|
||||||
@@ -26,9 +35,20 @@ public class OpcUtl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void writeValue(Group group, WriteRequest... requests) {
|
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
|
||||||
try {
|
try {
|
||||||
Map e = group.write(requests);
|
Map<Item, Integer> e=null;
|
||||||
|
try{
|
||||||
|
e=group.write(requests);
|
||||||
|
group.write(requests);
|
||||||
|
}catch (Exception e1){
|
||||||
|
try{
|
||||||
|
e= group.write(requests);
|
||||||
|
}catch (Exception e2){
|
||||||
|
e= group.write(requests);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean is_success = true;
|
boolean is_success = true;
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
Iterator arg4 = e.keySet().iterator();
|
Iterator arg4 = e.keySet().iterator();
|
||||||
@@ -50,9 +70,60 @@ public class OpcUtl {
|
|||||||
|
|
||||||
if (!is_success) {
|
if (!is_success) {
|
||||||
// throw new BusinessException(message.toString());
|
// throw new BusinessException(message.toString());
|
||||||
|
System.out.println("下发信号失败:"+message.toString());
|
||||||
|
System.out.println("下发信号失败原因:"+message.toString());
|
||||||
|
log.info("下发信号失败:"+message.toString());
|
||||||
|
throw new WDKException(message.toString());
|
||||||
}
|
}
|
||||||
} catch (JIException arg7) {
|
} catch (JIException arg7) {
|
||||||
// throw new BusinessException(arg7);
|
log.info("下发信号失败:"+arg7.getMessage());
|
||||||
|
System.out.println("下发信号失败原因:"+arg7.getMessage());
|
||||||
|
throw new WDKException(arg7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeValue(Group group, ItemValue... values) throws WDKException {
|
||||||
|
try {
|
||||||
|
if (values != null && values.length > 0) {
|
||||||
|
List<WriteRequest> ws = new ArrayList();
|
||||||
|
ItemValue[] var3 = values;
|
||||||
|
int var4 = values.length;
|
||||||
|
|
||||||
|
for(int var5 = 0; var5 < var4; ++var5) {
|
||||||
|
ItemValue value = var3[var5];
|
||||||
|
Item item = group.addItem(value.getItem_code());
|
||||||
|
ws.add(new WriteRequest(item, getVariant(value.getItem_value())));
|
||||||
|
}
|
||||||
|
|
||||||
|
writeValue(group, (WriteRequest[])ws.toArray(new WriteRequest[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (AddFailedException | JIException var8) {
|
||||||
|
throw new WDKException(var8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JIVariant getVariant(Object object) {
|
||||||
|
if (object instanceof Integer) {
|
||||||
|
return getIntegerVariant((Integer)object);
|
||||||
|
} else if (object instanceof String) {
|
||||||
|
return getStringVariant((String)object);
|
||||||
|
} else if (object instanceof byte[]) {
|
||||||
|
return getByteArrayVariant((byte[])((byte[])object));
|
||||||
|
} else if (object instanceof Byte[]) {
|
||||||
|
return getByteArrayVariant((Byte[])((Byte[])object));
|
||||||
|
} else if (object instanceof Boolean) {
|
||||||
|
return new JIVariant((Boolean)object);
|
||||||
|
} else if (object instanceof int[]) {
|
||||||
|
return getByteArrayVariantxx((int[])((int[])object));
|
||||||
|
} else if (object instanceof Integer[]) {
|
||||||
|
JIArray array = new JIArray((Integer)object, false);
|
||||||
|
JIVariant value = new JIVariant(array);
|
||||||
|
return value;
|
||||||
|
} else if (object instanceof JIVariant) {
|
||||||
|
return (JIVariant)object;
|
||||||
|
} else {
|
||||||
|
throw new WDKException("未实现目前支持是int,string,byte[]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +131,7 @@ public class OpcUtl {
|
|||||||
if (NumberUtil.compare(itemState.getQuality(), Short.valueOf(QualityTypeValue.OPC_QUALITY_GOOD)) != 0) {
|
if (NumberUtil.compare(itemState.getQuality(), Short.valueOf(QualityTypeValue.OPC_QUALITY_GOOD)) != 0) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
log.debug("value is not good {} : {}", item.getId(), itemState.getQuality());
|
log.debug("value is not good {} : {}", item.getId(), itemState.getQuality());
|
||||||
|
// throw new WDKException("值不健康进行重连!");
|
||||||
} else {
|
} else {
|
||||||
log.debug("value is not good {}", itemState.getQuality());
|
log.debug("value is not good {}", itemState.getQuality());
|
||||||
}
|
}
|
||||||
@@ -150,12 +222,28 @@ public class OpcUtl {
|
|||||||
server = new Server(getConnection(host, clsid, user, password, domain),
|
server = new Server(getConnection(host, clsid, user, password, domain),
|
||||||
Executors.newSingleThreadScheduledExecutor());
|
Executors.newSingleThreadScheduledExecutor());
|
||||||
server.connect();
|
server.connect();
|
||||||
|
successNum++;
|
||||||
return server;
|
return server;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new WDKException(e);
|
errNum++;
|
||||||
|
// e.printStackTrace();
|
||||||
|
System.out.println("server error:"+e.getMessage());
|
||||||
|
throw new WDKException(e.getMessage());
|
||||||
|
}finally{
|
||||||
|
System.out.println("successNum:"+successNum);
|
||||||
|
System.out.println("errNum:"+errNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Server getAutoServer(String host, String clsid, String user, String password, String domain) throws WDKException {
|
||||||
|
checkTimeout();
|
||||||
|
Server server = null;
|
||||||
|
server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor());
|
||||||
|
AutoReconnectController autoReconnectController = new AutoReconnectController(server);
|
||||||
|
autoReconnectController.connect();
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
public static ConnectionInformation getConnection(String host, String clsid, String user, String password,
|
public static ConnectionInformation getConnection(String host, String clsid, String user, String password,
|
||||||
String domain) {
|
String domain) {
|
||||||
ConnectionInformation connection = new ConnectionInformation();
|
ConnectionInformation connection = new ConnectionInformation();
|
||||||
@@ -167,6 +255,44 @@ public class OpcUtl {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JIVariant getByteArrayVariantxx(int[] bytes) {
|
||||||
|
Integer[] byte_Data = new Integer[bytes.length];
|
||||||
|
|
||||||
|
for(int i = 0; i < bytes.length; ++i) {
|
||||||
|
byte_Data[i] = bytes[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
JIArray array = new JIArray(byte_Data, false);
|
||||||
|
JIVariant value = new JIVariant(array);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JIVariant getIntegerVariant(Integer integer) {
|
||||||
|
return new JIVariant(integer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JIVariant getStringVariant(String string) {
|
||||||
|
return new JIVariant(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JIVariant getByteArrayVariant(byte[] bytes) {
|
||||||
|
Byte[] byte_Data = new Byte[bytes.length];
|
||||||
|
|
||||||
|
for(int i = 0; i < bytes.length; ++i) {
|
||||||
|
byte_Data[i] = bytes[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
JIArray array = new JIArray(byte_Data, false);
|
||||||
|
JIVariant value = new JIVariant(array);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JIVariant getByteArrayVariant(Byte[] bytes) {
|
||||||
|
JIArray array = new JIArray(bytes, false);
|
||||||
|
JIVariant value = new JIVariant(array);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public static String read(String item) throws Exception {
|
public static String read(String item) throws Exception {
|
||||||
System.out.println(item);
|
System.out.println(item);
|
||||||
Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", "");
|
Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", "");
|
||||||
@@ -193,5 +319,7 @@ public class OpcUtl {
|
|||||||
System.out.println(itemState.getQuality());
|
System.out.println(itemState.getQuality());
|
||||||
System.out.println(getValue(byteItem, itemState));
|
System.out.println(getValue(byteItem, itemState));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.agv.server.AgvService;
|
import org.nl.acs.agv.server.AgvService;
|
||||||
|
import org.nl.acs.agv.server.MagicAgvService;
|
||||||
import org.nl.acs.agv.server.NDCAgvService;
|
import org.nl.acs.agv.server.NDCAgvService;
|
||||||
import org.nl.acs.config.AcsConfig;
|
import org.nl.acs.config.AcsConfig;
|
||||||
import org.nl.acs.config.server.AcsConfigService;
|
import org.nl.acs.config.server.AcsConfigService;
|
||||||
@@ -82,7 +83,7 @@ public class PadServiceImpl implements PadService {
|
|||||||
throw new BadRequestException("未找到该指令!");
|
throw new BadRequestException("未找到该指令!");
|
||||||
}
|
}
|
||||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||||
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
|
MagicAgvService agvService = SpringContextHolder.getBean(MagicAgvService.class);
|
||||||
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class);
|
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class);
|
||||||
|
|
||||||
String task_id = instwo.getString("task_id");
|
String task_id = instwo.getString("task_id");
|
||||||
@@ -91,9 +92,8 @@ public class PadServiceImpl implements PadService {
|
|||||||
3 强制完成*/
|
3 强制完成*/
|
||||||
if (type.equals("1")) {
|
if (type.equals("1")) {
|
||||||
//调用agv删除任务的接口
|
//调用agv删除任务的接口
|
||||||
agvService = SpringContextHolder.getBean("agvServiceImpl");
|
|
||||||
try {
|
try {
|
||||||
agvService.deleteAgvInstToNDC(instwo.toJavaObject(Instruction.class));
|
agvService.deleteAgvInst(instwo.getString("instruction_code"));
|
||||||
instructionService.cancel(inst_uuid);
|
instructionService.cancel(inst_uuid);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -105,14 +105,13 @@ public class PadServiceImpl implements PadService {
|
|||||||
}
|
}
|
||||||
if (type.equals("2")) {
|
if (type.equals("2")) {
|
||||||
Instruction instdto = (Instruction) JSONObject.toJavaObject(instwo, Instruction.class);
|
Instruction instdto = (Instruction) JSONObject.toJavaObject(instwo, Instruction.class);
|
||||||
AgvService agvserver = SpringContextHolder.getBean("agvServiceImpl");
|
|
||||||
try {
|
try {
|
||||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
|
||||||
|
|
||||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")) {
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")) {
|
||||||
agvService.sendAgvInstToNDC(instdto);
|
agvService.sendAgvInstToMagic(instdto);
|
||||||
} else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "2")) {
|
} else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "2")) {
|
||||||
agvService.sendAgvInstToNDC(instdto);
|
agvService.sendAgvInstToMagic(instdto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -145,7 +144,7 @@ public class PadServiceImpl implements PadService {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> Taskoperation(Map<String, String> jsonObject) {
|
public Map<String, Object> Taskoperation(Map<String, String> jsonObject) {
|
||||||
JSONObject jo = new JSONObject();
|
JSONObject jo = new JSONObject();
|
||||||
String task_uuid = jsonObject.get("inst_uuid");
|
String task_uuid = jsonObject.get("task_uuid");
|
||||||
String type = jsonObject.get("type");
|
String type = jsonObject.get("type");
|
||||||
JSONObject taskjo = WQLObject.getWQLObject("acs_task").query("task_id='" + task_uuid + "'").uniqueResult(0);
|
JSONObject taskjo = WQLObject.getWQLObject("acs_task").query("task_id='" + task_uuid + "'").uniqueResult(0);
|
||||||
if (StrUtil.isEmpty(task_uuid)) {
|
if (StrUtil.isEmpty(task_uuid)) {
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.nl.acs.agv.server.MagicAgvService;
|
import org.nl.acs.agv.server.MagicAgvService;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.service.dto.Instruction;
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,91 +20,104 @@ import java.util.List;
|
|||||||
* 查询AGV任务状态
|
* 查询AGV任务状态
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component("queryMagicAgvTaskStatus")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class QueryMagicAgvTaskStatus {
|
public class QueryMagicAgvTaskStatus {
|
||||||
private final InstructionService instructionService;
|
private final InstructionService instructionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
MagicAgvService magicAgvService;
|
MagicAgvService magicAgvService;
|
||||||
|
|
||||||
|
private String log_file_type = "log_file_type";
|
||||||
|
private String log_type = "agv接口日志";
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
|
|
||||||
List<Instruction> instList = instructionService.findAllInstFromCache();
|
List<Instruction> instList = instructionService.findAllInstFromCache();
|
||||||
if (instList.size() > 0) {
|
MDC.put(log_file_type, log_type);
|
||||||
for (int i = 0; i < instList.size(); i++) {
|
try {
|
||||||
Instruction inst = instList.get(i);
|
if (instList.size() > 0) {
|
||||||
String instcode = inst.getInstruction_code();
|
for (int i = 0; i < instList.size(); i++) {
|
||||||
HttpResponse response = magicAgvService.queryAgvInstStatus(instcode);
|
Instruction inst = instList.get(i);
|
||||||
JSONObject jo = JSONObject.parseObject(response.body());
|
String instcode = inst.getInstruction_code();
|
||||||
if (MapUtil.isEmpty(jo)) continue;
|
HttpResponse response = magicAgvService.queryAgvInstStatus(instcode);
|
||||||
//反馈结果状态
|
if (response.getStatus() != 200) {
|
||||||
log.info("instcode:" + instcode + "," + jo.toString());
|
continue;
|
||||||
//指令执行状态
|
}
|
||||||
String state = jo.getString("state");
|
JSONObject jo = JSONObject.parseObject(response.body());
|
||||||
String processingVehicle = "";
|
if (MapUtil.isEmpty(jo)) continue;
|
||||||
//正在执行指令agv车号
|
//反馈结果状态
|
||||||
if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) {
|
log.info("instcode:" + instcode + "," + jo.toString());
|
||||||
processingVehicle = jo.getString("processingVehicle");
|
//指令执行状态
|
||||||
inst.setCarno(processingVehicle);
|
String state = jo.getString("state");
|
||||||
}
|
String processingVehicle = "";
|
||||||
// RAW:初始状态
|
//正在执行指令agv车号
|
||||||
// ACTIVE:业务订单已激活
|
if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) {
|
||||||
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
|
processingVehicle = jo.getString("processingVehicle");
|
||||||
// BEING_PROCESSED:业务订单正在被执行
|
inst.setCarno(processingVehicle);
|
||||||
// WITHDRAWN:业务订单已被撤销
|
}
|
||||||
// FINISHED:业务订单已完成
|
// RAW:初始状态
|
||||||
// FAILED:业务订单已失败
|
// ACTIVE:业务订单已激活
|
||||||
// UNROUTABLE:无法规划该业务订单的执行路线
|
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
|
||||||
|
// BEING_PROCESSED:业务订单正在被执行
|
||||||
|
// WITHDRAWN:业务订单已被撤销
|
||||||
|
// FINISHED:业务订单已完成
|
||||||
|
// FAILED:业务订单已失败
|
||||||
|
// UNROUTABLE:无法规划该业务订单的执行路线
|
||||||
|
|
||||||
//执行中
|
//执行中
|
||||||
if ("BEING_PROCESSED".equals(state)) {
|
if ("BEING_PROCESSED".equals(state)) {
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("1");
|
inst.setInstruction_status("1");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
}
|
}
|
||||||
} else if ("FINISHED".equals(state)) {
|
} else if ("FINISHED".equals(state)) {
|
||||||
if (inst != null) {
|
log.info("agv指令状态:{}",state);
|
||||||
inst.setInstruction_status("2");
|
if (inst != null) {
|
||||||
instructionService.finish(inst);
|
inst.setInstruction_status("2");
|
||||||
}
|
instructionService.finish(inst);
|
||||||
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
|
}
|
||||||
if (inst != null) {
|
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
|
||||||
inst.setInstruction_status("3");
|
if (inst != null) {
|
||||||
instructionService.update(inst);
|
inst.setInstruction_status("3");
|
||||||
instructionService.removeByCodeFromCache(instcode);
|
instructionService.update(inst);
|
||||||
}
|
instructionService.removeByCodeFromCache(instcode);
|
||||||
} else {
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
JSONArray ja = jo.getJSONArray("properties");
|
JSONArray ja = jo.getJSONArray("properties");
|
||||||
for (int j = 0; j < ja.size(); j++) {
|
for (int j = 0; j < ja.size(); j++) {
|
||||||
JSONObject item = ja.getJSONObject(j);
|
JSONObject item = ja.getJSONObject(j);
|
||||||
if ("True".equals(item.get("value"))) {
|
if ("True".equals(item.get("value"))) {
|
||||||
String param = item.get("key").toString();
|
String param = item.get("key").toString();
|
||||||
String[] strs = param.split("-");
|
String[] strs = param.split("-");
|
||||||
//onEntry请求进入 onStation请求离开
|
//onEntry请求进入 onStation请求离开
|
||||||
//onStation-库位名-动作名"
|
//onStation-库位名-动作名"
|
||||||
String type = null;
|
String type = null;
|
||||||
String device = null;
|
String device = null;
|
||||||
String action = null;
|
String action = null;
|
||||||
// =5表示为货位
|
// =5表示为货位
|
||||||
if (strs.length == 5) {
|
if (strs.length == 5) {
|
||||||
type = strs[0];
|
type = strs[0];
|
||||||
device = strs[1] + "-" + strs[2] + "-" + strs[3];
|
device = strs[1] + "-" + strs[2] + "-" + strs[3];
|
||||||
action = strs[4];
|
action = strs[4];
|
||||||
} else {
|
} else {
|
||||||
type = strs[0];
|
type = strs[0];
|
||||||
device = strs[1];
|
device = strs[1];
|
||||||
action = strs[2];
|
action = strs[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
String mes = "";
|
||||||
|
|
||||||
|
magicAgvService.process(instcode, type, device, action, processingVehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
String mes = "";
|
|
||||||
|
|
||||||
magicAgvService.process(instcode, type, device, action, processingVehicle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
MDC.remove(log_file_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module.exports = {
|
|||||||
/*
|
/*
|
||||||
title: 'EL-ADMIN',
|
title: 'EL-ADMIN',
|
||||||
*/
|
*/
|
||||||
title: '',
|
title: 'ACS',
|
||||||
/**
|
/**
|
||||||
* @description 是否显示 tagsView
|
* @description 是否显示 tagsView
|
||||||
*/
|
*/
|
||||||
@@ -29,7 +29,7 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* @description token key
|
* @description token key
|
||||||
*/
|
*/
|
||||||
TokenKey: 'NL-ADMIN-TOEKN',
|
TokenKey: 'ACS-TOKEN',
|
||||||
/**
|
/**
|
||||||
* @description 请求超时时间,毫秒(默认2分钟)
|
* @description 请求超时时间,毫秒(默认2分钟)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
pm.material = 输入.material_type
|
pm.material = 输入.material_type
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
ORDER BY
|
ORDER BY
|
||||||
col
|
col ASC
|
||||||
ENDSELECT
|
ENDSELECT
|
||||||
ENDQUERY
|
ENDQUERY
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* @description 网站标题
|
* @description 网站标题
|
||||||
*/
|
*/
|
||||||
title: 'EL-ADMIN',
|
title: 'LMS',
|
||||||
/**
|
/**
|
||||||
* @description 是否显示 tagsView
|
* @description 是否显示 tagsView
|
||||||
*/
|
*/
|
||||||
@@ -26,7 +26,7 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* @description token key
|
* @description token key
|
||||||
*/
|
*/
|
||||||
TokenKey: 'EL-ADMIN-TOEKN',
|
TokenKey: 'LMS-TOKEN',
|
||||||
/**
|
/**
|
||||||
* @description 请求超时时间,毫秒(默认2分钟)
|
* @description 请求超时时间,毫秒(默认2分钟)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user