<?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 academic_background_list_details;
                var marital_status_details;
                var source_of_income_details;
                var first_time_buyer_flag_details;
                var main_driver_of_car_details;
                try {
                    var academic_background_bm = $bm('app.lov.app_hls_academic_background_list');
                    var marital_status_bm = $bm('app.lov.app_hls_marital_status_list');
                    var source_of_income_bm = $bm('app.lov.app_hls_source_of_income_list');
                    var first_time_buyer_flag_bm = $bm('app.lov.app_hls_first_time_buyer_flag_list');
                    var main_driver_of_car_bm = $bm('app.lov.app_hls_main_driver_of_car_list');
                    var academic_background_map = academic_background_bm.queryAsMap();
                    var marital_status_map = marital_status_bm.queryAsMap();
                    var source_of_income_map = source_of_income_bm.queryAsMap();
                    var first_time_buyer_flag_map = first_time_buyer_flag_bm.queryAsMap();
                    var main_driver_of_car_map = main_driver_of_car_bm.queryAsMap();
            
                    academic_background_list_details = academic_background_map.getChildren();
                    marital_status_details = marital_status_map.getChildren();
                    source_of_income_details = source_of_income_map.getChildren();
                    first_time_buyer_flag_details = first_time_buyer_flag_map.getChildren();
                    main_driver_of_car_details = main_driver_of_car_map.getChildren();
            
                    $ctx.parameter.return_status = 'S';
                    $ctx.parameter.return_message = '执行成功';
                } catch (e) {
                    $ctx.parameter.return_status = 'E';
                    $ctx.parameter.return_message = String(e);
                }
            
            
                var result = {
                    result: $ctx.parameter.return_status,
                    message: $ctx.parameter.return_message,
                    academic_background_list: [],
                    marital_status_list: [],
                    source_of_income_list: [],
                    first_time_buyer_flag_list: [],
                    main_driver_of_car_list: []
                };
            
                var academic_background_list = result.academic_background_list;
                var marital_status_list = result.marital_status_list;
                var source_of_income_list = result.source_of_income_list;
                var first_time_buyer_flag_list = result.first_time_buyer_flag_list;
                var main_driver_of_car_list = result.main_driver_of_car_list;
            
                if (academic_background_list_details) {
                    for (var i = 0;i < academic_background_list_details.length;i++) {
                        var academic_background_list_detail = academic_background_list_details[i];
                        academic_background_list.push({
                            "code": academic_background_list_detail.code,
                            "name": academic_background_list_detail.name
                        });
                    }
                }
            
                if (marital_status_details) {
                    for (var j = 0;j < marital_status_details.length;j++) {
                        var marital_status_detail = marital_status_details[j];
                        marital_status_list.push({
                            "code": marital_status_detail.code,
                            "name": marital_status_detail.name
                        });
                    }
                }
            
                if (source_of_income_details) {
                    for (var m = 0;m < source_of_income_details.length;m++) {
                        var source_of_income_detail = source_of_income_details[m];
                        source_of_income_list.push({
                            "code": source_of_income_detail.code,
                            "name": source_of_income_detail.name
                        });
                    }
                }
                if (first_time_buyer_flag_details) {
                    for (var n = 0;n < first_time_buyer_flag_details.length;n++) {
                        var first_time_buyer_flag_detail = first_time_buyer_flag_details[n];
                        first_time_buyer_flag_list.push({
                            "code": first_time_buyer_flag_detail.code,
                            "name": first_time_buyer_flag_detail.name
                        });
                    }
                }
                if (main_driver_of_car_details) {
                    for (var n = 0;n < main_driver_of_car_details.length;n++) {
                        var main_driver_of_car_detail = main_driver_of_car_details[n];
                        main_driver_of_car_list.push({
                            "code": main_driver_of_car_detail.code,
                            "name": main_driver_of_car_detail.name
                        });
                    }
                }
                $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>
