/// <summary>
 /// 按作者统计收稿量
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public Pager<ContributionAccountEntity> GetContributionAccountListByAuhor(ContributionAccountQuery query)
 {
     return ContributionInfoDataAccess.Instance.GetContributionAccountListByAuhor(query);
 }
 /// <summary>
 /// 按年月统计收稿量
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public IList<ContributionAccountEntity> GetContributionAccountListByYear(ContributionAccountQuery query)
 {
     return ContributionInfoDataAccess.Instance.GetContributionAccountListByYear(query);
 }
 /// <summary>
 /// 按时间统计收稿量
 /// </summary>
 /// <returns></returns>
 private Highcharts GetContributionAccountListByYear(Int32 Year)
 {
     IAuthorPlatformFacadeService service = ServiceContainer.Instance.Container.Resolve<IAuthorPlatformFacadeService>();
     ContributionAccountQuery query = new ContributionAccountQuery();
     query.JournalID = JournalID;
     query.Year = Year;
     IList<ContributionAccountEntity> list = service.GetContributionAccountListByYear(query);
     if (list == null || list.Count == 0)
         return new Highcharts("chart");
     list = list.OrderBy(p => p.Month).ToList();
     Highcharts chart = new Highcharts("chart")
         .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
         .SetTitle(new Title { Text = "按年(" + Year .ToString()+ "年)统计收稿量" })
         .SetXAxis(new XAxis
         {
             Categories = list.Select(p => p.MonthName).ToArray<string>(),
             Title = new XAxisTitle { Text = "月份" }
         })
         .SetYAxis(new YAxis
         {
             Min = 0,
             Title = new YAxisTitle
             {
                 Text = "收稿量",
                 Align = AxisTitleAligns.High
             }
         })
         .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y; }" })
         .SetPlotOptions(new PlotOptions
         {
             Column = new PlotOptionsColumn
             {
                 PointPadding = 0.2,
                 BorderWidth = 0,
                 PointWidth = 20
             }
         })
         .SetLegend(new Legend
         {
             Layout = Layouts.Vertical,
             Align = HorizontalAligns.Right,
             VerticalAlign = VerticalAligns.Top,
             Floating = true,
             BorderWidth = 1,
             BackgroundColor = ColorTranslator.FromHtml("#FFFFFF"),
             Shadow = true
         })
         .SetCredits(new Credits { Enabled = false })
         .SetSeries(new[]
                    {
                        new Series { Name = "收稿量", Data = new Data(list.Select(p => (object)p.Account).ToArray<object>()) }
                    });
     return chart;
 }
        public ActionResult ContributionAccountToExcel(ContributionAccountQuery query, string strDict)
        {
            string msg = string.Empty;
            try
            {
                IAuthorPlatformFacadeService service = ServiceContainer.Instance.Container.Resolve<IAuthorPlatformFacadeService>();
                query.JournalID = CurAuthor.JournalID;
                query.IsReport = true;
                strDict = Server.UrlDecode(strDict);
                JavaScriptSerializer s = new JavaScriptSerializer();
                Dictionary<string, object> JsonData = (Dictionary<string, object>)s.DeserializeObject(strDict);
                IDictionary<string, string> dict = ((object[])JsonData.First().Value).Select(p => (Dictionary<string, object>)p).ToDictionary(p => p["key"].ToString(), q => q["value"].ToString());

                IList<ContributionAccountEntity> list = new List<ContributionAccountEntity>();
                IList<FlowStatusEntity> listFs = new List<FlowStatusEntity>();
                IList<FlowContribution> listFc = new List<FlowContribution>();
                switch (query.Kind)
                {
                    case 4:
                        msg = "按过程稿统计收稿量";
                        listFs = GetContributionProcessList();
                        break;
                    case 3:
                        msg = "按退稿统计收稿量";
                        listFc = GetContributionReturnList();
                        break;
                    case 2:
                        msg = "按作者统计收稿量";
                        var pager = service.GetContributionAccountListByAuhor(query);
                        if (pager != null) list = pager.ItemList;
                        break;
                    case 1:
                        msg = "按基金统计收稿量";
                        list = service.GetContributionAccountListByFund(query);
                        break;
                    case 0:
                        msg = "按时间统计收稿量";
                        list = service.GetContributionAccountListByYear(query);
                        break;

                }
                if(query.Kind == 1 || query.Kind == 2 || query.Kind == 0)
                {
                    if (list == null || list.Count <= 0)
                    {
                        return Content("没有数据不能导出,请先进行查询!");
                    }
                    RenderToExcel.ExportListToExcel<ContributionAccountEntity>(list, dict
                        , null
                        , msg + "_导出" + DateTime.Now.ToString("yyyy-MM-dd"), false, "xls");
                }
                else if (query.Kind == 3)
                {
                    if (listFc == null || listFc.Count <= 0)
                    {
                        return Content("没有数据不能导出,请先进行查询!");
                    }

                    RenderToExcel.ExportListToExcel<FlowContribution>(listFc, dict
                        , null
                        , msg + "_导出" + DateTime.Now.ToString("yyyy-MM-dd"), false, "xls");
                }
                else if(query.Kind == 4)
                {
                    if (listFs == null || listFs.Count <= 0)
                    {
                        return Content("没有数据不能导出,请先进行查询!");
                    }

                    RenderToExcel.ExportListToExcel<FlowStatusEntity>(listFs, dict
                        , null
                        , msg + "_导出" + DateTime.Now.ToString("yyyy-MM-dd"), false, "xls");
                }
                return Content("导出成功!");
            }
            catch (Exception ex)
            {
                LogProvider.Instance.Error("导出" + msg + "出现异常:" + ex.Message);
                return Content("导出" + msg + "异常!");
            }
        }
 /// <summary>
 /// 按年月统计收稿量
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public IList<ContributionAccountEntity> GetContributionAccountListByYear(ContributionAccountQuery query)
 {
     HttpClientHelper clientHelper = new HttpClientHelper();
     IList<ContributionAccountEntity> list = clientHelper.Post<IList<ContributionAccountEntity>, ContributionAccountQuery>(GetAPIUrl(APIConstant.CONTRIBUTIONACCOUNT_GETYEARLIST), query);
     return list;
 }
 public ActionResult GetContributionAccountListByAuhor(ContributionAccountQuery query)
 {
     IAuthorPlatformFacadeService service = ServiceContainer.Instance.Container.Resolve<IAuthorPlatformFacadeService>();
     query.JournalID = CurAuthor.JournalID;
     query.CurrentPage = Convert.ToInt32(Request.Params["page"]);
     query.PageSize = Convert.ToInt32(Request.Params["pagesize"]);
     Pager<ContributionAccountEntity> pager = service.GetContributionAccountListByAuhor(query);
     return Json(new { Rows = pager.ItemList, Total = pager.TotalRecords, Account=pager.Money });
 }
 /// <summary>
 /// 按作者统计收稿量
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>       
 public Pager<ContributionAccountEntity> GetContributionAccountListByAuhor(ContributionAccountQuery query)
 {
     HttpClientHelper clientHelper = new HttpClientHelper();
     Pager<ContributionAccountEntity> pager = clientHelper.Post<Pager<ContributionAccountEntity>, ContributionAccountQuery>(GetAPIUrl(APIConstant.CONTRIBUTIONACCOUNT_GETAUTHORLIST), query);
     return pager;
 }
 public IList<ContributionAccountEntity> GetContributionAccountListByYear(ContributionAccountQuery query)
 {
     IContributionInfoService service = ServiceContainer.Instance.Container.Resolve<IContributionInfoService>();
     return service.GetContributionAccountListByYear(query);
 }
 /// <summary>
 /// 按年月统计收稿量
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public IList<ContributionAccountEntity> GetContributionAccountListByYear(ContributionAccountQuery query)
 {
     IList<ContributionAccountEntity> list = ContributionInfoBusProvider.GetContributionAccountListByYear(query);
     if (list == null || list.Count == 0)
     {
         list.Add(new ContributionAccountEntity() { Year = query.Year, Month = 1, Account = 0 });
     }
     var groupYear = list.GroupBy(p => p.Year);
     foreach (var item in groupYear)
     {
         for (int i = 1; i < 13; i++)
         {
             if (item.Where(p => p.Year == item.Key && p.Month == i).Count() == 0)//补充缺少月份数据
             {
                 list.Add(new ContributionAccountEntity() { Year = item.Key, Month = i, Account = 0 });
             }
         }
     }
     return list;
 }
        /// <summary>
        /// 按基金级别统计收稿量
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public IList<ContributionAccountEntity> GetContributionAccountListByFund(ContributionAccountQuery query)
        {
            IList<ContributionAccountEntity> list = ContributionInfoBusProvider.GetContributionAccountListByFund(query);
            DictValueService service = new DictValueService();
            var dictLevel = service.DictValueBusProvider.GetDictValueDcit(query.JournalID, EnumDictKey.FundLevel.ToString());
            if (list == null)
                list = new List<ContributionAccountEntity>();
            foreach (var item in dictLevel)
            {
                if (list.Where(p => p.FundLevel == item.Key).Count()==0)
                {
                    list.Add(new ContributionAccountEntity() { FundLevel = item.Key, Account = 0 });
                }
            }
            foreach (var model in list)
            {
                model.FundName = dictLevel.GetValue(model.FundLevel, model.FundLevel.ToString());
            }

            return list;
        }
 /// <summary>
 /// 按作者统计收稿量
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public Pager<ContributionAccountEntity> GetContributionAccountListByAuhor(ContributionAccountQuery query)
 {
     Pager<ContributionAccountEntity> pager = ContributionInfoBusProvider.GetContributionAccountListByAuhor(query);
     if (pager == null) return pager;
     IList<ContributionAccountEntity> list = pager.ItemList;
     if (list == null || list.Count == 0)
         return pager;
     AuthorInfoService service = new AuthorInfoService();
     AuthorInfoQuery aQuery = new AuthorInfoQuery();
     aQuery.JournalID = query.JournalID;
     var dict = service.AuthorInfoBusProvider.GetAuthorDict(aQuery);
     foreach (var model in list)
     {
         model.AuthorName = dict.GetValue(model.AuthorID, model.AuthorID.ToString());
     }
     pager.ItemList = list;
     return pager;
 }