fix: 海康交互接口-base
This commit is contained in:
@@ -12,6 +12,7 @@ import org.nl.acs.device.domain.Device;
|
|||||||
import org.nl.acs.agv.hk.service.AcsToHkService;
|
import org.nl.acs.agv.hk.service.AcsToHkService;
|
||||||
import org.nl.acs.agv.hk.service.HkToAcsService;
|
import org.nl.acs.agv.hk.service.HkToAcsService;
|
||||||
import org.nl.acs.agv.hk.service.data.GenPreScheduleTaskReq;
|
import org.nl.acs.agv.hk.service.data.GenPreScheduleTaskReq;
|
||||||
|
import org.nl.acs.device_driver.basedriver.robot_arm.RobotArmDeviceDriver;
|
||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
import org.nl.acs.instruction.domain.Instruction;
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
import org.nl.acs.instruction.enums.InstTypeEnum;
|
import org.nl.acs.instruction.enums.InstTypeEnum;
|
||||||
@@ -25,6 +26,8 @@ import org.nl.system.service.param.ISysParamService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
@@ -116,7 +119,7 @@ public class HkToAcsServiceImpl implements HkToAcsService {
|
|||||||
instruction.setUpdate_time(now);
|
instruction.setUpdate_time(now);
|
||||||
instructionService.update(instruction);
|
instructionService.update(instruction);
|
||||||
}
|
}
|
||||||
//method 回调4、取放料箱申请inApply
|
//method 回调4、取料箱申请inApply
|
||||||
else if (StrUtil.equals(method, "inApply")) {
|
else if (StrUtil.equals(method, "inApply")) {
|
||||||
Device device = deviceAppService.findDeviceByCode(instruction.getStart_device_code());
|
Device device = deviceAppService.findDeviceByCode(instruction.getStart_device_code());
|
||||||
if (ObjectUtil.isEmpty(device)) {
|
if (ObjectUtil.isEmpty(device)) {
|
||||||
@@ -138,6 +141,16 @@ public class HkToAcsServiceImpl implements HkToAcsService {
|
|||||||
// standardWeightSiteDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
// standardWeightSiteDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
// 机械手驱动
|
||||||
|
RobotArmDeviceDriver robotArmDeviceDriver;
|
||||||
|
if (device.getDeviceDriver() instanceof RobotArmDeviceDriver) {
|
||||||
|
robotArmDeviceDriver = (RobotArmDeviceDriver) device.getDeviceDriver();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("to_out", "1");
|
||||||
|
robotArmDeviceDriver.writing(map);
|
||||||
|
robotArmDeviceDriver.setReqAgvTakeRequireSuccess(true);
|
||||||
|
robotArmDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//method 回调5、inApplyOk
|
//method 回调5、inApplyOk
|
||||||
else if (StrUtil.equals(method, "inApplyOK")) {
|
else if (StrUtil.equals(method, "inApplyOK")) {
|
||||||
@@ -148,6 +161,16 @@ public class HkToAcsServiceImpl implements HkToAcsService {
|
|||||||
reqParam.put("point_code", instruction.getStart_point_code());
|
reqParam.put("point_code", instruction.getStart_point_code());
|
||||||
acsToWmsService.takeFinish(reqParam);
|
acsToWmsService.takeFinish(reqParam);
|
||||||
}
|
}
|
||||||
|
Device device = deviceAppService.findDeviceByCode(instruction.getStart_device_code());
|
||||||
|
RobotArmDeviceDriver robotArmDeviceDriver;
|
||||||
|
if (device.getDeviceDriver() instanceof RobotArmDeviceDriver) {
|
||||||
|
robotArmDeviceDriver = (RobotArmDeviceDriver) device.getDeviceDriver();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("to_out", "0");
|
||||||
|
robotArmDeviceDriver.writing(map);
|
||||||
|
robotArmDeviceDriver.setReqAgvTakeRequireSuccess(true);
|
||||||
|
robotArmDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//method 回调6、放料箱申请outApply
|
//method 回调6、放料箱申请outApply
|
||||||
else if (StrUtil.equals(method, "outApply")) {
|
else if (StrUtil.equals(method, "outApply")) {
|
||||||
@@ -174,6 +197,28 @@ public class HkToAcsServiceImpl implements HkToAcsService {
|
|||||||
// standardWeightSiteDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
// standardWeightSiteDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
RobotArmDeviceDriver robotArmDeviceDriver;
|
||||||
|
if (device.getDeviceDriver() instanceof RobotArmDeviceDriver) {
|
||||||
|
robotArmDeviceDriver = (RobotArmDeviceDriver) device.getDeviceDriver();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("to_in", "1");
|
||||||
|
robotArmDeviceDriver.writing(map);
|
||||||
|
robotArmDeviceDriver.setReqAgvTakeRequireSuccess(true);
|
||||||
|
robotArmDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//method 回调7、放货完成
|
||||||
|
else if (StrUtil.equals(method, "outApplyOK")) {
|
||||||
|
Device device = deviceAppService.findDeviceByCode(instruction.getStart_device_code());
|
||||||
|
RobotArmDeviceDriver robotArmDeviceDriver;
|
||||||
|
if (device.getDeviceDriver() instanceof RobotArmDeviceDriver) {
|
||||||
|
robotArmDeviceDriver = (RobotArmDeviceDriver) device.getDeviceDriver();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("to_in", "0");
|
||||||
|
robotArmDeviceDriver.writing(map);
|
||||||
|
robotArmDeviceDriver.setReqAgvTakeRequireSuccess(true);
|
||||||
|
robotArmDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resp.put("code", "0");
|
resp.put("code", "0");
|
||||||
resp.put("message", "成功");
|
resp.put("message", "成功");
|
||||||
@@ -181,6 +226,8 @@ public class HkToAcsServiceImpl implements HkToAcsService {
|
|||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject warnCallback(JSONObject requestParam) {
|
public JSONObject warnCallback(JSONObject requestParam) {
|
||||||
String reqCode = requestParam.getString("reqCode");
|
String reqCode = requestParam.getString("reqCode");
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
package org.nl.acs.device_driver.basedriver.robot_arm;
|
package org.nl.acs.device_driver.basedriver.robot_arm;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.acs.agv.hk.UnifiedResponse;
|
||||||
|
import org.nl.acs.agv.hk.service.AcsToHkService;
|
||||||
|
import org.nl.acs.agv.hk.service.data.ContinueTaskReq;
|
||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
import org.nl.acs.device.service.DeviceService;
|
import org.nl.acs.device.service.DeviceService;
|
||||||
import org.nl.acs.device_driver.DeviceDriver;
|
import org.nl.acs.device_driver.DeviceDriver;
|
||||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
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.instruction.service.InstructionService;
|
||||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||||
import org.nl.acs.route.service.RouteLineService;
|
import org.nl.acs.route.service.RouteLineService;
|
||||||
@@ -46,11 +52,17 @@ public class RobotArmDeviceDriver extends AbstractOpcDeviceDriver implements Dev
|
|||||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||||
|
|
||||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||||
|
private final AcsToHkService acsToHkService = SpringContextHolder.getBean(AcsToHkService.class);
|
||||||
|
|
||||||
String container;
|
String container;
|
||||||
String container_type_desc;
|
String container_type_desc;
|
||||||
String last_container_type_desc;
|
String last_container_type_desc;
|
||||||
String last_container;
|
String last_container;
|
||||||
|
/**
|
||||||
|
* AGV请求取放货标记和指令号
|
||||||
|
*/
|
||||||
|
private volatile String reqAgvTakeInstCode = null;
|
||||||
|
private volatile Boolean reqAgvTakeRequireSuccess = false;
|
||||||
//放货准备锁
|
//放货准备锁
|
||||||
String putReadyLock = null;
|
String putReadyLock = null;
|
||||||
//有货标记
|
//有货标记
|
||||||
@@ -167,6 +179,26 @@ public class RobotArmDeviceDriver extends AbstractOpcDeviceDriver implements Dev
|
|||||||
acsToWmsService.applyTask(param);
|
acsToWmsService.applyTask(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 取货/放货信号写入需要初始化并允许离开
|
||||||
|
if (this.reqAgvTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqAgvTakeInstCode)) {
|
||||||
|
Instruction instruction = instructionService.findByCodeFromCache(this.reqAgvTakeInstCode);
|
||||||
|
//判断是否是取货还是放货
|
||||||
|
//如果是取货直接允许
|
||||||
|
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_device_code(), devicecode)) {
|
||||||
|
// 判断是否写回成功
|
||||||
|
if (to_out == 1) {
|
||||||
|
this.continueTask();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//如果是放货
|
||||||
|
else if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_device_code(), devicecode)) {
|
||||||
|
// 判断是否写回成功
|
||||||
|
if (to_in == 1) {
|
||||||
|
this.continueTask();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String getStatus() {
|
public synchronized String getStatus() {
|
||||||
@@ -229,4 +261,16 @@ public class RobotArmDeviceDriver extends AbstractOpcDeviceDriver implements Dev
|
|||||||
log.info("下发PLC信号:{},{}", this.devicecode, "to_command:" + value);
|
log.info("下发PLC信号:{},{}", this.devicecode, "to_command:" + value);
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.devicecode, message + param + " 写入 " + value));
|
lucene.deviceExecuteLog(new LuceneLogDto(this.devicecode, message + param + " 写入 " + value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void continueTask() {
|
||||||
|
ContinueTaskReq req = ContinueTaskReq.builder()
|
||||||
|
.taskCode(this.reqAgvTakeInstCode)
|
||||||
|
.build();
|
||||||
|
UnifiedResponse unifiedResponse = acsToHkService.continueTask(req);
|
||||||
|
// 初始化
|
||||||
|
if (unifiedResponse.isSuccess()) {
|
||||||
|
this.reqAgvTakeRequireSuccess = false;
|
||||||
|
this.reqAgvTakeInstCode = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user