| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100 |
- using CallCenter.Utility;
- using CallCenter.Utility.Time;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Filter;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.quality
- {
- public class QCManageController : BaseController
- {
- private readonly BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
- private readonly BLL.CallResult callResultBLL = new BLL.CallResult();
- private readonly BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
- #region 非自动外呼质检
- //获取未质检列表
- public ActionResult GetList()
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- string sql = " 1=1 ";
- DataTable dt = new DataTable();
- string phone = HttpUtility.UrlDecode(RequestString.GetQueryString("phone"));
- string usercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
- string calltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
- //string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- //string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string starttime = DateTime.Now.ToString("yyyy-MM-hh ") + " 00:00:01";
- string endtime = DateTime.Now.ToString("yyyy-MM-hh ") + " 23:59:59";
- string startl = HttpUtility.UrlDecode(RequestString.GetQueryString("startl"));
- string endl = HttpUtility.UrlDecode(RequestString.GetQueryString("endl"));
- string optid = HttpUtility.UrlDecode(RequestString.GetQueryString("optid"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- var roleId = CurrentUser.UserData.F_RoleId;
- var deptId = CurrentUser.UserData.F_DeptId;
- var deptCode = CurrentUser.UserData.F_DeptCode;
- var currentUsercode = CurrentUser.UserData.F_UserCode;
- if (roleId != 0)
- {
- if (roleId != 17)
- {
- if (deptCode.Replace("|0|1|", "").Length > 0)
- {
- if (roleId == 36 || roleId == 38 || roleId == 40)
- {
- sql += $" and UserCode='{currentUsercode}'";
- }
- else
- {
- sql += $" and UserCode in (SELECT F_UserCode FROM T_Sys_UserAccount WHERE F_DeptId={deptId})";
- }
- }
- else
- {
- if (roleId != 53 && roleId != 54)
- {
- sql += $" and UserCode in (SELECT F_UserCode FROM T_Sys_UserAccount WHERE F_DeptId={deptId})";
- }
- }
- }
- }
- sql += " and CallState='1' and F_QCState<>1 ";
- if (phone.Trim() != "")
- {
- sql += " and CallNumber='" + phone + "'";
- }
- if (usercode.Trim() != "")
- {
- sql += " and UserCode='" + usercode + "'";
- }
- if (calltype.Trim() != "")
- {
- sql += " and CallType='" + calltype + "'";
- }
- //if (starttime.Trim() == "" && endtime.Trim() == "")
- //{
- // sql += " and DATEDIFF(week, BeginTime,getdate())=1 ";//默认显示上周记录
- //}
- //else
- //{
- if (starttime.Trim() != "")
- {
- sql += " and BeginTime>='" + starttime + "'";
- }
- if (endtime.Trim() != "")
- {
- sql += " and BeginTime<='" + endtime + "'";
- }
- //}
- if (startl.Trim() != "")
- {
- sql += " and TalkLongTime>=" + startl + " ";
- }
- if (endl.Trim() != "")
- {
- sql += " and TalkLongTime<=" + endl + " ";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- List<Model.T_Call_CallRecords_QC> Plist = new BLL.T_Call_CallRecords_QC().GetModelList(sql);//.GetListV1(sql);
- List<Model.T_Call_CallRecordsLD> ldList = new BLL.T_Call_CallRecordsLD().GetModelList("");
- List<Model.T_Sys_UserAccount> userList = userBLL.DataTableToList(userBLL.GetList("").Tables[0]);
- List<Model.T_Sys_Department> deptList = deptBLL.DataTableToList(deptBLL.GetList("").Tables[0]);
- Model.PageData<object> pageData = new Model.PageData<object>();
- var list = Plist.Select(d =>
- {
- int lc = ldList.Where(l => l.F_CallRecordsID == d.CallRecordsId && l.F_OptID == int.Parse(optid) && l.F_IsListen == true).Count();
- int dc = ldList.Where(l => l.F_CallRecordsID == d.CallRecordsId && l.F_OptID == int.Parse(optid) && l.F_IsDownload == true).Count();
- string path = string.IsNullOrWhiteSpace(d.FilePath) ? "" : d.FilePath;
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- var configbak = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPathBak' ").FirstOrDefault(); //备份录音服务器地址
- //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);
- // }
- // d.FilePath = ym + path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
- //}
- //2018-05-16 lihai 判断录音是否存在
- //特别备注说明:所有备份录音都放到luyin文件夹下,所以FilePath录音目前需要处理
- if (path != "")
- {
- //文件路径
- var pathfile = path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
- if (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);
- }
- d.FilePath = ym + pathfile;
- }
- //判断是否录音存在,不存在用备份录音路径
- bool isfile = FileExistsHelper.RemoteFileExists(d.FilePath);
- if (!isfile)
- {
- //处理备份录音路径,record,和luyin文件都要过滤掉,配置文件加上ip+luyin
- pathfile = pathfile.Replace("Record", "luyin");
- if (configbak != null && !string.IsNullOrEmpty(configbak.F_ParamValue))
- {
- var ymbak = configbak.F_ParamValue;
- if (ymbak.Substring(ymbak.Length - 1) == "/")
- {
- ymbak = ymbak.Substring(0, ymbak.Length - 1);
- }
- d.FilePath = ymbak + pathfile;
- }
- }
- }
- var user = userList.SingleOrDefault(x => x.F_UserCode == d.UserCode);
- var dept = deptList.SingleOrDefault(x => x.F_DeptId == (user?.F_DeptId ?? 0));
- var deptParent = deptList.SingleOrDefault(x => x.F_DeptId == (dept?.F_ParentId ?? 0));
- return new
- {
- _callnumber = d.CallNumber,
- _filepath = d.FilePath,
- _f_qcstate = d.F_QCState,
- _f_qcscore = d.F_QCScore,
- _f_qcquestion = d.F_QCQuestion,
- _f_qcadvise = d.F_QCAdvise,
- _calltype = d.CallType,
- _callstate = d.CallState,
- _usercode = d.UserCode,
- _username = user?.F_UserName ?? "",
- _company = deptParent?.F_DeptName ?? "",
- _deptname = d.F_DeptName,
- _talkstarttime = d.TalkStartTime,
- _talkendtime = d.TalkEndTime,
- _talklongtime = d.TalkLongTime,
- _businesstype = d.BusinessType,
- _f_qclc = lc,
- _f_qcdc = dc,
- _callrecordsid = d.CallRecordsId,
- _callid = d.CallId
- };
- }).ToList<object>();
- //pageData.Rows = list.Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
- //pageData.Total = list.Count;
- var obj = new
- {
- rows = list.Skip((pageindex - 1) * pagesize).Take(pagesize).ToList(),
- total = list.Count
- };
- res = Content(obj.ToJson());
- //if (pageData.Total > 0)
- //{
- // res = Success("未质检列表加载成功", pageData);
- //}
- //else
- //{
- // res = Error("未质检列表暂无数据");
- //}
- return res;
- }
- //获取已质检列表
- public ActionResult GetYZJList()
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- string sql = " 1=1 ";
- DataTable dt = new DataTable();
- string phone = HttpUtility.UrlDecode(RequestString.GetQueryString("phone"));
- string usercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
- string calltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
- //string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- //string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string startl = HttpUtility.UrlDecode(RequestString.GetQueryString("startl"));
- string endl = HttpUtility.UrlDecode(RequestString.GetQueryString("endl"));
- string optid = HttpUtility.UrlDecode(RequestString.GetQueryString("optid"));
- string starttime = DateTime.Now.ToString("yyyy-MM-hh ") + " 00:00:01";
- string endtime = DateTime.Now.ToString("yyyy-MM-hh ") + " 23:59:59";
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- var roleId = CurrentUser.UserData.F_RoleId;
- var deptId = CurrentUser.UserData.F_DeptId;
- var deptCode = CurrentUser.UserData.F_DeptCode;
- var currentUsercode = CurrentUser.UserData.F_UserCode;
- if (roleId != 0)
- {
- if (roleId != 17)
- {
- if (deptCode.Replace("|0|1|", "").Length > 0)
- {
- if (roleId == 36 || roleId == 38 || roleId == 40)
- {
- sql += $" and UserCode='{currentUsercode}'";
- }
- else
- {
- sql += $" and UserCode in (SELECT F_UserCode FROM T_Sys_UserAccount WHERE F_DeptId={deptId})";
- }
- }
- else
- {
- if (roleId != 53 && roleId != 54)
- {
- sql += $" and UserCode in (SELECT F_UserCode FROM T_Sys_UserAccount WHERE F_DeptId={deptId})";
- }
- }
- }
- }
- //已接通,已质检
- sql += " and CallState='1' and F_QCState=1 ";
- if (phone.Trim() != "")
- {
- sql += " and CallNumber='" + phone + "'";
- }
- if (usercode.Trim() != "")
- {
- sql += " and UserCode='" + usercode + "'";
- }
- if (calltype.Trim() != "")
- {
- sql += " and CallType='" + calltype + "'";
- }
- if (starttime.Trim() != "")
- {
- sql += " and BeginTime>='" + starttime + "'";
- }
- if (endtime.Trim() != "")
- {
- sql += " and BeginTime<='" + endtime + "'";
- }
- if (startl.Trim() != "")
- {
- sql += " and TalkLongTime>=" + startl + " ";
- }
- if (endl.Trim() != "")
- {
- sql += " and TalkLongTime<=" + endl + " ";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- List<Model.T_Call_CallRecords_QC> Plist = new BLL.T_Call_CallRecords_QC().GetModelList(sql);//.GetListV1(sql);
- List<Model.T_Call_CallRecordsLD> ldList = new BLL.T_Call_CallRecordsLD().GetModelList("");
- List<Model.T_Sys_UserAccount> userList = userBLL.DataTableToList(userBLL.GetList("").Tables[0]);
- List<Model.T_Sys_Department> deptList = deptBLL.DataTableToList(deptBLL.GetList("").Tables[0]);
- Model.PageData<object> pageData = new Model.PageData<object>();
- var list = Plist.Select(d =>
- {
- int lc = ldList.Where(l => l.F_CallRecordsID == d.CallRecordsId && l.F_OptID == int.Parse(optid) && l.F_IsListen == true).Count();
- int dc = ldList.Where(l => l.F_CallRecordsID == d.CallRecordsId && l.F_OptID == int.Parse(optid) && l.F_IsDownload == true).Count();
- string path = string.IsNullOrWhiteSpace(d.FilePath) ? "" : d.FilePath;
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- var configbak = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPathBak' ").FirstOrDefault(); //备份录音服务器地址
- //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);
- // }
- // d.FilePath = ym + path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
- //}
- //2018-05-16 lihai 判断录音是否存在
- //特别备注说明:所有备份录音都放到luyin文件夹下,所以FilePath录音目前需要处理
- if (path != "")
- {
- //文件路径
- var pathfile = path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
- if (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);
- }
- d.FilePath = ym + pathfile;
- }
- //判断是否录音存在,不存在用备份录音路径
- bool isfile = FileExistsHelper.RemoteFileExists(d.FilePath);
- if (!isfile)
- {
- //处理备份录音路径,record,和luyin文件都要过滤掉,配置文件加上ip+luyin
- pathfile = pathfile.Replace("Record", "luyin");
- if (configbak != null && !string.IsNullOrEmpty(configbak.F_ParamValue))
- {
- var ymbak = configbak.F_ParamValue;
- if (ymbak.Substring(ymbak.Length - 1) == "/")
- {
- ymbak = ymbak.Substring(0, ymbak.Length - 1);
- }
- d.FilePath = ymbak + pathfile;
- }
- }
- }
- var user = userList.SingleOrDefault(x => x.F_UserCode == d.UserCode);
- var dept = deptList.SingleOrDefault(x => x.F_DeptId == user.F_DeptId);
- var deptParent = deptList.SingleOrDefault(x => x.F_DeptId == dept.F_ParentId);
- return new
- {
- _callnumber = d.CallNumber,
- _filepath = d.FilePath,
- _f_qcstate = d.F_QCState,
- _f_qcscore = d.F_QCScore,
- _f_qcquestion = d.F_QCQuestion,
- _f_qcadvise = d.F_QCAdvise,
- _calltype = d.CallType,
- _callstate = d.CallState,
- _usercode = d.UserCode,
- _username = user?.F_UserName ?? "",
- _talkstarttime = d.TalkStartTime,
- _talkendtime = d.TalkEndTime,
- _talklongtime = d.TalkLongTime,
- _businesstype = d.BusinessType,
- _f_qclc = lc,
- _f_qcdc = dc,
- _callrecordsid = d.CallRecordsId,
- _deptname = d.F_DeptName,
- _company = deptParent?.F_DeptName ?? "",
- _callid = d.CallId
- };
- }).ToList<object>();
- var obj = new
- {
- rows = list.Skip((pageindex - 1) * pagesize).Take(pagesize).ToList(),
- total = list.Count
- };
- res = Content(obj.ToJson());
- //pageData.Rows = list.Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
- //pageData.Total = list.Count;
- //if (pageData.Total > 0)
- //{
- // res = Success("已质检列表加载成功", pageData);
- //}
- //else
- //{
- // res = Error("已质检列表暂无数据");
- //}
- return res;
- }
- //获取质检详情
- public ActionResult GetIndexList(string id)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- DataTable dt = new DataTable();
- DataTable dtindex = new DataTable();
- DataTable dtres = new DataTable();
- dt = new BLL.T_QC_IndexCategory().GetList(" F_DeleteFlag=0 order by F_Sort ,F_CategoryId").Tables[0];
- dtindex = new BLL.T_QC_IndexBase().GetList(" F_DeleteFlag=0 order by F_Sort ,F_CategoryId").Tables[0];
- dtres = new BLL.T_QC_IndexRes().GetList(" CallRecordsId=" + id + " ").Tables[0];
- int i = 0;
- int m = 0;
- int indexcount = 0;
- int allscore = 0;
- int childscore = 0;
- int childpf = 0;
- int allpf = 0;
- List<Model.QCModel> qclist = new List<Model.QCModel>();
- object obj = null;
- foreach (DataRow dr in dt.Select("F_ParentId=0"))
- {
- Model.QCModel qcml = new Model.QCModel();
- List<Model.QCModel> qcclist = new List<Model.QCModel>();
- i = 0;
- indexcount = 0;
- childscore = 0;
- childpf = 0;
- string categoryid = dr["F_CategoryId"].ToString().Trim();
- qcml.Qcid = categoryid;
- qcml.Qcname = dr["F_CategoryName"].ToString().Trim();
- obj = DbHelperSQL.GetSingle("select count(*) from T_QC_IndexBase where F_CategoryId in(select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + dr["F_CategoryId"] + ")");
- qcml.Rowspan = obj.ToString();
- foreach (DataRow childdr in dt.Select("F_ParentId=" + categoryid + ""))
- {
- Model.QCModel qcmlc = new Model.QCModel();
- List<Model.QCModel> qccrlist = new List<Model.QCModel>();
- m = 0;
- #region 子分类
- string childcategoryid = childdr["F_CategoryId"].ToString().Trim();
- DataRow[] arrchild = dtindex.Select("F_CategoryId=" + childcategoryid + "");
- indexcount += arrchild.Length;
- //加载项
- qcmlc.Qcid = categoryid + "-" + childcategoryid;
- qcmlc.Qcname = childdr["F_CategoryName"].ToString().Trim();
- obj = DbHelperSQL.GetSingle("select count(*) from T_QC_IndexBase where F_CategoryId=" + childdr["F_CategoryId"]);
- qcmlc.Rowspan = obj.ToString();
- #endregion
- foreach (DataRow indexdr in arrchild)
- {
- Model.QCModel qcmlcr = new Model.QCModel();
- string indexid = indexdr["F_IndexId"].ToString().Trim();
- string pf = "0";
- try
- {
- //分类分数合计
- childscore += Convert.ToInt32(indexdr["F_Score"].ToString().Trim());
- //总计合计
- allscore += Convert.ToInt32(indexdr["F_Score"].ToString().Trim());
- }
- catch
- { }
- try
- {
- pf = dtres.Select("F_IndexId=" + indexid + "")[0]["F_QCScore"].ToString().Trim();
- childpf += Convert.ToInt32(pf);//分类评分合计
- allpf += Convert.ToInt32(pf);//评分总计
- }
- catch
- {
- }
- #region 指标
- //加载指标
- qcmlcr.Qcid = categoryid + "-" + childcategoryid + "-" + indexid;
- qcmlcr.Qcname = indexdr["F_Title"].ToString().Trim();
- qcmlcr.Qcscore = indexdr["F_Score"].ToString().Trim();
- qcmlcr.Qcpf = pf;
- qcmlcr.Rowspan = "0";
- qcmlcr.Colspan = "0";
- #endregion
- m++;
- qccrlist.Add(qcmlcr);
- }
- i++;
- qcmlc.Qclist = qccrlist;
- qcclist.Add(qcmlc);
- }
- //合计
- qcml.Qcscore = childscore.ToString().Trim();
- qcml.Qcpf = childpf.ToString().Trim();
- qcml.Qclist = qcclist;
- qcml.Colspan = "2";
- qclist.Add(qcml);
- }
- Model.QCModel qcmlhj = new Model.QCModel();
- qcmlhj.Qcid = "0";
- qcmlhj.Qcname = "总计";
- qcmlhj.Qcscore = allscore.ToString().Trim();
- qcmlhj.Qcpf = allpf.ToString().Trim();
- qcmlhj.Qclist = qclist;
- qcmlhj.Colspan = "3";
- res = Success("质检部分加载成功", qcmlhj);
- dtres.Clear();
- dtres.Dispose();
- dtindex.Clear();
- dtindex.Dispose();
- dt.Clear();
- dt.Dispose();
- return res;
- }
- //保存质检得分
- public ActionResult SaveData(string id, string xmlinfo)
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- DataTable dt = new DataTable();
- //string id = HttpUtility.UrlDecode(RequestString.GetQueryString("id"));
- //string userid = HttpUtility.UrlDecode(RequestString.GetQueryString("userid"));
- //string username = HttpUtility.UrlDecode(RequestString.GetQueryString("username"));
- //string xmlinfo = HttpUtility.UrlDecode(RequestString.GetQueryString("xmlinfo"));
- //string question = HttpUtility.UrlDecode(RequestString.GetQueryString("question"));
- //string advise = HttpUtility.UrlDecode(RequestString.GetQueryString("advise"));
- dt = new BLL.T_QC_IndexRes().GetList(" CallRecordsId=" + id + " ").Tables[0];
- int allscore = 0;
- foreach (string scoreinfo in xmlinfo.Trim(';').Split(';'))
- {
- //判断存在该指标评估则修改,无则添加
- string idsss = scoreinfo.Split(':')[0];
- string indexid = idsss.Split('-')[2];
- if (dt.Select(" F_IndexId=" + indexid + " ").Length > 0)
- {
- Model.T_QC_IndexRes model = new Model.T_QC_IndexRes();
- model.F_Id = Convert.ToInt32(dt.Select(" F_IndexId=" + indexid + " ")[0]["F_Id"].ToString());
- model.CallRecordsId = Convert.ToInt32(id);
- try
- {
- model.F_IndexId = Convert.ToInt32(indexid);
- }
- catch
- { }
- try
- {
- model.F_QCScore = Convert.ToInt32(scoreinfo.Split(':')[1]);
- allscore += Convert.ToInt32(scoreinfo.Split(':')[1]);
- }
- catch
- { }
- new BLL.T_QC_IndexRes().Update(model);
- }
- else
- {
- Model.T_QC_IndexRes model = new Model.T_QC_IndexRes();
- model.CallRecordsId = Convert.ToInt32(id);
- try
- {
- model.F_IndexId = Convert.ToInt32(indexid);
- }
- catch
- { }
- try
- {
- model.F_QCScore = Convert.ToInt32(scoreinfo.Split(':')[1]);
- allscore += Convert.ToInt32(scoreinfo.Split(':')[1]);
- }
- catch
- { }
- new BLL.T_QC_IndexRes().Add(model);
- }
- }
- Model.T_Call_CallRecords_QC callmodel = new Model.T_Call_CallRecords_QC();
- callmodel.CallRecordsId = Convert.ToInt32(id);
- callmodel.F_QCState = 1;
- callmodel.F_QCScore = allscore;
- callmodel.F_QCUserId = CurrentUser.UserData.F_UserId;
- callmodel.F_QCUserName = CurrentUser.UserData.F_UserName;
- callmodel.F_QCTime = DateTime.Now;
- callmodel.F_QCIsSelect = 0;
- callmodel.F_QCRemark = "";
- //callmodel.F_QCQuestion = question;
- //callmodel.F_QCAdvise = advise;
- if (new BLL.T_Call_CallRecords_QC().UpdateQC(callmodel))
- {
- res = Success("保存成功");
- }
- else
- {
- res = Error("保存质检评分信息失败");
- }
- dt.Clear();
- dt.Dispose();
- return res;
- }
- //添加日志
- public ActionResult AddLogs()
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- string id = HttpUtility.UrlDecode(RequestString.GetQueryString("id"));
- //string optid = HttpUtility.UrlDecode(RequestString.GetQueryString("optid"));
- //string optby = HttpUtility.UrlDecode(RequestString.GetQueryString("optby"));
- string type = HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
- bool r = addldlog(int.Parse(id), CurrentUser.UserData.F_UserId, CurrentUser.UserData.F_UserName, int.Parse(type));
- if (r)
- {
- res = Success("添加日志成功");
- }
- else
- {
- res = Error("添加日志失败");
- }
- return res;
- }
- private bool addldlog(int id, int optid, string optby, int type)
- {
- bool res = false;
- try
- {
- Model.T_Call_CallRecordsLD ldmodel = new Model.T_Call_CallRecordsLD();
- ldmodel.F_CallRecordsID = id;
- if (type == 0)
- ldmodel.F_IsListen = true;
- else if (type == 1)
- ldmodel.F_IsDownload = true;
- ldmodel.F_OptID = optid;
- ldmodel.F_OptBy = optby;
- ldmodel.F_OptDate = DateTime.Now;
- res = new BLL.T_Call_CallRecordsLD().Add(ldmodel) > 1;
- }
- catch (Exception ex)
- {
- }
- return res;
- }
- #endregion
- #region 自动外呼质检—号码质检
- /// <summary>
- /// 未质检列表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetAutoCallList(FilterTalkRecord filter)
- {
- var sort = "ORDER BY startdate desc";
- if (!string.IsNullOrWhiteSpace(filter.SortField))
- {
- var arr = filter.SortField.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- EnumTalkRecordsSortField e;
- if (!Enum.TryParse(arr[0], out e))
- return Error("排序字段参数错误");
- sort = "ORDER BY " + e.ToString() + " " + arr[1];
- }
- StringBuilder where = new StringBuilder();
- if (!string.IsNullOrWhiteSpace(filter.UserCode))
- {
- where.Append(" and agentid=" + filter.UserCode);
- }
- if (!string.IsNullOrWhiteSpace(filter.Phone))
- {
- where.Append(" and callee like '%" + filter.Phone + "%'");
- }
- if (!string.IsNullOrWhiteSpace(filter.TalkTime))
- {
- var arr = filter.TalkTime.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- if (arr.Length == 2)
- {
- if (arr[0] == "1")
- {
- where.Append(" and talktime>" + arr[1]);
- }
- else if (arr[0] == "2")
- {
- where.Append(" and talktime=" + arr[1]);
- }
- else if (arr[0] == "3")
- {
- where.Append(" and talktime<" + arr[1]);
- }
- else { }
- }
- }
- if (filter.StartTime == null || filter.EndTime == null)
- {
- filter.StartTime = DateTools.FirstSecondOfOneDay(DateTime.Now);
- filter.EndTime = DateTools.LastSecondOfOneDay(DateTime.Now);
- }
- //qcstate=1 = 已质检; qcstate=0 =未质检
- //qcstate 全部=0;未转坐席 = 1; 被叫接通转坐席未接 = 2; 转坐席且接通 = 3,
- where.Append(" and qcstate=0 and calltype in (2,3) and datediff(s,'" + filter.StartTime + "',StartDate)>=0 and datediff(s,EndDate,'" + filter.EndTime + "')>=0 ");
- int recordCount = 0;
- Model.PageData<Model.CallResult> pageModel = new Model.PageData<Model.CallResult>();
- StringBuilder fields = new StringBuilder();
- var dt = BLL.PagerBLL.GetListPager(
- "V_AutoCallResult",
- "Id",
- "id,itemid,taskname, callee, agentid, username,startdate,enddate,getinagentdate,calltype,talktime,RecordPath, QCState, QCScore, QCRemark, QCUserId, QCUserName,QCTime",
- where.ToString(),
- sort,
- filter.PageSize,
- filter.PageIndex,
- true,
- out recordCount);
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- var callResultList = callResultBLL.DataTableToListQC(dt);
- var obj = new
- {
- rows = callResultList.Select(x => new
- {
- id = x.Id,
- taskid = x.TaskId,
- callnumber = x.CallNumber,
- usercode = x.Usercode == "0" ? "" : x.Usercode,
- startdate = x.StartDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? "",
- getinagentdate = x.GetInAgentDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? "",
- enddate = x.EndDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? "",
- username = x.Username,
- calltype = Enum.Parse(typeof(EnumTalkRecordsCallType), x.CallType.ToString()).ToString(),
- talktime = x.TalkTime > 0 ? x.TalkTime.ToString() : "0",
- qcstate = x.QCState == 0 ? "未质检" : "已质检",
- qcscore = x.QCScore,
- qcremark = x.QCRemark ?? "",
- qcuserid = x.QCUserId?.ToString() ?? "",
- qcusername = x.QCUserName ?? "",
- qctime = x.QCTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? ""
- }),
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 已质检列表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetAutoCallYZJList(FilterTalkRecord filter)
- {
- var sort = "ORDER BY startdate desc";
- if (!string.IsNullOrWhiteSpace(filter.SortField))
- {
- var arr = filter.SortField.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- EnumTalkRecordsSortField e;
- if (!Enum.TryParse(arr[0], out e))
- return Error("排序字段参数错误");
- sort = "ORDER BY " + e.ToString() + " " + arr[1];
- }
- StringBuilder where = new StringBuilder();
- if (!string.IsNullOrWhiteSpace(filter.UserCode))
- {
- where.Append(" and agentid=" + filter.UserCode);
- }
- if (!string.IsNullOrWhiteSpace(filter.Phone))
- {
- where.Append(" and callee like '%" + filter.Phone + "%'");
- }
- if (!string.IsNullOrWhiteSpace(filter.TalkTime))
- {
- var arr = filter.TalkTime.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- if (arr.Length == 2)
- {
- if (arr[0] == "1")
- {
- where.Append(" and talktime>" + arr[1]);
- }
- else if (arr[0] == "2")
- {
- where.Append(" and talktime=" + arr[1]);
- }
- else if (arr[0] == "3")
- {
- where.Append(" and talktime<" + arr[1]);
- }
- else { }
- }
- }
- if (filter.StartTime == null || filter.EndTime == null)
- {
- filter.StartTime = DateTools.FirstSecondOfOneDay(DateTime.Now);
- filter.EndTime = DateTools.LastSecondOfOneDay(DateTime.Now);
- }
- //qcstate=1 = 已质检; qcstate=0 =未质检
- //calltype 全部=0;未转坐席 = 1; 被叫接通转坐席未接 = 2; 转坐席且接通 = 3,
- where.Append(" and qcstate=1 and calltype in (2,3) and datediff(s,'" + filter.StartTime + "',StartDate)>=0 and datediff(s,EndDate,'" + filter.EndTime + "')>=0 ");
- int recordCount = 0;
- Model.PageData<Model.CallResult> pageModel = new Model.PageData<Model.CallResult>();
- StringBuilder fields = new StringBuilder();
- var dt = BLL.PagerBLL.GetListPager(
- "V_AutoCallResult",
- "Id",
- "id,itemid,taskname, callee, agentid, username,startdate,enddate,getinagentdate,calltype,talktime,RecordPath, QCState, QCScore, QCRemark, QCUserId, QCUserName,QCTime",
- where.ToString(),
- sort,
- filter.PageSize,
- filter.PageIndex,
- true,
- out recordCount);
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- var callResultList = callResultBLL.DataTableToListQC(dt);
- var obj = new
- {
- rows = callResultList.Select(x => new
- {
- id = x.Id,
- taskid = x.TaskId,
- callnumber = x.CallNumber,
- usercode = x.Usercode == "0" ? "" : x.Usercode,
- startdate = x.StartDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? "",
- getinagentdate = x.GetInAgentDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? "",
- enddate = x.EndDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? "",
- username = x.Username,
- calltype = Enum.Parse(typeof(EnumTalkRecordsCallType), x.CallType.ToString()).ToString(),
- talktime = x.TalkTime > 0 ? x.TalkTime.ToString() : "0",
- qcstate = x.QCState == 0 ? "未质检" : "已质检",
- qcscore = x.QCScore,
- qcremark = x.QCRemark ?? "",
- qcuserid = x.QCUserId?.ToString() ?? "",
- qcusername = x.QCUserName ?? "",
- qctime = x.QCTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? ""
- }),
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取质检详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult GetQCDetail(string id)
- {
- DataTable dt = new DataTable();
- DataTable dtindex = new DataTable();
- DataTable dtres = new DataTable();
- try
- {
- dt = new BLL.T_QC_IndexCategory().GetList(" F_DeleteFlag=0 order by F_Sort ,F_CategoryId").Tables[0];
- dtindex = new BLL.T_QC_IndexBase().GetList(" F_DeleteFlag=0 order by F_Sort ,F_CategoryId").Tables[0];
- dtres = new BLL.T_QC_IndexRes().GetList(" CallRecordsId=" + id + " ").Tables[0];
- int i = 0;
- int m = 0;
- int indexcount = 0;
- int allscore = 0;
- int childscore = 0;
- int childpf = 0;
- int allpf = 0;
- List<Model.QCModel> qclist = new List<Model.QCModel>();
- object obj = null;
- foreach (DataRow dr in dt.Select("F_ParentId=0"))
- {
- Model.QCModel qcml = new Model.QCModel();
- List<Model.QCModel> qcclist = new List<Model.QCModel>();
- i = 0;
- indexcount = 0;
- childscore = 0;
- childpf = 0;
- string categoryid = dr["F_CategoryId"].ToString().Trim();
- qcml.Qcid = categoryid;
- qcml.Qcname = dr["F_CategoryName"].ToString().Trim();
- obj = DbHelperSQL.GetSingle("select count(*) from T_QC_IndexBase where F_CategoryId in(select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + dr["F_CategoryId"] + ")");
- qcml.Rowspan = obj.ToString();
- foreach (DataRow childdr in dt.Select("F_ParentId=" + categoryid + ""))
- {
- Model.QCModel qcmlc = new Model.QCModel();
- List<Model.QCModel> qccrlist = new List<Model.QCModel>();
- m = 0;
- #region 子分类
- string childcategoryid = childdr["F_CategoryId"].ToString().Trim();
- DataRow[] arrchild = dtindex.Select("F_CategoryId=" + childcategoryid + "");
- indexcount += arrchild.Length;
- //加载项
- qcmlc.Qcid = categoryid + "-" + childcategoryid;
- qcmlc.Qcname = childdr["F_CategoryName"].ToString().Trim();
- obj = DbHelperSQL.GetSingle("select count(*) from T_QC_IndexBase where F_CategoryId=" + childdr["F_CategoryId"]);
- qcmlc.Rowspan = obj.ToString();
- #endregion
- foreach (DataRow indexdr in arrchild)
- {
- Model.QCModel qcmlcr = new Model.QCModel();
- string indexid = indexdr["F_IndexId"].ToString().Trim();
- string pf = "0";
- try
- {
- //分类分数合计
- childscore += Convert.ToInt32(indexdr["F_Score"].ToString().Trim());
- //总计合计
- allscore += Convert.ToInt32(indexdr["F_Score"].ToString().Trim());
- }
- catch
- { }
- try
- {
- pf = dtres.Select("F_IndexId=" + indexid + "")[0]["F_QCScore"].ToString().Trim();
- childpf += Convert.ToInt32(pf);//分类评分合计
- allpf += Convert.ToInt32(pf);//评分总计
- }
- catch
- {
- }
- #region 指标
- //加载指标
- qcmlcr.Qcid = categoryid + "-" + childcategoryid + "-" + indexid;
- qcmlcr.Qcname = indexdr["F_Title"].ToString().Trim();
- qcmlcr.Qcscore = indexdr["F_Score"].ToString().Trim();
- qcmlcr.Qcpf = pf;
- qcmlcr.Rowspan = "0";
- qcmlcr.Colspan = "0";
- #endregion
- m++;
- qccrlist.Add(qcmlcr);
- }
- i++;
- qcmlc.Qclist = qccrlist;
- qcclist.Add(qcmlc);
- }
- //合计
- qcml.Qcscore = childscore.ToString().Trim();
- qcml.Qcpf = childpf.ToString().Trim();
- qcml.Qclist = qcclist;
- qcml.Colspan = "2";
- qclist.Add(qcml);
- }
- Model.QCModel qcmlhj = new Model.QCModel();
- qcmlhj.Qcid = "0";
- qcmlhj.Qcname = "总计";
- qcmlhj.Qcscore = allscore.ToString().Trim();
- qcmlhj.Qcpf = allpf.ToString().Trim();
- qcmlhj.Qclist = qclist;
- qcmlhj.Colspan = "3";
- return Success("质检部分加载成功", qcmlhj);
- }
- catch (Exception ex)
- {
- return Error("获取质检详情异常,错误:" + ex.ToString());
- }
- finally
- {
- dtres.Clear();
- dtres.Dispose();
- dtindex.Clear();
- dtindex.Dispose();
- dt.Clear();
- dt.Dispose();
- }
- }
- /// <summary>
- /// 保存质检详情
- /// </summary>
- /// <param name="id"></param>
- /// <param name="xmlinfo"></param>
- /// <returns></returns>
- public ActionResult SaveQCDetail(string id, string xmlinfo)
- {
- DataTable dt = new BLL.T_QC_IndexResAutoCall().GetList(" CallRecordsId=" + id + " ").Tables[0];
- int allscore = 0;
- foreach (string scoreinfo in xmlinfo.Trim(';').Split(';'))
- {
- //判断存在该指标评估则修改,无则添加
- string idsss = scoreinfo.Split(':')[0];
- string indexid = idsss.Split('-')[2];
- if (dt.Select(" F_IndexId=" + indexid + " ").Length > 0)
- {
- Model.T_QC_IndexResAutoCall model = new Model.T_QC_IndexResAutoCall();
- model.F_Id = Convert.ToInt32(dt.Select(" F_IndexId=" + indexid + " ")[0]["F_Id"].ToString());
- model.CallRecordsId = Convert.ToInt32(id);
- try
- {
- model.F_IndexId = Convert.ToInt32(indexid);
- }
- catch
- { }
- try
- {
- model.F_QCScore = Convert.ToInt32(scoreinfo.Split(':')[1]);
- allscore += Convert.ToInt32(scoreinfo.Split(':')[1]);
- }
- catch
- { }
- new BLL.T_QC_IndexResAutoCall().Update(model);
- }
- else
- {
- Model.T_QC_IndexResAutoCall model = new Model.T_QC_IndexResAutoCall();
- model.CallRecordsId = Convert.ToInt32(id);
- try
- {
- model.F_IndexId = Convert.ToInt32(indexid);
- }
- catch
- { }
- try
- {
- model.F_QCScore = Convert.ToInt32(scoreinfo.Split(':')[1]);
- allscore += Convert.ToInt32(scoreinfo.Split(':')[1]);
- }
- catch
- { }
- new BLL.T_QC_IndexResAutoCall().Add(model);
- }
- }
- Model.CallResult callmodel = new Model.CallResult();
- callmodel.Id = Convert.ToInt32(id);
- callmodel.QCState = 1;
- callmodel.QCScore = allscore;
- callmodel.QCUserId = CurrentUser.UserData.F_UserId;
- callmodel.QCUserCode = CurrentUser.UserData.F_UserCode;
- callmodel.QCUserName = CurrentUser.UserData.F_UserName;
- callmodel.QCTime = DateTime.Now;
- callmodel.QCRemark = "";
- //callmodel.F_QCIsSelect = 0;
- //callmodel.F_QCQuestion = question;
- //callmodel.F_QCAdvise = advise;
- if (new BLL.CallResult().UpdateQC(callmodel))
- return Error("保存质检评分信息失败");
- dt.Clear();
- dt.Dispose();
- return Success("保存成功");
- }
- #endregion
- }
- }
|