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