コード例 #1
0
        /// <summary>
        /// 获取网点相关数据
        /// </summary>
        /// <param name="isGetPointsBySite"></param>
        /// <param name="userID"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public OperationResult PostPointsBySite(Boolean isGetPointsBySite, string userID, siteParams param)
        {
            var result = new OperationResult();
            List <HeatmapPoint>    CMBData       = new List <HeatmapPoint>();
            List <_3rdPartyPoints> _3rdPartyData = new List <_3rdPartyPoints>();
            var ip = HostIP.GetHostAddress();
            int aum11 = 0, aum12 = 0, aum13 = 0, aum14 = 0, aum15 = 0, aum16 = 0, ump21 = 0, ump22 = 0, ump23 = 0, tCount = 0;
            var AumStatisticList = new List <Pro_GetAnywhereAUMStatisticsData_Result>();
            var UmpStatisticList = new List <Pro_GetAnywhereUMPStatisticsData_Result>();

            CommomMethods.visitLog(2, param.bankID, userID);
            try
            {
                using (var db = new HeatMapEntities())
                {
                    CMBData = db.Pro_GetBankData(param.bankID, param.type, param.isAum, param.AUMLevel, param.UMPLlevel, param.isNoDF, param.isCheck, param.distance).Select(x => new HeatmapPoint
                    {
                        lng       = x.Longitude,
                        lat       = x.Latitude,
                        userCount = x.UserCount,
                        aumCount  = x.AUMMoney,
                        deposit   = x.DepositMoney,
                        Distance  = x.Distance,
                        AUM_level = x.AUM_level,
                        UMP_level = x.UMP_level
                    }).ToList();

                    var statisticData = db.Pro_GetBankStatistics(param.bankID, param.isAum, param.AUMLevel, param.UMPLlevel, param.isNoDF).ToList();
                    if (param.type == 1 || param.type == 2)
                    {
                        tCount = (int)db.Pro_GetTwoBranchUserCount(param.bankID).FirstOrDefault().UserCount;
                        foreach (var point in statisticData)
                        {
                            //AUM统计
                            switch (point.AUM_level)
                            {
                            case 11: aum11 += (int)point.UserCount; break;

                            case 12: aum12 += (int)point.UserCount; break;

                            case 13: aum13 += (int)point.UserCount; break;

                            case 14: aum14 += (int)point.UserCount; break;

                            case 15: aum15 += (int)point.UserCount; break;

                            case 16: aum16 += (int)point.UserCount; break;

                            default: break;
                            }
                            //UMP统计
                            switch (point.UMP_level)
                            {
                            case 21: ump21 += (int)point.UserCount; break;

                            case 22: ump22 += (int)point.UserCount; break;

                            case 23: ump23 += (int)point.UserCount; break;

                            default: break;
                            }
                        }
                    }
                    else if (param.type == 3 || param.type == 4)
                    {
                        tCount = (int)CMBData.Sum(x => x.userCount);
                        foreach (var point in CMBData)
                        {
                            //AUM统计
                            switch (point.AUM_level)
                            {
                            case 11: aum11 += (int)point.userCount; break;

                            case 12: aum12 += (int)point.userCount; break;

                            case 13: aum13 += (int)point.userCount; break;

                            case 14: aum14 += (int)point.userCount; break;

                            case 15: aum15 += (int)point.userCount; break;

                            case 16: aum16 += (int)point.userCount; break;

                            default: break;
                            }
                            //UMP统计
                            switch (point.UMP_level)
                            {
                            case 21: ump21 += (int)point.userCount; break;

                            case 22: ump22 += (int)point.userCount; break;

                            case 23: ump23 += (int)point.userCount; break;

                            default: break;
                            }
                        }
                    }
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 11, AUM_Name = "零资产", UserCount = aum11, Total = tCount, Percent = aum11 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 12, AUM_Name = "非零不达标基客", UserCount = aum12, Total = tCount, Percent = aum12 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 13, AUM_Name = "达标基客", UserCount = aum13, Total = tCount, Percent = aum13 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 14, AUM_Name = "金卡", UserCount = aum14, Total = tCount, Percent = aum14 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 15, AUM_Name = "金葵花", UserCount = aum15, Total = tCount, Percent = aum15 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 16, AUM_Name = "私钻", UserCount = aum16, Total = tCount, Percent = aum16 * 100 / (decimal)tCount
                    });
                    UmpStatisticList.Add(new Pro_GetAnywhereUMPStatisticsData_Result {
                        UMP_level = 21, UMP_Name = "潜力金卡", UserCount = ump21, Total = tCount, Percent = ump21 * 100 / (decimal)tCount
                    });
                    UmpStatisticList.Add(new Pro_GetAnywhereUMPStatisticsData_Result {
                        UMP_level = 22, UMP_Name = "潜力金葵花", UserCount = ump22, Total = tCount, Percent = ump22 * 100 / (decimal)tCount
                    });
                    UmpStatisticList.Add(new Pro_GetAnywhereUMPStatisticsData_Result {
                        UMP_level = 23, UMP_Name = "潜力私钻", UserCount = ump23, Total = tCount, Percent = ump23 * 100 / (decimal)tCount
                    });
                    var PoiStatisticData = CommomMethods.GetSitePoiStatisticData(param.bankID);
                    if (param.type == 3 || param.type == 4)
                    {
                        _3rdPartyData = db.Pro_GetAnywhere3rdData(param.lat, param.lng, param.distance, (int)PointType.Work).Select(x => new _3rdPartyPoints
                        {
                            lng        = x.Longitude,
                            lat        = x.Latitude,
                            thirdParty = Convert.ToInt32(x.UserCount),
                            Distance   = x.Distance
                        }).ToList();
                        var sitePonetranceList = CommomMethods.CalSiteRelPonetrance(CMBData, _3rdPartyData);
                        result.ReturnData = new
                        {
                            CMBData            = CMBData,
                            _3rdPartyData      = _3rdPartyData,
                            PoiStatisticData   = PoiStatisticData,
                            sitePonetranceData = sitePonetranceList,
                            AumStatisticList   = AumStatisticList,
                            UmpStatisticList   = UmpStatisticList
                        };
                    }
                    else
                    {
                        result.ReturnData = new
                        {
                            CMBData          = CMBData,
                            PoiStatisticData = PoiStatisticData,
                            AumStatisticList = AumStatisticList,
                            UmpStatisticList = UmpStatisticList
                        };
                    }
                    result.ReturnCode = 1;
                }
            }
            catch (Exception ex)
            {
                result.Message    = ex.Message;
                result.ReturnCode = 0;
                Logger.Log.Error(ex.StackTrace);
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// 获取城市资产统计数据
        /// </summary>
        /// <param name="isGetBankStatisticData"></param>
        /// <param name="bankID"></param>
        /// <returns></returns>
        public OperationResult PostBankStatisticData(Boolean isGetBankStatisticData, branchParams param)
        {
            var result = new OperationResult();
            int aum11 = 0, aum12 = 0, aum13 = 0, aum14 = 0, aum15 = 0, aum16 = 0, ump21 = 0, ump22 = 0, ump23 = 0, tCount = 0;
            List <Pro_GetAnywhereUMPStatisticsData_Result> UmpStatisticList = new List <Pro_GetAnywhereUMPStatisticsData_Result>();
            List <Pro_GetAnywhereAUMStatisticsData_Result> AumStatisticList = new List <Pro_GetAnywhereAUMStatisticsData_Result>();

            try
            {
                using (var db = new HeatMapEntities())
                {
                    var data = db.Pro_GetBankStatistics(param.bankID, param.isAum, param.AUMLevel, param.UMPLlevel, param.isNoDF).ToList();
                    // 1.获取数据集合
                    var dataList = new List <statistic_2>();
                    tCount = (int)db.Pro_GetTwoBranchUserCount(param.bankID).FirstOrDefault().UserCount;
                    foreach (var point in data)
                    {
                        //AUM统计
                        switch (point.AUM_level)
                        {
                        case 11: aum11 += (int)point.UserCount; break;

                        case 12: aum12 += (int)point.UserCount; break;

                        case 13: aum13 += (int)point.UserCount; break;

                        case 14: aum14 += (int)point.UserCount; break;

                        case 15: aum15 += (int)point.UserCount; break;

                        case 16: aum16 += (int)point.UserCount; break;

                        default: break;
                        }
                        //UMP统计
                        switch (point.UMP_level)
                        {
                        case 21: ump21 += (int)point.UserCount; break;

                        case 22: ump22 += (int)point.UserCount; break;

                        case 23: ump23 += (int)point.UserCount; break;

                        default: break;
                        }
                    }
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 11, AUM_Name = "零资产", UserCount = aum11, Total = tCount, Percent = aum11 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 12, AUM_Name = "非零不达标基客", UserCount = aum12, Total = tCount, Percent = aum12 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 13, AUM_Name = "达标基客", UserCount = aum13, Total = tCount, Percent = aum13 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 14, AUM_Name = "金卡", UserCount = aum14, Total = tCount, Percent = aum14 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 15, AUM_Name = "金葵花", UserCount = aum15, Total = tCount, Percent = aum15 * 100 / (decimal)tCount
                    });
                    AumStatisticList.Add(new Pro_GetAnywhereAUMStatisticsData_Result {
                        AUM_level = 16, AUM_Name = "私钻", UserCount = aum16, Total = tCount, Percent = aum16 * 100 / (decimal)tCount
                    });
                    UmpStatisticList.Add(new Pro_GetAnywhereUMPStatisticsData_Result {
                        UMP_level = 21, UMP_Name = "潜力金卡", UserCount = ump21, Total = tCount, Percent = ump21 * 100 / (decimal)tCount
                    });
                    UmpStatisticList.Add(new Pro_GetAnywhereUMPStatisticsData_Result {
                        UMP_level = 22, UMP_Name = "潜力金葵花", UserCount = ump22, Total = tCount, Percent = ump22 * 100 / (decimal)tCount
                    });
                    UmpStatisticList.Add(new Pro_GetAnywhereUMPStatisticsData_Result {
                        UMP_level = 23, UMP_Name = "潜力私钻", UserCount = ump23, Total = tCount, Percent = ump23 * 100 / (decimal)tCount
                    });
                    // 2.设置单元格抬头
                    // key:实体对象属性名称,可通过反射获取值
                    // value:Excel列的名称
                    Dictionary <string, string> cellheader = new Dictionary <string, string> {
                        { "name", "类型" },
                        { "count", "数量" },
                        { "percent", "百分比" },
                    };
                    foreach (var item in AumStatisticList)
                    {
                        dataList.Add(new statistic_2
                        {
                            name    = item.AUM_Name,
                            count   = item.UserCount.ToString(),
                            percent = Math.Round((decimal)item.Percent, 2).ToString() + "%"
                        });
                    }
                    var url = ExcelHelper.EntityListToExcel2003(cellheader, dataList, "统计");
                    result.ReturnData = new { AumStatisticList = AumStatisticList, UmpStatisticList = UmpStatisticList, url = url };
                    result.ReturnCode = 1;
                }
            }
            catch (Exception ex)
            {
                result.Message    = ex.Message;
                result.ReturnCode = 0;
                Logger.Log.Error(ex);
            }

            return(result);
        }