<?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 bp_class_list_details;
                var business_type_details;
                var division_details;
                try {
                    var bp_class_list_bm = $bm('app.lov.app_hls_bp_class_list');
                    var business_type_bm = $bm('app.lov.app_hls_business_type_list');
                    var division_bm = $bm('app.lov.app_hls_division_list');
                    var car_type_bm = $bm('app.lov.app_hls_car_type_list');
                    var bp_class_list_map = bp_class_list_bm.queryAsMap();
                    var business_type_map = business_type_bm.queryAsMap();
                    var division_map = division_bm.queryAsMap();
                    var car_type_map = car_type_bm.queryAsMap();
                    bp_class_list_details = bp_class_list_map.getChildren();
                    business_type_details = business_type_map.getChildren();
                    division_details = division_map.getChildren();
                    car_type_details = car_type_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,
                    bp_class_list: [],
                    business_type_list: [],
                    division_list: [],
                    car_type_list: []
                };
                var bp_class_list = result.bp_class_list;
                var business_type_list = result.business_type_list;
                var division_list = result.division_list;
                var car_type_list = result.car_type_list;
            
                for (var i = 0;i < bp_class_list_details.length;i++) {
                    var bp_class_list_detail = bp_class_list_details[i];
                    bp_class_list.push({
                        "code": bp_class_list_detail.code,
                        "name": bp_class_list_detail.name
                    });
                }
                for (var j = 0;j < business_type_details.length;j++) {
                    var business_type_detail = business_type_details[j];
                    business_type_list.push({
                        "code": business_type_detail.code,
                        "name": business_type_detail.name
                    });
                }
                for (var m = 0;m < division_details.length;m++) {
                    var division_detail = division_details[m];
                    division_list.push({
                        "code": division_detail.code,
                        "name": division_detail.name
                    });
                }
                for (var n = 0;n < car_type_details.length;n++) {
                    var car_type_detail = car_type_details[n];
                    car_type_list.push({
                        "code": car_type_detail.code,
                        "name": car_type_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>
