Browse Source

插件源码

master
xiamaofa 8 months ago
parent
commit
50d74d230a
  1. 3
      README.md
  2. 122
      build.gradle
  3. 13
      encrypt.xml
  4. 26
      plugin.xml
  5. 42
      src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTable.java
  6. 43
      src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTableSheet.java
  7. 94
      src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPane.java
  8. 90
      src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPaneSheet.java
  9. 37
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetComponent.java
  10. 18
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetProvider.java
  11. 26
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/DBConfig.java
  12. 28
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuDatasetDatasourceGenerator.java
  13. 91
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuRowIterator.java
  14. 37
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetGenerator.java
  15. 49
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetPageGenerator.java
  16. 37
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetComponent.java
  17. 18
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetProvider.java
  18. 26
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/DBConfig.java
  19. 34
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuDatasetDatasourceGenerator.java
  20. 100
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuRowIterator.java
  21. 37
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetGenerator.java
  22. 49
      src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetPageGenerator.java
  23. 9
      src/main/java/com/eco/plugin/shsytzfsds/constants/Result.java
  24. 20
      src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerRegisterProvider.java
  25. 255
      src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerSelf.java
  26. 73
      src/main/java/com/eco/plugin/shsytzfsds/db/bean/DBEntity.java
  27. 153
      src/main/java/com/eco/plugin/shsytzfsds/db/controller/DBController.java
  28. 66
      src/main/java/com/eco/plugin/shsytzfsds/db/dao/DBDao.java
  29. 144
      src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModel.java
  30. 169
      src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModelSheet.java
  31. 58
      src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableData.java
  32. 63
      src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBean.java
  33. 63
      src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBeanSheet.java
  34. 58
      src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataSheet.java
  35. 69
      src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableData.java
  36. 67
      src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableDataSheet.java
  37. 89
      src/main/java/com/eco/plugin/shsytzfsds/utils/DataSetUtils.java
  38. 378
      src/main/java/com/eco/plugin/shsytzfsds/utils/FRUtils.java
  39. 290
      src/main/java/com/eco/plugin/shsytzfsds/utils/FeiShuUtils.java
  40. 260
      src/main/java/com/eco/plugin/shsytzfsds/utils/HttpUtils.java
  41. 108
      src/main/java/com/eco/plugin/shsytzfsds/utils/ResponseUtils.java
  42. 385
      src/main/java/com/eco/plugin/shsytzfsds/utils/Utils.java
  43. 35
      src/main/java/com/eco/plugin/shsytzfsds/webresourceProvider/WebResourceProvider.java
  44. 16
      src/main/resources/com/eco/plugin/shsytzfsds/css/wink.css
  45. 290
      src/main/resources/com/eco/plugin/shsytzfsds/html/dwb.html
  46. 356
      src/main/resources/com/eco/plugin/shsytzfsds/html/sheet.html
  47. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/bi/feishu.png
  48. 5
      src/main/resources/com/eco/plugin/shsytzfsds/js/bi/publicds.css
  49. 34
      src/main/resources/com/eco/plugin/shsytzfsds/js/bi/publicds.js
  50. 4
      src/main/resources/com/eco/plugin/shsytzfsds/js/jquery/jquery-2.1.3.min.js
  51. 1484
      src/main/resources/com/eco/plugin/shsytzfsds/js/jquery/jquery.tool.js
  52. 1
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/layui.css
  53. 1
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/code.css
  54. 1
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/laydate/default/laydate.css
  55. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/icon-ext.png
  56. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/icon.png
  57. 1
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/layer.css
  58. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-0.gif
  59. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-1.gif
  60. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-2.gif
  61. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.eot
  62. 554
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.svg
  63. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.ttf
  64. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.woff
  65. BIN
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.woff2
  66. 10543
      src/main/resources/com/eco/plugin/shsytzfsds/js/layui/layui.js
  67. 1789
      src/main/resources/com/eco/plugin/shsytzfsds/js/ui.js
  68. 382
      src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTable.js
  69. 493
      src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTableSheet.js

3
README.md

@ -1,2 +1,3 @@
# shopself-fsds
# JSD-13470
JSD-13470

122
build.gradle

@ -0,0 +1,122 @@
apply plugin: 'java'
ext {
/**
* jar的路径
* 1.jar需要打包到zip中,lib根目录下
* 2.jar仅仅是编译时需要lib下子目录下即可
*/
libPath = "$projectDir/../webroot/WEB-INF/lib"
/**
* class进行加密保护
*/
guard = true
def pluginInfo = getPluginInfo()
pluginPre = "fine-plugin"
pluginName = pluginInfo.id
pluginVersion = pluginInfo.version
outputPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes"
}
group = 'com.fr.plugin'
version = '10.0'
sourceCompatibility = '8'
sourceSets {
main {
java.outputDir = file(outputPath)
output.resourcesDir = file(outputPath)
}
}
ant.importBuild("encrypt.xml")
//ant变量
ant.projectDir = projectDir
ant.references["compile.classpath"] = ant.path {
fileset(dir: libPath, includes: '**/*.jar')
fileset(dir: ".",includes:"**/*.jar" )
}
classes.dependsOn('clean')
task copyFiles(type: Copy,dependsOn: 'classes'){
from outputPath
into "$projectDir/classes"
}
task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){
from "$projectDir/classes"
into "$projectDir/transform-classes"
include "**/*.*"
}
jar.dependsOn("preJar")
task makeJar(type: Jar,dependsOn: preJar){
from fileTree(dir: "$projectDir/transform-classes")
baseName pluginPre
appendix pluginName
version pluginVersion
destinationDir = file("$buildDir/libs")
doLast(){
delete file("$projectDir/classes")
delete file("$projectDir/transform-classes")
}
}
task copyFile(type: Copy,dependsOn: ["makeJar"]){
from "$buildDir/libs"
from("$projectDir/lib") {
include "*.jar"
}
from "$projectDir/plugin.xml"
into file("$buildDir/temp/plugin")
}
task zip(type:Zip,dependsOn:["copyFile"]){
from "$buildDir/temp/plugin"
destinationDir file("$buildDir/install")
baseName pluginPre
appendix pluginName
version pluginVersion
}
//build时包含哪些文件,
processResources {
// exclude everything
// *.css没效果
// exclude '**/*.css'
// except this file
// include 'xx.xml'
}
/*读取plugin.xml中的version*/
def getPluginInfo(){
def xmlFile = file("plugin.xml")
if (!xmlFile.exists()) {
return ["id":"none", "version":"1.0.0"]
}
def plugin = new XmlParser().parse(xmlFile)
def version = plugin.version[0].text()
def id = plugin.id[0].text()
return ["id":id,"version":version]
}
repositories {
mavenLocal()
maven {
url = uri('http://mvn.finedevelop.com/repository/maven-public/')
}
}
dependencies {
//使jar
implementation fileTree(dir: 'lib', include: ['**/*.jar'])
implementation fileTree(dir: libPath, include: ['**/*.jar'])
}

13
encrypt.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<target name="compile_encrypt_javas" depends="copyFiles">
<echo message="加密文件"/>
<echo message="${projectDir}"/>
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask">
<classpath refid="compile.classpath"/>
</taskdef>
<pretreatment baseDir="${projectDir}"/>
</target>
<target name="compile_plain_javas" depends="copyFiles">
</target>
</project>

26
plugin.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.eco.plugin.shsytzfsds</id>
<name><![CDATA[飞书表格数据集(bi)]]></name>
<active>yes</active>
<version>1.0.6</version>
<env-version>10.0</env-version>
<jartime>2018-07-31</jartime>
<vendor>wink</vendor>
<description><![CDATA[飞书表格数据集(bi)]]></description>
<change-notes><![CDATA[
]]></change-notes>
<main-package>com.eco.plugin.shsytzfsds</main-package>
<extra-decision>
<WebResourceProvider class="com.eco.plugin.shsytzfsds.webresourceProvider.WebResourceProvider"/>
<ControllerRegisterProvider class="com.eco.plugin.shsytzfsds.controller.ControllerRegisterProvider"/>
</extra-decision>
<extra-core>
<CustomDatasetProvider class="com.eco.plugin.shsytzfsds.biPlublicServerTable.DatasetProvider"/>
<CustomDatasetProvider class="com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.DatasetProvider"/>
<DBAccessProvider class="com.eco.plugin.shsytzfsds.db.controller.DBController"/>
</extra-core>
<function-recorder class="com.eco.plugin.shsytzfsds.controller.ControllerSelf"/>
</plugin>

42
src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTable.java

@ -0,0 +1,42 @@
//package com.eco.plugin.shsytzfsds.ServerTable;
//
//import com.fr.base.TableData;
//import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
//import com.fr.design.fun.impl.AbstractServerTableDataDefineProvider;
//
///**
// * @author 秃破天际
// * @version 10.0
// * Created by 秃破天际 on 2021-03-29
// **/
//public class ServerTable extends AbstractServerTableDataDefineProvider {
// @Override
// public Class<? extends TableData> classForTableData() {
// return com.eco.plugin.shsytzfsds.univalsalServerTable.TableData.class;
// }
//
// @Override
// public Class<? extends TableData> classForInitTableData() {
// return com.eco.plugin.shsytzfsds.univalsalServerTable.TableData.class;
// }
//
// @Override
// public Class<? extends AbstractTableDataPane> appearanceForTableData() {
// return TableDataPane.class;
// }
//
// @Override
// public String nameForTableData() {
// return "飞书多维表格";
// }
//
// @Override
// public String prefixForTableData() {
// return "飞书多维表格";
// }
//
// @Override
// public String iconPathForTableData() {
// return "com/eco/plugin/shsytzfsds/js/bi/feishu.png";
// }
//}

43
src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTableSheet.java

@ -0,0 +1,43 @@
//package com.eco.plugin.shsytzfsds.ServerTable;
//
//import com.eco.plugin.shsytzfsds.univalsalServerTable.TableDataSheet;
//import com.fr.base.TableData;
//import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
//import com.fr.design.fun.impl.AbstractServerTableDataDefineProvider;
//
///**
// * @author 秃破天际
// * @version 10.0
// * Created by 秃破天际 on 2021-03-29
// **/
//public class ServerTableSheet extends AbstractServerTableDataDefineProvider {
// @Override
// public Class<? extends TableData> classForTableData() {
// return TableDataSheet.class;
// }
//
// @Override
// public Class<? extends TableData> classForInitTableData() {
// return TableDataSheet.class;
// }
//
// @Override
// public Class<? extends AbstractTableDataPane> appearanceForTableData() {
// return TableDataPaneSheet.class;
// }
//
// @Override
// public String nameForTableData() {
// return "飞书电子表格";
// }
//
// @Override
// public String prefixForTableData() {
// return "飞书电子表格";
// }
//
// @Override
// public String iconPathForTableData() {
// return "com/eco/plugin/shsytzfsds/js/bi/feishu.png";
// }
//}

94
src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPane.java

@ -0,0 +1,94 @@
//package com.eco.plugin.shsytzfsds.ServerTable;
//
//import com.eco.plugin.shsytzfsds.univalsalServerTable.TableData;
//import com.fr.base.BaseUtils;
//import com.fr.base.Parameter;
//import com.fr.design.data.datapane.preview.PreviewTablePane;
//import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
//import com.fr.design.gui.ibutton.UIButton;
//import com.fr.design.gui.icontainer.UIScrollPane;
//import com.fr.design.gui.ilable.UILabel;
//import com.fr.design.gui.itableeditorpane.ParameterTableModel;
//import com.fr.design.gui.itableeditorpane.UITableEditorPane;
//import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
//import com.fr.design.gui.itextarea.UITextArea;
//import com.fr.design.layout.TableLayout;
//import com.fr.design.layout.TableLayoutHelper;
//import com.fr.script.Calculator;
//import com.fr.stable.ParameterProvider;
//
//import javax.swing.*;
//import java.awt.*;
//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
//
///**
// * @author 秃破天际
// * @version 10.0
// * Created by 秃破天际 on 2021-03-29
// **/
//public class TableDataPane extends AbstractTableDataPane<TableData> {
//
// private UITextArea config;
// private UITableEditorPane<ParameterProvider> parameterTableEditorPane;
//
// public TableDataPane(){
// config = new UITextArea();
// setLayout(new BorderLayout());
//
// UIButton preview = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
// preview.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// SwingUtilities.invokeLater(new Runnable() {
// @Override
// public void run() {
// PreviewTablePane.previewTableData(TableDataPane.this.updateBean());
// }
// });
// }
// });
//
// add(TableLayoutHelper.createTableLayoutPane(
// new Component[][] {{
// new UILabel("配置"),preview
// }},
// new double[] { TableLayout.PREFERRED },
// new double[] { TableLayout.FILL,TableLayout.PREFERRED }
// ),BorderLayout.NORTH);
//
// UIScrollPane loadArea = new UIScrollPane(config);
// add(loadArea, BorderLayout.CENTER);
//
// UITableModelAdapter<ParameterProvider> model = new ParameterTableModel();
// parameterTableEditorPane = new UITableEditorPane<ParameterProvider>(model);
//
// add(parameterTableEditorPane,BorderLayout.SOUTH);
// }
//
// @Override
// public void populateBean(TableData data) {
// if (data == null) {
// return;
// }
// Calculator c = Calculator.createCalculator();
// ParameterProvider[] parameters = data.getParameters(c);
// parameterTableEditorPane.populate(parameters);
// config.setText( data.getConfig() );
// }
//
// @Override
// public TableData updateBean() {
// TableData data = new TableData();
// data.setConfig( config.getText() );
// java.util.List<ParameterProvider> parameterProviderList = parameterTableEditorPane.update();
// Parameter[] parameters = parameterProviderList.toArray(new Parameter[parameterProviderList.size()]);
// data.setParameters(parameters);
// return data;
// }
//
// @Override
// protected String title4PopupWindow() {
// return "飞书多维表格";
// }
//}

90
src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPaneSheet.java

@ -0,0 +1,90 @@
//package com.eco.plugin.shsytzfsds.ServerTable;
//
//import com.eco.plugin.shsytzfsds.univalsalServerTable.TableDataSheet;
//import com.fr.base.BaseUtils;
//import com.fr.base.Parameter;
//import com.fr.design.data.datapane.preview.PreviewTablePane;
//import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
//import com.fr.design.gui.ibutton.UIButton;
//import com.fr.design.gui.icontainer.UIScrollPane;
//import com.fr.design.gui.ilable.UILabel;
//import com.fr.design.gui.itableeditorpane.ParameterTableModel;
//import com.fr.design.gui.itableeditorpane.UITableEditorPane;
//import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
//import com.fr.design.gui.itextarea.UITextArea;
//import com.fr.design.layout.TableLayout;
//import com.fr.design.layout.TableLayoutHelper;
//import com.fr.script.Calculator;
//import com.fr.stable.ParameterProvider;
//
//import javax.swing.*;
//import java.awt.*;
//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
//
//
//public class TableDataPaneSheet extends AbstractTableDataPane<TableDataSheet> {
//
// private UITextArea config;
// private UITableEditorPane<ParameterProvider> parameterTableEditorPane;
//
// public TableDataPaneSheet(){
// config = new UITextArea();
// setLayout(new BorderLayout());
//
// UIButton preview = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
// preview.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// SwingUtilities.invokeLater(new Runnable() {
// @Override
// public void run() {
// PreviewTablePane.previewTableData(TableDataPaneSheet.this.updateBean());
// }
// });
// }
// });
//
// add(TableLayoutHelper.createTableLayoutPane(
// new Component[][] {{
// new UILabel("配置"),preview
// }},
// new double[] { TableLayout.PREFERRED },
// new double[] { TableLayout.FILL,TableLayout.PREFERRED }
// ),BorderLayout.NORTH);
//
// UIScrollPane loadArea = new UIScrollPane(config);
// add(loadArea, BorderLayout.CENTER);
//
// UITableModelAdapter<ParameterProvider> model = new ParameterTableModel();
// parameterTableEditorPane = new UITableEditorPane<ParameterProvider>(model);
//
// add(parameterTableEditorPane,BorderLayout.SOUTH);
// }
//
// @Override
// public void populateBean(TableDataSheet data) {
// if (data == null) {
// return;
// }
// Calculator c = Calculator.createCalculator();
// ParameterProvider[] parameters = data.getParameters(c);
// parameterTableEditorPane.populate(parameters);
// config.setText( data.getConfig() );
// }
//
// @Override
// public TableDataSheet updateBean() {
// TableDataSheet data = new TableDataSheet();
// data.setConfig( config.getText() );
// java.util.List<ParameterProvider> parameterProviderList = parameterTableEditorPane.update();
// Parameter[] parameters = parameterProviderList.toArray(new Parameter[parameterProviderList.size()]);
// data.setParameters(parameters);
// return data;
// }
//
// @Override
// protected String title4PopupWindow() {
// return "飞书电子表格";
// }
//}

37
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetComponent.java

@ -0,0 +1,37 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.Atom;
import com.fr.web.struct.Registry;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
/**
* @author Heng.J
* @version 6.0
* Created by Heng.J on 2023/5/30
*/
public class DatasetComponent extends AssembleComponent {
public static final DatasetComponent KEY = new DatasetComponent();
@Override
public Atom[] refer() {
return new Atom[]{};
}
@Override
public ScriptPath script() {
return ScriptPath.build("com/eco/plugin/shsytzfsds/js/bi/publicds.js");
}
@Override
public StylePath style() {
return StylePath.build("com/eco/plugin/shsytzfsds/js/bi/publicds.css");
}
@Override
public Atom[] children() {
return Registry.getChildren(DatasetComponent.class);
}
}

18
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetProvider.java

@ -0,0 +1,18 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable;
import com.eco.plugin.shsytzfsds.biPlublicServerTable.generator.DatasetGenerator;
import com.finebi.provider.api.dataset.datasource.AbstractCustomDatasetProvider;
import com.finebi.provider.api.dataset.datasource.CustomDatasetGenerator;
/**
* @author wink
* @version 6.0
* Created by wink on 2023/5/30
*/
public class DatasetProvider extends AbstractCustomDatasetProvider {
@Override
public CustomDatasetGenerator getGenerator() {
return new DatasetGenerator();
}
}

26
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/DBConfig.java

@ -0,0 +1,26 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.data.feishu;
import java.util.HashMap;
import java.util.Map;
/**
* 用户自定义数据链接
*
* @author Heng.J
* @version 6.0
* Created by Heng.J on 2023/6/14
*/
public class DBConfig {
public static final String URL = "jdbc:mysql://localhost:3306/swift_data1?serverTimezone=Asia/Shanghai&useSSL=false";
public static final String USER = "root";
public static final String PASSWORD = "123456";
public static final Map<String, Class<?>> PARAMETER_MAP = new HashMap<>();
static {
PARAMETER_MAP.put("driver", String.class);
PARAMETER_MAP.put("appId", String.class);
}
}

28
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuDatasetDatasourceGenerator.java

@ -0,0 +1,28 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.data.feishu;
import com.eco.plugin.shsytzfsds.utils.DataSetUtils;
import com.finebi.cbb.api.model.RowIterator;
import com.finebi.provider.api.dataset.datasource.AbstractDefaultDatasourceGenerator;
import com.finebi.provider.api.dataset.datasource.CustomDatasetContext;
import com.fr.data.core.db.ColumnInformation;
import java.util.Collections;
import java.util.Map;
public class FeishuDatasetDatasourceGenerator extends AbstractDefaultDatasourceGenerator {
@Override
public RowIterator getRowIterator(String jsonContext, CustomDatasetContext datasetContext, ColumnInformation[] columnInfos) {
return new FeishuRowIterator(jsonContext, Collections.singletonList(datasetContext), null);
}
@Override
public Map<String, Class<?>> getParameters(String jsonContext, CustomDatasetContext datasetContext) {
return DBConfig.PARAMETER_MAP;
}
@Override
public ColumnInformation[] createColumnInfos(String jsonContext, CustomDatasetContext datasetContext) {
return DataSetUtils.getHeader(jsonContext);
}
}

91
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuRowIterator.java

@ -0,0 +1,91 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.data.feishu;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.eco.plugin.shsytzfsds.db.controller.DBController;
import com.eco.plugin.shsytzfsds.utils.FeiShuUtils;
import com.eco.plugin.shsytzfsds.utils.Utils;
import com.finebi.base.concurrent.ExecutorServiceFactory;
import com.finebi.cbb.api.model.RowIterator;
import com.finebi.provider.api.dataset.datasource.CustomDatasetContext;
import com.fr.data.core.db.ColumnInformation;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class FeishuRowIterator implements RowIterator {
private static int count = 0;
private String jsonContexts = "";
private static List<Object[]> result = new ArrayList<>();
public FeishuRowIterator(String jsonContexts, List<CustomDatasetContext> datasetContexts, String sql) {
count =0;
result = new ArrayList<>();
this.jsonContexts = jsonContexts;
JSONObject param = new JSONObject(jsonContexts);
String id = param.getString("appid");
DBEntity feishuApp = DBController.getById(id);
String appid = feishuApp.getAppid();
String secret = feishuApp.getSecret();
String url = param.getString("url");
String token = FeiShuUtils.getTenantToken(appid,secret);
JSONArray header =FeiShuUtils.getTableFields(url,token);
JSONArray dataArray = FeiShuUtils.getTableData(url,token,"");
addRowDatas(header,dataArray);
}
private void init() {
}
@Override
public void open() {
}
@Override
public boolean hasNext() {
return count < result.size();
}
@Override
public Object[] next() {
int current = count;
count++;
return result.get(current);
}
@Override
public void close() {
}
@Override
public void cancel() {
}
/**
* 添加行数据
* @param jsonArray
*/
private void addRowDatas(JSONArray header,JSONArray jsonArray) {
if(jsonArray == null || jsonArray.size() <= 0){
return ;
}
for(int i =0;i< jsonArray.size();i++){
JSONObject fields = jsonArray.getJSONObject(i).getJSONObject("fields");
Object[] rowDatas = new Object[header.length()];
for (int j = 0; j < header.length(); j++) {
String value = fields.getString(header.getString(j));
rowDatas[j] = Utils.isNullStr(value) ? "" :value;
}
result.add(rowDatas);
}
}
}

37
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetGenerator.java

@ -0,0 +1,37 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.generator;
import com.eco.plugin.shsytzfsds.biPlublicServerTable.data.feishu.FeishuDatasetDatasourceGenerator;
import com.finebi.provider.api.dataset.datasource.AbstractCustomDatasetGenerator;
import com.finebi.provider.api.dataset.datasource.CustomDatasetDatasourceGenerator;
import org.jetbrains.annotations.NotNull;
/**
* @author wink
* @version 6.0
* Created by wink on 2023/5/30
*/
public class DatasetGenerator extends AbstractCustomDatasetGenerator {
@Override
public @NotNull String getName() {
return "飞书多维表格";
}
/**
* 前端页面相关接口
* @return
*/
@Override
public @NotNull DatasetPageGenerator getPageGenerator() {
return new DatasetPageGenerator();
}
/**
* 后端数据相关接口
* @return
*/
@Override
public @NotNull CustomDatasetDatasourceGenerator getDatasourceGenerator() {
return new FeishuDatasetDatasourceGenerator();
}
}

49
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetPageGenerator.java

@ -0,0 +1,49 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.generator;
import com.eco.plugin.shsytzfsds.biPlublicServerTable.DatasetComponent;
import com.finebi.provider.api.dataset.datasource.CustomDatasetContext;
import com.finebi.provider.api.dataset.datasource.CustomDatasetPageGenerator;
import com.fr.web.struct.AssembleComponent;
/**
* @author wink
* @version 6.0
* Created by wink on 2023/5/30
* 前端接口
*/
public class DatasetPageGenerator implements CustomDatasetPageGenerator {
/**
* 图标
* @param datasetContext
* @return
*/
@Override
public String getIcon(CustomDatasetContext datasetContext) {
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAAkCAYAAAAU/hMoAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAVQSURBVFhH7Zd/SF5VGMdlRARRM9dqrCCk/rEw0tH+SDebGw2KUVKSBBGNEfujNUvWP1mNigrbP80/yh+zltooJraUqe8gcOU2bTRW8/XHdGqjLZ02UzdnnnO/Pc8599z33rv7vt53GDHYA1/ur/M+z+c8z3nOvW8KrgO7AblYdv1DSliwLAv7p87j8aFOrBvuwtrhzqSUN9KFsvEhCIu8kS8tobyHtQUyKRWosOYp0CBuirYhJRohtdjHEOppJUVQPjGiACWEnrwdIYwlhGRHsdlbiEyPIbX3BwpOkBw8CMotgkvppomRbulpQ++VaQWZrIVYk1wWLpVQ+nV2Evf2EygHDwLzyExGg24Y/llnkSetnYeypBuHnQ/NXcb9p9s1RChYoxa0TI86oGEtaUgTYHjuEtJP/6gCK4AwsDQmf6iLfHBV/kNIXXoN2j83hRV9XPqQjUSlX2KvTbcZf/HMA7nQYNOZep3q8V2XL+LWXgJIouzvXRiAlLHJ+uU3D+SlKxINR/RADcMguhuD0PkeP//m73MaUoG61il3tweQnp1qReZ3EZTsOownXmlEZkE9MjbtxaqifSh8oxmffHkCfSN/OfHZPJAXpgRWFVuob2dQvW54aKJtg53x2JI/o7Etx6xTs03xke7fXN2A1KerkZpTgWW5n+PO3CrckVupjqxlOZXq/sr1VegbmrAj+CDHpyxkb5cKtOaQ3shN+jm3ftPPdNlm5TxWn+lwZdEG7D6IlK5m3LZ1rwJQUGsqHCgDyPf4Gau2OaombswDOUHrWUPqY1mjxLywQfQQj2lwfsagAj2zU2rTjgG2YUlHE5YW7nFg0tbEMsZgBjSNztNyPkPRjhb1hmO/xryQM5YCNMoqlthWITA5o39gUE12/cb3Pxwb1Nk0gM/WOHAG1C0nmwS5fG0lugfGVRx3hISQrOztFjZ9MI/oCJVfdSStVTU6oPykOSnw4MBPSOloxtKCPQqCs+SH8yvtsQq8/E7EToBJhzYP5MVpLyQDmvPVJcAXEYl/5m1Q15qJGa9jgdrBEdz+TDWtL90cDGrO3QqTRbaEkFkEmf06SV1bqvwv7qL39+9257vKbq5/iY7ioYI6BaDhYiBuQJYzCTpufveQ7U9XyN2oCSH9UtCkR0sE3t8nMTZpYAWEEKhqOIl78qnEFDTeGvSLx92VV6GyGM+SgjQZ5XMGzn1T4NMmiSMnJ/DUqweczJkODoJyizPJ44rLOuwsBpsHcnKGQKi8friY+BmVXa1VnVVeAo9sm8MDL5zC3Ru+dfZCU+4gOJZ5nll0UL1EFhHSSK9TBnQ3F++tGVvO4b6Cw1ieR5t3HEieCD9LL+xA+2/zqlkS2dWQJqB9TFaq0UhZrwlkbP4D6c8dxYqNjVi+7itSHVZubKB7nXh46wQqW3WzJUb0QfI+qbLDwXzBkxFnV0u/Ys218s2ToPOP9tNmxX/OnG6Ob75MSgcyKPi1SPuy1zL55iM3G+8GvKeabSc0pKBJPblTzzQo4LWIIc3WlbND4sAx94tAf8QsZB5I/sHgeQsv7dYZZedGOqg+V+Wzr71Z91/re6wt5RJnRjVUok+/IPNAmm2AXtFoPW6h8GMNq4JfBRYv27H7vCafL5OInKDNnr5skoUz5oVkcbepdzPNmGiP9gq8XS+R/5ZQQd2A7u1KTYK7mia1vlRi59cWjvfbzaF86gSw7zAldpsH0phx4cDSHf6w6D7Lfy8Edn8vUVproaRGkgRK6wTKmwQaj1noPWupb1DzWyXyYPypRWUDh7VAyHjmBLUVdM+txbKkIP8vuwG5OAb8C5svkz2EkBopAAAAAElFTkSuQmCC";
}
/**
* 配置页面根节点dom元素
* @param datasetContext
* @return
*/
@Override
public String getEditPageHTML(CustomDatasetContext datasetContext) {
return "<iframe id='publicds' src=\"/webroot/decision/file?path=com/eco/plugin/shsytzfsds/html/dwb.html\" style=\"width:100%;height: 100%;border:none;position: fixed;\n" +
" top: 0;\n" +
" left: 0;\n" +
" width: 100%;\n" +
" height: 100%;\"></iframe>";
}
/**
* 注册组件
* @param datasetContext
* @return
*/
@Override
public AssembleComponent getComponent(CustomDatasetContext datasetContext) {
return DatasetComponent.KEY;
}
}

37
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetComponent.java

@ -0,0 +1,37 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.Atom;
import com.fr.web.struct.Registry;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
/**
* @author Heng.J
* @version 6.0
* Created by Heng.J on 2023/5/30
*/
public class DatasetComponent extends AssembleComponent {
public static final DatasetComponent KEY = new DatasetComponent();
@Override
public Atom[] refer() {
return new Atom[]{};
}
@Override
public ScriptPath script() {
return ScriptPath.build("com/eco/plugin/shsytzfsds/js/bi/publicds.js");
}
@Override
public StylePath style() {
return StylePath.build("com/eco/plugin/shsytzfsds/js/bi/publicds.css");
}
@Override
public Atom[] children() {
return Registry.getChildren(DatasetComponent.class);
}
}

18
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetProvider.java

@ -0,0 +1,18 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet;
import com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.generator.DatasetGenerator;
import com.finebi.provider.api.dataset.datasource.AbstractCustomDatasetProvider;
import com.finebi.provider.api.dataset.datasource.CustomDatasetGenerator;
/**
* @author wink
* @version 6.0
* Created by wink on 2023/5/30
*/
public class DatasetProvider extends AbstractCustomDatasetProvider {
@Override
public CustomDatasetGenerator getGenerator() {
return new DatasetGenerator();
}
}

26
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/DBConfig.java

@ -0,0 +1,26 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.feishu;
import java.util.HashMap;
import java.util.Map;
/**
* 用户自定义数据链接
*
* @author Heng.J
* @version 6.0
* Created by Heng.J on 2023/6/14
*/
public class DBConfig {
public static final String URL = "jdbc:mysql://localhost:3306/swift_data1?serverTimezone=Asia/Shanghai&useSSL=false";
public static final String USER = "root";
public static final String PASSWORD = "123456";
public static final Map<String, Class<?>> PARAMETER_MAP = new HashMap<>();
static {
PARAMETER_MAP.put("driver", String.class);
PARAMETER_MAP.put("appId", String.class);
}
}

34
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuDatasetDatasourceGenerator.java

@ -0,0 +1,34 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.feishu;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.eco.plugin.shsytzfsds.db.controller.DBController;
import com.eco.plugin.shsytzfsds.utils.DataSetUtils;
import com.eco.plugin.shsytzfsds.utils.FeiShuUtils;
import com.finebi.cbb.api.model.RowIterator;
import com.finebi.provider.api.dataset.datasource.AbstractDefaultDatasourceGenerator;
import com.finebi.provider.api.dataset.datasource.CustomDatasetContext;
import com.fr.data.core.db.ColumnInformation;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import java.util.Collections;
import java.util.Map;
public class FeishuDatasetDatasourceGenerator extends AbstractDefaultDatasourceGenerator {
@Override
public RowIterator getRowIterator(String jsonContext, CustomDatasetContext datasetContext, ColumnInformation[] columnInfos) {
return new FeishuRowIterator(jsonContext, Collections.singletonList(datasetContext), null);
}
@Override
public Map<String, Class<?>> getParameters(String jsonContext, CustomDatasetContext datasetContext) {
return DBConfig.PARAMETER_MAP;
}
@Override
public ColumnInformation[] createColumnInfos(String jsonContext, CustomDatasetContext datasetContext) {
return DataSetUtils.getSheetHeader(jsonContext);
}
}

100
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuRowIterator.java

@ -0,0 +1,100 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.feishu;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.eco.plugin.shsytzfsds.db.controller.DBController;
import com.eco.plugin.shsytzfsds.utils.FeiShuUtils;
import com.eco.plugin.shsytzfsds.utils.Utils;
import com.finebi.cbb.api.model.RowIterator;
import com.finebi.provider.api.dataset.datasource.CustomDatasetContext;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class FeishuRowIterator implements RowIterator {
private static int count = 0;
private String jsonContexts = "";
private static List<Object[]> result = new ArrayList<>();
public FeishuRowIterator(String jsonContexts, List<CustomDatasetContext> datasetContexts, String sql) {
count =0;
result = new ArrayList<>();
this.jsonContexts = jsonContexts;
JSONObject param = new JSONObject(jsonContexts);
String id = param.getString("appid");
String url = param.getString("url");
String rowSelect = param.getString("rowSelect");
int headrow = param.getInt("header");
String colSelect = param.getString("colSelect");
int rowsize = rowSelect.equals("custom") ? param.getInt("rowdata"):0;
String columnSize = colSelect.equals("colcustom") ? param.getString("coldata"):"";
DBEntity feishuApp = DBController.getById(id);
String appid = feishuApp.getAppid();
String secret = feishuApp.getSecret();
String token = FeiShuUtils.getTenantToken(appid,secret);
JSONArray jsonArray =FeiShuUtils.getSheetData(url,token,rowsize,columnSize,headrow,5000,0);
addRowDatas(jsonArray,headrow);
}
private void init() {
}
@Override
public void open() {
}
@Override
public boolean hasNext() {
return count < result.size();
}
@Override
public Object[] next() {
int current = count;
count++;
return result.get(current);
}
@Override
public void close() {
}
@Override
public void cancel() {
}
/**
* 添加行数据
* @param jsonArray
*/
private void addRowDatas(JSONArray jsonArray,int headerrow) {
if(jsonArray == null || jsonArray.size() <= 0){
return ;
}
for(int i =0;i< jsonArray.size();i++){
if(i == 0){
continue;
}
JSONArray values = jsonArray.getJSONArray(i);
Object[] rowDatas = new Object[values.length()];
for (int j = 0; j < values.length(); j++) {
rowDatas[j] =values.getString(j);
}
result.add(rowDatas);
}
}
}

37
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetGenerator.java

@ -0,0 +1,37 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.generator;
import com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.feishu.FeishuDatasetDatasourceGenerator;
import com.finebi.provider.api.dataset.datasource.AbstractCustomDatasetGenerator;
import com.finebi.provider.api.dataset.datasource.CustomDatasetDatasourceGenerator;
import org.jetbrains.annotations.NotNull;
/**
* @author wink
* @version 6.0
* Created by wink on 2023/5/30
*/
public class DatasetGenerator extends AbstractCustomDatasetGenerator {
@Override
public @NotNull String getName() {
return "飞书电子表格";
}
/**
* 前端页面相关接口
* @return
*/
@Override
public @NotNull DatasetPageGenerator getPageGenerator() {
return new DatasetPageGenerator();
}
/**
* 后端数据相关接口
* @return
*/
@Override
public @NotNull CustomDatasetDatasourceGenerator getDatasourceGenerator() {
return new FeishuDatasetDatasourceGenerator();
}
}

49
src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetPageGenerator.java

@ -0,0 +1,49 @@
package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.generator;
import com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.DatasetComponent;
import com.finebi.provider.api.dataset.datasource.CustomDatasetContext;
import com.finebi.provider.api.dataset.datasource.CustomDatasetPageGenerator;
import com.fr.web.struct.AssembleComponent;
/**
* @author wink
* @version 6.0
* Created by wink on 2023/5/30
* 前端接口
*/
public class DatasetPageGenerator implements CustomDatasetPageGenerator {
/**
* 图标
* @param datasetContext
* @return
*/
@Override
public String getIcon(CustomDatasetContext datasetContext) {
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAAkCAYAAAAU/hMoAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAVQSURBVFhH7Zd/SF5VGMdlRARRM9dqrCCk/rEw0tH+SDebGw2KUVKSBBGNEfujNUvWP1mNigrbP80/yh+zltooJraUqe8gcOU2bTRW8/XHdGqjLZ02UzdnnnO/Pc8599z33rv7vt53GDHYA1/ur/M+z+c8z3nOvW8KrgO7AblYdv1DSliwLAv7p87j8aFOrBvuwtrhzqSUN9KFsvEhCIu8kS8tobyHtQUyKRWosOYp0CBuirYhJRohtdjHEOppJUVQPjGiACWEnrwdIYwlhGRHsdlbiEyPIbX3BwpOkBw8CMotgkvppomRbulpQ++VaQWZrIVYk1wWLpVQ+nV2Evf2EygHDwLzyExGg24Y/llnkSetnYeypBuHnQ/NXcb9p9s1RChYoxa0TI86oGEtaUgTYHjuEtJP/6gCK4AwsDQmf6iLfHBV/kNIXXoN2j83hRV9XPqQjUSlX2KvTbcZf/HMA7nQYNOZep3q8V2XL+LWXgJIouzvXRiAlLHJ+uU3D+SlKxINR/RADcMguhuD0PkeP//m73MaUoG61il3tweQnp1qReZ3EZTsOownXmlEZkE9MjbtxaqifSh8oxmffHkCfSN/OfHZPJAXpgRWFVuob2dQvW54aKJtg53x2JI/o7Etx6xTs03xke7fXN2A1KerkZpTgWW5n+PO3CrckVupjqxlOZXq/sr1VegbmrAj+CDHpyxkb5cKtOaQ3shN+jm3ftPPdNlm5TxWn+lwZdEG7D6IlK5m3LZ1rwJQUGsqHCgDyPf4Gau2OaombswDOUHrWUPqY1mjxLywQfQQj2lwfsagAj2zU2rTjgG2YUlHE5YW7nFg0tbEMsZgBjSNztNyPkPRjhb1hmO/xryQM5YCNMoqlthWITA5o39gUE12/cb3Pxwb1Nk0gM/WOHAG1C0nmwS5fG0lugfGVRx3hISQrOztFjZ9MI/oCJVfdSStVTU6oPykOSnw4MBPSOloxtKCPQqCs+SH8yvtsQq8/E7EToBJhzYP5MVpLyQDmvPVJcAXEYl/5m1Q15qJGa9jgdrBEdz+TDWtL90cDGrO3QqTRbaEkFkEmf06SV1bqvwv7qL39+9257vKbq5/iY7ioYI6BaDhYiBuQJYzCTpufveQ7U9XyN2oCSH9UtCkR0sE3t8nMTZpYAWEEKhqOIl78qnEFDTeGvSLx92VV6GyGM+SgjQZ5XMGzn1T4NMmiSMnJ/DUqweczJkODoJyizPJ44rLOuwsBpsHcnKGQKi8friY+BmVXa1VnVVeAo9sm8MDL5zC3Ru+dfZCU+4gOJZ5nll0UL1EFhHSSK9TBnQ3F++tGVvO4b6Cw1ieR5t3HEieCD9LL+xA+2/zqlkS2dWQJqB9TFaq0UhZrwlkbP4D6c8dxYqNjVi+7itSHVZubKB7nXh46wQqW3WzJUb0QfI+qbLDwXzBkxFnV0u/Ys218s2ToPOP9tNmxX/OnG6Ob75MSgcyKPi1SPuy1zL55iM3G+8GvKeabSc0pKBJPblTzzQo4LWIIc3WlbND4sAx94tAf8QsZB5I/sHgeQsv7dYZZedGOqg+V+Wzr71Z91/re6wt5RJnRjVUok+/IPNAmm2AXtFoPW6h8GMNq4JfBRYv27H7vCafL5OInKDNnr5skoUz5oVkcbepdzPNmGiP9gq8XS+R/5ZQQd2A7u1KTYK7mia1vlRi59cWjvfbzaF86gSw7zAldpsH0phx4cDSHf6w6D7Lfy8Edn8vUVproaRGkgRK6wTKmwQaj1noPWupb1DzWyXyYPypRWUDh7VAyHjmBLUVdM+txbKkIP8vuwG5OAb8C5svkz2EkBopAAAAAElFTkSuQmCC";
}
/**
* 配置页面根节点dom元素
* @param datasetContext
* @return
*/
@Override
public String getEditPageHTML(CustomDatasetContext datasetContext) {
return "<iframe id='publicds' src=\"/webroot/decision/file?path=com/eco/plugin/shsytzfsds/html/sheet.html\" style=\"width:100%;height: 100%;border:none;position: fixed;\n" +
" top: 0;\n" +
" left: 0;\n" +
" width: 100%;\n" +
" height: 100%;\"></iframe>";
}
/**
* 注册组件
* @param datasetContext
* @return
*/
@Override
public AssembleComponent getComponent(CustomDatasetContext datasetContext) {
return DatasetComponent.KEY;
}
}

9
src/main/java/com/eco/plugin/shsytzfsds/constants/Result.java

@ -0,0 +1,9 @@
package com.eco.plugin.shsytzfsds.constants;
public class Result {
public static String paramNotNull= "必填参数不能为空";
public static String needLogin= "请先登录";
public static String validateFail = "鉴权失败";
}

20
src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerRegisterProvider.java

@ -0,0 +1,20 @@
package com.eco.plugin.shsytzfsds.controller;
import com.fr.decision.fun.impl.AbstractControllerRegisterProvider;
import com.fr.plugin.context.PluginContexts;
import com.fr.stable.fun.Authorize;
@Authorize(callSignKey = "com.eco.plugin.shsytzfsds")
public class ControllerRegisterProvider extends AbstractControllerRegisterProvider {
@Override
public Class<?>[] getControllers() {
if(!PluginContexts.currentContext().isAvailable()) {
return new Class[]{};
}
return new Class[]{
ControllerSelf.class
};
}
}

255
src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerSelf.java

@ -0,0 +1,255 @@
package com.eco.plugin.shsytzfsds.controller;
import com.eco.plugin.shsytzfsds.constants.Result;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.eco.plugin.shsytzfsds.db.controller.DBController;
import com.eco.plugin.shsytzfsds.utils.FRUtils;
import com.eco.plugin.shsytzfsds.utils.FeiShuUtils;
import com.eco.plugin.shsytzfsds.utils.ResponseUtils;
import com.eco.plugin.shsytzfsds.utils.Utils;
import com.finebi.web.action.v5.conf.FineExportAction;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.GetMapping;
import com.fr.third.springframework.web.bind.annotation.PostMapping;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Controller
@LoginStatusChecker(required = false)
@FunctionRecorder
public class ControllerSelf {
@GetMapping(value = "/fsds/getAllPage")
@ResponseBody
public void getAllPage(HttpServletRequest req,HttpServletResponse res){
try {
validateLogin(req,res);
} catch (Exception e) {
e.printStackTrace();
return;
}
List<DBEntity> all = DBController.getAllPage();
JSONArray allJson = JSONArray.create(all);
ResponseUtils.successResponse(res,allJson.toString());
}
@GetMapping(value = "/fsds/getAll")
@ResponseBody
public void getAll(HttpServletRequest req,HttpServletResponse res){
try {
validateLogin(req,res);
} catch (Exception e) {
e.printStackTrace();
return;
}
List<DBEntity> all = DBController.getAll();
JSONArray allJson = JSONArray.create(all);
ResponseUtils.successResponse(res,allJson.toString());
}
@GetMapping(value = "/fsds/getById")
@ResponseBody
public void getById(HttpServletRequest req,HttpServletResponse res){
try {
validateLogin(req,res);
} catch (Exception e) {
e.printStackTrace();
return;
}
String id = req.getParameter("id");
DBEntity dbEntity = DBController.getById(id);
JSONObject entityJson = JSONObject.mapFrom(dbEntity);
ResponseUtils.successResponse(res,entityJson.toString());
}
@PostMapping(value = "/fsds/add")
@ResponseBody
public void add(HttpServletRequest req,HttpServletResponse res){
try {
validateLogin(req,res);
} catch (Exception e) {
e.printStackTrace();
return;
}
JSONObject param = Utils.getRequestBody(req);
DBEntity entity = param.mapTo(DBEntity.class);
entity.setId(entity.getAppid());
boolean result = DBController.single(entity,null);
if(result){
ResponseUtils.successResponse(res,"添加成功");
}else{
ResponseUtils.failedResponse(res,"添加失败");
}
}
@PostMapping(value = "/fsds/update")
@ResponseBody
public void update(HttpServletRequest req,HttpServletResponse res){
try {
validateLogin(req,res);
} catch (Exception e) {
e.printStackTrace();
return;
}
JSONObject param = Utils.getRequestBody(req);
DBEntity entity = param.mapTo(DBEntity.class);
boolean result = DBController.single(entity,null);
if(result){
ResponseUtils.successResponse(res,"修改成功");
}else{
ResponseUtils.failedResponse(res,"修改失败");
}
}
@PostMapping(value = "/fsds/delete")
@ResponseBody
public void delete(HttpServletRequest req,HttpServletResponse res){
try {
validateLogin(req,res);
} catch (Exception e) {
e.printStackTrace();
return;
}
JSONObject param = Utils.getRequestBody(req);
String ids = param.getString("id");
String[] idarray = ids.split(",");
boolean result = false;
for (int i = 0; i < idarray.length; i++) {
String id = idarray[i];
DBEntity entity = new DBEntity();
entity.setId(id);
result = DBController.single(null,entity);
}
if(result){
ResponseUtils.successResponse(res,"删除成功");
}else{
ResponseUtils.failedResponse(res,"删除失败");
}
}
@PostMapping(value = "/fsds/getDWB")
@ResponseBody
public void getDWB(HttpServletRequest req,HttpServletResponse res){
try {
validateLogin(req,res);
} catch (Exception e) {
e.printStackTrace();
return;
}
JSONObject param = Utils.getRequestBody(req);
JSONObject result = new JSONObject();
String id = param.getString("appid");
String url = param.getString("url");
DBEntity feishuApp = DBController.getById(id);
String appid = feishuApp.getAppid();
String secret = feishuApp.getSecret();
String token = FeiShuUtils.getTenantToken(appid,secret);
JSONArray array =FeiShuUtils.getTableFields(url,token);
result.put("header",array);
JSONArray dataArray = FeiShuUtils.getTableData(url,token,"");
result.put("data",dataArray);
ResponseUtils.successResponse(res,result.toString());
}
@PostMapping(value = "/fsds/getSheet")
@ResponseBody
public void getSheet(HttpServletRequest req,HttpServletResponse res){
try {
validateLogin(req,res);
} catch (Exception e) {
e.printStackTrace();
return;
}
JSONObject param = Utils.getRequestBody(req);
String id = param.getString("appid");
String url = param.getString("url");
String rowSelect = param.getString("rowSelect");
int headrow = param.getInt("headrow");
String colSelect = param.getString("colSelect");
int rowsize = rowSelect.equals("custom") ? param.getInt("rowdata"):0;
String columnSize = colSelect.equals("colcustom") ? param.getString("coldata"):"";
DBEntity feishuApp = DBController.getById(id);
String appid = feishuApp.getAppid();
String secret = feishuApp.getSecret();
String token = FeiShuUtils.getTenantToken(appid,secret);
JSONArray jsonArray =FeiShuUtils.getSheetData(url,token,rowsize,columnSize,headrow,5000,0);
JSONArray dataHeader = new JSONArray();
JSONArray datas = new JSONArray();
JSONObject data = new JSONObject();
for(int i =0;i< jsonArray.size();i++){
JSONArray values = jsonArray.getJSONArray(i);
List<Object> rowDatas = new ArrayList<Object>();
data = new JSONObject();
for (int j = 0; j < values.length(); j++) {
if(i == 0){
JSONObject header = new JSONObject();
String str =headrow > 0 ? values.getString(j) : String.valueOf(j);
str = Utils.replaceNullStr(str,String.valueOf(j));
header.put("field",str);
header.put("title",str);
dataHeader.add(header);
}
String field =dataHeader.getJSONObject(j).getString("field");
String value = values.getString(j);
data.put(field,Utils.isNullStr(value) ? "" : value);
}
if(i ==0 && headrow > 0){
continue;
}
datas.add(data);
}
JSONObject result = new JSONObject();
result.put("header",dataHeader);
result.put("data",datas);
ResponseUtils.successResponse(res,result.toString());
}
/**
* 判断是否登陆
* @param req
* @param res
* @throws Exception
*/
private void validateLogin(HttpServletRequest req,HttpServletResponse res) throws Exception {
boolean isLogin = FRUtils.isLogin(req);
if(!isLogin){
ResponseUtils.failedResponse(res, Result.needLogin);
throw new Exception("needLogin");
}
}
}

73
src/main/java/com/eco/plugin/shsytzfsds/db/bean/DBEntity.java

@ -0,0 +1,73 @@
package com.eco.plugin.shsytzfsds.db.bean;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.stable.db.entity.TableAssociation;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
/**
* @author wink
* @version 10.0
* Created by wink on 2021-07-29
**/
@Entity
@Table(name = "plugin_entity_fs")
@TableAssociation(associated = true)
public class DBEntity extends BaseEntity {
@Column(name = "appname")
private String appname = null;
@Column(name = "appid")
private String appid = null;
@Column(name = "secret")
private String secret = null;
@Column(name = "enable")
private Boolean enable = null;
@Column(name = "describtion")
private String describtion = null;
public String getAppname() {
return appname;
}
public void setAppname(String appname) {
this.appname = appname;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public Boolean getEnable() {
return enable;
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
public String getDescribtion() {
return describtion;
}
public void setDescribtion(String describtion) {
this.describtion = describtion;
}
}

153
src/main/java/com/eco/plugin/shsytzfsds/db/controller/DBController.java

@ -0,0 +1,153 @@
package com.eco.plugin.shsytzfsds.db.controller;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.eco.plugin.shsytzfsds.db.dao.DBDao;
import com.eco.plugin.shsytzfsds.utils.FRUtils;
import com.fr.db.fun.impl.AbstractDBAccessProvider;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.db.accessor.DBAccessor;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import com.fr.stable.db.dao.DAOProvider;
import java.util.ArrayList;
import java.util.List;
/**
* @author wink
* @version 10.0
* Created by wink on 2021-07-29
**/
@EnableMetrics
@FunctionRecorder
public class DBController extends AbstractDBAccessProvider {
private static DBAccessor accessor;
public static DBAccessor getAccessor() {
return accessor;
}
@Override
public DAOProvider[] registerDAO() {
return new DAOProvider[]{
DBDao.DAO
};
}
@Override
public void onDBAvailable(DBAccessor accessor) {
DBController.accessor = accessor;
}
/**
* 单个操作
* @param addOrUpdate
* @param delete
* @return
*/
public static boolean single(DBEntity addOrUpdate,DBEntity delete){
//新增或者删除
if(addOrUpdate != null ){
try{
accessor.runDMLAction(new DBAction<Boolean>() {
@Override
public Boolean run(DAOContext context) throws Exception {
DBEntity ae =context.getDAO(DBDao.class).getById(addOrUpdate.getId());
if(ae != null ){
context.getDAO(DBDao.class).update(addOrUpdate);
}else{
context.getDAO(DBDao.class).add(addOrUpdate);
}
return true;
}
});
}catch(Throwable e){
FRUtils.FRLogError("single addOrUpdate exception ->"+e.getMessage() + addOrUpdate.toString());
}
}
if(delete != null ){
try{
accessor.runDMLAction(new DBAction<Boolean>() {
@Override
public Boolean run(DAOContext context) throws Exception {
context.getDAO(DBDao.class).remove(delete.getId());
return true;
}
});
}catch(Throwable e){
FRUtils.FRLogError("single delete exception ->"+e.getMessage() + delete.toString());
}
}
return true;
}
/**
* 根据id获取信息
* @param id
* @return
*/
public static DBEntity getById(final String id){
try{
return accessor.runQueryAction(new DBAction<DBEntity>() {
@Override
public DBEntity run(DAOContext context) throws Exception {
DBEntity result = context.getDAO(DBDao.class).getById(id);
return result == null ? new DBEntity() : result;
}
});
}catch(Throwable e){
FRUtils.FRLogError("exception getByUsername:"+e.getMessage());
}
return new DBEntity();
}
/**
* 获取全部信息
* @param
* @return
*/
public static List<DBEntity> getAll(){
try{
return accessor.runQueryAction(new DBAction<List<DBEntity>>() {
@Override
public List<DBEntity> run(DAOContext context) throws Exception {
List<DBEntity> result = context.getDAO(DBDao.class).getAll();
return result == null ? new ArrayList<>() : result;
}
});
}catch(Throwable e){
FRUtils.FRLogError("exception getById:"+e.getMessage());
}
return new ArrayList<>();
}
/**
* 获取全部信息
* @param
* @return
*/
public static List<DBEntity> getAllPage(){
try{
return accessor.runQueryAction(new DBAction<List<DBEntity>>() {
@Override
public List<DBEntity> run(DAOContext context) throws Exception {
List<DBEntity> result = context.getDAO(DBDao.class).getAllPage();
return result == null ? new ArrayList<>() : result;
}
});
}catch(Throwable e){
FRUtils.FRLogError("exception getById:"+e.getMessage());
}
return new ArrayList<>();
}
}

66
src/main/java/com/eco/plugin/shsytzfsds/db/dao/DBDao.java

@ -0,0 +1,66 @@
package com.eco.plugin.shsytzfsds.db.dao;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.List;
/**
* @author wink
* @version 10.0
* Created by wink on 2021-12-03
**/
public class DBDao extends BaseDAO<DBEntity> {
public DBDao(DAOSession session) {
super(session);
}
@Override
protected Class<DBEntity> getEntityClass() {
return DBEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return DBEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return DBDao.class;
}
};
public void add(DBEntity entity) throws Exception {
getSession().persist(entity);
}
public void remove(String id) throws Exception {
getSession().remove(QueryFactory.create()
.addRestriction(RestrictionFactory.eq("id", id)),
this.getEntityClass());
}
public void update(DBEntity entity) throws Exception {
getSession().merge(entity);
}
public List<DBEntity> getAll()throws Exception{
QueryCondition condition = QueryFactory.create()
.addRestriction(RestrictionFactory.like("appname", ""));
return find(condition);
}
public List<DBEntity> getAllPage()throws Exception{
QueryCondition condition = QueryFactory.create()
.addRestriction(RestrictionFactory.like("appname", ""));
return find(condition);
}
}

144
src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModel.java

@ -0,0 +1,144 @@
package com.eco.plugin.shsytzfsds.univalsalServerTable;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.eco.plugin.shsytzfsds.db.controller.DBController;
import com.eco.plugin.shsytzfsds.utils.FRUtils;
import com.eco.plugin.shsytzfsds.utils.FeiShuUtils;
import com.fr.data.AbstractDataModel;
import com.fr.general.data.TableDataException;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import java.util.ArrayList;
import java.util.List;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021-03-29
**/
public class DataModel extends AbstractDataModel {
private String config;
private ParameterProvider[] parameters;
//表头
private static String[] dataHeader = {};
//表数据
private List<List<Object>> datas = new ArrayList<>();
public DataModel(Calculator calculator, ParameterProvider[] parameters, String config){
this.parameters = parameters;
this.config = config;
try {
queryData();
} catch (Exception e) {
e.printStackTrace();
FRUtils.FRLogInfo("获取数据异常:"+e.getMessage());
}
}
@Override
public int getColumnCount() throws TableDataException {
return dataHeader.length;
}
@Override
public String getColumnName(int colIdx) throws TableDataException {
return dataHeader[colIdx];
}
@Override
public int getRowCount() throws TableDataException {
if (this.datas == null) {
return 0;
}
if (datas == null) {
return 0;
}
int count = datas.size();
return count;
}
@Override
public Object getValueAt(int rowIdx, int colIdx) throws TableDataException {
if (this.datas == null) {
return "";
}
if ((datas == null) || (datas.size() <= rowIdx)) {
return "";
}
List<Object> rowValues = datas.get(rowIdx);
if ((rowValues == null) || (rowValues.size() <= colIdx)) {
return "";
}
return rowValues.get(colIdx);
}
@Override
public void release() throws Exception {
parameters = null;
config = null;
}
//----------------------------------------------------------------------------以下为获取数据的的逻辑
/**
* 查询数据
*/
private void queryData() throws Exception {
String feishuid = "";
String url = "";
for (ParameterProvider pv : this.parameters){
if(pv.getName().equals("appid")){
feishuid = String.valueOf(pv.getValue());
}
if(pv.getName().equals("url")){
url = String.valueOf(pv.getValue());
}
}
DBEntity feishuApp = DBController.getById(feishuid);
String appid = feishuApp.getAppid();
String secret = feishuApp.getSecret();
String token = FeiShuUtils.getTenantToken(appid,secret);
JSONArray array =FeiShuUtils.getTableFields(url,token);
dataHeader = new String[array.length()];
for (int i = 0; i < array.length(); i++) {
dataHeader[i] = array.getString(i);
}
JSONArray dataArray = FeiShuUtils.getTableData(url,token,"");
addRowDatas(dataArray);
}
/**
* 添加行数据
* @param jsonArray
*/
private void addRowDatas(JSONArray jsonArray) {
if(jsonArray == null || jsonArray.size() <= 0){
return ;
}
for(int i =0;i< jsonArray.size();i++){
JSONObject fields = jsonArray.getJSONObject(i).getJSONObject("fields");
List<Object> rowDatas = new ArrayList<Object>();
for(String header : dataHeader){
rowDatas.add(fields.getString(header));
}
datas.add(rowDatas);
}
}
}

169
src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModelSheet.java

@ -0,0 +1,169 @@
package com.eco.plugin.shsytzfsds.univalsalServerTable;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.eco.plugin.shsytzfsds.db.controller.DBController;
import com.eco.plugin.shsytzfsds.utils.FRUtils;
import com.eco.plugin.shsytzfsds.utils.FeiShuUtils;
import com.eco.plugin.shsytzfsds.utils.Utils;
import com.fr.data.AbstractDataModel;
import com.fr.general.data.TableDataException;
import com.fr.json.JSONArray;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import java.util.ArrayList;
import java.util.List;
public class DataModelSheet extends AbstractDataModel {
private String config;
private ParameterProvider[] parameters;
//表头
private static String[] dataHeader = new String[0];
//表数据
private List<List<Object>> datas = new ArrayList<>();
public DataModelSheet(Calculator calculator, ParameterProvider[] parameters, String config){
this.parameters = parameters;
this.config = config;
try {
queryData();
} catch (Exception e) {
e.printStackTrace();
FRUtils.FRLogInfo("获取数据异常:"+e.getMessage());
}
}
@Override
public int getColumnCount() throws TableDataException {
return dataHeader.length;
}
@Override
public String getColumnName(int colIdx) throws TableDataException {
return dataHeader[colIdx];
}
@Override
public int getRowCount() throws TableDataException {
if (this.datas == null) {
return 0;
}
if (datas == null) {
return 0;
}
int count = datas.size();
return count;
}
@Override
public Object getValueAt(int rowIdx, int colIdx) throws TableDataException {
if (this.datas == null) {
return "";
}
if ((datas == null) || (datas.size() <= rowIdx)) {
return "";
}
List<Object> rowValues = datas.get(rowIdx);
if ((rowValues == null) || (rowValues.size() <= colIdx)) {
return "";
}
return rowValues.get(colIdx);
}
@Override
public void release() throws Exception {
parameters = null;
config = null;
}
//----------------------------------------------------------------------------以下为获取数据的的逻辑
/**
* 查询数据
*/
private void queryData() throws Exception {
String feishuid = "";
String url = "";
int headrow = 0;
int rowsize = 0;
String columnSize = "";
for (ParameterProvider pv : this.parameters){
if(pv.getName().equals("appid")){
feishuid = String.valueOf(pv.getValue());
}
if(pv.getName().equals("url")){
url = String.valueOf(pv.getValue());
}
if(pv.getName().equals("headrow")){
String value =String.valueOf(pv.getValue());
if(Utils.isNullStr(value)){
value = "0";
}
headrow = Integer.valueOf(value);
if(headrow < 0){
headrow = 0;
}
}
if(pv.getName().equals("rowsize")){
rowsize = Integer.valueOf(String.valueOf(pv.getValue()));
}
if(pv.getName().equals("columnSize")){
columnSize = String.valueOf(pv.getValue());
}
}
DBEntity feishuApp = DBController.getById(feishuid);
String appid = feishuApp.getAppid();
String secret = feishuApp.getSecret();
String token = FeiShuUtils.getTenantToken(appid,secret);
JSONArray array =FeiShuUtils.getSheetData(url,token,rowsize,columnSize,headrow,5000,0);
addRowDatas(array,headrow);
}
/**
* 添加行数据
* @param jsonArray
*/
private void addRowDatas(JSONArray jsonArray,int headerrow) {
if(jsonArray == null || jsonArray.size() <= 0){
return ;
}
for(int i =0;i< jsonArray.size();i++){
JSONArray values = jsonArray.getJSONArray(i);
List<Object> rowDatas = new ArrayList<Object>();
for (int j = 0; j < values.length(); j++) {
if(i == 0){
if(j == 0){
dataHeader = new String[values.length()];
}
dataHeader[j] = headerrow > 0 ? values.getString(j) : String.valueOf(j);
}
rowDatas.add(values.getString(j));
}
if(i ==0 && headerrow > 0){
continue;
}
datas.add(rowDatas);
}
}
}

58
src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableData.java

@ -0,0 +1,58 @@
package com.eco.plugin.shsytzfsds.univalsalServerTable;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.data.AbstractParameterTableData;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.script.Calculator;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
public class TableData extends AbstractParameterTableData {
/**
* 自定义一些配置
*/
private Conf<String> config = Holders.simple(StringUtils.EMPTY);
public String getConfig() {
return config.get();
}
public void setConfig( String config) {
this.config.set(config);
}
@Override
public DataModel createDataModel(Calculator calculator) {
return new DataModel( calculator,
Calculator.processParameters(calculator,super.getParameters(calculator)),
getConfig() );
}
@Override
public void readXML(XMLableReader reader) {
super.readXML(reader);
if (reader.isChildNode()){
if ("Attributes".equals(reader.getTagName())) {
try{
String conf = new String(GeneralXMLTools.readByteArray(reader), EncodeConstants.ENCODING_UTF_8);
setConfig(conf);
}catch(Exception e){
setConfig(StringUtils.EMPTY);
}
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
writer.startTAG("Attributes");
try{
GeneralXMLTools.writeByteArray(writer, getConfig().getBytes(EncodeConstants.ENCODING_UTF_8));
}catch(Exception e){}
writer.end();
}
}

63
src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBean.java

@ -0,0 +1,63 @@
package com.eco.plugin.shsytzfsds.univalsalServerTable;
import com.fr.decision.webservice.bean.BaseBean;
import com.fr.decision.webservice.bean.dataset.ParameterBean;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @author wink
* @version 10.0
* Created by wink on 2022-11-07
**/
public class TableDataBean extends BaseBean {
private List<ParameterBean> parameters = new ArrayList();
private String config;
public List<ParameterBean> getParameters() {
return parameters;
}
public void setParameters(List<ParameterBean> parameters) {
this.parameters = parameters;
}
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
@Override
public boolean equals(Object o){
return o instanceof TableDataBean
&& StringUtils.equals(((TableDataBean)o).config, config)
&& isSameParameter(((TableDataBean)o).parameters);
}
private boolean isSameParameter(List<ParameterBean> parameters){
if( null == parameters && null != this.parameters ){
return false;
}
if( null != parameters && null == this.parameters ){
return false;
}
if( parameters.size() != this.parameters.size() ){
return false;
}
for( int i=0,len= parameters.size();i<len;i++){
ParameterBean oItem = parameters.get(i);
ParameterBean sItem = this.parameters.get(i);
if( !StringUtils.equals(oItem.getName(),sItem.getName()) ||
!StringUtils.equals(oItem.getValue(),sItem.getValue()) ||
!StringUtils.equals(oItem.getType(),sItem.getType()) ){
return false;
}
}
return true;
}
}

63
src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBeanSheet.java

@ -0,0 +1,63 @@
package com.eco.plugin.shsytzfsds.univalsalServerTable;
import com.fr.decision.webservice.bean.BaseBean;
import com.fr.decision.webservice.bean.dataset.ParameterBean;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @author wink
* @version 10.0
* Created by wink on 2022-11-07
**/
public class TableDataBeanSheet extends BaseBean {
private List<ParameterBean> parameters = new ArrayList();
private String config;
public List<ParameterBean> getParameters() {
return parameters;
}
public void setParameters(List<ParameterBean> parameters) {
this.parameters = parameters;
}
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
@Override
public boolean equals(Object o){
return o instanceof TableDataBeanSheet
&& StringUtils.equals(((TableDataBeanSheet)o).config, config)
&& isSameParameter(((TableDataBeanSheet)o).parameters);
}
private boolean isSameParameter(List<ParameterBean> parameters){
if( null == parameters && null != this.parameters ){
return false;
}
if( null != parameters && null == this.parameters ){
return false;
}
if( parameters.size() != this.parameters.size() ){
return false;
}
for( int i=0,len= parameters.size();i<len;i++){
ParameterBean oItem = parameters.get(i);
ParameterBean sItem = this.parameters.get(i);
if( !StringUtils.equals(oItem.getName(),sItem.getName()) ||
!StringUtils.equals(oItem.getValue(),sItem.getValue()) ||
!StringUtils.equals(oItem.getType(),sItem.getType()) ){
return false;
}
}
return true;
}
}

58
src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataSheet.java

@ -0,0 +1,58 @@
package com.eco.plugin.shsytzfsds.univalsalServerTable;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.data.AbstractParameterTableData;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.script.Calculator;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
public class TableDataSheet extends AbstractParameterTableData {
/**
* 自定义一些配置
*/
private Conf<String> config = Holders.simple(StringUtils.EMPTY);
public String getConfig() {
return config.get();
}
public void setConfig( String config) {
this.config.set(config);
}
@Override
public DataModelSheet createDataModel(Calculator calculator) {
return new DataModelSheet( calculator,
Calculator.processParameters(calculator,super.getParameters(calculator)),
getConfig() );
}
@Override
public void readXML(XMLableReader reader) {
super.readXML(reader);
if (reader.isChildNode()){
if ("Attributes".equals(reader.getTagName())) {
try{
String conf = new String(GeneralXMLTools.readByteArray(reader), EncodeConstants.ENCODING_UTF_8);
setConfig(conf);
}catch(Exception e){
setConfig(StringUtils.EMPTY);
}
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
writer.startTAG("Attributes");
try{
GeneralXMLTools.writeByteArray(writer, getConfig().getBytes(EncodeConstants.ENCODING_UTF_8));
}catch(Exception e){}
writer.end();
}
}

69
src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableData.java

@ -0,0 +1,69 @@
package com.eco.plugin.shsytzfsds.univalsalServerTable;
import com.fr.base.Parameter;
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider;
import com.fr.decision.webservice.bean.dataset.ParameterBean;
import com.fr.json.JSONObject;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.web.struct.Atom;
import com.fr.web.struct.Component;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ParserType;
import com.fr.web.struct.category.ScriptPath;
import java.util.ArrayList;
import java.util.List;
@FunctionRecorder
public class UniversalServerTableData extends AbstractUniversalServerTableDataProvider<TableData> {
@Override
public Class classForTableData() {
return TableData.class;
}
@Override
public String nameForTableData() {
return "飞书多维表数据集";
}
@Override
public JSONObject serialize(TableData data) {
TableDataBean bean = new TableDataBean();
bean.setConfig(data.getConfig());
List<ParameterBean> parameterBeans = new ArrayList();
ParameterProvider[] parameters = data.getParameters(Calculator.createCalculator());
for (ParameterProvider parameter : parameters) {
parameterBeans.add(new ParameterBean(parameter.getValue().getClass().getSimpleName(),
parameter.getName(),
parameter.valueToString()));
}
bean.setParameters(parameterBeans);
return JSONObject.mapFrom(bean);
}
@Override
public TableData deserialize(TableData data, JSONObject config) {
TableDataBean bean = config.mapTo(TableDataBean.class);
TableData dataSet = new TableData();
dataSet.setConfig(bean.getConfig());
List<ParameterBean> params = bean.getParameters();
Parameter[] parameters = new Parameter[params.size()];
for (int i = 0; i < parameters.length; ++i) {
parameters[i] = params.get(i).createParameter();
}
dataSet.setParameters(parameters);
return dataSet;
}
@Override
public Atom client() {
return new Component() {
@Override
public ScriptPath script(RequestClient client) {
return ScriptPath.build("com/eco/plugin/shsytzfsds/js/univalsalServerTable.js", ParserType.DYNAMIC);
}
};
}
}

67
src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableDataSheet.java

@ -0,0 +1,67 @@
package com.eco.plugin.shsytzfsds.univalsalServerTable;
import com.fr.base.Parameter;
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider;
import com.fr.decision.webservice.bean.dataset.ParameterBean;
import com.fr.json.JSONObject;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.web.struct.Atom;
import com.fr.web.struct.Component;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ParserType;
import com.fr.web.struct.category.ScriptPath;
import java.util.ArrayList;
import java.util.List;
public class UniversalServerTableDataSheet extends AbstractUniversalServerTableDataProvider<TableDataSheet> {
@Override
public Class classForTableData() {
return TableDataSheet.class;
}
@Override
public String nameForTableData() {
return "飞书表格单sheet数据集";
}
@Override
public JSONObject serialize(TableDataSheet data) {
TableDataBeanSheet bean = new TableDataBeanSheet();
bean.setConfig(data.getConfig());
List<ParameterBean> parameterBeans = new ArrayList();
ParameterProvider[] parameters = data.getParameters(Calculator.createCalculator());
for (ParameterProvider parameter : parameters) {
parameterBeans.add(new ParameterBean(parameter.getValue().getClass().getSimpleName(),
parameter.getName(),
parameter.valueToString()));
}
bean.setParameters(parameterBeans);
return JSONObject.mapFrom(bean);
}
@Override
public TableDataSheet deserialize(TableDataSheet data, JSONObject config) {
TableDataBeanSheet bean = config.mapTo(TableDataBeanSheet.class);
TableDataSheet dataSet = new TableDataSheet();
dataSet.setConfig(bean.getConfig());
List<ParameterBean> params = bean.getParameters();
Parameter[] parameters = new Parameter[params.size()];
for (int i = 0; i < parameters.length; ++i) {
parameters[i] = params.get(i).createParameter();
}
dataSet.setParameters(parameters);
return dataSet;
}
@Override
public Atom client() {
return new Component() {
@Override
public ScriptPath script(RequestClient client) {
return ScriptPath.build("com/eco/plugin/shsytzfsds/js/univalsalServerTableSheet.js", ParserType.DYNAMIC);
}
};
}
}

89
src/main/java/com/eco/plugin/shsytzfsds/utils/DataSetUtils.java

@ -0,0 +1,89 @@
package com.eco.plugin.shsytzfsds.utils;
import com.eco.plugin.shsytzfsds.db.bean.DBEntity;
import com.eco.plugin.shsytzfsds.db.controller.DBController;
import com.fr.data.core.db.ColumnInformation;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import scala.annotation.meta.field;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
/**
* 数据集工具类
*/
public class DataSetUtils {
/**
* 获取数据集请求头
* @param paramStr
* @return
*/
public static ColumnInformation[] getHeader(String paramStr){
JSONObject param = new JSONObject(paramStr);
String appid = param.getString("appid");
String url = param.getString("url");
DBEntity feishuApp = DBController.getById(appid);
String secret = feishuApp.getSecret();
String token = FeiShuUtils.getTenantToken(appid,secret);
JSONArray array =FeiShuUtils.getTableFields(url,token);
ColumnInformation[] columnInformations = new ColumnInformation[array.length()];
for (int i = 0; i < array.length(); i++) {
ColumnInformation columnInformation = new ColumnInformation(array.getString(i), Types.VARCHAR,"VARCHAR",255,0);
columnInformations[i] =columnInformation;
}
return columnInformations;
}
/**
* 获取电子表格头
* @param paramStr
* @return
*/
public static ColumnInformation[] getSheetHeader(String paramStr){
JSONObject param = new JSONObject(paramStr);
String id = param.getString("appid");
String url = param.getString("url");
int headrow = param.getInt("headrow");
String colSelect = param.getString("colSelect");
int rowsize = headrow+1;
String columnSize = colSelect.equals("colcustom") ? param.getString("coldata"):"";
DBEntity feishuApp = DBController.getById(id);
String appid = feishuApp.getAppid();
String secret = feishuApp.getSecret();
String token = FeiShuUtils.getTenantToken(appid,secret);
JSONArray jsonArray =FeiShuUtils.getSheetData(url,token,rowsize,columnSize,headrow,10,0);
ColumnInformation[] columnInformations = null;
for(int i =0;i< jsonArray.size();i++){
JSONArray values = jsonArray.getJSONArray(i);
for (int j = 0; j < values.length(); j++) {
if(i == 0){
if(j == 0){
columnInformations = new ColumnInformation[values.length()];
}
String field =headrow > 0 ? values.getString(j) : String.valueOf(j);
field = Utils.replaceNullStr(field,String.valueOf(j));
ColumnInformation columnInformation = new ColumnInformation(field, Types.VARCHAR,"VARCHAR",255,0);
columnInformations[j] =columnInformation;
}
}
break;
}
return columnInformations;
}
}

378
src/main/java/com/eco/plugin/shsytzfsds/utils/FRUtils.java

@ -0,0 +1,378 @@
package com.eco.plugin.shsytzfsds.utils;
import com.fr.base.ServerConfig;
import com.fr.base.TableData;
import com.fr.base.TemplateUtils;
import com.fr.decision.authority.AuthorityContext;
import com.fr.decision.authority.base.constant.type.operation.ManualOperationType;
import com.fr.decision.authority.data.User;
import com.fr.decision.base.util.UUIDUtil;
import com.fr.decision.privilege.TransmissionTool;
import com.fr.decision.privilege.encrpt.PasswordValidator;
import com.fr.decision.webservice.bean.authentication.OriginUrlResponseBean;
import com.fr.decision.webservice.interceptor.handler.ReportTemplateRequestChecker;
import com.fr.decision.webservice.login.LogInOutResultInfo;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.decision.webservice.utils.DecisionStatusService;
import com.fr.decision.webservice.utils.UserSourceFactory;
import com.fr.decision.webservice.v10.login.LoginService;
import com.fr.decision.webservice.v10.login.event.LogInOutEvent;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.event.EventDispatcher;
import com.fr.file.TableDataConfig;
import com.fr.general.data.DataModel;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.restriction.RestrictionFactory;
import com.fr.third.springframework.web.method.HandlerMethod;
import com.fr.web.controller.ReportRequestService;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
public class FRUtils {
/**
* 判断用户是否存在
* @param userName
* @return
*/
public static boolean isUserExist(String userName){
if (StringUtils.isEmpty(userName)) {
return false;
} else {
try {
List userList = AuthorityContext.getInstance().getUserController().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("userName", userName)));
return userList != null && !userList.isEmpty();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
return false;
}
}
}
/**
* 判断是否登录FR
* @param req
* @return
*/
public static boolean isLogin(HttpServletRequest req){
return LoginService.getInstance().isLogged(req);
}
/**
* 帆软登录
* @param httpServletRequest
* @param httpServletResponse
* @param userName
* @param url
*/
public static void login(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String userName,String url){
FineLoggerFactory.getLogger().debug("FRLOG:用户名:"+userName+";跳转链接:"+url);
//判断用户名是否为空
if(!Utils.isNullStr(userName)){
if(isUserExist(userName)){
try {
LoginService.getInstance().login(httpServletRequest, httpServletResponse, userName);
EventDispatcher.fire(LogInOutEvent.LOGIN,new LogInOutResultInfo(httpServletRequest,httpServletResponse,userName,true));
FineLoggerFactory.getLogger().debug("FRLOG:登陆成功!");
if(!Utils.isNullStr(url)){
httpServletResponse.sendRedirect(url);
}
} catch (Exception e) {
ResponseUtils.failedResponse(httpServletResponse,"登录异常,请联系管理员!");
FineLoggerFactory.getLogger().debug("FRLOGException:"+e.getMessage());
}
}else{
ResponseUtils.failedResponse(httpServletResponse,"用户:"+userName+"在帆软系统中不存在!");
}
}else{
ResponseUtils.failedResponse(httpServletResponse,"用户名不能为空!");
}
}
/**
* 帆软登录
* @param httpServletRequest
* @param httpServletResponse
* @param token
* @param url
*/
public static void loginByToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String token,String url){
FineLoggerFactory.getLogger().debug("FRLOG:token:"+token+";跳转链接:"+url);
//判断用户名是否为空
if(!Utils.isNullStr(token)){
writeToken2Cookie(httpServletResponse,token,-1);
HttpSession session = httpServletRequest.getSession(true);
httpServletRequest.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME,token);
session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, token);
if(!Utils.isNullStr(url)){
try {
httpServletResponse.sendRedirect(url);
} catch (IOException e) {
ResponseUtils.failedResponse(httpServletResponse,"跳转异常!");
}
}
}else{
ResponseUtils.failedResponse(httpServletResponse,"token不能为空!");
}
}
/**
* 产品原始登录方法
* @param req
* @param res
* @param username
* @return
*/
public static JSONObject originLogin(HttpServletRequest req,HttpServletResponse res,String username){
// String password = param.getString("password");
// password = decryptFRPsd(password);
FRUtils.FRLogInfo("originLogin:"+username);
if(isUserExist(username)){
try {
String token = LoginService.getInstance().login(req, res, username);
JSONObject result = new JSONObject();
result.put("username",username);
result.put("validity",-1);
result.put("accessToken",token);
result.put("username",username);
result.put("url","/webroot/decision");
JSONObject originUrlResponse = new JSONObject();
originUrlResponse.put("originUrl","/webroot/decision");
originUrlResponse.put("method","GET");
originUrlResponse.put("parameters",new JSONObject());
result.put("originUrlResponse",originUrlResponse);
return new JSONObject().put("data",result);
} catch (Exception e) {
ResponseUtils.failedResponse(res,"登录异常,请联系管理员!");
}
}else{
ResponseUtils.failedResponse(res,"用户:"+username+"在帆软系统中不存在!");
}
return new JSONObject();
}
/**
* 获取token
* @param httpServletRequest
* @param httpServletResponse
* @param username
* @return
*/
public static String getToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String username){
String token = "";
try {
token = LoginService.getInstance().login(httpServletRequest, httpServletResponse, username);
} catch (Exception e) {
FineLoggerFactory.getLogger().debug("FRLOG:获取token失败"+e.getMessage());
}
return token;
}
private static void writeToken2Cookie(HttpServletResponse req, String token, int num) {
try {
if (StringUtils.isNotEmpty(token)) {
Cookie cookie = new Cookie("fine_auth_token", token);
long maxAge = num == -2 ? 1209600000L : (long)num;
cookie.setMaxAge((int)maxAge);
cookie.setPath(ServerConfig.getInstance().getCookiePath());
req.addCookie(cookie);
Cookie rememberCookie = new Cookie("fine_remember_login", String.valueOf(num == -2 ? -2 : -1));
rememberCookie.setMaxAge((int)maxAge);
rememberCookie.setPath(ServerConfig.getInstance().getCookiePath());
req.addCookie(rememberCookie);
} else {
FineLoggerFactory.getLogger().error("empty token cannot save.");
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 后台登出
* @param httpServletRequest
* @param httpServletResponse
*/
public static void logoutByToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String token)
{
httpServletRequest.setAttribute("fine_auth_token",token);
logout(httpServletRequest,httpServletResponse);
}
/**
*
* @param httpServletRequest
* @param httpServletResponse
*/
public static void logout(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse)
{
if(!isLogin(httpServletRequest)){
return ;
}
try {
LoginService.getInstance().logout(httpServletRequest,httpServletResponse);
} catch (Exception e) {
ResponseUtils.failedResponse(httpServletResponse,"登出异常,请联系管理员!");
FineLoggerFactory.getLogger().debug("FRLOGException:"+e.getMessage());
}
}
/**
* 打印FR日志
* @param message
*/
public static void FRLogInfo(String message){
FineLoggerFactory.getLogger().info("FRLOG:"+message);
}
/**
* 打印FR日志-debug
* @param message
*/
public static void FRLogDebug(String message){
FineLoggerFactory.getLogger().debug("FRLOG:"+message);
}
/**
* 打印FR日志-error
* @param message
*/
public static void FRLogError(String message){
FineLoggerFactory.getLogger().error("FRLOG:"+message);
}
/**
* 根据用户名获取用户信息
* @param userName
* @return
*/
public static User getFRUserByUserName(String userName){
try {
return UserService.getInstance().getUserByUserName(userName);
} catch (Exception e) {
FRLogInfo("获取用户信息异常:"+e.getMessage());
}
return null;
}
/**
* 解密FR密码
* @param password
* @return
*/
public static String decryptFRPsd(String password){
FRLogInfo("解密密码:"+password);
return TransmissionTool.decrypt(password);
}
/**
* 根据明文密码生成数据库中的密码用户密码校验用
* @return
*/
public static String getDBPsd(String username,String password){
PasswordValidator pv = UserSourceFactory.getInstance().getUserSource(ManualOperationType.KEY).getPasswordValidator();
String uuid = UUIDUtil.generate();
return pv.encode(username, password, uuid);
}
/**
* 获取带参数的访问链接
* @return
*/
public static String getAllUrl(HttpServletRequest httpServletRequest){
return WebUtils.getOriginalURL(httpServletRequest);
}
/**
* 根据originKey获取源链接
* @param req
* @return
* @throws Exception
*/
public static String getOriginUrl(HttpServletRequest req) throws Exception {
String origin = req.getParameter("origin");
if (StringUtils.isNotEmpty(origin)) {
OriginUrlResponseBean originUrlResponseBean = (OriginUrlResponseBean) DecisionStatusService.originUrlStatusService().get(origin);
DecisionStatusService.originUrlStatusService().delete(origin);
if (originUrlResponseBean != null) {
return originUrlResponseBean.getOriginUrl();
}
}
return new OriginUrlResponseBean(TemplateUtils.render("${fineServletURL}")).getOriginUrl();
}
/**
* 判断是否开启模板认证
* @param
* @return
* @throws Exception
*/
public static boolean isTempAuth(HttpServletRequest req,HttpServletResponse res) throws Exception {
ReportTemplateRequestChecker checker = new ReportTemplateRequestChecker();
HandlerMethod hm = new HandlerMethod(new ReportRequestService(),ReportRequestService.class.getMethod("preview", HttpServletRequest.class, HttpServletResponse.class, String.class));
return checker.checkRequest(req,res,hm);
}
/**
* 获取数据集数据
* @param serverDataSetName
* @return
*/
public static DataModel getTableData(String serverDataSetName){
TableData userdebug = TableDataConfig.getInstance().getTableData(serverDataSetName);
DataModel userdebugDM = userdebug.createDataModel(Calculator.createCalculator());
// userdebugDM.getRowCount();
// userdebugDM.getColumnIndex();
// userdebugDM.getValueAt()
return userdebugDM;
}
public static String getIndex(HttpServletRequest req){
String url = req.getScheme()+"://"+req.getServerName()+":"+String.valueOf(req.getServerPort())+req.getRequestURI();
return url;
}
/**
* 获取帆软域名
* @param req
* @return
*/
public static String getFRDomain(HttpServletRequest req){
String domain = req.getScheme()+"://"+req.getServerName();
int port = req.getServerPort();
if(port != 80){
domain += ":"+String.valueOf(req.getServerPort());
}
return domain;
}
}

290
src/main/java/com/eco/plugin/shsytzfsds/utils/FeiShuUtils.java

@ -0,0 +1,290 @@
package com.eco.plugin.shsytzfsds.utils;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* 飞书工具类
*/
public class FeiShuUtils {
private static final String tenant_token_url = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal";
private static final String sheet_data_url = "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values/:range";
//根据sheettoken获取sheet信息地址
private static final String sheet_sheet_url = "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/metainfo";
private static final String table_data_url = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records";
private static final String table_fields_url = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields";
/**
* 获取自建应用token
* @param appid
* @param appSecret
* @return
*/
public static String getTenantToken(String appid,String appSecret){
JSONObject param = new JSONObject();
param.put("app_id",appid);
param.put("app_secret",appSecret);
String result = HttpUtils.HttpPostJson(tenant_token_url,param.toString(),null);
return new JSONObject(result).getString("tenant_access_token");
}
/**
* 获取单sheet数据
* @param url
* @param token
* @param rowsize 行号为0时获取全部数据源
* @param column 列号
* @param headRow 标题行 获取数据时排除此行
* @param pagecount 每页数量此处为行数
* @param curentrow 当前行数
* @return
*/
public static JSONArray getSheetData(String url,String token,int rowsize,String column,int headRow,int pagecount,int curentrow){
JSONArray array = new JSONArray();
JSONObject sheetParam = getSheetParam(url,token);
String sheetToken = sheetParam.getString("sheetToken");
String sheetId = sheetParam.getString("sheetId");
String rowCount = sheetParam.getString("rowCount");
String columnCount = sheetParam.getString("columnCount");
//最大行为0时获取全部数据
if(rowsize <= 0){
rowsize = Integer.valueOf(rowCount);
}
//列名为空时获取全部数据
if(Utils.isNullStr(column)){
column = numberToLetter(Integer.valueOf(columnCount));
}
if(curentrow <= headRow){
curentrow = headRow == 0 ? 1 : headRow;
}
int startrow = curentrow;
curentrow +=pagecount;
if(curentrow > rowsize){
curentrow = rowsize;
}
String range = sheetId+"!A"+startrow+":"+column+curentrow;
String requestUrl =sheet_data_url.replaceAll(":spreadsheetToken",sheetToken).replaceAll(":range",range);
Map<String,String> header = new HashMap<>();
header.put("Authorization","Bearer "+token);
header.put("Content-Type","application/json; charset=utf-8");
String result = HttpUtils.httpGet(requestUrl,null,header);
array.addAll(new JSONObject(result).getJSONObject("data").getJSONObject("valueRange").getJSONArray("values"));
if(curentrow < rowsize){
JSONArray childrenArray = getSheetData(url,token,rowsize,column,headRow,pagecount,curentrow+1);
array.addAll(childrenArray);
}
return array;
}
/**
* 根据url获取sheet参数
* @param url
* @return
*/
private static JSONObject getSheetParam(String url,String token) {
String[] urls = url.split("\\?");
String[] urlParam = urls[0].split("/");
String sheetToken =urlParam[urlParam.length-1];
String sheetId = "";
JSONArray sheetArray = getSheetArray(sheetToken,token);
if(urls.length > 1){
String paramstr = urls[1];
String[] params = paramstr.split("&");
for (String param : params){
String[] kv = param.split("=");
if(kv[0].equals("sheet")){
sheetId = kv[1];
break;
}
}
}else{
sheetId = sheetArray.getJSONObject(0).getString("sheetId");
}
JSONObject result = new JSONObject();
result.put("sheetToken",sheetToken);
result.put("sheetId",sheetId);
for (int i = 0; i < sheetArray.length(); i++) {
JSONObject sheet = sheetArray.getJSONObject(i);
String sheetIdE = sheet.getString("sheetId");
if(sheetIdE.equals(sheetId)){
result.put("rowCount",sheet.getString("rowCount"));
result.put("columnCount",sheet.getString("columnCount"));
}
}
return result;
}
private static JSONArray getSheetArray(String sheetToken,String token){
String url = sheet_sheet_url.replaceAll(":spreadsheetToken",sheetToken);
Map<String,String> header = new HashMap<>();
header.put("Authorization","Bearer "+token);
header.put("Content-Type","application/json; charset=utf-8");
String result = HttpUtils.httpGet(url,null,header);
return new JSONObject(result).getJSONObject("data").getJSONArray("sheets");
}
/**
* 获取多维表数据
* @param url
* @param token
* @param pageToken
* @return
*/
public static JSONArray getTableData(String url,String token,String pageToken){
JSONArray array = new JSONArray();
JSONObject sheetParam = getTableParam(url);
String app_token = sheetParam.getString("app_token");
String table_id = sheetParam.getString("table_id");
String requestUrl =table_data_url.replaceAll(":app_token",app_token).replaceAll(":table_id",table_id)+"?page_token="+pageToken+"&page_size="+500;
Map<String,String> header = new HashMap<>();
header.put("Authorization","Bearer "+token);
String result = HttpUtils.httpGet(requestUrl,null,header);
JSONObject data = new JSONObject(result).getJSONObject("data");
pageToken = data.getString("page_token");
array.addAll(data.getJSONArray("items"));
boolean hasMore = data.getBoolean("has_more");
if(hasMore){
array.addAll(getTableData(url,token,pageToken));
}
return array;
}
/**
* 获取多维表字段
* @param url
* @param token
* @return
*/
public static JSONArray getTableFields(String url,String token){
JSONObject sheetParam = getTableParam(url);
String app_token = sheetParam.getString("app_token");
String table_id = sheetParam.getString("table_id");
String requestUrl =table_fields_url.replaceAll(":app_token",app_token).replaceAll(":table_id",table_id);
Map<String,String> header = new HashMap<>();
header.put("Authorization","Bearer "+token);
String result = HttpUtils.httpGet(requestUrl,null,header);
JSONObject data = new JSONObject(result).getJSONObject("data");
JSONArray fileds =data.getJSONArray("items");
JSONArray resultArray = new JSONArray();
for (int i = 0; i < fileds.length(); i++) {
JSONObject filed = fileds.getJSONObject(i);
resultArray.add(filed.getString("field_name"));
}
return resultArray;
}
/**
* 解析多维表参数
* @param url
* @return
*/
private static JSONObject getTableParam(String url) {
String[] urls = url.split("\\?");
String[] urlParam = urls[0].split("/");
String app_token =urlParam[urlParam.length-1];
String paramstr = urls[1];
String[] params = paramstr.split("&");
String sheetId = "";
for (String param : params){
String[] kv = param.split("=");
if(kv[0].equals("table")){
sheetId = kv[1];
break;
}
}
JSONObject result = new JSONObject();
result.put("app_token",app_token);
result.put("table_id",sheetId);
return result;
}
public static void main(String[] args) {
// String token =getTenantToken("cli_a4756c7b3939d00b","4CFoMmAe03YU0kY3ZCsLgfRMnB48Vwxa");
//14730 客户飞书参数
String token =getTenantToken("cli_a52dc2cb0039900c","ugnGbddZTyeTP08ILvR2uhMGsqxVn2Jk");
String url = "https://w808buw46o.feishu.cn/base/XSKlbxuXda5VGxs54pmcMpnZnWC?table=tblSfSJcbBFzE182&view=vewA9JsnjJ";
// String url = "https://ka04381dfr9.feishu.cn/sheets/RrnVs4bBkhOIYftOH4tc4xiDnUd?sheet=9fc5e2";
////// String url = "https://ka04381dfr9.feishu.cn/sheets/RrnVs4bBkhOIYftOH4tc4xiDnUd";
// int rowsize = 6;
// int headRow = 1;
// String column = "C";
// int pageCount = 1;
// int currentRow = 0;
////
// JSONArray jsonArray = getSheetData(url,token,rowsize,column,headRow,pageCount,currentRow);
//多维表
// String url = "https://ka04381dfr9.feishu.cn/base/X50lbouzeaI2H4sZazCcVM1lnJg?table=tblznO8etpFgDCcT&view=vewNfD7zhV";
//异数据源多维表
// String url = "https://ka04381dfr9.feishu.cn/base/Nte9biFa2afxnfsu4SdcXSM9nte?table=tblhXY5sLnZrq3yr&view=vewsaUn2WV";
//审批多维表
// String url = "https://ka04381dfr9.feishu.cn/base/X50lbouzeaI2H4sZazCcVM1lnJg?table=tbllWZFrVSmYHfQ4&view=vewqQwbR9O";
JSONArray tableFields = getTableFields(url,token);
JSONArray jsonArray = getTableData(url,token,"");
System.out.println();
}
public static String numberToLetter(int num){
if(num <= 0){
return null;
}
String letter = "";
num--;
do{
if(letter.length()>0){
num--;
}
letter = ((char)(num%26+(int)'A'))+letter;
num = (int)((num-num%26)/26);
}while (num>0);
return letter;
}
}

260
src/main/java/com/eco/plugin/shsytzfsds/utils/HttpUtils.java

@ -0,0 +1,260 @@
package com.eco.plugin.shsytzfsds.utils;
import com.fr.log.FineLoggerFactory;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.NameValuePair;
import com.fr.third.org.apache.http.client.CookieStore;
import com.fr.third.org.apache.http.client.entity.UrlEncodedFormEntity;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import com.fr.third.org.apache.http.client.methods.HttpPost;
import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier;
import com.fr.third.org.apache.http.entity.StringEntity;
import com.fr.third.org.apache.http.impl.client.BasicCookieStore;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.third.org.apache.http.impl.client.HttpClients;
import com.fr.third.org.apache.http.impl.cookie.BasicClientCookie;
import com.fr.third.org.apache.http.message.BasicNameValuePair;
import com.fr.third.org.apache.http.ssl.SSLContexts;
import com.fr.third.org.apache.http.ssl.TrustStrategy;
import com.fr.third.org.apache.http.util.EntityUtils;
import javax.net.ssl.SSLContext;
import javax.servlet.http.Cookie;
import java.io.UnsupportedEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class HttpUtils {
/**
* httpGet请求
* @param url
* @return
*/
public static String httpGet(String url,Cookie[] cookies,Map<String,String> header){
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--url:"+url);
//创建httpClient
CloseableHttpClient httpclient = createHttpClient(cookies);
HttpGet getMethod = new HttpGet(url);
if(header != null && header.size() > 0){
Set<String> keySet = header.keySet();
for(String key : keySet){
getMethod.setHeader(key,header.get(key));
}
}
try {
HttpResponse response = httpclient.execute(getMethod);
int status =response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String returnResult = EntityUtils.toString(entity, "utf-8");
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--status:"+status +";returnResult:"+returnResult);
httpclient.close();
if (status == HttpStatus.SC_OK) {
return returnResult;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--exception:"+e.getMessage());
}
try {
httpclient.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:http关闭异常:"+e.getMessage());
}
return "";
}
/**
* HttpPost请求
* @param postMethod
* @return
*/
private static String HttpPost(HttpPost postMethod){
CloseableHttpClient httpclient = createHttpClient(null);
try {
HttpResponse response = httpclient.execute(postMethod);
int status = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String returnResult = EntityUtils.toString(entity, "utf-8");
FineLoggerFactory.getLogger().info("FRLOG:HttpPost:status:"+status+"returnResult:"+returnResult);
httpclient.close();
if (status == HttpStatus.SC_OK) {
return returnResult;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpPost:exception:"+e.getMessage());
}
try {
httpclient.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:http关闭异常:"+e.getMessage());
}
return "";
}
public static String HttpPostXML(String url, String xmlParam){
FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:url:"+url);
HttpPost postMethod = new HttpPost(url);
postMethod.setHeader("Content-type", "text/html");
HttpEntity entity = null;
try {
entity = new StringEntity(xmlParam,"utf-8");
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:参数异常:"+e.getMessage());
return "";
}
postMethod.setEntity(entity);
return HttpPost(postMethod);
}
public static String HttpPostText(String url, String xmlParam){
FineLoggerFactory.getLogger().info("FRLOG:HttpPostText:url:"+url);
HttpPost postMethod = new HttpPost(url);
postMethod.setHeader("Content-type", "text/plain");
HttpEntity entity = null;
try {
entity = new StringEntity(xmlParam,"utf-8");
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpPostText:参数异常:"+e.getMessage());
return "";
}
postMethod.setEntity(entity);
return HttpPost(postMethod);
}
public static String HttpPostJson(String url, String param,Map<String,String> header){
FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:url:"+url);
HttpPost postMethod = new HttpPost(url);
postMethod.setHeader("Content-Type","application/json");
if(header != null && header.size() > 0){
Set<String> keySet = header.keySet();
for(String key : keySet){
postMethod.setHeader(key,header.get(key));
}
}
if(!Utils.isNullStr(param)){
HttpEntity entity = null;
try {
entity = new StringEntity(param,"utf-8");
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:参数异常:"+e.getMessage());
return "";
}
postMethod.setEntity(entity);
}
return HttpPost(postMethod);
}
public static String HttpPostForm(String url, Map<String,String> header,Map<String,String> param){
FineLoggerFactory.getLogger().info("FRLOG:HttpForm:url:"+url);
HttpPost postMethod = new HttpPost(url);
if(header != null && header.size() > 0){
Set<String> keySet = header.keySet();
for(String key : keySet){
postMethod.setHeader(key,header.get(key));
}
}
if(param != null && param.size() > 0){
List<NameValuePair> params = new ArrayList<NameValuePair>(param.size());
for(Map.Entry<String,String> map : param.entrySet()){
params.add(new BasicNameValuePair(map.getKey(), map.getValue()));
}
try {
postMethod.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpForm:异常:"+e.getMessage());
return "";
}
}
return HttpPost(postMethod);
}
private static CloseableHttpClient createHttpClient(Cookie[] cookies){
SSLContext sslContext = null;
try {
sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
return true;
}
}).build();
} catch (Exception e) {
FRUtils.FRLogDebug("exception:"+e.getMessage());
}
CloseableHttpClient httpclient = null;
if(cookies != null && cookies.length > 0){
CookieStore cookieStore = cookieToCookieStore(cookies);
httpclient = HttpClients.custom().setSslcontext(sslContext).
setSSLHostnameVerifier(new NoopHostnameVerifier()).setDefaultCookieStore(cookieStore).build();
}
else{
httpclient = HttpClients.custom().setSslcontext(sslContext).
setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
}
return httpclient;
}
/**
* cookies转cookieStore
* @param cookies
* @return
*/
public static CookieStore cookieToCookieStore(Cookie[] cookies){
CookieStore cookieStore = new BasicCookieStore();
if(cookies != null && cookies.length>0){
for(Cookie cookie : cookies){
BasicClientCookie cookie1 = new BasicClientCookie(cookie.getName(), cookie.getValue());
cookieStore.addCookie(cookie1);
}
}
return cookieStore;
}
}

108
src/main/java/com/eco/plugin/shsytzfsds/utils/ResponseUtils.java

@ -0,0 +1,108 @@
package com.eco.plugin.shsytzfsds.utils;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
public class ResponseUtils {
private static final int SUCCESS = 200;
private static final int FAILED = -1;
public static void successResponse(HttpServletResponse res, String body) {
response(res, body, SUCCESS);
}
public static void failedResponse(HttpServletResponse res, String body) {
response(res, body, FAILED);
}
private static void response(HttpServletResponse res, String body, int code) {
JSONObject object = new JSONObject();
PrintWriter pw;
try {
object.put("code", code);
object.put("data", body);
pw = WebUtils.createPrintWriter(res);
} catch (Exception e) {
FineLoggerFactory.getLogger().debug(e.getMessage());
return;
}
res.setContentType("application/json;charset=utf-8");
String result = object.toString();
pw.println(result);
pw.flush();
pw.close();
}
public static void response(HttpServletResponse res,JSONObject json){
PrintWriter pw;
try {
pw = WebUtils.createPrintWriter(res);
} catch (Exception e) {
FineLoggerFactory.getLogger().debug(e.getMessage());
return;
}
res.setContentType("application/json;charset=utf-8");
String result = json.toString();
pw.println(result);
pw.flush();
pw.close();
}
public static void responseText(HttpServletResponse res,String text){
PrintWriter pw;
try {
pw = WebUtils.createPrintWriter(res);
} catch (Exception e) {
FineLoggerFactory.getLogger().debug(e.getMessage());
return;
}
res.setContentType("text/html;charset=utf-8");
pw.println(text);
pw.flush();
pw.close();
}
public static void responseXml(HttpServletResponse res,String xml){
PrintWriter pw;
try {
pw = WebUtils.createPrintWriter(res);
} catch (Exception e) {
FineLoggerFactory.getLogger().debug(e.getMessage());
return;
}
res.setContentType("text/xml;charset=utf-8");
pw.println(xml);
pw.flush();
pw.close();
}
public static void setCSRFHeader(HttpServletResponse httpServletResponse){
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,HEAD,PUT,PATCH");
httpServletResponse.setHeader("Access-Control-Max-Age", "36000");
httpServletResponse.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,Authorization,authorization");
}
public static void responseJsonp(HttpServletRequest req, HttpServletResponse res, JSONObject json){
PrintWriter pw;
try {
pw = WebUtils.createPrintWriter(res);
} catch (Exception e) {
FineLoggerFactory.getLogger().debug(e.getMessage());
return;
}
res.setContentType("text/javascript;charset=utf-8;charset=utf-8");
String result = json.toString();
String jsonp=req.getParameter("callback");
pw.println(jsonp+"("+result+")");
pw.flush();
pw.close();
}
}

385
src/main/java/com/eco/plugin/shsytzfsds/utils/Utils.java

@ -0,0 +1,385 @@
package com.eco.plugin.shsytzfsds.utils;
import com.fr.base.TemplateUtils;
import com.fr.data.NetworkHelper;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.json.JSONObject;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Utils {
public static byte[] getByteHeader(byte[] bytes){
byte[] newByte = new byte[3];
for(int i=0;i<bytes.length;i++){
if(i < 3){
newByte[i] = bytes[i];
continue;
}
break;
}
return newByte;
}
public static String bytesToHexString(byte[] src) {
StringBuilder stringBuilder = new StringBuilder();
if (src == null || src.length <= 0) {
return null;
}
for (int i = 0; i < src.length; i++) {
int v = src[i] & 0xFF;
String hv = Integer.toHexString(v);
if (hv.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append(hv);
}
return stringBuilder.toString();
}
/**
* 判断字符串是否为空
* @param str
* @return true 空字符串 false 非空字符串
*/
public static boolean isNullStr(String str){
return !(str != null && !str.isEmpty() && !"null".equals(str));
}
/**
* 判断字符串是否非空
* @param str
* @return
*/
public static boolean isNotNullStr(String str){
return !isNullStr(str);
}
/**
* MD5加密
* @param str
* @return
*/
public static String getMd5Str(String str)
{
return DigestUtils.md5Hex(str);
}
/**
* 帆软shaEncode加密
*/
public static String shaEncode(String str){
return CodeUtils.sha256Encode(str);
}
/**
* 获取uuid
*/
public static String uuid(){
return UUID.randomUUID().toString();
}
/**
* 替换空字符串
* @param str
* @param replace
* @return
*/
public static String replaceNullStr(String str,String replace){
if(isNullStr(str)){
return replace;
}
return str;
}
/**
* 获取请求体
* @param req
* @return
*/
public static JSONObject getRequestBody(HttpServletRequest req){
StringBuffer sb = new StringBuffer();
String line = null;
try {
BufferedReader reader = req.getReader();
while ((line = reader.readLine()) != null)
sb.append(line);
} catch (Exception e) {
FRUtils.FRLogDebug("getRequestBody:exception:"+e.getMessage());
}
//将空格和换行符替换掉避免使用反序列化工具解析对象时失败
String jsonString = sb.toString().replaceAll("\\s","").replaceAll("\n","");
FRUtils.FRLogDebug("reqBody:"+jsonString);
JSONObject json = new JSONObject(jsonString);
return json;
}
/**
* 获取本机ip
* @return
* @throws UnknownHostException
*/
public static String getLocalIp() throws UnknownHostException {
InetAddress localHost = InetAddress.getLocalHost();
String ipAddress = localHost.getHostAddress();
return ipAddress;
}
/**
* 获取ip
* @return
*/
public static String getIp(HttpServletRequest req){
String realIp = req.getHeader("X-Real-IP");
String fw = req.getHeader("X-Forwarded-For");
if (StringUtils.isNotEmpty(fw) && !"unKnown".equalsIgnoreCase(fw)) {
int para3 = fw.indexOf(",");
return para3 != -1 ? fw.substring(0, para3) : fw;
} else {
fw = realIp;
if (StringUtils.isNotEmpty(realIp) && !"unKnown".equalsIgnoreCase(realIp)) {
return realIp;
} else {
if (StringUtils.isBlank(realIp) || "unknown".equalsIgnoreCase(realIp)) {
fw = req.getHeader("Proxy-Client-IP");
}
if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) {
fw = req.getHeader("WL-Proxy-Client-IP");
}
if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) {
fw = req.getHeader("HTTP_CLIENT_IP");
}
if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) {
fw = req.getHeader("HTTP_X_FORWARDED_FOR");
}
if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) {
fw = req.getRemoteAddr();
}
return fw;
}
}
}
/**
* 根据key获取cookie
* @param req
* @return
*/
public static String getCookieByKey(HttpServletRequest req,String key){
Cookie[] cookies = req.getCookies();
String cookie = "";
if(cookies == null || cookies.length <=0){
return "";
}
for(int i = 0; i < cookies.length; i++) {
Cookie item = cookies[i];
if (item.getName().equalsIgnoreCase(key)) {
cookie = item.getValue();
}
}
FRUtils.FRLogDebug("cookie:"+cookie);
return cookie;
}
/**
* 判断是否是手机端的链接
* @param req
* @return
*/
public static boolean isMobile(HttpServletRequest req) {
String[] mobileArray = {"iPhone", "iPad", "android", "windows phone", "xiaomi"};
String userAgent = req.getHeader("user-agent");
if (userAgent != null && userAgent.toUpperCase().contains("MOBILE")) {
for(String mobile : mobileArray) {
if(userAgent.toUpperCase().contains(mobile.toUpperCase())) {
return true;
}
}
}
return NetworkHelper.getDevice(req).isMobile();
}
/**
* 只编码中文
* @param url
* @return
*/
public static String encodeCH(String url ){
Matcher matcher = Pattern.compile("[\\u4E00-\\u9FA5]*[\\(\\)]").matcher(url);
while(matcher.find()){
String chn = matcher.group();
url = url.replaceAll(chn, URLEncoder.encode(chn));
}
return url;
}
/**
* 获取web-inf文件夹下的文件
* filename /resources/ip4enc.properties
*/
public static InputStream getResourcesFile(String filename){
return ResourceIOUtils.read(filename);
}
/**
*
* @param res
* @param path /com/fr/plugin/loginAuth/html/getMac.html
* @param parameterMap
*/
public static void toErrorPage(HttpServletResponse res,String path,Map<String, String> parameterMap){
if(parameterMap == null){
parameterMap = new HashMap<String, String>();
}
try {
String macPage = TemplateUtils.renderTemplate(path, parameterMap);
WebUtils.printAsString(res, macPage);
}catch (Exception e){
FRUtils.FRLogError("跳转页面异常");
}
}
/**
* 判断是否是管理员
* @param username
* @return
*/
public static boolean isAdmin(String username) throws Exception{
return UserService.getInstance().isAdmin(UserService.getInstance().getUserByUserName(username).getId());
}
/**
* 去掉浏览器中的参数
* @param url
* @param param
* @return
*/
public static String removeParam(String url,String param){
if(!url.contains("?")){
return url;
}
String[] urls = url.split("\\?");
String queryStr = urls[1];
String[] params = queryStr.split("&");
url = urls[0];
for(int i=0;i<params.length;i++){
String paramEach = params[i];
if(paramEach.contains(param)){
continue;
}
url+=!url.contains("?")?"?"+paramEach:"&"+paramEach;
}
return url;
}
/**
* 获取跳转链接
* @param req
* @param param
* @return
*/
public static String getRedirectUrl(HttpServletRequest req,String param){
String url = FRUtils.getAllUrl(req);
if(isNotNullStr(param)){
url = removeParam(url,param);
}
url = encodeCH(url);
return url;
}
/**
* 去除空格换行
* @param str
* @return
*/
public static String trim(String str){
return str.trim().replaceAll("\n","").replaceAll("\r","");
}
/**
* list 转化为指定字符分割的字符串
* @param list
* @param list
* @return
*/
public static String listToStr(List<String> list, String split){
String result = "";
if(list == null || list.size() <= 0){
return result;
}
for(String str : list){
result+=","+str;
}
result = result.substring(1);
return result;
}
/**
* array 转化为指定字符分割的字符串
* @param list
* @param list
* @return
*/
public static String arrayToStr(String[] list, String split){
String result = "";
if(list == null ||list.length <= 0){
return result;
}
for(int i=0;i<list.length;i++){
String str = list[i];
result+=","+str;
}
result = result.substring(1);
return result;
}
}

35
src/main/java/com/eco/plugin/shsytzfsds/webresourceProvider/WebResourceProvider.java

@ -0,0 +1,35 @@
package com.eco.plugin.shsytzfsds.webresourceProvider;
import com.fr.decision.fun.impl.AbstractWebResourceProvider;
import com.fr.decision.web.MainComponent;
import com.fr.web.struct.Atom;
import com.fr.web.struct.Component;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
/**
* Created by wink on 2021-12-03
*/
public class WebResourceProvider extends AbstractWebResourceProvider {
@Override
public Atom attach() {
return MainComponent.KEY;
}
@Override
public Atom client() {
return new Component() {
@Override
public ScriptPath script(RequestClient requestClient) {
return ScriptPath.build("/com/eco/plugin/shsytzfsds/js/ui.js");
}
@Override
public StylePath style(RequestClient requestClient) {
return StylePath.EMPTY;
// return StylePath.build("/com/fr/plugin/jdfSSO/css/icon.css");
}
};
}
}

16
src/main/resources/com/eco/plugin/shsytzfsds/css/wink.css

@ -0,0 +1,16 @@
.wink-input {
width : 150px;
}
.wink-bi-border {
border:1px solid black
}
.wink-border-bottom {
border:none;
border-bottom: 1px solid black;
}
.wink-font-weight {
font-weight: bold;
}

290
src/main/resources/com/eco/plugin/shsytzfsds/html/dwb.html

@ -0,0 +1,290 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>飞书多维表格</title>
<link rel="stylesheet" href="file?path=com/eco/plugin/shsytzfsds/js/layui/css/layui.css">
<link rel="stylesheet" href="file?path=com/eco/plugin/shsytzfsds/css/wink.css">
<script src="file?path=com/eco/plugin/shsytzfsds/js/layui/layui.js"></script>
<script src="file?path=com/eco/plugin/shsytzfsds/js/jquery/jquery-2.1.3.min.js"></script>
<style>
div {
width:100%;
/*height:100%*/
}
</style>
</head>
<body>
<div class="layui-fluid" style="">
<div class="layui-row" style="position:fixed;top:0;left:0;height:40px;width:100%;line-height: 40px">
<div class="layui-col-lg3" style="padding: 10px">
数据集名称:
<input id="name" class="wink-input" style="border:none;border-bottom: 1px solid black">
</div>
<div class="layui-col-lg1 layui-col-md-offset8" style="text-align: right;padding-right: 5px">
<button id="cancel" type="button" class="layui-btn layui-btn-primary layui-btn-xs">取消</button>
<button id="ok" type="button" class="layui-btn layui-btn-normal layui-btn-xs">确认</button>
</div>
</div>
<div class="layui-row" style="position: fixed;top:40px;left:0px;width:100%;height: 100%;">
<div class="layui-col-lg3" style="height:100%;padding: 10px">
<div class="layui-row" style="height: 40px;line-height: 40px;">
<div class="layui-col-lg2 wink-font-weight" style="">
飞书应用
</div>
<div class="layui-col-lg10" style="">
<select id="app" class="wink-input wink-border-bottom" >
</select>
</div>
</div>
<div class="layui-row" style="">
<div class="layui-col-lg2 wink-font-weight" style="">
多维表url
</div>
<div class="layui-col-lg10" style="">
<input id="url" class="wink-input">
</div>
</div>
</div>
<div class="layui-col-lg9 " style="">
<div class="layui-row" style="height: 40px;line-height: 40px">
<div class="layui-col-lg12" style="text-align: right;padding-right: 5px">
<button id="view" type="button" class="layui-btn layui-btn-primary layui-btn-xs">预览</button>
</div>
</div>
<div class="layui-row" style="position: fixed;top:80px;width:100%;height: 100%;border : 1px dashed black">
<div class="layui-col-lg9 bi-border">
<table id="dataTable" lay-filter="dataTable"></table>
</div>
</div>
</div>
</div>
</div>
<script>
var configData = {};
var table = "";
var layer = "";
layui.use(['layer', 'form','table','dropdown'], function(){
layer = layui.layer;
var form = layui.form;
table = layui.table
var dropdown = layui.dropdown;
init();
getApp();
});
/**
* 加载数据
*/
function init(){
initAppList();
bindEvent();
}
/**
* 绑定事件
*/
function bindEvent(){
//预览
$("#view").click(function(){
var height = window.innerHeight/2+"px";
var width = window.innerWidth/2+"px";
var index = layer.load(2,{
offset:[height,width]
});
configData.appid = $("#app").val();
configData.url = $("#url").val();
$.ajax({
type:"post",
async:true,
url:"/webroot/decision/fsds/getDWB",
xhrFields:{
withCredentials:true
},
data:JSON.stringify(configData),
contentType:"application/json",
success:function(data){
layer.close(index);
if(!data.data){
alert("预览失败");
return ;
}
var tableData = JSON.parse(data.data);
var header = tableData.header;
header = operater(header);
var data = tableData.data;
data = operaterData(data);
var tableHeight = window.innerHeight-90
table.render({
elem: '#dataTable' //指定原始表格元素选择器(推荐id选择器)
,height: tableHeight //容器高度
,cols: header,
data:data,
page:true,
limit:200,
skin:"line",
even: true //开启隔行背景
});
},
error:function(data){
layer.close(index);
}
})
})
}
/**
* 处理表格数据
*/
function operaterData(data){
var result = [];
$.each(data,function(index,item){
result.push(item.fields);
})
return result;
}
/**
* 处理表头数据
* @param header
*/
function operater(header){
var result = [];
$.each(header,function(index,item){
result.push({
"field":item,
"title":item
})
})
return [result];
}
/**
* 加载飞书应用列表
*/
function initAppList(){
var applist = getApp();
if(applist){
$.each(applist,function(index,app){
$("#app").append("<option value='"+app.id+"'>"+app.appname+"</option>")
})
}
}
/**
* 获取数据
*/
function getValue(){
return {
appid:$("#app").val(),
url:$("#url").val(),
name:$("#name").val(),
}
}
/**
* 设置数据
*/
function setValue(data){
data = JSON.parse(data);
configData = data;
$("#app").val(data.appid)
$("#url").val(data.url)
$("#name").val(data.name)
}
/**
* 获取启用的应用数据
* @param param
* @returns {{count, page: (boolean|number|*), items: {}}}
*/
function getApp(){
var result = {};
$.ajax({
type:"get",
async:false,
url:"/webroot/decision/fsds/getAll",
xhrFields:{
withCredentials:true
},
success:function(data){
result = JSON.parse(data.data);
},
error:function(data){
}
})
return result;
}
/**
* 获取多维表数据
* @param param
* @returns {{count, page: (boolean|number|*), items: {}}}
*/
function getDWBData(){
configData.appid = $("#app").val();
configData.url = $("#url").val();
var result = {};
$.ajax({
type:"post",
async:false,
url:"/webroot/decision/fsds/getDWB",
xhrFields:{
withCredentials:true
},
data:JSON.stringify(configData),
contentType:"application/json",
success:function(data){
result = JSON.parse(data.data);
},
error:function(data){
}
})
return result;
}
/**
* 打开加载
*/
function openLayer(){
var height = window.innerHeight/2+"px";
var width = window.innerWidth/2+"px";
var index = layer.load(2,{
offset:[height,width]
});
}
/**
* 校验必填参数
*/
function validate(){
var result = false;
var appid=$("#app").val();
var url=$("#url").val();
var name=$("#name").val();
if(appid && url && name){
result = true;
}else{
alert("请先填写配置信息");
}
return result;
}
</script>
</body>
</html>

356
src/main/resources/com/eco/plugin/shsytzfsds/html/sheet.html

@ -0,0 +1,356 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>飞书多维表格</title>
<link rel="stylesheet" href="file?path=com/eco/plugin/shsytzfsds/js/layui/css/layui.css">
<link rel="stylesheet" href="file?path=com/eco/plugin/shsytzfsds/css/wink.css">
<script src="file?path=com/eco/plugin/shsytzfsds/js/layui/layui.js"></script>
<script src="file?path=com/eco/plugin/shsytzfsds/js/jquery/jquery-2.1.3.min.js"></script>
<style>
div {
width:100%;
/*height:100%*/
}
</style>
</head>
<body>
<div class="layui-fluid" style="">
<div class="layui-row" style="position:fixed;top:0;left:0;height:40px;width:100%;line-height: 40px">
<div class="layui-col-lg3" style="padding: 10px">
数据集名称:
<input id="name" class="wink-input" style="border:none;border-bottom: 1px solid black">
</div>
<div class="layui-col-lg1 layui-col-md-offset8" style="text-align: right;padding-right: 5px">
<button id="cancel" type="button" class="layui-btn layui-btn-primary layui-btn-xs">取消</button>
<button id="ok" type="button" class="layui-btn layui-btn-normal layui-btn-xs">确认</button>
</div>
</div>
<div class="layui-row" style="position: fixed;top:40px;left:0px;width:100%;height: 100%;">
<div class="layui-col-lg3" style="height:100%;padding: 10px">
<div class="layui-row" style="height: 40px;line-height: 40px;">
<div class="layui-col-lg4 wink-font-weight" style="text-align: right;padding-right: 5px">
飞书应用
</div>
<div class="layui-col-lg8" style="padding-left: 10px">
<select id="app" class="wink-input wink-border-bottom" >
</select>
</div>
</div>
<div class="layui-row" style="height:30px;line-height: 30px">
<div class="layui-col-lg4 wink-font-weight" style="text-align: right;padding-right: 5px">
表格url
</div>
<div class="layui-col-lg8" style="padding-left: 10px">
<input id="url" class="wink-input">
</div>
</div>
<div class="layui-row" style="height:30px;line-height: 30px">
<div class="layui-col-lg4 wink-font-weight" style="text-align: right;padding-right: 5px">
设置表头
</div>
<div class="layui-col-lg8" style="padding-left: 10px">
<input id="headrow" style="width:100px" value="1">
</div>
</div>
<div class="layui-row" style="height:30px;line-height: 30px">
<div class="layui-col-lg4 wink-font-weight" style="text-align: right;padding-right: 5px">
选取行数据
</div>
<div class="layui-col-lg8 " style="padding-left: 10px">
<input id="default" type="radio" value="default" name="row" checked> 默认(第2行~全部行)
</div>
</div>
<div class="layui-row" style="height:30px;line-height: 30px">
<div class="layui-col-lg8 layui-col-md-offset4" style="padding-left: 10px">
<input id="custom" type="radio" value="custom" name="row"> 自定义
<input id="row" style="width:80px" disabled>
</div>
</div>
<div class="layui-row" style="height:30px;line-height: 30px">
<div class="layui-col-lg4 wink-font-weight" style="text-align: right;padding-right: 5px">
选取列数据
</div>
<div class="layui-col-lg8" style="padding-left: 10px">
<input id="coldefault" type="radio" value="coldefault" name="col" checked> 默认(第A列~最后有数据列)
</div>
</div>
<div class="layui-row" style="height:30px;line-height: 30px">
<div class="layui-col-lg8 layui-col-md-offset4" style="padding-left: 10px">
<input id="colcustom" type="radio" value="colcustom" name="col"> 自定义
<input id="col" style="width:80px" disabled>
</div>
</div>
</div>
<div class="layui-col-lg9 " style="">
<div class="layui-row" style="height: 40px;line-height: 40px">
<div class="layui-col-lg12" style="text-align: right;padding-right: 5px">
<button id="view" type="button" class="layui-btn layui-btn-primary layui-btn-xs">预览</button>
</div>
</div>
<div class="layui-row" style="position: fixed;top:80px;width:100%;height: 100%;border : 1px dashed black">
<div class="layui-col-lg9 bi-border">
<table id="dataTable" lay-filter="dataTable"></table>
</div>
</div>
</div>
</div>
</div>
<script>
var configData = {};
var table = "";
var layer = "";
layui.use(['layer', 'form','table','dropdown'], function(){
layer = layui.layer;
table = layui.table
init();
getApp();
});
/**
* 加载数据
*/
function init(){
initAppList();
bindEvent();
}
/**
* 绑定事件
*/
function bindEvent(){
//预览
$("#view").click(function(){
var height = window.innerHeight/2+"px";
var width = window.innerWidth/2+"px";
var index = layer.load(2,{
offset:[height,width]
});
var data = getValue();
$.ajax({
type:"post",
async:true,
url:"/webroot/decision/fsds/getSheet",
xhrFields:{
withCredentials:true
},
data:JSON.stringify(data),
contentType:"application/json",
success:function(data){
layer.close(index);
if(!data.data){
alert("预览失败");
return ;
}
var tableData = JSON.parse(data.data);
var header = tableData.header;
header = [header];
var data = tableData.data;
var tableHeight = window.innerHeight-90
table.render({
elem: '#dataTable' //指定原始表格元素选择器(推荐id选择器)
,height: tableHeight //容器高度
,cols: header,
data:data,
page:true,
limit:200,
skin:"line",
even: true //开启隔行背景
});
},
error:function(data){
layer.close(index);
}
})
})
//默认row选择事件
$("#default").click(function(){
$("#row").attr("disabled",true);
})
//自定义row选择事件
$("#custom").click(function(){
$("#row").removeAttr("disabled");
})
//默认col选择事件
$("#coldefault").click(function(){
$("#col").attr("disabled",true);
})
//自定义col选择事件
$("#colcustom").click(function(){
$("#col").removeAttr("disabled");
})
}
/**
* 处理表格数据
*/
function operaterData(data){
var result = [];
$.each(data,function(index,item){
result.push(item.fields);
})
return result;
}
/**
* 处理表头数据
* @param header
*/
function operater(header){
var result = [];
$.each(header,function(index,item){
result.push({
"field":item,
"title":item
})
})
return [result];
}
/**
* 加载飞书应用列表
*/
function initAppList(){
var applist = getApp();
if(applist){
$.each(applist,function(index,app){
$("#app").append("<option value='"+app.id+"'>"+app.appname+"</option>")
})
}
}
/**
* 获取数据
*/
function getValue(){
return {
appid:$("#app").val(),
url:$("#url").val(),
name:$("#name").val(),
headrow:$("#headrow").val(),
rowSelect:$("input[name='row']:checked").prop("value"),
rowdata:$("#row").val(),
colSelect:$("input[name='col']:checked").prop("value"),
coldata:$("#col").val(),
}
}
/**
* 设置数据
*/
function setValue(data){
console.info(data)
data = JSON.parse(data);
console.info(data);
configData = data;
$("#app").val(data.appid)
$("#url").val(data.url)
$("#name").val(data.name)
$("#headrow").val(data.headrow)
var rowSelect = data.rowSelect;
if(rowSelect == "custom"){
$("#custom").attr("checked",true);
$("#row").removeAttr("disabled");
$("#row").val(data.rowdata)
}
var colSelect = data.colSelect;
if(colSelect == "colcustom"){
$("#colcustom").attr("checked",true);
$("#col").removeAttr("disabled");
$("#col").val(data.coldata)
}
}
/**
* 获取启用的应用数据
* @param param
* @returns {{count, page: (boolean|number|*), items: {}}}
*/
function getApp(){
var result = {};
$.ajax({
type:"get",
async:false,
url:"/webroot/decision/fsds/getAll",
xhrFields:{
withCredentials:true
},
success:function(data){
result = JSON.parse(data.data);
},
error:function(data){
}
})
return result;
}
/**
* 获取多维表数据
* @param param
* @returns {{count, page: (boolean|number|*), items: {}}}
*/
function getDWBData(){
var data = getValue();
var result = {};
$.ajax({
type:"post",
async:true,
url:"/webroot/decision/fsds/getSheet",
xhrFields:{
withCredentials:true
},
data:JSON.stringify(data),
contentType:"application/json",
success:function(data){
result = JSON.parse(data.data);
},
error:function(data){
}
})
return result;
}
/**
* 校验必填参数
*/
function validate(){
var result = false;
var appid=$("#app").val();
var url=$("#url").val();
var name=$("#name").val();
if(appid && url && name){
result = true;
}else{
alert("请先填写配置信息");
}
return result;
}
/**
* 打开加载
*/
function openLayer(){
var height = window.innerHeight/2+"px";
var width = window.innerWidth/2+"px";
var index = layer.load(2,{
offset:[height,width]
});
}
</script>
</body>
</html>

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/bi/feishu.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

5
src/main/resources/com/eco/plugin/shsytzfsds/js/bi/publicds.css

@ -0,0 +1,5 @@
#test {
background-color: #77ee77;
width: 500px;
height: 500px;
}

34
src/main/resources/com/eco/plugin/shsytzfsds/js/bi/publicds.js

@ -0,0 +1,34 @@
function render(data, config, saveFn, closeFn) {
console.log('data:', data);
console.log('config:', config);
var iframe = document.getElementById('publicds').contentWindow;
iframe.document.getElementById("cancel").onclick = function(){
closeFn();
}
iframe.document.getElementById("ok").onclick = function(){
iframe.openLayer();
var data = iframe.getValue();
data = JSON.stringify(data);
if(iframe.validate()){
saveFn({
transferName:JSON.parse(data).name,
jsonContext:data
}).then(function(res){
console.log(res);
if(res.code == 200){
closeFn();
}
});
}
}
if(data){
iframe.setValue(data.jsonContext);
}
}
new BIPlugin().init(render);

4
src/main/resources/com/eco/plugin/shsytzfsds/js/jquery/jquery-2.1.3.min.js vendored

File diff suppressed because one or more lines are too long

1484
src/main/resources/com/eco/plugin/shsytzfsds/js/jquery/jquery.tool.js

File diff suppressed because it is too large Load Diff

1
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/layui.css

File diff suppressed because one or more lines are too long

1
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/code.css

@ -0,0 +1 @@
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-view{display:block;position:relative;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#fafafa;color:#333;font-family:Courier New;font-size:13px}.layui-code-title{position:relative;padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee;font-size:12px}.layui-code-title>.layui-code-about{position:absolute;right:10px;top:0;color:#b7b7b7}.layui-code-about>a{padding-left:10px}.layui-code-view>.layui-code-ol,.layui-code-view>.layui-code-ul{position:relative;overflow:auto}.layui-code-view>.layui-code-ol>li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view>.layui-code-ol>li:first-child,.layui-code-view>.layui-code-ul>li:first-child{padding-top:10px}.layui-code-view>.layui-code-ol>li:last-child,.layui-code-view>.layui-code-ul>li:last-child{padding-bottom:10px}.layui-code-view>.layui-code-ul>li{position:relative;line-height:20px;padding:0 10px;list-style-type:none;*list-style-type:none;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-dark{border:1px solid #0c0c0c;border-left-color:#3f3f3f;background-color:#0c0c0c;color:#c2be9e}.layui-code-dark>.layui-code-title{border-bottom:none}.layui-code-dark>.layui-code-ol>li,.layui-code-dark>.layui-code-ul>li{background-color:#3f3f3f;border-left:none}.layui-code-dark>.layui-code-ul>li{margin-left:6px}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}

1
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/laydate/default/laydate.css

File diff suppressed because one or more lines are too long

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/icon-ext.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

1
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/layer.css

File diff suppressed because one or more lines are too long

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-0.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-1.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-2.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.eot

Binary file not shown.

554
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 299 KiB

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.ttf

Binary file not shown.

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.woff

Binary file not shown.

BIN
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.woff2

Binary file not shown.

10543
src/main/resources/com/eco/plugin/shsytzfsds/js/layui/layui.js vendored

File diff suppressed because it is too large Load Diff

1789
src/main/resources/com/eco/plugin/shsytzfsds/js/ui.js

File diff suppressed because it is too large Load Diff

382
src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTable.js

@ -0,0 +1,382 @@
!(function () {
var Model = BI.inherit(Fix.Model, {
_init: function () {
this.service = BI.Services.getService("dec.service.data.set");
},
context: ["dataSetName", "ableSave"],
state: function () {
var val = this.options.value.datasetData || {};
return {
config : val.config || "",
parameters: val.parameters || []
};
},
childContext: ["previewAble", "previewedDataSet"],
watch: {
previewAble: function (v) {
this.setAbleSave(v);
}
},
computed: {
paramHeader: function () {
//定义参数列表表头
var map = BI.map(BI.Constants.getConstant("dec.constants.data.set.sql.header"), function (i, v) {
return BI.extend({
textAlign: "left",
height: 30,
hgap: 10
}, v);
});
map.push({
textAlign: "left",
height: 30,
hgap: 10,
text: ""
});
return [map];
},
paramItems: function () {
var self = this;
return BI.map(this.model.parameters, function (i, param) {
return [{
type: "bi.text_editor",
value: param.name,
textAlign: "left",
height: 30,
lgap: 10,
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: function () {
self.setParamName(i, this.getValue());
}
}]
}, {
type: "bi.icon_text_value_combo",
cls: "field-type-change",
height: 30,
items: BI.Constants.getConstant("dec.constants.data.set.sql.field"),
value: param.type,
listeners: [{
eventName: BI.IconTextValueCombo.EVENT_CHANGE,
action: function () {
self.setParamType(i, this.getValue()[0]);
}
}]
}, self.service.createParameterValueItem(param, function (val) {
self.setParamValue(i, val);
}),{
type: "bi.icon_button",
cls: "default-delete-font",
height: 30,
lgap: 10,
title: BI.i18nText("Dec-Basic_Delete"),
handler: function () {
self.deleteParameter(i);
}
}];
});
},
previewAble: function () {
return BI.isNotEmptyString(this.model.config);
},
previewedDataSet: function () {
return {
datasetType: DecCst.DataSet.Type.DEMO_DATA,
datasetName: this.model.dataSetName,
datasetData: {
config: this.model.config,
parameters: this.model.parameters
}
};
}
},
actions: {
initPage: function (cb) {
var self = this;
cb();
},
setConfig: function(v){
this.model.config = v;
},
refreshParam: function () {
var self = this;
Dec.Utils.getDataSetParameters(this.model.previewedDataSet, function (res) {
self.model.parameters = self.service.getParameters(res.data, self.model.parameters);
});
},
addParamter:function(v){
this.model.parameters.push(v);
},
deleteParameter:function(index){
this.model.parameters.splice(index, 1);
},
setParamName: function (index, name) {
this.model.parameters[index].name = name;
},
setParamType: function (index, type) {
if (this.model.parameters[index].type !== type) {
this.model.parameters[index].type = type;
this.model.parameters[index].value = this.service.getDefaultValueByType(type);
this.model.parameters.splice(0, 0);
}
},
setParamValue: function (index, val) {
this.model.parameters[index].value = val;
},
setAbleSave: function (v) {
this.model.ableSave = v;
}
}
});
BI.model("dec.model.data.set.type.sync.data", Model);
var DemoData = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-data-set-sql",
$testId: "dec-data-set-sql",
value: {
datasetData: {}
}
},
_store: function () {
return BI.Models.getModel("dec.model.data.set.type.sync.data", this.options);
},
watch: {
config: function (v) {
this.configEditor.setValue(v);
},
"config || parameters.**": function () {
this.previewPane.resetPreview();
},
parameters: function () {
// this.paramSettingPane.populate(this.model.paramItems, this.model.paramHeader);
}
},
beforeInit: function (cb) {
this.store.initPage(cb);
},
render: function () {
var self = this;
self.store.setConfig("1");
var feishuApp = getFeishuApp();
var parameter = this.model.parameters;
var appid = "";
var url = "";
$.each(parameter,function(index,item){
if(item.name == 'appid'){
appid = item.value;
}
if(item.name == 'url'){
url = item.value;
}
})
return {
type: "bi.htape",
items: [
//左侧的配置界面
{
el: {
type: "bi.vtape",
items: [
{
type: "bi.left",
height:25,
items: [
{
type: "bi.label",
text:"飞书应用",
textHeight:25,
textAlign:"left",
css:{"font-weight":"bold","color":"black"},
width:100,
rgap:10
},{
type: "bi.text_value_combo",
text: "",
value: appid,
width: 200,
allowClear: true,
height: 24,
items: feishuApp,
ref:function(obj){
self.checkbox = obj;
},
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
var appid = self.checkbox.getValue()[0];
var url =self.url.getValue();
self.model.parameters = [{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}]
}
}],
}
]
},
{
type:"dec.wink.item",
text:"多维表url",
value:url,
ref:function(obj){
self.url = obj
},
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
var appid = self.checkbox.getValue()[0];
var url =self.url.getValue();
self.model.parameters = [{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}]
}
}],
}
],
lgap: 10,
vgap: 15
},
width: 410,
lgap: 10,
vgap: 15
},
//右侧的预览界面
{
el: {
type: "bi.absolute",
cls: "bi-sortable-holder",
items: [{
el: {
type: "dec.data.set.preview",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
self.store.refreshParam();
self.previewPane.previewData();
}
}],
ref: function (_ref) {
self.previewPane = _ref;
}
}, top: 10, right: 10, bottom: 10, left: 10
}]
},
hgap: 10,
vgap: 15
}
]
};
},
getValue: function () {
var appid = this.checkbox.getValue()[0];
var url =this.url.getValue();
return {
config: this.model.config,
parameters: [{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}]
};
}
});
BI.shortcut("dec.data.set.type.sync.data", DemoData);
$.extend(DecCst.DataSet.Type,{DEMO_DATA:"飞书多维表数据集"});
BI.config("dec.provider.data.set", function (provider) {
provider.registerDataSetType({
value: DecCst.DataSet.Type.DEMO_DATA,
text: "飞书多维表数据集",
cardType: "dec.data.set.type.sync.data",
iconCls: "management-maintenance-cloud-font",
ableSave:true
});
});
})();
//ajax--------------------------------------------------------------------------------------------------
function getFeishuApp(){
var result = {};
$.ajax({
type:"get",
async:false,
url:"decision/fsds/getAll",
xhrFields:{
withCredentials:true
},
success:function(data){
result = JSON.parse(data.data);
},
error:function(data){
}
})
var resultArray = [];
$.each(result,function(index,item){
resultArray.push({"text":item.appname,"value":item.id})
})
return resultArray;
}
//通用组件------------------------------------------------------------------------------------------------
//文字+输入框标题
var e = BI.inherit(BI.Widget, {
props: {
text: "",
value:"",
inputType:"text",
disabled:false
},
render: function () {
var t = this;
return {
type: "bi.left",
height:25,
items: [
{
type: "bi.label",
text:this.options.text,
textHeight:25,
textAlign:"left",
css:{"font-weight":"bold","color":"black"},
width:100,
rgap:10
},{
type: "bi.editor",
allowBlank: true,
value:this.options.value,
width: 200,
height: 25,
cls: "bi-border",
inputType:this.options.inputType,
disabled:this.options.disabled,
validationChecker:function(){
return true;
},
ref:function(ref){
t.input = ref;
},
listeners: [{
eventName: "EVENT_CHANGE",
action: function() {
t.fireEvent("EVENT_CHANGE", "");
}
}]
}
]
}
},
getValue:function(){
return this.input.getValue();
},
setValue:function(value){
this.input.setValue(value)
}
});
BI.shortcut("dec.wink.item", e);

493
src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTableSheet.js

@ -0,0 +1,493 @@
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021-03-29
**/
!(function () {
var Model = BI.inherit(Fix.Model, {
_init: function () {
this.service = BI.Services.getService("dec.service.data.set");
},
context: ["dataSetName", "ableSave"],
state: function () {
var val = this.options.value.datasetData || {};
return {
config : val.config || "",
parameters: val.parameters || []
};
},
childContext: ["previewAble", "previewedDataSet"],
watch: {
previewAble: function (v) {
this.setAbleSave(v);
}
},
computed: {
paramHeader: function () {
//定义参数列表表头
var map = BI.map(BI.Constants.getConstant("dec.constants.data.set.sql.header"), function (i, v) {
return BI.extend({
textAlign: "left",
height: 30,
hgap: 10
}, v);
});
map.push({
textAlign: "left",
height: 30,
hgap: 10,
text: ""
});
return [map];
},
paramItems: function () {
var self = this;
return BI.map(this.model.parameters, function (i, param) {
return [{
type: "bi.text_editor",
value: param.name,
textAlign: "left",
height: 30,
lgap: 10,
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: function () {
self.setParamName(i, this.getValue());
}
}]
}, {
type: "bi.icon_text_value_combo",
cls: "field-type-change",
height: 30,
items: BI.Constants.getConstant("dec.constants.data.set.sql.field"),
value: param.type,
listeners: [{
eventName: BI.IconTextValueCombo.EVENT_CHANGE,
action: function () {
self.setParamType(i, this.getValue()[0]);
}
}]
}, self.service.createParameterValueItem(param, function (val) {
self.setParamValue(i, val);
}),{
type: "bi.icon_button",
cls: "default-delete-font",
height: 30,
lgap: 10,
title: BI.i18nText("Dec-Basic_Delete"),
handler: function () {
self.deleteParameter(i);
}
}];
});
},
previewAble: function () {
return BI.isNotEmptyString(this.model.config);
},
previewedDataSet: function () {
return {
datasetType: DecCst.DataSet.Type.DEMO_DATA2,
datasetName: this.model.dataSetName,
datasetData: {
config: this.model.config,
parameters: this.model.parameters
}
};
}
},
actions: {
initPage: function (cb) {
var self = this;
cb();
},
setConfig: function(v){
this.model.config = v;
},
refreshParam: function () {
var self = this;
Dec.Utils.getDataSetParameters(this.model.previewedDataSet, function (res) {
self.model.parameters = self.service.getParameters(res.data, self.model.parameters);
});
},
addParamter:function(v){
this.model.parameters.push(v);
},
deleteParameter:function(index){
this.model.parameters.splice(index, 1);
},
setParamName: function (index, name) {
this.model.parameters[index].name = name;
},
setParamType: function (index, type) {
if (this.model.parameters[index].type !== type) {
this.model.parameters[index].type = type;
this.model.parameters[index].value = this.service.getDefaultValueByType(type);
this.model.parameters.splice(0, 0);
}
},
setParamValue: function (index, val) {
this.model.parameters[index].value = val;
},
setAbleSave: function (v) {
this.model.ableSave = v;
}
}
});
BI.model("dec.model.data.set.type.sync.data.sheet", Model);
var DemoData = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-data-set-sql",
$testId: "dec-data-set-sql",
value: {
datasetData: {}
}
},
_store: function () {
return BI.Models.getModel("dec.model.data.set.type.sync.data.sheet", this.options);
},
watch: {
config: function (v) {
this.configEditor.setValue(v);
},
"config || parameters.**": function () {
this.previewPane.resetPreview();
},
parameters: function () {
// this.paramSettingPane.populate(this.model.paramItems, this.model.paramHeader);
}
},
beforeInit: function (cb) {
this.store.initPage(cb);
},
render: function () {
var self = this;
self.store.setConfig("1");
var feishuApp = getFeishuApp();
var parameter = this.model.parameters;
var appid = "";
var url = "";
var headrow = 0;
var rowsize = 0;
var columnSize = "A";
$.each(parameter,function(index,item){
if(item.name == 'appid'){
appid = item.value;
}
if(item.name == 'url'){
url = item.value;
}
if(item.name == 'headrow'){
headrow = item.value;
}
if(item.name == 'rowsize'){
rowsize = item.value;
}
if(item.name == 'columnSize'){
columnSize = item.value;
}
})
return {
type: "bi.htape",
items: [
//左侧的配置界面
{
el: {
type: "bi.vtape",
items: [
{
type: "bi.left",
height:25,
items: [
{
type: "bi.label",
text:"飞书应用",
textHeight:25,
textAlign:"left",
css:{"font-weight":"bold","color":"black"},
width:100,
rgap:10
},{
type: "bi.text_value_combo",
text: "",
value: appid,
width: 200,
allowClear: true,
height: 24,
items: feishuApp,
ref:function(obj){
self.checkbox = obj;
},
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
var appid = self.checkbox.getValue()[0];
var url =self.url.getValue();
var headrow = self.headrow.getValue();
var rowsize = self.rowsize.getValue();
var columnSize = self.columnSize.getValue();
self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}
,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize},
]
}
}],
}
]
},
{
type: "bi.absolute",
items:[
{
type:"dec.wink.item",
text:"多维表url",
value:url,
ref:function(obj){
self.url = obj
},
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
var appid = self.checkbox.getValue()[0];
var url =self.url.getValue();
var headrow = self.headrow.getValue();
var rowsize = self.rowsize.getValue();
var columnSize = self.columnSize.getValue();
self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}
,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize},
]
}
}],
},
{
type:"dec.wink.item",
text:"表头行号",
value:headrow,
ref:function(obj){
self.headrow = obj
},
top:40,
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
var appid = self.checkbox.getValue()[0];
var url =self.url.getValue();
var headrow = self.headrow.getValue();
var rowsize = self.rowsize.getValue();
var columnSize = self.columnSize.getValue();
self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}
,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize},
]
}
}],
},
{
type:"dec.wink.item",
text:"截止行号",
value:rowsize,
ref:function(obj){
self.rowsize = obj
},
top:80,
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
var appid = self.checkbox.getValue()[0];
var url =self.url.getValue();
var headrow = self.headrow.getValue();
var rowsize = self.rowsize.getValue();
var columnSize = self.columnSize.getValue();
self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}
,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize},
]
}
}],
},
{
type:"dec.wink.item",
text:"截止列名",
value:columnSize,
ref:function(obj){
self.columnSize = obj
},
top:120,
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
var appid = self.checkbox.getValue()[0];
var url =self.url.getValue();
var headrow = self.headrow.getValue();
var rowsize = self.rowsize.getValue();
var columnSize = self.columnSize.getValue();
self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}
,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize},
]
}
}],
}
]
},
],
lgap: 10,
vgap: 15
},
width: 410,
lgap: 10,
vgap: 15
},
//右侧的预览界面
{
el: {
type: "bi.absolute",
cls: "bi-sortable-holder",
items: [{
el: {
type: "dec.data.set.preview",
listeners: [{
eventName: "EVENT_CHANGE",
action: function () {
self.store.refreshParam();
self.previewPane.previewData();
}
}],
ref: function (_ref) {
self.previewPane = _ref;
}
}, top: 10, right: 10, bottom: 10, left: 10
}]
},
hgap: 10,
vgap: 15
}
]
};
},
getValue: function () {
var appid = this.checkbox.getValue()[0];
var url =this.url.getValue();
var headrow = this.headrow.getValue();
var rowsize = this.rowsize.getValue();
var columnSize = this.columnSize.getValue();
return {
config: this.model.config,
parameters: [{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}
,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize},
]
};
}
});
BI.shortcut("dec.data.set.type.sync.data.sheet", DemoData);
$.extend(DecCst.DataSet.Type,{DEMO_DATA2:"飞书表格单sheet数据集"});
BI.config("dec.provider.data.set", function (provider) {
provider.registerDataSetType({
value: DecCst.DataSet.Type.DEMO_DATA2,
text: "飞书表格单sheet数据集",
cardType: "dec.data.set.type.sync.data.sheet",
iconCls: "management-maintenance-cloud-font",
ableSave:true
});
});
})();
//ajax--------------------------------------------------------------------------------------------------
function getFeishuApp(){
var result = {};
$.ajax({
type:"get",
async:false,
url:"decision/fsds/getAll",
xhrFields:{
withCredentials:true
},
success:function(data){
result = JSON.parse(data.data);
},
error:function(data){
}
})
var resultArray = [];
$.each(result,function(index,item){
resultArray.push({"text":item.appname,"value":item.id})
})
return resultArray;
}
//通用组件------------------------------------------------------------------------------------------------
//文字+输入框标题
var e = BI.inherit(BI.Widget, {
props: {
text: "",
value:"",
inputType:"text",
disabled:false
},
render: function () {
var t = this;
return {
type: "bi.left",
height:25,
items: [
{
type: "bi.label",
text:this.options.text,
textHeight:25,
textAlign:"left",
css:{"font-weight":"bold","color":"black"},
width:100,
rgap:10
},{
type: "bi.editor",
allowBlank: true,
value:this.options.value,
width: 200,
height: 25,
cls: "bi-border",
inputType:this.options.inputType,
disabled:this.options.disabled,
validationChecker:function(){
return true;
},
ref:function(ref){
t.input = ref;
},
listeners: [{
eventName: "EVENT_CHANGE",
action: function() {
t.fireEvent("EVENT_CHANGE", "");
}
}]
}
]
}
},
getValue:function(){
return this.input.getValue();
},
setValue:function(value){
this.input.setValue(value)
}
});
BI.shortcut("dec.wink.item", e);
Loading…
Cancel
Save