<?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 contract_chart_query() {
                var year_con_list_details;
                var season_con_list_details;
                var month_con_list_details;
                var year_put_list_details;
                var season_put_list_details;
                var month_put_list_details;
                var year_rent_list_details;
                var season_rent_list_details;
                var month_rent_list_details;
                try {
                    //本年的合同
                    var year_con_bm= $bm('app.chart.year_con_chart');
                    var year_con_list_map = year_con_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    year_con_list_details = year_con_list_map.getChildren();
                    	
                    //本季的合同
                    var season_con_bm= $bm('app.chart.season_con_chart');
                    var season_con_list_map = season_con_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    season_con_list_details = season_con_list_map.getChildren();
                    
                    //本月的合同
                    var month_con_bm= $bm('app.chart.month_con_chart');
                    var month_con_list_map = month_con_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    month_con_list_details = month_con_list_map.getChildren();
                    
                    //本年的投放信息
                    var year_put_bm= $bm('app.chart.year_con_put_inform');
                    var year_put_list_map = year_put_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    year_put_list_details = year_put_list_map.getChildren();
                    
                     //本季的投放信息
                    var season_put_bm= $bm('app.chart.season_con_put_inform');
                    var season_put_list_map = season_put_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    season_put_list_details = season_put_list_map.getChildren();
                    
                    //本月的投放信息
                    var month_put_bm= $bm('app.chart.month_con_put_inform');
                    var month_put_list_map = month_put_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    month_put_list_details = month_put_list_map.getChildren();
                    
                    //本年的回笼信息
                    var year_rent_bm= $bm('app.chart.year_con_rent_inform');
                    var year_rent_list_map = year_rent_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    year_rent_list_details = year_rent_list_map.getChildren();
                    
                    //本季的回笼信息
                    var season_rent_bm= $bm('app.chart.season_con_rent_inform');
                    var season_rent_list_map = season_rent_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    season_rent_list_details = season_rent_list_map.getChildren();
                    
                    //本月的回笼信息
                    var month_rent_bm= $bm('app.chart.month_con_rent_inform');
                    var month_rent_list_map = month_rent_bm.queryAsMap({
                        user_id:$ctx.parameter.user_id
                    });
                    month_rent_list_details = month_rent_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,
                    year_con:[],
                    season_con:[],
                    month_con:[],
                    year_put:[],
                    season_put:[],
                    month_put:[],
                    year_rent:[],
                    season_rent:[],
                    month_rent:[]
                };
                //本年的合同
                var year_con = result.year_con;
                if (year_con_list_details) {
                    for (var i = 0;i < year_con_list_details.length;i++) {
                        var year_con_list_detail = year_con_list_details[i];
                        year_con.push({
                            "other_count": year_con_list_detail.other_count,
                            "new_count": year_con_list_detail.new_count,
                            "sign_count": year_con_list_detail.sign_count,
                            "incept_count": year_con_list_detail.incept_count,
                            "overdue_count": year_con_list_detail.overdue_count
                            
                        });
                    }
                }
                //本季合同
                var season_con = result.season_con;
                if (season_con_list_details) {
                    for (var i = 0;i < season_con_list_details.length;i++) {
                        var season_con_list_detail = season_con_list_details[i];
                        season_con.push({
                            "other_count": season_con_list_detail.other_count,
                            "new_count": season_con_list_detail.new_count,
                            "sign_count": season_con_list_detail.sign_count,
                            "incept_count": season_con_list_detail.incept_count,
                            "overdue_count": season_con_list_detail.overdue_count
                            
                        });
                    }
                }
                //本月合同
                 var month_con = result.month_con;
                if (month_con_list_details) {
                    for (var i = 0;i < month_con_list_details.length;i++) {
                        var month_con_list_detail = month_con_list_details[i];
                        month_con.push({
                            "other_count": month_con_list_detail.other_count,
                            "new_count": month_con_list_detail.new_count,
                            "sign_count": month_con_list_detail.sign_count,
                            "incept_count": month_con_list_detail.incept_count,
                            "overdue_count": month_con_list_detail.overdue_count
                            
                        });
                    }
                }
                //本年投放
                var year_put = result.year_put;
                if (year_put_list_details) {
                    for (var i = 0;i < year_put_list_details.length;i++) {
                        var year_put_list_detail  = year_put_list_details[i];
                        year_put.push({
                            "put_total": year_put_list_detail.put_total,
                            "received_total": year_put_list_detail.received_total,
                            "unrecevie_total": year_put_list_detail.unrecevie_total
                            
                            
                        });
                    }
                }
                //本季投放
                var season_put = result.season_put;
                if (season_put_list_details) {
                    for (var i = 0;i < season_put_list_details.length;i++) {
                        var season_put_list_detail  = season_put_list_details[i];
                        season_put.push({
                            "put_total": season_put_list_detail.put_total,
                            "received_total": season_put_list_detail.received_total,
                            "unrecevie_total": season_put_list_detail.unrecevie_total
                            
                            
                        });
                    }
                }
                //本月投放
                var month_put = result.month_put;
                if (month_put_list_details) {
                    for (var i = 0;i < month_put_list_details.length;i++) {
                        var month_put_list_detail  = month_put_list_details[i];
                        month_put.push({
                            "put_total": month_put_list_detail.put_total,
                            "received_total": month_put_list_detail.received_total,
                            "unrecevie_total": month_put_list_detail.unrecevie_total
                            
                            
                        });
                    }
                }
                //本年租金
                 var year_rent = result.year_rent;
                if (year_rent_list_details) {
                    for (var i = 0;i < year_rent_list_details.length;i++) {
                        var year_rent_list_detail  = year_rent_list_details[i];
                        year_rent.push({
                            "rent_total": year_rent_list_detail.rent_total,
                            "received_rent_total": year_rent_list_detail.received_rent_total,
                            "unreceive_rent_total": year_rent_list_detail.unreceive_rent_total
                            
                            
                        });
                    }
                }
                
                //本季租金
                 var season_rent = result.season_rent;
                if (season_rent_list_details) {
                    for (var i = 0;i < season_rent_list_details.length;i++) {
                        var season_rent_list_detail  = season_rent_list_details[i];
                        season_rent.push({
                            "rent_total": season_rent_list_detail.rent_total,
                            "received_rent_total": season_rent_list_detail.received_rent_total,
                            "unreceive_rent_total": season_rent_list_detail.unreceive_rent_total
                            
                            
                        });
                    }
                }
                //本月租金
                 var month_rent = result.month_rent;
                if (month_rent_list_details) {
                    for (var i = 0;i < month_rent_list_details.length;i++) {
                        var month_rent_list_detail  = month_rent_list_details[i];
                        month_rent.push({
                            "rent_total": month_rent_list_detail.rent_total,
                            "received_rent_total": month_rent_list_detail.received_rent_total,
                            "unreceive_rent_total": month_rent_list_detail.unreceive_rent_total
                            
                            
                        });
                    }
                }
                $ctx.parameter.json = JSON.stringify(result);
            }
            if ($ctx.parameter.return_status != 'E'&& $ctx.parameter.return_status != 'TIMEOUT') {
                contract_chart_query();
            }
        ]]></s:server-script>
    </a:init-procedure>
    <a:service-output output="/parameter/@json"/>
</a:service>