| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- using CallCenter.Utility;
- using CallCenterApi.Common;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.tel
- {
- [Authority]
- public class CallrecordsController : BaseController
- {
- //获取通话记录列表
- public ActionResult GetList(string phone, string usercode,int isdc=0)
- {
- string sql = "";
- DataTable dt = new DataTable();
- // int roleid = User.F_RoleId;
- string callstate = HttpUtility.UrlDecode(RequestString.GetQueryString("callstate"));
- string calltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
- string actiontype = HttpUtility.UrlDecode(RequestString.GetQueryString("actiontype"));
- string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string tasktype = HttpUtility.UrlDecode(RequestString.GetQueryString("tasktype"));
- string extnumber = HttpUtility.UrlDecode(RequestString.GetQueryString("extnumber"));
- string PhoneType = HttpUtility.UrlDecode(RequestString.GetQueryString("phoneType"));
- int type = RequestString.GetInt("type", 0);
- int islike = RequestString.GetInt("islike", 1);
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- //if (roleid != 0)
- //{
- // if (roleid == 1)
- // {
- // sql += " and UserCode='" + User.F_WorkNumber + "' ";
- // }
- //}
- if (type != 0)
- {
- sql += " and F_CallInType = '" + type + "' ";
- }
- if (usercode != null && usercode.Trim() != "")
- {
- sql += " and UserCode in(" + usercode + ")";
- }
- if (PhoneType != null && PhoneType.Trim() != "")
- {
- sql += " and PhoneType='"+ PhoneType + "'";
- }
-
- if (islike > 0)
- {
- if (phone != null && phone.Trim() != "")
- {
- sql += " and CallNumber like '%" + phone + "%'";
- }
- }
- else
- {
- if (phone != null && phone.Trim() != "")
- {
- sql += " and CallNumber = '" + phone + "'";
- }
- }
- if (callstate.Trim() != "")
- {
- if (callstate.Trim() == "0")
- {
- sql += " and CallState=0 and isnull(UserCode,'')!='' ";
- }
- else if (callstate.Trim() == "3")
- {
- sql += " and CallState=0 and CallType=0 and isnull(UserCode,'')='' ";
- }
- else
- {
- sql += " and CallState='" + callstate + "'";
- }
- }
- //else
- // sql += " and isnull(UserCode,'')<>'' ";
- if (calltype.Trim() != "")
- {
- if (calltype=="3")
- {
- sql += " and CallType='1'";
- sql += " and CallId in(select F_CallRecordId from T_Bus_VisitResult WITH(NOLOCK) where F_CallRecordId !='' and F_CallRecordId is not null )";
- }
- else
- sql += " and CallType='" + calltype + "'";
- }
- if (tasktype.Trim() != "")
- {
- if (tasktype.Trim() == "2")
- {
- sql += " and TaskType='" + tasktype + "'";
- }
- else if (tasktype.Trim() == "0")
- {
- sql += " and (TaskType is null or TaskType!='2')";
- }
- }
- if (actiontype.Trim() != "")
- {
- sql += " and ActionType=" + actiontype.Trim();
- }
- if (starttime.Trim() != "")
- {
- sql += " and BeginTime>='" + starttime + "' ";
- }
- if (endtime.Trim() != "")
- {
- sql += " and BeginTime<='" + endtime + "' ";
- }
- if(extnumber.Trim()!="")
- {
- sql += " and isnull(ExtNumber,'')='" + extnumber.Trim() + "'";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- if (isdc > 0)
- {
- var dtdc = DbHelperSQL.Query(" select ROW_NUMBER() OVER(ORDER BY CallRecordsId desc) 编号, CallNumber 电话号码,(case CallType when 0 then '呼入' else '呼出' end ) 呼叫方向,(case CallState when 0 then ( case CallType when 0 then (case when isnull(UserCode,'')!='' then '主动放弃' else '未接通' end) else '未接通' end ) else '已接通' end ) 呼叫状态,UserCode 坐席工号,dbo.GetUserName(UserCode) as 坐席姓名, "
- + "BeginTime 开始时间,TalkStartTime 通话开始时间 ,TalkEndTime " +
- " 通话结束时间 ,EndTime 结束时间 ,LongTime 通话时长 ,PhoneType " +
- "电话类别"
- + " from T_Call_CallRecords a WITH(NOLOCK) where 1=1 " + sql+ "ORDER BY CallRecordsId desc").Tables[0];
- var msg = new NPOIHelper().ExportToExcel("通话记录", dtdc);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- else
- {
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Call_CallRecords WITH(NOLOCK)",
- "CallRecordsId",
- "*,dbo.GetUserName(UserCode) as UserName",
- sql,
- "ORDER BY CallRecordsId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- // var usercodes= (from r in dt.AsEnumerable() select r.Field<string>("UserCode")).ToList<string>().Distinct();
- // var users = new BLL.T_Sys_UserAccount().GetModelList(" F_UserCode in ('" + string.Join("','", usercodes) + "')");
- dt.Columns.Add("TypeName", typeof(string));
- dt.Columns.Add("WorkOrderId", typeof(string));
- foreach (DataRow dr in dt.Rows)
- {
- string path = dr["FilePath"] != null ? dr["FilePath"].ToString() : "";
- if (path != "" && config != null && !string.IsNullOrEmpty(config.F_ParamValue))
- {
- var ym = config.F_ParamValue;
- if (ym.Substring(ym.Length - 1) == "/")
- {
- ym = ym.Substring(0, ym.Length - 1);
- }
- string lujing = path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
- string wlpath = ym + lujing;
- //if (!CommonHelper.FileIsExist(wlpath))
- //{
- // wlpath = lujing;
- //}
- dr["FilePath"] = wlpath;
- }
- if (dr["F_CallInType"] != null && dr["F_CallInType"].ToString() != "")
- {
- int tid = Int32.Parse(dr["F_CallInType"].ToString());
- var tn = new BLL.T_Sys_DictionaryValue().GetModel(tid);
- if (tn != null)
- {
- dr["TypeName"] = tn.F_Value;
- }
- }
- dr["WorkOrderId"] = DB.DbHelperSQL.GetSingle(" select top 1 F_WorkOrderId from T_Bus_WorkOrder WITH(NOLOCK) where F_CallRecordId='" + dr["CallRecordsId"].ToString() + "' and F_IsDelete=0 ");
- }
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
-
- }
- //获取未接来电
- public ActionResult GetListWJ(string phone)
- {
- string sql = "";
- DataTable dt = new DataTable();
- string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string ishf = HttpUtility.UrlDecode(RequestString.GetQueryString("ishf"));//是否回复 0否1是
- string ishfSuccess = HttpUtility.UrlDecode(RequestString.GetQueryString("ishfsuc"));//是否回复成功 0否1是
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (phone != null && phone.Trim() != "")
- {
- sql += " and CallNumber like '%" + phone + "%'";
- }
- if (starttime.Trim() != "")
- {
- sql += " and datediff(day,BeginTime,'" + starttime.Trim() + "')<=0 ";
- }
- if (endtime.Trim() != "")
- {
- sql += " and datediff(day,BeginTime,'" + endtime.Trim() + "')>=0 ";
- }
- if (ishf.Trim() != "")
- {
- sql += " and F_wjishf=" + ishf.Trim() + " ";
- }
- if (ishfSuccess.Trim() != "")
- {
- sql += " and F_wjishfSuccess=" + ishfSuccess.Trim() + " ";
- }
- sql += " and CallState='0'";
- sql += " and CallType='0'";
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Call_CallRecords WITH(NOLOCK)",
- "CallRecordsId",
- "*",
- sql,
- "ORDER BY CallRecordsId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- //获取转移或三方通话,均为手机号
- //rep_transfer只有转移的数据
- public ActionResult GetListZY(string phone, string usercode)
- {
- string sql = "";
- DataTable dt = new DataTable();
- string callstate = HttpUtility.UrlDecode(RequestString.GetQueryString("callstate"));
- string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- sql += " and ActionType>1";//1正常呼入呼出、2转移、3三方通话
- if (usercode != null && usercode.Trim() != "")
- {
- sql += " and UserCode='" + usercode + "'";
- }
- if (phone != null && phone.Trim() != "")
- {
- sql += " and CallNumber like '%" + phone + "%'";
- }
- if (callstate.Trim() != "")
- {
- sql += " and CallState='" + callstate + "'";
- }
- if (starttime.Trim() != "")
- {
- sql += " and datediff(day,BeginTime,'" + starttime + "')<=0 ";
- }
- if (endtime.Trim() != "")
- {
- sql += " and datediff(day,BeginTime,'" + endtime + "')>=0 ";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
-
-
- dt = BLL.PagerBLL.GetListPager(
- "T_Call_CallRecords WITH(NOLOCK)",
- "CallRecordsId",
- "*",
- sql,
- "ORDER BY CallRecordsId desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- List<Model.T_Call_CallRecords> callList = new BLL.T_Call_CallRecords().DataTableToList(dt);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = callList,
- total = recordCount
- };
- return Content(obj.ToJson());
-
-
- }
- //删除通话记录
- public ActionResult DelCallRecord(string[] ids)
- {
- if (ids != null && ids.Length > 0)
- {
- string idd = " ";
- foreach (string str in ids)
- {
- idd += str + ",";
- }
- if (new BLL.T_Call_CallRecords().DeleteList(idd.TrimEnd(',')))
- {
- return Success("删除成功");
- }
- else
- return Error("删除失败");
- }
- else
- {
- return Error("请选择要删除的记录");
- }
- }
- }
- }
|