|
@@ -96,326 +96,256 @@ public class DataFormat {
|
|
|
return tempIndex == str.length() ? str : str.substring(0, tempIndex);
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public static Map<String, Object> typeBToMap(String typeStr, String dataObjectId, Map<String, String> transMaps) {
|
|
|
+ public static Map<String, Object> typeBToMap(Object typeStr, String dataObjectId, Map<String, String> transMaps) {
|
|
|
try {
|
|
|
- if (MapTools.isBlank(typeStr)) {
|
|
|
- return MapTools.processSuccess(null);
|
|
|
+ if (Objects.isNull(typeStr)) return MapTools.processSuccess(null);
|
|
|
+ if (Objects.isNull(transMaps)) transMaps = new HashMap<>();
|
|
|
+ List<Object> tempList = new ArrayList<>();
|
|
|
+ if (typeStr instanceof List<?> tempInList) {
|
|
|
+ tempList.addAll(tempInList);
|
|
|
+ } else {
|
|
|
+ tempList.add(typeStr);
|
|
|
}
|
|
|
- if (Objects.isNull(transMaps)) {
|
|
|
- transMaps = new HashMap<>();
|
|
|
+ List<Map<String, Object>> rsList = new ArrayList<>();
|
|
|
+ for (Object o : tempList) {
|
|
|
+ String inData = Objects.toString(o);
|
|
|
+ if (MapTools.isBlank(inData)) continue;
|
|
|
+ int dataObjectIdIndex = inData.indexOf("dataObjectId");
|
|
|
+ String tpDataObjectId = inData.length() > 39 ? inData.substring(dataObjectIdIndex + 15, dataObjectIdIndex + 39) : null;
|
|
|
+ rsList.addAll(typebHandler(inData, transMaps, MapTools.isBlank(tpDataObjectId) ? dataObjectId : tpDataObjectId));
|
|
|
}
|
|
|
- List<String> typeStrList = MapTools.patternContent(typeStr, "\\{(.+?)\\}");
|
|
|
-
|
|
|
- List<Map<String, Object>> returnDataList = new ArrayList<>();
|
|
|
- for (String dataType : messageRules.keySet()) {
|
|
|
- List<String> messagList = new ArrayList<>();
|
|
|
- for (String tempTypeStr : typeStrList) {
|
|
|
- if (tempTypeStr.indexOf("dataObjectId") > 0) {
|
|
|
- String tempDataObjectId = tempTypeStr.substring(tempTypeStr.indexOf("dataObjectId"));
|
|
|
- dataObjectId = tempDataObjectId.replaceAll("[^0-9]+", "");
|
|
|
- }
|
|
|
- List<String> tempMessageList = MapTools.patternContent(tempTypeStr, messageRules.get(dataType));
|
|
|
- if (tempMessageList.size() > 0) {
|
|
|
- messagList.addAll(tempMessageList);
|
|
|
- } else {
|
|
|
- if (tempTypeStr.contains(dataType)) {
|
|
|
- HashMap<String, Object> errorMap = new HashMap<>();
|
|
|
- errorMap.put("dataObjectId", dataObjectId);
|
|
|
- errorMap.put("errMessage", "报文数据格式错误");
|
|
|
- errorMap.put("sourceData", tempTypeStr);
|
|
|
- if (!returnDataList.contains(errorMap)) {
|
|
|
- returnDataList.add(errorMap);
|
|
|
- }
|
|
|
+ return processSuccess(rsList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return processFail(LogUtils.getException(e));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static List<Map<String, Object>> typebHandler(String typeStr, Map<String, String> transMaps, String dataObjectId) {
|
|
|
+ List<String> typeStrList = MapTools.patternContent(typeStr, "\\{(.+?)\\}");
|
|
|
+
|
|
|
+ List<Map<String, Object>> returnDataList = new ArrayList<>();
|
|
|
+ for (String dataType : messageRules.keySet()) {
|
|
|
+ List<String> messagList = new ArrayList<>();
|
|
|
+ for (String tempTypeStr : typeStrList) {
|
|
|
+ if (tempTypeStr.indexOf("dataObjectId") > 0) {
|
|
|
+ String tempDataObjectId = tempTypeStr.substring(tempTypeStr.indexOf("dataObjectId"));
|
|
|
+ dataObjectId = tempDataObjectId.replaceAll("[^0-9]+", "");
|
|
|
+ }
|
|
|
+ List<String> tempMessageList = MapTools.patternContent(tempTypeStr, messageRules.get(dataType));
|
|
|
+ if (tempMessageList.size() > 0) {
|
|
|
+ messagList.addAll(tempMessageList);
|
|
|
+ } else {
|
|
|
+ if (tempTypeStr.contains(dataType)) {
|
|
|
+ HashMap<String, Object> errorMap = new HashMap<>();
|
|
|
+ errorMap.put("dataObjectId", dataObjectId);
|
|
|
+ errorMap.put("errMessage", "报文数据格式错误");
|
|
|
+ errorMap.put("sourceData", tempTypeStr);
|
|
|
+ if (!returnDataList.contains(errorMap)) {
|
|
|
+ returnDataList.add(errorMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- for (String signData : messagList) {
|
|
|
- Map<String, Object> signDataMap = new HashMap<>();
|
|
|
- signDataMap.put("dataType", dataType);
|
|
|
- signDataMap.put("dataObjectId", dataObjectId);
|
|
|
- signDataMap.put("sourceData", signData);
|
|
|
- String[] rowDataList = signData.split("(?=\\.[A-Z]{1}\\/)");
|
|
|
-
|
|
|
- signDataMap.put("dataState", dataType.equals("BSM") ? (rowDataList[0].contains("DEL") ? "DEL" : (rowDataList[0].contains("CHG") ? "CHG" : "ADD")) : null);
|
|
|
- List<Map<String, Object>> containerList = new ArrayList<>();
|
|
|
- List<Map<String, Object>> luggageList = new ArrayList<>();
|
|
|
- for (int rowNum = 1; rowNum < rowDataList.length; rowNum++) {
|
|
|
- String rowDataStr = rowDataList[rowNum];
|
|
|
- String rowType = rowDataStr.substring(0, 3);
|
|
|
- if (".B/.N/".contains(rowType)) {
|
|
|
- List<String> luggageNumList = new ArrayList<>();
|
|
|
- String luggageState = null;
|
|
|
- String[] colList = rowDataStr.split("\\/");
|
|
|
- for (int colNum = 1; colNum < colList.length; colNum++) {
|
|
|
- String colValue = colList[colNum].trim();
|
|
|
- colValue = replaceWrap(colValue);
|
|
|
- if (MapTools.isNumber(colValue) && colValue.length() == 13) {
|
|
|
- String luggageNum = colValue.substring(0, 10);
|
|
|
- for (int loopNum = 0; loopNum < Integer.parseInt(colValue.substring(10, 13)); loopNum++) {
|
|
|
- luggageNum = String.format("%010d", (Long.parseLong(luggageNum) + loopNum));
|
|
|
- luggageNumList.add(luggageNum);
|
|
|
- }
|
|
|
- } else {
|
|
|
- luggageState = MapTools.isNotBlank(colValue) ? colValue.substring(0, 3) : null;
|
|
|
+ }
|
|
|
+ for (String signData : messagList) {
|
|
|
+ Map<String, Object> signDataMap = new HashMap<>();
|
|
|
+ signDataMap.put("dataType", dataType);
|
|
|
+ signDataMap.put("dataObjectId", dataObjectId);
|
|
|
+ signDataMap.put("sourceData", signData);
|
|
|
+ String[] rowDataList = signData.split("(?=\\.[A-Z]{1}\\/)", -1);
|
|
|
+
|
|
|
+ signDataMap.put("dataState", dataType.equals("BSM") ? (rowDataList[0].contains("DEL") ? "DEL" : (rowDataList[0].contains("CHG") ? "CHG" : "ADD")) : null);
|
|
|
+ List<Map<String, Object>> containerList = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> luggageList = new ArrayList<>();
|
|
|
+ for (int rowNum = 1; rowNum < rowDataList.length; rowNum++) {
|
|
|
+ String rowDataStr = rowDataList[rowNum];
|
|
|
+ String rowType = rowDataStr.substring(0, 3);
|
|
|
+ if (".B/.N/".contains(rowType)) {
|
|
|
+ List<String> luggageNumList = new ArrayList<>();
|
|
|
+ String luggageState = null;
|
|
|
+ String[] colList = rowDataStr.split("\\/", -1);
|
|
|
+ for (int colNum = 1; colNum < colList.length; colNum++) {
|
|
|
+ String colValue = colList[colNum].trim();
|
|
|
+ colValue = replaceWrap(colValue);
|
|
|
+ if (MapTools.isNumber(colValue) && colValue.length() == 13) {
|
|
|
+ String luggageNum = colValue.substring(0, 10);
|
|
|
+ for (int loopNum = 0; loopNum < Integer.parseInt(colValue.substring(10, 13)); loopNum++) {
|
|
|
+ luggageNum = String.format("%010d", (Long.parseLong(luggageNum) + loopNum));
|
|
|
+ luggageNumList.add(luggageNum);
|
|
|
}
|
|
|
- }
|
|
|
- for (String luggageNum : luggageNumList) {
|
|
|
- Map<String, Object> luggageMap = new HashMap<>();
|
|
|
- luggageMap.put("luggageNum", luggageNum);
|
|
|
- luggageMap.put("abnormalState", luggageState);
|
|
|
- luggageList.add(luggageMap);
|
|
|
+ } else {
|
|
|
+ luggageState = MapTools.isNotBlank(colValue) ? colValue.substring(0, 3) : null;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (".C/.E/.L/.M/.P/.Q/.R/.T/".contains(rowType)) {
|
|
|
- rowDataStr = rowDataStr.replace(rowType, "").trim();
|
|
|
+ for (String luggageNum : luggageNumList) {
|
|
|
+ Map<String, Object> luggageMap = new HashMap<>();
|
|
|
+ luggageMap.put("luggageNum", luggageNum);
|
|
|
+ luggageMap.put("abnormalState", luggageState);
|
|
|
+ luggageList.add(luggageMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (".C/.E/.L/.M/.P/.Q/.R/.T/".contains(rowType)) {
|
|
|
+ rowDataStr = rowDataStr.replace(rowType, "").trim();
|
|
|
|
|
|
- rowDataStr = replaceWrap(rowDataStr);
|
|
|
- if (".P/".equals(rowType)) {
|
|
|
- rowDataStr = rowDataStr.replaceAll("[(0-9)]", "").replaceAll("\\/", "");
|
|
|
- }
|
|
|
- if (Objects.nonNull(transMaps.get(rowType))) {
|
|
|
- signDataMap.put(transMaps.get(rowType), (signDataMap.containsKey(rowType) ? signDataMap.get(rowType) + "," : "") + rowDataStr);
|
|
|
- }
|
|
|
+ rowDataStr = replaceWrap(rowDataStr);
|
|
|
+ if (".P/".equals(rowType)) {
|
|
|
+ rowDataStr = rowDataStr.replaceAll("[(0-9)]", "").replaceAll("\\/", "");
|
|
|
}
|
|
|
-
|
|
|
- if (".D/.F/.G/.H/.I/.J/.O/.S/.W/.X/.Y/".contains(rowType) && !signDataMap.containsKey(rowType + "1")) {
|
|
|
- String[] colList = rowDataStr.split("\\/");
|
|
|
- for (int colNum = 1; colNum < colList.length; colNum++) {
|
|
|
- String colValue = colList[colNum].trim();
|
|
|
- colValue = replaceWrap(colValue);
|
|
|
-
|
|
|
- if (".F/.I/.O/.D/.J/".contains(rowType)) {
|
|
|
- String patternValue = MapTools.patternKey(colValue, "[0-3]{1}[0-9]{1}(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)");
|
|
|
- if (!MapTools.isBlank(patternValue)) {
|
|
|
- colValue = TypeBDateChange(patternValue, null);
|
|
|
- signDataMap.put(rowType.equals(".D/") ? ".D/3" : (rowType.equals(".J/") ? ".J/4" : (rowType + "2")), colValue);
|
|
|
- }
|
|
|
- if (".F/.I/.O/".contains(rowType) && MapTools.isNotBlank(colValue)) {
|
|
|
- if (colValue.length() == 3 && !MapTools.isBlank(MapTools.patternKey(colValue, "[A-z]{3}"))) {
|
|
|
- if (!signDataMap.containsKey(transMaps.get(rowType + "3"))) {
|
|
|
- signDataMap.put(transMaps.get(rowType + "3"), colValue);
|
|
|
- }
|
|
|
- }
|
|
|
- if (colNum == 1) {
|
|
|
- String temp = colValue.substring(2);
|
|
|
- signDataMap.put(transMaps.get(rowType + "1"), colValue.substring(0, 2) + ((MapTools.isNumber(temp.substring(temp.length() - 1)) ? String.format("%4s", temp) : String.format("%5s", temp)).replace(" ", "0")));
|
|
|
+ if (Objects.nonNull(transMaps.get(rowType))) {
|
|
|
+ signDataMap.put(transMaps.get(rowType), (signDataMap.containsKey(rowType) ? signDataMap.get(rowType) + "," : "") + rowDataStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (".D/.F/.G/.H/.I/.J/.O/.S/.W/.X/.Y/".contains(rowType) && !signDataMap.containsKey(rowType + "1")) {
|
|
|
+ String[] colList = rowDataStr.split("\\/", -1);
|
|
|
+ for (int colNum = 1; colNum < colList.length; colNum++) {
|
|
|
+ String colValue = colList[colNum].trim();
|
|
|
+ colValue = replaceWrap(colValue);
|
|
|
+
|
|
|
+ if (".F/.I/.O/.D/.J/".contains(rowType)) {
|
|
|
+ String patternValue = MapTools.patternKey(colValue, "[0-3]{1}[0-9]{1}(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)");
|
|
|
+ if (!MapTools.isBlank(patternValue)) {
|
|
|
+ colValue = TypeBDateChange(patternValue, null);
|
|
|
+ signDataMap.put(rowType.equals(".D/") ? ".D/3" : (rowType.equals(".J/") ? ".J/4" : (rowType + "2")), colValue);
|
|
|
+ }
|
|
|
+ if (".F/.I/.O/".contains(rowType) && MapTools.isNotBlank(colValue)) {
|
|
|
+ if (colValue.length() == 3 && !MapTools.isBlank(MapTools.patternKey(colValue, "[A-z]{3}"))) {
|
|
|
+ if (!signDataMap.containsKey(transMaps.get(rowType + "3"))) {
|
|
|
+ signDataMap.put(transMaps.get(rowType + "3"), colValue);
|
|
|
}
|
|
|
}
|
|
|
- if ((rowType + "" + colNum).equals(".J/5") || (rowType + "" + colNum).equals(".D/4")) {
|
|
|
- colValue = TypeBDateChange(null, colValue);
|
|
|
+ if (colNum == 1) {
|
|
|
+ String temp = colValue.substring(2);
|
|
|
+ signDataMap.put(transMaps.get(rowType + "1"), colValue.substring(0, 2) + ((MapTools.isNumber(temp.substring(temp.length() - 1)) ? String.format("%4s", temp) : String.format("%5s", temp)).replace(" ", "0")));
|
|
|
}
|
|
|
}
|
|
|
- if (".S/".contains(rowType) && MapTools.isNotBlank(colValue)) {
|
|
|
- if ("I,V,A".contains(colValue) && colValue.length() == 1 && !signDataMap.containsKey(transMaps.get(".S/8"))) {
|
|
|
- signDataMap.put(transMaps.get(".S/8"), colValue);
|
|
|
- }
|
|
|
+ if ((rowType + "" + colNum).equals(".J/5") || (rowType + "" + colNum).equals(".D/4")) {
|
|
|
+ colValue = TypeBDateChange(null, colValue);
|
|
|
}
|
|
|
- if (".X/".contains(rowType) && MapTools.isNotBlank(colValue)) {
|
|
|
- if (colValue.length() == 3) {
|
|
|
- if ("CLR,RFJ,UCL".contains(colValue)) {
|
|
|
- signDataMap.put(transMaps.get(".X/2"), colValue);
|
|
|
- } else {
|
|
|
- signDataMap.put(transMaps.get(".X/1"), colValue);
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ if (".S/".contains(rowType) && MapTools.isNotBlank(colValue)) {
|
|
|
+ if ("I,V,A".contains(colValue) && colValue.length() == 1 && !signDataMap.containsKey(transMaps.get(".S/8"))) {
|
|
|
+ signDataMap.put(transMaps.get(".S/8"), colValue);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- String key = rowType + "" + colNum;
|
|
|
- if (".D/3.D/4.J/4.J/5".contains(rowType + "" + colNum)) {
|
|
|
- if (!signDataMap.containsKey(key)) {
|
|
|
- signDataMap.put(rowType + "" + colNum, colValue);
|
|
|
+ }
|
|
|
+ if (".X/".contains(rowType) && MapTools.isNotBlank(colValue)) {
|
|
|
+ if (colValue.length() == 3) {
|
|
|
+ if ("CLR,RFJ,UCL".contains(colValue)) {
|
|
|
+ signDataMap.put(transMaps.get(".X/2"), colValue);
|
|
|
+ } else {
|
|
|
+ signDataMap.put(transMaps.get(".X/1"), colValue);
|
|
|
}
|
|
|
- } else {
|
|
|
- if (Objects.nonNull(transMaps.get(rowType + "" + colNum))) {
|
|
|
- if (!signDataMap.containsKey(transMaps.get(key))) {
|
|
|
- signDataMap.put(transMaps.get(rowType + "" + colNum), colValue);
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String key = rowType + "" + colNum;
|
|
|
+ if (".D/3.D/4.J/4.J/5".contains(rowType + "" + colNum)) {
|
|
|
+ if (!signDataMap.containsKey(key)) {
|
|
|
+ signDataMap.put(rowType + "" + colNum, colValue);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Objects.nonNull(transMaps.get(rowType + "" + colNum))) {
|
|
|
+ if (!signDataMap.containsKey(transMaps.get(key))) {
|
|
|
+ signDataMap.put(transMaps.get(rowType + "" + colNum), colValue);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- if (Objects.nonNull(signDataMap.get(".D/3")) && Objects.nonNull(signDataMap.get(".D/4"))) {
|
|
|
- String d4 = signDataMap.get(".D/4").toString();
|
|
|
- signDataMap.put("checkInTimeType", d4.substring(d4.length() - 1));
|
|
|
- signDataMap.put(transMaps.get(".D/3.D/4"), (signDataMap.get(".D/3") + " " + d4.substring(0, d4.length() - 1)).trim());
|
|
|
- signDataMap.remove(".D/3");
|
|
|
- signDataMap.remove(".D/4");
|
|
|
- }
|
|
|
- if (Objects.nonNull(signDataMap.get(".J/4")) && Objects.nonNull(signDataMap.get(".J/5"))) {
|
|
|
- String J5 = signDataMap.get(".J/5").toString();
|
|
|
- signDataMap.put("processTimeType", J5.substring(J5.length() - 1));
|
|
|
- signDataMap.put(transMaps.get(".J/4.J/5"), (signDataMap.get(".J/4") + " " + J5.substring(0, J5.length() - 1)).trim());
|
|
|
- signDataMap.remove(".J/4");
|
|
|
- signDataMap.remove(".J/5");
|
|
|
- }
|
|
|
+ if (Objects.nonNull(signDataMap.get(".D/3")) && Objects.nonNull(signDataMap.get(".D/4"))) {
|
|
|
+ String d4 = signDataMap.get(".D/4").toString();
|
|
|
+ signDataMap.put("checkInTimeType", d4.substring(d4.length() - 1));
|
|
|
+ signDataMap.put(transMaps.get(".D/3.D/4"), (signDataMap.get(".D/3") + " " + d4.substring(0, d4.length() - 1)).trim());
|
|
|
+ signDataMap.remove(".D/3");
|
|
|
+ signDataMap.remove(".D/4");
|
|
|
}
|
|
|
- if (".V/".equals(rowType) && !signDataMap.containsKey(rowType + "1")) {
|
|
|
- signDataMap.put(transMaps.get(".V/1"), rowDataStr.substring(4, 5));
|
|
|
- signDataMap.put(transMaps.get(".V/2"), rowDataStr.substring(5, 8));
|
|
|
+ if (Objects.nonNull(signDataMap.get(".J/4")) && Objects.nonNull(signDataMap.get(".J/5"))) {
|
|
|
+ String J5 = signDataMap.get(".J/5").toString();
|
|
|
+ signDataMap.put("processTimeType", J5.substring(J5.length() - 1));
|
|
|
+ signDataMap.put(transMaps.get(".J/4.J/5"), (signDataMap.get(".J/4") + " " + J5.substring(0, J5.length() - 1)).trim());
|
|
|
+ signDataMap.remove(".J/4");
|
|
|
+ signDataMap.remove(".J/5");
|
|
|
}
|
|
|
- if (".U/".equals(rowType)) {
|
|
|
- Map<String, Object> containerMap = new HashMap<>();
|
|
|
- String[] colList = rowDataStr.split("\\/");
|
|
|
- for (int colNum = 1; colNum < colList.length; colNum++) {
|
|
|
- String colValue = colList[colNum];
|
|
|
-
|
|
|
- colValue = replaceWrap(colValue);
|
|
|
- if (Objects.nonNull(transMaps.get(rowType + "" + colNum))) {
|
|
|
- containerMap.put(transMaps.get(rowType + "" + colNum), colValue);
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ if (".V/".equals(rowType) && !signDataMap.containsKey(rowType + "1")) {
|
|
|
+ signDataMap.put(transMaps.get(".V/1"), rowDataStr.substring(4, 5));
|
|
|
+ signDataMap.put(transMaps.get(".V/2"), rowDataStr.substring(5, 8));
|
|
|
+ }
|
|
|
+ if (".U/".equals(rowType)) {
|
|
|
+ Map<String, Object> containerMap = new HashMap<>();
|
|
|
+ String[] colList = rowDataStr.split("\\/", -1);
|
|
|
+ for (int colNum = 1; colNum < colList.length; colNum++) {
|
|
|
+ String colValue = colList[colNum];
|
|
|
+ colValue = replaceWrap(colValue);
|
|
|
+ if (Objects.nonNull(transMaps.get(rowType + "" + colNum))) {
|
|
|
+ containerMap.put(transMaps.get(rowType + "" + colNum), colValue);
|
|
|
}
|
|
|
- containerList.add(containerMap);
|
|
|
+
|
|
|
}
|
|
|
+ containerList.add(containerMap);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- if (containerList.size() == 0) {
|
|
|
- containerList.add(new HashMap<>());
|
|
|
- }
|
|
|
- if (containerList.size() > 2) {
|
|
|
- signDataMap.put("errMessage", "容器数量超规 " + containerList.size());
|
|
|
- Map<String, Object> containerMap = containerList.get(0);
|
|
|
- containerList = new ArrayList<>() {{
|
|
|
- add(containerMap);
|
|
|
- }};
|
|
|
+
|
|
|
+ if (containerList.size() == 0) {
|
|
|
+ containerList.add(new HashMap<>());
|
|
|
+ }
|
|
|
+ if (containerList.size() > 2) {
|
|
|
+ signDataMap.put("errMessage", "容器数量超规 " + containerList.size());
|
|
|
+ Map<String, Object> containerMap = containerList.get(0);
|
|
|
+ containerList = new ArrayList<>() {{
|
|
|
+ add(containerMap);
|
|
|
+ }};
|
|
|
|
|
|
+ }
|
|
|
+ for (int containerNum = 0; containerNum < containerList.size(); containerNum++) {
|
|
|
+ HashMap<String, Object> tempDataMapClone = MapTools.clone(signDataMap);
|
|
|
+ HashMap<String, Object> tempDataMap = Objects.isNull(tempDataMapClone) ? new HashMap<>() : tempDataMapClone;
|
|
|
+ Map<String, Object> containerMap = containerList.get(containerNum);
|
|
|
+ if (containerNum == 0 && containerList.size() > 1) {
|
|
|
+ containerMap.put("containerState", "OFF");
|
|
|
}
|
|
|
- for (int containerNum = 0; containerNum < containerList.size(); containerNum++) {
|
|
|
- HashMap<String, Object> tempDataMapClone = MapTools.clone(signDataMap);
|
|
|
- HashMap<String, Object> tempDataMap = Objects.isNull(tempDataMapClone) ? new HashMap<>() : tempDataMapClone;
|
|
|
- Map<String, Object> containerMap = containerList.get(containerNum);
|
|
|
- if (containerNum == 0 && containerList.size() > 1) {
|
|
|
- containerMap.put("containerState", "OFF");
|
|
|
- }
|
|
|
- if (!containerMap.isEmpty()) {
|
|
|
- tempDataMap.putAll(containerMap);
|
|
|
- }
|
|
|
- tempDataMap.values().removeAll(Collections.singleton(null));
|
|
|
- tempDataMap.values().removeAll(Collections.singleton(""));
|
|
|
- if (luggageList.size() == 0) {
|
|
|
- returnDataList.add(specialHandler(tempDataMap, dataObjectId));
|
|
|
- } else {
|
|
|
- for (Map<String, Object> tempLuggageMap : luggageList) {
|
|
|
- if (containerNum == 0 && containerList.size() > 1 && tempLuggageMap.get("abnormalState") == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (containerNum != 0 && containerList.size() > 1 && tempLuggageMap.get("abnormalState") != null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- HashMap<String, Object> objectObjectHashMap = new HashMap<>();
|
|
|
- objectObjectHashMap.putAll(tempDataMap);
|
|
|
- objectObjectHashMap.putAll(tempLuggageMap);
|
|
|
+ if (!containerMap.isEmpty()) {
|
|
|
+ tempDataMap.putAll(containerMap);
|
|
|
+ }
|
|
|
+ tempDataMap.values().removeAll(Collections.singleton(null));
|
|
|
+ tempDataMap.values().removeAll(Collections.singleton(""));
|
|
|
+ if (luggageList.size() == 0) {
|
|
|
+ returnDataList.add(specialHandler(tempDataMap, dataObjectId));
|
|
|
+ } else {
|
|
|
+ for (Map<String, Object> tempLuggageMap : luggageList) {
|
|
|
+ if (containerNum == 0 && containerList.size() > 1 && tempLuggageMap.get("abnormalState") == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (containerNum != 0 && containerList.size() > 1 && tempLuggageMap.get("abnormalState") != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ HashMap<String, Object> objectObjectHashMap = new HashMap<>();
|
|
|
+ objectObjectHashMap.putAll(tempDataMap);
|
|
|
+ objectObjectHashMap.putAll(tempLuggageMap);
|
|
|
|
|
|
- if (Objects.isNull(objectObjectHashMap.get("abnormalState"))) {
|
|
|
- objectObjectHashMap.remove("abnormalState");
|
|
|
- }
|
|
|
-
|
|
|
- returnDataList.add(specialHandler(objectObjectHashMap, dataObjectId));
|
|
|
+ if (Objects.isNull(objectObjectHashMap.get("abnormalState"))) {
|
|
|
+ objectObjectHashMap.remove("abnormalState");
|
|
|
}
|
|
|
+ returnDataList.add(specialHandler(objectObjectHashMap, dataObjectId));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (returnDataList.size() == 0) {
|
|
|
- HashMap<String, Object> errorMap = new HashMap<>();
|
|
|
- errorMap.put("dataObjectId", dataObjectId);
|
|
|
- errorMap.put("errMessage", "报文数据格式错误");
|
|
|
- errorMap.put("sourceData", typeStr);
|
|
|
- returnDataList.add(errorMap);
|
|
|
- }
|
|
|
- return processSuccess(returnDataList);
|
|
|
- } catch (Exception e) {
|
|
|
- return processFail(LogUtils.getException(e));
|
|
|
}
|
|
|
+ if (returnDataList.size() == 0) {
|
|
|
+ HashMap<String, Object> errorMap = new HashMap<>();
|
|
|
+ errorMap.put("dataObjectId", dataObjectId);
|
|
|
+ errorMap.put("errMessage", "报文数据格式错误");
|
|
|
+ errorMap.put("sourceData", typeStr);
|
|
|
+ returnDataList.add(errorMap);
|
|
|
+ }
|
|
|
+ return returnDataList;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -557,7 +487,6 @@ public class DataFormat {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
* map key值转换
|
|
|
*
|
|
@@ -596,11 +525,11 @@ public class DataFormat {
|
|
|
Document doc = DocumentHelper.parseText(xmlStr);
|
|
|
Element root = doc.getRootElement();
|
|
|
Map<String, Object> returnMap = xmlToMap(root);
|
|
|
- returnMap.put("souceData",xml);
|
|
|
+ returnMap.put("souceData", xml);
|
|
|
return processSuccess(returnMap);
|
|
|
} catch (Exception e) {
|
|
|
Map<String, Object> errMap = processFail("入参不是规则的xml :" + xml);
|
|
|
- errMap.put("souceData",xml);
|
|
|
+ errMap.put("souceData", xml);
|
|
|
return errMap;
|
|
|
}
|
|
|
}
|