新需求
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package org.nl.hand.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -62,4 +63,25 @@ public class PadController {
|
||||
public ResponseEntity<Object> Taskoperation(@RequestBody Map<String, String> whereJson) {
|
||||
return new ResponseEntity<>(HandService.Taskoperation(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/area")
|
||||
@Log("查询所有区域信息")
|
||||
@ApiOperation("查询所有区域信息")
|
||||
public ResponseEntity<Object> area() {
|
||||
return new ResponseEntity<>(HandService.area(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/point")
|
||||
@Log("根据区域查询点位")
|
||||
@ApiOperation("根据区域查询点位")
|
||||
public ResponseEntity<Object> point(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(HandService.point(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/take")
|
||||
@Log("取放盖确认")
|
||||
@ApiOperation("取放盖确认")
|
||||
public ResponseEntity<Object> take(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(HandService.take(param), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
package org.nl.hand.service;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -42,4 +44,10 @@ public interface PadService {
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> Taskoperation(Map<String, String> jsonObject);
|
||||
|
||||
JSONObject area();
|
||||
|
||||
JSONObject point(JSONObject param);
|
||||
|
||||
JSONObject take(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -215,4 +215,53 @@ public class PadServiceImpl implements PadService {
|
||||
jo.put("result", new JSONObject());
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject area() {
|
||||
JSONObject resultJSON = new JSONObject();
|
||||
|
||||
JSONArray result = WQL
|
||||
.getWO("QHAND_QUERY")
|
||||
.addParam("flag", "6")
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
|
||||
resultJSON.put("code", "1");
|
||||
resultJSON.put("desc", "操作成功");
|
||||
resultJSON.put("result", result);
|
||||
return resultJSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject point(JSONObject param) {
|
||||
JSONObject resultJSON = new JSONObject();
|
||||
|
||||
JSONArray result = WQL
|
||||
.getWO("QHAND_QUERY")
|
||||
.addParam("flag", "6")
|
||||
.addParam("region", param.getString("region"))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
|
||||
resultJSON.put("code", "1");
|
||||
resultJSON.put("desc", "操作成功");
|
||||
resultJSON.put("result", result);
|
||||
return resultJSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject take(JSONObject param) {
|
||||
JSONObject resultJSON = new JSONObject();
|
||||
|
||||
JSONObject update_extra = new JSONObject();
|
||||
update_extra.put("extra_value", param.getString("type"));
|
||||
|
||||
WQLObject
|
||||
.getWQLObject("acs_device_extra")
|
||||
.update(update_extra, "extra_name = 'agv_check_status' AND device_code = " + param.getString("device_code") + "'");
|
||||
|
||||
resultJSON.put("code", "1");
|
||||
resultJSON.put("desc", "操作成功");
|
||||
return resultJSON;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
输入.next_devicecode TYPEAS s_string
|
||||
输入.detail_id TYPEAS s_string
|
||||
输入.start_point TYPEAS s_string
|
||||
输入.next_point TYPEAS s_string
|
||||
输入.next_point TYPEAS s_string
|
||||
输入.region TYPEAS s_string
|
||||
|
||||
|
||||
|
||||
@@ -174,3 +175,36 @@
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
QUERY
|
||||
SELECT
|
||||
`value` AS 'region_id',
|
||||
label AS 'region_name'
|
||||
FROM
|
||||
`sys_dict_detail`
|
||||
WHERE
|
||||
`name` = 'region_type'
|
||||
AND `value` = '3'
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "6"
|
||||
QUERY
|
||||
SELECT
|
||||
device.device_id,
|
||||
device.device_code,
|
||||
device.device_name,
|
||||
device_extra.extra_value AS 'status'
|
||||
FROM
|
||||
acs_device device
|
||||
JOIN acs_device_extra device_extra ON device.device_id = device_extra.device_id
|
||||
AND extra_name = 'agv_check_status'
|
||||
WHERE
|
||||
device.is_delete = '0'
|
||||
AND device_extra.is_delete = '0'
|
||||
AND device.region = 输入.region
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -0,0 +1,527 @@
|
||||
package org.nl.start.auto.run;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.config.server.impl.AcsConfigServiceImpl;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.log.service.impl.DeviceExecuteLogServiceImpl;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
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.Map;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket s;
|
||||
String ip = "127.0.0.1";
|
||||
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
|
||||
AcsConfigService acsConfigService;
|
||||
@Autowired
|
||||
AutoRunService autoRunService;
|
||||
|
||||
|
||||
public NDCSocketConnectionAutoRun() {
|
||||
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return NDCSocketConnectionAutoRun.class.getSimpleName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "NDC在线连接";
|
||||
}
|
||||
|
||||
public void autoRun() {
|
||||
|
||||
try {
|
||||
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
NDCAgvService AgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogServiceImpl.class);
|
||||
ip = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
|
||||
port = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT));
|
||||
byte[] b = new byte[1028];
|
||||
s = new Socket(ip, port);
|
||||
dos = new DataOutputStream(s.getOutputStream());
|
||||
dis = new DataInputStream(s.getInputStream());
|
||||
WQLObject device_extra_table = WQLObject.getWQLObject("acs_device_extra");
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
System.out.println("收到请求参数:" + bs);
|
||||
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];
|
||||
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;
|
||||
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);
|
||||
}
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver;
|
||||
StandardStorageDeviceDriver standardStorageDeviceDriver;
|
||||
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver;
|
||||
StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver;
|
||||
int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE));
|
||||
|
||||
try {
|
||||
if (phase == 0x01) {
|
||||
data = AgvService.sendAgvOneModeInst(phase, index);
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
inst.setInstruction_status("1");
|
||||
inst.setAgv_jobno(String.valueOf(index));
|
||||
inst.setSend_status("1");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
//分配 车id
|
||||
else if (phase == 0x02) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
inst.setCarno(String.valueOf(carno));
|
||||
instructionService.update(inst);
|
||||
}
|
||||
}
|
||||
// 到达取货点请求取货
|
||||
else if (phase == 0x03) {
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
|
||||
break;
|
||||
}
|
||||
//检测站点
|
||||
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMove() != 0) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
logServer.deviceExecuteLog(device_code,"","", "AGV请求取货设备{}无货,无法反馈");
|
||||
}
|
||||
}
|
||||
//普通站点
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
if (device.getHas_goods() != 0) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
logServer.deviceExecuteLog(device_code,"","","AGV请求取货设备{}无货,无法反馈");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检验取放货条件
|
||||
JSONObject agv_check = device_extra_table
|
||||
.query("is_delete = '0' AND extra_code = 'agv_check' AND device_code = '" + device.getDevice_code() + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(agv_check) && "true".equals(agv_check.getString("extra_value"))) {
|
||||
JSONObject agv_check_status = device_extra_table
|
||||
.query("is_delete = '0' AND extra_code = 'agv_check_status' AND device_code = '" + device.getDevice_code() + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(agv_check_status) && "2".equals(agv_check_status.getString("extra_value"))) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
agv_check_status.put("extra_value", "0");
|
||||
device_extra_table.update(agv_check_status);
|
||||
} else {
|
||||
logServer.deviceExecuteLog(device_code,"","","AGV请求取货设备{}未放盖确认,无法反馈");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 取货完成请求离开
|
||||
else if (phase == 0x05) {
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
|
||||
break;
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMove() == 0) {
|
||||
inst.setExecute_status("5");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
logServer.deviceExecuteLog(device_code,"","","AGV取货完成请求离开设备{}有货,无法反馈");
|
||||
}
|
||||
}
|
||||
|
||||
// if(!inst.getTask_code().startsWith("-")) {
|
||||
// //反馈wms系统动作完成
|
||||
// inst.setFinish_type("1");
|
||||
// instructionService.update(inst);
|
||||
// JSONObject feedjo = new JSONObject();
|
||||
// feedjo.put("status","1");
|
||||
// feedjo.put("device_code",device_code);
|
||||
// feedjo.put("vehicle_code",inst.getVehicle_code());
|
||||
// feedjo.put("task_code",inst.getTask_code());
|
||||
// JSONArray feedja = JSONArray.parseArray(String.valueOf(feedjo));
|
||||
// acsToWmsService.feedbackActionStatusToWms(feedja);
|
||||
// }
|
||||
|
||||
}
|
||||
//请求放货
|
||||
else if (phase == 0x07) {
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
|
||||
break;
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMove() == 0) { inst.setExecute_status("3");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
logServer.deviceExecuteLog(device_code,"","","AGV请求放货设备{}有货,无法反馈");
|
||||
}
|
||||
}
|
||||
// 检验取放货条件
|
||||
JSONObject agv_check = device_extra_table
|
||||
.query("is_delete = '0' AND extra_code = 'agv_check' AND device_code = '" + device.getDevice_code() + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(agv_check) && "true".equals(agv_check.getString("extra_value"))) {
|
||||
JSONObject agv_check_status = device_extra_table
|
||||
.query("is_delete = '0' AND extra_code = 'agv_check_status' AND device_code = '" + device.getDevice_code() + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(agv_check_status) && "1".equals(agv_check_status.getString("extra_value"))) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
agv_check_status.put("extra_value", "0");
|
||||
device_extra_table.update(agv_check_status);
|
||||
} else {
|
||||
logServer.deviceExecuteLog(device_code,"","","AGV请求取货设备{}未取盖确认,无法反馈");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 放货完成请求离开
|
||||
else if (phase == 0x09) {
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
|
||||
break;
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMove() != 0) {
|
||||
inst.setExecute_status("6");
|
||||
instructionService.update(inst);
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else {
|
||||
logServer.deviceExecuteLog(device_code,"","","AGV放货完成请求离开设备{}无货,无法反馈");
|
||||
}
|
||||
}
|
||||
|
||||
// if(!inst.getTask_code().startsWith("-")){
|
||||
// //反馈wms系统动作完成
|
||||
// inst.setFinish_type("1");
|
||||
// instructionService.update(inst);
|
||||
// JSONObject feedjo = new JSONObject();
|
||||
// feedjo.put("status","2");
|
||||
// feedjo.put("device_code",device_code);
|
||||
// feedjo.put("vehicle_code",inst.getVehicle_code());
|
||||
// feedjo.put("task_code",inst.getTask_code());
|
||||
// JSONArray feedja = new JSONArray();
|
||||
// feedja.add(feedjo);
|
||||
// acsToWmsService.feedbackActionStatusToWms(feedja);
|
||||
// }
|
||||
|
||||
}
|
||||
//任务完毕
|
||||
//(无车id及状态)
|
||||
else if (phase == 0x0A) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.finish(inst);
|
||||
}
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
//请求删除任务
|
||||
else if (phase == 0x30) {
|
||||
flag = true;
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
data = AgvService.sendAgvOneModeInst(0x8F, index, 0);
|
||||
} else {
|
||||
log.info("未找到对应的指令无法删除");
|
||||
break;
|
||||
}
|
||||
}
|
||||
//任务删除确认
|
||||
//(需要WCS反馈)
|
||||
else if (phase == 0xFF) {
|
||||
flag = true;
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.cancel(inst.getInstruction_id());
|
||||
}
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
//进入区域
|
||||
else if (phase == 0x50) {
|
||||
//开门
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutodoorDeviceDriver.OpenOrClose("1");
|
||||
if (standardAutodoorDeviceDriver.getAction() == 1) {
|
||||
standardAutodoorDeviceDriver.OpenOrClose("1");
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//离开区域
|
||||
else if (phase == 0x51) {
|
||||
//关门
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
standardAutodoorDeviceDriver.OpenOrClose("2");
|
||||
if (standardAutodoorDeviceDriver.getAction() == 2) {
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
} else if (phase == 0x64) {
|
||||
data = AgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
//上报异常
|
||||
else if (phase == 0x67) {
|
||||
AgvDto dto = null;
|
||||
Map<String, AgvDto> map = AgvService.findAllAgvFromCache();
|
||||
if (map.containsKey(String.valueOf(carno))) {
|
||||
dto = map.get(String.valueOf(carno));
|
||||
} else {
|
||||
dto = new AgvDto();
|
||||
}
|
||||
dto.setName(String.valueOf(carno));
|
||||
if (arr[18] * 256 + arr[19] == 0) {
|
||||
dto.setState("IDLE");
|
||||
acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "0", "");
|
||||
} else {
|
||||
StringBuffer errbs = new StringBuffer();
|
||||
for (int i = 0; i < ERROR.length; i++) {
|
||||
if (((arr[18] * 256 + arr[19]) & (1 << i)) > 0)
|
||||
errbs.append("," + ERROR[i]);
|
||||
//反馈故障
|
||||
}
|
||||
dto.setState("ERROR");
|
||||
acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "1", "error");
|
||||
}
|
||||
}
|
||||
//X坐标
|
||||
else if (phase == 0x70) {
|
||||
AgvDto dto = null;
|
||||
Map<String, AgvDto> map = AgvService.findAllAgvFromCache();
|
||||
carno = arr[18] * 256 + arr[19];
|
||||
if (map.containsKey(String.valueOf(carno))) {
|
||||
dto = map.get(String.valueOf(carno));
|
||||
} else {
|
||||
dto = new AgvDto();
|
||||
}
|
||||
dto.setName(String.valueOf(carno));
|
||||
dto.setPositionX(String.valueOf(ikey));
|
||||
}
|
||||
//Y坐标
|
||||
else if (phase == 0x71) {
|
||||
AgvDto dto = null;
|
||||
Map<String, AgvDto> map = AgvService.findAllAgvFromCache();
|
||||
carno = arr[18] * 256 + arr[19];
|
||||
if (map.containsKey(String.valueOf(carno))) {
|
||||
dto = map.get(String.valueOf(carno));
|
||||
} else {
|
||||
dto = new AgvDto();
|
||||
}
|
||||
dto.setName(String.valueOf(carno));
|
||||
dto.setPositionY(String.valueOf(ikey));
|
||||
}
|
||||
//角度
|
||||
else if (phase == 0x72) {
|
||||
AgvDto dto = null;
|
||||
Map<String, AgvDto> map = AgvService.findAllAgvFromCache();
|
||||
carno = arr[18] * 256 + arr[19];
|
||||
if (map.containsKey(String.valueOf(carno))) {
|
||||
dto = map.get(String.valueOf(carno));
|
||||
} else {
|
||||
dto = new AgvDto();
|
||||
}
|
||||
dto.setName(String.valueOf(carno));
|
||||
dto.setPositionAngle(String.valueOf(ikey));
|
||||
}
|
||||
//电量
|
||||
else if (phase == 0x73) {
|
||||
AgvDto dto = null;
|
||||
Map<String, AgvDto> map = AgvService.findAllAgvFromCache();
|
||||
carno = arr[18] * 256 + arr[19];
|
||||
if (map.containsKey(String.valueOf(carno))) {
|
||||
dto = map.get(String.valueOf(carno));
|
||||
} else {
|
||||
dto = new AgvDto();
|
||||
}
|
||||
dto.setName(String.valueOf(carno));
|
||||
dto.setEnergyLevel(String.valueOf(ikey));
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
write(data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
log.info(e.toString());
|
||||
log.info(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("agv上报不是0073类型动作,不处理");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
|
||||
} 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
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -160,6 +160,32 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-tooltip class="item" effect="dark" content="AGV取放货前是否需要额外校验" placement="bottom-end">
|
||||
<el-form-item label="AGV取放货校验" label-width="150px">
|
||||
<el-switch v-model="form.agv_check" />
|
||||
</el-form-item>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
<el-col>
|
||||
<el-form-item label="AGV取放货校验状态" label-width="150px">
|
||||
<el-select
|
||||
v-model="form.agv_check_status"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dict.agv_check_status"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
@@ -271,6 +297,7 @@ import deviceCrud from '@/api/acs/device/device'
|
||||
|
||||
export default {
|
||||
name: 'StandardInspectSite',
|
||||
dicts: ['agv_check_status'],
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
@@ -301,7 +328,9 @@ export default {
|
||||
manual_create_task: true,
|
||||
is_pickup: true,
|
||||
is_release: true,
|
||||
link_device_code: []
|
||||
link_device_code: [],
|
||||
agv_check: true,
|
||||
agv_check_status: ''
|
||||
},
|
||||
rules: {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user