ChenYL 2 лет назад
Родитель
Сommit
51eb2f8eed
2 измененных файлов с 82 добавлено и 54 удалено
  1. 22 0
      pom.xml
  2. 60 54
      src/main/java/top/zhixinghe1/money/AggApplication.java

+ 22 - 0
pom.xml

@@ -59,4 +59,26 @@
             </snapshots>
         </pluginRepository>
     </pluginRepositories>
+
+    <build>
+        <plugins>
+            <!-- 4、指定启动类,指定配置文件,将依赖打成外部jar包 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <!-- 是否要把第三方jar加入到类构建路径 -->
+                            <addClasspath>true</addClasspath>
+                            <!-- 外部依赖jar包的最终位置 -->
+                            <classpathPrefix>lib/</classpathPrefix>
+                            <!-- 项目启动类 -->
+                            <mainClass>top.zhixinghe1.money.AggApplication</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>

+ 60 - 54
src/main/java/top/zhixinghe1/money/AggApplication.java

@@ -23,60 +23,66 @@ import java.util.stream.Collectors;
  */
 public class AggApplication {
 
-    public static void main(String[] args) {
-//        String dataDirPath = "D:\\Documents\\ChenYL\\CodeRepository\\money-mining-python\\data";
-        String dataDirPath = "D:\\Documents\\ChenYL\\CodeRepository\\money-mining-python\\data\\test";
+//    public static void main(String[] args) {
+////        String dataDirPath = "D:\\Documents\\ChenYL\\CodeRepository\\money-mining-python\\data";
+//        String dataDirPath = "D:\\Documents\\ChenYL\\CodeRepository\\money-mining-python\\data\\test";
+//
+//        // 判断传入路径是否有效
+//        File dataDir = new File(dataDirPath);
+//        if (!dataDir.exists() || !dataDir.isDirectory()) {
+//            System.out.println(String.format("数据目录路径不存在,%s", dataDirPath));
+//            return;
+//        }
+//
+//        // 判断关键资源文件是否存在
+//        List<String> fileNameList = Arrays.asList("长尾词_合并_分词.txt", "长尾词_合并_聚合.txt", "长尾词_合并.txt", "长尾词_合并_倒排索引.txt");
+//        for (String fileName : fileNameList) {
+//            String resFilePath = String.join(File.separator, dataDirPath, fileName);
+//            File resfile = new File(resFilePath);
+//            if (!resfile.exists() || !resfile.isFile()) {
+//                System.out.println(String.format("文件不存在!文件路径:%s", resFilePath));
+//                return;
+//            }
+//        }
+//
+//        // 归档历史数据文件
+//        File[] files = dataDir.listFiles();
+//        Pattern aggFilePattern = Pattern.compile("长尾词_合并_聚合_\\d+_\\d+.txt");
+//        List<File> historyAggFile = Arrays.stream(files).filter(file -> {
+//            Matcher matcher = aggFilePattern.matcher(file.getName());
+//            return matcher.find();
+//        }).collect(Collectors.toList());
+//        if (Objects.nonNull(historyAggFile) || historyAggFile.size() > 0) {
+//            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+//            String archivePath = String.join(File.separator, dataDirPath, String.format("长尾词_聚合_归档_%s", sdf.format(new Date())));
+//            File archiveDir = new File(archivePath);
+//            archiveDir.mkdirs();
+//            for (File historyFile : historyAggFile) {
+//                String destPath = String.join(File.separator, archivePath, historyFile.getName());
+//                System.out.println(destPath);
+//                historyFile.renameTo(new File(destPath));
+//            }
+//        }
+//
+//        JedisPool pool = new JedisPool("127.0.0.1", 6379);
+//        try (Jedis jedis = pool.getResource()) {
+//            try (FileReader reader = new FileReader(String.join(File.separator, dataDirPath, "长尾词_合并_分词.txt"));
+//                 BufferedReader br = new BufferedReader(reader)) {
+//                String line = null;
+//                while ((line = br.readLine()) != null) {
+//                    System.out.println(line);
+//                    System.out.println("暂停");
+//                }
+//
+//            } catch (IOException e) {
+//                throw new RuntimeException(e);
+//            }
+//        }
+//    }
 
-        // 判断传入路径是否有效
-        File dataDir = new File(dataDirPath);
-        if (!dataDir.exists() || !dataDir.isDirectory()) {
-            System.out.println(String.format("数据目录路径不存在,%s", dataDirPath));
-            return;
-        }
-
-        // 判断关键资源文件是否存在
-        List<String> fileNameList = Arrays.asList("长尾词_合并_分词.txt", "长尾词_合并_聚合.txt", "长尾词_合并.txt", "长尾词_合并_倒排索引.txt");
-        for (String fileName : fileNameList) {
-            String resFilePath = String.join(File.separator, dataDirPath, fileName);
-            File resfile = new File(resFilePath);
-            if (!resfile.exists() || !resfile.isFile()) {
-                System.out.println(String.format("文件不存在!文件路径:%s", resFilePath));
-                return;
-            }
-        }
-
-        // 归档历史数据文件
-        File[] files = dataDir.listFiles();
-        Pattern aggFilePattern = Pattern.compile("长尾词_合并_聚合_\\d+_\\d+.txt");
-        List<File> historyAggFile = Arrays.stream(files).filter(file -> {
-            Matcher matcher = aggFilePattern.matcher(file.getName());
-            return matcher.find();
-        }).collect(Collectors.toList());
-        if (Objects.nonNull(historyAggFile) || historyAggFile.size() > 0) {
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-            String archivePath = String.join(File.separator, dataDirPath, String.format("长尾词_聚合_归档_%s", sdf.format(new Date())));
-            File archiveDir = new File(archivePath);
-            archiveDir.mkdirs();
-            for (File historyFile : historyAggFile) {
-                String destPath = String.join(File.separator, archivePath, historyFile.getName());
-                System.out.println(destPath);
-                historyFile.renameTo(new File(destPath));
-            }
-        }
-
-        JedisPool pool = new JedisPool("127.0.0.1", 6379);
-        try (Jedis jedis = pool.getResource()) {
-            try (FileReader reader = new FileReader(String.join(File.separator, dataDirPath, "长尾词_合并_分词.txt"));
-                 BufferedReader br = new BufferedReader(reader)) {
-                String line = null;
-                while ((line = br.readLine()) != null) {
-                    System.out.println(line);
-                    System.out.println("暂停");
-                }
-
-            } catch (IOException e) {
-                throw new RuntimeException(e);
-            }
-        }
+    public static void main(String[] args) throws InterruptedException {
+        System.out.println("hello python start");
+        Thread.sleep(5000);
+        System.out.println("hello python end");
     }
 }