285 lines
12 KiB
C#
285 lines
12 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Ord;
|
|
using WX.CRM.IBLL.Util;
|
|
using WX.CRM.Model.Enum;
|
|
using WX.CRM.Model.MAP;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.Ord
|
|
{
|
|
public class MemoStatisticsController : BaseController
|
|
{
|
|
#region 初始化
|
|
IORD_MEMOTYPE_Q memoTypeBll;
|
|
ICACHE_Q cacheBll;
|
|
private readonly IORD_MEMOSUBTYPE_Q _memosubtypeQ;
|
|
|
|
public MemoStatisticsController(IORD_MEMOTYPE_Q _memoTypeBll, ICACHE_Q _cacheBll, IORD_MEMOSUBTYPE_Q memosubtypeQ)
|
|
{
|
|
this.memoTypeBll = _memoTypeBll;
|
|
this.cacheBll = _cacheBll;
|
|
_memosubtypeQ = memosubtypeQ;
|
|
}
|
|
ValidationErrors errors = new ValidationErrors();
|
|
#endregion
|
|
|
|
#region 员工工单统计
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_工单统计)]
|
|
public ActionResult MemoStatistics()
|
|
{
|
|
ToolBar tool = new ToolBar();
|
|
tool.AllowButton("Other1");
|
|
tool.AddOtherButton("Other1", "导出", "icon-export", "export_click", true);
|
|
ViewBag.ToolBar = tool;
|
|
|
|
//Pager pg = new Pager() { page = 1, rows = int.MaxValue };
|
|
Table tb = new Table("tablist");
|
|
tb.isNumber = false;
|
|
//tb.AddHeadCol("saleEid", "", "销售员工", "sortTable('tablist',0,'float');", "cursor:pointer");
|
|
tb.AddHeadCol("saleEid", "", "销售员工");
|
|
string paraValue = cacheBll.GetValue_Parameter(Parameter.ORD_MemoStatistics_01);
|
|
var deptCode = cacheBll.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
string[] str = paraValue.Split('#');
|
|
for (int i = 0; i < str.Length; i++)
|
|
{
|
|
if (deptCode == "TDOEM1")
|
|
{
|
|
var model = _memosubtypeQ.GetModel(Convert.ToDecimal(str[i]));
|
|
if (model != null)
|
|
tb.AddHeadCol(model.SUBTYPEID.ToString(), "", model.TYPENAME, true);
|
|
}
|
|
else
|
|
{
|
|
var model = memoTypeBll.GetModel_MemoType(Convert.ToDecimal(str[i]));
|
|
if (model != null)
|
|
tb.AddHeadCol(model.TYPEID.ToString(), "", model.TYPENAME, true);
|
|
}
|
|
}
|
|
tb.AddHeadRow();
|
|
//ViewBag.GroupList = tb.GetHead() + Pagination.GetPage(pg, "tablist", "10,20,50");
|
|
ViewBag.GroupList = tb.GetHead();
|
|
|
|
ViewBag.inneruserid = UserId;
|
|
ViewBag.userGroupId = userGroupId;
|
|
ViewBag.saleDeptId = saleDeptId;
|
|
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
|
|
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_工单统计)]
|
|
public JsonResult GetMemoStatistics(Pager pg, string columns, QueryUserComboDto usercomboDto)
|
|
{
|
|
string stime = Request.Form["STime"];
|
|
string etime = Request.Form["ETime"];
|
|
//string saleDeptId = Request.Form["saleDeptId"];
|
|
//string groupId = Request.Form["groupId"];
|
|
//string userId = Request.Form["userId"];
|
|
|
|
Table tb = new Table(columns, true);
|
|
tb.isNumber = false;
|
|
tb.gridPager = new Pager() { page = 1, rows = int.MaxValue };
|
|
DataSet ds = new DataSet();
|
|
var deptCode = cacheBll.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
if (deptCode == "TDOEM1")
|
|
{
|
|
ds = memoTypeBll.NJ_GetMemoTypeStatistics(ref pg, stime, etime, columns, usercomboDto);
|
|
}
|
|
else
|
|
{
|
|
ds = memoTypeBll.GetMemoTypeStatistics(ref pg, stime, etime, columns, usercomboDto);
|
|
}
|
|
|
|
#region 绑定数据
|
|
foreach (DataRow dataRow in ds.Tables[0].Rows)
|
|
{
|
|
for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
|
|
{
|
|
tb.AddCol(dataRow[ds.Tables[0].Columns[i].ToString()]);
|
|
}
|
|
tb.AddRow();
|
|
}
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dataRow in ds.Tables[1].Rows)
|
|
{
|
|
for (int i = 0; i < ds.Tables[1].Columns.Count; i++)
|
|
{
|
|
tb.AddCol(dataRow[ds.Tables[1].Columns[i].ToString()]);
|
|
}
|
|
tb.AddFootRow();
|
|
}
|
|
}
|
|
#endregion
|
|
var json = new
|
|
{
|
|
totalPages = pg.totalPages,
|
|
totalRows = pg.totalRows,
|
|
rowsList = tb.GetRows(),
|
|
foot = tb.GetFoot()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_公共权限)]
|
|
public void ExportAll(QueryUserComboDto usercomboDto)
|
|
{
|
|
string stime = Request.QueryString["STime"];
|
|
string etime = Request.QueryString["ETime"];
|
|
//string saleDeptId = Request.QueryString["saleDeptId"];
|
|
//string groupId = Request.QueryString["groupId"];
|
|
//string userId = Request.QueryString["userId"];
|
|
|
|
string paraValue = cacheBll.GetValue_Parameter(Parameter.ORD_MemoStatistics_01);
|
|
paraValue = "saleEid," + paraValue.Replace('#', ',');
|
|
|
|
Pager pg = new Pager() { rows = int.MaxValue, page = 1 };
|
|
DataSet ds = new DataSet();
|
|
var deptCode = cacheBll.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
if (deptCode == "TDOEM1")
|
|
{
|
|
ds = memoTypeBll.NJ_GetMemoTypeStatistics(ref pg, stime, etime, paraValue, usercomboDto);
|
|
}
|
|
else
|
|
{
|
|
ds = memoTypeBll.GetMemoTypeStatistics(ref pg, stime, etime, paraValue, usercomboDto);
|
|
}
|
|
|
|
//ExcelHelper.ExportDataTableToExcel(ds.Tables[0], "工单统计.xls", "工单统计");
|
|
ExcelHelper.ExportDataSetToExcel(ds, "工单统计.xls", "工单统计,合计");
|
|
}
|
|
|
|
#endregion 员工工单统计
|
|
|
|
#region 组别工单统计
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_组别工单统计)]
|
|
public ActionResult GroupMemoStatistics()
|
|
{
|
|
ToolBar tool = new ToolBar();
|
|
tool.AllowButton("Other1");
|
|
tool.AddOtherButton("Other1", "导出", "icon-export", "export_click", true);
|
|
ViewBag.ToolBar = tool;
|
|
|
|
Pager pg = new Pager() { page = 1, rows = 100 };
|
|
Table tb = new Table("tablist");
|
|
tb.isNumber = false;
|
|
tb.AddHeadCol("saleGroup", "", "销售组");
|
|
string paraValue = cacheBll.GetValue_Parameter(Parameter.ORD_MemoStatistics_01);
|
|
var deptCode = cacheBll.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
string[] str = paraValue.Split('#');
|
|
for (int i = 0; i < str.Length; i++)
|
|
{
|
|
if (deptCode == "TDOEM1")
|
|
{
|
|
var model = _memosubtypeQ.GetModel(Convert.ToDecimal(str[i]));
|
|
if (model != null)
|
|
tb.AddHeadCol(model.SUBTYPEID.ToString(), "", model.TYPENAME, true);
|
|
}
|
|
else
|
|
{
|
|
var model = memoTypeBll.GetModel_MemoType(Convert.ToDecimal(str[i]));
|
|
if (model != null)
|
|
tb.AddHeadCol(model.TYPEID.ToString(), "", model.TYPENAME, true);
|
|
}
|
|
}
|
|
tb.AddHeadRow();
|
|
ViewBag.GroupList = tb.GetHead() + Pagination.GetPage(pg, "tablist", "5,10,15,20");
|
|
|
|
ViewBag.inneruserid = UserId;
|
|
ViewBag.userGroupId = userGroupId;
|
|
ViewBag.saleDeptId = saleDeptId;
|
|
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
|
|
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_组别工单统计)]
|
|
public JsonResult GetGroupMemoStatistics(Pager pg, string columns, QueryUserComboDto usercomboDto)
|
|
{
|
|
string stime = Request.Form["STime"];
|
|
string etime = Request.Form["ETime"];
|
|
//string saleDeptId = Request.Form["saleDeptId"];
|
|
//string groupId = Request.Form["groupId"];
|
|
|
|
Table tb = new Table(columns, true);
|
|
tb.isNumber = false;
|
|
tb.gridPager = pg;
|
|
//DataSet ds = memoTypeBll.GetGroupMemoTypeStatistics(ref pg, stime, etime, columns,saleDeptId,groupId);
|
|
DataSet ds = new DataSet();
|
|
var deptCode = cacheBll.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
if (deptCode == "TDOEM1")
|
|
{
|
|
ds = memoTypeBll.NJ_GetGroupMemoTypeStatistics(ref pg, stime, etime, columns, usercomboDto);
|
|
}
|
|
else
|
|
{
|
|
ds = memoTypeBll.GetGroupMemoTypeStatistics(ref pg, stime, etime, columns, usercomboDto);
|
|
}
|
|
|
|
#region 绑定数据
|
|
foreach (DataRow dataRow in ds.Tables[0].Rows)
|
|
{
|
|
for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
|
|
{
|
|
tb.AddCol(dataRow[ds.Tables[0].Columns[i].ToString()]);
|
|
}
|
|
tb.AddRow();
|
|
}
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dataRow in ds.Tables[1].Rows)
|
|
{
|
|
for (int i = 0; i < ds.Tables[1].Columns.Count; i++)
|
|
{
|
|
tb.AddCol(dataRow[ds.Tables[1].Columns[i].ToString()]);
|
|
}
|
|
tb.AddFootRow();
|
|
}
|
|
}
|
|
#endregion
|
|
var json = new
|
|
{
|
|
totalPages = pg.totalPages,
|
|
totalRows = pg.totalRows,
|
|
rowsList = tb.GetRows(),
|
|
foot = tb.GetFoot()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_公共权限)]
|
|
public void GroupExportAll(QueryUserComboDto usercomboDto)
|
|
{
|
|
string stime = Request.QueryString["STime"];
|
|
string etime = Request.QueryString["ETime"];
|
|
//string saleDeptId = Request.Form["saleDeptId"];
|
|
//string groupId = Request.QueryString["groupId"];
|
|
|
|
string paraValue = cacheBll.GetValue_Parameter(Parameter.ORD_MemoStatistics_01);
|
|
paraValue = "saleEid," + paraValue.Replace('#', ',');
|
|
|
|
Pager pg = new Pager() { rows = int.MaxValue, page = 1 };
|
|
DataSet ds = new DataSet();
|
|
var deptCode = cacheBll.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_Environment_DeptCode);
|
|
if (deptCode == "TDOEM1")
|
|
{
|
|
ds = memoTypeBll.NJ_GetGroupMemoTypeStatistics(ref pg, stime, etime, paraValue, usercomboDto);
|
|
}
|
|
else
|
|
{
|
|
ds = memoTypeBll.GetGroupMemoTypeStatistics(ref pg, stime, etime, paraValue, usercomboDto);
|
|
}
|
|
|
|
//ExcelHelper.ExportDataTableToExcel(ds.Tables[0], "组别工单统计.xls", "组别工单统计");
|
|
ExcelHelper.ExportDataSetToExcel(ds, "组别工单统计.xls", "组别工单统计,合计");
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|