app_auto_data.lsc 4.31 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: wanghaitao  
$Date: 2016-01-16 下午04:38:31  
$Revision: 1.0  
$Purpose: APP,
-->
<a:service xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" trace="true">
<a:init-procedure>
<s:server-script><![CDATA[
            /**
             *read me
             *1.bm部分需改为相应系统的逻辑,此处逻辑为hr系统,仅供参考
             *2.session、cookie部分不用修改,如果出现session、cookie方面的问题,可检查此处的session、cookie(如'/session/@session_id'是否有值)
             *3.调试函数:println(Object);会将Object打印在控制台(如应用服务器tomcat的控制台)。例如:println($session.toXML());会将session对象以xml格式打印出来。
             */
             try {
                var result,
                hls_car_brand_bm,
                hls_car_brand_records,
                brands_len,
                hls_car_series_bm,
                hls_car_series_records,
                series_len,
                hls_car_model_bm,
                hls_car_model_records,
                model_len;
                result = {
                    head: {
                        message: " ",
                        code: $ctx.success ? 'success' : 'failure'
                    },
                    body: {
                        brands: [],
                        series: [],
                        models: []
                    }
                };
                /* 品牌数据 */
                brands = result.body.brands;
                hls_car_brand_bm = new ModelService('price_app.hls_car_brand');
                hls_car_brand_records = hls_car_brand_bm.queryAsMap().getChildren();
                brands_len = hls_car_brand_records.length;
                for(var i = 0;i < brands_len;i++){
                    brands.push({
                        "value_code":hls_car_brand_records[i].value_code,
                        "value_name":hls_car_brand_records[i].value_name,
                        "brand_code":hls_car_brand_records[i].brand_code
                    });
                }
                /* 车系数据 */         
                series = result.body.series;
                hls_car_series_bm = new ModelService('price_app.hls_car_series');
                hls_car_series_records = hls_car_series_bm.queryAsMap().getChildren();
                series_len = hls_car_series_records.length;
                for (var j = 0;j < series_len;j++) {
                    // series.push({"test":1});
                    series.push({
                        "value_code":hls_car_series_records[j].value_code,
                        "value_name":hls_car_series_records[j].value_name,
                        "series_code":hls_car_series_records[j].series_code,
                        "brand_id": hls_car_series_records[j].brand_id,
                        "pic_code":hls_car_series_records[j].pic_code ? hls_car_series_records[j].pic_code : ''
                    });
                };
                /* 车型数据 */  
                models = result.body.models;
                hls_car_model_bm = new ModelService('price_app.hls_car_model');
                hls_car_model_records = hls_car_model_bm.queryAsMap().getChildren();
                model_len = hls_car_model_records.length;
                for (var k = 0;k < model_len;k++) {
                    models.push({
                        "value_code":hls_car_model_records[k].value_code,
                        "value_name":hls_car_model_records[k].value_name,
                        "series_id":hls_car_model_records[k].series_id,
                        "brand_id":hls_car_model_records[k].brand_id,
                        "guide_price":hls_car_model_records[k].guide_price
                    });
                };
                /*test*/
                // result.head.message = model_len;


            } catch (e) {
                println(e);
            } finally {
                //执行finally代码,将result对象回写
                // $ctx.parameter.json = JSON.stringify(result);
                $ctx.parameter.json = JSON.stringify(result);
            }
            ]]></s:server-script>
            </a:init-procedure>
            <a:service-output output="/parameter/@json"/>
            </a:service>