Browse Source

扩展单元格上传

pull/1/head
richie 6 years ago
parent
commit
7957218d21
  1. 3
      plugin.xml
  2. 51
      src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java

3
plugin.xml

@ -2,12 +2,13 @@
<id>com.fr.plugin.file.submit.oss</id>
<name><![CDATA[文件上传下载(OSS)]]></name>
<active>yes</active>
<version>1.3</version>
<version>2.0</version>
<env-version>10.0</env-version>
<jartime>2018-11-02</jartime>
<vendor>author</vendor>
<description><![CDATA[文件上传至阿里云的OSS中。]]></description>
<change-notes><![CDATA[
[2018-11-21]修复扩展单元格无法正确上传文件的问题。<br/>
[2018-11-06]提供函数OssFile2Image,可以将OSS中的图片文件展示到报表中。<br/>
[2018-11-05]JavaScript事件中可以使用改插件。<br/>
[2018-11-05]下载无法使用$$$的问题。<br/>

51
src/main/java/com/fr/plugin/file/submit/oss/job/OssSubmitJob.java

@ -7,12 +7,24 @@ import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.file.submit.oss.conf.FileSubmitOssServerConfig;
import com.fr.plugin.file.submit.oss.fun.OssConstants;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTarget;
import com.fr.plugin.file.submit.oss.fun.OssSubmitTargetConfig;
import com.fr.plugin.file.submit.oss.fun.OssUpload;
import com.fr.plugin.file.submit.oss.fun.OssVariableValue;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.report.worksheet.CalculatableResWorkSheet;
import com.fr.script.Calculator;
import com.fr.stable.ColumnRow;
import com.fr.stable.ColumnRowRelated;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.write.DBWriteAction;
import com.fr.write.DMLReport;
import com.fr.write.cal.WB;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* 提交到OSS的任务
@ -39,12 +51,47 @@ public class OssSubmitJob extends AbstractSubmitTask {
@Override
@Focus(id = "com.fr.plugin.file.submit.oss", text = "Plugin-File_Submit_OSS", source = Original.PLUGIN)
public void doJob(Calculator calculator) throws Exception {
public void doJob(Calculator ca) throws Exception {
ossClient = new OSSClient(
FileSubmitOssServerConfig.getInstance().getEndPoint(),
FileSubmitOssServerConfig.getInstance().getAccessKeyId(),
FileSubmitOssServerConfig.getInstance().getAccessKeySecret());
OssUpload.upload(calculator, ossClient, submitTargetConfig);
CalculatableResWorkSheet currentReport = ca.getAttribute(DMLReport.KEY);
if (submitTargetConfig != null && currentReport != null) {
ColumnRow[] crs = calculateRelatedColumnRows(submitTargetConfig);
if (currentReport instanceof WB) {
WB wb = (WB) (currentReport);
wb.setCurrentColumnRow(crs, (ColumnRow) ca.getAttribute(ColumnRow.class), ca, new DBWriteAction() {
@Override
public void run(int index, Calculator ca, int groupIdx) throws Exception {
OssUpload.upload(ca, ossClient, submitTargetConfig);
}
@Override
public boolean isDynamic() {
return false;
}
}, -1);
}
}
}
private ColumnRow[] calculateRelatedColumnRows(OssSubmitTargetConfig config) {
Set<ColumnRow> set = new HashSet<ColumnRow>();
OssSubmitTarget[] targets = config.getSubmitTargets();
for (OssSubmitTarget target : targets) {
set.addAll(Arrays.asList(getColumnRowsFromValue(target.getDirectory())));
set.addAll(Arrays.asList(getColumnRowsFromValue(target.getName())));
set.addAll(Arrays.asList(getColumnRowsFromValue(target.getFile())));
}
return set.toArray(new ColumnRow[0]);
}
private ColumnRow[] getColumnRowsFromValue(OssVariableValue value) {
if (value != null && value.getValue() instanceof ColumnRowRelated) {
return ((ColumnRowRelated) value.getValue()).getRelatedColumnRows();
}
return new ColumnRow[0];
}
@Override

Loading…
Cancel
Save