183 lines
7.8 KiB
C#
183 lines
7.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.QH;
|
|
using WX.CRM.IBLL.Util;
|
|
using WX.CRM.Model.QueryMap;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.QH
|
|
{
|
|
public class GroupPerformanceQueryController : BaseController
|
|
{
|
|
ValidationErrors errors = new ValidationErrors();
|
|
IQH_PerformanceQuery_Q perfermanceQuery_Q;
|
|
IQH_MONTHLYSTATEMENT_Q monthlyQ;
|
|
private ICACHE_Q _cacheQ;
|
|
public GroupPerformanceQueryController(IQH_PerformanceQuery_Q _perfermanceQuery_Q, ICACHE_Q cacheQ, IQH_MONTHLYSTATEMENT_Q _monthlyQ)
|
|
{
|
|
this.perfermanceQuery_Q = _perfermanceQuery_Q;
|
|
this._cacheQ = cacheQ;
|
|
this.monthlyQ = _monthlyQ;
|
|
}
|
|
|
|
#region 首页
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_期货组别业绩汇总查询_实时)]
|
|
public ActionResult Index()
|
|
{
|
|
ToolBar tb = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.期货组别业绩汇总查询_实时, userRightId);
|
|
tb.AllowButton(toolbtn);
|
|
tb.AddOtherButton("Other1", "导出", "icon-export", "ExportAllPage_Click1", true);
|
|
//tb.AddOtherButton("Other2", "报表重算", "icon-settings", "initRpt", true);
|
|
//tb.AddOtherButton("Other3", "高级查询条件", "icon-search", "AdvanceSearch", true);
|
|
ViewBag.ToolBar = tb;
|
|
|
|
Pager gp = new Pager() { page = 1, rows = 500 };
|
|
Table tab = new Table("tablist");
|
|
tab.AddHeadCol("groupName", "", "组别");
|
|
tab.AddHeadCol("openCount", "", "客户数", true);
|
|
tab.AddHeadCol("intervalTradeUserCount", "", "区间交易用户数", true);
|
|
tab.AddHeadCol("tradeTimes", "", "交易次数", true);
|
|
tab.AddHeadCol("tradeNumber", "", "交易手数", true);
|
|
tab.AddHeadCol("commission", "", "佣金", true);
|
|
|
|
tab.AddHeadRow();
|
|
ViewBag.GroupList = tab.GetTable() + Pagination.GetPage(gp, "tablist", "500");
|
|
//ViewBag.GroupList = tab.GetTable();
|
|
|
|
//ViewBag.inneruserid = UserId;
|
|
ViewBag.userGroupId = userGroupId;
|
|
ViewBag.saleDeptId = saleDeptId;
|
|
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
|
|
|
|
List<decimal> yearMonth = monthlyQ.GetAllOpYeanAndMonth();
|
|
ViewBag.maxMonthlyDate = (yearMonth == null || yearMonth.Count == 0) ? 190001 : yearMonth.FirstOrDefault();
|
|
|
|
return View();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_期货组别业绩汇总查询_实时)]
|
|
public JsonResult GetHtmlList(Pager pg, string columns)
|
|
{
|
|
string groupId = Request.Form["groupId"];
|
|
string stime = Request.Form["STime"];
|
|
string etime = Request.Form["ETime"];
|
|
//string ym = Request.Form["SltYearMonth"];
|
|
string searchType = Request.Form["SearchType"];
|
|
|
|
DateTime? sd1 = null;
|
|
DateTime? ed1 = null;
|
|
//decimal _ym = decimal.Parse(ym);
|
|
DateTime initDatetime = System.DateTime.MinValue;
|
|
//try
|
|
//{
|
|
if (!string.IsNullOrEmpty(stime))
|
|
sd1 = DateTime.Parse(stime);
|
|
if (!string.IsNullOrEmpty(etime))
|
|
ed1 = DateTime.Parse(etime).AddDays(1);
|
|
|
|
var deptCode = _cacheQ.GetValue_Parameter(Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
|
|
List<QH_GroupPerformanceQuery> list;
|
|
list = perfermanceQuery_Q.QH_GroupPerformanceQuery(ref pg, deptCode, groupId, sd1, ed1);
|
|
|
|
Table tb = new Table(columns, true);
|
|
|
|
foreach (QH_GroupPerformanceQuery model in list)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.groupName))
|
|
tb.AddCol(model.groupName != "合计" ? InnerUserHelper.Instance.GetGroupName(decimal.Parse(model.groupName)) : model.groupName);
|
|
else
|
|
tb.AddCol("");
|
|
tb.AddCol(model.openCount ?? 0);
|
|
tb.AddCol(model.intervalTradeUserCount ?? 0);
|
|
tb.AddCol(model.tradeTimes ?? 0);
|
|
tb.AddCol(model.tradeNumber ?? 0);
|
|
tb.AddCol(model.commission ?? 0);
|
|
tb.AddRow();
|
|
}
|
|
var json = new
|
|
{
|
|
//totalPages = pg.totalPages,
|
|
//totalRows = pg.totalRows,
|
|
rowsList = tb.GetRows(),
|
|
initTime = initDatetime.ToString("yyyy-MM-dd hh:mm:ss")
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// LogHelper.Error("QH_GroupPerformanceQueryController:" + ex.Message + ex.StackTrace);
|
|
// return JsonHandler.ManageMessage(ex.Message, false);
|
|
//}
|
|
}
|
|
#endregion
|
|
#region 初始化报表
|
|
//public JsonResult InitRpt()
|
|
//{
|
|
// try
|
|
// {
|
|
// string ym = Request["SltYearMonth"];
|
|
// decimal _ym = decimal.Parse(ym);
|
|
// var deptCode = _cacheQ.GetValue_Parameter(Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
// perfermanceQuery_Q.QH_GroupPerformanceInitCache(deptCode, _ym);
|
|
// var json = new { result = 1, msg = ym + "初始化成功!" };
|
|
// return Json(json, JsonRequestBehavior.AllowGet);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// LogHelper.Error("QH_GroupPerformanceQueryController(InitRpt):" + ex.Message + ex.StackTrace);
|
|
// var json = new { result = 0, msg = ex.Message };
|
|
// return Json(json, JsonRequestBehavior.AllowGet);
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
#region 导出
|
|
public FileResult Export()
|
|
{
|
|
string groupId = Request["groupId"];
|
|
string stime = Request["STime"];
|
|
string etime = Request["ETime"];
|
|
//string ym = Request["SltYearMonth"];
|
|
string searchType = Request["SearchType"];
|
|
//decimal _ym = decimal.Parse(ym);
|
|
DateTime initDatetime = System.DateTime.MinValue;
|
|
|
|
DateTime? sd1 = null;
|
|
DateTime? ed1 = null;
|
|
|
|
if (!string.IsNullOrEmpty(stime))
|
|
sd1 = DateTime.Parse(stime);
|
|
if (!string.IsNullOrEmpty(etime))
|
|
ed1 = DateTime.Parse(etime).AddDays(1);
|
|
|
|
var deptCode = _cacheQ.GetValue_Parameter(Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
|
|
var pager = new Pager() { page = 1, rows = int.MaxValue };
|
|
var checkedFilds = PageRequest.GetQueryString("checkedFilds");
|
|
var checkedTitle = PageRequest.GetQueryString("checkedTitles");
|
|
//var list = perfermanceQuery_Q.Gjs_GroupPerformanceQuery(ref pager, deptCode, groupId, sd1, ed1);
|
|
List<QH_GroupPerformanceQuery> list;
|
|
list = perfermanceQuery_Q.QH_GroupPerformanceQuery(ref pager, deptCode, groupId, sd1, ed1);
|
|
|
|
foreach (var item in list)
|
|
{
|
|
if (!string.IsNullOrEmpty(item.groupName))
|
|
item.groupName = item.groupName != "合计" ? InnerUserHelper.Instance.GetGroupName(decimal.Parse(item.groupName)) : item.groupName;
|
|
else
|
|
item.groupName = "";
|
|
}
|
|
return File(ExcelHelper.ExportListModelToExcel<QH_GroupPerformanceQuery>(list, "期货组别业绩汇总查询(实时)", 60000, checkedFilds, checkedTitle, null), "application/ms-excel", PageRequest.GetDlownLoadName("贵金属组别业绩汇总查询(实时).xls"));
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|