<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:ns1="leaf.application.action" xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
    <a:init-procedure>
        <s:server-script import="app/app_login_check.js"><![CDATA[
            function lov_query() {
                var lov_list_details;
                try {
                    var lov_list_bm = $bm('app.lov.app_prj_project');
                    if (!$ctx.parameter.creation_date) {
                        $ctx.parameter.creation_date = null;
                    }
                    if (!$ctx.parameter.project_number) {
                        $ctx.parameter.project_number = null;
                    }
                    if (!$ctx.parameter.bp_id_tenant_n) {
                        $ctx.parameter.bp_id_tenant_n = null;
                    }
                    if (!$ctx.parameter.bp_id_tenant_n) {
                        $ctx.parameter.bp_id_tenant_n = null;
                    }
                    var lov_list_map = lov_list_bm.queryAsMap({
                        project_number: $ctx.parameter.project_number,
                        bp_name: $ctx.parameter.bp_id_tenant_n,
                        creation_date: $ctx.parameter.creation_date,
                        user_id: $ctx.parameter.user_id
                    });
                    lov_list_details = lov_list_map.getChildren();
                    $ctx.parameter.return_status = 'S';
                    $ctx.parameter.return_message = '执行成功';
                } catch (e) {
                    $ctx.success = "true";
                    $ctx.parameter.return_status = 'E';
                    $ctx.parameter.return_message = String(e);
                }
            
            
                var result = {
                    result: $ctx.parameter.return_status,
                    message: $ctx.parameter.return_message,
                    prj_list: []
                };
                var prj_list = result.prj_list;
                if (lov_list_details) {
                    for (var i = 0;i < lov_list_details.length;i++) {
                        var lov_list_detail = lov_list_details[i];
                        prj_list.push({
                            "project_number": lov_list_detail.project_number,
                            "bp_id_tenant_n": lov_list_detail.bp_name,
                            "project_id": String(lov_list_detail.project_id),
                            "creation_date": String(lov_list_detail.creation_date),
                            "project_status": lov_list_detail.project_status,
                            "project_status_n": lov_list_detail.project_status_n
                        });
                    }
                }
            
                $ctx.parameter.json = JSON.stringify(result);
            }
            
           if ($ctx.parameter.return_status != 'E'&& $ctx.parameter.return_status != 'TIMEOUT') {
                lov_query();
            }
        ]]></s:server-script>
    </a:init-procedure>
    <a:service-output output="/parameter/@json"/>
</a:service>
