zhoupeng 1 rok temu
rodzic
commit
a4de47dbd3

+ 8 - 6
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/task/PrintTask.java

@@ -1,6 +1,8 @@
 package com.example.opc_da.task;
 
+import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.example.opc_common.entity.Print;
 import com.example.opc_common.entity.PrintConfig;
 import com.example.opc_common.enums.ResultEnum;
@@ -15,6 +17,8 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.net.InetAddress;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -51,13 +55,11 @@ public class PrintTask {
                     printConfig = printConfig1;
                 }
             }
-            String url = "http://" + hostAddress + ":8081/app" + pageUrl + "?id=" + reportTableId +
-                    "&printArea=" + printConfig.getPrintArea() + "&printAreaValue=" + printConfig.getPrintAreaValue();
+//            String url = "http://192.168.0.15:8081/app" + pageUrl + "?id=" + reportTableId;
+            String url = "http://" + hostAddress + ":8081/app" + pageUrl + "?id=" + reportTableId;
             log.info("报表请求地址{}", url);
-            Map<String, Object> map = new HashMap<>();
-            map.put("url", url);
-            map.put("printConfig", printConfig);
-            String post = HttpUtil.post("http://" + printIp + ":8084" + printUrl, map);
+            String post = HttpUtil.post("http://" + printIp + ":8084" + printUrl + "?excelUrl=" + URLEncoder.encode(url, "UTF-8") + "&printConfig=" + JSONObject.toJSONString(printConfig), new HashMap<>());
+//            String post = HttpUtil.post("http://" + printIp + ":8084" + printUrl, map);
             log.info(post);
         } catch (Exception e) {
             String message = e.getMessage();

+ 8 - 4
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/util/OpcDaUtil.java

@@ -550,11 +550,12 @@ public class OpcDaUtil {
             treeBrowser.fillLeaves(branch);
         } catch (Exception ignored) {
         }
-        List<Map<String, String>> mapList = new ArrayList<>();
+        List<Map<String, String>> mapAllList = new ArrayList<>();
 
-        Iterator iter = branch.getBranches().iterator();
         JSONArray objects = JSONObject.parseArray(needItemStr);
         for (Object obj : objects) {
+            List<Map<String, String>> mapList = new ArrayList<>();
+            Iterator iter = branch.getBranches().iterator();
             String itemstr = obj.toString();
             while (iter.hasNext()) {
                 Branch subBranch = (Branch) iter.next();
@@ -581,9 +582,10 @@ public class OpcDaUtil {
                     Map<String, String> map = mapList.get(i);
                     map.put("itemReadName", prefix + "." + map.get("current") + "." + itemstr);
                 }
+                mapAllList.addAll(mapList);
             }
         }
-        return mapList;
+        return mapAllList;
     }
 
     /**
@@ -611,7 +613,9 @@ public class OpcDaUtil {
 //            map.put(leaf.getName(), leaf.getItemId());
             String itemName = leaf.getName();
             if (itemName.equals(needItemStr)) {
-                map.put("fullPath", genFullPath(leaf));
+                String label = genFullPath(leaf);
+                map.put("label", label);
+                map.put("value", label);
                 map.put("itemName", itemName);
                 map.put("itemReadName", leaf.getItemId());
                 break;