findAllAgvFromCache();
-
- /**
- * 查询自动门状态
- *
- * @param device
- * @return
- */
- public String queryDoorStatus(String device);
-
- /**
- * 先工agv 等待点请求
- * AGV->ACS
- * @param param
- * @return
- */
- public String waitPointRequest(String param);
-
- /**
- * acs->agv
- * 关闭运单系列
- *
- * @param code
- * @return
- * @throws Exception
- */
- public HttpResponse markComplete(String code) throws Exception;
-
- /**
- * 查询AGV状态
- *
- * @return
- */
- public HttpResponse queryXZAgvDeviceStatus();
-
- /**
- * 查询AGV任务状态
- * @param instCode
- * @return
- */
- public HttpResponse queryXZAgvInstStatus(String instCode);
-
- /**
- * 删除先知任务
- *
- * @param instCode
- * @return
- */
- public HttpResponse deleteXZAgvInst(String instCode);
-
-
- /**
- * 下发运单序列
- *
- * @param inst
- * @return
- * @throws Exception
- */
- public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception;
-
- /**
- * 追加运单
- * @param inst
- * @return
- * @throws Exception
- */
- public HttpResponse addOrderSequences(Instruction inst) throws Exception;
-
- /**
- * 组织json数据
- * @param inst
- * @return
- * @throws Exception
- */
- public String sendOrderSequencesParam(Instruction inst) throws Exception;
-
-
- /**
- * 创建
- * @param inst
- * @param type
- * @return
- */
- public JSONObject createOrederData(Instruction inst, String type);
-
- /**
- * 请求取货放货
- * @param requestParam
- * @return
- */
- JSONObject xgAGVWaitPointRequest(JSONObject requestParam);
-
-
- /**
- * 查询场景中指定机器人信息
- */
- HttpResponse getRobotInfo(String robotCode);
-
- /**
- * 下发叉车运单
- *
- * @param dto
- * @param interactionJsonDTO
- * @return
- */
- HttpResponse sendOrderSequencesToForklift(Instruction dto, InteractionJsonDTO interactionJsonDTO);
-
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/ZheDaAgvService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/ZheDaAgvService.java
deleted file mode 100644
index 7e43c63..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/ZheDaAgvService.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.nl.acs.agv.server;
-
-
-import cn.hutool.http.HttpResponse;
-import org.nl.acs.instruction.domain.Instruction;
-
-/**
- * 浙大AGV服务
- * @author 20220102CG\noblelift
- */
-public interface ZheDaAgvService {
-
- /**
- * 下发指令
- *
- * @param inst 指令对象
- * @return
- * @throws Exception
- */
- public HttpResponse sendAgvInstToAgv(Instruction inst) throws Exception;
-
- /**
- * 查询AGV状态
- * 永裕家居项目:共两楼
- *
- * @param floor 1、二楼AGV系统;2、一楼AGV系统
- * @return
- */
- public HttpResponse queryAgvInstStatus(String floor);
-
- /**
- * AGV任务处理
- * @param jobno
- * @param type
- * @param address
- * @param action
- * @param processingVehicle
- * @return
- */
- String process(String jobno, String type, String address, String action, String processingVehicle);
-
- /**
- * 标记完成
- *
- * @param code
- * @return
- */
- public HttpResponse markComplete(String code);
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java
deleted file mode 100644
index 97f7cf2..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.nl.acs.agv.server.dto;
-
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * @author wangsong
- */
-@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/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
deleted file mode 100644
index 8786b5b..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.nl.acs.agv.server.impl;
-
-import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.AcsConfig;
-import org.nl.acs.agv.server.AgvService;
-import org.nl.acs.agv.server.dto.AgvDto;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.device.enums.DeviceType;
-import org.nl.acs.task.service.TaskService;
-import org.nl.common.exception.BadRequestException;
-import org.nl.system.service.param.ISysParamService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author 20220102CG\noblelift
- */
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class AgvServiceImpl implements AgvService {
-
- @Autowired
- DeviceAppService deviceAppService;
- @Autowired
- TaskService taskService;
- @Autowired
- InstructionService instructionService;
-
- @Autowired
- ISysParamService paramService;
- @Autowired
- AcsToWmsService acsToWmsService;
-
- Map AGVDeviceStatus = new HashMap();
-
-
- @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 String requestOpenOrCloseDoor(String device_code, String param) {
- log.info("AGV请求开关门参数,设备:{},参数:{}", device_code, param);
- int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue());
- switch (type) {
- case 4:
- acsToWmsService.applyOpenOrCloseDoor(device_code, param);
- break;
- default:
- break;
-
- }
- return null;
- }
-
-
- @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;
- JSONObject jo = JSONObject.parseObject(mes);
- ja.add(jo);
- }
- log.info("AGV查询全部自动门状态,反馈:{}", ja.toString());
- return ja.toString();
- }
-
-
- /*public static void main(String[] args) {
- String address = "L1-01-01";
- if (address.indexOf(my_separator) > 0) {
- String str = address.substring(address.indexOf("-"), address.length());
- address = address.substring(0, address.indexOf("-"));
- }
- }*/
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java
deleted file mode 100644
index b5025ee..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java
+++ /dev/null
@@ -1,804 +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.AcsConfig;
-import org.nl.acs.agv.AgvUtil;
-import org.nl.acs.agv.server.MagicAgvService;
-import org.nl.acs.agv.server.dto.AgvDto;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver;
-import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.opc.DeviceAppServiceImpl;
-import org.nl.acs.device.enums.DeviceType;
-import org.nl.common.exception.BadRequestException;
-import org.nl.config.language.LangProcess;
-import org.nl.system.service.param.ISysParamService;
-import org.nl.config.SpringContextHolder;
-import org.springframework.stereotype.Service;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author 20220102CG\noblelift
- */
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class MagicAgvServiceImpl implements MagicAgvService {
-
- private final DeviceAppService deviceAppService;
- private final ISysParamService paramService;
- private final AcsToWmsService acsToWmsService;
-
-
-
- Map AGVDeviceStatus = new HashMap();
- /**
- * 进入离开等待
- */
- private static final String ONE = "1";
- /**
- * 进入等待 离开不等待
- */
- private static final String TWO = "2";
- /**
- * 进入不等待 离开等待
- */
- private static final String THREE = "3";
- /**
- * 不等待
- */
- private static final String FOUR = "4";
- private static final String FIVE = "5";
-
- /**
- * 1请求取货
- */
- private static final String INST_ONE = "1";
- /**
- * 2取货完成离开
- */
- private static final String INST_TWO = "2";
- /**
- * 3请求放货
- */
- private static final String INST_THREE = "3";
- /**
- * 4放货完成离开
- */
- private static final String INST_FOUR = "4";
-
- /**
- * 请求进入
- */
- private static final String ON_ENTRY = "onEntry";
- /**
- * 请求取货
- */
- private static final String LOAD = "load";
- /**
- * 请求放货
- */
- private static final String UNLOAD = "Unload";
- /**
- * 取货放货完成
- */
- private static final String ON_STATION = "onStation";
- /**
- * 取货完成离开
- */
- private static final int PICKUP_COMPLETE_TWO = 2;
- /**
- * 放货完成离开
- */
- private static final int DELIVERY_COMPLETE_FOUR = 4;
-
-
-
-
- @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 HttpResponse queryAgvInstStatus(String instCode) {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instCode;
-
- HttpResponse result = HttpRequest.get(agvurl)
- //超时,毫秒
- .timeout(20000)
- .execute();
- log.info("查询agv指令数据:" + result.body());
- return result;
- } else {
- return null;
- }
-
- }
-
-
- @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(CommonFinalParam.TWO, 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(LangProcess.msg("device_checkNull", device_code));
- }
- if (i == 0) {
- ja.add(destination(device_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE));
- } else if (i == pathlist.size() - 1) {
- ja.add(destination(device_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
- } else {
- ja.add(destination(device_code, "NOP", CommonFinalParam.ONE, "5"));
- }
-
- }
-
- //指定agv车号 暂时不用 设置任务最终时间
- //orderjo.put("intendedVehicle", "");
- orderjo.put("deadline", AgvUtil.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", AgvUtil.getNextDay(1));
- //拼接起点子任务动作,待完善,动作码需要从数据库取值
- ja.add(destination(startAddress, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE));
- //拼接终点子任务动作,待完善,动作码需要从数据库取值
- ja.add(destination(nextAddress, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
-
- 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(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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;
- }
-
- }
-
- /**
- * 返回一个点位操作子任务
- *
- * @param locationName 点位
- * @param operation 点位操作
- * @param propertiesType 子任务类型
- * @param pro 子任务参数
- * 调用demo:destination("sh15p", "Spin", CommonFinalParam.TWO, "3.14")
- * demo:destination("cz14", "JackUnload", CommonFinalParam.THREE, "")
- * @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 (CommonFinalParam.ONE.equals(propertiesType)) {
-
- //pro 1 进入离开等待
- if (ONE.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 (TWO.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 (THREE.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 if (FOUR.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", "False");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- } else if (FIVE.equals(pro)) {
- JSONArray properties = new JSONArray();
- JSONObject pro2 = new JSONObject();
- pro2.put("key", "PauseOnStation");
- pro2.put("value", "True");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- }
- //Spin转动
- } else if (CommonFinalParam.TWO.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- //坐标系类型,global_spin_angle为全局坐标系
- pro1.put("key", "global_spin_angle");
- //弧度值,如3.14
- pro1.put("value", pro);
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- //固定值
- pro2.put("key", "spin_direction");
- //弧度值,如0
- pro2.put("value", "0");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //JackUnload,Jackload不操作
- } else if (CommonFinalParam.THREE.equals(propertiesType)) {
- 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 (CommonFinalParam.FOUR.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- //坐标系类型,robot_spin_angle为机器人坐标系
- pro1.put("key", "robot_spin_angle");
- //弧度值,如3.14
- pro1.put("value", pro);
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- //固定值
- pro2.put("key", "spin_direction");
- //弧度值,如0
- pro2.put("value", "0");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- }
- return destinationOrder;
- }
-
-
- @Override
- public HttpResponse queryMagicAgvDeviceStatus() {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
- agvurl = agvurl + ":" + agvport + "/v1/vehicles";
- HttpResponse result = HttpRequest.get(agvurl)
- //超时,毫秒
- .timeout(20000)
- .execute();
- log.info("查询agv状态数据:{}", result.body());
- if (result.getStatus() == CommonFinalParam.STATUS_OPEN) {
- 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 deleteAgvInst(String instCode) {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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;
- }
-
- }
-
- /**
- * 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
- * @param jobno
- * @param type
- * @param address
- * @param action
- * @param processingVehicle
- * @return
- */
-
- @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(CommonFinalParam.DOT) > 0) {
- str = address.substring(address.indexOf(CommonFinalParam.DOT), address.length());
- address = address.substring(0, address.indexOf(CommonFinalParam.DOT));
- } else if (address.indexOf(CommonFinalParam.HYPHEN_) > 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;
- //请求进入
- if (ON_ENTRY.equals(type)) {
-
- if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
- standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver();
- //请求取货
- if (LOAD.equals(action)) {
- if (standardInspectSiteDeviceDriver.getMode() == CommonFinalParam.DEVICE_MODE_TWO && standardInspectSiteDeviceDriver.getMove() > CommonFinalParam.DEVICE_MOVE_ZERO) {
- inst.setExecute_status(INST_ONE);
- is_feedback = true;
- }
- //请求放货
- } else if (UNLOAD.equals(action)) {
- if (standardInspectSiteDeviceDriver.getMode() == CommonFinalParam.DEVICE_MODE_TWO && standardInspectSiteDeviceDriver.getMove() == CommonFinalParam.DEVICE_MOVE_ZERO) {
- inst.setExecute_status(INST_THREE);
- is_feedback = true;
- }
- }
- }
-
-
- if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
- //请求取货
- if (LOAD.equals(action)) {
- if (addressdevice.getHas_goods() > 0) {
- inst.setExecute_status(INST_ONE);
- is_feedback = true;
- }
- //请求放货
- } else if (UNLOAD.equals(action)) {
- if (addressdevice.getHas_goods() == 0) {
- inst.setExecute_status(INST_THREE);
- is_feedback = true;
- }
- }
- }
-
-
- //取放货完成
- } else if (ON_STATION.equals(type)) {
- System.out.println("取放货完成");
- if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
- standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver();
- //取货完成
- if (LOAD.equals(action)) {
- if (standardInspectSiteDeviceDriver.getMode() == CommonFinalParam.DEVICE_MODE_TWO && standardInspectSiteDeviceDriver.getMove() == CommonFinalParam.DEVICE_MOVE_ZERO) {
- inst.setExecute_device_code(processingVehicle);
- inst.setExecute_status(INST_TWO);
- is_feedback = true;
- }
- //放货完成
- } else if (UNLOAD.equals(action)) {
- if (standardInspectSiteDeviceDriver.getMode() == CommonFinalParam.DEVICE_MODE_TWO && standardInspectSiteDeviceDriver.getMove() > CommonFinalParam.DEVICE_MOVE_ZERO) {
- inst.setExecute_device_code(address);
- inst.setExecute_status(INST_FOUR);
- is_feedback = true;
- }
- }
- }
-
-
- if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
- //取货完成
- if (LOAD.equals(action)) {
- inst.setExecute_device_code(processingVehicle);
- inst.setExecute_status(CommonFinalParam.TWO);
- is_feedback = true;
- //放货完成
- } else if (UNLOAD.equals(action)) {
- inst.setExecute_device_code(address);
- inst.setExecute_status(INST_FOUR);
- 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 (ON_STATION.equals(type)) {
- param = "EntryPermitted-" + backaddress + action;
- } else if (ON_STATION.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 = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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 requestAck(String address) {
- log.info("AGV请求离开参数:{}", address);
- boolean flag = false;
-
- if (address.indexOf(CommonFinalParam.DOT) > 0) {
- address = address.substring(0, address.indexOf("."));
- }
- if (address.indexOf(CommonFinalParam.HYPHEN_) > 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;
-
- if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
- standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver();
- flag = true;
- log.info("agvstatus:" + standardInspectSiteDeviceDriver.getFlag() + "");
- //取货完成离开
- if (standardInspectSiteDeviceDriver.getFlag() == PICKUP_COMPLETE_TWO) {
- if (standardInspectSiteDeviceDriver.getMove() == 0) {
- flag = true;
- standardInspectSiteDeviceDriver.setFlag(5);
- }
- }
- //放货完成离开
- if (standardInspectSiteDeviceDriver.getFlag() == DELIVERY_COMPLETE_FOUR) {
- 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() == PICKUP_COMPLETE_TWO) {
- flag = true;
- standardOrdinarySiteDeviceDriver.setFlag(5);
- }
- //放货完成离开
- if (standardOrdinarySiteDeviceDriver.getFlag() == DELIVERY_COMPLETE_FOUR) {
- 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 HttpResponse pause() throws Exception {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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() == CommonFinalParam.STATUS_OPEN) {
- type = "info";
- } else {
- type = "error";
- }
- return result;
- } else {
- return null;
- }
- }
-
-
-
- @Override
- public HttpResponse pause(String device_code) throws Exception {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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() == CommonFinalParam.STATUS_OPEN) {
- type = "info";
- } else {
- type = "error";
- }
- return result;
- } else {
- return null;
- }
-
-
- }
-
-
- @Override
- public HttpResponse resume(String device_code) throws Exception {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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 queryDoorStatus(String device) {
- log.info("AGV查询自动门状态,参数:{}", device);
- int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue());
- switch (type) {
- case 4:
- if (StrUtil.equals(paramService.findByCode(AcsConfig.HASOTHERSYSTEM).getValue(), CommonFinalParam.ONE)) {
- String result = acsToWmsService.queryDoorsStatus().body();
- JSONArray ja = JSONArray.parseArray(result);
- log.info("AGV查询自动门状态,反馈:{}", ja.toString());
- return ja.toString();
- }
- return null;
- default:
- if (StrUtil.equals(CommonFinalParam.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(LangProcess.msg("device_checkNull", list.get(i).getDevice_code()));
- }
- String mes = null;
-
- }
- log.info("AGV查询自动门状态,反馈:{}", ja.toString());
- return ja.toString();
-
- } else {
- Device doordevice = deviceAppService.findDeviceByCode(device);
- if (ObjectUtil.isEmpty(doordevice)) {
- throw new BadRequestException(LangProcess.msg("device_checkNull", device));
- }
- String mes = null;
- JSONObject jo = JSONObject.parseObject(mes);
- log.info("AGV查询自动门状态,反馈:{}", jo.toString());
- return jo.toString();
- }
- }
- }
-
- @Override
- public Map findAllAgvFromCache() {
- return AGVDeviceStatus;
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java
deleted file mode 100644
index fb299fe..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java
+++ /dev/null
@@ -1,644 +0,0 @@
-package org.nl.acs.agv.server.impl;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.AcsConfig;
-import org.nl.acs.agv.server.NDCAgvService;
-import org.nl.acs.agv.server.dto.AgvDto;
-import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
-import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.service.DeviceService;
-import org.nl.acs.device.service.impl.DeviceServiceImpl;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.log.service.DeviceExecuteLogService;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.opc.DeviceAppServiceImpl;
-import org.nl.common.exception.BadRequestException;
-import org.nl.system.service.dict.ISysDictService;
-import org.nl.system.service.dict.dao.Dict;
-import org.nl.system.service.param.ISysParamService;
-import org.nl.common.utils.CodeUtil;
-import org.nl.config.SpringContextHolder;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author 20220102CG\noblelift
- */
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class NDCAgvServiceImpl implements NDCAgvService {
-
- private final DeviceAppService deviceAppService;
- private final ISysParamService paramService;
-// private final AcsToWmsService acsToWmsService;
- private final ISysDictService dictService;
- private final DeviceExecuteLogService logServer;
-
- Map AGVDeviceStatus = new HashMap();
-
-
- @Override
- public void deleteAgvInstToNDC(Instruction inst) throws Exception {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- 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);
- TwoNDCSocketConnectionAutoRun.write(b);
- System.out.println("下发删除agv指令数据:" + Bytes2HexString(b));
- }
-
- }
-
-
- @Override
- public void sendAgvInstToNDC(String agv_system_type, Instruction inst) {
- log.info("sendAgvInstToNDC 指令下发NDC:" + "inst_code:" + inst.getInstruction_code() + ",agv_system_type:" + agv_system_type + ",agv_inst_type:" + inst.getAgv_inst_type() +
- ",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() +
- ",nextAddress:" + inst.getNext_point_code());
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
- if (!StrUtil.equals(agv_system_type, "1")) {
- String instcode = inst.getInstruction_code();
- int type = Integer.parseInt(inst.getAgv_inst_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());
- int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2());
- int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2());
- 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 qhdhigh2 = (byte) IntToHexHigh(startAddress2);
- byte qhdlow2 = (byte) IntToHexLow(startAddress2);
- byte fhdhigh = (byte) IntToHexHigh(nextAddress);
- byte fhdlow = (byte) IntToHexLow(nextAddress);
- byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2);
- byte fhdlow2 = (byte) IntToHexLow(nextAddress2);
- 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 += "取货点2 /qhd2:" + (startAddress2);
- str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF);
- str += "放货点2 /fhd2:" + (nextAddress2);
- str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF);
-
- str += "优先级 /priority:" + (priority);
- str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
-
- byte[] b = new byte[]{};
- if (type == 1) {
- b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X16,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X71,
- (byte) 0X00, (byte) 0X12,
- (byte) 0X01, prioritylow,
- (byte) 0X00, (byte) 0X01,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) typehigh, (byte) typelow,
- (byte) qhdhigh, (byte) qhdlow,
- (byte) qhdhigh2, (byte) qhdlow2,
- (byte) fhdhigh, (byte) fhdlow,
- (byte) fhdhigh2, (byte) fhdlow2
- };
- } else if (type == 2) {
- b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X16,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X71,
- (byte) 0X00, (byte) 0X12,
- (byte) 0X01, prioritylow,
- (byte) 0X00, (byte) 0X01,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) typehigh, (byte) typelow,
- (byte) qhdhigh, (byte) qhdlow,
- (byte) 0X00, (byte) 0X00,
- (byte) fhdhigh, (byte) fhdlow,
- (byte) 0X00, (byte) 0X00
- };
- } else if (type == 3) {
- b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X16,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X71,
- (byte) 0X00, (byte) 0X12,
- (byte) 0X01, prioritylow,
- (byte) 0X00, (byte) 0X01,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) typehigh, (byte) typelow,
- (byte) qhdhigh, (byte) qhdlow,
- (byte) qhdhigh2, (byte) qhdlow2,
- (byte) fhdhigh, (byte) fhdlow,
- (byte) fhdhigh2, (byte) fhdlow2
- };
- }
- log.info("下发AGV作业指令 --{}", str1);
- log.info("下发AGV作业指令--{}", str);
- log.info("下发agv指令数据--{}", Bytes2HexString(b));
-
- if (StrUtil.equals(agv_system_type, "2")) {
- TwoNDCSocketConnectionAutoRun.write(b);
- }
- } else {
-
- String instcode = inst.getInstruction_code();
- int startHeight = Integer.parseInt(StrUtil.isEmpty(inst.getStart_height()) ? "0" : inst.getStart_height());
- int nextHeight = Integer.parseInt(StrUtil.isEmpty(inst.getNext_height()) ? "0" : inst.getNext_height());
- //默认取货放货高度都为0
- //int type = Integer.parseInt(inst.getInstruction_type());
- int type = 4;
- if (startHeight != 0 && nextHeight != 0) {
- //取货放货高度都不为0
- type = 1;
- } else if (startHeight != 0 && nextHeight == 0) {
- //取货高度不为0 放货高度为0
- type = 2;
- } else if (startHeight == 0 && nextHeight != 0) {
- //取货高度为0 放货高度不为0
- type = 3;
- }
- 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);
-
- byte shhigh = (byte) IntToHexHigh(startHeight);
- byte shlow = (byte) IntToHexLow(startHeight);
-
- byte nhhigh = (byte) IntToHexHigh(nextHeight);
- byte nhlow = (byte) IntToHexLow(nextHeight);
-
- 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) 0X16,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X71,
- (byte) 0X00, (byte) 0X12,
- (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,
- (byte) shhigh, (byte) shlow,
- (byte) nhhigh, (byte) nhlow
- };
- log.info("下发AGV作业指令 --{}", str1);
- log.info("下发AGV作业指令--{}", str);
- log.info("下发agv指令数据--{}", Bytes2HexString(b));
- OneNDCSocketConnectionAutoRun.write(b);
- }
- }
- }
-
- @Override
- public byte[] sendAgvOneModeInst(int phase, int index, int result, int startPoint, int nextPoint, int startHigh, int nextHigh) {
- 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 startPointHigh = (byte) IntToHexHigh(startPoint);
- byte startPointLow = (byte) IntToHexLow(startPoint);
- byte nextPointHigh = (byte) IntToHexHigh(nextPoint);
- byte nextPointLow = (byte) IntToHexLow(nextPoint);
- byte startHighHigh = (byte) IntToHexHigh(startHigh);
- byte startHighLow = (byte) IntToHexLow(startHigh);
- byte nextHighHigh = (byte) IntToHexHigh(nextHigh);
- byte nextHighLow = (byte) IntToHexLow(nextHigh);
-
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X12,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6D,
- (byte) 0X00, (byte) 0X0E,
- (byte) indexhigh, (byte) indexlow,
- (byte) 0X01, (byte) 0X14,
- (byte) phasehigh, (byte) phaselow,
- (byte) startPointHigh, (byte) startPointLow,
- (byte) nextPointHigh, (byte) nextPointLow,
- (byte) startHighHigh, (byte) startHighLow,
- (byte) nextHighHigh, (byte) nextHighLow
- };
-
- 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 byte[] sendAgvTwoModeInst(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[] 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
- };
-
-
- 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 byte[] sendAgvTwoModeInst(int phase, int index, int result, int offset, int quantity) {
- 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 offsethigh = (byte) IntToHexHigh(offset);
- byte offsetlow = (byte) IntToHexLow(offset);
- byte quantityhigh = (byte) IntToHexHigh(quantity);
- byte quantitylow = (byte) IntToHexLow(quantity);
-
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0E,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X6D,
- (byte) 0X00, (byte) 0X0A,
- (byte) indexhigh, (byte) indexlow,
- (byte) 0X01, (byte) 0X12,
- (byte) phasehigh, (byte) phaselow,
- (byte) offsethigh, (byte) offsetlow,
- (byte) quantityhigh, (byte) quantitylow
- };
-
-
- log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:"
- + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF) + ",是否侧移: " + (offset == 1 ? "侧移" : "不测移") + ",偏离量: " + quantity);
-
- System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
- return b;
- }
-
- @Override
- public byte[] sendAgvTwoModeInst() {
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X00,
- (byte) 0X00, (byte) 0X04,
- };
- return b;
- }
-
-
- @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[] 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) 0X10,
- (byte) phasehigh, (byte) phaselow
- };
-
-
- 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 byte[] sendAgvTwoModeInst(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[] 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
- };
-
-
- 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 byte[] sendAgvOneModeInst(int phase, int index, int result) {
- return new byte[0];
- }*/
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void charge(String carno) {
- //检查数据字典station为0的参数
- //分配车辆
- Dict dict = dictService.getDictByName3("station",carno,null);
- int satation=0;
- if(ObjectUtil.isNotEmpty(dict)){
- log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1());
- return;
- }
- Dict temp = dictService.getDictByName2("station");
- if(ObjectUtil.isNotEmpty(temp)){
- satation = Integer.parseInt(temp.getPara1());
- }
- if(satation!=0){
- String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
- byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
- byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
- byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
- byte carlow = (byte) IntToHexLow(Integer.parseInt(carno));
- byte satationhigh = (byte) IntToHexHigh(satation);
- byte satationlow = (byte) IntToHexLow(satation);
- String str = "十进制下发:";
- String str1 = "十六进制下发:";
- str += "ikey:" + (Integer.parseInt(instcode));
- str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
- str += "carno:" + (Integer.parseInt(carno));
- str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
- str += "/satation:" + (satation);
- str1 += "/satation:" + hexToString(satationhigh & 0xFF) + hexToString(satationlow & 0xFF);
-
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0E,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X71,
- (byte) 0X00, (byte) 0X0A,
- (byte) 0X64, (byte) 0X80,
- (byte) 0X00, (byte) 0X01,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) carhigh, (byte) carlow,
- (byte) satationhigh, (byte) satationlow
-
- };
- log.info("下发AGV充电任务--{}", str1);
-
- try{
- OneNDCSocketConnectionAutoRun.write(b);
- } catch (Exception e){
- log.error("下发充电任务失败{}{}",e,e.getMessage());
- }
-
- temp.setValue("1");
- temp.setPara2(carno);
- temp.setPara3("下发充电");
- dictService.updateDetail(temp);
-
- }else{
- log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务",carno);
- }
- }
-
- @Override
- public boolean createChargingTaskToNDC(String carno) {
- byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
- byte carlow = (byte) IntToHexLow(Integer.parseInt(carno));
-
- String instcode = CodeUtil.getNewCode("INSTRUCT_NO");
- byte instcodehigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
- byte instcodelow = (byte) IntToHexLow(Integer.parseInt(instcode));
-
- String str = "十进制下发:";
- String str1 = "十六进制下发:";
- str += "carno:" + (Integer.parseInt(carno));
- str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
-
- str += "/instcode:" + (instcode);
- str1 += "/instcode:" + hexToString(instcodehigh & 0xFF) + hexToString(instcodelow & 0xFF);
-
- System.out.println(str);
- System.out.println(str1);
-
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0C,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X71,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X64, (byte) 0X80,
- (byte) 0X00, (byte) 0X01,
- (byte) instcodehigh, (byte) instcodelow,
- (byte) carhigh, (byte) carlow
- };
- log.info("下发AGV充电任务--{}", str1);
-
- try {
-// OneNDCSocketConnectionAutoRun.write(b);
- TwoNDCSocketConnectionAutoRun.write(b);
- } catch (Exception e) {
- e.getMessage();
- return false;
- }
- System.out.println("下发agv充电任务数据:" + Bytes2HexString(b));
- return true;
- }
-
- 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;
- }
-
-
- @Override
- public Map findAllAgvFromCache() {
- return AGVDeviceStatus;
- }
-
- @Override
- public void charge(String carno, String station) {
- //判断当前充电桩是否已下发充电任务
- Dict temp = dictService.getDictByName2("station", station);
- if (ObjectUtil.isNotEmpty(temp)) {
- int satation = 0;
- if(ObjectUtil.isNotEmpty(temp)){
- satation = Integer.parseInt(temp.getPara1());
- }
- String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
- byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
- byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
- byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
- byte carlow = (byte) IntToHexLow(Integer.parseInt(carno));
- byte satationhigh = (byte) IntToHexHigh(satation);
- byte satationlow = (byte) IntToHexLow(satation);
- String str = "十进制下发:";
- String str1 = "十六进制下发:";
- str += "ikey:" + (Integer.parseInt(instcode));
- str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
- str += "carno:" + (Integer.parseInt(carno));
- str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
- str += "/satation:" + (satation);
- str1 += "/satation:" + hexToString(satationhigh & 0xFF) + hexToString(satationlow & 0xFF);
- //todo 核对NDC协议
- byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
- (byte) 0X00, (byte) 0X08,
- (byte) 0X00, (byte) 0X0E,
- (byte) 0X00, (byte) 0X01,
- (byte) 0X00, (byte) 0X71,
- (byte) 0X00, (byte) 0X0A,
- (byte) 0X64, (byte) 0X80,
- (byte) 0X00, (byte) 0X01,
- (byte) ikeyhigh, (byte) ikeylow,
- (byte) carhigh, (byte) carlow,
- (byte) satationhigh, (byte) satationlow
-
- };
- log.info("下发AGV充电任务--{}", str1);
-
- try{
- OneNDCSocketConnectionAutoRun.write(b);
- temp.setValue("1");
- temp.setPara2(String.valueOf(carno));
- dictService.updateDetail(temp);
- } catch (Exception e){
- log.error("下发充电任务失败{}{}",e,e.getMessage());
- }
-
- } else {
- log.info("当前充电桩{}已被使用!请检查充电桩状态再操作!", station);
- throw new BadRequestException("当前充电桩已被使用或者车号不为空,请检查充电桩状态再操作!");
- }
- }
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java
deleted file mode 100644
index eccdd07..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java
+++ /dev/null
@@ -1,1547 +0,0 @@
-package org.nl.acs.agv.server.impl;
-
-import cn.hutool.core.util.IdUtil;
-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.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import jodd.util.StringUtil;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.AcsConfig;
-import org.nl.acs.agv.AgvUtil;
-import org.nl.acs.agv.AgvWaitUtil;
-import org.nl.acs.agv.server.XianGongAgvService;
-import org.nl.acs.agv.server.dto.AgvDto;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.instruction.service.dto.InteractionJsonDTO;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.device.enums.DeviceType;
-import org.nl.acs.task.enums.ActionTypeEnum;
-import org.nl.acs.task.enums.AgvActionTypeEnum;
-import org.nl.acs.task.enums.AgvSystemTypeEnum;
-import org.nl.acs.task.service.TaskService;
-import org.nl.acs.task.service.dto.TaskDto;
-import org.nl.common.exception.BadRequestException;
-import org.nl.config.language.LangProcess;
-import org.nl.config.lucene.service.LuceneExecuteLogService;
-import org.nl.config.lucene.service.dto.LuceneLogDto;
-import org.nl.system.service.param.ISysParamService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Service;
-
-import java.util.*;
-
-/**
- * @author 20220102CG\noblelift
- */
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class XianGongAgvServiceImpl implements XianGongAgvService {
- private final DeviceAppService deviceAppService;
- private final ISysParamService paramService;
- @Autowired
- @Lazy
- private AcsToWmsService acsToWmsService;
-
- @Autowired
- private InstructionService instructionService;
-
- @Autowired
- private TaskService taskserver;
-
- @Autowired
- private LuceneExecuteLogService luceneExecuteLogService;
- @Autowired
- private DeviceAppService deviceAppservice;
-
-
- @Autowired
- private AgvWaitUtil agvWaitUtil;
-
- Map AGVDeviceStatus = new HashMap();
-
- private static final String JACKLOAD_THREE = "3";
- private static final String FOUR = "4";
- private static final String WAIT_FIVE = "5";
-
- @Value("${agvToAcs.addr}")
- private String addr;
-
-
- @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);
- 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 HttpResponse markComplete(String code) throws Exception {
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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 queryXZAgvDeviceStatus() {
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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() == CommonFinalParam.STATUS_OPEN) {
- 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(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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 HttpResponse deleteXZAgvInst(String instCode) {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- agvurl = agvurl + ":" + agvport + "/terminate";
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("id", instCode);
- jsonObject.put("disableVehicle", false);
- log.info("删除agv指令请求agvurl:{}", agvurl);
- HttpResponse result = HttpRequest.post(agvurl)
- .body(jsonObject.toJSONString())
- .timeout(20000)
- .execute();
- log.info("删除agv指令请求反馈:{}", result);
- return result;
- } else {
- return null;
- }
- }
-
-
- @Override
- public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception {
- com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
- jo.put("id", inst.getInstruction_code());
- //运单封口,true=创建运单之后不可添加动作块;false=创建运单可以添加动作块
- if (AgvActionTypeEnum.ORDINARY.getCode().equals(inst.getAgv_action_type())) {
- jo.put("complete", true);
- } else {
- jo.put("complete", false);
- }
- //动作块
- jo.put("blocks", createBlocksData(inst));
- //运单优先级
- jo.put("priority", inst.getPriority());
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code("下发诺宝运单")
- .content("任务号:" + inst.getTask_code() + ",指令号:" + inst.getInstruction_code() + ",下发agv订单序列参数:" + jo)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- log.info("任务号:{},指令号{},下发诺宝运单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo);
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- agvurl = agvurl + ":" + agvport + "/setOrder";
-
- log.info(agvurl);
- HttpResponse result = HttpRequest.post(agvurl)
- //表单内容
- .body(String.valueOf(jo))
- //超时,毫秒
- .timeout(20000)
- .execute();
- LuceneLogDto logDto1 = LuceneLogDto.builder()
- .device_code("诺宝运单响应")
- .content("任务号:" + inst.getTask_code() + ",指令号:" + inst.getInstruction_code() + ",下发诺宝订单序列反馈参数:" + jo)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto1);
- log.info("任务号:{},指令号{},状态{},下发agv订单序列反馈:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body());
-
- return result;
- } else {
- return null;
- }
- }
-
- /**
- * 下发动作块信号
- *
- * @param inst
- * @return
- */
- public JSONArray createBlocksData(Instruction inst) {
- JSONArray ja = new JSONArray();
- String instruction_code = inst.getInstruction_code();
- String start_device_code = inst.getStart_device_code();
- String start_point_code = inst.getStart_point_code();
- String next_device_code = inst.getNext_device_code();
- String next_point_code = inst.getNext_point_code();
- Integer agv_action_type = inst.getAgv_action_type();
-
-
- //起点1
- sendStartDeviceOrder(ja, start_device_code, start_point_code, instruction_code, agv_action_type);
- //终点1
- sendEndDeviceOrder(ja, start_device_code, instruction_code, next_point_code, next_device_code, agv_action_type);
-
- return ja;
- }
-
- /**
- * 下发取货信号
- *
- * @param ja
- * @param pointCode 起始点位
- * @param device_code 起始设备
- * @param instCode 指令号
- * @param agv_action_type
- */
- public void sendStartDeviceOrder(JSONArray ja, String pointCode, String device_code, String instCode, Integer agv_action_type) {
- Device startDevice = deviceAppService.findDeviceByCode(device_code);
- //取货前等待
- JSONObject jo = new JSONObject();
- //动作块id
- jo.put("blockId", IdUtil.simpleUUID());
- //目的地名称
- if (AgvActionTypeEnum.IN_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) {
- jo.put("location", pointCode + "WAIT");
- } else {
- jo.put("location", pointCode + "INGET");
- }
- //执行脚本
- jo.put("operation", "script");
- if (AgvActionTypeEnum.IN_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) {
- jo.put("id", pointCode + "WAIT");
- } else {
- jo.put("id", pointCode + "INGET");
- }
- //通信脚本,动作前后与现场设备交互的场景
- jo.put("script_name", "userpy/interact.py");
- JSONObject script_args = new JSONObject();
- //更改为现场设备IP及PORT
- script_args.put("addr", addr);
- JSONObject data = new JSONObject();
- JSONObject reach = new JSONObject();
- reach.put("task_code", instCode);
- if (AgvActionTypeEnum.IN_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) {
- reach.put("address", pointCode + "WAIT");
- } else {
- reach.put("address", pointCode + "INGET");
- }
- data.put("reach", reach);
- script_args.put("data", data);
- script_args.put("protocol", "HTTP");
- jo.put("script_args", script_args);
- ja.add(jo);
-
- if (AgvActionTypeEnum.ORDINARY.getCode().equals(agv_action_type) || AgvActionTypeEnum.OUT_STOCK.getCode().equals(agv_action_type)) {
- //将货物顶起来,机器识别提升高度
- JSONObject jo1 = new JSONObject();
- jo1.put("blockId", IdUtil.simpleUUID());
- jo1.put("location", pointCode);
- jo1.put("operation", "JackLoad");
- inspectInStocckSet(pointCode, jo1);
- ja.add(jo1);
- JSONObject jo2 = new JSONObject();
- jo2.put("blockId", IdUtil.simpleUUID());
- jo2.put("location", pointCode + "OUTGET");
- jo2.put("operation", "script");
- jo2.put("id", pointCode + "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", instCode);
- reach2.put("address", pointCode + "OUTGET");
- data2.put("reach", reach2);
- script_args2.put("data", data2);
- script_args2.put("protocol", "HTTP");
- jo2.put("script_args", script_args2);
- ja.add(jo2);
- }
- }
-
- private void inspectInStocckSet(String pointCode, JSONObject jo1) {
- Device device = deviceAppservice.findDeviceByCode(pointCode);
- StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- String inspectInStocck = (String) device.getExtraValue().get("inspect_in_stocck");
- if (StrUtil.isNotEmpty(inspectInStocck) && inspectInStocck.equals("true")) {
- jo1.put("operationArgs", new JSONObject() {{
- put("recognize", false);
- }});
- } else {
- jo1.put("operationArgs", new JSONObject() {{
- put("recognize", true);
- }});
- }
- } else {
- jo1.put("operationArgs", new JSONObject() {{
- put("recognize", true);
- }});
- }
- }
-
- /**
- * 下发放货信号
- *
- * @param ja
- * @param device_code 起始设备
- * @param instCode 指令号
- * @param pointCode 终点点位
- * @param nextDeviceCode 终点设备
- * @param agv_action_type
- */
- public void sendEndDeviceOrder(JSONArray ja, String device_code, String instCode, String pointCode, String nextDeviceCode, Integer agv_action_type) {
- Device nextDevice = deviceAppService.findDeviceByCode(nextDeviceCode);
- if (!AgvActionTypeEnum.IN_STOCK.getCode().equals(agv_action_type)) {
- //放货前等待
- JSONObject jo3 = new JSONObject();
- jo3.put("blockId", IdUtil.simpleUUID());
- if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) {
- jo3.put("location", pointCode + "WAIT");
- } else {
- jo3.put("location", pointCode + "INPUT");
- }
- jo3.put("operation", "script");
- if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) {
- jo3.put("id", pointCode + "WAIT");
- } else {
- jo3.put("id", pointCode + "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", instCode);
- if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) {
- reach3.put("address", pointCode + "WAIT");
- } else {
- reach3.put("address", pointCode + "INPUT");
- }
- data3.put("reach", reach3);
- script_args3.put("data", data3);
- script_args3.put("protocol", "HTTP");
- jo3.put("script_args", script_args3);
- ja.add(jo3);
-
- if (AgvActionTypeEnum.ORDINARY.getCode().equals(agv_action_type)) {
- //将货物放下
- com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
- jo4.put("blockId", IdUtil.simpleUUID());
- jo4.put("location", pointCode);
- jo4.put("operation", "JackUnload");
- ja.add(jo4);
-
-
- //放货完成等待
- com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
- jo5.put("blockId", IdUtil.simpleUUID());
- jo5.put("location", pointCode + "OUTPUT");
- jo5.put("operation", "script");
- jo5.put("id", pointCode + "OUTPUT");
- jo5.put("script_name", "userpy/interact.py");
- com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
- script_args5.put("addr", addr);
- com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
- com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
- reach5.put("task_code", instCode);
- reach5.put("address", pointCode + "OUTPUT");
- data5.put("reach", reach5);
- script_args5.put("data", data5);
- script_args5.put("protocol", "HTTP");
- jo5.put("script_args", script_args5);
- ja.add(jo5);
- }
- }
-
- }
-
-
- @Override
- public HttpResponse addOrderSequences(Instruction inst) throws Exception {
- JSONObject orderjo = createOrederData(inst, CommonFinalParam.ONE);
- log.info("指令号:{},追加agv订单序列参数:{}", inst.getInstruction_code(), orderjo.toString());
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- 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(CommonFinalParam.ONE, inst_type)) {
- orderjo.put("wrappingSequence", task_code);
- }
- String instno = inst.getInstruction_code();
- //指定agv车号 暂时不用
- //orderjo.put("intendedVehicle", "");
- //设置任务最终时间
- orderjo.put("deadline", AgvUtil.getNextDay(1));
- orderjo.put("category", "");
- //拼接起点子任务动作,待完善,动作码需要从数据库取值
- int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue());
-
- switch (type) {
- case 3:
- break;
- case 4:
- 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);
- break;
- default:
- 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;
- }
-
-
- /**
- * 返回一个点位操作子任务 先知使用
- *
- * @param locationName 点位
- * @param operation 点位操作
- * @param propertiesType 子任务类型
- * @param pro 子任务参数
- * 调用demo:destination("sh15p", "Spin", CommonFinalParam.TWO, "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);
- //Wait请求是否继续
- if (CommonFinalParam.ONE.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro2 = new JSONObject();
- //固定值
- pro2.put("key", "device:queryAtExecuted");
- //pro为wait请求的标识,一般用点位拼接的字符串
- pro2.put("value", pro + ":wait");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //Spin转动
- } else if (CommonFinalParam.TWO.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- //坐标系类型,global_spin_angle为全局坐标系
- pro1.put("key", "global_spin_angle");
- //弧度值,如3.14
- pro1.put("value", pro);
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- //固定值
- pro2.put("key", "spin_direction");
- //弧度值,如0
- pro2.put("value", "0");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //JackUnload,Jackload不操作
- } else if (JACKLOAD_THREE.equals(propertiesType)) {
- 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 (FOUR.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- //坐标系类型,robot_spin_angle为机器人坐标系
- pro1.put("key", "robot_spin_angle");
- //弧度值,如3.14
- pro1.put("value", pro);
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- //固定值
- pro2.put("key", "spin_direction");
- //弧度值,如0
- pro2.put("value", "0");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //Wait请求是否继续
- } else if (WAIT_FIVE.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro2 = new JSONObject();
-
- destinationOrder.put("properties", "[]");
- }
- return destinationOrder;
- }
-
-
- @Override
- public String queryDoorStatus(String device) {
- log.info("AGV查询自动门状态,参数:{}", device);
- int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue());
- switch (type) {
- case 4:
- if (StrUtil.equals(paramService.findByCode(AcsConfig.HASOTHERSYSTEM).getValue(), CommonFinalParam.ONE)) {
- String result = acsToWmsService.queryDoorsStatus().body();
- JSONArray ja = JSONArray.parseArray(result);
- log.info("AGV查询自动门状态,反馈:{}", ja.toString());
- return ja.toString();
- }
- return null;
- default:
- if (StrUtil.equals(CommonFinalParam.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(LangProcess.msg("device_checkNull", list.get(i).getDevice_code()));
- }
- String mes = null;
- 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(LangProcess.msg("device_checkNull", device));
- }
- String mes = null;
- JSONObject jo = JSONObject.parseObject(mes);
- log.info("AGV查询自动门状态,反馈:{}", jo.toString());
- return jo.toString();
- }
- }
-
- }
-
- @Override
- public Map findAllAgvFromCache() {
- return AGVDeviceStatus;
- }
-
-
- @Override
- public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) {
- log.info("仙工AGV请求取放货,请求参数 - {}", requestParam);
- String inst_code = requestParam.getString("task_code");
- Instruction instructionDto = instructionService.findByCodeFromCache(inst_code);
- if (ObjectUtil.isEmpty(instructionDto)) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .content("请求失败,未找到指令!" + inst_code)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- throw new BadRequestException("请求失败,未找到指令!");
- }
- String address = requestParam.getString("address");
- if (StrUtil.isBlank(address)) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("请求失败,地址为空!" )
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- throw new BadRequestException("请求失败,地址为空!");
- }
- if (address.contains("IN") || address.contains("WAIT")) {
- String task_code = instructionDto.getTask_code();
- String deviceCodeNow;
- if (address.contains("WAIT")) {
- deviceCodeNow = address.substring(0, address.length() - 4);
- } else {
- deviceCodeNow = address.substring(0, address.length() - 5);
- }
- if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("设备号 " + deviceCodeNow + " 不存在!")
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
- }
- //一楼诺宝agv
- if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
-
- if (address.contains("GET")) {
- return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
- } else if (address.contains("PUT")) {
- return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
- }
- //如果是取货二次分配,取放货二次分配需要重新追加动作块
- if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
- Integer actionType = ActionTypeEnum.IN_STOCK.getCode();
- String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
- log.info("取货二次分配追加诺宝成功,新点位 - {}", newPointCode);
- JSONObject map = new JSONObject();
- map.put("status", 200);
- map.put("message", "取货二次分配追加诺宝成功!");
- return map;
- }
- //如果是放货二次分配,取放货二次分配需要重新追加动作块
- if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
- Integer actionType = ActionTypeEnum.OUT_STOCK.getCode();
- String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
-// sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), deviceCodeNow, instructionDto);
- log.info("放货二次分配追加诺宝成功,新点位 - {}", newPointCode);
- JSONObject map = new JSONObject();
- map.put("status", 200);
- map.put("message", "放货二次分配追加诺宝成功!");
- return map;
- }
- }
- //一楼叉车
- if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
- if (address.contains("GET")) {
- //取货前等待
- return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
- } else {
- //放货前二次分配
- if (address.contains("WAIT")) {
- String newPointCode = applyCCAgvTask(task_code, instructionDto);
-
- JSONObject map = new JSONObject();
- map.put("status", 200);
- map.put("message", "允许叉车放货!" + "点位" + newPointCode);
- log.info("允许仙工AGV放货,设备号 - {}", newPointCode);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("叉车允许放货" + "新点位:" + newPointCode + map )
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- return map;
- }
- //放货前等待
- if (address.contains("PUT")) {
- return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
- }
- }
- }
- }
- if (address.contains("OUT")) {
- String deviceCodeNow = address.substring(0, address.length() - 6);
- if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
- throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
- }
-
- if (address.contains("GET")) {
- //取货完成
- JSONObject jsonObject = agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto);
- if (StringUtil.equals("200", jsonObject.getString("status"))) {
- log.info("仙工AGV取货完成后离开,设备号 - {}", deviceCodeNow);
- return jsonObject;
- }
- } else if (address.contains("PUT")) {
- //放货完成
- JSONObject jsonObject = agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto);
- if (StringUtil.equals("200", jsonObject.getString("status"))) {
- log.info("仙工AGV放货完成后离开,设备号 - {}", deviceCodeNow);
- return jsonObject;
- }
-
- }
- }
-
- throw new BadRequestException("请求失败,IN OUT 站点错误!");
- }
-
- private String applyCCAgvTask(String task_code, Instruction instructionDto) {
- JSONObject param = new JSONObject();
- param.put("task_code", task_code);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("叉车二次分配请求lms,参数:" + task_code)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- String response = acsToWmsService.applySendOutTwo(param);
- JSONObject jo = JSON.parseObject(response);
- if (jo.getInteger("status") == 200) {
- LuceneLogDto logDto2 = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("叉车二次分配请求lms,参数,接口返回:" + jo)
- .build();
- logDto2.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto2);
- //二次分配更新点位
- updataTask(instructionDto, jo.getString("data"));
- //请求成功调用叉车追加动作块
- sendAddSequencesToCCAgv(instructionDto.getInstruction_code(), jo.getString("data"), instructionDto);
- return jo.getString("data");
-
- } else {
- LuceneLogDto logDto2 = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("叉车二次分配请求lms失败,返回参数:" + jo.getString("message"))
- .build();
- logDto2.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto2);
- throw new BadRequestException("叉车二次分配请求lms返回失败");
- }
- }
-
- private void sendAddSequencesToCCAgv(String instructionCode, String nextPoint, Instruction instructionDto) {
- com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
- jo.put("id", instructionCode);
- //动作块
- jo.put("blocks", createBlocksDataTowCCStart(nextPoint));
- //追加订单封口
- jo.put("complete", true);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("指令号:" + instructionCode + ",追加叉车运单参数:" + jo)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- log.info("任务号:{},指令号{},追加诺宝叉车运单:{}", instructionCode, instructionCode, jo);
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- agvurl = agvurl + ":" + agvport + "/addBlocks";
-
- log.info(agvurl);
- HttpResponse result = HttpRequest.post(agvurl)
- //表单内容
- .body(String.valueOf(jo))
- //超时,毫秒
- .timeout(20000)
- .execute();
- LuceneLogDto logDto1 = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("指令号:" + instructionCode + ",下发追加诺宝叉车运单反馈参数:" + result)
- .build();
- logDto1.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto1);
- log.info("指令号{},状态{},下发追加叉车运单序列反馈:{}", instructionCode, result.getStatus(), result.body());
-
- }
-
- }
-
- private Object createBlocksDataTowCCStart(String nextPoint) {
- JSONArray ja = new JSONArray();
- JSONObject jo9 = new JSONObject();
- jo9.put("blockId", IdUtil.simpleUUID());
- jo9.put("location", nextPoint);
- jo9.put("binTask", "ForkUnload");
- ja.add(jo9);
-
- JSONObject jo10 = new JSONObject();
- jo10.put("blockId", IdUtil.simpleUUID());
- jo10.put("location", nextPoint + "OUTPUT");
- jo10.put("binTask", "OutForkHeight");
- ja.add(jo10);
- return ja;
- }
-
- @Override
- public HttpResponse getRobotInfo(String robotCode) {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- agvurl = agvurl + ":" + agvport + "/" + "robotsStatus?vehicles=" + robotCode;
- log.info("根据指定机器人查询状态的请求:{}", agvurl);
- HttpResponse result = HttpRequest.get(agvurl)
- .timeout(20000)//超时,毫秒
- .execute();
- log.info("根据指定机器人查询状态的请求反馈:{}", result);
- return result;
- } else {
- return null;
- }
- }
-
- private String applyXGAgvTask(String task_code, Integer actionType, Instruction instructionDto) {
-
- JSONObject param = new JSONObject();
- param.put("taskCode", task_code);
- param.put("actionType", actionType.toString());
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("二次分配请求lms,参数:" + task_code + "--" + ActionTypeEnum.getStatus(actionType))
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- String response = acsToWmsService.secondaryAllocationPoint(param);
- JSONObject jo = JSON.parseObject(response);
- if (jo.getInteger("status") == 200) {
- LuceneLogDto logDto2 = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("二次分配请求lms,参数,接口返回:" + jo)
- .build();
- logDto2.setLog_level(4);
- //二次分配更新点位
- updataTask(instructionDto, jo.getString("data"));
- luceneExecuteLogService.deviceExecuteLog(logDto2);
- if (!ActionTypeEnum.IN_FINISHING.getCode().equals(actionType)) {
- //请求成功调用诺宝追加动作块
- sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), jo.getString("data"), instructionDto);
- }
- return jo.getString("data");
-
- } else {
- LuceneLogDto logDto2 = LuceneLogDto.builder()
- .device_code(instructionDto.getCarno())
- .content("二次分配请求lms,返回参数:" + jo)
- .build();
- logDto2.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto2);
- throw new BadRequestException("二次分配请求lms返回失败");
- }
-
-
- }
-
- private void updataTask(Instruction instructionDto, String newPoint) {
-
- TaskDto taskUpdate = new TaskDto();
- if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
- instructionDto.setStart_point_code(newPoint);
- taskUpdate.setStart_point_code(newPoint);
- instructionDto.setStart_device_code(newPoint);
- taskUpdate.setStart_device_code(newPoint);
- }
- if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
- instructionDto.setNext_point_code(newPoint);
- taskUpdate.setNext_point_code(newPoint);
- instructionDto.setNext_device_code(newPoint);
- taskUpdate.setNext_device_code(newPoint);
- }
- taskUpdate.setTask_id(instructionDto.getTask_id());
- instructionService.update(instructionDto);
- taskserver.update(taskUpdate);
- }
-
-
- @Override
- public HttpResponse sendOrderSequencesToForklift(Instruction inst, InteractionJsonDTO interactionJsonDTO) {
- com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
- jo.put("id", inst.getInstruction_code());
- //运单封口,true=创建运单之后不可添加动作块;false=创建运单可以添加动作块
- if (AgvActionTypeEnum.ORDINARY.getCode().equals(inst.getAgv_action_type())) {
- jo.put("complete", true);
- } else {
- jo.put("complete", false);
- } //动作块
- jo.put("blocks", createBlocksForklift(inst, interactionJsonDTO));
- //运单优先级
- jo.put("priority", inst.getPriority());
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code("下发叉车运单")
- .content("任务号:" + inst.getTask_code() + ",指令号:" + inst.getInstruction_code() + ",下发叉车订单序列参数:" + jo)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo);
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- agvurl = agvurl + ":" + agvport + "/setOrder";
-
- log.info(agvurl);
- HttpResponse result = HttpRequest.post(agvurl)
- //表单内容
- .body(String.valueOf(jo))
- //超时,毫秒
- .timeout(20000)
- .execute();
- LuceneLogDto logDto1 = LuceneLogDto.builder()
- .device_code("叉车运单响应")
- .content("任务号:" + inst.getTask_code() + ",指令号:" + inst.getInstruction_code() + ",下发叉车订单序列反馈参数:" + jo)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto1);
- log.info("任务号:{},指令号{},状态{},下发agv叉车订单序列反馈:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body());
-
- return result;
- } else {
- return null;
- }
- }
-
-
-
- /**
- * 追加动作块
- *
- * @param
- * @param instructionCode
- * @param instructionDto
- * @return
- */
- private void sendAddSequencesToNBAgv(String instructionCode, String point, Instruction instructionDto) {
- com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
- jo.put("id", instructionCode);
- //动作块
- if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
- jo.put("blocks", createBlocksDataTowStart(instructionCode, point, instructionDto));
- }
- if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
- jo.put("blocks", createBlocksDataTowEnd(instructionCode, point, instructionDto));
- }
- //追加订单封口
- jo.put("complete", true);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code("追加诺宝运单")
- .content("指令号:" + instructionCode + ",追加诺宝运单参数:" + jo)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- log.info("任务号:{},指令号{},追加诺宝运单:{}", instructionCode, point, jo);
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- agvurl = agvurl + ":" + agvport + "/addBlocks";
-
- log.info(agvurl);
- HttpResponse result = HttpRequest.post(agvurl)
- //表单内容
- .body(String.valueOf(jo))
- //超时,毫秒
- .timeout(20000)
- .execute();
- LuceneLogDto logDto1 = LuceneLogDto.builder()
- .device_code("追加诺宝运单参数")
- .content("指令号:" + instructionCode + ",下发追加诺宝运单反馈参数:" + jo)
- .build();
- logDto1.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto1);
- log.info("指令号{},状态{},下发追加诺宝运单序列反馈:{}", instructionCode, result.getStatus(), result.body());
-
- }
- }
-
- private Object createBlocksDataTowEnd(String instructionCode, String point, Instruction instructionDto) {
- JSONArray ja = new JSONArray();
- //终点2
- sendEndDeviceOrder3(ja, point, instructionCode, instructionDto);
- return ja;
-
- }
-
- private void sendEndDeviceOrder3(JSONArray ja, String nextDeviceCode, String instructionCode, Instruction instructionDto) {
- JSONObject jo3 = new JSONObject();
- jo3.put("blockId", IdUtil.simpleUUID());
- jo3.put("location", nextDeviceCode + "INPUT");
- jo3.put("operation", "script");
- jo3.put("id", nextDeviceCode + "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", instructionCode);
- reach3.put("address", nextDeviceCode + "INPUT");
- data3.put("reach", reach3);
- script_args3.put("data", data3);
- script_args3.put("protocol", "HTTP");
- jo3.put("script_args", script_args3);
- ja.add(jo3);
-
-
- //将货物放下
- com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
- jo4.put("blockId", IdUtil.simpleUUID());
- jo4.put("location", nextDeviceCode);
- jo4.put("operation", "JackUnload");
- ja.add(jo4);
- //放货完成等待
- com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
- jo5.put("blockId", IdUtil.simpleUUID());
- jo5.put("location", nextDeviceCode + "OUTPUT");
- jo5.put("operation", "script");
- jo5.put("id", nextDeviceCode + "OUTPUT");
- jo5.put("script_name", "userpy/interact.py");
- com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
- script_args5.put("addr", addr);
- com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
- com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
- reach5.put("task_code", instructionCode);
- reach5.put("address", nextDeviceCode + "OUTPUT");
- data5.put("reach", reach5);
- script_args5.put("data", data5);
- script_args5.put("protocol", "HTTP");
- jo5.put("script_args", script_args5);
- ja.add(jo5);
-
- }
-
-
- private Object createBlocksDataTowStart(String instructionCode, String startPoint, Instruction instructionDto) {
- JSONArray ja = new JSONArray();
- String nextDeviceCode = instructionDto.getNext_device_code();
- //起点2
- sendStartDeviceOrder2(ja, startPoint, instructionCode, instructionDto);
- //终点2
- sendEndDeviceOrder2(ja, nextDeviceCode, instructionCode, instructionDto);
- return ja;
-
- }
-
- private void sendEndDeviceOrder2(JSONArray ja, String nextDeviceCode, String instructionCode, Instruction instructionDto) {
- if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
- //放货前等待
- JSONObject jo3 = new JSONObject();
- jo3.put("blockId", IdUtil.simpleUUID());
- jo3.put("location", nextDeviceCode + "INPUT");
- jo3.put("operation", "script");
- jo3.put("id", nextDeviceCode + "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", instructionCode);
- reach3.put("address", nextDeviceCode + "INPUT");
- data3.put("reach", reach3);
- script_args3.put("data", data3);
- script_args3.put("protocol", "HTTP");
- jo3.put("script_args", script_args3);
- ja.add(jo3);
- //将货物放下
- com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
- jo4.put("blockId", IdUtil.simpleUUID());
- jo4.put("location", nextDeviceCode);
- jo4.put("operation", "JackUnload");
- ja.add(jo4);
- //放货完成等待
- com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
- jo5.put("blockId", IdUtil.simpleUUID());
- jo5.put("location", nextDeviceCode + "OUTPUT");
- jo5.put("operation", "script");
- jo5.put("id", nextDeviceCode + "OUTPUT");
- jo5.put("script_name", "userpy/interact.py");
- com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
- script_args5.put("addr", addr);
- com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
- com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
- reach5.put("task_code", instructionCode);
- reach5.put("address", nextDeviceCode + "OUTPUT");
- data5.put("reach", reach5);
- script_args5.put("data", data5);
- script_args5.put("protocol", "HTTP");
- jo5.put("script_args", script_args5);
- ja.add(jo5);
- }
- }
-
- private void sendStartDeviceOrder2(JSONArray ja, String startPoint, String instructionCode, Instruction instructionDto) {
- //取货前等待
- JSONObject jo = new JSONObject();
- //动作块id
- jo.put("blockId", IdUtil.simpleUUID());
- //目的地名称
- jo.put("location", startPoint + "INGET");
- //执行脚本
- jo.put("operation", "script");
- jo.put("id", startPoint + "INGET");
- //通信脚本,动作前后与现场设备交互的场景
- jo.put("script_name", "userpy/interact.py");
- JSONObject script_args = new JSONObject();
- //更改为现场设备IP及PORT
- script_args.put("addr", addr);
- JSONObject data = new JSONObject();
- JSONObject reach = new JSONObject();
- reach.put("task_code", instructionCode);
- reach.put("address", startPoint + "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", startPoint);
- jo1.put("operation", "JackLoad");
- inspectInStocckSet(startPoint, jo1);
- ja.add(jo1);
- JSONObject jo2 = new JSONObject();
- jo2.put("blockId", IdUtil.simpleUUID());
- jo2.put("location", startPoint + "OUTGET");
- jo2.put("operation", "script");
- jo2.put("id", startPoint + "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", instructionCode);
- reach2.put("address", startPoint + "OUTGET");
- data2.put("reach", reach2);
- script_args2.put("data", data2);
- script_args2.put("protocol", "HTTP");
- jo2.put("script_args", script_args2);
- ja.add(jo2);
- }
-
- /**
- * 叉车运单动作块
- *
- * @param inst
- * @param interactionJsonDTO
- * @return
- */
- private JSONArray createBlocksForklift(Instruction inst, InteractionJsonDTO interactionJsonDTO) {
- JSONArray ja = new JSONArray();
- //起点
- Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code());
- String pointCode = inst.getStart_point_code();
-
-
- //取货前等待
- JSONObject jo = new JSONObject();
- //动作块id
- jo.put("blockId", IdUtil.simpleUUID());
- //目的地名称
- jo.put("location", pointCode + "INGET");
- //执行脚本
- jo.put("operation", "script");
- jo.put("id", pointCode + "INGET");
- //通信脚本,动作前后与现场设备交互的场景
- jo.put("script_name", "userpy/interact.py");
- JSONObject script_args = new JSONObject();
- //更改为现场设备IP及PORT
- script_args.put("addr", addr);
- JSONObject data = new JSONObject();
- JSONObject reach = new JSONObject();
- reach.put("task_code", inst.getInstruction_code());
- reach.put("address", pointCode + "INGET");
- data.put("reach", reach);
- script_args.put("data", data);
- script_args.put("protocol", "HTTP");
- jo.put("script_args", script_args);
- ja.add(jo);
-
- if (AgvActionTypeEnum.ORDINARY.getCode().equals(inst.getAgv_action_type())) {
- // to do
- JSONObject jo1 = new JSONObject();
- jo1.put("blockId", IdUtil.simpleUUID());
- jo1.put("location", inst.getStart_point_code() + "INGET");
- jo1.put("binTask", "InForkHeight");
- ja.add(jo1);
-
- JSONObject jo3 = new JSONObject();
- //动作块id
- jo3.put("blockId", IdUtil.simpleUUID());
- //目的地名称
- jo3.put("location", pointCode + "INGET");
- jo3.put("id", pointCode + "INGET");
- //执行脚本
- jo3.put("operation", "expand");
- //通信脚本,动作前后与现场设备交互的场景
- jo3.put("script_name", "Fork-expand.py");
- JSONObject script_args2 = new JSONObject();
- if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
- script_args2.put("expandWidth", interactionJsonDTO.getExpandWidthLength());
- }
- script_args2.put("operation", "expand");
- jo3.put("script_args", script_args2);
- ja.add(jo3);
-
- JSONObject jo4 = new JSONObject();
- //动作块id
- jo4.put("blockId", IdUtil.simpleUUID());
- //目的地名称
- jo4.put("location", pointCode + "INGET");
- jo4.put("id", pointCode + "INGET");
- //执行脚本
- jo4.put("operation", "stretch");
- //通信脚本,动作前后与现场设备交互的场景
- jo4.put("script_name", "Fork-expand.py");
- JSONObject script_args1 = new JSONObject();
- if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
- script_args1.put("stretchLength", interactionJsonDTO.getExpandWidthLength());
- }
- script_args1.put("operation", "stretch");
- jo4.put("script_args", script_args1);
- ja.add(jo4);
-
- JSONObject jo6 = new JSONObject();
- jo6.put("blockId", IdUtil.simpleUUID());
- jo6.put("location", inst.getStart_point_code());
- jo6.put("binTask", "Script");
- ja.add(jo6);
-
- JSONObject jo7 = new JSONObject();
- jo7.put("blockId", IdUtil.simpleUUID());
- jo7.put("location", inst.getStart_point_code());
- jo7.put("binTask", "ForkLoad");
- ja.add(jo7);
-
- //取货完成
- JSONObject jo2 = new JSONObject();
- jo2.put("blockId", IdUtil.simpleUUID());
- jo2.put("location", pointCode + "OUTGET");
- jo2.put("operation", "script");
- jo2.put("id", pointCode + "OUTGET");
- jo2.put("script_name", "userpy/interact.py");
- JSONObject script_args4 = new JSONObject();
- script_args4.put("addr", addr);
- JSONObject data2 = new JSONObject();
- JSONObject reach2 = new JSONObject();
- reach2.put("task_code", inst.getInstruction_code());
- reach2.put("address", pointCode + "OUTGET");
- data2.put("reach", reach2);
- script_args4.put("data", data2);
- script_args4.put("protocol", "HTTP");
- jo2.put("script_args", script_args4);
- ja.add(jo2);
-
-
- //ForkUnload(货叉卸载货物,会将叉车的状态变成非载货中)
- JSONObject jo8 = new JSONObject();
- jo8.put("blockId", IdUtil.simpleUUID());
- jo8.put("location", inst.getStart_point_code() + "OUTGET");
- jo8.put("binTask", "OutForkHeight");
- ja.add(jo8);
-
- JSONObject jo9 = new JSONObject();
- jo9.put("blockId", IdUtil.simpleUUID());
- jo9.put("location", inst.getNext_point_code());
- jo9.put("binTask", "ForkUnload");
- ja.add(jo9);
-
- JSONObject jo10 = new JSONObject();
- jo10.put("blockId", IdUtil.simpleUUID());
- jo10.put("location", inst.getNext_point_code() + "OUTPUT");
- jo10.put("binTask", "OutForkHeight");
- ja.add(jo10);
-
- } else if (AgvActionTypeEnum.IN_STOCK.getCode().equals(inst.getAgv_action_type())) {
-
- } else if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(inst.getAgv_action_type())) {
- // to do
- JSONObject jo1 = new JSONObject();
- jo1.put("blockId", IdUtil.simpleUUID());
- jo1.put("location", inst.getStart_point_code() + "INGET");
- jo1.put("binTask", "InForkHeight");
- ja.add(jo1);
-
- JSONObject jo3 = new JSONObject();
- //动作块id
- jo3.put("blockId", IdUtil.simpleUUID());
- //目的地名称
- jo3.put("location", pointCode + "INGET");
- jo3.put("id", pointCode + "INGET");
- //执行脚本
- jo3.put("operation", "expand");
- //通信脚本,动作前后与现场设备交互的场景
- jo3.put("script_name", "Fork-expand.py");
- JSONObject script_args2 = new JSONObject();
- if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
- script_args2.put("expandWidth", interactionJsonDTO.getExpandWidthLength());
- }
- script_args2.put("operation", "expand");
- jo3.put("script_args", script_args2);
- ja.add(jo3);
-
- JSONObject jo4 = new JSONObject();
- //动作块id
- jo4.put("blockId", IdUtil.simpleUUID());
- //目的地名称
- jo4.put("location", pointCode + "INGET");
- jo4.put("id", pointCode + "INGET");
- //执行脚本
- jo4.put("operation", "stretch");
- //通信脚本,动作前后与现场设备交互的场景
- jo4.put("script_name", "Fork-expand.py");
- JSONObject script_args1 = new JSONObject();
- if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
- script_args1.put("stretchLength", interactionJsonDTO.getExpandWidthLength());
- }
- script_args1.put("operation", "stretch");
- jo4.put("script_args", script_args1);
- ja.add(jo4);
-
- JSONObject jo6 = new JSONObject();
- jo6.put("blockId", IdUtil.simpleUUID());
- jo6.put("location", inst.getStart_point_code());
- jo6.put("binTask", "Script");
- ja.add(jo6);
-
- JSONObject jo7 = new JSONObject();
- jo7.put("blockId", IdUtil.simpleUUID());
- jo7.put("location", inst.getStart_point_code());
- jo7.put("binTask", "ForkLoad");
- ja.add(jo7);
-
- //取货完成
- JSONObject jo2 = new JSONObject();
- jo2.put("blockId", IdUtil.simpleUUID());
- jo2.put("location", pointCode + "OUTGET");
- jo2.put("operation", "script");
- jo2.put("id", pointCode + "OUTGET");
- jo2.put("script_name", "userpy/interact.py");
- JSONObject script_args4 = new JSONObject();
- script_args4.put("addr", addr);
- JSONObject data2 = new JSONObject();
- JSONObject reach2 = new JSONObject();
- reach2.put("task_code", inst.getInstruction_code());
- reach2.put("address", pointCode + "OUTGET");
- data2.put("reach", reach2);
- script_args4.put("data", data2);
- script_args4.put("protocol", "HTTP");
- jo2.put("script_args", script_args4);
- ja.add(jo2);
-
-
- //ForkUnload(货叉卸载货物,会将叉车的状态变成非载货中)
- JSONObject jo8 = new JSONObject();
- jo8.put("blockId", IdUtil.simpleUUID());
- jo8.put("location", inst.getStart_point_code() + "OUTGET");
- jo8.put("binTask", "OutForkHeight");
- ja.add(jo8);
-
- JSONObject jo9 = new JSONObject();
- jo9.put("blockId", IdUtil.simpleUUID());
- jo9.put("location", inst.getNext_device_code() + "WAIT");
- jo9.put("operation", "script");
- jo9.put("id", inst.getNext_device_code() + "WAIT");
- jo9.put("script_name", "userpy/interact.py");
- JSONObject script_args5 = new JSONObject();
- script_args5.put("addr", addr);
- JSONObject data3 = new JSONObject();
- JSONObject reach3 = new JSONObject();
- reach3.put("task_code", inst.getInstruction_code());
- reach3.put("address", inst.getNext_device_code() + "WAIT");
- data3.put("reach", reach3);
- script_args5.put("data", data3);
- script_args5.put("protocol", "HTTP");
- jo9.put("script_args", script_args5);
- ja.add(jo9);
-
- } else if (AgvActionTypeEnum.IN_STOCK.getCode().equals(inst.getAgv_action_type())) {
-
- }
-
-
- return ja;
- }
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java
deleted file mode 100644
index 499e813..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java
+++ /dev/null
@@ -1,442 +0,0 @@
-package org.nl.acs.agv.server.impl;
-
-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.AcsConfig;
-import org.nl.acs.agv.AgvUtil;
-import org.nl.acs.agv.server.ZheDaAgvService;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.opc.DeviceAppServiceImpl;
-import org.nl.acs.task.service.TaskService;
-import org.nl.acs.task.service.dto.TaskDto;
-import org.nl.system.service.param.ISysParamService;
-import org.nl.config.SpringContextHolder;
-import org.springframework.stereotype.Service;
-
-/**
- * @author 20220102CG\noblelift
- */
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class ZheDaAgvServiceImpl implements ZheDaAgvService {
- private final ISysParamService paramService;
-
- /**
- * 判断是否追加任务
- */
- private static final String THREE = "3";
- private static final String FOUR = "4";
- private static final String FIVE = "5";
- /**
- * 取货的进入前等待和离开等待
- */
- private static final String LOAD = "load";
- /**
- * 取货的进入前等待和离开等待
- */
- private static final String ENTRY_REQUIRED = "EntryRequired";
- private static final String ENTRYREQUIRED = "entryRequired";
- private static final String PAUSE_ON_STATION = "PauseOnStation";
- /**
- * 等待点等待
- */
- private static final String WAIT = "Wait";
- /**
- * 放货的进入前等待和离开等待
- */
- private static final String UNLOAD = "Unload";
-
-
- @Override
- public HttpResponse sendAgvInstToAgv(Instruction inst) throws Exception {
- JSONObject jo = new JSONObject();
- String start_point_code = inst.getStart_point_code();
- String next_point_code = inst.getNext_point_code();
- //1楼AGV普通任务
- //2楼AGV普通任务
- //2楼AGV起点追加任务
- //2楼AGV终点追加任务
- String task_type = inst.getInstruction_type();
- jo.put("deadline", AgvUtil.getNextDay(1));
- //判断是否追加任务
- if (THREE.equals(task_type) || FOUR.equals(task_type)) {
- jo.put("complete", "false");
- } else {
- jo.put("complete", "true");
- }
- jo.put("task_code", inst.getInstruction_code());
- //根据任务,下发指令类型
- JSONArray destinations = new JSONArray();
- if (THREE.equals(task_type)) {
- destinations.add(destination(start_point_code, "Wait", "5", CommonFinalParam.ONE));
- } else if (FOUR.equals(task_type)) {
- destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE));
- destinations.add(destination(next_point_code, "Wait", "5", CommonFinalParam.ONE));
- } else {
- destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE));
- destinations.add(destination(next_point_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
- }
-
- jo.put("destinations", destinations);
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvurl2 = paramService.findByCode(AcsConfig.AGVURL2).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
- String agvport2 = paramService.findByCode(AcsConfig.AGVPORT2).getValue();
-
-
- //不同楼层下发不同的agv系统
- if (CommonFinalParam.ONE.equals(task_type)) {
- agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst.getInstruction_code();
- } else {
- agvurl = agvurl2 + ":" + agvport2 + "/v1/transportOrders/" + inst.getInstruction_code();
- }
- log.info("下发agv任务请求:{}", agvurl);
-
- HttpResponse result = HttpRequest.post(agvurl)
- //表单内容
- .body(String.valueOf(jo))
- //超时,毫秒
- .timeout(20000)
- .execute();
- log.info("下发agv任务请求反馈:{}", result);
- return result;
- } else {
- return null;
- }
- }
-
- /**
- * ZDAGV
- * @param type
- * @return
- */
-
- @Override
- public HttpResponse queryAgvInstStatus(String type) {
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = "";
- String agvport = "";
- if (CommonFinalParam.ONE.equals(type)) {
- agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
- }
- if (CommonFinalParam.TWO.equals(type)) {
- agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue();
- agvport = paramService.findByCode(AcsConfig.AGVPORT2).getValue();
- }
-
- agvurl = agvurl + ":" + agvport + "/v1/transportOrders";
- HttpResponse result = HttpRequest.get(agvurl)
- //超时,毫秒
- .timeout(20000)
- .execute();
- System.out.println("查询agv指令数据:" + result.body());
-
- return result;
- } else {
- return null;
- }
- }
-
- /**
- * 处理AGV指令 ZDAGV
- *
- * @param jobno
- * @param type
- * @param address
- * @param action
- * @param processingVehicle
- * @return
- */
-
- @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);
- //释放AGV资源,继续后续动作
- boolean is_feedback = false;
- String str = "";
- String backaddress = address;
- if (address.indexOf(CommonFinalParam.DOT) > 0) {
- str = address.substring(address.indexOf(".") + 1, address.length());
- address = address.substring(0, address.indexOf("."));
- } else if (address.indexOf(CommonFinalParam.HYPHEN_) > 0) {
- address = address.substring(0, address.indexOf("-"));
- }
- InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
- TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
- AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
-
- Instruction inst = instructionService.findByCodeFromCache(jobno);
- TaskDto task = taskService.findByCode(inst.getTask_code());
-
- DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
- Device addressdevice = appService.findDeviceByCode(address);
-
- //等待点等待
- if (WAIT.equals(action)) {
- if (WAIT.equals(type)) {
- JSONObject jo = new JSONObject();
- jo.put("task_code", inst.getInstruction_code());
- JSONArray destinations = new JSONArray();
- String inst_type = inst.getInstruction_type();
- //如果任务类型为1,在点位进行等待,则查询当前叠盘位的数量,取当前数量的层数进行追加任务
-// if (CommonFinalParam.ONE.equals(inst_type)) {
-// emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) addressdevice.getDeviceDriver();
-// int current_num = emptyVehicleStackingPositionDeviceDriver.getNumber();
-// if (current_num > 12) {
-// log.info("当前叠盘架:" + jobno + "已放满!");
-// return null;
-// }
-// String start_point_code = inst.getStart_point_code();
-// String next_point_code = inst.getNext_point_code();
-// start_point_code = start_point_code + "." + (current_num + 1);
-// destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE));
-// destinations.add(destination(next_point_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
-//
-// }
-
- String resp = acsToWmsService.requestTaskAgain(address, task.getExt_task_id(), inst.getVehicle_code());
- JSONObject respjson = JSONObject.parseObject(resp);
-
- if (StrUtil.equals(inst.getInstruction_type(), THREE)) {
- //2楼AGV起点追加任务
- String start_device_code = respjson.getString("device_code");
- String next_device_code = inst.getNext_device_code();
- destinations.add(destination(start_device_code, "load", CommonFinalParam.ONE, CommonFinalParam.ONE));
- destinations.add(destination(next_device_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
-
- } else if (StrUtil.equals(inst.getInstruction_type(), FOUR)) {
- //2楼AGV终点追加任务
- String next_device_code = respjson.getString("device_code");
- destinations.add(destination(next_device_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
- }
-
- jo.put("destinations", destinations);
-
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- String url = agvurl + ":" + agvport + "/addDestinations";
- log.info("下发agv任务请求:{}", url);
-
- HttpResponse result = HttpRequest.post(url)
- //表单内容
- .body(String.valueOf(jo))
- //超时,毫秒
- .timeout(20000)
- .execute();
- log.info("下发agv任务请求反馈:{}", result);
-
- //对任务进行封口
- JSONObject complete = new JSONObject();
- complete.put("task_code", inst.getInstruction_code());
-
- String url2 = agvurl + ":" + agvport + "markComplete";
- log.info("下发agv任务请求:{}", url2);
-
- HttpResponse result2 = HttpRequest.post(url2)
- //表单内容
- .body(String.valueOf(complete))
- //超时,毫秒
- .timeout(20000)
- .execute();
- log.info("下发agv任务请求反馈:{}", result2);
- }
- }
-
- JSONObject requestjo = new JSONObject();
- if (is_feedback) {
- requestjo.put("task_code", jobno);
- requestjo.put("operation", action);
- if (ENTRYREQUIRED.equals(type) || ENTRY_REQUIRED.equals(type)) {
- requestjo.put("entryRequired", "true");
- } else {
- requestjo.put("pauseOnStation", "true");
- }
- log.info("反馈AGV请求数据:{}", requestjo);
- System.out.println("back agv:" + requestjo);
-
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- if (FOUR.equals(inst.getInstruction_type())) {
- agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue();
- }
- agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact";
-
- HttpResponse result = HttpRequest.post(agvurl)
- .body(String.valueOf(requestjo))
- //超时,毫秒
- .timeout(20000)
- .execute();
- }
- return requestjo.toString();
-
- }
-
-
- @Override
- public HttpResponse markComplete(String code) {
-
- if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
- String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
- String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
-
- agvurl = agvurl + ":" + agvport + "/v1/" + 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;
- }
-
- }
-
-
- /**
- * 返回一个点位操作子任务 ZDAGV
- *
- * @param locationName 点位
- * @param operation 点位操作
- * @param propertiesType 子任务类型
- * @param pro 子任务参数
- * 调用demo:destination("sh15p", "Spin", CommonFinalParam.TWO, "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 (CommonFinalParam.ONE.equals(propertiesType)) {
-
- //pro 1 进入离开等待
- if (CommonFinalParam.ONE.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 (CommonFinalParam.TWO.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 (THREE.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);
- }
- //Spin转动
- } else if (CommonFinalParam.TWO.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- //坐标系类型,global_spin_angle为全局坐标系
- pro1.put("key", "global_spin_angle");
- //弧度值,如3.14
- pro1.put("value", pro);
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- //固定值
- pro2.put("key", "spin_direction");
- //弧度值,如0
- pro2.put("value", "0");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //JackUnload,Jackload不操作
- } else if (THREE.equals(propertiesType)) {
- 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 (FOUR.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- //坐标系类型,robot_spin_angle为机器人坐标系
- pro1.put("key", "robot_spin_angle");
- //弧度值,如3.14
- pro1.put("value", pro);
- properties.add(pro1);
- JSONObject pro2 = new JSONObject();
- //固定值
- pro2.put("key", "spin_direction");
- //弧度值,如0
- pro2.put("value", "0");
- properties.add(pro2);
- destinationOrder.put("properties", properties);
- //在该点进行等待
- } else if (FIVE.equals(propertiesType)) {
- JSONArray properties = new JSONArray();
- JSONObject pro1 = new JSONObject();
- pro1.put("key", "Wait");
- pro1.put("value", "True");
- properties.add(pro1);
- destinationOrder.put("properties", properties);
- }
- return destinationOrder;
- }
-
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java
deleted file mode 100644
index 3cd3a01..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java
+++ /dev/null
@@ -1,302 +0,0 @@
-package org.nl.acs.auto.run;
-
-import cn.hutool.core.util.ObjectUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.AcsConfig;
-import org.nl.acs.agv.server.NDCAgvService;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device.service.DeviceService;
-import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.enums.InstructionStatusEnum;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
-import org.nl.acs.log.service.DeviceExecuteLogService;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.config.lucene.service.LuceneExecuteLogService;
-import org.nl.system.service.dict.ISysDictService;
-import org.nl.system.service.dict.dao.Dict;
-import org.nl.system.service.param.ISysParamService;
-import org.nl.config.SpringContextHolder;
-import org.nl.system.service.param.impl.SysParamServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.net.Socket;
-import java.util.Date;
-import java.util.List;
-
-import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
-/**
- * Demo class
- *
- * @author zhoujj
- * @date 2023/12/06
- */
-@Slf4j
-@Component
-public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
-
- Socket s;
- String ip = "192.168.46.225";
- int port = 1234;
- static DataOutputStream dos;
- static DataInputStream dis;
- private int recordTimeOut = 10000;
- private Date recordTime;
- String[] ERROR = new String[]{
- "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位",
- "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位",
- "抬叉停止"};
- boolean bConnected = true;
-
- boolean isReConnect = false;
-
- @Autowired
- ISysParamService paramService;
- @Autowired
- AutoRunService autoRunService;
- @Autowired
- LuceneExecuteLogService luceneExecuteLogService;
- @Autowired
- ISysDictService dictService;
-
-
- public OneNDCSocketConnectionAutoRun() {
- this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
- }
- @Override
- public String getCode() {
- return OneNDCSocketConnectionAutoRun.class.getSimpleName();
- }
- @Override
- public String getName() {
- return "NDC在线连接";
- }
-
- @Override
- public void autoRun() throws IOException {
- System.out.println("NDCAgv链接开始");
- ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
- InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
- AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
- NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class);
- DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
- DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
- DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
- ip = paramService.findByCode(AcsConfig.AGVURL2).getValue();
- port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
-
-
- try {
- byte[] b = new byte[1024];
- s = new Socket(ip, port);
- dos = new DataOutputStream(s.getOutputStream());
- dis = new DataInputStream(s.getInputStream());
- System.out.println("NDCAgv链接成功");
- log.info("NDCAgv链接成功");
- while (bConnected) {
- int count = dis.read(b);
-
- if (count == -1) {
- break;
- }
-
- int[] arr = new int[count];
- StringBuffer bs = new StringBuffer();
-
- for (int i = 0; i < count; i++) {
- int temp = b[i];
- if (temp < 0) {
- temp += 256;
- }
- arr[i] = temp;
- StringBuffer bs1 = new StringBuffer("0");
- bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
- }
-
- boolean flag = false;
- if (arr[8] * 256 + arr[9] == 0x73) {
- byte[] data = null;
- System.out.println("接收agv上报信息:" + bs);
- //执行阶段
- int phase = arr[16] * 256 + arr[17];
- // agv任务号
- int index = arr[12] * 256 + arr[13];
- /**
- * 任务号
- */
- int ikey = arr[26] * 256 + arr[27];
- //站点号
- int agvaddr = arr[18] * 256 + arr[19];
- //车号
- int carno = arr[20];
- //充电桩站点号
- int station = arr[25];
- Instruction link_inst = null;
- Instruction inst = null;
- List insts = null;
- boolean link_flag = false;
- Device agv_device = null;
- if (carno != 0) {
- agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
- }
- if (ikey != 0) {
- inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
- if (ObjectUtil.isEmpty(inst)) {
- inst = instructionService.findByCode(String.valueOf(ikey));
- }
- }
- if (!ObjectUtil.isEmpty(link_inst)) {
- link_flag = true;
- }
- log.info("接收agv上报信息:" + bs);
- log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
- Device device = null;
- String device_code = null;
-
-
- //
- AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
-
- //开始任务/上报订单号
- if (phase == 0x01) {
- if (!ObjectUtil.isEmpty(inst)) {
- inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
- inst.setAgv_jobno(String.valueOf(index));
- inst.setSend_status(CommonFinalParam.ONE);
- instructionService.update(inst);
- }
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
- }
- //任务完毕
- //(无车id及状态)
- else if (phase == 0x0A) {
- if (!ObjectUtil.isEmpty(inst)) {
- instructionService.finish(inst.getInstruction_id());
- } else {
- log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!");
- }
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
- log.info("指令号:{},已反馈agv任务完成!");
- }
- //请求删除任务
- //(需要WCS反馈)
- else if (phase == 0x30) {
- data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0);
- }
- //任务删除确认
- //(需要WCS反馈)
- else if (phase == 0xFF) {
-
- if (!ObjectUtil.isEmpty(inst)) {
- if (!ObjectUtil.isEmpty(inst)) {
- instructionService.cancelNOSendAgv(inst.getInstruction_id());
- }
- }
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
-
- }else if (phase == 0x64){
- log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}",agvaddr,station);
- Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
- if (ObjectUtil.isNotEmpty(dict)){
- dict.setValue("1");
- dict.setPara2(String.valueOf(agvaddr));
- dict.setPara3("下发成功");
- dictService.updateDetail(dict);
- }
- //充电成功
- }else if (phase == 0x65){
- log.info("AGV车号{}反馈充电中,充电桩{}",agvaddr,station);
- //充电取消上报
- }else if (phase == 0x66){
- log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}",agvaddr,station);
- Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
- if (ObjectUtil.isNotEmpty(dict)){
- dict.setValue("0");
- dict.setPara2("");
- dict.setPara3("充电桩空闲");
- dictService.updateDetail(dict);
- }
- } else {
- //上报异常信息
- //(不需要WCS反馈)
- if (phase == 0x67) {
- device = deviceAppService.findDeviceByCode(Integer.toString(arr[27]));
- } else {
- device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
- }
- if (ObjectUtil.isNotEmpty(device)) {
- if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
- agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
- agvNdcOneDeviceDriver.processSocket(arr);
- }
- }
-
- }
- if (!ObjectUtil.isEmpty(data)) {
- write(data);
- }
-
- } else {
- System.out.println("agv上报不是0073类型动作,不处理");
- }
- }
-
- } catch (Exception e) {
- System.out.println("Agv链接异常");
- log.info("Agv链接异常");
- log.error("agv连接出现异常:{}", e);
- if (ObjectUtil.isNotEmpty(s)) {
- s.close();
- }
- System.out.println(e.getMessage());
- e.printStackTrace();
-
- } finally {
-
-
- }
-
- }
-
-
- @Override
- public void stop() {
- super.after();
- try {
- s.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-
- public static void write(byte[] b) {
- try {
- log.info("下发agv数据:" + Bytes2HexString(b));
- System.out.println("下发agv数据:" + Bytes2HexString(b));
- dos.write(b);
- dos.flush();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- try {
- Thread.sleep(5000L);
- log.info("再次下发agv数据:" + Bytes2HexString(b));
- System.out.println("再次下发agv数据:" + Bytes2HexString(b));
- dos.write(b);
- dos.flush();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
-
- }
- }
-}
-
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java
deleted file mode 100644
index fe8c323..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java
+++ /dev/null
@@ -1,413 +0,0 @@
-package org.nl.acs.auto.run;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.AcsConfig;
-import org.nl.acs.agv.server.NDCAgvService;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device.service.DeviceService;
-import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver;
-import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver;
-import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
-import org.nl.acs.log.service.DeviceExecuteLogService;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.config.SpringContextHolder;
-import org.nl.config.lucene.service.LuceneExecuteLogService;
-import org.nl.config.lucene.service.dto.LuceneLogDto;
-import org.nl.system.service.dict.ISysDictService;
-import org.nl.system.service.dict.dao.Dict;
-import org.nl.system.service.param.ISysParamService;
-import org.nl.system.service.param.impl.SysParamServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
-
-
-@Slf4j
-@Component
-public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
-
- Socket socket;
- String ip = "192.168.46.225";
- int port = 1234;
- static DataOutputStream dos;
- static DataInputStream dis;
- private int recordTimeOut = 10000;
- private Date recordTime;
- String[] ERROR = new String[]{
- "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位",
- "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位",
- "抬叉停止"};
- boolean bConnected = true;
-
- boolean isReConnect = false;
- int i = 1;
- boolean requireSucessRegion = false;
- boolean requireSucessTake = false;
- boolean requireSucessPut = false;
-
-
- @Autowired
- ISysParamService paramService;
- @Autowired
- AutoRunService autoRunService;
- @Autowired
- LuceneExecuteLogService luceneExecuteLogService;
- @Autowired
- ISysDictService dictService;
-
- public TwoNDCSocketConnectionAutoRun() {
- this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
- }
-
- @Override
- public String getCode() {
- return TwoNDCSocketConnectionAutoRun.class.getSimpleName();
- }
-
- @Override
- public String getName() {
- return "2楼1区域AGV系统";
- }
-
- @Override
- public void autoRun() throws IOException {
- ISysParamService paramService = SpringContextHolder.getBean(SysParamServiceImpl.class);
- InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
- AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
- NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
- DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
- DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
- DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
-
- try {
- log.info("2楼1区域AGV系统链接开始");
- ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
- port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).getValue());
-// byte[] b = new byte[1024];
-// s = new Socket(ip, port);
-// System.out.println("2楼1区域Agv链接成功");
-// dos = new DataOutputStream(s.getOutputStream());
-// dis = new DataInputStream(s.getInputStream());
-
- InetSocketAddress socketAddress = new InetSocketAddress(ip, port);
-
- byte[] b = new byte[1024];
- socket = new Socket();
- socket.connect(socketAddress, 5 * 1000);
- socket.setKeepAlive(true);//长链接
- socket.setSoTimeout(30000);//读取超时时间
- dos = new DataOutputStream(socket.getOutputStream());
- dis = new DataInputStream(socket.getInputStream());
-
- while (socket.isConnected()) {
- System.out.println("当前socket状态:"+socket.isConnected());
- int count = dis.read(b);
-// System.out.println("当前count值:"+count);
- if (count == -1) {
- log.error("agv连接出现异常:服务端被关闭");
- if (ObjectUtil.isNotEmpty(socket)) {
- socket.close();
- }
- break;
- }
-
- int[] arr = new int[count];
- StringBuffer bs = new StringBuffer();
-
- for (int i = 0; i < count; i++) {
- int temp = b[i];
- if (temp < 0)
- temp += 256;
- arr[i] = temp;
- StringBuffer bs1 = new StringBuffer("0");
- bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
- }
-
- System.out.println("收到请求参数:" + bs);
-
- boolean flag = false;
- if (arr.length < 10) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code("ndc")
- .content("接收agv上报信息:" + bs)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- log.info("接收agv上报信息:" + bs);
- } else {
- if (arr[8] * 256 + arr[9] == 0x73) {
- byte[] data = null;
- System.out.println("接收agv上报信息:" + bs);
- //执行阶段
- int phase = arr[16] * 256 + arr[17];
- // agv任务号
- int index = arr[12] * 256 + arr[13];
- //任务号
- int ikey = arr[26] * 256 + arr[27];
- //站点号
- int agvaddr = arr[18] * 256 + arr[19];
- //车号
- int carno = arr[20];
- //充电桩站点号
- int station = arr[25];
- Instruction inst = null;
- if (ikey != 0) {
- inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
- }
- log.info("接收agv上报信息:" + bs);
- log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
- Device device = null;
- String device_code = null;
- String old_device_code = null;
- String emptyNum = null;
- //自动门
- StandardAutodoorDeviceDriver standardAutodoorDeviceDriver;
- if (agvaddr != 0) {
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- if (StrUtil.contains(old_device_code, "-")) {
- String[] point = old_device_code.split("-");
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, ".")) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- device = deviceAppService.findDeviceByCode(device_code);
- }
-
- AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver;
- AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
- //开始任务
- if (phase == 0x01) {
- if (!ObjectUtil.isEmpty(inst)) {
- inst.setInstruction_status("1");
- inst.setAgv_jobno(String.valueOf(index));
- inst.setSend_status("1");
- instructionService.update(inst);
- data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
- }
- flag = true;
- }
- //任务完毕
- //(无车id及状态)
- else if (phase == 0x14) {
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到指令号{}对应的指令", ikey);
- } else {
- String agvcar = inst.getCarno();
- Device agvDevice = deviceAppService.findDeviceByCode(agvcar);
- if (agvDevice != null) {
- if (agvDevice.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
- agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) agvDevice.getDeviceDriver();
- agvNdcTwoDeviceDriver.setInstruction(null);
- } else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
- agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
- agvNdcOneDeviceDriver.setInstruction(null);
- }
- }
- inst.setInstruction_status("2");
- try {
- instructionService.finish(inst);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
- }
- //请求删除任务
- //(需要WCS反馈)
- else if (phase == 0x30) {
-// data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0);
- data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0, 0, 0);
- }
- //任务删除确认
- //(需要WCS反馈)
- else if (phase == 0xFF) {
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到指令号{}对应的指令", ikey);
- } else {
- instructionService.cancelNOSendAgv(inst.getInstruction_id());
- }
- data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
- } else if (phase == 0x50) {
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- return;
- }
- if (ObjectUtil.isNotEmpty(device)) {
- if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
- standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
- try {
- standardAutodoorDeviceDriver.writing("to_open", "1");
- standardAutodoorDeviceDriver.writing("to_close", "0");
- } catch (Exception e) {
- log.info("下发电气信号失败:" + e.getMessage());
- e.printStackTrace();
- }
- if (standardAutodoorDeviceDriver.getOpen() == 1 && standardAutodoorDeviceDriver.getToOpen() == 1) {
- log.info("下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getOpen());
- data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
- } else {
- log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getToClose());
- }
- }
- } else {
- log.info(agvaddr + "对应设备号为空!");
- }
-
- } else if (phase == 0x51) {
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- return;
- }
- if (ObjectUtil.isNotEmpty(device)) {
- if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
- standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
- try {
- standardAutodoorDeviceDriver.writing("to_close", "1");
- standardAutodoorDeviceDriver.writing("to_open", "0");
- } catch (Exception e) {
- log.info("下发电气信号失败:" + e.getMessage());
- e.printStackTrace();
- }
- if (standardAutodoorDeviceDriver.getClose() == 1) {
- log.info("读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose());
- data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
- } else {
- log.info("未下发NDC信号原因: 读取自动门信号值为:{}", standardAutodoorDeviceDriver.getClose());
- }
- }
- } else {
- log.info(device_code + "对应设备号为空!");
- }
- } else if (phase == 0x64){
- log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}",agvaddr,station);
- Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
- if (ObjectUtil.isNotEmpty(dict)){
- dict.setValue("1");
- dict.setPara2(String.valueOf(agvaddr));
- dict.setPara3("下发成功");
- dictService.updateDetail(dict);
- }
- //充电成功
- }else if (phase == 0x65){
- log.info("AGV车号{}反馈充电中,充电桩{}",agvaddr,station);
- //充电取消上报
- }else if (phase == 0x66){
- log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}",agvaddr,station);
- Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
- if (ObjectUtil.isNotEmpty(dict)){
- dict.setValue("0");
- dict.setPara2("");
- dict.setPara3("充电桩空闲");
- dictService.updateDetail(dict);
- }
- }
- else {
- //上报异常信息
- //(不需要WCS反馈)
- if (phase == 0x67 || phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74) {
- device = deviceAppService.findDeviceByCode(Integer.toString(arr[18] * 256 + arr[19]));
- } else {
- device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
- }
- try {
- if (ObjectUtil.isNotEmpty(device)) {
- if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
- agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver();
- agvNdcTwoDeviceDriver.processSocket(arr);
- } else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
- agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
- agvNdcOneDeviceDriver.processSocket(arr);
- }
- } else {
- log.info("当前phase:" + phase + "未找到对应设备");
- }
- } catch (Exception e) {
- log.info("processSocket出错:{},{}", e, e.getMessage());
- e.printStackTrace();
- }
- }
- if (!ObjectUtil.isEmpty(data)) {
- write(data);
- }
- } else {
- System.out.println("agv上报不是0073类型动作,不处理");
- }
- }
- }
- } catch (Exception e) {
- System.out.println("TwoAgv链接异常");
- log.info("TwoAgv链接异常");
- log.error("agv连接出现异常:{}", e);
- logServer.deviceExecuteLog("NDC2", "", "", "agv异常" + e.getMessage());
- logServer.deviceExecuteLog("NDC2", "", "", "agv异常" + e);
- if (ObjectUtil.isNotEmpty(socket)) {
- socket.close();
- }
- System.out.println(e.getMessage());
- } finally {
- closeResources();
- }
-
- }
-
-
- @Override
- public void stop() {
- super.after();
- closeResources();
- }
-
-
- private void closeResources() {
- try {
- if (dis != null) dis.close();
- if (dos != null) dos.close();
- if (socket != null && !socket.isClosed()) socket.close();
- } catch (IOException e) {
- log.error("关闭资源时发生错误: {}", e.getMessage(), e);
- }
- }
-
-
- public static void write(byte[] b) {
- try {
- log.info("下发agv数据:" + Bytes2HexString(b));
- System.out.println("下发agv数据:" + Bytes2HexString(b));
- dos.write(b);
- dos.flush();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- try {
- Thread.sleep(1000);
- log.info("再次下发agv数据:" + Bytes2HexString(b));
- System.out.println("再次下发agv数据:" + Bytes2HexString(b));
- dos.write(b);
- dos.flush();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
-
- }
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardOrdinarySiteDevice.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardOrdinarySiteDevice.java
index fddd360..3f0aabf 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardOrdinarySiteDevice.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardOrdinarySiteDevice.java
@@ -16,18 +16,6 @@ public class StandardOrdinarySiteDevice extends AbstractDriverService {
public JSONObject getDeviceInfo(Device device) {
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
JSONObject jo = new JSONObject();
- jo.put("container", standardOrdinarySiteDeviceDriver.getContainer());
- jo.put("hasGoods", standardOrdinarySiteDeviceDriver.getHasGoods());
- jo.put("isOnline", true);
- //点击弹出
- jo.put("is_click", true);
- jo.put("device_type", device.getDevice_type());
- jo.put("error", standardOrdinarySiteDeviceDriver.getError());
- jo.put("isError", standardOrdinarySiteDeviceDriver.getIserror());
- jo.put("container", standardOrdinarySiteDeviceDriver.getContainer());
- jo.put("message", standardOrdinarySiteDeviceDriver.getMessage());
- jo.put("material", standardOrdinarySiteDeviceDriver.getMaterial());
- jo.put("batch", standardOrdinarySiteDeviceDriver.getBatch());
return jo;
}
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
index 9fc61f9..df78e91 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
@@ -26,7 +26,6 @@ import org.nl.acs.device.enums.DeviceType;
import org.nl.acs.device.service.mapper.DeviceExtraMapper;
import org.nl.acs.device.domain.DeviceRunpoint;
import org.nl.acs.device.service.mapper.DeviceRunpointMapper;
-import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver;
import org.nl.acs.route.domain.RouteLine;
import org.nl.acs.route.service.mapper.RouteLineMapper;
import org.nl.acs.storage_cell.domain.StorageCell;
@@ -574,17 +573,6 @@ public class DeviceServiceImpl extends CommonServiceImpl i
Device device = appService.findDeviceByCode(device_code);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol();
- if (branchProtocol == 2) {
- devicejo.put("device_code", device_code);
- devicejo.put("branchProtocol", branchProtocol);
- devicejo.put("region", region);
- devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty());
- devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark());
- devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial());
- devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess());
- deviceInfo.add(devicejo);
- }
}
}
} else if (status.equals("3")) {
@@ -596,17 +584,6 @@ public class DeviceServiceImpl extends CommonServiceImpl i
Device device = appService.findDeviceByCode(device_code);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol();
- if (branchProtocol == 3) {
- devicejo.put("device_code", device_code);
- devicejo.put("branchProtocol", branchProtocol);
- devicejo.put("region", region);
- devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty());
- devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial());
- devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark());
- devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess());
- deviceInfo.add(devicejo);
- }
}
}
} else {
@@ -617,16 +594,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i
String device_code = obj.getString("device_code");
Device device = appService.findDeviceByCode(device_code);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol();
- devicejo.put("device_code", device_code);
- devicejo.put("branchProtocol", branchProtocol);
- devicejo.put("region", region);
- devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty());
- devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial());
- devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark());
- devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess());
- deviceInfo.add(devicejo);
+
}
}
}
@@ -925,38 +893,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- if (!StrUtil.isEmpty(hasGoodStatus)) {
- standardOrdinarySiteDeviceDriver.setHasGoods(Integer.parseInt(hasGoodStatus));
- device.setHas_goods(Integer.parseInt(hasGoodStatus));
- }
- if (StrUtil.isNotEmpty(material_type)) {
- standardOrdinarySiteDeviceDriver.setMaterial(material_type);
- device.setMaterial_type(material_type);
- } else {
- standardOrdinarySiteDeviceDriver.setMaterial("");
- device.setMaterial_type("");
- }
- if (StrUtil.isNotEmpty(quantity)) {
- standardOrdinarySiteDeviceDriver.setQty(quantity);
- device.setQuantity(quantity);
- } else {
- standardOrdinarySiteDeviceDriver.setQty("");
- device.setQuantity("");
- }
- if (StrUtil.isNotEmpty(remark)) {
- standardOrdinarySiteDeviceDriver.setRemark(remark);
- device.setRemark(remark);
- } else {
- standardOrdinarySiteDeviceDriver.setRemark("");
- device.setRemark("");
- }
- if (StrUtil.isNotEmpty(batch)) {
- standardOrdinarySiteDeviceDriver.setBatch(batch);
- device.setBatch(batch);
- } else {
- standardOrdinarySiteDeviceDriver.setBatch("");
- device.setBatch("");
- }
+
// WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint");
// JSONObject json = runpointwo.query("device_code ='" + device_code + "'").uniqueResult(0);
DeviceRunpoint deviceRunpoint = new LambdaQueryChainWrapper<>(deviceRunpointMapper)
@@ -985,9 +922,6 @@ public class DeviceServiceImpl extends CommonServiceImpl i
standardInspectSiteDeviceDriver.setBatch(batch);
device.setMaterial_type(material_type);
device.setBatch(batch);
- }else if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
- BeltConveyorDeviceDriver beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) device.getDeviceDriver();
- beltConveyorDeviceDriver.setDeviceStatus(form);
}
}
@@ -1009,9 +943,6 @@ public class DeviceServiceImpl extends CommonServiceImpl i
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver();
- standardOrdinarySiteDeviceDriver.setBranchProtocol(4);
- standardOrdinarySiteDeviceDriver.setMaterial(material_type);
- standardOrdinarySiteDeviceDriver.setBatch(batch);
}
}
@@ -1032,7 +963,6 @@ public class DeviceServiceImpl extends CommonServiceImpl i
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver();
- standardOrdinarySiteDeviceDriver.setHasGoods(0);
JSONObject jsonjo = new JSONObject();
jsonjo.put("device_code", start_device_code);
jsonjo.put("hasGoodStatus", "0");
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDefination.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDefination.java
deleted file mode 100644
index 5c2a2c3..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDefination.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.nl.acs.device_driver.agv.magic_agv;
-
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device.enums.DeviceType;
-import org.nl.acs.device_driver.DeviceDriver;
-import org.nl.acs.device_driver.DeviceDriverDefination;
-import org.springframework.stereotype.Service;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * 普通站点定义
- */
-@Service
-public class MagicAgvDefination implements DeviceDriverDefination {
- @Override
- public String getDriverCode() {
- return "magic_agv";
- }
-
- @Override
- public String getDriverName() {
- return "标准版-MagicAgv";
- }
-
- @Override
- public String getDriverDescription() {
- return "标准版-MagicAgv";
- }
-
- @Override
- public DeviceDriver getDriverInstance(Device device) {
- return (new MagicAgvDeviceDriver()).setDevice(device).setDriverDefination(this);
-
- }
-
- @Override
- public Class extends DeviceDriver> getDeviceDriverType() {
- return MagicAgvDeviceDriver.class;
- }
-
- @Override
- public List getFitDeviceTypes() {
- List types = new LinkedList();
- types.add(DeviceType.agv);
- return types;
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDeviceDriver.java
deleted file mode 100644
index 2ccc733..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDeviceDriver.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.nl.acs.device_driver.agv.magic_agv;
-
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device_driver.DeviceDriver;
-import org.nl.acs.device_driver.DeviceDriverDefination;
-import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
-import org.springframework.stereotype.Service;
-
-/**
- * 普通站点
- */
-@Slf4j
-@Service
-public class MagicAgvDeviceDriver extends AbstractDeviceDriver implements DeviceDriver {
- @Override
- public Device getDevice() {
- return null;
- }
-
- @Override
- public DeviceDriverDefination getDriverDefination() {
- return null;
- }
-
- @Override
- public DeviceDriver setDriverDefination(DeviceDriverDefination var1) {
- return null;
- }
-
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDefination.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDefination.java
deleted file mode 100644
index 68913dc..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDefination.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.nl.acs.device_driver.agv.ndcone;
-
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device.enums.DeviceType;
-import org.nl.acs.device_driver.DeviceDriver;
-import org.nl.acs.device_driver.DeviceDriverDefination;
-import org.springframework.stereotype.Service;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * NDC单工位AGV
- */
-@Service
-public class AgvNdcOneDefination implements DeviceDriverDefination {
- @Override
- public String getDriverCode() {
- return "agv_ndc_one";
- }
-
- @Override
- public String getDriverName() {
- return "NDC1楼AGV";
- }
-
- @Override
- public String getDriverDescription() {
- return "NDC1楼AGV";
- }
-
- @Override
- public DeviceDriver getDriverInstance(Device device) {
- return (new AgvNdcOneDeviceDriver()).setDevice(device).setDriverDefination(this);
-
- }
-
- @Override
- public Class extends DeviceDriver> getDeviceDriverType() {
- return AgvNdcOneDeviceDriver.class;
- }
-
- @Override
- public List getFitDeviceTypes() {
- List types = new LinkedList();
- types.add(DeviceType.agv);
- return types;
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java
deleted file mode 100644
index 5d392a5..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java
+++ /dev/null
@@ -1,498 +0,0 @@
-package org.nl.acs.device_driver.agv.ndcone;
-
-import cn.hutool.core.util.ObjectUtil;
-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.NDCAgvService;
-import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device.service.DeviceService;
-import org.nl.acs.device_driver.DeviceDriver;
-import org.nl.acs.device_driver.FeedLmsRealFailed;
-import org.nl.acs.device_driver.agv.utils.OneAgvPhase;
-import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
-import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
-import org.nl.acs.log.service.DeviceExecuteLogService;
-import org.nl.acs.monitor.DeviceStageMonitor;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.system.service.param.ISysParamService;
-import org.nl.config.SpringContextHolder;
-
-
-import java.util.List;
-
-/**
- * NDC单工位AGV
- */
-@Slf4j
-@Data
-@RequiredArgsConstructor
-public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
-
- ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
- InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
- AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
- NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class);
- DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
- DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
- DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
-// DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
-
- OneAgvPhase oneAgvPhase = new OneAgvPhase();
-
- int agvaddr = 0;
- int agvaddr_copy = 0;
- int weight = 0;
- String device_code = "";
-
- String message = null;
-
- int phase = 0;
- String error_type = "agv_error_type";
- String error_code = "0";
- /**
- * x坐标
- */
- int x = 0;
- /**
- * y坐标
- */
- int y = 0;
- /**
- * 角度
- */
- int angle = 0;
- /**
- * 电量
- */
- int electric_qty = 0;
- /**
- * 三色灯状态
- */
- int status = 0;
- /**
- * 三色灯状态
- */
- int last_status = 0;
- int error = 0;
- int last_error = 0;
- String error_message = "";
-
- private synchronized void setErrorInfo(int error, String error_code, String error_message) {
- this.error = error;
- this.error_code = error_code;
- this.error_message = error_message;
- }
-
- private Instruction instruction;
-
- int mode = 2;
-
- public synchronized void processSocket(int[] arr) throws Exception {
- device_code = this.getDeviceCode();
- byte[] data = null;
- phase = arr[16] * 256 + arr[17];
- // agv任务号
- int index = arr[12] * 256 + arr[13];
- /**
- * 任务号
- */
- int ikey = arr[26] * 256 + arr[27];
- //站点号
- agvaddr = arr[18] * 256 + arr[19];
- //车号
- int carno = arr[20];
- log.info(this.device_code, "", "", "接收agv上报信息:" + "phase--" + phase + " index--" + index + " 指令号--" + ikey + " 站点号--" + agvaddr + " 车号--" + carno);
- Instruction link_inst = null;
- List insts = null;
- Instruction inst = null;
- boolean link_flag = false;
- Device agv_device = null;
- if (carno != 0) {
- agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
- }
- if (ikey != 0) {
- if (phase != 0x67 && phase != 0x71 && phase != 0x72 && phase != 0x73 && phase != 0x74 && phase != 0x75) {
- inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
- this.instruction = inst;
- }
-// if (ObjectUtil.isEmpty(inst)){
-// inst = instructionService.findByCode(String.valueOf(ikey));
-// }
- }
- if (!ObjectUtil.isEmpty(link_inst)) {
- link_flag = true;
- }
-
- Device device = null;
- String old_device_code = null;
- String emptyNum = null;
- String device_code = null;
-
-// if (phase == 0x67) {
-// //故障信息
-// if (arr[18] * 256 + arr[19] == 0) {
-//
-// }
-// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
-// }
-
- //普通站点
- StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
-
- //分配 车id
- //(不需要WCS反馈)
- if (phase == 0x02) {
- inst.setCarno(String.valueOf(carno));
- instructionService.update(inst);
- logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈车号:" + carno + ",指令号:" + ikey);
-
- //到达取货点
- //(需要WCS反馈)
- } else if (phase == 0x03) {
- if (agvaddr == 0) {
- agvaddr = agvaddr_copy;
- }
- if (agvaddr < 1) {
- logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
- return;
- }
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- if (agvaddr != 0) {
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
-
- device = deviceAppService.findDeviceByCode(device_code);
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空");
- return;
- }
- //校验agv上报站点编号与指令起始点相同
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到编号{}对应的指令", ikey);
- logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
- return;
- }
-
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- standardOrdinarySiteDeviceDriver.setAgvphase(phase);
- standardOrdinarySiteDeviceDriver.setIndex(index);
- standardOrdinarySiteDeviceDriver.setInst(inst);
- }
-
-
-
- //取货完毕
- //(需要WCS反馈)
- } else if (phase == 0x05) {
- if (agvaddr == 0) {
- agvaddr = agvaddr_copy;
- }
- if (agvaddr < 1) {
- logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
- return;
- }
- if (agvaddr != 0) {
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
- device = deviceAppService.findDeviceByCode(device_code);
-
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code);
- return;
- }
- //校验agv上报站点编号与指令起始点相同
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到关联编号{}对应的指令", ikey);
- logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
- return;
- }
-
- if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
-
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- standardOrdinarySiteDeviceDriver.setAgvphase(phase);
- standardOrdinarySiteDeviceDriver.setIndex(index);
- standardOrdinarySiteDeviceDriver.setInst(inst);
- }
-
-
-
- }
- if (ObjectUtil.isNotEmpty(data)) {
- logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data));
- }
- //到达放货点
- //(需要WCS反馈)
- } else if (phase == 0x07) {
- if (agvaddr == 0) {
- agvaddr = agvaddr_copy;
- }
- if (agvaddr < 1) {
- logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
- return;
- }
- if (agvaddr != 0) {
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
- device = deviceAppService.findDeviceByCode(device_code);
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- return;
- }
- //校验agv上报站点编号与指令起始点相同
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到关联编号{}对应的指令", ikey);
- return;
- }
- if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
-
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
- }
-
- }
- //放货完毕
- //(需要WCS反馈)
- } else if (phase == 0x09) {
- if (agvaddr == 0) {
- agvaddr = agvaddr_copy;
- }
- if (agvaddr < 1) {
- logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
- return;
- }
- if (agvaddr != 0) {
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
-
- device = deviceAppService.findDeviceByCode(device_code);
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- return;
- }
- //校验agv上报站点编号与指令起始点相同
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到编号{}对应的指令", ikey);
- return;
- }
- if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
-
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
- }
-
- }
- }
- //到达位置点
- //(需要WCS反馈)
- //param,agv货位id待定
- else if (phase == 0x64) {
- //1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备
- agvaddr = arr[18] * 256 + arr[19];
- agvaddr_copy = agvaddr;
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
- //进入交通灯区域
- } else if (phase == 0x50) {
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
- //离开交通灯区域
- } else if (phase == 0x51) {
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
- //agv异常
- } else if (phase == 0x67) {
-// if (ikey == 0) {
-// this.setErrorInfo(ikey, "0", "正常");
-// } else {
-// Map error = ErrorUtil.getAgvErrorMsg(ikey);
-// String code = error.get("code");
-// String info = error.get("info");
-// this.setErrorInfo(ikey, code, info);
-// }
-
- if (error != last_error) {
-// DeviceErrorLogDto dto = new DeviceErrorLogDto();
-// dto.setDevice_code(this.getDevice().getDevice_code());
-// dto.setError_code(String.valueOf(error_code));
-// dto.setError_info(error_message);
-// deviceErrorLogService.create(dto);
-
- JSONObject param = new JSONObject();
- param.put("device_code", this.device_code);
- param.put("error", error);
- param.put("error_msg", error == 0 ? "" : this.getError_message());
- param.put("device_name", this.getDevice().getDevice_name());
- param.put("device_type", "4");
- param.put("product_area", paramService.findByCode("productArea").getValue());
-// acsToWmsService.sendDeviceStatus(param);
- }
- data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
- last_error = error;
- } else if (phase == 0x70) {
- //x坐标
- x = ikey;
- } else if (phase == 0x71) {
- //y坐标
- y = ikey;
- } else if (phase == 0x72) {
- //车辆角度
- angle = ikey;
- } else if (phase == 0x73) {
- //agv电量
- electric_qty = ikey;
- } else if (phase == 0x74) {
- //三色灯状态
- status = ikey;
-
- if (status != last_status && status != 6 && status != 7) {
- boolean flag = true;
- JSONObject param = new JSONObject();
- param.put("device_code", this.device_code);
- if (status == 1) {
- param.put("mode", 0);
- } else if (status == 2) {
- param.put("mode", 3);
- } else if ("345".contains(String.valueOf(status))) {
- param.put("mode", 2);
- } else {
- flag = false;
- }
-
- if (flag) {
-// param.put("device_name", this.getDevice().getDevice_name());
-// param.put("device_type", "4");
-// param.put("product_area", paramService.findByCode("productArea").getValue());
-// acsToWmsService.sendDeviceStatus(param);
- }
- }
-
- last_status = status;
- }
- if (!ObjectUtil.isEmpty(data)) {
- phase = 0;
- logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data));
- OneNDCSocketConnectionAutoRun.write(data);
- }
-
- }
-
- 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;
- }
-
-
- @Override
- public JSONObject getDeviceStatusName() {
- JSONObject jo = new JSONObject();
- //agv编码
- jo.put("car_no", this.getDevice().getDevice_code());
- //agv名称
- jo.put("device_name", this.getDevice().getDevice_name());
- //x坐标
- jo.put("x", this.getX());
- //y坐标
- jo.put("y", this.getY());
- //角度
- jo.put("angle", this.getAngle());
- jo.put("phase", phase);
- jo.put("phase_name", oneAgvPhase.getPhaseName(phase));
- //电量
- jo.put("electricity", this.getElectric_qty());
- String status_name = this.status == 1 ? "关机" : this.status == 2 ? "工作中" : this.status == 3 ? "交通管制" : this.status == 4 ? "任务等待" : this.status == 5 ? "充电中" : this.status == 6 ? "故障中" : this.status == 7 ? "电量低" : "正常";
- //agv状态
- jo.put("status_name", status_name);
- /**
- * 任务号
- */
- jo.put("task_code", ObjectUtil.isEmpty(instruction) ? "0" : instruction.getTask_code());
- //异常
- jo.put("fault", this.getError_message());
- jo.put("message",message);
- return jo;
- }
-
-
-
-
- @Override
- public void setDeviceStatus(JSONObject data) {
-
- }
-
- @Override
- public JSONObject feedLmsRealFailedInfo() {
- JSONObject jo = new JSONObject();
- jo.put("device_code", this.getDevice().getDevice_code());
- jo.put("device_name", this.getDevice().getDevice_name());
- jo.put("fault_code", error_code);
- jo.put("fault_info", error_message);
- jo.put("fault_type", error_type);
- return jo;
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java
deleted file mode 100644
index 494b51b..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java
+++ /dev/null
@@ -1,679 +0,0 @@
-package org.nl.acs.device_driver.agv.ndctwo;
-
-
-import cn.hutool.core.util.ObjectUtil;
-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.AcsConfig;
-import org.nl.acs.agv.server.NDCAgvService;
-import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device.service.DeviceService;
-import org.nl.acs.device_driver.DeviceDriver;
-import org.nl.acs.device_driver.FeedLmsRealFailed;
-import org.nl.acs.device_driver.agv.utils.TwoAgvPhase;
-import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver;
-import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
-import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
-import org.nl.acs.history.ErrorUtil;
-import org.nl.acs.history.service.DeviceErrorLogService;
-import org.nl.acs.history.service.dto.DeviceErrorLogDto;
-import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
-import org.nl.acs.log.service.DeviceExecuteLogService;
-import org.nl.acs.monitor.DeviceStageMonitor;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.task.service.TaskService;
-import org.nl.acs.task.service.dto.TaskDto;
-import org.nl.acs.task.service.impl.TaskServiceImpl;
-import org.nl.config.lucene.service.LuceneExecuteLogService;
-import org.nl.config.lucene.service.dto.LuceneLogDto;
-import org.nl.config.thread.ThreadPoolExecutorUtil;
-import org.nl.system.service.dict.ISysDictService;
-import org.nl.system.service.dict.dao.Dict;
-import org.nl.system.service.param.ISysParamService;
-import org.nl.config.SpringContextHolder;
-
-import java.time.LocalTime;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.concurrent.ThreadPoolExecutor;
-
-
-/**
- * NDC双工位AGV
- */
-@Slf4j
-@Data
-@RequiredArgsConstructor
-public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
-
- ISysParamService ISysParamService = SpringContextHolder.getBean(ISysParamService.class);
- InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
- TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
- AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
- NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
- DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
- DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
- DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
- DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
- LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
- TwoAgvPhase twoAgvPhase = new TwoAgvPhase();
- ISysDictService dictService = SpringContextHolder.getBean(ISysDictService.class);
-
- String error_code = "0";
- int agvaddr = 0;
- int agvaddr_copy = 0;
- int weight = 0;
- int agv_power = 0;
- String device_code = "";
- int phase = 0;
- int region = 0;
- int error = 0;
- int last_error = 0;
- private Instruction instruction;
- String message = null;
- int x = 0; //x坐标
- int y = 0; //y坐标
- int angle = 0; //角度
- int electric_qty = 0; //电量
- int status = 0; //三色灯状态
- int last_status = 0; //三色灯状态
- String error_message = "";
- String error_type = "agv_error_type";
- Boolean isonline = true;
- Boolean iserror = false;
- boolean isCharge = false;
-
- private synchronized void setErrorInfo(int error, String error_code, String error_message) {
- this.error = error;
- this.error_code = error_code;
- this.error_message = error_message;
- }
-
- public synchronized void processSocket(int[] arr) throws Exception {
- device_code = this.getDeviceCode();
- byte[] data = null;
- phase = arr[16] * 256 + arr[17];
- // agv任务号
- int index = arr[12] * 256 + arr[13];
- /**
- * 任务号
- */
- int ikey = arr[26] * 256 + arr[27];
- //站点号
- agvaddr = arr[18] * 256 + arr[19];
- //车号
- int carno = arr[20];
- Instruction inst = null;
- Device agv_device = null;
- if (carno != 0) {
- agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
- }
- TaskDto task = null;
- if (ikey != 0) {
- if (phase != 0x67 && phase != 0x71 && phase != 0x72 && phase != 0x73 && phase != 0x74 && phase != 0x75) {
- inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
- this.instruction = inst;
- }
- if (ObjectUtil.isNotEmpty(inst)) {
-// log.info("该指令号未找到对应指令:" + ikey);
-// message = "该指令号未找到对应指令:" + ikey;
-// logServer.deviceExecuteLog(this.device_code, "", "", "该指令号未找到对应指令:" + ikey);
-// return;
- task = taskService.findByTaskCode(inst.getTask_code());
- } else {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("指令号为空!")
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
- }
-
-
- Device device = null;
- String old_device_code = null;
- String emptyNum = null;
- String device_code = null;
-
- if (agvaddr != 0) {
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
- device = deviceAppService.findDeviceByCode(device_code);
-
- //普通站点
- StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
- //标准-光电检测
- StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
-
-
- if (phase == 0x02) {
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到指令号{}对应的指令", ikey);
- return;
- }
- inst.setCarno(String.valueOf(carno));
- instructionService.update(inst);
- }
- //到达取货点
- //(Itype=1/2/3,需要WCS反馈Phase)
- else if (phase == 0x03) {
- if (agvaddr == 0) {
- agvaddr = agvaddr_copy;
- }
- if (agvaddr < 1) {
- logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
- return;
- }
- device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- if (agvaddr != 0) {
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
-
- device = deviceAppService.findDeviceByCode(device_code);
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content(agvaddr + "对应设备号为空")
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- return;
- }
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到指令号{}对应的指令", ikey);
- return;
- }
- if (ObjectUtil.isEmpty(inst.getCarno())) {
- inst.setCarno(String.valueOf(carno));
- instructionService.update(inst);
- }
-
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- standardOrdinarySiteDeviceDriver.setOption(0);
- } else {
- data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
- }
-
- // 取货完毕
- //(Itype=1/2/3,需要WCS反馈Phase)
- else if (phase == 0x05) {
- if (agvaddr == 0) {
- agvaddr = agvaddr_copy;
- }
- if (agvaddr < 1) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agv地址参数有误,phase:" + phase)
- .build();
- logDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- return;
- }
- if (agvaddr != 0) {
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
- device = deviceAppService.findDeviceByCode(device_code);
-
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("对应设备号为空" + device_code)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- return;
- }
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到指令号{}对应的指令", ikey);
- return;
- }
- if (ObjectUtil.isEmpty(inst.getCarno())) {
- inst.setCarno(String.valueOf(carno));
- instructionService.update(inst);
- }
-
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- standardOrdinarySiteDeviceDriver.setAgvphase(phase);
- standardOrdinarySiteDeviceDriver.setIndex(index);
- standardOrdinarySiteDeviceDriver.setInst(inst);
- } else {
- data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
- }
-
- // 到达放货点
- //(Itype=1/2/3,需要WCS反馈)
- else if (phase == 0x07) {
- if (agvaddr == 0) {
- agvaddr = agvaddr_copy;
- }
- if (agvaddr < 1) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("agv地址参数有误,phase:" + phase)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- return;
- }
- if (agvaddr != 0) {
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
-
- device = deviceAppService.findDeviceByCode(device_code);
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- return;
- }
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到指令号{}对应的指令", ikey);
- return;
- }
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- standardOrdinarySiteDeviceDriver.setOption(0);
-
- } else {
- data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
- }
-
-
- //放货完成
- //(Itype=1/2/3,需要WCS反馈)
- else if (phase == 0x09) {
- if (agvaddr == 0) {
- agvaddr = agvaddr_copy;
- }
- if (agvaddr < 1) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("agv地址参数有误,phase:" + phase)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- return;
- }
- if (agvaddr != 0) {
- CommonFinalParam commonFinalParam = new CommonFinalParam();
- old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
- if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) {
- String[] point = old_device_code.split(commonFinalParam.getBARRE());
- device_code = point[0];
- } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) {
- String[] point = old_device_code.split("\\.");
- device_code = point[0];
- emptyNum = point[1];
- } else {
- device_code = old_device_code;
- }
- }
-
- device = deviceAppService.findDeviceByCode(device_code);
- if (ObjectUtil.isEmpty(device_code)) {
- log.info(agvaddr + "对应设备号为空!");
- return;
- }
- if (ObjectUtil.isEmpty(inst)) {
- log.info("未找到指令号{}对应的指令", ikey);
- return;
- }
- if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
- standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
- data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- standardOrdinarySiteDeviceDriver.setAgvphase(phase);
- standardOrdinarySiteDeviceDriver.setIndex(index);
- standardOrdinarySiteDeviceDriver.setInst(inst);
- } else {
- data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
- }
- //上传AGV电量
- else if (phase == 0x70) {
- //x坐标
- x = ikey;
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "x坐标:" + x)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- } else if (phase == 0x71) {
- //y坐标
- y = ikey;
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "y坐标:" + y)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- } else if (phase == 0x72) {
- //车辆角度
- angle = ikey;
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "车辆角度:" + angle)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- } else if (phase == 0x73) {
- log.info("接收agv上报信息,phase == 0x73:" + phase);
- //agv电量
- electric_qty = ikey;
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "agv电量:" + electric_qty)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- //自动充电的车号
- String is_atuo_car = ISysParamService.findByCode(AcsConfig.IS_ATUO_CAR).getValue();
- //当前上报的车号
- String now_car = String.valueOf(this.agvaddr);
- //如果配置的车号是诺宝车号
- if(now_car.equals(is_atuo_car)){
- //是否开启自动充电
- String is_atuo_electric = ISysParamService.findByCode(AcsConfig.IS_ATUO_ELECTRIC).getValue();
- log.info("接收agv上报信息,is_atuo_electric:" + is_atuo_electric);
- if("1".equals(is_atuo_electric)){
- String electric_begin = ISysParamService.findByCode(AcsConfig.ELECTRIC_BEGIN).getValue();
- String[] begins = electric_begin.split(":");
- String electric_end = ISysParamService.findByCode(AcsConfig.ELECTRIC_END).getValue();
- String[] ends = electric_end.split(":");
- // 定义时间段
- LocalTime startTime = LocalTime.of(Integer.parseInt(begins[0]), Integer.parseInt(begins[1])); // 上午8点
- LocalTime endTime = LocalTime.of(Integer.parseInt(ends[0]), Integer.parseInt(ends[1])); // 晚上22点
- // 获取当前时间
- LocalTime now = LocalTime.now();
- // 判断当前时间是否在时间段内
- boolean isInRange = !now.isBefore(startTime) && !now.isAfter(endTime);
- int electric = 0 ;
- //早上8-22点
- if(isInRange){
- electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC).getValue());
- }else{
- electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC2).getValue());
- }
- if (electric_qty>0 && electric_qty < electric) {
- log.info("当前车辆{}电量为{}低于{},开始判断是否需要充电!", this.agvaddr, electric_qty,electric);
- //判断是否已下发充电任务
- Dict dict1 = dictService.getDictByName3("station",String.valueOf(this.agvaddr),null);
- if(ObjectUtil.isNotEmpty(dict1)){
- log.info("当前车辆{}已分配充电桩{},退出后续判断",this.agvaddr,dict1.getPara1());
- }else{
- //未下发,判断是否有空闲充电桩
- Dict dict = dictService.getDictByName2("station");
- if(ObjectUtil.isNotEmpty(dict)){
- ndcAgvService.charge(String.valueOf(this.agvaddr));
- isCharge =true;
- }else{
- log.info("当前车辆{}电量为{}低于{},但无空闲充电桩!", this.agvaddr, electric_qty,electric);
- }
- }
- }
- }
- }
- } else if (phase == 0x74) {
- //三色灯状态
- status = ikey;
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(this.getDeviceCode())
- .content("agvphase:" + phase + "三色灯状态:" + status)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
-
- if (status != last_status && status != 6 && status != 7) {
- boolean flag = true;
- JSONObject param = new JSONObject();
- param.put("device_code", this.device_code);
- if (status == 1) {
- param.put("mode", 0);
- } else if (status == 2) {
- param.put("mode", 3);
- } else if ("345".contains(String.valueOf(status))) {
- param.put("mode", 2);
- } else {
- flag = false;
- }
-
- if (flag) {
- param.put("device_name", this.getDevice().getDevice_name());
- param.put("device_type", "4");
- param.put("product_area", ISysParamService.findByCode("productArea").getValue());
- acsToWmsService.sendDeviceStatus(param);
- }
- }
-
- last_status = status;
- } //进入区域(phase值)
- else if (phase == 0x50) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("agvphase:" + phase + "自动门开门")
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
- //离开区域(phase值)
- else if (phase == 0x51) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("agvphase:" + phase + "自动门关门")
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
- //上报异常信息
- //(不需要WCS反馈)
- else if (phase == 0x67) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("agvphase:" + phase + "异常信息:" + error)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- //故障信息
- if (ikey == 0) {
- this.setErrorInfo(ikey, "0", "正常");
- } else {
- Map error = ErrorUtil.getAgvErrorMsg(ikey);
- String code = error.get("code");
- String info = error.get("info");
- this.setErrorInfo(ikey, code, info);
- }
- if (error != last_error) {
- DeviceErrorLogDto dto = new DeviceErrorLogDto();
- dto.setDevice_code(this.getDevice().getDevice_code());
- dto.setError_code(String.valueOf(error_code));
- dto.setError_info(error_message);
- deviceErrorLogService.create(dto);
-
- JSONObject param = new JSONObject();
- param.put("device_code", this.device_code);
- param.put("error", error);
- param.put("error_msg", error == 0 ? "" : this.getError_message());
- param.put("device_name", this.getDevice().getDevice_name());
- param.put("device_type", "4");
- param.put("product_area", ISysParamService.findByCode("productArea").getValue());
- acsToWmsService.sendDeviceStatus(param);
- }
- last_error = error;
- }
- if (!ObjectUtil.isEmpty(data)) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("agvphase:" + phase + "反馈:" + data)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
-// if (StrUtil.equals(inst.getAgv_system_type(), "2")) {
-// TwoNDCSocketConnectionAutoRun.write(data);
-// }
-// else if (StrUtil.equals(inst.getAgv_system_type(), "3")) {
-// TwoNDC2SocketConnectionAutoRun.write(data);
-// }
- if (StrUtil.equals(inst.getAgv_system_type(), "2")) {
- TwoNDCSocketConnectionAutoRun.write(data);
- }
- }
-
- }
-
- @Override
- public JSONObject getDeviceStatusName() {
- JSONObject jo = new JSONObject();
- //agv编码
- jo.put("car_no", this.getDevice().getDevice_code());
- //agv名称
- jo.put("device_name", this.getDevice().getDevice_name());
- //x坐标
- jo.put("x", this.getX());
- //y坐标
- jo.put("y", this.getY());
- //角度
- jo.put("angle", this.getAngle());
- jo.put("phase", phase);
- jo.put("phase_name", twoAgvPhase.getPhaseName(phase));
- //电量
- jo.put("electricity", this.getElectric_qty());
- String status_name = this.status == 1 ? "关机" : this.status == 2 ? "工作中" : this.status == 3 ? "交通管制" : this.status == 4 ? "任务等待" : this.status == 5 ? "充电中" : this.status == 6 ? "故障中" : this.status == 7 ? "电量低" : "正常";
- //agv状态
- jo.put("status_name", status_name);
- //任务号
- jo.put("task_code", ObjectUtil.isEmpty(instruction) ? "0" : instruction.getTask_code());
- //异常
- jo.put("fault", this.getError_message());
- jo.put("message", message);
- return jo;
- }
-
- @Override
- public void setDeviceStatus(JSONObject data) {
-
- }
-
- @Override
- public JSONObject feedLmsRealFailedInfo() {
- JSONObject jo = new JSONObject();
- jo.put("device_code", this.getDevice().getDevice_code());
- jo.put("device_name", this.getDevice().getDevice_name());
- jo.put("fault_code", String.valueOf(error));
- jo.put("fault_info", error == 0 ? "正常" : error_message);
- jo.put("fault_type", error_type);
- return jo;
- }
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/IAgv.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/IAgv.java
deleted file mode 100644
index 87efc38..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/IAgv.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.nl.acs.device_driver.agv.utils;
-
-public interface IAgv {
- /**
- * 获取phase名称
- * @param phase
- * @return
- */
- String getPhaseName(Integer phase);
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/OneAgvPhase.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/OneAgvPhase.java
deleted file mode 100644
index d611d3f..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/OneAgvPhase.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.nl.acs.device_driver.agv.utils;
-
-import org.springframework.stereotype.Service;
-
-@Service
-public class OneAgvPhase implements IAgv {
- @Override
- public String getPhaseName(Integer phase) {
- if (phase == 0x01) {
- return "开始任务/上报订单号";
- } else if (phase == 0x02) {
- return "分配车id";
- } else if (phase == 0x03) {
- return "到达取货点";
- } else if (phase == 0x05) {
- return "取货完毕";
- } else if (phase == 0x07) {
- return "到达放货点";
- } else if (phase == 0x09) {
- return "放货完毕";
- } else if (phase == 0x0A) {
- return "任务完毕";
- } else if (phase == 0x30) {
- return "请求删除任务";
- } else if (phase == 0xFF) {
- return "任务删除确认";
- } else if (phase == 0x64) {
- return "到达位置点";
- } else if (phase == 0x65) {
- return "称重就绪";
- }
- return null;
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/TwoAgvPhase.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/TwoAgvPhase.java
deleted file mode 100644
index 0050427..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/TwoAgvPhase.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.nl.acs.device_driver.agv.utils;
-
-import org.springframework.stereotype.Service;
-
-@Service
-public class TwoAgvPhase implements IAgv {
- @Override
- public String getPhaseName(Integer phase) {
- if (phase == 0x01) {
- return "开始任务/上报订单号";
- } else if (phase == 0x02) {
- return "分配车id";
- } else if (phase == 0x03) {
- return "到达取货点1";
- } else if (phase == 0x05) {
- return "取货点1取货完毕";
- } else if (phase == 0x07) {
- return "到达取货点2";
- } else if (phase == 0x09) {
- return "取货点2取货完毕";
- } else if (phase == 0x0A) {
- return "自动缓存线--到达送满框1";
- } else if (phase == 0x0B) {
- return "到达倒料点1";
- } else if (phase == 0x0C) {
- return "自动缓存线--送满框完毕1";
- } else if (phase == 0x0D) {
- return "倒料点1倒料完毕";
- } else if (phase == 0x0E) {
- return "自动缓存线--到达取空框1";
- } else if (phase == 0x0F) {
- return "到达倒料点2";
- } else if (phase == 0x11) {
- return "倒料点2倒料完毕";
- } else if (phase == 0x13) {
- return "到达送箱点1";
- } else if (phase == 0x15) {
- return "送箱点1送箱完毕";
- } else if (phase == 0x17) {
- return "到达送箱点2";
- } else if (phase == 0x19) {
- return "送箱完毕/送空框完毕2";
- } else if (phase == 0x30) {
- return "请求删除任务";
- } else if (phase == 0xFF) {
- return "任务删除确认";
- } else if (phase == 0x64) {
- return "取货完毕/取满框完毕1/点对点取货完毕";
- } else if (phase == 0x65) {
- return "称重就绪";
- } else if (phase == 0x1A) {
- return "任务完毕";
- }
- return null;
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/ItemProtocol.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/ItemProtocol.java
deleted file mode 100644
index 18fe2fc..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/ItemProtocol.java
+++ /dev/null
@@ -1,391 +0,0 @@
-package org.nl.acs.device_driver.agv.xg_agv;
-
-import cn.hutool.core.util.ObjectUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Slf4j
-public class ItemProtocol {
- public static String is_charging = "is_charging";
- public static String stop = "stop";
- public static String DI0 = "DI0";
- public static String DI1 = "DI1";
- public static String DI2 = "DI2";
- public static String DI3 = "DI3";
- public static String DI4 = "DI4";
- public static String DI11 = "DI12";
- public static String DI12 = "DI12";
- public static String DO0 = "DO0";
- public static String DO1 = "DO1";
- public static String DO2 = "DO2";
- public static String x = "x";
- public static String y = "y";
- public static String angle = "angle";
- /**
- * 站点的 id 号, 0 表示无导航站点
- */
- public static String navigation_address = "navigation_address";
- /**
- * 0 = 定位失败, 1 = 定位正确, 2 = 正在重定位, 3 = 定位完成;机器人刚启动后,定位状态为 2,
- * 当定位状态变为 3 时,可以用 [0x]00003 地址位确认定位正确,确认后定位状态将变为 1
- */
- public static String positioning_status = "positioning_status";
-
-
- /**
- * 0 = 无, 1 = 等待执行导航, 2 = 正在执行导航, 3 = 导航暂停, 4 = 到达, 5 = 失败, 6 = 取消, 7 = 超时
- */
- public static String navigation_status = "navigation_status";
-
-
- /**
- * 0 = 没有导航, 1 = 自由导航到任意点, 2 = 自由导航到站点, 3 = 路径导航到站点, 7 = 平动转动, 100 = 其他
- */
- public static String navigation_type = "navigation_type";
- /**
- * 范围为 0 ~ 1
- */
- public static String electricity = "electricity";
- public static String address = "address";
- public static String next_address = "next_address";
- public static String home_relocation = "home_relocation";
- /**
- * 确认定位正确
- */
- public static String locate_correct = "locate_correct";
- public static String pause_navigation = "pause_navigation";
- public static String continue_navigation = "continue_navigation";
- public static String cancle_navigation = "cancle_navigation";
- /**
- * 滚筒运行状态
- */
- public static String drum_run_status = "drum_run_status";
-
-
- public static String to_home_relocation = "to_home_relocation";
- /**
- * 确认定位正确
- */
- public static String to_locate_correct = "to_locate_correct";
- public static String to_pause_navigation = "to_pause_navigation";
- public static String to_continue_navigation = "to_continue_navigation";
- public static String to_cancle_navigation = "to_cancle_navigation";
- public static String to_DO0_height = "to_DO0_height";
- public static String to_DO0_low = "to_DO0_low";
- public static String to_DO1_height = "to_DO1_height";
- public static String to_DO1_low = "to_DO1_low";
- public static String to_DO2_low = "to_DO2_low";
- public static String to_DO8_low = "to_DO8_low";
- public static String to_DO9_low = "to_DO9_low";
-
- public static String to_address = "to_address";
- public static String to_clear_error = "to_clear_error";
- /**
- * 虚拟高电平写
- */
- public static String to_di_height = "to_di_height";
- /**
- * 虚拟低电平写
- */
- public static String to_di_low = "to_di_low";
- /**
- * 下发任务链
- */
- public static String to_line = "to_line";
-
-
- public int getIs_charging() {
- return this.getOpcIntegerValue(is_charging);
- }
-
- public int getStop() {
- return this.getOpcIntegerValue(stop);
- }
-
- public int getDI0() {
- return this.getOpcIntegerValue(DI0);
- }
-
- public int getDI1() {
- return this.getOpcIntegerValue(DI1);
- }
-
- public int getDI2() {
- return this.getOpcIntegerValue(DI2);
- }
-
- public int getDI3() {
- return this.getOpcIntegerValue(DI3);
- }
-
- public int getDI4() {
- return this.getOpcIntegerValue(DI4);
-
- }
-
- public int getDI11() {
- return this.getOpcIntegerValue(DI11);
-
- }
-
- public int getDI12() {
- return this.getOpcIntegerValue(DI12);
-
- }
-
- public int getDO0() {
- return this.getOpcIntegerValue(DO0);
-
- }
-
- public int getDO1() {
- return this.getOpcIntegerValue(DO1);
-
- }
-
- public int getDO2() {
- return this.getOpcIntegerValue(DO2);
-
- }
-
- public Float getX() {
- return this.getOpcFloatValue(x);
-
- }
-
- public Float getY() {
- return this.getOpcFloatValue(y);
-
- }
-
- public Float getAngle() {
- return this.getOpcFloatValue(angle);
-
- }
-
- public short getNavigation_address() {
- return this.getOpcShortValue(navigation_address);
-
- }
-
- public short getPositioning_status() {
- return this.getOpcShortValue(positioning_status);
- }
-
- public short getNavigation_status() {
- return this.getOpcShortValue(navigation_status);
- }
-
- public short getNavigation_type() {
- return this.getOpcShortValue(navigation_type);
-
- }
-
- public int getElectricity() {
- return this.getOpcIntegerValue(electricity);
-
- }
-
- public int getAddress() {
- return this.getOpcIntegerValue(address);
-
- }
-
- public short getNext_address() {
- return this.getOpcShortValue(next_address);
- }
-
- public int getHome_relocation() {
- return this.getOpcIntegerValue(home_relocation);
-
- }
-
- public int getLocate_correct() {
- return this.getOpcIntegerValue(locate_correct);
-
- }
-
- public int getPause_navigation() {
- return this.getOpcIntegerValue(pause_navigation);
-
- }
-
- public int getContinue_navigation() {
- return this.getOpcIntegerValue(continue_navigation);
-
- }
-
- public int getCancle_navigation() {
- return this.getOpcIntegerValue(cancle_navigation);
- }
-
- public short getDrum_run_status() {
- return this.getOpcShortValue(drum_run_status);
- }
-
- public static void setTo_home_relocation(String to_home_relocation) {
- ItemProtocol.to_home_relocation = to_home_relocation;
- }
-
- public static void setTo_locate_correct(String to_locate_correct) {
- ItemProtocol.to_locate_correct = to_locate_correct;
- }
-
- public static void setTo_pause_navigation(String to_pause_navigation) {
- ItemProtocol.to_pause_navigation = to_pause_navigation;
- }
-
- public static void setTo_continue_navigation(String to_continue_navigation) {
- ItemProtocol.to_continue_navigation = to_continue_navigation;
- }
-
- public static void setTo_cancle_navigation(String to_cancle_navigation) {
- ItemProtocol.to_cancle_navigation = to_cancle_navigation;
- }
-
- public static void setTo_DO0_height(String to_DO0_height) {
- ItemProtocol.to_DO0_height = to_DO0_height;
- }
-
- public static void setTo_DO0_low(String to_DO0_low) {
- ItemProtocol.to_DO0_low = to_DO0_low;
- }
-
- public static void setTo_DO1_height(String to_DO1_height) {
- ItemProtocol.to_DO1_height = to_DO1_height;
- }
-
- public static void setTo_DO1_low(String to_DO1_low) {
- ItemProtocol.to_DO1_low = to_DO1_low;
- }
-
- public static void setTo_DO8_low(String to_DO8_low) {
- ItemProtocol.to_DO8_low = to_DO8_low;
- }
-
- public static void setTo_DO9_low(String to_DO9_low) {
- ItemProtocol.to_DO9_low = to_DO9_low;
- }
-
-
- public static void setTo_address(String to_address) {
- ItemProtocol.to_address = to_address;
- }
-
- public static void setTo_clear_error(String to_clear_error) {
- ItemProtocol.to_clear_error = to_clear_error;
- }
-
- public static void setTo_di_height(String to_di_height) {
- ItemProtocol.to_di_height = to_di_height;
- }
-
- public static void setTo_di_low(String to_di_low) {
- ItemProtocol.to_di_low = to_di_low;
- }
-
- private XgagvDeviceDriver driver;
-
- public ItemProtocol(XgagvDeviceDriver driver) {
- this.driver = driver;
- }
-
- public ItemProtocol() {
-
- }
-
-
- public Float getOpcFloatValue(String protocol) {
- Float value = this.driver.getFloatValue(protocol);
- if (ObjectUtil.isEmpty(value)) {
-
- } else {
- return value;
- }
- return 0.0f;
- }
-
- public int getOpcIntegerValue(String protocol) {
- Integer value = this.driver.getIntegerValue(protocol);
- if (value == null) {
-
- } else {
- return value;
- }
- return 0;
-
- }
-
- public short getOpcShortValue(String protocol) {
- Short value = this.driver.getShortValue(protocol);
- if (value == null) {
-
- } else {
- return value;
- }
- return 0;
-
- }
-
- public static List getReadableItemDtos() {
- ArrayList list = new ArrayList();
- list.add(new ItemDto(is_charging, "是否充电", "10003"));
- list.add(new ItemDto(DI0, "DI0", "10020"));
- list.add(new ItemDto(DI1, "DI1", "10021"));
- list.add(new ItemDto(DI2, "DI2", "10022"));
- list.add(new ItemDto(DI3, "DI3", "10023"));
- list.add(new ItemDto(DI4, "DI4", "10024"));
- list.add(new ItemDto(DO1, "DO1", "10061"));
- list.add(new ItemDto(DO2, "DO2", "10062"));
- list.add(new ItemDto(DI11, "DI11", "10031"));
- list.add(new ItemDto(DI12, "DI12", "10032"));
- list.add(new ItemDto(x, "x", "30001"));
- list.add(new ItemDto(y, "y", "30003"));
- list.add(new ItemDto(angle, "angle", "30005"));
- list.add(new ItemDto(navigation_address, "当前导航站点", "30007"));
- list.add(new ItemDto(positioning_status, "定位状态", "30008"));
- list.add(new ItemDto(navigation_status, "当前导航状态", "30009"));
- list.add(new ItemDto(navigation_type, "当前导航类型", "30010"));
- list.add(new ItemDto(electricity, "电量", "30013"));
- list.add(new ItemDto(address, "当前所在站点", "30034"));
- list.add(new ItemDto(next_address, "下一个要经过的站点", "30036"));
- list.add(new ItemDto(home_relocation, "在Home点重定位", "00002"));
- list.add(new ItemDto(locate_correct, "确认定位正确", "00003"));
- list.add(new ItemDto(pause_navigation, "暂停导航", "00004"));
- list.add(new ItemDto(continue_navigation, "继续导航", "00005"));
- list.add(new ItemDto(cancle_navigation, "取消导航", "00006"));
- list.add(new ItemDto(drum_run_status, "滚筒运行状态", "30062"));
- list.add(new ItemDto(stop, "车子停止", "10019"));
-
-
- return list;
- }
-
- public static List getWriteableItemDtos() {
- ArrayList list = new ArrayList();
- list.add(new ItemDto(to_home_relocation, "to_在Home点重定位", "00002"));
- list.add(new ItemDto(to_locate_correct, "to_确认定位正确", "00003"));
- list.add(new ItemDto(to_pause_navigation, "to_暂停导航", "00004"));
- list.add(new ItemDto(to_continue_navigation, "to_继续导航", "00005"));
- list.add(new ItemDto(to_cancle_navigation, "to_取消导航", "00006"));
- list.add(new ItemDto(to_DO0_height, "to_DO0置为高电平", "00061"));
- list.add(new ItemDto(to_DO0_low, "to_DO0置为低电平", "00020"));
- list.add(new ItemDto(to_DO1_height, "to_DO1置为高电平", "00062"));
- list.add(new ItemDto(to_DO1_low, "to_DO1置为低电平", "00021"));
- list.add(new ItemDto(to_DO2_low, "to_DO2置为低电平", "00022"));
- list.add(new ItemDto(to_DO8_low, "to_DO8置为低电平", "00028"));
- list.add(new ItemDto(to_DO9_low, "to_DO9置为低电平", "00029"));
- list.add(new ItemDto(to_address, "to_address", "40001"));
- list.add(new ItemDto(to_clear_error, "to_clear_error", "40090"));
- list.add(new ItemDto(to_di_height, "虚拟高电平写", "40063"));
- list.add(new ItemDto(to_di_low, "虚拟低电平写", "40064"));
- list.add(new ItemDto(to_line, "to_line", "40043"));
-
- return list;
- }
-
-}
-
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDeviceDriver.java
deleted file mode 100644
index ff626a4..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDeviceDriver.java
+++ /dev/null
@@ -1,667 +0,0 @@
-package org.nl.acs.device_driver.agv.xg_agv;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpResponse;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import lombok.Data;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.enums.InstructionStatusEnum;
-import org.nl.acs.utils.ReadUtil;
-import org.nl.acs.device_driver.DeviceDriver;
-import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver;
-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.instruction.service.InstructionService;
-import org.nl.acs.monitor.DeviceStageMonitor;
-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.config.SpringContextHolder;
-import org.nl.config.language.LangProcess;
-import org.nl.config.lucene.service.LuceneExecuteLogService;
-import org.nl.config.lucene.service.dto.LuceneLogDto;
-import org.openscada.opc.lib.da.Server;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * 仙工agv
- */
-@Slf4j
-@Data
-@RequiredArgsConstructor
-public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
- @Autowired
- RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
- @Autowired
- TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
- @Autowired
- InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
- @Autowired
- DeviceAppService deviceAppService = SpringContextHolder.getBean("deviceAppServiceImpl");
- @Autowired
- LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
- ;
- @Autowired
- AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
- /**
- * 车辆ip 0-未知;1-需充电;2-可执行任务;3-充满电
- */
- String agv_mode = "0";
-
- String last_mode = "0";
- private Date instruction_require_time = new Date();
- private int instruction_require_time_out = 3000;
- int is_charging = 0;
- int stop = 0;
- int DI0 = 0;
- int DI1 = 0;
- int DI2 = 0;
- int DI3 = 0;
- int DI4 = 0;
- int DI11 = 0;
- int DI12 = 0;
- int DO0 = 0;
- int DO1 = 0;
- int DO2 = 0;
- Float x = 0f;
- Float y = 0f;
- Float angle = 0f;
- int navigation_address = 0;
- int positioning_status = 0;
- int navigation_status = 0;
- int navigation_type = 0;
- int electricity = 0;
- int address = 0;
- int next_address = 0;
- int home_relocation = 0;
- int locate_correct = 0;
- int pause_navigation = 0;
- int continue_navigation = 0;
- int cancle_navigation = 0;
- int drum_run_status = 0;
-
- int last_is_charging = 0;
- int last_stop = 0;
- int last_DI0 = 0;
- int last_DI1 = 0;
- int last_DI2 = 0;
- int last_DI3 = 0;
- int last_DI4 = 0;
- int last_DI11 = 0;
- int last_DI12 = 0;
- int last_DO0 = 0;
- int last_DO1 = 0;
- int last_DO2 = 0;
- Float last_x = 0f;
- Float last_y = 0f;
- Float last_angle = 0f;
- int last_navigation_address = 0;
- int last_positioning_status = 0;
- int last_navigation_status = 0;
- int last_navigation_type = 0;
- int last_electricity = 0;
- int last_address = 0;
- int last_next_address = 0;
- int last_home_relocation = 0;
- int last_locate_correct = 0;
- int last_pause_navigation = 0;
- int last_continue_navigation = 0;
- int last_cancle_navigation = 0;
- int last_drum_run_status = 0;
- String message = null;
- String device_code;
- Instruction inst = null;
- protected ItemProtocol itemProtocol = new ItemProtocol(this);
-
- /**
- * 最小电量
- */
- double min_electric = 0.0;
- /**
- * 最大电量
- */
- double cancle_electric = 0.0;
- /**
- * 执行任务电量
- */
- double task_electric = 0.0;
- /**
- * 休息点
- */
- int relax_point = 0;
- /**
- * 充电点
- */
- int charge_point = 0;
-
- @Override
- public Device getDevice() {
- return this.device;
- }
-
- @Override
- public void execute() throws Exception {
-
- device_code = this.getDeviceCode();
- is_charging = this.itemProtocol.getIs_charging();
- DI0 = this.itemProtocol.getDI0();
- DI1 = this.itemProtocol.getDI1();
- DI2 = this.itemProtocol.getDI2();
- DI3 = this.itemProtocol.getDI3();
- DI4 = this.itemProtocol.getDI4();
- DI11 = this.itemProtocol.getDI11();
- DI12 = this.itemProtocol.getDI12();
- DO0 = this.itemProtocol.getDO0();
- DO1 = this.itemProtocol.getDO1();
- DO2 = this.itemProtocol.getDO2();
- x = this.itemProtocol.getX();
- y = this.itemProtocol.getY();
- navigation_address = this.itemProtocol.getNavigation_address();
- positioning_status = this.itemProtocol.getPositioning_status();
- navigation_status = this.itemProtocol.getNavigation_status();
- navigation_type = this.itemProtocol.getNavigation_type();
- electricity = this.itemProtocol.getElectricity();
- address = this.itemProtocol.getAddress();
- next_address = this.itemProtocol.getNext_address();
- home_relocation = this.itemProtocol.getHome_relocation();
- locate_correct = this.itemProtocol.getLocate_correct();
- pause_navigation = this.itemProtocol.getPause_navigation();
- continue_navigation = this.itemProtocol.getContinue_navigation();
- cancle_navigation = this.itemProtocol.getCancle_navigation();
- drum_run_status = this.itemProtocol.getDrum_run_status();
- stop = this.itemProtocol.getStop();
- if (home_relocation != last_home_relocation) {
-// luceneExecuteLogService.deviceExecuteLog(
-// new LuceneLogDto(this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.device_code, ItemProtocol.to_home_relocation, this.last_home_relocation, this.home_relocation));
- }
-
- if (stop != last_stop) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.stop + "变更从" + this.last_stop + "->" + this.stop)
- .build();
- logDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
-
- if (address != last_address) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.address + this.last_address + "->" + this.address)
- .build();
- logDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
-
- if (electricity != last_electricity) {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.electricity + this.last_electricity + "->" + this.electricity)
- .build();
- logDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
-
- //获取最小电量
- if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("min_electric"))) {
- message = "未配置最小电量";
- return;
- }
- min_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("min_electric"));
- //获取最大电量
- if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("cancle_electric"))) {
- message = "未配置最大电量";
- return;
- }
- cancle_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("cancle_electric"));
- //可执行任务电量
- if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("task_electric"))) {
- message = "未配置可执行任务电量";
- return;
- }
- task_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("task_electric"));
- //休息点
- if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("relax_point"))) {
- message = "未配置休息点";
- return;
- }
- Device relax_point_device = deviceAppService.findDeviceByCode((String) this.getDevice().getExtraValue().get("relax_point"));
- relax_point = Integer.parseInt(relax_point_device.getAddress());
- //充电点
- if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("charge_point"))) {
- message = "未配置充电点";
- return;
- }
- Device charge_point_device = deviceAppService.findDeviceByCode((String) this.getDevice().getExtraValue().get("charge_point"));
- charge_point = Integer.parseInt(charge_point_device.getAddress());
- List instList = instructionService.findAllInstFromCache();
-
- if (instList.size() > 0) {
- for (int i = 0; i < instList.size(); i++) {
- inst = instList.get(i);
- if (ObjectUtil.equal(inst.getInstruction_type(), CommonFinalParam.ONE)) {
- continue;
- }
- }
- if (ObjectUtil.isEmpty(inst)) {
- message = "未找到对应指令";
- return;
- }
- }
- //先判断当前有无指令
- if (ObjectUtil.isEmpty(inst)) {
- if (electricity != 0 && electricity < min_electric && address != charge_point && (navigation_status == 0 || navigation_status == 4)) {
- log.info("下发充电:{}", charge_point);
- feedAgvTaskStatus(inst, "5");
- }
- if (electricity != 0 && electricity > cancle_electric && address == charge_point && (navigation_status == 0 || navigation_status == 4)) {
- log.info("下发回休息点:{}", relax_point);
-
- }
- } else {
- TaskDto task = taskserver.findByCodeFromCache(inst.getTask_code());
- Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
- Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
- int start_device_code = Integer.parseInt(start_device.getAddress());
- int next_device_code = Integer.parseInt(next_device.getAddress());
-
-
- StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
- //指令状态就绪
- if (StrUtil.equals(InstructionStatusEnum.READY.getIndex(), inst.getInstruction_status())) {
- log.info("下发指令号{},起点{}", inst.getInstruction_code(), start_device);
- //判断指令起点与任务起点是否相同
- feedAgvTaskStatus(inst, CommonFinalParam.ONE);
- }
-
- //取货完成请求离开
- if (StrUtil.equals(InstructionStatusEnum.BUSY.getIndex(), inst.getInstruction_status()) && address == 5 && stop == 1 && StrUtil.equals(inst.getExecute_status(), CommonFinalParam.ONE)) {
- //请求wms是否允许从取货点离开
- feedAgvTaskStatus(inst, "2");
- }
-
- //请求放货
- if (StrUtil.equals(InstructionStatusEnum.BUSY.getIndex(), inst.getInstruction_status()) && address == 2 && stop == 1 && StrUtil.equals(inst.getExecute_status(), "2")) {
- //请求wms是否允许进入放货
- feedAgvTaskStatus(inst, "3");
-
- }
- //放货完成 完成任务回休息点
- if (StrUtil.equals(InstructionStatusEnum.BUSY.getIndex(), inst.getInstruction_status()) && address == 1 && stop == 1 && StrUtil.equals(inst.getExecute_status(), "3")) {
- feedAgvTaskStatus(inst, "4");
- }
-
- }
-
- //请求开门
- if ((address == 3 || address == 11) && stop == 1) {
- feedAgvAction("5");
- }
-
- //请求关门
- if ((address == 9 || address == 10) && stop == 1) {
- feedAgvAction("6");
- }
-
- //请求充电
- if (address == 4 && stop == 1) {
- feedAgvAction("7");
- }
- last_home_relocation = home_relocation;
- last_address = address;
- last_next_address = next_address;
- last_electricity = electricity;
- last_stop = stop;
- }
-
-
- public void writing(String key, int value) {
- String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
- + "." + key;
- String opcservcerid = this.getDevice().getOpc_server_id();
- Server server = ReadUtil.getServer(opcservcerid);
- Map itemMap = new HashMap();
- itemMap.put(to_command, value);
- LuceneLogDto resplogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + key + "value:" + value)
- .build();
-
- ReadUtil.write(itemMap, server);
- }
-
- @Override
- public JSONObject getDeviceStatusName() {
- JSONObject jo = new JSONObject();
- String mode = "";
- jo.put("device_name", this.getDevice().getDevice_name());
- jo.put("message", message);
- jo.put("is_click", true);
- jo.put("address", address);
- jo.put("stop", stop);
- jo.put("electricity", electricity);
- jo.put("is_charging", is_charging);
-
- return jo;
- }
-
- @Override
- public void setDeviceStatus(JSONObject data) {
-
-
- }
-
- /**
- * 反馈wms动作状态
- *
- * @param type
- * @return
- */
- public boolean feedAgvTaskStatus(Instruction inst, String type) 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 {
-
- //请求WMS允许取货
- if (StrUtil.equals(type, CommonFinalParam.ONE)) {
- Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
- Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
- int start_device_code = Integer.parseInt(start_device.getAddress());
- int next_device_code = Integer.parseInt(next_device.getAddress());
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("vehicle_code", inst.getVehicle_code());
- jo.put("status", CommonFinalParam.ONE);
- jo.put("device_code", this.device_code);
- jo.put("task_code", inst.getTask_code());
- ja.add(jo);
- LuceneLogDto reqlogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("请求参数:" + jo)
- .requestparam("请求参数:" + jo)
- .method("feedAgvTaskStatus")
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(reqlogDto);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- LuceneLogDto resplogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("返回参数:" + resp.body())
- .responseparam("返回参数:" + resp.body())
- .method("feedAgvTaskStatus")
- .status_code(String.valueOf(resp.getStatus()))
- .build();
- resplogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(resplogDto);
-
- if (resp.getStatus() == 200) {
-
- inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
- inst.setExecute_status(CommonFinalParam.ONE);
- instructionService.update(inst);
- writing("to_line", 1);
-
- } else {
- writing("to_line", 1);
-
- }
- //取货完成请求离开
- } else if (StrUtil.equals(type, "2")) {
- Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
- Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
- int start_device_code = Integer.parseInt(start_device.getAddress());
- int next_device_code = Integer.parseInt(next_device.getAddress());
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("vehicle_code", inst.getVehicle_code());
- jo.put("status", "2");
- jo.put("device_code", this.device_code);
- jo.put("task_code", inst.getTask_code());
- ja.add(jo);
- LuceneLogDto reqlogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("请求参数:" + jo)
- .requestparam("请求参数:" + jo)
- .method("feedAgvTaskStatus")
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(reqlogDto);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- LuceneLogDto resplogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("返回参数:" + resp.body())
- .responseparam("返回参数:" + resp.body())
- .method("feedAgvTaskStatus")
- .status_code(String.valueOf(resp.getStatus()))
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(resplogDto);
- if (resp.getStatus() == 200) {
-
- inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
- inst.setExecute_status("2");
- instructionService.update(inst);
- } else {
-
- }
- //请求放货
- } else if (StrUtil.equals(type, "3")) {
- Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
- Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
- int start_device_code = Integer.parseInt(start_device.getAddress());
- int next_device_code = Integer.parseInt(next_device.getAddress());
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("vehicle_code", inst.getVehicle_code());
- jo.put("status", "3");
- jo.put("device_code", this.device_code);
- jo.put("task_code", inst.getTask_code());
- ja.add(jo);
- LuceneLogDto reqlogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("请求参数:" + jo)
- .requestparam("请求参数:" + jo)
- .method("feedAgvTaskStatus")
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(reqlogDto);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- LuceneLogDto resplogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("返回参数:" + resp.body())
- .responseparam("返回参数:" + resp.body())
- .method("feedAgvTaskStatus")
- .status_code(String.valueOf(resp.getStatus()))
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(resplogDto);
- if (resp.getStatus() == 200) {
- inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
- inst.setExecute_status("3");
- instructionService.update(inst);
- } else {
-
- }
- } else if (StrUtil.equals(type, "4")) {
- Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
- Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
- int start_device_code = Integer.parseInt(start_device.getAddress());
- int next_device_code = Integer.parseInt(next_device.getAddress());
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("vehicle_code", inst.getVehicle_code());
- jo.put("status", "4");
- jo.put("device_code", this.device_code);
- jo.put("task_code", inst.getTask_code());
- ja.add(jo);
- LuceneLogDto reqlogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("请求参数:" + jo)
- .requestparam("请求参数:" + jo)
- .method("feedAgvTaskStatus")
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(reqlogDto);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- LuceneLogDto resplogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("返回参数:" + resp.body())
- .responseparam("返回参数:" + resp.body())
- .method("feedAgvTaskStatus")
- .status_code(String.valueOf(resp.getStatus()))
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(resplogDto);
- if (resp.getStatus() == 200) {
- writing("to_line", 2);
- inst.setInstruction_status(InstructionStatusEnum.FINISHED.getIndex());
- inst.setExecute_status("4");
- instructionService.finish(inst);
- } else {
-
- }
- } else if (StrUtil.equals(type, "5")) {
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("status", "5");
- jo.put("device_code", this.address);
- ja.add(jo);
- LuceneLogDto reqlogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("请求参数:" + jo)
- .requestparam("请求参数:" + jo)
- .method("feedAgvTaskStatus")
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(reqlogDto);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- LuceneLogDto resplogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("返回参数:" + resp.body())
- .responseparam("返回参数:" + resp.body())
- .method("feedAgvTaskStatus")
- .status_code(String.valueOf(resp.getStatus()))
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(resplogDto);
- if (resp.getStatus() == 200) {
- writing("to_di_low", 0);
- writing("to_di_height", 0);
- } else {
-
- }
- } else if (StrUtil.equals(type, "6")) {
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("status", "6");
- jo.put("device_code", this.device_code);
- ja.add(jo);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- if (resp.getStatus() == 200) {
- writing("to_di_height", 0);
- writing("to_di_low", 0);
- } else {
-
- }
- } else if (StrUtil.equals(type, "7")) {
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("status", "7");
- jo.put("device_code", this.device_code);
- ja.add(jo);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- if (resp.getStatus() == 200) {
- writing("to_di_low", 0);
- } else {
-
- }
- }
- }
- return true;
- }
-
- public boolean feedAgvAction(String type) 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 {
- if (StrUtil.equals(type, "5")) {
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("status", "5");
- jo.put("device_code", "A4");
- ja.add(jo);
- LuceneLogDto reqlogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("请求参数:" + jo)
- .requestparam("请求参数:" + jo)
- .method("feedAgvTaskStatus")
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(reqlogDto);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- LuceneLogDto resplogDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("返回参数:" + resp.body())
- .responseparam("返回参数:" + resp.body())
- .method("feedAgvTaskStatus")
- .status_code(String.valueOf(resp.getStatus()))
- .build();
- reqlogDto.setLog_level(2);
- luceneExecuteLogService.deviceExecuteLog(resplogDto);
- if (resp.getStatus() == 200) {
- writing("to_di_low", 0);
- writing("to_di_height", 0);
- } else {
- writing("to_di_low", 0);
- writing("to_di_height", 0);
- }
- } else if (StrUtil.equals(type, "6")) {
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("status", "6");
- jo.put("device_code", "A4");
- ja.add(jo);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- if (resp.getStatus() == 200) {
- writing("to_di_height", 0);
- writing("to_di_low", 0);
- } else {
- writing("to_di_height", 0);
- writing("to_di_low", 0);
- }
- } else if (StrUtil.equals(type, "7")) {
- JSONArray ja = new JSONArray();
- JSONObject jo = new JSONObject();
- jo.put("status", "7");
- jo.put("device_code", "A4");
- ja.add(jo);
- HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
- if (resp.getStatus() == 200) {
- writing("to_di_height", 0);
- } else {
- writing("to_di_height", 0);
- }
- }
- }
- return true;
- }
-}
-
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv_car/XgAgvCarDefination.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv_car/XgAgvCarDefination.java
deleted file mode 100644
index e07d85d..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv_car/XgAgvCarDefination.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.nl.acs.device_driver.agv.xg_agv_car;
-
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device.enums.DeviceType;
-import org.nl.acs.device_driver.DeviceDriver;
-import org.nl.acs.device_driver.DeviceDriverDefination;
-import org.springframework.stereotype.Service;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * 仙工AGV
- */
-@Service
-public class XgAgvCarDefination implements DeviceDriverDefination {
- @Override
- public String getDriverCode() {
- return "xg_agv_car";
- }
-
- @Override
- public String getDriverName() {
- return "仙工AGV车";
- }
-
- @Override
- public String getDriverDescription() {
- return "仙工AGV车";
- }
-
- @Override
- public DeviceDriver getDriverInstance(Device device) {
- return (new XgAgvCarDeviceDriver()).setDevice(device).setDriverDefination(this);
-
- }
-
- @Override
- public Class extends DeviceDriver> getDeviceDriverType() {
- return XgAgvCarDeviceDriver.class;
- }
-
- @Override
- public List getFitDeviceTypes() {
- List types = new LinkedList();
- types.add(DeviceType.agv);
- return types;
- }
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv_car/XgAgvCarDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv_car/XgAgvCarDeviceDriver.java
deleted file mode 100644
index 6c70564..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv_car/XgAgvCarDeviceDriver.java
+++ /dev/null
@@ -1,313 +0,0 @@
-package org.nl.acs.device_driver.agv.xg_agv_car;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.http.HttpResponse;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import lombok.Data;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.acs.agv.server.NDCAgvService;
-import org.nl.acs.agv.server.XianGongAgvService;
-import org.nl.acs.common.base.CommonFinalParam;
-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.AbstractDeviceDriver;
-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.domain.Instruction;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.log.service.DeviceExecuteLogService;
-import org.nl.acs.monitor.DeviceStageMonitor;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.route.service.RouteLineService;
-import org.nl.acs.task.service.TaskService;
-import org.nl.config.SpringContextHolder;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-
-/**
- * 仙工AGV
- */
-@Slf4j
-@Data
-@RequiredArgsConstructor
-public class XgAgvCarDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
- @Autowired
- DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
- @Autowired
- InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
- @Autowired
- DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
- @Autowired
- RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
- @Autowired
- TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
- @Autowired
- RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
- @Autowired
- AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
- @Autowired
- DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
- @Autowired
- NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
- @Autowired
- XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
-
- Integer hasGoods = 0;
- int error = 0;
- Boolean iserror = false;
- Boolean islock = false;
-
- int branchProtocol = 0;
- int last_branchProtocol = 0;
- /**
- * 是否需要输入物料
- */
- String input_material = "0";
- /**
- * 备注
- */
- String remark = "";
- /**
- * 数量
- */
- String qty = "";
- /**
- * 批次
- */
- String batch = "";
- /**
- * 物料
- */
- String material = "";
- /**
- * 目标点位
- */
- String purpose = "";
- /**
- * 当前指令
- */
- Instruction inst = null;
- /**
- * 上次指令
- */
- Instruction last_inst = null;
-
- boolean requireSucess = false;
-
- /**
- * 触摸屏手动触发任务
- */
- private Boolean is_has_task = false;
-
- /**
- * 申请搬运任务
- */
- private Boolean apply_handling = false;
- /**
- * 申请物料
- */
- private Boolean apply_material = false;
-
- /**
- * 1取货完成 2放货完成 3进入区域 4离开区域
- */
- private int flag;
-
- /**
- * 人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0
- */
- private int manua_confirm = 0;
-
- /**
- * 是否推送场景的状态 0=可推送 1=正在更新场景 2=正在执行运单
- */
- private String upload_scene_status = "";
- /**
- * 机器人当前运单
- */
- private String current_order = "";
- /**
- * 机器人连接状态 0表示断连 1表示连接上
- */
- private String connection_status = "";
- /**
- * 机器人可接单状态 true=可接单 false=不可接单
- */
- private boolean dispatchable = false;
- /**
- * core出错标识
- */
- private boolean is_error = false;
- /**
- * 是否正在执行用户下发的运单
- */
- private boolean procBusiness = false;
- /**
- * 机器人当前地图不在场景中
- */
- private boolean current_map_invalid = false;
- /**
- * 机器人是否断连
- */
- private boolean disconnect = false;
- /**
- * 1 = api 设置可接单,2 = api 设置不可接单(小车占用资源), 3 = api 设置不可接单(小车不占用资源)
- */
- private int dispatchable_status = 0;
- /**
- * 低电量
- */
- private boolean low_battery = false;
- /**
- * 暂停运单
- */
- private boolean suspended = false;
- /**
- * 未确认定位
- */
- private boolean unconfirmed_reloc = false;
- /**
- * 0: 控制权在core手上 1; 控制权被其他人抢走; 2: 控制权没有被抢占
- */
- private int unlock = 0;
-
- /**
- * agv二次分配类型(1、普通任务 2、取货二次分配 3、防货二次分配 4、取放货二次分配)
- */
- private String taskType = "";
-
-
- String device_code = null;
- String container;
- String container_type_desc;
- String last_container_type_desc;
- String last_container;
- private Date instruction_require_time = new Date();
- private Date instruction_finished_time = new Date();
-
- private int instruction_require_time_out;
-
- String message;
-
- // 1 上位系统允许进入 2 上位系统允许离开
- int status = 0;
-
- int agvphase = 0;
- int index = 0;
-
- int mode = 2;
-
- int move;
-
- @Override
- public void execute() {
- try {
-// getAgvStatus();
- } catch (Exception e) {
- message = "获取机器人状态报错";
- }
- }
-
- @Override
- public JSONObject getDeviceStatusName() {
- Map map = new LinkedHashMap<>();
-// try {
-// getAgvStatus();
-// } catch (Exception e) {
-// message = "获取机器人状态报错";
-// }
- String isError;
- if (is_error) {
- isError = "出错,不执行任何运单";
- } else {
- isError = "正常";
- }
- if (CommonFinalParam.ONE.equals(upload_scene_status)) {
- upload_scene_status = "正在更新场景";
- } else if (CommonFinalParam.TWO.equals(upload_scene_status)) {
- upload_scene_status = "正在执行运单";
- } else if (CommonFinalParam.DELETE.equals(upload_scene_status)) {
- upload_scene_status = "可推送";
- }
- map.put("errors", isError);
- map.put("upload_scene_status", upload_scene_status);
- map.put("procBusiness", procBusiness ? "是": "否");
- // map.put("current_order", current_order);
- map.put("connection_status", "1".equals(connection_status) ? "连接上" : "断连");
- map.put("dispatchable", dispatchable ? "可接单" : "不可接单");
- map.put("dispatchable_status", dispatchable_status == 1?"设置可接单" : dispatchable_status == 2?"设置不可接单(小车占用资源)" : dispatchable_status == 3?"设置不可接单(小车不占用资源)" : "未知");
- map.put("current_map_invalid", current_map_invalid ? "机器人不在地图场景中": "机器人在地图场景中");
- map.put("disconnect", disconnect ? "机器人断连" : "机器人连接上");
- map.put("low_battery", low_battery ? "低电量": "正常");
- map.put("suspended", suspended ? "订单被暂停,需要人工手动恢复": "正常");
- map.put("message", message);
- map.put("agv_task_type", taskType);
- map.put("unconfirmed_reloc", unconfirmed_reloc ? "未确认定位" : "正常");
- map.put("unlock", unlock == 0 ? "控制权在core手上" : unlock == 1 ? "控制权被其他人抢走" : unlock == 2 ? "控制权没有被抢占" : "未知");
- map.put("move_2","有货");
- JSONObject jo = new JSONObject(map);
- return jo;
- }
-
-
- @Override
- public void setDeviceStatus(JSONObject data) {
-
- }
-
-
- /**
- * 获取机器人信息
- */
- private void getAgvStatus() {
- HttpResponse robotInfo = xianGongAgvService.getRobotInfo(this.getDevice().getDevice_name());
- if (ObjectUtil.isNotEmpty(robotInfo) && robotInfo.getStatus() == 200) {
- JSONObject jsonObject = JSONObject.parseObject(robotInfo.body());
- String report = jsonObject.getString("report");
- //core出错标识
- is_error = jsonObject.getBooleanValue("is_error");
- //是否推送场景的状态 0=可推送 1=正在更新场景 2=正在执行运单
- upload_scene_status = jsonObject.getString("upload_scene_status");
- JSONArray objects = JSONObject.parseArray(report);
- for (Object object : objects) {
- JSONObject json = (JSONObject) object;
- //是否正在执行用户下发的运单
- procBusiness = json.getBooleanValue("procBusiness");
- //机器人当前运单
- current_order = json.getString("current_order");
- //机器人连接状态 0表示断连 1表示连接上
- connection_status = json.getString("connection_status");
- //机器人可接单状态 true=可接单 false=不可接单
- dispatchable = json.getBooleanValue("dispatchable");
- //机器人不可接单原因
- JSONObject undispatchableReason = json.getJSONObject("undispatchable_reason");
- //机器人当前地图不在场景中
- current_map_invalid = undispatchableReason.getBooleanValue("current_map_invalid");
- //网络断连
- disconnect = undispatchableReason.getBooleanValue("disconnect");
- //可接单状态: 0 = api 设置可接单, 1 = api 设置不可接单
- dispatchable_status = undispatchableReason.getIntValue("dispatchable_status");
- //低电量
- low_battery = undispatchableReason.getBooleanValue("low_battery");
- //当前车子的订单被暂停了,需要人为手动恢复
- suspended = undispatchableReason.getBooleanValue("suspended");
- //未确认定位
- unconfirmed_reloc = undispatchableReason.getBooleanValue("unconfirmed_reloc");
- //0: 控制权在core手上 , 1:控制权被其他人抢走
- unlock = undispatchableReason.getIntValue("unlock");
- }
- } else {
- message = "请求机器人状态失败";
- log.info("请求{}机器人状态失败", this.getDevice().getDevice_name());
- }
- }
-}
-
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/camera/HikvisionDualSnapshot.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/camera/HikvisionDualSnapshot.java
new file mode 100644
index 0000000..dec0a51
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/camera/HikvisionDualSnapshot.java
@@ -0,0 +1,178 @@
+package org.nl.acs.device_driver.camera;
+
+import com.sun.jna.Library;
+import com.sun.jna.Native;
+import com.sun.jna.Structure;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.auth.DigestScheme;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.client5.http.auth.AuthCache;
+import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
+import org.apache.hc.core5.http.HttpHost;
+
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+/**
+ * @Description 海康摄像机抓图
+ * @Author Gengby
+ * @Date 2025/8/18
+ */
+public class HikvisionDualSnapshot {
+
+ // HCNetSDK 接口映射
+ public interface HCNetSDK extends Library {
+ HCNetSDK INSTANCE = Native.load("HCNetSDK", HCNetSDK.class);
+
+ //初始化 SDK 库
+ boolean NET_DVR_Init();
+
+ //登录设备(传入设备 IP、端口、用户名、密码),返回一个用户 ID(后续调用都要用)
+ int NET_DVR_Login_V30(String sDVRIP, short wDVRPort, String sUserName, String sPassword, NET_DVR_DEVICEINFO_V30 lpDeviceInfo);
+
+ //抓拍一张 JPEG 图片保存到本地。
+ boolean NET_DVR_CaptureJPEGPicture(int lUserID, int lChannel, NET_DVR_JPEGPARA lpJpegPara, String sPicFileName);
+
+ //注销登录。
+ boolean NET_DVR_Logout(int lUserID);
+
+ ////清理 SDK 库
+ boolean NET_DVR_Cleanup();
+ }
+
+ @Structure.FieldOrder({"sSerialNumber", "byAlarmInPortNum", "byAlarmOutPortNum", "byDiskNum",
+ "byDVRType", "byChanNum", "byStartChan", "byAudioChanNum", "byIPChanNum"})
+ public static class NET_DVR_DEVICEINFO_V30 extends Structure {
+ //序列号
+ public byte[] sSerialNumber = new byte[48];
+ //报警输入口个数
+ public byte byAlarmInPortNum;
+ //报警输出口个数
+ public byte byAlarmOutPortNum;
+ //硬盘个数
+ public byte byDiskNum;
+ //DVR 类型
+ public byte byDVRType;
+ //模拟通道数
+ public byte byChanNum;
+ //起始通道号
+ public byte byStartChan;
+ //音频通道数
+ public byte byAudioChanNum;
+ //IP 通道数
+ public byte byIPChanNum;
+ }
+
+ @Structure.FieldOrder({"wPicSize", "wPicQuality"})
+ public static class NET_DVR_JPEGPARA extends Structure {
+ // 0: QCIF, 1: CIF, 2: D1, 3: UXGA...
+ public short wPicSize;
+ // 0: 最差, 1: 较差, 2: 一般, 3: 较好, 4:最好
+ public short wPicQuality;
+ }
+
+ public static boolean snapshotHttp(String ip, int port, String username, String password, String channel) {
+ String url = String.format("http://%s:%d/ISAPI/Streaming/channels/%s/picture", ip, port, channel);
+
+ // 1. 设置 Digest 认证信息
+ BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
+ Credentials credentials = new UsernamePasswordCredentials(username, password.toCharArray());
+ credsProvider.setCredentials(new AuthScope(ip, port), credentials);
+
+ // 2. 构造 HttpClient
+ try (CloseableHttpClient httpClient = HttpClients.custom()
+ .setDefaultCredentialsProvider(credsProvider)
+ .build()) {
+
+ HttpGet request = new HttpGet(url);
+
+ // 3. 设置认证缓存,指定 Digest 认证
+ HttpHost targetHost = new HttpHost("http", ip, port);
+ AuthCache authCache = new BasicAuthCache();
+ DigestScheme digestAuth = new DigestScheme();
+ authCache.put(targetHost, digestAuth);
+
+ HttpClientContext localContext = HttpClientContext.create();
+ localContext.setAuthCache(authCache);
+
+ return httpClient.execute(request, localContext, response -> {
+ if (response.getCode() == 200) {
+ try (InputStream inputStream = response.getEntity().getContent();
+ //命名规则:任务号+载具号+时间.jpg
+ FileOutputStream fos = new FileOutputStream("snapshot_http.jpg")) {
+ byte[] buffer = new byte[4096];
+ int len;
+ while ((len = inputStream.read(buffer)) != -1) {
+ fos.write(buffer, 0, len);
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ });
+
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ //HCNetSDK 抓图
+ public static boolean snapshotSdk(String ip, short port, String username, String password, int channel) {
+ if (!HCNetSDK.INSTANCE.NET_DVR_Init()) {
+ System.err.println("[SDK] 初始化失败");
+ return false;
+ }
+ NET_DVR_DEVICEINFO_V30 deviceInfo = new NET_DVR_DEVICEINFO_V30();
+ int userId = HCNetSDK.INSTANCE.NET_DVR_Login_V30(ip, port, username, password, deviceInfo);
+ if (userId < 0) {
+ System.err.println("[SDK] 登录失败");
+ HCNetSDK.INSTANCE.NET_DVR_Cleanup();
+ return false;
+ }
+
+ NET_DVR_JPEGPARA jpegPara = new NET_DVR_JPEGPARA();
+ // D1
+ jpegPara.wPicSize = 2;
+ // 一般质量
+ jpegPara.wPicQuality = 2;
+ //命名规则:任务号+载具号+时间.jpg
+ boolean result = HCNetSDK.INSTANCE.NET_DVR_CaptureJPEGPicture(userId, channel, jpegPara, "snapshot_sdk.jpg");
+ if (result) {
+ System.out.println("[SDK] 抓图成功,保存为 snapshot_sdk.jpg");
+ } else {
+ System.err.println("[SDK] 抓图失败");
+ }
+
+ HCNetSDK.INSTANCE.NET_DVR_Logout(userId);
+ HCNetSDK.INSTANCE.NET_DVR_Cleanup();
+ return result;
+ }
+
+ public static void main(String[] args) {
+ // IP
+ String ip = "192.168.1.64";
+ // 端口号
+ int port = 80;
+ // 账号
+ String username = "admin";
+ // 密码
+ String password = "12345";
+ // HTTP 通道号
+ String channelHttp = "101";
+ // SDK 通道号(一般是 1)
+ int channelSdk = 1;
+
+ boolean ok = snapshotHttp(ip, port, username, password, channelHttp);
+ if (!ok) {
+ System.out.println("[系统] HTTP 抓图失败,尝试 SDK 模式...");
+ snapshotSdk(ip, (short) port, username, password, channelSdk);
+ }
+ }
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java
deleted file mode 100644
index 75db7af..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java
+++ /dev/null
@@ -1,632 +0,0 @@
-package org.nl.acs.device_driver.conveyor.belt_conveyor;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpResponse;
-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.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-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.enums.StorageTypeEnum;
-import org.nl.acs.ext.wms.service.AcsToWmsService;
-import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
-import org.nl.acs.history.ErrorUtil;
-import org.nl.acs.history.service.DeviceErrorLogService;
-import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
-import org.nl.acs.instruction.domain.Instruction;
-import org.nl.acs.instruction.enums.InstructionStatusEnum;
-import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.log.service.DeviceExecuteLogService;
-import org.nl.acs.monitor.DeviceStageMonitor;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.opc.DeviceAppServiceImpl;
-import org.nl.acs.route.service.RouteLineService;
-import org.nl.acs.task.service.TaskService;
-import org.nl.acs.utils.DeviceErrorUtil;
-import org.nl.config.SpringContextHolder;
-import org.nl.config.language.LangProcess;
-import org.nl.config.lucene.service.LuceneExecuteLogService;
-import org.nl.config.lucene.service.dto.LuceneLogDto;
-import org.nl.system.service.param.ISysParamService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-/**
- * 输送线
- */
-@Slf4j
-@Data
-@RequiredArgsConstructor
-public class BeltConveyorDeviceDriver 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
- DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
- @Autowired
- AgvService agvService = SpringContextHolder.getBean(AgvService.class);
- @Autowired
- DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
-
- LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
-
- ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
- DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
-
- private Date instruction_update_time = new Date();
- private Date require_apply_strangulation_time = new Date();
- private int instruction_update_time_out = 500;
- 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;
- private int require_apply_strangulation_time_out = 4000;
-
- String notCreateInstMessage = "";
-
-
- /**
- * 心跳
- */
- int heartbeat = 0;
- int last_heartbeat = 0;
- /**
- * 工作模式
- */
- int mode = 0;
- int last_mode = 0;
- /**
- * 光电信号
- */
- int move = 0;
- int last_move = 0;
- /**
- * 托盘方向
- */
- int container_direction = 0;
- int last_container_direction = 0;
- /**
- * 报警
- */
- int error = 0;
- int last_error = 0;
- /**
- * 动作信号
- */
- int action = 0;
- int last_action = 0;
- /**
- * 任务号
- */
- int task = 0;
- int last_task = 0;
- /**
- * 托盘类型
- */
- int container_type = 0;
- int last_container_type = 0;
- /**
- * 纯数字托盘号
- */
- int container_no = 0;
- int last_container_no = 0;
-
- int inventory_qty = 0;
- int out_finish = 0;
- /**
- * 下发命令
- */
- String to_command = null;
- String last_to_command = null;
- /**
- * 下发目标站
- */
- String to_target = null;
- String last_to_target = null;
- /**
- * 下发任务号
- */
- String to_task = null;
- String last_to_task = null;
- /**
- * 下发接纯数字托盘号
- */
- int to_container_no = 0;
- int last_to_container_no = 0;
- /**
- * 下发托盘类型
- */
- int to_container_type = 0;
- int last_to_container_type = 0;
-
- int to_height_level = 0;
- int last_to_height_level = 0;
-
-
- //子卷条码
- String material_barcode = null;
- String last_material_barcode = null;
- /**
- * 当前指令
- */
- Instruction inst = null;
-
- String material = null;
- String vehicle_code2;
-
- Boolean isonline = true;
-
- Boolean iserror = false;
-
- /**
- * 1-执行任务;2-取货完成;3-放货完成;
- */
- int flag;
-
-
- int last_inventory_qty = 0;
- int last_out_finish = 0;
-
- String last_material = null;
- String message = null;
- String device_code;
- String task_code = null;
- String vehicle_code;
- String inst_message;
-
- String hand_barcode = null;
-
- Boolean ignore_pickup_check = false;
-
- List getDeviceCodeList = null;
-
- List putDeviceCodeList = null;
-
- /**
- * led点阵屏信息
- */
- JSONObject led_message = null;
-
-
- @Override
- public Device getDevice() {
- return this.device;
- }
-
- /**
- * 请求成功标记
- */
- Boolean requireSucess = false;
-
- @Override
- public void execute() {
- try {
- device_code = this.getDeviceCode();
- heartbeat = this.itemProtocol.getHeartbeat();
- mode = this.itemProtocol.getMode();
- move = this.itemProtocol.getMove();
- action = this.itemProtocol.getAction();
- container_direction = this.itemProtocol.getContainer_direction();
- container_type = this.itemProtocol.getContainer_type();
- error = this.itemProtocol.getError();
- task = this.itemProtocol.getTask();
- to_command = this.itemProtocol.getTo_command();
- to_target = this.itemProtocol.getTotarget();
- to_task = this.itemProtocol.getTo_task();
- to_container_no = this.itemProtocol.getContainer_direction();
-
-
- if (move != last_move && last_move == 1 && mode > 0) {
- requireSucess = false;
- }
-
- if (mode != last_mode) {
- requireSucess = false;
- }
-
- if (move != 0 && task > 0) {
- CompletableFuture.runAsync(() -> {
- // 异步更新指令状态
- try {
- update_instruction_status();
- } catch (Exception e) {
- e.printStackTrace();
- log.error("更新指令失败原因:{}", e.getMessage());
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("设备号" + device_code + "报错原因:" + e.getMessage())
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
- });
- if (null != inst) {
- inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code();
- vehicle_code2 = inst.getVehicle_code2();
- }
- }
-
-
- if (mode == 0) {
- this.setIsonline(false);
- message = "脱机";
- } else if (error != 0) {
- this.setIserror(true);
- message = "有报警";
-
- } else {
- this.setIsonline(true);
- this.setIserror(false);
- message = "";
- Instruction instruction = null;
- List toInstructions;
-
- switch (mode) {
- case 1:
- log.debug("弃用(留作兼容)");
- break;
- case 2:
- //申请任务
- if (move == 1 && !requireSucess) {
- instruction_require();
- } else {
- String remark = "";
- ;
- if (mode != 2) {
- remark = "universal_remark2";
- }
- if (move != 0) {
- remark = "universal_remark3";
- }
- if (task != 0) {
- remark = "universal_remark4";
- if (ObjectUtil.isNotEmpty(this.inst)) {
- this.inst = null;
- }
- }
- if (requireSucess) {
- remark = "universal_remark5";
- }
- this.setNotCreateInstMessage(remark);
- //}
- }
- break;
- case 3:
- log.info(this.device_code + ",运行中");
- break;
- default:
- break;
- }
- }
-
- } catch (Exception var17) {
- this.iserror = true;
- message = "读取信号值时出现异常";
- String extracted = DeviceErrorUtil.extracted(var17);
- if (var17 instanceof NullPointerException) {
- message += " - 空指针异常";
- // 记录详细的堆栈跟踪信息
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- var17.printStackTrace(pw);
- String stackTrace = sw.toString();
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content(this.device_code + extracted + ",报错信息:" + var17.getMessage() + ",堆栈跟踪:" + stackTrace)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- } else {
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content(this.device_code + extracted + ",报错信息:" + var17.getMessage())
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- var17.printStackTrace();
- }
- }
-
- last_heartbeat = heartbeat;
- last_mode = mode;
- last_move = move;
- last_error = error;
- last_container_direction = container_direction;
- last_container_no = container_no;
- last_container_type = container_type;
- last_action = action;
- last_task = task;
- last_to_command = to_command;
- last_to_target = to_target;
- last_to_task = to_task;
- last_to_container_no = to_container_no;
- last_to_container_type = to_container_type;
- }
-
-
- 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.conveyor.belt_conveyor.ItemProtocol.item_to_command;
- Map itemMap = new HashMap();
- itemMap.put(to_command, command);
- this.control(itemMap);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("下发多个电气信号" + itemMap)
- .build();
- logDto.setLog_level(3);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
-
- private void applyEmptyTask(String type, int mode) {
- Date date = new Date();
- if (date.getTime() - this.require_apply_strangulation_time.getTime()
- < (long) this.require_apply_strangulation_time_out) {
- log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
- return;
- } else {
- this.require_apply_strangulation_time = date;
- try {
- JSONObject param = new JSONObject();
- param.put("device_code", device_code);
- param.put("container_type", container_type);
- param.put("type", type);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("申请空托盘出入库,参数:" + param)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- HttpResponse httpResponse = acsToWmsService.applyTwo(param);
- JSONObject jsonObject = null;
- if(ObjectUtil.isNotEmpty(httpResponse)){
- String body = httpResponse.body();
- jsonObject = JSONObject.parseObject(body);
- }
- message = "申请空托盘出入库,返回参数:" + jsonObject;
- if (ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200) {
- LuceneLogDto logDto2 = LuceneLogDto.builder()
- .device_code(device_code)
- .content("申请空托盘出入库,参数,接口返回:" + jsonObject)
- .build();
- logDto2.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto2);
- List list1 = new ArrayList();
- Map map = new HashMap();
- map.put("code", "to_command");
- map.put("value", mode);
- list1.add(map);
- this.writing(list1);
- this.requireSucess = true;
- } else {
- this.iserror = true;
- message = "申请空托盘出入库出错,返回参数:" + jsonObject;
- LuceneLogDto logDto2 = LuceneLogDto.builder()
- .device_code(device_code)
- .content("申请空托盘出入库,返回参数:" + jsonObject)
- .build();
- logDto2.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto2);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
-
- /**
- * 申请任务
- */
- public synchronized Boolean
- instruction_require() {
- return true;
- }
-
- public void writing(List list) {
-
- Map itemMap = new HashMap();
- for (int i = 0; i < list.size(); i++) {
- Object ob = list.get(i);
- JSONObject json = (JSONObject) JSONObject.toJSON(ob);
- if (!StrUtil.isEmpty(json.getString("value"))) {
- String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
- + "." + json.getString("code");
- itemMap.put(to_param, json.getString("value"));
- }
- }
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("下发多个电气信号" + itemMap)
- .build();
- logDto.setLog_level(3);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
- try {
- this.checkcontrol(itemMap);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public void writing(String key, String param) {
-
- String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
- + "." + key;
- //String opcservcerid = this.getDevice().getOpc_server_id();
- //Server server = ReadUtil.getServer(opcservcerid);
- Map itemMap = new HashMap();
-
- itemMap.put(to_param, Integer.parseInt(param));
- //itemMap.put(to_param, Integer.parseInt(value));
- this.control(itemMap);
- logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + param);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("下发多个电气信号" + itemMap)
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
- }
-
- public synchronized boolean finish_instruction() throws Exception {
- instructionService.finish(inst);
- return true;
- }
-
- @Override
- public JSONObject getDeviceStatusName() {
- JSONObject jo = new JSONObject();
- String mode = "";
- String move = "";
- String requireSucess = "0";
- if (this.requireSucess) {
- requireSucess = "1";
- }
- if (this.getMode() == 0) {
- mode = LangProcess.msg("universal_off-line");
- } else if (this.getMode() == 1) {
- mode = LangProcess.msg("universal_stand-alone");
- } else if (this.getMode() == 2) {
- mode = LangProcess.msg("universal_standby");
- } else if (this.getMode() == 3) {
- mode = LangProcess.msg("universal_operation");
- } else if (this.getMode() == 5) {
- mode = LangProcess.msg("one_mode3");
- }
-
- jo.put("device_name", this.getDevice().getDevice_name());
- jo.put("mode", mode);
- jo.put("message", message);
- jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
- if (this.getMove() == 0) {
- move = LangProcess.msg("universal_no");
- jo.put("hasGoods", false);
- } else if (this.getMove() == 1) {
- move = LangProcess.msg("universal_yes");
- jo.put("hasGoods", true);
- } else if (this.getMove() == 2) {
- move = LangProcess.msg("universal_two_yes");
- jo.put("hasGoods", true);
- }
- String container_type = "";
- if (this.container_type == 1) {
- container_type = LangProcess.msg("universal_small_pallets");
- } else if (this.container_type == 2) {
- container_type = LangProcess.msg("universal_large_pallets");
- }
- jo.put("move", move);
- jo.put("task", task);
- jo.put("type", container_type);
- jo.put("is_click", true);
- jo.put("isOnline", this.getIsonline());
- jo.put("requireSucess", requireSucess);
- jo.put("hand_barcode", hand_barcode);
- jo.put("materiel", material_barcode);
- jo.put("inst_message", this.inst_message);
- jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage));
- jo.put("vehicle_code2", this.vehicle_code2);
- return jo;
- }
-
-
- /**
- * 更新指令状态
- */
- public synchronized void update_instruction_status() throws Exception {
- Date date = new Date();
- if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
- log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
- } else {
- this.instruction_update_time = date;
- inst = checkInst();
- if (inst != null) {
- //a点到b点,给状态说允许取货
- if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
- inst.setInstruction_status(CommonFinalParam.ONE);
- inst.setExecute_device_code(this.device_code);
- instructionService.update(inst);
- logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task);
- }
- //当货物到达b点,实现完成指令
-
- if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) || StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) {
- if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
- inst.setExecute_device_code(this.device_code);
- finish_instruction();
- logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task);
- }
- }
- }
- }
- }
-
- public Instruction checkInst() {
- if (ObjectUtil.isNotEmpty(this.inst)) {
- if (this.task > 0) {
- if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) {
- return this.inst;
- } else {
- inst = instructionService.findByCodeFromCache(String.valueOf(task));
- return inst;
- }
- }
- } else {
- inst = instructionService.findByCodeFromCache(String.valueOf(task));
- return inst;
- }
- return null;
- }
-
-
- @Override
- public void setDeviceStatus(JSONObject data) {
- String requestSucess = data.getString("requireSucess");
- if (StrUtil.equals(requestSucess, "0")) {
- this.requireSucess = false;
- } else if (StrUtil.equals(requestSucess, "1")) {
- this.requireSucess = true;
- }
- String hand_barcode = data.getString("hand_barcode");
- this.setHand_barcode(hand_barcode);
- }
-
- public static boolean arrayEquals(int[] a, int[] b) {
- // 判断两个数组长度是否相等
- if (a.length != b.length) {
- return false;
- }
- // 判断两个数组对应位置上的元素是否相同
- for (int i = 0; i < a.length; i++) {
- if (a[i] != b[i]) {
- return false;
- }
- }
- return true;
- }
-
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java
deleted file mode 100644
index 3dac73a..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java
+++ /dev/null
@@ -1,197 +0,0 @@
-package org.nl.acs.device_driver.conveyor.belt_conveyor;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-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_container_direction = "container_direction";
- /**
- * 托盘类型
- */
- public static String item_container_type = "container_type";
- /**
- * 任务号
- */
- public static String item_task = "task";
-
- /**
- * 下发命令
- */
- public static String item_to_command = "to_command";
- /**
- * 下发托盘类型
- */
- public static String item_to_container_type = "to_container_type";
- /**
- * 下发任务号
- */
- public static String item_to_task = "to_task";
- /**
- * 下发目标站
- */
- public static String item_to_target = "to_target";
-
-
-
-
-
-
-
-
- private BeltConveyorDeviceDriver driver;
-
- public ItemProtocol(BeltConveyorDeviceDriver driver) {
- this.driver = driver;
- }
-
-
- public int getHeartbeat() {
- return this.getOpcIntegerValue(item_heartbeat);
- }
-
- public int getMode() {
- return this.getOpcIntegerValue(item_mode);
- }
-
- public int getMove() {
- return this.getOpcIntegerValue(item_move);
- }
-
- public int getContainer_direction() {
- return this.getOpcIntegerValue(item_container_direction);
- }
-
- public int getContainer_type() {
- return this.getOpcIntegerValue(item_container_type);
- }
-
- public int getAction() {
- return this.getOpcIntegerValue(item_action);
- }
-
-
- public int getError() {
- return this.getOpcIntegerValue(item_error);
- }
-
- public int getTask() {
- return this.getOpcIntegerValue(item_task);
- }
-
- public String getTo_task() {
- return this.getOpcStringValue(item_to_task);
- }
-
-
-
-
- public String getTotarget() {
- return this.getOpcStringValue(item_to_target);
- }
-
- public String getTo_command() {
- return this.getOpcStringValue(item_to_command);
- }
-
- public int getTo_container_type() {
- return this.getOpcIntegerValue(item_to_container_type);
- }
-
- Boolean isonline;
-
- public int getOpcIntegerValue(String protocol) {
- Integer value = this.driver.getIntegeregerValue(protocol);
- if (value == null) {
- setIsonline(false);
- } else {
- setIsonline(true);
- return value;
- }
- return 0;
- }
-
-
- public String getOpcStringValue(String protocol) {
- String value = this.driver.getStringValue(protocol);
- if (StrUtil.isBlank(value)) {
- //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)});
-
- } else {
- return value;
- }
- return "";
- }
-
- public int[] getOpcArrayValue(String protocol) {
- int[] arrayValue = this.driver.getIntegeregerArrayValue(protocol);
- if (ObjectUtil.isNull(arrayValue)) {
-
- } else {
- return arrayValue;
- }
- return new int[3];
- }
-
-
- public static List getReadableItemDtos() {
- ArrayList list = new ArrayList();
- list.add(new ItemDto(item_heartbeat, "心跳", "DB101.B0"));
- list.add(new ItemDto(item_mode, "工作模式", "DB101.B2"));
- list.add(new ItemDto(item_move, "光电信号", "DB101.B3"));
- list.add(new ItemDto(item_container_direction, "托盘方向", "DB101.B4"));
- list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B5"));
- list.add(new ItemDto(item_action, "动作类型", "DB101.B6"));
- list.add(new ItemDto(item_error, "报警", "DB101.B58"));
- list.add(new ItemDto(item_task, "任务号", "DB101.D68"));
- return list;
- }
-
- public static List getWriteableItemDtos() {
- ArrayList list = new ArrayList();
- list.add(new ItemDto(item_to_target, "下发仓位号", "DB102.W2"));
- list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4"));
- list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D1"));
- list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB102.B5"));
-
- return list;
- }
-
- @Override
- public String toString() {
- return "";
- }
-
-}
-
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java
deleted file mode 100644
index d98844d..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.nl.acs.device_driver.conveyor.belt_conveyor;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.io.Serializable;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class Paper implements Serializable {
- /**
- * 设备号
- */
- private String device_code;
-
- private String material_code;
- private String qty;
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java
index 2fc71f1..c695b29 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java
@@ -257,12 +257,6 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
} catch (Exception e) {
e.printStackTrace();
}
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(devicecode)
- .content("下发多个电气信号" + itemMap)
- .build();
- logDto.setLog_level(3);
- luceneExecuteLogService.deviceExecuteLog(logDto);
}
public void writing(int type, int command) {
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java
index 41870a3..7473b29 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java
@@ -1,35 +1,18 @@
package org.nl.acs.device_driver.conveyor.standard_ordinary_site;
-import cn.hutool.core.util.ObjectUtil;
-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.NDCAgvService;
-import org.nl.acs.common.base.CommonFinalParam;
-import org.nl.acs.device.domain.Device;
-import org.nl.acs.device.service.DeviceService;
-import org.nl.acs.device.service.dto.DeviceDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
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.history.ErrorUtil;
-import org.nl.acs.instruction.domain.Instruction;
+import org.nl.acs.ext.hk.service.AcsToHkService;
import org.nl.acs.instruction.service.InstructionService;
-import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
-import org.nl.acs.opc.DeviceAppService;
-import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.config.SpringContextHolder;
-import org.nl.config.language.LangProcess;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Date;
/**
@@ -39,190 +22,32 @@ import java.util.Date;
@Data
@RequiredArgsConstructor
public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
- @Autowired
- DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
- @Autowired
- InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
- @Autowired
- DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
- @Autowired
- RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
- @Autowired
- TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
- @Autowired
- RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
- @Autowired
- AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
- @Autowired
- DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
- @Autowired
- NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
+ private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
+ private final TaskService taskService = SpringContextHolder.getBean(TaskService.class);
+ private final AcsToHkService acsToHkService = SpringContextHolder.getBean(AcsToHkService.class);
- Integer hasGoods = 0;
- int error = 0;
- Boolean iserror = false;
- Boolean islock = false;
-
- // 1 上位系统允许进入 2 上位系统允许离开
- int option = 0;
-
- int branchProtocol = 0;
- int last_branchProtocol = 0;
- /**
- * 是否需要输入物料
- */
- String input_material = "0";
- /**
- * 备注
- */
- String remark = "";
- /**
- * 数量
- */
- String qty = "";
- /**
- * 批次
- */
- String batch = "";
- /**
- * 物料
- */
- String material = "";
- /**
- * 目标点位
- */
- String purpose = "";
- /**
- * 当前指令
- */
- Instruction inst = null;
- /**
- * 上次指令
- */
- Instruction last_inst = null;
-
- boolean requireSucess = false;
-
- /**
- * 触摸屏手动触发任务
- */
- private Boolean is_has_task = false;
-
- /**
- * 申请搬运任务
- */
- private Boolean apply_handling = false;
-
- /**
- * 忽略校验
- */
- private Boolean standard_ordinary_site = false;
- /**
- * 申请物料
- */
- private Boolean apply_material = false;
-
- /**
- * 1取货完成 2放货完成 3进入区域 4离开区域
- */
- private int flag;
-
- //任务号
- String task_code;
-
- /**
- * 人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0
- */
- private int manua_confirm = 0;
String device_code = null;
- String container;
- String container_type_desc;
- String last_container_type_desc;
- String last_container;
- private Date instruction_require_time = new Date();
- private Date instruction_finished_time = new Date();
-
- private int instruction_require_time_out;
String message;
- // 1 上位系统允许进入 2 上位系统允许离开
- int status = 0;
-
- int agvphase = 0;
- int index = 0;
-
- int mode = 2;
-
- int move;
@Override
public void execute() {
- hasGoods = this.getDevice().getHas_goods();
- batch = this.getDevice().getBatch();
- device_code = this.getDeviceCode();
+ device_code = this.getDevice().getDevice_code();
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
- String mode = "";
-// String action = "";
- String move = "";
- String option = "";
- if (this.getOption() == 0) {
- option = LangProcess.msg("universal_actionMessage1");
- } else if (this.getOption() == 1) {
- option = LangProcess.msg("universal_actionMessage2");
- } else if (this.getOption() == 2) {
- option = LangProcess.msg("universal_actionMessage3");
- }
- if (this.getMode() == 0) {
- mode = LangProcess.msg("universal_off-line");
- } else if (this.getMode() == 1) {
- mode = LangProcess.msg("universal_stand-alone");
- } else if (this.getMode() == 2) {
- mode = LangProcess.msg("universal_standby");
- } else if (this.getMode() == 3) {
- mode = LangProcess.msg("universal_operation");
- }
-
-
- if (this.getMove() == 0) {
- move = LangProcess.msg("universal_no");
- jo.put("hasGoods", false);
- } else if (this.getMove() == 1) {
- move = LangProcess.msg("universal_yes");
- jo.put("hasGoods", true);
- } else if (this.getMove() == 2) {
- move = LangProcess.msg("universal_two_yes");
- jo.put("hasGoods", true);
- }
- jo.put("device_name", this.getDevice().getDevice_name());
- DeviceDto dto = deviceservice.findByCode(this.getDevice().getDevice_code());
- jo.put("zh_device_name",dto.getZh_device_name());
- jo.put("en_device_name",dto.getEn_device_name());
- jo.put("in_device_name",dto.getIn_device_name());
- jo.put("mode", mode);
- jo.put("move", move);
-// jo.put("action", action);
- jo.put("isOnline", true);
-// jo.put("error", ErrorUtil.getDictDetail("error_type", String.valueOf(this.getError())));
- jo.put("isError", this.getIserror());
- jo.put("option", option);
- jo.put("is_click", true);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
- String flag = data.getString("option");
- if(StrUtil.isNotEmpty(flag)){
- option = Integer.parseInt(flag);
- }
+
}
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/ItemProtocol.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/ItemProtocol.java
new file mode 100644
index 0000000..33e4ce2
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/ItemProtocol.java
@@ -0,0 +1,64 @@
+package org.nl.acs.device_driver.conveyor.standard_weight;
+
+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_weight = "weight";
+
+ private StandardWeightSiteDeviceDriver driver;
+
+ public ItemProtocol(StandardWeightSiteDeviceDriver driver) {
+ this.driver = driver;
+ }
+
+ public Float getWeight() {
+ return this.getOpcFloatValue(item_weight);
+ }
+
+ 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 Float getOpcFloatValue(String protocol) {
+ Float value = this.driver.getFloatValue(protocol);
+ if (value == null) {
+ setIsonline(false);
+ } else {
+ setIsonline(true);
+ return value;
+ }
+ return 0.0f;
+ }
+
+ public static List getReadableItemDtos() {
+ ArrayList list = new ArrayList();
+ list.add(new ItemDto(item_weight, "重量", "40001"));
+ return list;
+ }
+
+ public static List getWriteableItemDtos() {
+ ArrayList list = new ArrayList();
+ return list;
+ }
+
+}
+
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDefination.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/StandardWeightSiteDefination.java
similarity index 67%
rename from nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDefination.java
rename to nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/StandardWeightSiteDefination.java
index 1ce3a1a..19f4c03 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDefination.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/StandardWeightSiteDefination.java
@@ -1,4 +1,4 @@
-package org.nl.acs.device_driver.agv.xg_agv;
+package org.nl.acs.device_driver.conveyor.standard_weight;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device.domain.Device;
@@ -11,40 +11,41 @@ import java.util.LinkedList;
import java.util.List;
/**
- * magic3.0
+ * 检测站点驱动定义
+ * 说明:该站点为普通带光电检测站点
*/
@Service
-public class XgagvDefination implements OpcDeviceDriverDefination {
+public class StandardWeightSiteDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
- return "xg_agv";
+ return "standard_weight";
}
@Override
public String getDriverName() {
- return "仙工AGV";
+ return "标准版-称重站点";
}
@Override
public String getDriverDescription() {
- return "仙工AGV";
+ return "标准版-称重站点";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
- return (new XgagvDeviceDriver()).setDevice(device).setDriverDefination(this);
+ return (new StandardWeightSiteDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class extends DeviceDriver> getDeviceDriverType() {
- return XgagvDeviceDriver.class;
+ return StandardWeightSiteDeviceDriver.class;
}
@Override
public List getFitDeviceTypes() {
List types = new LinkedList();
- types.add(DeviceType.agv);
+ types.add(DeviceType.conveyor);
return types;
}
@@ -57,4 +58,5 @@ public class XgagvDefination implements OpcDeviceDriverDefination {
public List getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
+
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/StandardWeightSiteDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/StandardWeightSiteDeviceDriver.java
new file mode 100644
index 0000000..c9c1968
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_weight/StandardWeightSiteDeviceDriver.java
@@ -0,0 +1,194 @@
+package org.nl.acs.device_driver.conveyor.standard_weight;
+
+import cn.hutool.core.util.ObjectUtil;
+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.device.domain.Device;
+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.enums.ApplyPassEnum;
+import org.nl.acs.ext.hk.UnifiedResponse;
+import org.nl.acs.ext.hk.service.AcsToHkService;
+import org.nl.acs.ext.hk.service.data.BoxApplyPassReq;
+import org.nl.acs.ext.wms.service.AcsToWmsService;
+import org.nl.acs.instruction.domain.Instruction;
+import org.nl.acs.instruction.enums.InstTypeEnum;
+import org.nl.acs.instruction.service.InstructionService;
+import org.nl.acs.monitor.DeviceStageMonitor;
+import org.nl.acs.task.service.TaskService;
+import org.nl.config.SpringContextHolder;
+import org.nl.config.lucene.service.LuceneExecuteLogService;
+import org.nl.config.lucene.service.dto.LuceneLogDto;
+
+import java.util.Optional;
+
+
+/**
+ * 称重站点驱动
+ */
+@Slf4j
+@Data
+@RequiredArgsConstructor
+public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
+
+ protected ItemProtocol itemProtocol = new ItemProtocol(this);
+
+ private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
+ private final AcsToHkService acsToHkService = SpringContextHolder.getBean(AcsToHkService.class);
+ private final LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
+ private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
+ private final TaskService taskService = SpringContextHolder.getBean(TaskService.class);
+
+ private Float weight = 0.0f;
+ private Float last_weight = 0.0f;
+
+ String deviceCode;
+
+ /**
+ * CTU请求取货标记和任务号
+ */
+ private volatile String reqTakeInstCode = null;
+ private volatile Boolean reqTakeRequireSuccess = false;
+
+ /**
+ * 请求时间
+ */
+ private long requireTime = System.currentTimeMillis();
+
+ /**
+ * 请求间隔时间
+ */
+ private long requireTimeOut = 5000L;
+
+ /**
+ * 反馈WMS重量执行次数
+ */
+ private int executeTimes = 0;
+
+
+ @Override
+ public Device getDevice() {
+ return this.device;
+ }
+
+ private boolean isTimeValid(long currentTimeMillis) {
+ return currentTimeMillis - this.requireTime >= this.requireTimeOut;
+ }
+
+ @Override
+ public void execute() {
+ this.deviceCode = this.getDevice().getDevice_code();
+ this.weight = this.itemProtocol.getWeight();
+
+ if (!this.weight.equals(this.last_weight)) {
+ luceneExecuteLogService.deviceExecuteLog(new LuceneLogDto(this.deviceCode, "自动线程读取信号: weight,由" + this.last_weight + "->" + this.weight));
+ }
+
+ if (this.reqTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqTakeInstCode)) {
+ Instruction instruction = instructionService.findByCodeFromCache(this.reqTakeInstCode);
+ //取货申请
+ if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_device_code(), this.deviceCode)) {
+ if (StrUtil.equals(InstTypeEnum.CTU_IN_TASK.getCode(), instruction.getInstruction_type())) {
+ boolean feedFlag = Optional.ofNullable(this.getDevice().getExtraValue().get("isFeedWeight")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
+ if (feedFlag) {
+ this.feedWeight(instruction);
+ } else {
+ this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode());
+ }
+ } else {
+ this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode());
+ }
+ }
+ //放货申请
+ else if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_device_code(), this.deviceCode)) {
+ boolean putFlag = Optional.ofNullable(this.getDevice().getExtraValue().get("ignore_release_check")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
+ if (putFlag) {
+ this.applyPass(instruction);
+ } else {
+ this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
+ }
+ }
+ }
+ this.last_weight = this.weight;
+ }
+
+
+ private void feedWeight(Instruction instruction) {
+ long currentTimeMillis = System.currentTimeMillis();
+ if (!isTimeValid(currentTimeMillis)) {
+ log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
+ } else {
+ this.requireTime = currentTimeMillis;
+ JSONObject reqParam = new JSONObject();
+ reqParam.put("task_code", instruction.getTask_code());
+ reqParam.put("weigh_qty", this.weight);
+ UnifiedResponse wmsUnifiedResponse = acsToWmsService.feedWeight(reqParam, JSONObject.class);
+ if (wmsUnifiedResponse.isSuccess()) {
+ JSONObject data = wmsUnifiedResponse.getData();
+ if (data != null && "1".equals(data.getString("is_weigh"))) {
+ this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode());
+ } else {
+ try {
+ instructionService.cancel(instruction.getInstruction_id());
+ taskService.cancelNoSendWms(instruction.getTask_id());
+ } catch (Exception e) {
+ luceneExecuteLogService.deviceExecuteLog(new LuceneLogDto(this.deviceCode, "反馈重量后,取消指令出现异常, 异常原因:" + e.getMessage()));
+ }
+ this.reqTakeRequireSuccess = false;
+ this.reqTakeInstCode = null;
+ }
+ }
+ }
+ }
+
+ private void applyPass(Instruction instruction) {
+ long currentTimeMillis = System.currentTimeMillis();
+ if (!isTimeValid(currentTimeMillis)) {
+ log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
+ } else {
+ this.requireTime = currentTimeMillis;
+ JSONObject reqParam = new JSONObject();
+ reqParam.put("task_code", instruction.getTask_code());
+ reqParam.put("point_code", instruction.getNext_point_code());
+ UnifiedResponse wmsUnifiedResponse = acsToWmsService.applyPass(reqParam, JSONObject.class);
+ if (wmsUnifiedResponse.isSuccess() && wmsUnifiedResponse.getData() != null) {
+ JSONObject data = wmsUnifiedResponse.getData();
+ if (data != null && "1".equals(data.getString("is_confirm"))) {
+ this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
+ this.reqTakeRequireSuccess = true;
+ this.reqTakeInstCode = null;
+ }
+ }
+ }
+ }
+
+ private void boxApplyPass(String type) {
+ BoxApplyPassReq bapReq = BoxApplyPassReq.builder()
+ .taskCode(this.reqTakeInstCode)
+ .type(type)
+ .build();
+ UnifiedResponse unifiedResponse = acsToHkService.boxApplyPass(bapReq, String.class);
+ if (unifiedResponse.isSuccess()) {
+ this.reqTakeRequireSuccess = false;
+ this.reqTakeInstCode = null;
+ }
+ }
+
+
+ @Override
+ public JSONObject getDeviceStatusName() {
+ JSONObject jo = new JSONObject();
+ return jo;
+ }
+
+ @Override
+ public void setDeviceStatus(JSONObject data) {
+
+ }
+
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java
index dec0681..2015e8f 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java
@@ -60,6 +60,8 @@ public interface OpcDeviceDriver extends DeviceDriver {
dto.setItem_code(json.getString("extra_code"));
dto.setItem_value(json.getString("extra_value"));
+ dto.setItem_value_type(json.getString("value_type"));
+ dto.setItem_name(json.getString("extra_name"));
returns.add(dto);
}
return returns;
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/standard_manipulator/StandardManipulatoDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/standard_manipulator/StandardManipulatoDeviceDriver.java
index 871a173..255b32e 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/standard_manipulator/StandardManipulatoDeviceDriver.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/standard_manipulator/StandardManipulatoDeviceDriver.java
@@ -14,8 +14,6 @@ import org.nl.acs.device_driver.FeedLmsRealFailed;
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.data.ApplyManipulatorActionRequest;
-import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
@@ -184,12 +182,6 @@ public class StandardManipulatoDeviceDriver extends AbstractOpcDeviceDriver impl
} catch (Exception var17) {
this.iserror = true;
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null")
- .build();
- logDto.setLog_level(4);
- luceneExecuteLogService.deviceExecuteLog(logDto);
var17.printStackTrace();
}
@@ -206,48 +198,6 @@ public class StandardManipulatoDeviceDriver extends AbstractOpcDeviceDriver impl
}
- /**
- * // * 申请任务
- * // *
- * // * @param
- * //
- */
- public synchronized void applyTask() {
- ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
- ApplyManipulatorActionResponse applyManipulatorActionResponse;
- String direction = (String) this.getDevice().getExtraValue().get("direction");
- applyManipulatorActionRequest.setDevice_code(device_code);
- applyManipulatorActionRequest.setDirection(direction);//rgv申请位置
- applyManipulatorActionRequest.setQzz_no(String.valueOf(barcode));//气涨轴编码
- applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
- Map map = new LinkedHashMap<>();
- if (applyManipulatorActionResponse.getstatus() == 200) {
- Map data = applyManipulatorActionResponse.getData();
- String point_code2 = data.get("point_code2");//目标站点
- Device deviceByCode = deviceAppService.findDeviceByCode(point_code2);
- String address = deviceByCode.getExtraValue().get("address").toString();
- String material_code = data.get("material_code");//子卷号
- String to_is_labeling = data.get("to_is_labeling");//是否贴标
- map.put("to_target", address);
- map.put("to_sub_volume_no", material_code);
- map.put("to_command", "1");
- if (StrUtil.equals("1",to_is_labeling)){
- map.put("to_is_labeling","1");
- }else {
- map.put("to_is_labeling","0");
- }
- this.writing(map);
- logServer.deviceExecuteLog(this.device_code, "", "", "申请行架任务,返回参数:" + applyManipulatorActionResponse);
- message = "universal_message12";
- requireSucess = true;
- } else {
- map.put("to_command", 99);
- this.writing(map);
- requireSucess = true;
- message = "universal_message13";
- logServer.deviceExecuteLog(this.device_code, "", "", "申请行架任务反馈失败,返回参数:" + applyManipulatorActionResponse);
- }
- }
public void writing(Map map) {
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@@ -259,13 +209,6 @@ public class StandardManipulatoDeviceDriver extends AbstractOpcDeviceDriver impl
});
if (ObjectUtil.isNotEmpty(itemMap)) {
this.control(itemMap);
- logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
- LuceneLogDto logDto = LuceneLogDto.builder()
- .device_code(device_code)
- .content("下发多个电气信号" + itemMap)
- .build();
- logDto.setLog_level(3);
- luceneExecuteLogService.deviceExecuteLog(logDto);
}
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDefination.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDefination.java
similarity index 64%
rename from nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDefination.java
rename to nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDefination.java
index 2fc507b..31ff435 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDefination.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDefination.java
@@ -1,4 +1,4 @@
-package org.nl.acs.device_driver.agv.ndctwo;
+package org.nl.acs.device_driver.storage.standard_storage;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device.enums.DeviceType;
@@ -10,40 +10,40 @@ import java.util.LinkedList;
import java.util.List;
/**
- * NDC双工位AGV
+ * 货架
*/
@Service
-public class AgvNdcTwoDefination implements DeviceDriverDefination {
+public class StandardStorageDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
- return "agv_ndc_two";
+ return "standard_storage";
}
@Override
public String getDriverName() {
- return "NDC双工位AGV";
+ return "标准版-货架";
}
@Override
public String getDriverDescription() {
- return "NDC双工位AGV";
+ return "标准版-货架";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
- return (new AgvNdcTwoDeviceDriver()).setDevice(device).setDriverDefination(this);
+ return (new StandardStorageDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class extends DeviceDriver> getDeviceDriverType() {
- return AgvNdcTwoDeviceDriver.class;
+ return StandardStorageDeviceDriver.class;
}
@Override
public List getFitDeviceTypes() {
List types = new LinkedList();
- types.add(DeviceType.agv);
+ types.add(DeviceType.storage);
return types;
}
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDeviceDriver.java
new file mode 100644
index 0000000..0b572f2
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/storage/standard_storage/StandardStorageDeviceDriver.java
@@ -0,0 +1,21 @@
+package org.nl.acs.device_driver.storage.standard_storage;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.nl.acs.device_driver.DeviceDriver;
+import org.nl.acs.device_driver.RouteableDeviceDriver;
+import org.nl.acs.device_driver.StorageDeviceDriver;
+import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
+
+
+/**
+ * 标准版货架
+ */
+@Slf4j
+@Data
+public class StandardStorageDeviceDriver extends AbstractDeviceDriver implements RouteableDeviceDriver, StorageDeviceDriver, DeviceDriver {
+ public StandardStorageDeviceDriver() {
+
+ }
+}
+
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/ItemProtocol.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/ItemProtocol.java
new file mode 100644
index 0000000..16decc5
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/ItemProtocol.java
@@ -0,0 +1,65 @@
+package org.nl.acs.device_driver.temperature_humidity_sensor;
+
+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_temperature = "temperature";
+
+ /**
+ * 湿度
+ */
+ public static String item_humidity = "humidity";
+
+
+
+ private TemperatureHumidityDeviceDriver driver;
+
+
+
+ public ItemProtocol(TemperatureHumidityDeviceDriver driver) {
+ this.driver = driver;
+ }
+
+
+ public Float getTemperature() {
+ return this.getOpcFloatValue(item_temperature);
+ }
+
+
+ public Float getHumidity() {
+ return this.getOpcFloatValue(item_humidity);
+ }
+
+
+ public Float getOpcFloatValue(String protocol) {
+ Float value = this.driver.getFloatValue(protocol);
+ if (value == null) {
+ return 0.0f;
+ } else {
+ return value;
+ }
+ }
+
+ public static List getReadableItemDtos() {
+ ArrayList list = new ArrayList<>();
+ list.add(new ItemDto(item_temperature, "温度", "31009"));
+ list.add(new ItemDto(item_humidity, "湿度", "31011"));
+ return list;
+ }
+
+ public static List getWriteableItemDtos() {
+ ArrayList list = new ArrayList<>();
+ return list;
+ }
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/TemperatureHumidityDefination.java
similarity index 73%
rename from nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java
rename to nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/TemperatureHumidityDefination.java
index 947ad84..3fa523f 100644
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/TemperatureHumidityDefination.java
@@ -1,4 +1,4 @@
-package org.nl.acs.device_driver.conveyor.belt_conveyor;
+package org.nl.acs.device_driver.temperature_humidity_sensor;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device.domain.Device;
@@ -10,35 +10,31 @@ import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
-/**
- * 标准版-输送机
- */
@Service
-public class BeltConveyorDefination implements OpcDeviceDriverDefination {
+public class TemperatureHumidityDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
- return "belt_conveyor";
+ return "temperature_humidity_driver";
}
@Override
public String getDriverName() {
- return "标准版-输送线";
+ return "温湿度-传感器";
}
@Override
public String getDriverDescription() {
- return "标准版-输送线";
+ return "温湿度-传感器";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
- return (new BeltConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
-
+ return (new TemperatureHumidityDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class extends DeviceDriver> getDeviceDriverType() {
- return BeltConveyorDeviceDriver.class;
+ return TemperatureHumidityDeviceDriver.class;
}
@Override
@@ -57,5 +53,4 @@ public class BeltConveyorDefination implements OpcDeviceDriverDefination {
public List getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
-
}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/TemperatureHumidityDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/TemperatureHumidityDeviceDriver.java
new file mode 100644
index 0000000..8fee7b2
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/temperature_humidity_sensor/TemperatureHumidityDeviceDriver.java
@@ -0,0 +1,83 @@
+package org.nl.acs.device_driver.temperature_humidity_sensor;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.nl.acs.device.domain.Device;
+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.monitor.DeviceStageMonitor;
+import org.nl.config.SpringContextHolder;
+import org.nl.config.lucene.service.LuceneExecuteLogService;
+import org.nl.config.lucene.service.dto.LuceneLogDto;
+
+
+/**
+ * RGV
+ */
+@Slf4j
+@Data
+@RequiredArgsConstructor
+public class TemperatureHumidityDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
+
+ protected ItemProtocol itemProtocol = new ItemProtocol(this);
+ private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
+
+ /**
+ * 当前设备号
+ */
+ private String device_code;
+
+ /**
+ * 温度
+ */
+ private float temperature = 0.0f;
+ private float last_temperature = 0.0f;
+
+ /**
+ * 湿度
+ */
+ private float humidity = 0.0f;
+ private float last_humidity = 0.0f;
+
+
+ @Override
+ public Device getDevice() {
+ return this.device;
+ }
+
+ @Override
+ public void execute() {
+
+ this.device_code = this.getDevice().getDevice_code();
+ this.temperature = this.itemProtocol.getTemperature();
+ this.humidity = this.itemProtocol.getHumidity();
+
+ if (this.temperature != this.last_temperature) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.device_code, "自动线程读取信号: 温度—temperature,由" + this.last_temperature + "->" + this.temperature));
+ }
+
+ if (this.humidity != this.last_humidity) {
+ logService.deviceExecuteLog(new LuceneLogDto(this.device_code, "自动线程读取信号: 湿度—humidity,由" + this.last_humidity + "->" + this.humidity));
+ }
+
+ this.last_temperature = this.temperature;
+ this.last_humidity = this.humidity;
+ }
+
+ @Override
+ public JSONObject getDeviceStatusName() {
+ JSONObject jo = new JSONObject();
+ return jo;
+ }
+
+ @Override
+ public void setDeviceStatus(JSONObject data) {
+
+ }
+
+
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/enums/ApplyPassEnum.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/enums/ApplyPassEnum.java
new file mode 100644
index 0000000..3cd2a88
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/enums/ApplyPassEnum.java
@@ -0,0 +1,39 @@
+package org.nl.acs.ext.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2025/9/9
+ */
+@Getter
+@AllArgsConstructor
+public enum ApplyPassEnum {
+
+ GET_PASS("1", "取货申请通过"),
+ PUT_PASS( "2", "放货申请通过");
+
+
+ /**
+ * 编码
+ */
+ private String code;
+ /**
+ * 名字
+ */
+ private String name;
+
+ /**
+ * 构造方法
+ *
+ * @param index
+ * @param code
+ * @param name
+ */
+ ApplyPassEnum(String index, String code, String name) {
+ this.code = code;
+ this.name = name;
+ }
+}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/enums/ConfirmEnum.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/enums/ConfirmEnum.java
new file mode 100644
index 0000000..338f335
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/enums/ConfirmEnum.java
@@ -0,0 +1,39 @@
+package org.nl.acs.ext.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2025/9/9
+ */
+@Getter
+@AllArgsConstructor
+public enum ConfirmEnum {
+
+ GET_CONFIRM("1", "确认取货"),
+ PUT_CONFIRM("2", "确认放货");
+
+
+ /**
+ * 编码
+ */
+ private String code;
+ /**
+ * 名字
+ */
+ private String name;
+
+ /**
+ * 构造方法
+ *
+ * @param index
+ * @param code
+ * @param name
+ */
+ ConfirmEnum(String index, String code, String name) {
+ this.code = code;
+ this.name = name;
+ }
+}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkHttpUtil.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkHttpUtil.java
new file mode 100644
index 0000000..c39b388
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkHttpUtil.java
@@ -0,0 +1,131 @@
+package org.nl.acs.ext.hk;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpRequest;
+import com.alibaba.fastjson.JSON;
+import org.nl.acs.AcsConfig;
+import org.nl.acs.common.base.CommonFinalParam;
+import org.nl.acs.ext.hk.log.ToOthersInterfaceLog;
+import org.nl.system.service.param.ISysParamService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2024/4/22
+ */
+@Component
+public class HkHttpUtil {
+
+ private static final RequestAdapter REQUEST_ADAPTER = new HkRequestAdapter();
+ private static final ResponseAdapter RESPONSE_ADAPTER = new HkResponseAdapter();
+
+ @Autowired
+ private ISysParamService paramService;
+
+ @ToOthersInterfaceLog("ACS->HK")
+ public UnifiedResponse sendPostRequest(String path, W requestParam, Class type) {
+ if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
+ return new UnifiedResponse<>(false, "未开启连接该系统!");
+ }
+ try {
+ String body = HttpRequest
+ .post(REQUEST_ADAPTER.getUrl() + path)
+ .setConnectionTimeout(5000)
+ .body(JSON.toJSONString(requestParam))
+ .execute()
+ .body();
+ return RESPONSE_ADAPTER.adapt(body, type);
+ } catch (Exception e) {
+ return new UnifiedResponse<>(false, e.getMessage());
+ }
+ }
+
+ @ToOthersInterfaceLog("ACS->HK")
+ public UnifiedResponse sendPostRequest(String path, W requestParam) {
+ if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
+ return new UnifiedResponse<>(false, "未开启连接该系统!");
+ }
+ try {
+ String body = HttpRequest
+ .post(REQUEST_ADAPTER.getUrl() + path)
+ .setConnectionTimeout(5000)
+ .body(JSON.toJSONString(requestParam))
+ .execute()
+ .body();
+ return RESPONSE_ADAPTER.adapt(body, null);
+ } catch (Exception e) {
+ return new UnifiedResponse<>(false, e.getMessage());
+ }
+ }
+
+ @ToOthersInterfaceLog("ACS->HK")
+ public UnifiedResponse sendPostRequest(String path, Class type) {
+ if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
+ return new UnifiedResponse<>(false, "未开启连接该系统!");
+ }
+ try {
+ String body = HttpRequest
+ .post(REQUEST_ADAPTER.getUrl() + path)
+ .setConnectionTimeout(5000)
+ .execute()
+ .body();
+ return RESPONSE_ADAPTER.adapt(body, type);
+ } catch (Exception e) {
+ return new UnifiedResponse<>(false, e.getMessage());
+ }
+ }
+
+ @ToOthersInterfaceLog("ACS->HK")
+ public UnifiedResponse sendPostRequest(String path) {
+ if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
+ return new UnifiedResponse<>(false, "未开启连接该系统!");
+ }
+ try {
+ String body = HttpRequest
+ .post(REQUEST_ADAPTER.getUrl() + path)
+ .setConnectionTimeout(5000)
+ .execute()
+ .body();
+ return RESPONSE_ADAPTER.adapt(body, null);
+ } catch (Exception e) {
+ return new UnifiedResponse<>(false, e.getMessage());
+ }
+ }
+
+ @ToOthersInterfaceLog("ACS->HK")
+ public UnifiedResponse sendGetRequest(String path, Class type) {
+ if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
+ return new UnifiedResponse<>(false, "未开启连接该系统!");
+ }
+ try {
+ String body = HttpRequest
+ .get(REQUEST_ADAPTER.getUrl() + path)
+ .setConnectionTimeout(5000)
+ .execute()
+ .body();
+ return RESPONSE_ADAPTER.adapt(body, type);
+ } catch (Exception e) {
+ return new UnifiedResponse<>(false, e.getMessage());
+ }
+ }
+
+ @ToOthersInterfaceLog("ACS->HK")
+ public UnifiedResponse sendGetRequest(String path) {
+ if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
+ return new UnifiedResponse<>(false, "未开启连接该系统!");
+ }
+ try {
+ String body = HttpRequest
+ .get(REQUEST_ADAPTER.getUrl() + path)
+ .setConnectionTimeout(5000)
+ .execute()
+ .body();
+ return RESPONSE_ADAPTER.adapt(body, null);
+ } catch (Exception e) {
+ return new UnifiedResponse<>(false, e.getMessage());
+ }
+ }
+
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkRequestAdapter.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkRequestAdapter.java
new file mode 100644
index 0000000..87421c8
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkRequestAdapter.java
@@ -0,0 +1,20 @@
+package org.nl.acs.ext.hk;
+
+import org.nl.acs.AcsConfig;
+import org.nl.config.SpringContextHolder;
+import org.nl.system.service.param.ISysParamService;
+
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2024/4/22
+ */
+public class HkRequestAdapter implements RequestAdapter {
+ @Override
+ public String getUrl() {
+ ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
+ return paramService.findByCode(AcsConfig.HK_URL).getValue();
+ }
+
+}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkResponseAdapter.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkResponseAdapter.java
new file mode 100644
index 0000000..b95d679
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/HkResponseAdapter.java
@@ -0,0 +1,39 @@
+package org.nl.acs.ext.hk;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.Collection;
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2024/4/22
+ */
+public class HkResponseAdapter implements ResponseAdapter {
+
+ @Override
+ public UnifiedResponse adapt(String responseBody, Class type) {
+ JSONObject resp = JSON.parseObject(responseBody);
+ boolean isSuccess = resp.getInteger("code") == 0;
+ String message = resp.getString("message");
+ String reqCode = resp.getString("reqCode");
+ if (type != null) {
+ Object dataObject = resp.get("data");
+ T data;
+ if (type == String.class) {
+ data = type.cast(dataObject.toString());
+ } else if (type == Object.class) {
+ data = type.cast(dataObject);
+ } else if (type.isArray() || Collection.class.isAssignableFrom(type)) {
+ data = JSON.parseObject(dataObject.toString(), type);
+ } else {
+ data = JSON.parseObject(resp.getString("data"), type);
+ }
+ return new UnifiedResponse<>(isSuccess, message, reqCode, data);
+ }
+ return new UnifiedResponse<>(isSuccess, message, reqCode);
+ }
+
+}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/RequestAdapter.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/RequestAdapter.java
new file mode 100644
index 0000000..59de74b
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/RequestAdapter.java
@@ -0,0 +1,10 @@
+package org.nl.acs.ext.hk;
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2024/4/22
+ */
+public interface RequestAdapter {
+ String getUrl();
+}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/ResponseAdapter.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/ResponseAdapter.java
new file mode 100644
index 0000000..7f8be2a
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/ResponseAdapter.java
@@ -0,0 +1,12 @@
+package org.nl.acs.ext.hk;
+
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2024/4/22
+ */
+public interface ResponseAdapter {
+ public UnifiedResponse adapt(String responseBody, Class type);
+}
+
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/UnifiedResponse.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/UnifiedResponse.java
new file mode 100644
index 0000000..501eda1
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/UnifiedResponse.java
@@ -0,0 +1,55 @@
+package org.nl.acs.ext.hk;
+
+
+public class UnifiedResponse {
+ private boolean success;
+ private String message;
+ private String reqCode;
+ private T data;
+
+ public UnifiedResponse(boolean success, String message, T data) {
+ this.success = success;
+ this.message = message;
+ this.data = data;
+ }
+
+ public UnifiedResponse(boolean success, String message, String reqCode, T data) {
+ this.success = success;
+ this.message = message;
+ this.reqCode = reqCode;
+ this.data = data;
+ }
+
+
+ public UnifiedResponse(boolean success, String message) {
+ this.success = success;
+ this.message = message;
+ }
+
+ public UnifiedResponse(boolean success, String message, String reqCode) {
+ this.success = success;
+ this.message = message;
+ this.reqCode = reqCode;
+ }
+
+ public boolean isSuccess() {
+ return this.success;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ public String getReqCode() {
+ return this.reqCode;
+ }
+
+ public T getData() {
+ return this.data;
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+}
+
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/OtherToInterfaceLogAspect.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/OtherToInterfaceLogAspect.java
new file mode 100644
index 0000000..6761503
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/OtherToInterfaceLogAspect.java
@@ -0,0 +1,109 @@
+package org.nl.acs.ext.hk.log;
+
+import com.alibaba.fastjson.JSON;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.nl.acs.ext.hk.utils.IpUtil;
+import org.nl.common.exception.BadRequestException;
+import org.nl.config.lucene.service.LuceneExecuteLogService;
+import org.nl.config.lucene.service.dto.LuceneLogDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.*;
+
+import java.lang.reflect.Method;
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2024/7/8
+ */
+@Aspect
+@Component
+public class OtherToInterfaceLogAspect {
+
+ @Autowired
+ private LuceneExecuteLogService logService;
+
+ @Around("@annotation(org.nl.acs.ext.hk.log.OthersToInterfaceLog)")
+ public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
+ long startTime = System.currentTimeMillis();
+
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+
+ Class> targetClass = joinPoint.getTarget().getClass();
+ RequestMapping classRequestMapping = targetClass.getAnnotation(RequestMapping.class);
+ String classUrlValue = classRequestMapping != null ? String.join(",", classRequestMapping.value()) : "No Class Annotation";
+
+ String methodUrlValue = "";
+ if (method.isAnnotationPresent(GetMapping.class)) {
+ GetMapping getMapping = method.getAnnotation(GetMapping.class);
+ methodUrlValue = String.join(",", getMapping.value());
+ } else if (method.isAnnotationPresent(PostMapping.class)) {
+ PostMapping postMapping = method.getAnnotation(PostMapping.class);
+ methodUrlValue = String.join(",", postMapping.value());
+ } else if (method.isAnnotationPresent(PutMapping.class)) {
+ PutMapping putMapping = method.getAnnotation(PutMapping.class);
+ methodUrlValue = String.join(",", putMapping.value());
+ } else if (method.isAnnotationPresent(DeleteMapping.class)) {
+ DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class);
+ methodUrlValue = String.join(",", deleteMapping.value());
+ } else if (method.isAnnotationPresent(RequestMapping.class)) {
+ RequestMapping methodRequestMapping = method.getAnnotation(RequestMapping.class);
+ methodUrlValue = String.join(",", methodRequestMapping.value());
+ }
+ String request_direction = "";
+ if (method.isAnnotationPresent(OthersToInterfaceLog.class)) {
+ OthersToInterfaceLog interfaceLog = method.getAnnotation(OthersToInterfaceLog.class);
+ request_direction = interfaceLog.value();
+ }
+
+ String methodName = joinPoint.getSignature().getName();
+ Object[] args = joinPoint.getArgs();
+
+ LuceneLogDto logDto =
+ LuceneLogDto.builder()
+ .logType("接口日志")
+ .request_url(IpUtil.localIP() + classUrlValue + methodUrlValue)
+ .request_direction(request_direction)
+ .request_param(JSON.toJSONString(args))
+ .method(methodName)
+ .content("开始请求")
+ .build();
+ logService.interfaceExecuteLog(logDto);
+ Object result = null;
+ try {
+ result = joinPoint.proceed();
+ } catch (Exception e) {
+ logDto =
+ LuceneLogDto.builder()
+ .logType("接口日志")
+ .request_url(IpUtil.localIP() + classUrlValue + methodUrlValue)
+ .request_direction(request_direction)
+ .request_param(JSON.toJSONString(args))
+ .method(methodName)
+ .response_param(e.getMessage())
+ .executeTime(System.currentTimeMillis() - startTime)
+ .content("响应请求")
+ .build();
+ logService.interfaceExecuteLog(logDto);
+ throw new BadRequestException(e.getMessage());
+ }
+ logDto =
+ LuceneLogDto.builder()
+ .logType("接口日志")
+ .request_url(IpUtil.localIP() + classUrlValue + methodUrlValue)
+ .request_direction(request_direction)
+ .request_param(JSON.toJSONString(args))
+ .method(methodName)
+ .response_param(JSON.toJSONString(result))
+ .executeTime(System.currentTimeMillis() - startTime)
+ .content("响应请求")
+ .build();
+ logService.interfaceExecuteLog(logDto);
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/OthersToInterfaceLog.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/OthersToInterfaceLog.java
new file mode 100644
index 0000000..9a99667
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/OthersToInterfaceLog.java
@@ -0,0 +1,12 @@
+package org.nl.acs.ext.hk.log;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface OthersToInterfaceLog {
+ String value() default "";
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/ToOtherInterfaceLogAspect.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/ToOtherInterfaceLogAspect.java
new file mode 100644
index 0000000..f1a1974
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/ToOtherInterfaceLogAspect.java
@@ -0,0 +1,139 @@
+package org.nl.acs.ext.hk.log;
+
+import com.alibaba.fastjson.JSON;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.nl.common.exception.BadRequestException;
+import org.nl.config.lucene.service.LuceneExecuteLogService;
+import org.nl.config.lucene.service.dto.LuceneLogDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ReflectionUtils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * @Description TODO
+ * @Author Gengby
+ * @Date 2024/7/8
+ */
+@Aspect
+@Component
+public class ToOtherInterfaceLogAspect {
+
+ private static final ConcurrentMap, Field> fieldCache = new ConcurrentHashMap<>();
+ private static final ConcurrentMap, Method> methodCache = new ConcurrentHashMap<>();
+
+ @Autowired
+ private LuceneExecuteLogService logService;
+
+ @Around("@annotation(org.nl.acs.ext.hk.log.ToOthersInterfaceLog)")
+ public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
+ long startTime = System.currentTimeMillis();
+
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+
+
+ String request_direction = "";
+ if (method.isAnnotationPresent(ToOthersInterfaceLog.class)) {
+ ToOthersInterfaceLog interfaceLog = method.getAnnotation(ToOthersInterfaceLog.class);
+ request_direction = interfaceLog.value();
+ }
+ String methodName = joinPoint.getSignature().getName();
+ Object[] args = joinPoint.getArgs();
+ Object url = "";
+ Object requesr_param = "";
+ if (args.length > 1) {
+ url = args[0];
+ requesr_param = args[1];
+ }
+
+ Class> targetClass = joinPoint.getTarget().getClass();
+
+ Object ipPort = "";
+ try {
+ Field requestAdapterField = fieldCache.computeIfAbsent(targetClass, clazz -> {
+ try {
+ Field field = clazz.getDeclaredField("REQUEST_ADAPTER");
+ ReflectionUtils.makeAccessible(field);
+ return field;
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ Object requestAdapterObject = requestAdapterField.get(null);
+
+ Method getUrlMethod = methodCache.computeIfAbsent(requestAdapterObject.getClass(), clazz -> {
+ try {
+ Method m = clazz.getDeclaredMethod("getUrl");
+ ReflectionUtils.makeAccessible(m);
+ return m;
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ ipPort = getUrlMethod.invoke(requestAdapterObject);
+ } catch (Exception e) {
+ LuceneLogDto logDto =
+ LuceneLogDto.builder()
+ .logType("接口日志")
+ .request_url(ipPort + String.valueOf(url))
+ .request_direction(request_direction)
+ .request_param(JSON.toJSONString(requesr_param))
+ .method(methodName)
+ .content("开始请求,获取url失败," + e.getMessage())
+ .build();
+ logService.interfaceExecuteLog(logDto);
+ }
+
+ LuceneLogDto logDto =
+ LuceneLogDto.builder()
+ .logType("接口日志")
+ .request_url(ipPort + String.valueOf(url))
+ .request_direction(request_direction)
+ .request_param(JSON.toJSONString(requesr_param))
+ .method(methodName)
+ .content("开始请求")
+ .build();
+ logService.interfaceExecuteLog(logDto);
+ Object result = null;
+ try {
+ result = joinPoint.proceed();
+ } catch (Exception e) {
+ logDto =
+ LuceneLogDto.builder()
+ .logType("接口日志")
+ .request_url(ipPort + String.valueOf(url))
+ .request_direction(request_direction)
+ .request_param(JSON.toJSONString(requesr_param))
+ .method(methodName)
+ .response_param(e.getMessage())
+ .executeTime(System.currentTimeMillis() - startTime)
+ .content("响应请求")
+ .build();
+ logService.interfaceExecuteLog(logDto);
+ throw new BadRequestException(e.getMessage());
+ }
+ logDto =
+ LuceneLogDto.builder()
+ .logType("接口日志")
+ .request_url(ipPort + String.valueOf(url))
+ .request_direction(request_direction)
+ .request_param(JSON.toJSONString(requesr_param))
+ .method(methodName)
+ .response_param(JSON.toJSONString(result))
+ .executeTime(System.currentTimeMillis() - startTime)
+ .content("响应请求")
+ .build();
+ logService.interfaceExecuteLog(logDto);
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/ToOthersInterfaceLog.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/ToOthersInterfaceLog.java
new file mode 100644
index 0000000..2e08b02
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/log/ToOthersInterfaceLog.java
@@ -0,0 +1,12 @@
+package org.nl.acs.ext.hk.log;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ToOthersInterfaceLog {
+ String value() default "";
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/rest/AcsToHkController.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/rest/AcsToHkController.java
new file mode 100644
index 0000000..2ed9e8e
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/hk/rest/AcsToHkController.java
@@ -0,0 +1,64 @@
+package org.nl.acs.ext.hk.rest;
+
+import cn.dev33.satoken.annotation.SaIgnore;
+import com.alibaba.fastjson.JSONObject;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.nl.acs.ext.hk.service.AcsToHkService;
+import org.nl.acs.ext.hk.service.data.BindPodAndBerthReq;
+import org.nl.acs.ext.hk.service.data.QueryTaskStatusReq;
+import org.nl.acs.ext.hk.service.data.ResumeRobotReq;
+import org.nl.acs.ext.hk.service.data.StopRobotReq;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author ludj
+ * @date 2021-07-21
+ **/
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/acsToHk")
+@Slf4j
+public class AcsToHkController {
+
+ @Autowired
+ private AcsToHkService acsToHkService;
+
+ @SaIgnore
+ @PostMapping("/queryTaskStatus")
+ public ResponseEntity