pioneer
2 years ago
commit
c6a584ed54
12 changed files with 229 additions and 0 deletions
@ -0,0 +1,6 @@ |
|||||||
|
# open-JSD-11676 |
||||||
|
|
||||||
|
JSD-11676 定时调度分sheet导出数据\ |
||||||
|
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||||
|
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||||
|
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,26 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<plugin> |
||||||
|
<id>com.fr.plugin.akfgp.job</id> |
||||||
|
<name><![CDATA[定时调度Sheet导出_EK]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>1.0.2</version> |
||||||
|
<env-version>11.0~11.0</env-version> |
||||||
|
<jartime>2021-10-19</jartime> |
||||||
|
<vendor>fr.open</vendor> |
||||||
|
<description><![CDATA[定时调度Sheet导出]]></description> |
||||||
|
<change-notes><![CDATA[ |
||||||
|
[2022-12-18]JSD-11676插件初始化<br/> |
||||||
|
]]></change-notes> |
||||||
|
<main-package>com.fr.plugin.akfgp</main-package> |
||||||
|
<prefer-packages> |
||||||
|
<prefer-package>com.fanruan.api.*</prefer-package> |
||||||
|
</prefer-packages> |
||||||
|
<lifecycle-monitor class="com.fr.plugin.akfgp.PluginMonitor"/> |
||||||
|
<extra-decision> |
||||||
|
<WebResourceProvider class="com.fr.plugin.akfgp.decision.DecisionResourceProvider"/> |
||||||
|
</extra-decision> |
||||||
|
<extra-schedule> |
||||||
|
<OutputFormatProvider class="com.fr.plugin.akfgp.format.OutputExcelPlus"/> |
||||||
|
</extra-schedule> |
||||||
|
<function-recorder class="com.fr.plugin.akfgp.LocaleFinder"/> |
||||||
|
</plugin> |
@ -0,0 +1,41 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: PluginMonitor |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/12/18 20:10 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.akfgp; |
||||||
|
|
||||||
|
import com.fr.plugin.akfgp.format.OutputExcelPlus; |
||||||
|
import com.fr.plugin.context.PluginContext; |
||||||
|
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||||
|
import com.fr.schedule.extension.report.job.output.BaseOutputFormat; |
||||||
|
import com.fr.schedule.extension.report.job.output.OutputExcel; |
||||||
|
|
||||||
|
import static com.fr.plugin.akfgp.format.OutputExcelPlus.CONVERT_TO_EXCEL_PLUS; |
||||||
|
import static com.fr.schedule.extension.report.job.output.OutputExcel.CONVERT_TO_EXCEL; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <PluginMonitor> |
||||||
|
* |
||||||
|
* @author xx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class PluginMonitor extends AbstractPluginLifecycleMonitor { |
||||||
|
public PluginMonitor() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterRun(PluginContext pluginContext) { |
||||||
|
BaseOutputFormat.removeOutputFormat(CONVERT_TO_EXCEL_PLUS); |
||||||
|
BaseOutputFormat.registerOutputFormat(new OutputExcelPlus()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beforeStop(PluginContext pluginContext) { |
||||||
|
BaseOutputFormat.removeOutputFormat(CONVERT_TO_EXCEL); |
||||||
|
BaseOutputFormat.registerOutputFormat(new OutputExcel()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: DecisionAtom |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/4/25 15:50 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.akfgp.decision; |
||||||
|
|
||||||
|
import com.fr.web.struct.Component; |
||||||
|
import com.fr.web.struct.Filter; |
||||||
|
import com.fr.web.struct.browser.RequestClient; |
||||||
|
import com.fr.web.struct.category.ScriptPath; |
||||||
|
|
||||||
|
public class DecisionAtom extends Component { |
||||||
|
public static final DecisionAtom KEY = new DecisionAtom(); |
||||||
|
|
||||||
|
@Override |
||||||
|
public ScriptPath script(RequestClient requestClient) { |
||||||
|
return ScriptPath.build("/com/fr/plugin/akfgp/web/akfgp.js"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Filter filter() { |
||||||
|
return new Filter() { |
||||||
|
@Override |
||||||
|
public boolean accept() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: DecisionResourceProvider |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/4/25 15:50 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.akfgp.decision; |
||||||
|
|
||||||
|
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||||
|
import com.fr.decision.web.MainComponent; |
||||||
|
import com.fr.web.struct.Atom; |
||||||
|
|
||||||
|
public class DecisionResourceProvider extends AbstractWebResourceProvider { |
||||||
|
@Override |
||||||
|
public Atom attach() { |
||||||
|
return MainComponent.KEY; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Atom client() { |
||||||
|
return DecisionAtom.KEY; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,92 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starterBI |
||||||
|
* FileName: OutputExcelPlus |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/11/15 21:26 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.akfgp.format; |
||||||
|
|
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.intelli.record.Original; |
||||||
|
import com.fr.io.TemplateWorkBookIO; |
||||||
|
import com.fr.io.exporter.PageExcelExporter; |
||||||
|
import com.fr.main.TemplateWorkBook; |
||||||
|
import com.fr.main.workbook.PageWorkBook; |
||||||
|
import com.fr.main.workbook.ResultWorkBook; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
import com.fr.report.core.ReportUtils; |
||||||
|
import com.fr.report.report.PageReport; |
||||||
|
import com.fr.schedule.extension.report.job.output.OutputExcel; |
||||||
|
import com.fr.stable.PageActor; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
import com.fr.web.core.SessionPoolManager; |
||||||
|
import com.fr.web.core.TemplateSessionIDInfo; |
||||||
|
|
||||||
|
import java.io.OutputStream; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import static com.fr.plugin.akfgp.format.OutputExcelPlus.PLUGIN_ID; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <OutputExcelPlus> |
||||||
|
* |
||||||
|
* @author xx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@EnableMetrics |
||||||
|
@Authorize(callSignKey = PLUGIN_ID) |
||||||
|
public class OutputExcelPlus extends OutputExcel { |
||||||
|
public static final String PLUGIN_ID = "com.fr.plugin.akfgp.job"; |
||||||
|
public static final int CONVERT_TO_EXCEL_PLUS = 4096; |
||||||
|
public static final String SESSIONID = "SESSIONID"; |
||||||
|
|
||||||
|
public OutputExcelPlus() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getFormat() { |
||||||
|
return CONVERT_TO_EXCEL_PLUS; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getFileSuffix() { |
||||||
|
return ".xlsx"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Focus(id = PLUGIN_ID, text = "Plugin-akfgp", source = Original.PLUGIN) |
||||||
|
public void flush(OutputStream out, ResultWorkBook result) throws Exception { |
||||||
|
LogKit.info("akfgp-OutputExcelPlus output start ..."); |
||||||
|
try { |
||||||
|
//定时调度配置的参数
|
||||||
|
Map<String, Object> parameterMap = result.getExecuteParameters(); |
||||||
|
String sheetParamName = parameterMap.get("paramName").toString(); |
||||||
|
String sheetParamValue; |
||||||
|
if (parameterMap.containsKey("paramValue")) { |
||||||
|
sheetParamValue = parameterMap.get("paramValue").toString(); |
||||||
|
} else { |
||||||
|
sheetParamValue = parameterMap.get(sheetParamName).toString(); |
||||||
|
} |
||||||
|
String[] sheetParams = sheetParamValue.split(","); |
||||||
|
String sessionID = parameterMap.get(SESSIONID).toString(); |
||||||
|
TemplateSessionIDInfo sessionIDInfo = SessionPoolManager.getSessionIDInfor(sessionID, TemplateSessionIDInfo.class); |
||||||
|
String tplPath = sessionIDInfo.getRelativePath(); |
||||||
|
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(tplPath); |
||||||
|
result.removeReport(0); |
||||||
|
for (String sheetParam : sheetParams) { |
||||||
|
parameterMap.put(sheetParamName, sheetParam); |
||||||
|
PageWorkBook pageWorkBook = (PageWorkBook) workbook.execute(parameterMap, new PageActor()); |
||||||
|
PageReport pageReport = pageWorkBook.getPageReport(0); |
||||||
|
result.addReport(sheetParam, pageReport); |
||||||
|
} |
||||||
|
PageExcelExporter excelExport = new PageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(result)); |
||||||
|
excelExport.export(out, result); |
||||||
|
out.close(); |
||||||
|
} catch (Exception e) { |
||||||
|
LogKit.error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue