fix ndc驱动
This commit is contained in:
@@ -2,17 +2,16 @@ package org.nl.acs.device_driver.basedriver.agv.ndcone;
|
||||
|
||||
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.EqualsAndHashCode;
|
||||
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.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.agv.utils.ErrorUtil;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
|
||||
@@ -22,9 +21,8 @@ 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.LokiLog;
|
||||
import org.nl.acs.log.LokiLogType;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
@@ -33,18 +31,17 @@ import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* NDC单工位AGV
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver {
|
||||
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor {
|
||||
|
||||
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
@@ -74,8 +71,10 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
int last_status = 0;
|
||||
int last_error = 0;
|
||||
|
||||
@LokiLog(type = LokiLogType.ACS_TO_LMS)
|
||||
public synchronized void processSocket(int[] arr) throws Exception {
|
||||
String error_code = "0";
|
||||
String error_message = "";
|
||||
|
||||
public synchronized void processSocket(int[] arr) {
|
||||
device_code = this.getDeviceCode();
|
||||
byte[] data = null;
|
||||
phase = arr[16] * 256 + arr[17];
|
||||
@@ -91,10 +90,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
List<Instruction> 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) {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
// if (ObjectUtil.isEmpty(inst)) {
|
||||
@@ -110,21 +105,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
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;
|
||||
//货架
|
||||
StandardStorageDeviceDriver standardStorageDeviceDriver;
|
||||
//
|
||||
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
|
||||
|
||||
//分配 车id
|
||||
//(不需要WCS反馈)
|
||||
if (phase == 0x02) {
|
||||
@@ -151,7 +131,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
} 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;
|
||||
}
|
||||
@@ -159,8 +138,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空");
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
@@ -169,34 +148,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
|
||||
return;
|
||||
}
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "0")) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
} else {
|
||||
Object reqWms = device.getExtraValue().get("reqWms");
|
||||
if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) {
|
||||
JSONArray req = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("vehicle_code", inst.getVehicle_code());
|
||||
map.put("status", "1");
|
||||
map.put("device_code", inst.getStart_point_code());
|
||||
map.put("task_code", inst.getTask_code());
|
||||
req.add(map);
|
||||
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
|
||||
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
JSONObject resp = JSONObject.parseObject(httpResponse.body());
|
||||
if (resp.getJSONObject("payload").getInteger("status") == 200) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
log.info("指令号:{},acs请求wms取货申请成功,wms允许agv申请取货,已反馈agv允许取货", inst.getInstruction_code());
|
||||
} else {
|
||||
log.warn("指令号:{},acs请求wms取货申请失败,wms不允许agv取货,未反馈agv允许取货", inst.getInstruction_code());
|
||||
}
|
||||
} else {
|
||||
log.warn("指令号:{},acs请求wms取货申请失败,连接被拒绝,未反馈agv允许取货", inst.getInstruction_code());
|
||||
}
|
||||
} else {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//取货完毕
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x05) {
|
||||
@@ -215,7 +167,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
} 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;
|
||||
}
|
||||
@@ -234,34 +185,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
return;
|
||||
}
|
||||
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "0")) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
} else {
|
||||
Object reqWms = device.getExtraValue().get("reqWms");
|
||||
if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) {
|
||||
JSONArray req = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("vehicle_code", inst.getVehicle_code());
|
||||
map.put("status", "2");
|
||||
map.put("device_code", inst.getStart_point_code());
|
||||
map.put("task_code", inst.getTask_code());
|
||||
req.add(map);
|
||||
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
|
||||
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
JSONObject resp = JSONObject.parseObject(httpResponse.body());
|
||||
if (resp.getJSONObject("payload").getInteger("status") == 200) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
log.info("指令号:{},acs反馈wms取货完成离开成功,wms允许agv取货完成离开,已反馈agv取货完成离开", inst.getInstruction_code());
|
||||
} else {
|
||||
log.warn("指令号:{},acs反馈wms取货完成离开失败,wms不允许agv取货完成离开,未反馈agv取货完成离开", inst.getInstruction_code());
|
||||
}
|
||||
} else {
|
||||
log.warn("指令号:{},acs反馈wms取货完成离开失败,连接被拒绝,未反馈agv取货完成离开", inst.getInstruction_code());
|
||||
}
|
||||
} else {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
//到达放货点
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x07) {
|
||||
@@ -280,7 +203,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
} 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;
|
||||
}
|
||||
@@ -296,35 +218,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
return;
|
||||
}
|
||||
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "0")) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
} else {
|
||||
Object reqWms = device.getExtraValue().get("reqWms");
|
||||
if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) {
|
||||
JSONArray req = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("vehicle_code", inst.getVehicle_code());
|
||||
map.put("status", "3");
|
||||
map.put("device_code", inst.getNext_point_code());
|
||||
map.put("task_code", inst.getTask_code());
|
||||
req.add(map);
|
||||
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
|
||||
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
JSONObject resp = JSONObject.parseObject(httpResponse.body());
|
||||
if (resp.getJSONObject("payload").getInteger("status") == 200) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code());
|
||||
} else {
|
||||
log.warn("指令号:{},acs请求wms放货申请失败,wms不允许agv放货,未反馈agv允许放货", inst.getInstruction_code());
|
||||
}
|
||||
} else {
|
||||
log.warn("指令号:{},acs请求wms放货申请失败,连接被拒绝,未反馈agv允许放货", inst.getInstruction_code());
|
||||
}
|
||||
} else {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//放货完毕
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x09) {
|
||||
@@ -343,7 +236,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
} 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;
|
||||
}
|
||||
@@ -359,34 +251,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
log.info("未找到编号{}对应的指令", ikey);
|
||||
return;
|
||||
}
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "0")) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
} else {
|
||||
Object reqWms = device.getExtraValue().get("reqWms");
|
||||
if (ObjectUtil.isNotEmpty(reqWms) && reqWms.toString().equals("true")) {
|
||||
JSONArray req = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("vehicle_code", inst.getVehicle_code());
|
||||
map.put("status", "4");
|
||||
map.put("device_code", inst.getNext_point_code());
|
||||
map.put("task_code", inst.getTask_code());
|
||||
req.add(map);
|
||||
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
|
||||
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
JSONObject resp = JSONObject.parseObject(httpResponse.body());
|
||||
if (resp.getJSONObject("payload").getInteger("status") == 200) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
log.info("指令号:{},acs请求wms放货完成申请成功,wms允许agv放货完成,已反馈agv放货完成", inst.getInstruction_code());
|
||||
} else {
|
||||
log.warn("指令号:{},acs请求wms放货完成离开失败,wms不允许agv放货完成离开,未反馈agv放货完成离开", inst.getInstruction_code());
|
||||
}
|
||||
} else {
|
||||
log.warn("指令号:{},acs请求wms放货完成离开失败,连接被拒绝,未反馈agv放货完成离开", inst.getInstruction_code());
|
||||
}
|
||||
} else {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//到达位置点
|
||||
@@ -397,12 +261,38 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
agvaddr_copy = agvaddr;
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x50) {//进入交通灯区域
|
||||
} else if (phase == 0x50) {//进入区域
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x51) {//离开交通灯区域
|
||||
} else if (phase == 0x51) {//离开区域
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x67) {//agv异常
|
||||
if (ikey == 0) {
|
||||
this.setErrorInfo(ikey, "0", "正常");
|
||||
} else {
|
||||
Map<String, String> error = ErrorUtil.getAgvErrorMsg(ikey);
|
||||
String code = error.get("code");
|
||||
String info = error.get("info");
|
||||
this.setErrorInfo(ikey, code, info);
|
||||
}
|
||||
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 (!ObjectUtil.isEmpty(data)) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
@@ -410,4 +300,19 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package org.nl.acs.device_driver.basedriver.agv.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.nl.modules.system.domain.Dict;
|
||||
import org.nl.modules.system.service.DictDetailService;
|
||||
import org.nl.modules.system.service.DictService;
|
||||
import org.nl.modules.system.service.dto.DictDetailDto;
|
||||
import org.nl.modules.system.service.impl.DictDetailServiceImpl;
|
||||
import org.nl.modules.system.service.impl.DictServiceImpl;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: geng by
|
||||
* @createDate: 2023/3/15
|
||||
*/
|
||||
public class ErrorUtil {
|
||||
|
||||
public static ConcurrentHashMap<String, List<DictDetailDto>> dictMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public static String getDictDetail(String type, String error_code) {
|
||||
getDict();
|
||||
List<DictDetailDto> dictDetailDtos = dictMap.get(type);
|
||||
String detail = null;
|
||||
if (ObjectUtil.isNotEmpty(dictDetailDtos)) {
|
||||
for (int i = 0; i < dictDetailDtos.size(); i++) {
|
||||
DictDetailDto dictDetailDto = dictDetailDtos.get(i);
|
||||
String value = dictDetailDto.getValue();
|
||||
String label = dictDetailDto.getLabel();
|
||||
if (StrUtil.equals(value, error_code)) {
|
||||
detail = label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return detail == null ? "字典表未配置对应的报警信息" : detail;
|
||||
}
|
||||
|
||||
public static Map<Integer, String> getDictDetailByName(String type) {
|
||||
getDict();
|
||||
List<DictDetailDto> dictDetailDtos = dictMap.get(type);
|
||||
Map<Integer, String> map = new HashMap<>();
|
||||
if (ObjectUtil.isNotEmpty(dictDetailDtos)) {
|
||||
List<DictDetailDto> dtos = dictDetailDtos
|
||||
.stream()
|
||||
.filter(dictDetailDto -> !dictDetailDto.getValue().equals("0"))
|
||||
.filter(dictDetailDto -> !dictDetailDto.getValue().equals("-1"))
|
||||
.collect(Collectors.toList());
|
||||
dtos.forEach(dictDetailDto -> map.put(Integer.parseInt(dictDetailDto.getValue()), dictDetailDto.getLabel()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public static void getDict() {
|
||||
if (ObjectUtil.isEmpty(dictMap)) {
|
||||
DictDetailService dictDetailService = SpringContextHolder.getBean(DictDetailServiceImpl.class);
|
||||
DictService dictService = SpringContextHolder.getBean(DictServiceImpl.class);
|
||||
List<Dict> dictDtos = dictService.queryAll();
|
||||
for (int i = 0; i < dictDtos.size(); i++) {
|
||||
Dict dictDto = dictDtos.get(i);
|
||||
dictMap.put(dictDto.getName(), getDict(dictDto.getName(), t -> {
|
||||
return dictDetailService.getDictByName(t);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<DictDetailDto> getDict(String name, Function<String, List<DictDetailDto>> f) {
|
||||
return f.apply(name);
|
||||
}
|
||||
|
||||
public static Map<String, String> getAgvErrorMsg(Integer ageErrorNum) {
|
||||
Map<Integer, String> agvMap = getDictDetailByName("agv_error_type");
|
||||
Integer[] keys = agvMap.keySet().toArray(new Integer[0]);
|
||||
String message = "";
|
||||
String code = "";
|
||||
out:
|
||||
for (int i = 1; i < 1 << keys.length; i++) {
|
||||
int sum = 0;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sbCode = new StringBuffer();
|
||||
inner:
|
||||
for (int j = 0; j < keys.length; j++) {
|
||||
if ((i & 1 << j) != 0) {
|
||||
sum += keys[j];
|
||||
sb.append(agvMap.get(keys[j])).append(",");
|
||||
sbCode.append(keys[j]).append(",");
|
||||
}
|
||||
}
|
||||
if (sum == ageErrorNum) {
|
||||
code = sbCode.toString();
|
||||
message = sb.toString();
|
||||
break out;
|
||||
}
|
||||
}
|
||||
Map<String, String> map = new HashMap<>();
|
||||
String info = replace(message);
|
||||
code = replace(code);
|
||||
map.put("code", StrUtil.isEmpty(code) ? "-1" : code);
|
||||
map.put("info", StrUtil.isEmpty(info) ? "AGV上报报警代码有误" : info);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String replace(String message) {
|
||||
if (StrUtil.isEmpty(message)) {
|
||||
return null;
|
||||
}
|
||||
if (message.endsWith(",")) {
|
||||
return message.substring(0, message.length() - 1);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user