findAllAgvFromCache();
-
- void updateAgvFromCache(AgvDto dto);
-
- /**
- * 删除magic任务
- *
- * @param instCode
- * @return
- */
- public HttpResponse deleteAgvInst(String instCode);
-
- /**
- * 删除先知任务
- *
- * @param instCode
- * @return
- */
- public HttpResponse deleteXZAgvInst(String instCode);
-
- /**
- * 删除NDC任务
- *
- * @param inst
- * @throws Exception
- */
- public void deleteAgvInstToNDC(Instruction inst) throws Exception;
-
-
- /**
- * 查询Magic AGV任务状态调用
- *
- * @param jobno
- * @param type
- * @param address
- * @param action
- * @param processingVehicle
- * @return
- */
- public String process(String jobno, String type, String address, String action, String processingVehicle);
-
- /**
- * Magic AGV 请求离开调用
- *
- * @param device
- * @return
- */
- public String requestAck(String device);
-
- /**
- * 先工agv 等待点请求
- *
- * @param
- * @return
- */
- public String waitPointRequest(String param);
-
- /**
- * 请求开门、关门
- *
- * @param device
- * @return
- */
- public String requestOpenOrCloseDoor(String device, String param);
-
- /**
- * 查询自动门状态
- *
- * @param device
- * @return
- */
- public String queryDoorStatus(String device);
-
- public String queryAllDoorStatus();
-
-
- /**
- * 下发NDC agv单工动作指令
- *
- * @param phase
- * @param index
- * @param result1
- * @param result2
- */
- public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2);
-
- /**
- * 下发agv单工动作指令
- *
- * @param phase
- * @param index
- */
- public byte[] sendAgvOneModeInst(int phase, int index);
-
- /**
- * 反馈agv单工动作指令
- *
- * @param phase
- * @param index
- */
- public byte[] sendAgvOneModeInst(int phase, int index, int result);
-
-
- /**
- * 下发运单序列
- *
- * @param inst
- * @return
- * @throws Exception
- */
- public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception;
-
- public HttpResponse addOrderSequences(Instruction inst) throws Exception;
-
- /**
- * 组织json数据
- *
- * @param
- * @return
- * @throws Exception
- */
- public String sendOrderSequencesParam(Instruction inst) throws Exception;
-
- public JSONObject createOrederData(Instruction inst, String type);
-
- /**
- * magic 全部暂停车辆
- */
- public HttpResponse pause() throws Exception;
-
- /**
- * magic 暂停指定车辆
- */
- public HttpResponse pause(String device_code) throws Exception;
-
- /**
- * magic 全部恢复车辆
- */
- public HttpResponse resume() throws Exception;
-
- /**
- * magic 恢复指定车辆
- */
- public HttpResponse resume(String device_code) throws Exception;
-
-
- String queryDeviceStation();
-}
diff --git a/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java b/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java
deleted file mode 100644
index ed1333a..0000000
--- a/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.nl.acs.agv.server.dto;
-
-import lombok.Data;
-
-import java.io.Serializable;
-
-@Data
-public class AgvDto implements Serializable {
-
- /**
- * 名称
- */
- private String name;
-
- /**
- * 机器人当前的自身状态
- *
- * UNKNOWN:未知状态
- * UNAVAILABLE:通信超时或者已断开连接
- * ERROR:错误状态
- * IDLE:空闲状态
- * EXECUTING:正在执行运单
- * CHARGING:正在充电
- */
- private String state;
-
- /**
- * 机器人的剩余电量值(单位:整数百分比)
- */
- private String energyLevel;
-
- /**
- *
- */
- private String energyLevelGood;
-
- /**
- * 机器人在 SRD 系统中的在线状态
- *
- * TO_BE_IGNORED:机器人处于离线状态,SRD 不会标识出机器人位置。
- * TO_BE_NOTICED:机器人处于离线状态,SRD 标识出机器人的位置。
- * TO_BE_RESPECTED:机器人处于在线状态,但不能接受新的运单。
- * TO_BE_UTILIZED:机器人处于在线状态,可以接受并执行新的运单。
- */
- private String integrationLevel;
-
- /**
- * 机器人当前的运单执行状态
- *
- * UNAVAILABLE:无法执行任何运单和任务
- * IDLE:空闲状态
- * AWAITING_ORDER:机器人在等待运单中新的子任务
- * PROCESSING_ORDER:机器人正在执行运单
- */
- private String procState;
-
- /**
- * 角度
- */
- private String positionAngle;
-
- /**
- * X坐标
- */
- private String positionX;
-
- /**
- * Y坐标
- */
- private String positionY;
-
- /**
- * 当前任务号
- */
- private String transportOrder;
-
-}
diff --git a/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
deleted file mode 100644
index d846ff5..0000000
--- a/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
+++ /dev/null
@@ -1,1750 +0,0 @@
-package org.nl.acs.agv.server.impl;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpResponse;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.agv.server.AgvService;
-import org.nl.acs.agv.server.dto.AgvDto;
-import org.nl.acs.config.AcsConfig;
-import org.nl.acs.config.server.AcsConfigService;
-import org.nl.acs.device.service.DeviceService;
-import org.nl.acs.device.service.impl.DeviceServiceImpl;
-import org.nl.acs.device_driver.machines_site.MachinesSiteDeviceDriver;
-import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver;
-import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
-import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
-import org.nl.acs.device_driver.standard_manipulator_inspect_site.StandardManipulatorInspectSiteDeviceDriver;
-import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
-import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver;
-import org.nl.acs.device_driver.weighing_site.WeighingSiteDeviceDriver;
-import org.nl.acs.ext.erp.service.AcsToErpService;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.instruction.service.dto.Instruction;
-import org.nl.acs.log.service.LogServer;
-import org.nl.acs.opc.Device;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.opc.DeviceAppServiceImpl;
-import org.nl.acs.opc.DeviceType;
-import org.nl.acs.task.service.TaskService;
-import org.nl.exception.BadRequestException;
-import org.nl.start.auto.run.NDCSocketConnectionAutoRun;
-import org.nl.utils.SpringContextHolder;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class AgvServiceImpl implements AgvService {
-
- @Autowired
- DeviceAppService deviceAppService;
- @Autowired
- TaskService taskService;
- @Autowired
- InstructionService instructionService;
- @Autowired
- AcsConfigService acsConfigService;
- @Autowired
- AcsToErpService acsToErpService;
- @Autowired
- AcsToWmsService acsToWmsService;
-
- private final LogServer logServer;
-
- Map AGVDeviceStatus = new HashMap();
-
- /**
- * 获得之后num个天的时间
- *
- * @param num
- * @return
- */
- public static String getNextDay(int num) {
- Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DAY_OF_MONTH, num);
- Date date = calendar.getTime();
- TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- df.setTimeZone(tz);
- String nowAsISO = df.format(date);
- return nowAsISO;
- }
-
- /**
- * 返回一个点位操作子任务
- *
- * @param locationName 点位
- * @param operation 点位操作
- * @param propertiesType 子任务类型
- * @param pro 子任务参数
- * 调用demo:destination("sh15p", "Spin", "2", "3.14")
- * demo:destination("cz14", "JackUnload", "3", "")
- * @return
- */
- public static JSONObject destination(String locationName, String operation, String propertiesType, String pro) {
- //新增业务订单
- JSONObject destinationOrder = new JSONObject();
- //目标工作站
- destinationOrder.put("locationName", locationName);
- //机器人在工作站要执行的操作
- destinationOrder.put("operation", operation);
- if (propertiesType.equals("1")) {//取货前等待、取货后等待
-
- //pro 1 进入离开等待
- if ("1".equals(pro)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "EntryRequired");
- pro1.put("value", "True");
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "PauseOnStation");
- pro2.put("value", "True");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //进入等待 离开不等待
- } else if ("2".equals(pro)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "EntryRequired");
- pro1.put("value", "True");
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "PauseOnStation");
- pro2.put("value", "False");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //进入不等待 离开等待
- } else if ("3".equals(pro)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "EntryRequired");
- pro1.put("value", "False");
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "PauseOnStation");
- pro2.put("value", "True");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //不等待
- } else {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "EntryRequired");
- pro1.put("value", "False");
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "PauseOnStation");
- pro2.put("value", "False");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- }
-
- } else if (propertiesType.equals("2")) {//Spin转动
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "global_spin_angle");//坐标系类型,global_spin_angle为全局坐标系
- pro1.put("value", pro);//弧度值,如3.14
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "spin_direction");//固定值
- pro2.put("value", "0");//弧度值,如0
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- } else if (propertiesType.equals("3")) {//JackUnload,Jackload不操作
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "recognize");//固定值
- pro1.put("value", "false");//固定值
- properties.add(pro1);
- destinationOrder.put("properties", properties);
- } else if (propertiesType.equals("4")) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "robot_spin_angle");//坐标系类型,robot_spin_angle为机器人坐标系
- pro1.put("value", pro);//弧度值,如3.14
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "spin_direction");//固定值
- pro2.put("value", "0");//弧度值,如0
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- }
- return destinationOrder;
- }
-
- /**
- * 返回一个点位操作子任务 先知使用
- *
- * @param locationName 点位
- * @param operation 点位操作
- * @param propertiesType 子任务类型
- * @param pro 子任务参数
- * 调用demo:destination("sh15p", "Spin", "2", "3.14")
- * demo:destination("cz14", "JackUnload", "3", "")
- * @return
- */
- public static JSONObject destination2(String locationName, String operation, String propertiesType, String pro) {
- //新增业务订单
- JSONObject destinationOrder = new JSONObject();
- //目标工作站
- destinationOrder.put("locationName", locationName);
- //机器人在工作站要执行的操作
- destinationOrder.put("operation", operation);
- if (propertiesType.equals("1")) {//Wait请求是否继续
- JSONArray properties = new JSONArray();
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "device:queryAtExecuted");//固定值
- pro2.put("value", pro + ":wait");//pro为wait请求的标识,一般用点位拼接的字符串
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- } else if (propertiesType.equals("2")) {//Spin转动
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "global_spin_angle");//坐标系类型,global_spin_angle为全局坐标系
- pro1.put("value", pro);//弧度值,如3.14
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "spin_direction");//固定值
- pro2.put("value", "0");//弧度值,如0
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- } else if (propertiesType.equals("3")) {//JackUnload,Jackload不操作
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "recognize");//固定值
- pro1.put("value", "false");//固定值
- properties.add(pro1);
- destinationOrder.put("properties", properties);
- } else if (propertiesType.equals("4")) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "robot_spin_angle");//坐标系类型,robot_spin_angle为机器人坐标系
- pro1.put("value", pro);//弧度值,如3.14
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "spin_direction");//固定值
- pro2.put("value", "0");//弧度值,如0
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- } else if (propertiesType.equals("5")) {//Wait请求是否继续
- JSONArray properties = new JSONArray();
- JSONObject pro2 = new JSONObject();
-
- destinationOrder.put("properties", "[]");
- }
- return destinationOrder;
- }
-
- @Override
- public HttpResponse sendAgvInstToMagic(Instruction inst) throws Exception {
- JSONArray ja = new JSONArray();
- JSONObject orderjo = new JSONObject();
- String instno = inst.getInstruction_code();
- String compound_inst_data = inst.getCompound_inst_data();
- String[] str = null;
- List pathlist = null;
-
- if (StrUtil.equals("2", inst.getInstruction_type()) && !StrUtil.isEmpty(compound_inst_data)) {
- str = compound_inst_data.split("->");
- pathlist = Arrays.asList(str);
-
- for (int i = 0; i < pathlist.size(); i++) {
- String device_code = pathlist.get(i);
- Device device = deviceAppService.findDeviceByCode(device_code);
- if (ObjectUtil.isEmpty(device)) {
- throw new BadRequestException("未找到该设备【" + device_code + "】");
- }
- if (i == 0) {
- ja.add(destination(device_code, "Load", "1", "1"));
- } else if (i == pathlist.size() - 1) {
- ja.add(destination(device_code, "Unload", "1", "1"));
- } else {
- ja.add(destination(device_code, "OP_DUMP", "1", "4"));
- }
-
- }
-
- //指定agv车号 暂时不用
- //orderjo.put("intendedVehicle", "");
- //设置任务最终时间
- orderjo.put("deadline", getNextDay(1));
-
- orderjo.put("destinations", ja);
-
- JSONObject prijo = new JSONObject();
- prijo.put("key", "priority");
- prijo.put("value", inst.getPriority());
-
- JSONArray prija = new JSONArray();
- prija.add(prijo);
- orderjo.put("properties", prija);
-
-
- } else {
-
- String startAddress = inst.getStart_point_code();
- String nextAddress = inst.getNext_point_code();
- DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
- Device nextdevice = appService.findDeviceByCode(nextAddress);
- Device startdevice = appService.findDeviceByCode(startAddress);
- //指定agv车号 暂时不用
- //orderjo.put("intendedVehicle", "");
- //设置任务最终时间
- orderjo.put("deadline", getNextDay(1));
- //拼接起点子任务动作,待完善,动作码需要从数据库取值
- ja.add(destination(startAddress, "Load", "1", "1"));
- //拼接终点子任务动作,待完善,动作码需要从数据库取值
- ja.add(destination(nextAddress, "Unload", "1", "1"));
-
- orderjo.put("destinations", ja);
-
- JSONObject prijo = new JSONObject();
- prijo.put("key", "priority");
- prijo.put("value", inst.getPriority());
-
- JSONArray prija = new JSONArray();
- prija.add(prijo);
- orderjo.put("properties", prija);
-
- }
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instno;
-
- log.info("下发agv指令参数:{}", orderjo.toString());
-
- HttpResponse result = null;
- try {
- result = HttpRequest.post(agvurl)
- .body(String.valueOf(orderjo))//表单内容
- .timeout(20000)//超时,毫秒
- .execute();
- } catch (Exception e) {
- throw new RuntimeException("下发agv失败!");
- }
- return result;
- } else {
- return null;
- }
-
-
- }
-
- @Override
- public HttpResponse markComplete(String code) throws Exception {
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/api/route/orderSequences/" + code + "/markComplete";
- log.info("关闭agv运单序列请求:{}", agvurl);
-
- HttpResponse result = HttpRequest.post(agvurl)
- //.body(String.valueOf(orderjo))//表单内容
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("关闭agv运单序列请求反馈:{}", result);
-
- return result;
- } else {
- return null;
- }
-
- }
-
- @Override
- public HttpResponse sendAgvInstToMagic(String instcode) throws Exception {
- InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
- Instruction inst = instructionService.findByCodeFromCache(instcode);
- HttpResponse result = this.sendAgvInstToMagic(inst);
- return result;
- }
-
- @Override
- public void sendAgvInstToNDC(Instruction inst) {
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String instcode = inst.getInstruction_code();
- int type = Integer.parseInt(inst.getInstruction_type());
- int priority = Integer.parseInt(inst.getPriority()) + 128;
- DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
- DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
- int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
- int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
-
- byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
- byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
- byte typehigh = (byte) IntToHexHigh(type);
- byte typelow = (byte) IntToHexLow(type);
- byte qhdhigh = (byte) IntToHexHigh(startAddress);
- byte qhdlow = (byte) IntToHexLow(startAddress);
- byte fhdhigh = (byte) IntToHexHigh(nextAddress);
- byte fhdlow = (byte) IntToHexLow(nextAddress);
- byte prioritylow = (byte) IntToHexLow(priority);
-
- String str = "十进制下发:";
- String str1 = "十六进制下发:";
- str += "ikey:" + (Integer.parseInt(instcode));
- str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
-
- str += "/type:" + (type);
- str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
-
- str += "/qhd:" + (startAddress);
- str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
- str += "/fhd:" + (nextAddress);
- str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
-
- str += "/priority:" + (priority);
- str1 += "/priority:" + hexToString(prioritylow & 0xFF);
-
- System.out.println(str);
- System.out.println(str1);
-
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X12,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X71,
- (byte) 0X00, (byte) 0X0E,
- (byte) 0X01, prioritylow,
- (byte) 0X00, (byte) 0X01,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) typehigh, (byte) typelow,
- (byte) qhdhigh, (byte) qhdlow,
- (byte) fhdhigh, (byte) fhdlow
- };
- log.info("下发AGV作业指令--{}", str1);
-
- NDCSocketConnectionAutoRun.write(b);
- System.out.println("下发agv指令数据:" + Bytes2HexString(b));
- }
- }
-
- @Override
- public void sendAgvInstToNDC(String instcode) throws Exception {
- InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
- Instruction inst = instructionService.findByCodeFromCache(instcode);
- sendAgvInstToNDC(inst);
- }
-
-
- @Override
- public HttpResponse queryAgvInstStatus(String instCode) {
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instCode;
-
- HttpResponse result = HttpRequest.get(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- System.out.println("查询agv指令数据:" + result.body());
-
- return result;
- } else {
-
- return null;
- }
- }
-
- @Override
- public HttpResponse queryMagicAgvDeviceStatus() {
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/vehicles";
-
- HttpResponse result = HttpRequest.get(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- System.out.println("查询agv状态数据:" + result.body());
- if (result.getStatus() == 200) {
- JSONArray ja = (JSONArray)JSONArray.parse(result.body());
- for (int i = 0; i < ja.size(); i++) {
- JSONObject jo = (JSONObject) ja.get(i);
- String name = jo.getString("name");
- String state = jo.getString("state");
- String energyLevel = jo.getString("energyLevel");
- String transportOrder = jo.getString("transportOrder");
- String positionAngle = jo.getString("positionAngle");
- String positionX = jo.getString("positionX");
- String positionY = jo.getString("positionY");
- AgvDto dto = new AgvDto();
- dto.setName(name);
- dto.setEnergyLevel(energyLevel);
- dto.setState(state);
- dto.setPositionAngle(positionAngle);
- dto.setPositionX(positionX);
- dto.setPositionY(positionY);
- dto.setTransportOrder(transportOrder);
-
- if (AGVDeviceStatus.containsKey(name)) {
- AGVDeviceStatus.remove(name);
- AGVDeviceStatus.put(name, dto);
- } else {
- AGVDeviceStatus.put(name, dto);
- }
- }
- }
- return result;
- } else {
- return null;
- }
- }
-
- @Override
- public HttpResponse queryXZAgvDeviceStatus() {
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- String agvurl1 = agvurl + ":" + agvport + "/api/route/vehicles";
- String agvurl2 = agvurl + ":" + agvport + "/api/route/vehicleDetails";
-
- HttpResponse result = HttpRequest.get(agvurl1)
- .timeout(20000)//超时,毫秒
- .execute();
-
-
- HttpResponse result2 = HttpRequest.get(agvurl2)
- .timeout(20000)//超时,毫秒
- .execute();
-
- System.out.println("查询agv状态数据:" + result.body());
- if (result.getStatus() == 200) {
- JSONArray ja = (JSONArray)JSONArray.parse(result.body());
-
- for (int i = 0; i < ja.size(); i++) {
- JSONObject jo = (JSONObject) ja.get(i);
- String name = jo.getString("name");
- String state = jo.getString("state");
- String energyLevel = jo.getString("energyLevel");
- String transportOrder = jo.getString("transportOrder");
- JSONObject detailjo = (JSONObject)JSONObject.parse(result2.body());
- JSONObject item = (JSONObject) detailjo.get(name);
- String x = item.getString("x");
- String y = item.getString("y");
- String angle = item.getString("angle");
- AgvDto dto = new AgvDto();
- dto.setName(name);
- dto.setEnergyLevel(energyLevel);
- dto.setState(state);
- dto.setTransportOrder(transportOrder);
- dto.setPositionAngle(angle);
- dto.setPositionX(x);
- dto.setPositionY(y);
- if (AGVDeviceStatus.containsKey(name)) {
- AGVDeviceStatus.remove(name);
- AGVDeviceStatus.put(name, dto);
- } else {
- AGVDeviceStatus.put(name, dto);
- }
- }
- }
- return result;
- } else {
- return null;
- }
- }
-
-
-
- @Override
- public HttpResponse queryXZAgvInstStatus(String instCode) {
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + instCode;
-
- HttpResponse result = HttpRequest.get(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- System.out.println("查询agv指令数据:" + result.body());
-
- return result;
- } else {
-
- return null;
- }
-
-
- }
-
- @Override
- public Map findAllAgvFromCache() {
- return AGVDeviceStatus;
- }
-
- @Override
- public void updateAgvFromCache(AgvDto dto) {
- if (AGVDeviceStatus.containsKey(dto.getName())) {
- AGVDeviceStatus.remove(dto.getName());
- }
- AGVDeviceStatus.put(dto.getName(), dto);
- }
-
- @Override
- public HttpResponse deleteAgvInst(String instCode) {
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instCode + "/withdrawal";
- log.info("删除agv指令请求agvurl:{}", agvurl);
-
- HttpResponse result = null;
- try {
- result = HttpRequest.post(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("删除agv指令请求反馈:{}", result);
- } catch (Exception e) {
- throw new RuntimeException("下发agv失败!");
- }
-
- return result;
-
- } else {
-
- return null;
- }
-
- }
-
- @Override
- public HttpResponse deleteXZAgvInst(String instCode) {
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + instCode + "/withdrawal";
- log.info("删除agv指令请求agvurl:{}", agvurl);
- HttpResponse result = HttpRequest.post(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("删除agv指令请求反馈:{}", result);
-
- return result;
-
- } else {
-
- return null;
- }
-
- }
-
- @Override
- public void deleteAgvInstToNDC(Instruction inst) throws Exception {
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- int index = Integer.parseInt(inst.getAgv_jobno());
-
- byte indexhigh = (byte) IntToHexHigh(index);
- byte indexlow = (byte) IntToHexLow(index);
-
- String str = "十进制下发:";
- String str1 = "十六进制下发:";
- str += "index:" + index;
- str1 += "ikey:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF);
- System.out.println(str);
- System.out.println(str1);
-
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X06,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6E,
- (byte) 0X00, (byte) 0X02,
- (byte) indexhigh, (byte) indexlow,
- };
- log.info("下发删除AGV指令--{}", Bytes2HexString(b));
-
- NDCSocketConnectionAutoRun.write(b);
- System.out.println("下发删除agv指令数据:" + Bytes2HexString(b));
- }
- }
-
- //1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
- @Override
- public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) {
- log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action);
- boolean is_feedback = false;
- String str = "";
- String backaddress = address;
- if (address.indexOf(".") > 0) {
- str = address.substring(address.indexOf("."), address.length());
- address = address.substring(0, address.indexOf("."));
- } else if (address.indexOf("-") > 0) {
- address = address.substring(0, address.indexOf("-"));
- }
- InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
- Instruction inst = instructionService.findByCodeFromCache(jobno);
-
-
- DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
- Device addressdevice = appService.findDeviceByCode(address);
- StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
- StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
- SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver;
- //请求进入
- if ("onEntry".equals(type)) {
-
- if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
- standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver();
- //请求取货
- if ("Load".equals(action)) {
- if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() > 0) {
- inst.setExecute_status("1");
- is_feedback = true;
- }
- //请求放货
- } else if ("Unload".equals(action)) {
- if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) {
- inst.setExecute_status("3");
- is_feedback = true;
- }
- }
- }
- if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) {
- specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
- //请求取货
- if ("Load".equals(action)) {
- if (addressdevice.getHas_goods() > 0) {
- inst.setExecute_status("1");
- is_feedback = true;
- }
- //请求放货
- } else if ("Unload".equals(action)) {
- if (addressdevice.getHas_goods() == 0) {
- inst.setExecute_status("3");
- is_feedback = true;
- }
- }
-
- }
- if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
- //请求取货
- if ("Load".equals(action)) {
- if (addressdevice.getHas_goods() > 0) {
- inst.setExecute_status("1");
- is_feedback = true;
- }
- //请求放货
- } else if ("Unload".equals(action)) {
- if (addressdevice.getHas_goods() == 0) {
- inst.setExecute_status("3");
- is_feedback = true;
- }
- }
- }
-
- if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
- //请求取货
- if ("Load".equals(action)) {
- inst.setExecute_status("1");
- is_feedback = true;
- //请求放货
- } else if ("Unload".equals(action)) {
- inst.setExecute_status("3");
- is_feedback = true;
- }
- }
-
- //取放货完成
- } else if ("onStation".equals(type)) {
-
- System.out.println("取放货完成");
- if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
- standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver();
- //取货完成
- if ("Load".equals(action)) {
- if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) {
- inst.setExecute_device_code(processingVehicle);
- inst.setExecute_status("2");
- is_feedback = true;
- }
- //放货完成
- } else if ("Unload".equals(action)) {
- if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() > 0) {
- inst.setExecute_device_code(address);
- inst.setExecute_status("4");
- is_feedback = true;
- }
- }
-
- }
- if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
- //取货完成
- if ("Load".equals(action)) {
- inst.setExecute_device_code(processingVehicle);
- inst.setExecute_status("2");
- is_feedback = true;
- //放货完成
- } else if ("Unload".equals(action)) {
- inst.setExecute_device_code(address);
- inst.setExecute_status("4");
- is_feedback = true;
- }
-
- }
- if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) {
- specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
- //取货完成
- if ("Load".equals(action)) {
- inst.setExecute_device_code(processingVehicle);
- inst.setExecute_status("2");
- is_feedback = true;
- //放货完成
- } else if ("Unload".equals(action)) {
- inst.setExecute_device_code(processingVehicle);
- inst.setExecute_status("4");
- is_feedback = true;
- }
- }
- if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
- //取货完成
- if ("Load".equals(action)) {
- inst.setExecute_device_code(processingVehicle);
- inst.setExecute_status("2");
- is_feedback = true;
- //放货完成
- } else if ("Unload".equals(action)) {
- inst.setExecute_device_code(processingVehicle);
- inst.setExecute_status("4");
- is_feedback = true;
- }
- }
- }
-
- JSONObject requestjo = new JSONObject();
- JSONArray ja = new JSONArray();
- if (is_feedback) {
- String param = "";
- JSONObject jo = new JSONObject();
- if (str.length() > 0) {
- backaddress = backaddress + str;
- }
- if ("onEntry".equals(type)) {
- param = "EntryPermitted-" + backaddress + action;
- } else if ("onStation".equals(type)) {
- param = "ContinueOnStation-" + backaddress + action;
- }
-
- jo.put("key", param);
- jo.put("value", "False");
- ja.add(jo);
- requestjo.put("properties", ja);
- log.info("反馈AGV请求数据:{}", requestjo);
- System.out.println("back agv:" + requestjo);
-
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact";
-
- HttpResponse result = HttpRequest.post(agvurl)
- .body(String.valueOf(requestjo))
- .timeout(20000)//超时,毫秒
- .execute();
- }
- is_feedback = false;
-
- return requestjo.toString();
-
- }
-
- @Override
- public String waitPointRequest(String param) {
- log.info("收到AGV请求参数:{}", param);
- String[] strs = param.split("-");
- String address = strs[0];
- String inst_code = strs[1];
- String type = strs[2];
- String newaddress = null;
- // 前置点会加上p
- if (address.endsWith("IN")) {
- newaddress = address.substring(0, address.length() - 2);
- } else if (address.endsWith("OUT")) {
- newaddress = address.substring(0, address.length() - 3);
- } else if (address.endsWith("P") || address.endsWith("L") || address.endsWith("R")) {
- newaddress = address.substring(0, address.length() - 1);
- } else if (address.endsWith("CZ")) {
- newaddress = address.substring(0, address.length() - 2);
- } else if (address.endsWith("IQ") || address.endsWith("OQ")) {
- newaddress = address.substring(0, address.length() - 2);
- } else {
- newaddress = address;
- }
- boolean is_feedback = false;
-
- Device device = deviceAppService.findDeviceByCode(newaddress);
- StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
- MachinesSiteDeviceDriver machinesSiteDeviceDriver;
- WeighingSiteDeviceDriver weighingSiteDeviceDriver;
- StandardManipulatorInspectSiteDeviceDriver sandardManipulatorInspectSiteDeviceDriver;
- StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- //人工确认信号
- if (standardOrdinarySiteDeviceDriver.getManua_confirm() == 2) {
- is_feedback = true;
- standardOrdinarySiteDeviceDriver.setManua_confirm(0);
- } else {
- standardOrdinarySiteDeviceDriver.setManua_confirm(1);
- }
- }
- if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
- standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
- //请求取货
- if (StrUtil.equals(type, "01") && address.endsWith("IN")
- && standardInspectSiteDeviceDriver.getMove() != 0) {
- standardInspectSiteDeviceDriver.writing(1, 1);
- is_feedback = true;
- }
- //取货完成
- else if (StrUtil.equals(type, "02")) {
- standardInspectSiteDeviceDriver.writing(1, 2);
- is_feedback = true;
- }
- //取货完成离开
- else if (StrUtil.equals(type, "05") && address.endsWith("OUT")
- && standardInspectSiteDeviceDriver.getMove() == 0) {
- standardInspectSiteDeviceDriver.writing(1, 5);
- is_feedback = true;
- }
- //请求放货
- else if (StrUtil.equals(type, "03") && address.endsWith("IN")
- && standardInspectSiteDeviceDriver.getMove() == 0) {
- standardInspectSiteDeviceDriver.writing(1, 3);
- is_feedback = true;
- }
- //放货完成
- else if (StrUtil.equals(type, "04")) {
- standardInspectSiteDeviceDriver.writing(1, 4);
- is_feedback = true;
- }
- //放货完成离开
- else if (StrUtil.equals(type, "06") && address.endsWith("OUT")
- && standardInspectSiteDeviceDriver.getMove() != 0) {
- standardInspectSiteDeviceDriver.writing(1, 6);
- is_feedback = true;
- }
-
- }
- if (device.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) {
- sandardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) device.getDeviceDriver();
- //请求进
- if (StrUtil.equals(type, "07") && address.endsWith("IQ")
- && (sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 1 || sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3)) {
- sandardManipulatorInspectSiteDeviceDriver.writing(1, 7);
- is_feedback = true;
- }
- //请求取货
- else if (StrUtil.equals(type, "01") && address.endsWith("IN")
- && (sandardManipulatorInspectSiteDeviceDriver.getActoin() == 1 || sandardManipulatorInspectSiteDeviceDriver.getActoin() == 3)
- && sandardManipulatorInspectSiteDeviceDriver.getMove() != 0) {
- sandardManipulatorInspectSiteDeviceDriver.writing(1, 1);
- is_feedback = true;
- }
- //取货完成
- else if (StrUtil.equals(type, "02")) {
- sandardManipulatorInspectSiteDeviceDriver.writing(1, 2);
- is_feedback = true;
- }
- //取货完成离开
- else if (StrUtil.equals(type, "05") && address.endsWith("OUT")
- && sandardManipulatorInspectSiteDeviceDriver.getMove() == 0) {
- sandardManipulatorInspectSiteDeviceDriver.writing(1, 5);
- is_feedback = true;
- }
- //请求离开
- else if (StrUtil.equals(type, "08") && address.endsWith("OQ")
- && (sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 2 || sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3)) {
- sandardManipulatorInspectSiteDeviceDriver.writing(1, 8);
- is_feedback = true;
- }
- //请求放货
- else if (StrUtil.equals(type, "03") && address.endsWith("IN")
- && (sandardManipulatorInspectSiteDeviceDriver.getActoin() == 2 || sandardManipulatorInspectSiteDeviceDriver.getActoin() == 3)
- && sandardManipulatorInspectSiteDeviceDriver.getMove() == 0) {
- sandardManipulatorInspectSiteDeviceDriver.writing(1, 3);
- is_feedback = true;
- }
- //放货完成
- else if (StrUtil.equals(type, "04")) {
- sandardManipulatorInspectSiteDeviceDriver.writing(1, 4);
- is_feedback = true;
- }
- //放货完成离开
- else if (StrUtil.equals(type, "06") && address.endsWith("OUT")
- && sandardManipulatorInspectSiteDeviceDriver.getMove() != 0) {
- sandardManipulatorInspectSiteDeviceDriver.writing(1, 6);
- is_feedback = true;
- }
-
- }
- if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) {
- weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver();
- Instruction inst = instructionService.findByCodeFromCache(inst_code);
- weighingSiteDeviceDriver.setInst(inst);
- //调用erp接口
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASOTHERSYSTEM).toString(), "1")) {
- log.info("请求ERP接口参数:{}", inst.getStart_device_code());
- JSONObject jo = acsToErpService.sendDeviceToWms(inst.getStart_device_code());
- log.info("ERP接口反馈:{}", jo);
- }
- is_feedback = true;
- }
- if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) {
- machinesSiteDeviceDriver = (MachinesSiteDeviceDriver) device.getDeviceDriver();
- //请求进
- if (address.endsWith("IN")) {
- if (machinesSiteDeviceDriver.getIoaction() == 1 || machinesSiteDeviceDriver.getIoaction() == 3) {
- is_feedback = true;
- } else {
- machinesSiteDeviceDriver.writing(6);
- }
- }
- //请求离开
- else if (address.endsWith("OUT")) {
- machinesSiteDeviceDriver.writing(6);
- machinesSiteDeviceDriver.writing(6);
- is_feedback = true;
-
- } else {
-
- if (machinesSiteDeviceDriver.getIoaction() == 2 || machinesSiteDeviceDriver.getIoaction() == 3) {
- is_feedback = true;
- } else {
- machinesSiteDeviceDriver.writing(5);
- machinesSiteDeviceDriver.writing(2, device.getAddress() == null ? 0 : Integer.parseInt(device.getAddress()));
- }
- }
- }
- JSONObject jo = new JSONObject();
- if (is_feedback) {
- jo.put("name", param);
- jo.put("lastAction", "wait");
- jo.put("lastActionStatus", "DONE");
- jo.put("status", "IDLE");
- } else {
- jo.put("name", param);
- jo.put("lastAction", "wait");
- jo.put("lastActionStatus", "FAILED");
- jo.put("status", "IDLE");
- }
- is_feedback = false;
- log.info("反馈AGV请求参数:{}", jo.toString());
-
- return jo.toString();
- }
-
- @Override
- public String requestAck(String address) {
- log.info("AGV请求离开参数:{}", address);
- boolean flag = false;
-
- if (address.indexOf(".") > 0) {
- address = address.substring(0, address.indexOf("."));
- }
- if (address.indexOf("-") > 0) {
- address = address.substring(0, address.indexOf("-"));
- }
- InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
-
- DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
- Device addressdevice = appService.findDeviceByCode(address);
- StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
- StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
- StandardStorageDeviceDriver standardStorageDeviceDriver;
- //mes = AgvClientXZ.mes(zlbh, device, type);
- //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
- if ((addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver)) {
- flag = true;
- }
-
- if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
- standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver();
- flag = true;
- log.info("agvstatus:" + standardInspectSiteDeviceDriver.getFlag() + "");
- //取货完成离开
- if (standardInspectSiteDeviceDriver.getFlag() == 2) {
- if (standardInspectSiteDeviceDriver.getMove() == 0) {
- flag = true;
- standardInspectSiteDeviceDriver.setFlag(5);
- }
- }
- //放货完成离开
- if (standardInspectSiteDeviceDriver.getFlag() == 4) {
- if (standardInspectSiteDeviceDriver.getMove() == 1) {
- flag = true;
- standardInspectSiteDeviceDriver.setFlag(6);
- }
- }
- }
-
- if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
- flag = true;
- log.info("agvstatus:" + standardOrdinarySiteDeviceDriver.getFlag() + "");
-
- //取货完成离开
- if (standardOrdinarySiteDeviceDriver.getFlag() == 2) {
- flag = true;
- standardOrdinarySiteDeviceDriver.setFlag(5);
- }
- //放货完成离开
- if (standardOrdinarySiteDeviceDriver.getFlag() == 4) {
- flag = true;
- standardOrdinarySiteDeviceDriver.setFlag(6);
- }
- }
-
- if (flag) {
- log.info("AGV请求离开,反馈成功:{}", address);
- System.out.println("AGV请求离开,反馈成功 " + address);
- return "OK";
- } else {
- log.info("AGV请求离开,反馈失败{}", address);
- System.out.println("AGV请求离开,反馈失败 " + address);
- throw new RuntimeException("AGV请求离开,反馈失败 " + address);
- }
- }
-
- @Override
- public String requestOpenOrCloseDoor(String device, String param) {
- log.info("AGV请求开关门参数,设备:{},参数:{}", device, param);
- int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE));
- switch (type) {
- case 4:
- acsToWmsService.applyOpenOrCloseDoor(device, param);
- break;
- default:
- StandardAutodoorDeviceDriver autodoor;
- Device doordevice = deviceAppService.findDeviceByCode(device);
- if (ObjectUtil.isEmpty(doordevice)) {
- throw new BadRequestException("未找到对应设备");
- }
- if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
- autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver();
- if (StrUtil.equals("open", param)) {
- autodoor.OpenOrClose("1");
- log.info("下发开门请求");
-
- } else if (StrUtil.equals("close", param)) {
- autodoor.OpenOrClose("2");
- log.info("下发关门请求");
- }
- }
- break;
-
- }
- return null;
- }
-
- @Override
- public String queryDoorStatus(String device) {
- log.info("AGV查询自动门状态,参数:{}", device);
- int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE));
- switch (type) {
- case 4:
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASOTHERSYSTEM).toString(), "1")) {
- String result = acsToWmsService.queryDoorsStatus().body();
- JSONArray ja = JSONArray.parseArray(result);
- log.info("AGV查询自动门状态,反馈:{}", ja.toString());
- return ja.toString();
- }
- return null;
- default:
- if (StrUtil.equals("doors", device)) {
- List list = deviceAppService.findDevice(DeviceType.autodoor);
- JSONArray ja = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code());
- if (ObjectUtil.isEmpty(doordevice)) {
- throw new BadRequestException("未找到对应设备");
- }
- String mes = null;
- StandardAutodoorDeviceDriver autodoor;
- if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
- autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver();
- mes = autodoor.getStatus();
- }
- JSONObject jo = JSONObject.parseObject(mes);
- ja.add(jo);
- }
- log.info("AGV查询自动门状态,反馈:{}", ja.toString());
- return ja.toString();
-
- } else {
- Device doordevice = deviceAppService.findDeviceByCode(device);
- if (ObjectUtil.isEmpty(doordevice)) {
- throw new BadRequestException("未找到对应设备");
- }
- String mes = null;
- StandardAutodoorDeviceDriver autodoor;
- if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
- autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver();
- mes = autodoor.getStatus();
- }
- JSONObject jo = JSONObject.parseObject(mes);
- log.info("AGV查询自动门状态,反馈:{}", jo.toString());
- return jo.toString();
- }
- }
- }
-
- @Override
- public String queryAllDoorStatus() {
- log.info("AGV查询全部自动门状态");
- List list = deviceAppService.findDevice(DeviceType.autodoor);
- JSONArray ja = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code());
- if (ObjectUtil.isEmpty(doordevice)) {
- throw new BadRequestException("未找到对应设备");
- }
- String mes = null;
- StandardAutodoorDeviceDriver autodoor;
- if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
- autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver();
- mes = autodoor.getStatus();
- }
- JSONObject jo = JSONObject.parseObject(mes);
- ja.add(jo);
- }
- log.info("AGV查询全部自动门状态,反馈:{}", ja.toString());
- return ja.toString();
- }
-
-
- @Override
- public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2) {
- if (phase < 0 || index < 0)
- return null;
- byte indexhigh = (byte) IntToHexHigh(index);
- byte indexlow = (byte) IntToHexLow(index);
- byte phasehigh = (byte) IntToHexHigh(phase);
- byte phaselow = (byte) IntToHexLow(phase);
- byte resulthigh1 = (byte) IntToHexHigh(result1);
- byte resultlow1 = (byte) IntToHexLow(result1);
- byte resulthigh2 = (byte) IntToHexHigh(result2);
- byte resultlow2 = (byte) IntToHexLow(result2);
-
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0D,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6D,
- (byte) 0X00, (byte) 0X08,
- (byte) indexhigh, (byte) indexlow,
- (byte) 0X01, (byte) 0X12,
- (byte) phasehigh, (byte) phaselow,
- (byte) resulthigh1, (byte) resultlow1,
- (byte) resulthigh2, (byte) resultlow2
- };
-
- log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
- //87CD 0008 000C 0001 006D 0008 0000 0114 000E 0000
- //87CD 0008 000C 0001 006D 0008 0003 0114 008F 0000
- System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
- return b;
- }
-
- @Override
- public byte[] sendAgvOneModeInst(int phase, int index) {
- return new byte[0];
- }
-
- @Override
- public byte[] sendAgvOneModeInst(int phase, int index, int result) {
- if (phase < 0 || index < 0)
- return null;
- byte indexhigh = (byte) IntToHexHigh(index);
- byte indexlow = (byte) IntToHexLow(index);
- byte phasehigh = (byte) IntToHexHigh(phase);
- byte phaselow = (byte) IntToHexLow(phase);
- byte resulthigh = (byte) IntToHexHigh(result);
- byte resultlow = (byte) IntToHexLow(result);
-
- int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE));
- byte[] b = new byte[]{};
- switch (type) {
- case 0:
- b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0A,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6D,
- (byte) 0X00, (byte) 0X06,
- (byte) indexhigh, (byte) indexlow,
- (byte) 0X01, (byte) 0X12,
- (byte) phasehigh, (byte) phaselow
- };
- break;
- case 1:
- b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0D,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6D,
- (byte) 0X00, (byte) 0X08,
- (byte) indexhigh, (byte) indexlow,
- (byte) 0X01, (byte) 0X12,
- (byte) phasehigh, (byte) phaselow,
- (byte) resulthigh, (byte) resultlow
- };
- break;
- case 2:
- b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0A,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6D,
- (byte) 0X00, (byte) 0X06,
- (byte) indexhigh, (byte) indexlow,
- (byte) 0X01, (byte) 0X12,
- (byte) phasehigh, (byte) phaselow
- };
- break;
- case 5:
- b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0A,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6D,
- (byte) 0X00, (byte) 0X06,
- (byte) indexhigh, (byte) indexlow,
- (byte) 0X01, (byte) 0X12,
- (byte) phasehigh, (byte) phaselow
- };
- break;
- case 7:
- b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0A,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6D,
- (byte) 0X00, (byte) 0X06,
- (byte) indexhigh, (byte) indexlow,
- (byte) 0X01, (byte) 0X12,
- (byte) phasehigh, (byte) phaselow
- };
- break;
- }
-
-
- log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
-
- System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
- return b;
- }
-
- @Override
- public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception {
-
- JSONObject jo = new JSONObject();
- jo.put("intendedVehicle", "");
- jo.put("category", "");
- jo.put("failureFatal", false);
- jo.put("complete", false);
- JSONArray transports = new JSONArray();
- JSONObject orderjo = new JSONObject();
- orderjo.put("name", inst.getInstruction_code());
- orderjo.put("order", createOrederData(inst, "1"));
- transports.add(orderjo);
- jo.put("transports", transports);
-
- JSONArray ja1 = new JSONArray();
- JSONObject jo1 = new JSONObject();
- jo1.put("key", "");
- jo1.put("value", "");
- ja1.add(jo1);
- jo.put("properties", ja1);
-
- log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo.toString());
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/api/route/orderSequences/" + inst.getTask_code();
-
- HttpResponse result = HttpRequest.post(agvurl)
- .body(String.valueOf(jo))//表单内容
- .timeout(20000)//超时,毫秒
- .execute();
- log.info(agvurl);
- log.info("任务号:{},指令号{},状态{},下发agv订单序列反馈:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body());
-
- return result;
- } else {
- return null;
- }
- }
-
- @Override
- public HttpResponse addOrderSequences(Instruction inst) throws Exception {
- JSONObject orderjo = createOrederData(inst, "1");
- log.info("指令号:{},追加agv订单序列参数:{}", inst.getInstruction_code(), orderjo.toString());
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + inst.getInstruction_code();
-
- HttpResponse result = HttpRequest.post(agvurl)
- .body(String.valueOf(orderjo))//表单内容
- .timeout(20000)//超时,毫秒
- .execute();
- log.info(agvurl);
- log.info("任务号:{},指令号{},状态{},追加agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body());
-
- return result;
- } else {
- return null;
- }
- }
-
- @Override
- public String sendOrderSequencesParam(Instruction inst) throws Exception {
- JSONObject jo = new JSONObject();
- jo.put("intendedVehicle", "");
- jo.put("category", "Park");
- jo.put("failureFatal", true);
- jo.put("complete", false);
- JSONArray transports = new JSONArray();
- JSONObject orderjo = createOrederData(inst, "0");
- JSONObject order = new JSONObject();
- orderjo.put("order", order);
- orderjo.put("name", inst.getInstruction_code());
- transports.add(orderjo);
- jo.put("transports", transports);
- return jo.toString();
- }
-
- @Override
- public JSONObject createOrederData(Instruction inst, String inst_type) {
- String inst_code = inst.getInstruction_code();
- String task_code = inst.getTask_code();
- String compound_inst_data = inst.getCompound_inst_data();
- String[] str = null;
- List pathlist = null;
- if (!StrUtil.isEmpty(compound_inst_data)) {
- str = compound_inst_data.split("->");
- pathlist = Arrays.asList(str);
- }
- JSONArray ja = new JSONArray();
- JSONObject orderjo = new JSONObject();
-
- //1表示追加任务,需将task_code赋值给wrappingSequence
- if (StrUtil.equals("1", inst_type)) {
- orderjo.put("wrappingSequence", task_code);
- }
- String instno = inst.getInstruction_code();
- //指定agv车号 暂时不用
- //orderjo.put("intendedVehicle", "");
- //设置任务最终时间
- orderjo.put("deadline", getNextDay(1));
- orderjo.put("category", "");
- //拼接起点子任务动作,待完善,动作码需要从数据库取值
- int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE));
-
- switch (type) {
- case 3:
- break;
- case 4:
- if (StrUtil.equals(inst.getCompound_inst(), "1")) {
- for (int i = 0; i < pathlist.size(); i++) {
- String device_code = pathlist.get(i);
- Device device = deviceAppService.findDeviceByCode(device_code);
- if (ObjectUtil.isEmpty(device)) {
- throw new BadRequestException("未找到该设备【" + device_code + "】");
- }
-
- MachinesSiteDeviceDriver machinesSiteDeviceDriver;
- if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) {
- ja.add(destination2(device_code + "IN", "Wait", "1", device_code + "IN"
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(device_code, "Wait", "1", device_code
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(device_code + "OUT", "Wait", "1", device_code + "OUT"
- + "-" + inst_code + "-" + "01"));
-
- } else {
- ja.add(destination2(device_code, "Wait", "1", device_code + "-" + inst_code + "-" + "01"));
- }
- }
-
- ja.add(destination2(inst.getNext_point_code(), "Wait", "1", inst.getNext_point_code() + "-" + inst_code + "-" + "01"));
-
- } else {
- String startAddress = inst.getStart_device_code();
- String nextAddress = inst.getNext_device_code();
- //追加则下发目标点 不追加就下方起点、目标点
- if (StrUtil.equals("1", inst_type)) {
- Device device = deviceAppService.findDeviceByCode(nextAddress);
- MachinesSiteDeviceDriver machinesSiteDeviceDriver;
- if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) {
- ja.add(destination2(startAddress, "Wait", "5", startAddress
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(nextAddress + "IN", "Wait", "1", nextAddress + "IN"
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(nextAddress, "Wait", "1", nextAddress
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(nextAddress + "OUT", "Wait", "1", nextAddress + "OUT"
- + "-" + inst_code + "-" + "01"));
- } else {
- ja.add(destination2(startAddress, "Wait", "1", startAddress
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(nextAddress, "Wait", "1", nextAddress
- + "-" + inst_code + "-" + "01"));
- }
-
- } else {
- ja.add(destination2(startAddress, "Wait", "1", startAddress
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(nextAddress, "Wait", "1", nextAddress
- + "-" + inst_code + "-" + "01"));
- }
- }
- break;
- case 6:
- String startAddress = inst.getStart_device_code();
- String nextAddress = inst.getNext_device_code();
- Device startdevice = deviceAppService.findDeviceByCode(startAddress);
- Device nextdevice = deviceAppService.findDeviceByCode(nextAddress);
- StandardManipulatorInspectSiteDeviceDriver standardManipulatorInspectSiteDeviceDriver;
- StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
- //起点
- if (startdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) {
-
- ja.add(destination2(startAddress + "IQ", "Wait", "1", startAddress + "IQ"
- + "-" + inst_code + "-" + "07"));
- ja.add(destination2(startAddress + "IN", "Wait", "1", startAddress + "IN"
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(startAddress, "Load", "3", startAddress
- + "-" + inst_code + "-" + "02"));
- ja.add(destination2(startAddress + "OUT", "Wait", "1", startAddress + "OUT"
- + "-" + inst_code + "-" + "05"));
- ja.add(destination2(startAddress + "OQ", "Wait", "1", startAddress + "OQ"
- + "-" + inst_code + "-" + "08"));
-
- } else if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
-
- ja.add(destination2(startAddress + "IN", "Wait", "1", startAddress + "IN"
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(startAddress, "Load", "3", startAddress
- + "-" + inst_code + "-" + "02"));
- ja.add(destination2(startAddress + "OUT", "Wait", "1", startAddress + "OUT"
- + "-" + inst_code + "-" + "05"));
-
- } else {
- ja.add(destination2(nextAddress, "Wait", "1", startAddress
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(startAddress, "Load", "3", startAddress
- + "-" + inst_code + "-" + "01"));
- }
-
- //终点
- if (nextdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) {
- ja.add(destination2(nextAddress + "IQ", "Wait", "1", nextAddress + "IQ"
- + "-" + inst_code + "-" + "07"));
- ja.add(destination2(nextAddress + "IN", "Wait", "1", nextAddress + "IN"
- + "-" + inst_code + "-" + "03"));
- ja.add(destination2(nextAddress, "ForkLoad", "3", nextAddress
- + "-" + inst_code + "-" + "04"));
- ja.add(destination2(nextAddress + "OUT", "Wait", "1", nextAddress + "OUT"
- + "-" + inst_code + "-" + "06"));
- ja.add(destination2(nextAddress + "OQ", "Wait", "1", nextAddress + "OQ"
- + "-" + inst_code + "-" + "08"));
- } else if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
- ja.add(destination2(nextAddress + "IN", "Wait", "1", nextAddress + "IN"
- + "-" + inst_code + "-" + "03"));
- ja.add(destination2(nextAddress, "ForkLoad", "3", nextAddress
- + "-" + inst_code + "-" + "04"));
- ja.add(destination2(nextAddress + "OUT", "Wait", "1", nextAddress + "OUT"
- + "-" + inst_code + "-" + "06"));
- } else {
- ja.add(destination2(nextAddress, "Wait", "1", nextAddress
- + "-" + inst_code + "-" + "01"));
- ja.add(destination2(nextAddress, "ForkLoad", "3", nextAddress
- + "-" + inst_code + "-" + "01"));
- }
- break;
- }
-
- orderjo.put("destinations", ja);
- JSONObject prijo = new JSONObject();
- prijo.put("key", "duration");
- prijo.put("value", "101");
-
- JSONArray prija = new JSONArray();
- prija.add(prijo);
- orderjo.put("properties", prija);
-
- return orderjo;
- }
-
- @Override
- public HttpResponse pause() throws Exception {
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/vehicles/pause";
- log.info("暂停所有agv请求:{}", agvurl);
-
- HttpResponse result = HttpRequest.post(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("暂停所有agv请求反馈:{}", result);
- String type = "";
- if (result.getStatus() == 200) {
- type = "info";
- } else {
- type = "error";
- }
- logServer.log("", "pause", type, "", result.body(), String.valueOf(result.getStatus()), agvurl, "");
- return result;
- } else {
- return null;
- }
- }
-
- @Override
- public HttpResponse pause(String device_code) throws Exception {
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/vehicles/" + device_code + "/pause";
- log.info("暂停{} agv请求:{}", device_code, agvurl);
-
- HttpResponse result = HttpRequest.post(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("暂停{} agv请求反馈:{}", device_code, result);
- String type = "";
- return result;
- } else {
- return null;
- }
- }
-
- @Override
- public HttpResponse resume() throws Exception {
-
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/vehicles/resume";
- log.info("恢复所有agv请求:{}", agvurl);
-
- HttpResponse result = HttpRequest.post(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("恢复所有agv请求反馈:{}", result);
- String type = "";
- if (result.getStatus() == 200) {
- type = "info";
- } else {
- type = "error";
- }
- logServer.log("", "resume", type, "", result.body(), String.valueOf(result.getStatus()), agvurl, "");
- return result;
- } else {
- return null;
- }
- }
-
- @Override
- public HttpResponse resume(String device_code) throws Exception {
- if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
- String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
- String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
-
- agvurl = agvurl + ":" + agvport + "/v1/vehicles/" + device_code + "/resume";
- log.info("恢复{} agv请求:{}", device_code, agvurl);
-
- HttpResponse result = HttpRequest.post(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("恢复{} agv请求反馈:{}", device_code, result);
-
- return result;
- } else {
- return null;
- }
- }
-
- @Override
- public String queryDeviceStation() {
- return null;
- }
-
- String hexToString(int i) {
- return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase();
- }
-
-
- public static int IntToHexHigh(int b) {
- int big = (b & 0xFF00) >> 8;
- return big;
- }
-
- public static int IntToHexLow(int b) {
- int little = b & 0xFF;
- return little;
- }
-
-
- public static String Bytes2HexString(byte[] b) {
- String ret = "";
- for (int i = 0; i < b.length; i++) {
- String hex = Integer.toHexString(b[i] & 0xFF);
- if (hex.length() == 1) {
- hex = '0' + hex;
- }
- ret += hex.toUpperCase();
- }
- return ret;
- }
-
- public static void main(String[] args) {
- String address = "L1-01-01";
- if (address.indexOf("-") > 0) {
- String str = address.substring(address.indexOf("-"), address.length());
- address = address.substring(0, address.indexOf("-"));
- System.out.println(address);
- }
- }
-}
diff --git a/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java b/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java
index ff6b4f1..4584a1b 100644
--- a/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java
+++ b/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java
@@ -214,7 +214,6 @@ public class DeviceController {
@ApiOperation("改变电子围栏状态")
//@PreAuthorize("@el.check('device:add')")
public ResponseEntity