319 lines
18 KiB
C#
319 lines
18 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web.Mvc;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.IBLL.Ord;
|
||
using WX.CRM.IBLL.Util;
|
||
using WX.CRM.IBLL.Wx;
|
||
using WX.CRM.Model.Entity;
|
||
using WX.CRM.Model.MAP;
|
||
using WX.CRM.Model.QueryMap;
|
||
using WX.CRM.WebHelper;
|
||
|
||
namespace WX.CRM.WEB.Controllers.Ord
|
||
{
|
||
public class MemoQueryController : BaseController
|
||
{
|
||
//
|
||
// GET: /MemoQuery/
|
||
ValidationErrors errors = new ValidationErrors();
|
||
IORD_SPECIALMEMO_Q specialMemoBiz_Q;
|
||
IORD_SERVICEMEMO_Q serviceMemoBiz_Q;
|
||
IORD_SALEMEMO_Q saleMemoBiz_Q;
|
||
IORD_PURPOSEMEMO_Q purposeMemoBiz_Q;
|
||
private ICACHE_Q cacheQ;
|
||
private readonly IWX_RCONTACT _wxRcontact;
|
||
private readonly IORD_SERVICEMEMO_EXT _ordServiceMemoExt;
|
||
|
||
public MemoQueryController(IORD_SPECIALMEMO_Q _specialMemoBiz_Q, IORD_SERVICEMEMO_Q _serviceMemoBiz_Q, IORD_SALEMEMO_Q _saleMemoBiz_Q, IORD_PURPOSEMEMO_Q _purposeMemoBiz_Q, ICACHE_Q _cacheQ, IWX_RCONTACT wxRcontact, IORD_SERVICEMEMO_EXT ordServiceMemoExt)
|
||
{
|
||
this.specialMemoBiz_Q = _specialMemoBiz_Q;
|
||
this.serviceMemoBiz_Q = _serviceMemoBiz_Q;
|
||
this.saleMemoBiz_Q = _saleMemoBiz_Q;
|
||
this.purposeMemoBiz_Q = _purposeMemoBiz_Q;
|
||
this.cacheQ = _cacheQ;
|
||
_wxRcontact = wxRcontact;
|
||
_ordServiceMemoExt = ordServiceMemoExt;
|
||
}
|
||
#region 工单综合查询
|
||
/// <summary>
|
||
/// 工单综合查询
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_工单查询)]
|
||
public ActionResult MemoQuery()
|
||
{
|
||
//tool.AllowButton("Other1", "Other2");//, "Other3"
|
||
//tool.AddOtherButton("Other1", "导出", "icon-export", "export_click", true);
|
||
//tool.AddOtherButton("Other2", "导出客户所有客户ID", "icon-export", "exportAll_click", true);
|
||
//tool.AddOtherButton("Other3", "systemBtn", "icon-export", "delete_click", true);
|
||
ToolBar tool = new ToolBar();
|
||
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.工单查询, userRightId);
|
||
|
||
tool.AllowButton(toolbtn);
|
||
ViewBag.ToolBar = tool;
|
||
|
||
Pager pager = new Pager() { page = 1, rows = 10 };
|
||
string tableId = "tablist";
|
||
Table tab = new Table(tableId);
|
||
tab.AddHeadCol("MEMOID", "12%", "工单编号");
|
||
tab.AddHeadCol("RESID", "12%", "客户ID");
|
||
tab.AddHeadCol("NAME", "7%", "客户姓名");
|
||
|
||
tab.AddHeadCol("BUSINESSID", "5%", "业务类型");
|
||
tab.AddHeadCol("MEMOCONTENTID", "", "工单内容");
|
||
tab.AddHeadCol("MEMOTYPEID", "8%", "工单大类");
|
||
tab.AddHeadCol("MEMOSUBTYPEID", "8%", "工单小类");
|
||
tab.AddHeadCol("INNERUSERID", "8%", "受理人");
|
||
tab.AddHeadCol("CTIME", "10%", "工单时间");
|
||
tab.AddHeadCol("CALLTIME", "10%", "通话时间");
|
||
tab.AddHeadRow();
|
||
|
||
ViewBag.gridTable = tab.GetTable() + Pagination.GetPage(pager, tableId, "10,20,30");
|
||
|
||
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 GetMemoQueryHtml(Pager pager, string columns, QueryUserComboDto userComboDto)
|
||
{
|
||
string memoId = Request.Form["memoId"];
|
||
string stime = Request.Form["stime"];
|
||
string etime = Request.Form["etime"];
|
||
string BusinessType = Request.Form["BusinessType"];
|
||
string MemoType = Request.Form["MemoType"];
|
||
string MemoSubtype = Request.Form["MemoSubtype"];
|
||
string content = Request.Form["memoContent"];
|
||
//string saleDeptId = Request.Form["saleDeptId"];
|
||
//string groupId = Request.Form["groupId"];
|
||
//string userId = Request.Form["userId"];
|
||
string eid = Request["eid"];
|
||
string resid = Request["resid"];
|
||
|
||
string isShowMobileOfContent = cacheQ.GetValue_Parameter(Model.Enum.Parameter.Sys_IsShowMobileOfContent);
|
||
|
||
|
||
if (!string.IsNullOrEmpty(eid))
|
||
{
|
||
userComboDto.userId = InnerUserHelper.Instance.GetUserIdByEid(int.Parse(eid));
|
||
}
|
||
List<ORD_MemoQuery> list = new List<ORD_MemoQuery>();
|
||
#region 获取数据
|
||
switch (Convert.ToInt32(BusinessType))
|
||
{
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.服务工单:
|
||
list = serviceMemoBiz_Q.GetList(ref pager, memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), content, userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.特殊订单:
|
||
list = specialMemoBiz_Q.GetList(ref pager, memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), content, userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.销售工单:
|
||
list = saleMemoBiz_Q.GetList(ref pager, memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), content, userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.意向工单:
|
||
list = purposeMemoBiz_Q.GetList(ref pager, memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), content, userComboDto);
|
||
break;
|
||
}
|
||
#endregion
|
||
Table table = new Table(columns, true);
|
||
table.gridPager = pager;
|
||
|
||
ICACHE_Q ui = DataCacheHelper.GetCache();
|
||
List<ORD_MEMOTYPE> memoTypeList = ui.GetList_MemoType();//缓存读取 工单大类数据
|
||
List<ORD_MEMOSUBTYPE> memoSubTypeList = ui.GetList_MemoSubType();//缓存读取 获取所有工单小类数据
|
||
ORD_MEMOTYPE memotype = null;
|
||
ORD_MEMOSUBTYPE memosubType = null;
|
||
foreach (ORD_MemoQuery model in list)
|
||
{
|
||
table.AddCol(table.tdLeft5, "", model.MEMOID);
|
||
table.AddCol(table.tdLeft5, "", "<a href=\"javascript:void(0);\" onclick=\"OpenCustomerByResId('" + model.RESID + "')\">" + model.RESID + "</a>");
|
||
table.AddCol(model.CNAME);
|
||
table.AddCol(Handler.MethodRsource.GetMemoBusinessName(Convert.ToInt32(BusinessType), Convert.ToInt32(model.BUSINESSID)));
|
||
if (model.ExtMemoId.HasValue)
|
||
{
|
||
model.STRCONTENT = model.STRCONTENT + string.Format("<a style='padding-left:20px' href='javascript:void(0)' onclick='mmore({0})'>更多</a>", model.ExtMemoId.Value);
|
||
}
|
||
if(!string.IsNullOrEmpty(model.STRCONTENT) && (model.STRCONTENT.Contains("证监会") || model.STRCONTENT.Contains("投诉监管")))
|
||
{
|
||
model.STRCONTENT = model.STRCONTENT.Replace("证监会", "<span class='markClass'>证监会</span>").Replace("投诉监管", "<span class='markClass'>投诉监管</span>");
|
||
}
|
||
if (!string.IsNullOrEmpty(isShowMobileOfContent) && isShowMobileOfContent == "1")
|
||
{
|
||
table.AddCol(table.tdLeft5, "", model.STRCONTENT);
|
||
}
|
||
else
|
||
{
|
||
table.AddCol(table.tdLeft5, "", Utility.ReplaceMobile(model.STRCONTENT));
|
||
}
|
||
memotype = memoTypeList.FirstOrDefault(m => m.TYPEID == model.MEMOTYPEID);
|
||
table.AddCol(table.tdLeft5, "", memotype == null ? "" : memotype.TYPENAME);
|
||
memosubType = memoSubTypeList.FirstOrDefault(m => m.SUBTYPEID == model.MEMOSUBTYPEID);
|
||
table.AddCol(table.tdLeft5, "", memosubType == null ? "" : memosubType.TYPENAME);
|
||
table.AddCol(table.tdLeft5, "", InnerUserHelper.Instance.EidAndName(model.INNERUSERID));
|
||
table.AddCol(model.CTIME);
|
||
table.AddCol(model.CALLTIME);
|
||
table.AddRow();
|
||
}
|
||
var json = new
|
||
{
|
||
totalPages = pager.totalPages,
|
||
totalRows = pager.totalRows,
|
||
rowsList = table.GetRows()
|
||
};
|
||
return Json(json, JsonRequestBehavior.AllowGet);
|
||
}
|
||
public JsonResult DelMemo(string BusinessType, string MemoId) {
|
||
|
||
|
||
return Json(new { }, JsonRequestBehavior.AllowGet);
|
||
}
|
||
#endregion
|
||
|
||
#region
|
||
public ActionResult ServiceMemoExt(decimal extmemoid)
|
||
{
|
||
var model = _ordServiceMemoExt.Get(p => p.MEMOID == extmemoid);
|
||
return View(model);
|
||
}
|
||
#endregion
|
||
|
||
#region 客户编号导出
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_工单查询)]
|
||
public FileResult ResourceIDExport(QueryUserComboDto userComboDto)
|
||
{
|
||
string memoId = Request.QueryString["memoId"];
|
||
string stime = Request.QueryString["stime"];
|
||
string etime = Request.QueryString["etime"];
|
||
string BusinessType = Request.QueryString["BusinessType"];
|
||
string MemoType = Request.QueryString["MemoType"];
|
||
string MemoSubtype = Request.QueryString["MemoSubtype"];
|
||
string content = Request.Form["memoContent"];
|
||
//string saleDeptId = Request.QueryString["saleDeptId"];
|
||
//string groupId = Request.QueryString["groupId"];
|
||
//string userId = Request.QueryString["userId"];
|
||
//var bangwx = Request["bangwx"];
|
||
string eid = Request["eid"];
|
||
string resid = Request["resid"];
|
||
|
||
//LogHelper.Info("bangwx:" + bangwx);
|
||
//LogHelper.Info("schkMemo:" + schkMemo);
|
||
//var wxResIds = new List<string>();
|
||
//if (bangwx == "true")
|
||
//{
|
||
// wxResIds = _wxRcontact.GetList(p => p.RESID != null).Select(p => p.RESID).ToList();
|
||
//}
|
||
if (!string.IsNullOrEmpty(eid))
|
||
{
|
||
userComboDto.userId = InnerUserHelper.Instance.GetUserIdByEid(int.Parse(eid));
|
||
}
|
||
List<ORD_MemoQuery> list = new List<ORD_MemoQuery>();
|
||
Pager pager = new Pager { page = 1, rows = 60000 };
|
||
#region 获取数据
|
||
switch (Convert.ToInt32(BusinessType))
|
||
{
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.服务工单:
|
||
list = serviceMemoBiz_Q.GetList(ref pager, memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), content, userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.特殊订单:
|
||
list = specialMemoBiz_Q.GetList(ref pager, memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), content, userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.销售工单:
|
||
list = saleMemoBiz_Q.GetList(ref pager, memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), content, userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.意向工单:
|
||
list = purposeMemoBiz_Q.GetList(ref pager, memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), content, userComboDto);
|
||
break;
|
||
}
|
||
#endregion
|
||
//return File(ExcelHelper.ExportListObjectToExcel(list, "客户编号", "工单综合查询", null), "application/ms-excel", PageRequest.GetDlownLoadName("客户编号" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"));
|
||
//return File(ExcelHelper.ExportListModelToExcel<ord_memoExport>(list, "工单综合查询", 60000, "[resid][otherResid]", "客户ID,客户相关客户ID", null), "application/ms-excel", PageRequest.GetDlownLoadName("客户编号" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"));
|
||
|
||
//list = list.Where(p => !wxResIds.Contains(p.RESID)).ToList();
|
||
//var lis = list.Where(m => m.resid == m.otherResid).Select(s => new { s.resid, s.resAscription }).Distinct().ToList();
|
||
//List<ord_memoExport> ListExp = lis.Select(v => new ord_memoExport() { resid = v.resid,resAscription=v.resAscription }).ToList();
|
||
var title = "[resid][cname][innerUserId][ctime][calltime][STRCONTENT]";
|
||
var titleTxt = "客户ID,姓名,受理人,受理时间,开始时间,工单内容";
|
||
if (MemoSubtype == "1023")
|
||
{
|
||
//标签工单才执行此处理(北一)
|
||
title = "[resid][cname][innerUserId][ctime][calltime][STRCONTENT][QW][CP][ZHIBO][ZHIBOTXT][MYD][MYDTXT]";
|
||
titleTxt = "客户ID,姓名,受理人,受理时间,开始时间,工单内容,企微,产品,直播,直播说明,满意度,满意度说明";
|
||
}
|
||
return File(ExcelHelper.ExportListModelToExcel<ORD_MemoQuery>(list, "工单综合查询", 60000, title, titleTxt, DataFormart), "application/ms-excel", PageRequest.GetDlownLoadName("客户编号" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"));
|
||
|
||
//return File(ExcelHelper.ExportListModelToExcel<ord_memoExport>(ListExp, "工单综合查询", 60000, "[resid][resAscription]", "客户ID,资源归属", null), "application/ms-excel", PageRequest.GetDlownLoadName("客户编号" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"));
|
||
}
|
||
#endregion
|
||
|
||
#region 所有客户编号导出
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_工单查询)]
|
||
public FileResult AllResourceIDExport(QueryUserComboDto userComboDto)
|
||
{
|
||
string memoId = Request.QueryString["memoId"];
|
||
string stime = Request.QueryString["stime"];
|
||
string etime = Request.QueryString["etime"];
|
||
string BusinessType = Request.QueryString["BusinessType"];
|
||
string MemoType = Request.QueryString["MemoType"];
|
||
string MemoSubtype = Request.QueryString["MemoSubtype"];
|
||
//string saleDeptId = Request.QueryString["saleDeptId"];
|
||
//string groupId = Request.QueryString["groupId"];
|
||
//string userId = Request.QueryString["userId"];
|
||
//var bangwx = Request["bangwx"];
|
||
string eid = Request["eid"];
|
||
string resid = Request["resid"];
|
||
//LogHelper.Info("bangwx:" + bangwx);
|
||
//LogHelper.Info("schkMemo:" + schkMemo);
|
||
//var wxResIds = new List<string>();
|
||
//if (bangwx == "true")
|
||
//{
|
||
// wxResIds = _wxRcontact.GetList(p => p.RESID != null).Select(p => p.RESID).ToList();
|
||
//}
|
||
if (!string.IsNullOrEmpty(eid))
|
||
{
|
||
userComboDto.userId = InnerUserHelper.Instance.GetUserIdByEid(int.Parse(eid));
|
||
}
|
||
List<ord_memoExport> list = new List<ord_memoExport>();
|
||
#region 获取数据
|
||
switch (Convert.ToInt32(BusinessType))
|
||
{
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.服务工单:
|
||
list = serviceMemoBiz_Q.GetMemoResId(memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.特殊订单:
|
||
list = specialMemoBiz_Q.GetMemoResId(memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.销售工单:
|
||
list = saleMemoBiz_Q.GetMemoResId(memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), userComboDto);
|
||
break;
|
||
case (int)WX.CRM.Model.Enum.EnumMemoType.意向工单:
|
||
list = purposeMemoBiz_Q.GetMemoResId(memoId, stime, etime, resid, Convert.ToDecimal(MemoType), Convert.ToDecimal(MemoSubtype), userComboDto);
|
||
break;
|
||
}
|
||
#endregion
|
||
//list = list.Where(p => !wxResIds.Contains(p.resid)).ToList();
|
||
//return File(ExcelHelper.ExportListObjectToExcel(list, "客户编号", "工单综合查询", null), "application/ms-excel", PageRequest.GetDlownLoadName("客户编号" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"));
|
||
return File(ExcelHelper.ExportListModelToExcel<ord_memoExport>(list, "工单综合查询", 60000, "[resid][otherResid][resascription][name][innerUserId][ctime][calltime]", "客户ID,客户相关客户ID,资源归属,姓名,受理人,受理时间,开始时间", DataFormart), "application/ms-excel", PageRequest.GetDlownLoadName("客户编号" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"));
|
||
}
|
||
|
||
public string DataFormart(string key, object value)
|
||
{
|
||
string formartValue = string.Empty;
|
||
switch (key)
|
||
{
|
||
case "innerUserId":
|
||
formartValue = InnerUserHelper.Instance.EidAndName(Convert.ToDecimal(value)).ToString(); break;
|
||
case "INNERUSERID":
|
||
formartValue = InnerUserHelper.Instance.EidAndName(Convert.ToDecimal(value)).ToString(); break;
|
||
|
||
default: formartValue = string.Format("{0}", value); break;
|
||
}
|
||
return formartValue;
|
||
}
|
||
#endregion
|
||
}
|
||
} |