commit fe12744038295561226623546e78772db785fa41 Author: lidongy <1879087903@qq.com> Date: Thu Apr 1 14:33:15 2021 +0800 first commit diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..2b7985a --- /dev/null +++ b/build.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/finekit-10.0-20200630.jar b/lib/finekit-10.0-20200630.jar new file mode 100644 index 0000000..f4fbaf3 Binary files /dev/null and b/lib/finekit-10.0-20200630.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..0a72e46 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,20 @@ + + + com.fr.plugin.demo.data.transfer.process + + yes + no + 1.0.0 + 10.0 + 2021-02-01 + lidongy + + [2021-03-31]第一版

+ ]]>
+ + + + +
\ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..91b2629 --- /dev/null +++ b/readme.md @@ -0,0 +1,19 @@ +# 帆软资源迁移过程demo插件 +# 这个插件演示了在资源导出、导入时做拦截。 +# 使用举例: +## 1,资源导出 +![1](screenshots/export1.png) +![1](screenshots/export2.png) + +## 2,查看日志,里面有迁移的内容 + +![1](screenshots/log1.png) + +## 3,查看资源文件,有定义的额外导出内容extra.txt + +![1](screenshots/resource.png) + +## 4,导入时查看日志,可以识别到extra.txt的内容 + + +![1](screenshots/log2.png) diff --git a/screenshots/export1.png b/screenshots/export1.png new file mode 100644 index 0000000..131ceb1 Binary files /dev/null and b/screenshots/export1.png differ diff --git a/screenshots/export2.png b/screenshots/export2.png new file mode 100644 index 0000000..35babc7 Binary files /dev/null and b/screenshots/export2.png differ diff --git a/screenshots/log1.png b/screenshots/log1.png new file mode 100644 index 0000000..9926020 Binary files /dev/null and b/screenshots/log1.png differ diff --git a/screenshots/log2.png b/screenshots/log2.png new file mode 100644 index 0000000..67c2f3f Binary files /dev/null and b/screenshots/log2.png differ diff --git a/screenshots/resource.png b/screenshots/resource.png new file mode 100644 index 0000000..9837b30 Binary files /dev/null and b/screenshots/resource.png differ diff --git a/src/java/com/fr/plugin/demo/data/transfer/DemoTransferProcess.java b/src/java/com/fr/plugin/demo/data/transfer/DemoTransferProcess.java new file mode 100644 index 0000000..1e830c1 --- /dev/null +++ b/src/java/com/fr/plugin/demo/data/transfer/DemoTransferProcess.java @@ -0,0 +1,78 @@ +package com.fr.plugin.demo.data.transfer; + +import com.fanruan.api.log.LogKit; +import com.fanruan.api.runtime.ResourceKit; +import com.fanruan.api.util.GeneralKit; +import com.fr.decision.fun.impl.AbstractDataTransferProcessProvider; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.third.fasterxml.jackson.databind.ObjectMapper; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * @author lidongy + * @version 10.0 + * Created by lidongy on 2021/3/31 + */ +@EnableMetrics +public class DemoTransferProcess extends AbstractDataTransferProcessProvider { + private static final String EXPORT_TEMP_DIR = "export_temp_dir"; + private static final String IMPORT_TEMP_DIR = "import_temp_dir"; + + @Override + @Focus(id = "com.fr.plugin.demo.data.transfer.process", text = "", source = Original.PLUGIN) + public void afterBuildExportData(Map> allResource) { + printAllResource(allResource); + ResourceKit.write(GeneralKit.pathJoin(EXPORT_TEMP_DIR, "extra.txt"), "resource"); + } + + @Override + public void afterImport(Map> allResource) { + printAllResource(allResource); + ByteArrayOutputStream outputStream = null; + InputStream inputStream = null; + try { + inputStream = ResourceKit.read(GeneralKit.pathJoin(IMPORT_TEMP_DIR, EXPORT_TEMP_DIR, "extra.txt")); + outputStream = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len = -1; + while ((len = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, len); + } + } catch (IOException e) { + LogKit.error(e, e.getMessage()); + } finally { + try { + if (outputStream != null) { + outputStream.close(); + } + if (inputStream != null) { + inputStream.close(); + } + } catch (Exception e) { + LogKit.error(e, e.getMessage()); + } + } + LogKit.info("读到了资源为" + outputStream.toString()); + } + + private void printAllResource(Map> allResource) { + try { + Iterator>> it = allResource.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry> entry = it.next(); + LogKit.info("导出数据类型:" + entry.getKey()); + LogKit.info("id集合:" + new ObjectMapper().writeValueAsString(entry.getValue())); + } + } catch (Exception e) { + LogKit.error(e, e.getMessage()); + } + } +}