1
0
DESKTOP-2K9OVK9\siwei 4 недель назад
Родитель
Сommit
3bda62da2e

+ 36 - 13
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/ProjectImpl.java

@@ -42,11 +42,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Serializable;
+import java.io.*;
 import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.nio.charset.Charset;
@@ -1960,18 +1956,45 @@ public class ProjectImpl implements ProjectService {
         return currentProjectWorkflow;
     }
 
+
+
+
+//    @Override
+//    public JSONArray getResourceData() throws IOException {
+//        java.net.URL fileURL = this.getClass().getResource("/one_code_index_v1.json");
+//        // String fileName = "classpath:reportConfig.txt";
+//        String fileName = fileURL.getPath();
+//        String configStr = FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8);
+//        JSONArray aa = JSON.parseArray(configStr);
+//        enrichCycleResourceData(aa);
+//        log.info("------------" + aa.toJSONString());
+//        return aa;
+//    }
+
+
     @Override
     public JSONArray getResourceData() throws IOException {
-        java.net.URL fileURL = this.getClass().getResource("/one_code_index_v1.json");
-        // String fileName = "classpath:reportConfig.txt";
-        String fileName = fileURL.getPath();
-        String configStr = FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8);
-        JSONArray aa = JSON.parseArray(configStr);
-        enrichCycleResourceData(aa);
-        log.info("------------" + aa.toJSONString());
-        return aa;
+        // 获取资源输入流,兼容开发环境 + jar包环境
+        try (BufferedReader reader = new BufferedReader(
+                new InputStreamReader(
+                        this.getClass().getResourceAsStream("/one_code_index_v1.json"),
+                        StandardCharsets.UTF_8
+                )
+        )) {
+            StringBuilder sb = new StringBuilder();
+            String line;
+            while ((line = reader.readLine()) != null) {
+                sb.append(line);
+            }
+            String configStr = sb.toString();
+            JSONArray aa = JSON.parseArray(configStr);
+            enrichCycleResourceData(aa);
+            log.info("------------" + aa.toJSONString());
+            return aa;
+        }
     }
 
+
     private void enrichCycleResourceData(JSONArray nodes) {
         if (nodes == null) {
             return;

+ 2 - 2
siwei-modules/siwei-job/src/main/resources/bootstrap.yml

@@ -15,14 +15,14 @@ spring:
       discovery:
         # 服务注册地址
         enabled: true
-        namespace: public
+        namespace: one_code
         server-addr: 127.0.0.1:8848
         username: nacos
         password: nacos
       config:
         # 配置中心地址
         enabled: true
-        namespace: public
+        namespace: one_code
         server-addr: 127.0.0.1:8848
         username: nacos
         password: nacos