Browse Source

1、修改报表公式问题

lry 11 months ago
parent
commit
58c634a868

+ 38 - 15
industry-system/industry-da/src/main/java/com/example/opc_da/validate/reportTable/AutomaticReportTableValidate.java

@@ -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;
     }
 

+ 0 - 8
industry-system/industry-da/src/main/resources/static/reportSheet/js/Luckysheet-2.1.13/luckysheet.umd.js

@@ -66961,7 +66961,6 @@
 				}
 			},
 			pasteHandlerOfCopyPaste: function(e) {
-				//console.log('pasteHandlerOfCopyPaste');
 				if (Fh(Zr.luckysheet_select_save, Zr.currentSheetIndex)) {
 					var t = $.extend(!0, {}, Zr.config);
 					null == t.merge && (t.merge = {});
@@ -66990,7 +66989,6 @@
 					
 					//如果是数据点位则生成新的标识替换复制的标识
 					var tableid = uuidv4();
-					//console.log('tableid='+tableid)
 					if(m.length > 0)
 						for (var p = 0; p < m.length; p++)
 							for (var f = 0; f < m[p].length; f++) {
@@ -72959,7 +72957,6 @@
 				Qo(r)
 			},
 			insertUpdateFunctionGroup: function(e, t, a) {
-				console.log('insertUpdateFunctionGroup');
 				null == a && (a = Zr.currentSheetIndex);
 				var r = Yo(),
 					n = r[Go(a)],
@@ -73217,7 +73214,6 @@
 					.execFunctionGroup()
 			},
 			execFunctionGroup: function(e, t, a, r, n) {
-				console.log('in');
 				var l = this,
 					i = arguments.length > 5 && void 0 !== arguments[5] && arguments[5],
 					o = this;
@@ -73236,7 +73232,6 @@
 					];
 					Lu(0, 0, s, a), o.execFunctionGlobalData[e + "_" + t + "_" + r] = s[0][0]
 				}
-				//console.log(o.getAllFunctionGroup());
 				for (var c = o.getAllFunctionGroup(), u = {}, d = Yo(), h = {}, m = 0; m < d.length; m++) {
 					var p = d[m];
 					h[p.index] = p.data
@@ -73528,14 +73523,11 @@
 				Qo(r)
 			},
 			execfunction: function(e, t, a, r, n, l) {
-				//console.log('execfunction');
 				var i = mi().formulaMore;
-				console.log(e);
 				if (e.indexOf(this.error.r) > -1) return [!1, this.error.r, e];
 				this.checkBracketNum(e) || (e += ")"), null == r && (r = Zr.currentSheetIndex), Zr
 					.calculateSheetIndex = r;
 				var o = $.trim(this.functionParserExe(e));
-				//console.log(e);
 				if ("luckysheet_function." != o.substr(0, 20) && "luckysheet_compareWith" != o.substr(0,
 					22) || (this.functionHTMLIndex = 0), !this.testFunction(e, o) || "" == o) return Fm
 					.info("", i.execfunctionError), [!1, this.error.n, e];

+ 1 - 1
industry-system/industry-da/src/main/resources/static/reportSheet/js/report-history.js

@@ -284,7 +284,7 @@ const indexFn = {
 					cellMousedown:function(cell,position,sheet,ctx){
 						//console.log('r='+position.r+','+'c='+position.c);
 						//console.log(position.c);
-						console.log(cell);
+						//console.log(cell);
 					},
 					workbookCreateAfter: function() {
 						luckysheet.setRangeShow('B1:B2', {

+ 1 - 1
industry-system/industry-da/src/main/resources/static/reportSheet/js/src/model/right-menu.js

@@ -33,7 +33,7 @@ layui.define(['layer', 'util', 'jquery', 'form', 'sheetTypew', 'chartRightw', 'i
 			if (layui.sheetTypew.templateReportId > 0) {
 				params.id = layui.sheetTypew.templateReportId
 				params.version = layui.sheetTypew.templateReportVersion
-				console.log(params)
+				//console.log(params)
 				layui.api.updateTableTemplate(params).then(json => {
 					if (json.code == 200) {
 						window.localStorage.setItem('cnt',0);

+ 1 - 1
industry-system/industry-da/src/main/resources/static/reportSheet/js/src/model/sheet-util.js

@@ -167,7 +167,7 @@ layui.define(function(exports) {
 				cellMousedown:function(cell,position,sheet,ctx){
 					//console.log('r='+position.r+','+'c='+position.c);
 					//console.log(position.c);
-					console.log(cell);
+					//console.log(cell);
 				},
 				rangePasteAfter:function(range,data){
 					 //console.log('rangePasteAfter')