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.Model.QueryMap; using WX.CRM.WebHelper; namespace WX.CRM.WEB.Controllers.QH { public class UserPerformanceQueryController : BaseController { ValidationErrors errors = new ValidationErrors(); IQH_PerformanceQuery_Q perfermanceQuery_Q; IQH_MONTHLYSTATEMENT_Q monthlyQ; public UserPerformanceQueryController(IQH_PerformanceQuery_Q _perfermanceQuery_Q, IQH_MONTHLYSTATEMENT_Q _monthlyQ) { this.perfermanceQuery_Q = _perfermanceQuery_Q; 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 = 10 }; Table tab = new Table("tablist"); //tab.AddHeadCol("deptName", "", "部门"); tab.AddHeadCol("groupName", "", "组别"); tab.AddHeadCol("isDismiss", "", "在(离)职"); tab.AddHeadCol("entryTime", "", "入职时间"); tab.AddHeadCol("eid", "", "工号"); tab.AddHeadCol("name", "", "姓名"); 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", "5,8,10,15"); //ViewBag.GroupList = tab.GetTable(); ViewBag.inneruserid = UserId; ViewBag.userGroupId = userGroupId; ViewBag.saleDeptId = saleDeptId; ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId); List 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 saleEid = Request.Form["SaleEid"]; string groupId = Request.Form["groupId"]; string inneruserid = Request.Form["userId"]; string stime = Request.Form["STime"]; string etime = Request.Form["ETime"]; string isdismiss = Request.Form["isDismiss"]; //string ym = Request.Form["SltYearMonth"]; string searchType = Request.Form["SearchType"]; string businessType = Request.Form["BusinessType"]; decimal isdis = 0; decimal eid = 0; DateTime? sd1 = null; DateTime? ed1 = null; DateTime initDatetime = System.DateTime.MinValue; //try //{ if (!string.IsNullOrWhiteSpace(isdismiss)) decimal.TryParse(isdismiss, out isdis); if (!string.IsNullOrWhiteSpace(saleEid)) decimal.TryParse(saleEid, out eid); if (!string.IsNullOrEmpty(stime)) sd1 = DateTime.Parse(stime); if (!string.IsNullOrEmpty(etime)) ed1 = DateTime.Parse(etime).AddDays(1); List list; list = perfermanceQuery_Q.QH_UserPerformanceQuery(ref pg, groupId, inneruserid, eid, sd1, ed1, isdis, businessType); Table tb = new Table(columns, true); //tb.gridPager = pg; foreach (QH_UserPerformanceQuery model in list) { if (!string.IsNullOrEmpty(model.groupName)) tb.AddCol(model.groupName != "合计" ? InnerUserHelper.Instance.GetGroupName(decimal.Parse(model.groupName)) : model.groupName); else tb.AddCol(""); if (model.isDismiss.HasValue) tb.AddCol(model.isDismiss.Value == 0 ? "否" : "是"); else tb.AddCol(model.isDismiss); tb.AddCol(model.entryTime); tb.AddCol(model.eid); tb.AddCol(model.name); 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("Gjs_UserPerformanceQueryController:" + 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); // perfermanceQuery_Q.QH_UserPerformanceInitCache(_ym); // var json = new { result = 1, msg = ym + "初始化成功!" }; // return Json(json, JsonRequestBehavior.AllowGet); // } // catch (Exception ex) // { // LogHelper.Error("Gjs_UserPerformanceQueryController(InitRpt):" + ex.Message + ex.StackTrace); // var json = new { result = 0, msg = ex.Message }; // return Json(json, JsonRequestBehavior.AllowGet); // } //} #endregion #region 导出 public FileResult Export() { string saleEid = Request["SaleEid"]; string groupId = Request["groupId"]; string inneruserid = Request["userId"]; string stime = Request["STime"]; string etime = Request["ETime"]; //string ym = Request["SltYearMonth"]; string isdismiss = Request["isDismiss"]; string searchType = Request["SearchType"]; string businessType = Request.Form["BusinessType"]; decimal isdis = 0; decimal eid = 0; DateTime? sd1 = null; DateTime? ed1 = null; //decimal _ym = decimal.Parse(ym); if (!string.IsNullOrWhiteSpace(isdismiss)) decimal.TryParse(isdismiss, out isdis); if (!string.IsNullOrWhiteSpace(saleEid)) decimal.TryParse(saleEid, out eid); if (!string.IsNullOrEmpty(stime)) sd1 = DateTime.Parse(stime); if (!string.IsNullOrEmpty(etime)) ed1 = DateTime.Parse(etime).AddDays(1); DateTime initDatetime = System.DateTime.MinValue; var pager = new Pager() { page = 1, rows = int.MaxValue }; var checkedFilds = PageRequest.GetQueryString("checkedFilds"); var checkedTitle = PageRequest.GetQueryString("checkedTitles"); List list; list = perfermanceQuery_Q.QH_UserPerformanceQuery(ref pager, groupId, inneruserid, eid, sd1, ed1, isdis, businessType); 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(list, "员工业绩汇总查询(实时)", 60000, checkedFilds, checkedTitle, null), "application/ms-excel", PageRequest.GetDlownLoadName("期货员工业绩汇总查询(实时).xls")); } #endregion } }