<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="ZJ_WFL_WORKFLOW">
    <bm:fields>
        <bm:field name="workflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WORKFLOW_ID" prompt="ZJ_WFL_WORKFLOW.WORKFLOW_ID"/>
        <bm:field name="workflow_code" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="WORKFLOW_CODE" prompt="工作流代码" queryWidth="80"/>
        <bm:field name="workflow_desc" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="WORKFLOW_DESC" prompt="工作流描述" queryWidth="130"/>
        <bm:field name="workflow_type_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WORKFLOW_TYPE_ID" prompt="ZJ_WFL_WORKFLOW.WORKFLOW_TYPE_ID"/>
        <bm:field name="workflow_type_code" forInsert="false" forUpdate="false"/>
        <bm:field name="workflow_type_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="sub_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUB_CATEGORY" prompt="ZJ_WFL_WORKFLOW.SUB_CATEGORY"/>
        <bm:field name="sub_category_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="ZJ_WFL_WORKFLOW.ENABLED_FLAG"/>
        <bm:field name="can_cancel" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CAN_CANCEL" prompt="是否可收回"/>
        <bm:field name="enabled_flag_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="display_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DISPLAY_MY_SUB_TYPE" prompt="ZJ_WFL_WORKFLOW.DISPLAY_MY_SUB_TYPE"/>
        <bm:field name="display_service_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DISPLAY_MY_SUB_SERVICE_ID" prompt="ZJ_WFL_WORKFLOW.DISPLAY_MY_SUB_SERVICE_ID"/>
        <bm:field name="display_service_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="display_service_name" forInsert="false" forUpdate="false"/>
        <bm:field name="show_approve_history_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SHOW_APPROVE_HISTORY_FLAG" prompt="ZJ_WFL_WORKFLOW.SHOW_APPROVE_HISTORY_FLAG"/>
        <bm:field name="show_all_approve_ht_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SHOW_ALL_APPROVE_HT_FLAG" prompt="ZJ_WFL_WORKFLOW.SHOW_ALL_APPROVE_HT_FLAG"/>
        <bm:field name="serial_number" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SERIAL_NUMBER" prompt="序号"/>
        <bm:field name="is_archive" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="IS_ARCHIVE" />
        <bm:field name="is_archive_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="archive_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ARCHIVE_TYPE" />
        <bm:field name="archive_type_desc" forInsert="false" forUpdate="false"/>

    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			select t1.workflow_id,
				       t1.workflow_code,
				       t1.workflow_desc,
				       t1.workflow_type_id,
				       t1.workflow_type_code,
				       t1.workflow_type_desc,
				       t1.sub_category,
				       t1.sub_category_desc,
				       t1.enabled_flag,
				       t1.can_cancel,
				       t1.enabled_flag_desc,
				       t1.display_type,
				       t1.display_service_id,
				       t1.display_service_desc,
				       t1.display_service_name,
				       t1.show_approve_history_flag,
				       t1.show_all_approve_ht_flag,
				       t1.serial_number,
				       t1.is_archive,
                      t1.archive_type,
                      t1.is_archive_desc,
                      t1.archive_type_desc
				  from zj_wfl_workflow_v t1
				  #WHERE_CLAUSE#
				  order by t1.serial_number,t1.workflow_type_code,t1.workflow_code
    		]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
            begin
				zj_wfl_workflow_pkg.delete_wfl_workflow
				(
					p_workflow_id        	  => ${@workflow_id},					
					p_user_id                 => ${/session/@user_id}
				);
			end;
			]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="workflow_id" input="true" inputPath="@workflow_id" output="true" outputPath="@workflow_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
	            begin
					 zj_wfl_workflow_pkg.workflow_handle(p_sql_type						=> 'INSERT',
					 									 p_workflow_id      			=> ${@workflow_id},
										                 p_workflow_code    			=> ${@workflow_code},
										                 p_workflow_desc    			=> ${@workflow_desc},
										                 p_workflow_type_id 			=> ${@workflow_type_id},
										                 p_sub_category     			=> ${@sub_category},
										                 p_enabled_flag     			=> ${@enabled_flag},
										                 p_can_cancel     				=> ${@can_cancel},
										                 p_display_type      			=> ${@display_type},
										                 p_display_service_id			=> ${@display_service_id},
										                 p_show_approve_history_flag	=> ${@show_approve_history_flag},
										                 p_show_all_approve_ht_flag		=> ${@show_all_approve_ht_flag},
										                 p_serial_number				=> ${@serial_number},
                                                         p_is_archive                   => ${@is_archive},
                                                         p_archive_type                 => ${@archive_type},
                                                         p_user_id          			=> ${/session/@user_id});
			
				end;
			]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
		   		begin
					 zj_wfl_workflow_pkg.workflow_handle(p_sql_type						=> 'UPDATE',
					 									 p_workflow_id      			=> ${@workflow_id},
										                 p_workflow_code    			=> ${@workflow_code},
										                 p_workflow_desc    			=> ${@workflow_desc},
										                 p_workflow_type_id 			=> ${@workflow_type_id},
										                 p_sub_category     			=> ${@sub_category},
										                 p_enabled_flag     			=> ${@enabled_flag},
										                 p_can_cancel     				=> ${@can_cancel},
										                 p_display_type      			=> ${@display_type},
										                 p_display_service_id			=> ${@display_service_id},
										                 p_show_approve_history_flag	=> ${@show_approve_history_flag},
										                 p_show_all_approve_ht_flag		=> ${@show_all_approve_ht_flag},
										                 p_serial_number				=> ${@serial_number},
                                                         p_is_archive                   => ${@is_archive},
                                                         p_archive_type                 => ${@archive_type},
                                                        p_user_id          			=> ${/session/@user_id});
			
				end;
			]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="workflow_id" queryOperator="="/>
        <bm:query-field field="workflow_code" queryOperator="like"/>
        <bm:query-field field="workflow_type_id" queryOperator="like"/>
        <bm:query-field field="workflow_desc" queryOperator="like"/>
        <bm:query-field field="sub_category" queryOperator="="/>
        <bm:query-field field="enabled_flag" queryOperator="="/>
    </bm:query-fields>
    <!-- <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="exists             (select 1 from  zj_wfl_workflow_node t,zj_wfl_workflow_assign_rule r,exp_emp_assign_e_v ex where t.workflow_id=t1.WORKFLOW_ID            and r.assign_source_id=t.node_id and r.company_id=${/session/@company_id} and r.approval_rule=&apos;APPOINTED_COM_POS&apos;         and ex.user_id=${/session/@user_id} )"/>
    </bm:data-filters> -->
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="workflow_id"/>
    </bm:primary-key>
</bm:model>
