<?xml version="1.0" encoding="UTF-8"?>
<et:ReportTask xmlns:t="leaf.application.action" xmlns:a="http://www.leaf-framework.org/application" xmlns:et="leaf.plugin.export.task" xmlns:p="uncertain.proc" reportDir="D:/u01/hls_file/task_excel">
	<!--下载报表的权限校验-->
    <p:procedure name="pre-service">
        <p:set field="@success" value="true"/>
        <t:session-copy/>
        <p:switch test="/session/@session_id">
            <p:case Value="*">
                <a:model-query defaultWhereclause="report_id = ${/parameter/@report_id}" fetchAll="true" model="psr.PSR1030.psr_task_reports" rootPath="result"/>
                <p:switch test="/model/result/record">
                    <p:case Value="null">
						<p:set field="/access-check/@status_code" value="unauthorized"/>
                        <t:check-dispatch dispatchUrl="${/request/@context_path}/error_screen_unauthorized.lview" field="/access-check/@status_code" message="没有权限访问指定的页面" value="unauthorized"/>
                    </p:case>
                </p:switch>
            </p:case>
            <p:case>
                <p:set field="/access-check/@status_code" value="login_required"/>
                <t:check-dispatch dispatchUrl="${/request/@context_path}/error_session_expired.lview" field="/access-check/@status_code" message="登录已失效,请重新登录" value="login_required"/>
            </p:case>
        </p:switch>
    </p:procedure>
	<!-- 创建任务模板-->
	<task:async-task xmlns:task="leaf.application.task" bm="db.sys_tasks_pkg.add_task" taskDescription="生成报表" taskName="生成报表" taskType="JAVA">
		<ex:ModelExportTask xmlns:ex="leaf.plugin.export.task"/>
		<!--生成报表后的后续处理,这里是模板,请修改以适应实际情况-->
		<p:switch test="/parameter/@sendToMail">
			<p:case Value="true">
				<mail:AutoSendMail xmlns:mail="leaf.plugin.mail" content="mail" title="test" tto="jinxiao.lin@hand-china.com">
					<attachments>
						<mail:attachment path="${/parameter/@file_path}"/>
					</attachments>
				</mail:AutoSendMail>
				<et:ReportRemove xmlns:et="leaf.plugin.export.task" fullPath="${/parameter/@file_path}"/>
			</p:case>
			<p:case>
				<a:model-insert model="psr.PSR1030.psr_task_reports"/>
			</p:case>
		</p:switch>
     </task:async-task>	
</et:ReportTask>