Merge branch 'master' of http://121.40.234.130:8899/root/lanzhouhailiang_one
This commit is contained in:
@@ -10,10 +10,7 @@ import org.nl.modules.system.service.impl.DictDetailServiceImpl;
|
|||||||
import org.nl.modules.system.service.impl.DictServiceImpl;
|
import org.nl.modules.system.service.impl.DictServiceImpl;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -68,9 +65,7 @@ public class ErrorUtil {
|
|||||||
List<Dict> dictDtos = dictService.queryAll();
|
List<Dict> dictDtos = dictService.queryAll();
|
||||||
for (int i = 0; i < dictDtos.size(); i++) {
|
for (int i = 0; i < dictDtos.size(); i++) {
|
||||||
Dict dictDto = dictDtos.get(i);
|
Dict dictDto = dictDtos.get(i);
|
||||||
dictMap.put(dictDto.getName(), getDict(dictDto.getName(), t -> {
|
dictMap.put(dictDto.getName(), getDict(dictDto.getName(), dictDetailService::getDictByName));
|
||||||
return dictDetailService.getDictByName(t);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,35 +74,57 @@ public class ErrorUtil {
|
|||||||
return f.apply(name);
|
return f.apply(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> getAgvErrorMsg(Integer ageErrorNum) {
|
public static Map<String, String> getAgvErrorMsg(Integer agvErrorNum) {
|
||||||
Map<Integer, String> agvMap = getDictDetailByName("agv_error_type");
|
String code;
|
||||||
Integer[] keys = agvMap.keySet().toArray(new Integer[0]);
|
String message;
|
||||||
String message = "";
|
|
||||||
String code = "";
|
if (agvErrorNum == 0) {
|
||||||
out:
|
code = "0";
|
||||||
for (int i = 1; i < 1 << keys.length; i++) {
|
message = "正常";
|
||||||
int sum = 0;
|
} else if (agvErrorNum < 0) {
|
||||||
StringBuffer sb = new StringBuffer();
|
code = "-1";
|
||||||
StringBuffer sbCode = new StringBuffer();
|
message = "AGV上报报警代码有误";
|
||||||
inner:
|
} else {
|
||||||
for (int j = 0; j < keys.length; j++) {
|
Map<Integer, String> agvMap = getDictDetailByName("agv_error_type");
|
||||||
if ((i & 1 << j) != 0) {
|
if (agvMap.isEmpty()) {
|
||||||
sum += keys[j];
|
code = "-1";
|
||||||
sb.append(agvMap.get(keys[j])).append(",");
|
message = "字典表未配置 [agv_error_type]";
|
||||||
sbCode.append(keys[j]).append(",");
|
} else {
|
||||||
|
List<Map.Entry<Integer, String>> errors = agvMap.entrySet().stream().filter(e -> e.getKey() > 0).sorted(Comparator.comparingInt(Map.Entry::getKey)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (errors.isEmpty()) {
|
||||||
|
code = "-1";
|
||||||
|
message = "字典表 [agv_error_type] 配置有误";
|
||||||
|
} else if (agvErrorNum >= (int) Math.pow(2, errors.get(errors.size() - 1).getKey())) {
|
||||||
|
code = "-1";
|
||||||
|
message = "AGV上报报警代码有误";
|
||||||
|
} else {
|
||||||
|
int index = 0;
|
||||||
|
StringBuilder errorCode = new StringBuilder();
|
||||||
|
StringBuilder errorMessage = new StringBuilder();
|
||||||
|
for (int i = agvErrorNum; i != 0; i = i >> 1) {
|
||||||
|
if (index == errors.size()) {
|
||||||
|
errorCode.setLength(0);
|
||||||
|
errorCode.append("-1");
|
||||||
|
errorMessage.setLength(0);
|
||||||
|
errorMessage.append("字典表 [agv_error_type] 配置有误");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i % 2 == 1) {
|
||||||
|
errorCode.append(errors.get(index).getKey()).append(",");
|
||||||
|
errorMessage.append(errors.get(index).getValue()).append(",");
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
code = errorCode.toString();
|
||||||
|
message = errorMessage.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sum == ageErrorNum) {
|
|
||||||
code = sbCode.toString();
|
|
||||||
message = sb.toString();
|
|
||||||
break out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
String info = replace(message);
|
map.put("code", replace(code));
|
||||||
code = replace(code);
|
map.put("info", replace(message));
|
||||||
map.put("code", StrUtil.isEmpty(code) ? "-1" : code);
|
|
||||||
map.put("info", StrUtil.isEmpty(info) ? "AGV上报报警代码有误" : info);
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +132,7 @@ public class ErrorUtil {
|
|||||||
if (StrUtil.isEmpty(message)) {
|
if (StrUtil.isEmpty(message)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (message.endsWith(",")) {
|
if (message.endsWith(",") || message.endsWith(",")) {
|
||||||
return message.substring(0, message.length() - 1);
|
return message.substring(0, message.length() - 1);
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
|
|||||||
Reference in New Issue
Block a user