去除无用代码,新增主数据功能
This commit is contained in:
@@ -29,21 +29,23 @@ public class FormExecelUtils {
|
||||
Map<String, Object> dataMap = new HashMap<>(16);
|
||||
Map m = excelDataList.get(z);
|
||||
List excelEntrySet = new ArrayList<>(m.entrySet());
|
||||
// 取出的数据最后一行 不带行标签
|
||||
int resultsize = z == excelDataList.size() - 1 ? excelEntrySet.size()
|
||||
: m.containsKey("excelRowNum") ? excelEntrySet.size() - 1 : excelEntrySet.size();
|
||||
if (resultsize < selectKey.size()) {
|
||||
throw new WorkFlowException(MsgCode.VS407.get());
|
||||
}
|
||||
for (int e = 0; e < resultsize; e++) {
|
||||
|
||||
// 读取所有有效字段,不校验数量,只校验字段是否合法
|
||||
for (int e = 0; e < excelEntrySet.size(); e++) {
|
||||
Map.Entry o = (Map.Entry) excelEntrySet.get(e);
|
||||
String entryKey = o.getKey().toString();
|
||||
String substring = entryKey.substring(entryKey.lastIndexOf("(") + 1, entryKey.lastIndexOf(")"));
|
||||
boolean contains = selectKey.contains(substring);
|
||||
if (!contains) {
|
||||
throw new WorkFlowException(MsgCode.VS407.get());
|
||||
|
||||
// 跳过没有括号的字段(避免报错)
|
||||
if (!entryKey.contains("(") || !entryKey.contains(")")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String substring = entryKey.substring(entryKey.lastIndexOf("(") + 1, entryKey.lastIndexOf(")"));
|
||||
|
||||
// 只保留模板里有的字段,不存在的自动忽略
|
||||
if (selectKey.contains(substring)) {
|
||||
dataMap.put(substring, o.getValue());
|
||||
}
|
||||
dataMap.put(substring, o.getValue());
|
||||
}
|
||||
allDataList.add(dataMap);
|
||||
}
|
||||
@@ -103,6 +105,9 @@ public class FormExecelUtils {
|
||||
for (String tab : tablefield1) {
|
||||
// 去掉最后一个 放到下条数据里
|
||||
List<Map<String, Object>> mapList = c.get(tab);
|
||||
if(mapList == null || mapList.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> map = mapList.get(mapList.size() - 1);
|
||||
List<Map<String, Object>> aList = new ArrayList<>();
|
||||
aList.add(map);
|
||||
@@ -132,6 +137,9 @@ public class FormExecelUtils {
|
||||
|
||||
// 处理结果
|
||||
for (int r = 0; r < results.size(); r++) {
|
||||
if(r >= IndexMap.size()){
|
||||
break;
|
||||
}
|
||||
Map<String, List<Map<String, Object>>> entry = IndexMap.get(r);
|
||||
Map<String, Object> map = results.get(r);
|
||||
for (Map.Entry<String, List<Map<String, Object>>> entry1 : entry.entrySet()) {
|
||||
@@ -148,4 +156,4 @@ public class FormExecelUtils {
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user