|
@@ -71,9 +71,14 @@ public abstract class AutomaticReportTableValidate implements ReportTableValidat
|
|
|
*/
|
|
|
private JSONObject resolveAutoTableSheetData(JSONObject sheet, LocalDateTime referTime) {
|
|
|
JSONArray sheetData = sheet.getJSONArray("data");
|
|
|
+ String sheetIndex = sheet.getString("index");
|
|
|
//遍历sheet所有单元格,并存为Map<tableId,Map<uid,JSONObject>>格式
|
|
|
- Map<String, Map<String, JSONObject>> sheetTableMap = getAutoStringMapMap(sheetData);
|
|
|
-
|
|
|
+ Map<String, Map<String, JSONObject>> sheetTableMap = getAutoStringMapMap(sheetData,sheetIndex);
|
|
|
+ //
|
|
|
+ //处理公式
|
|
|
+ sheet.put("calcChain",sheetTableMap.get("calcChain").values().toArray());
|
|
|
+ //清除公式
|
|
|
+ sheetTableMap.remove("calcChain");
|
|
|
//遍历生成的sheetTableMap,根据配置获取数据,并存为Map<tableId, Map<uid,List<Item>>>格式
|
|
|
Map<String, Map<String, List<Item>>> sheetTableDataMap = new HashMap<>();
|
|
|
for (Map.Entry<String, Map<String, JSONObject>> sheetTable : sheetTableMap.entrySet()) {
|
|
@@ -161,7 +166,7 @@ public abstract class AutomaticReportTableValidate implements ReportTableValidat
|
|
|
* @return
|
|
|
*/
|
|
|
@NotNull
|
|
|
- private static Map<String, Map<String, JSONObject>> getAutoStringMapMap(JSONArray sheetData) {
|
|
|
+ private static Map<String, Map<String, JSONObject>> getAutoStringMapMap(JSONArray sheetData,String index) {
|
|
|
Map<String, Map<String, JSONObject>> sheetTableMap = new HashMap<>();
|
|
|
for (int i = 0; i < sheetData.size(); i++) {
|
|
|
JSONArray row = sheetData.getJSONArray(i);
|
|
@@ -170,25 +175,43 @@ public abstract class AutomaticReportTableValidate implements ReportTableValidat
|
|
|
if (Blank.isNotEmpty(rowCol)) {
|
|
|
try {
|
|
|
JSONObject rowColJson = JSONObject.parseObject(rowCol.getString("celldata"));
|
|
|
- String tableId = rowColJson.getString("tableId");
|
|
|
- String type = rowColJson.getString("type");
|
|
|
- if (type.equals("data")) {
|
|
|
- JSONObject rowColData = rowColJson.getJSONObject("data");
|
|
|
- String uid = rowColData.getString("uid");
|
|
|
- Map<String, JSONObject> sheetUidMap = sheetTableMap.get(tableId);
|
|
|
- if (Blank.isEmpty(sheetUidMap)) sheetUidMap = new HashMap<>();
|
|
|
- //得到所有sheet数据生成条件
|
|
|
- if (Blank.isEmpty(sheetUidMap.get(uid)) && Blank.isNotEmpty(uid)) {
|
|
|
- sheetUidMap.put(uid, rowColJson);
|
|
|
- sheetTableMap.put(tableId, sheetUidMap);
|
|
|
+ if(rowColJson!=null){
|
|
|
+ String tableId = rowColJson.getString("tableId");
|
|
|
+ String type = rowColJson.getString("type");
|
|
|
+ if (type.equals("data")) {
|
|
|
+ JSONObject rowColData = rowColJson.getJSONObject("data");
|
|
|
+ String uid = rowColData.getString("uid");
|
|
|
+ Map<String, JSONObject> sheetUidMap = sheetTableMap.get(tableId);
|
|
|
+ if (Blank.isEmpty(sheetUidMap)) sheetUidMap = new HashMap<>();
|
|
|
+ //得到所有sheet数据生成条件
|
|
|
+ if (Blank.isEmpty(sheetUidMap.get(uid)) && Blank.isNotEmpty(uid)) {
|
|
|
+ sheetUidMap.put(uid, rowColJson);
|
|
|
+ sheetTableMap.put(tableId, sheetUidMap);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ String calcCell = rowCol.getString("f");
|
|
|
+ if(!calcCell.equals("")){
|
|
|
+ JSONObject calcChain = new JSONObject();
|
|
|
+ calcChain.put("r",i);
|
|
|
+ calcChain.put("c",j);
|
|
|
+ calcChain.put("index",index);
|
|
|
+
|
|
|
+ Map<String, JSONObject> sheetCalcMap = sheetTableMap.get("calcChain");
|
|
|
+ if (Blank.isEmpty(sheetCalcMap)) sheetCalcMap = new HashMap<>();
|
|
|
+ String cell = String.format("%d_%d",i,j);
|
|
|
+ if (Blank.isEmpty(sheetCalcMap.get(cell)) && Blank.isNotEmpty(cell)) {
|
|
|
+ sheetCalcMap.put(cell, calcChain);
|
|
|
+ sheetTableMap.put("calcChain", sheetCalcMap);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
return sheetTableMap;
|
|
|
}
|
|
|
|