using Core.Web.App_Start; using Core.Web.WebHelper; using CRM.Core.BLL.Csvr; using CRM.Core.BLL.FB; using CRM.Core.BLL.Util; using CRM.Core.Common.Layui; using CRM.Core.DTO; using CRM.Core.Model; using CRM.Core.Model.Entity; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Web.Caching; using System.Web.Mvc; using System.Web.UI.WebControls.WebParts; using WX.CRM.Common; using WX.CRM.Common.Employee; using WX.CRM.Common.StockHelper; namespace Core.Web.Controllers { public class CallRecordController : BaseController { private Csvr_CallRecord_BL _csvrCallRecord; private Ord_MemoContent_BL _memoContent; private CACHE_BL _cacheBL; //private Ord_MemoContent_BL _memoContent; public CallRecordController() { } [HttpGet] [AuthorizeRedirect(RightsConfig.CONST_录音查询, ToolBarConfig.CONST_NotButton, true)] public ActionResult Index() { _cacheBL = new CACHE_BL(); var host = _cacheBL.GetValue_Parameter(CRM.Core.Model.Enum.Parameter.Hg_Internal_WebApi); var url = host + "/api/CsvrCallRecord/companies"; //url = "https://localhost:7151/api/CsvrCallRecord/companies"; var res = CRM.Core.Common.Utility.GetData(url, ""); var result = JsonConvert.DeserializeObject>>(res); if (result.Code == 0) { ViewBag.CompanyList = result.Data; } List vurtual = _cacheBL.GetCompanyVirtual(); ViewBag.vurtual = vurtual; ViewBag.hgServiceHost = _cacheBL.GetValue_Parameter("HgCrm_ServiceHost"); return View(); } [HttpGet] public ActionResult ChooseCallRecord(string umid) { ViewBag.umid = umid; return View(); } [HttpPost] [AuthorizeRedirect(RightsConfig.CONST_录音查询, ToolBarConfig.CONST_NotButton, false)] public JsonResult ChooseCallRecord(Laypage pager, string umid) { //if (string.IsNullOrEmpty(companyCode)) //{ // return Json(new LayuiData() { msg = "请查询", count = 0, code = 0, data = null }, JsonRequestBehavior.AllowGet); //} _cacheBL = new CACHE_BL(); var host = _cacheBL.GetValue_Parameter(CRM.Core.Model.Enum.Parameter.Hg_Internal_WebApi); var url = host + "/api/CsvrCallRecord/page"; //url = "https://localhost:7151/api/CsvrCallRecord/page"; var para = "PageSize=10000"; if (pager.page > 0) { para += "&PageIndex=" + pager.page.ToString(); } else { para += "&PageIndex=1"; } if (!string.IsNullOrEmpty(umid)) { para += "&UMID=" + umid; } var res = CRM.Core.Common.Utility.GetData(url, para); LogHelper.Info($"{url}{para}"); var result = JsonConvert.DeserializeObject>>(res); if (result.Code != 0) { return Json("", JsonRequestBehavior.DenyGet); } pager.count = result.Data.Total; var data = new LayuiData() { msg = "数据加载成功!", count = pager.count, code = 0, data = result.Data.Data.ToList() }; return Json(data, JsonRequestBehavior.AllowGet); } [HttpPost] public JsonResult Index2(Laypage pager, string columns, long? recordId, string resId, DateTime? stime, DateTime? etime, string companyCode, int? deptId, int? groupId, int? userId) { if (string.IsNullOrEmpty(companyCode)) { return Json(new LayuiData() { msg = "请查询", count = 0, code = 0, data = null }, JsonRequestBehavior.AllowGet); } ConStringHelper.CompanyCode code = (ConStringHelper.CompanyCode)Enum.Parse(typeof(ConStringHelper.CompanyCode), companyCode); _csvrCallRecord = new Csvr_CallRecord_BL(code); var list = _csvrCallRecord.GetList_JianCha(pager, recordId, resId, stime, etime, deptId, groupId, userId); var coids = list.Where(p => p.coid != null).Select(p => p.coid); if (coids.Any()) { _memoContent = new Ord_MemoContent_BL(code); var memoContentList = _memoContent.GetOrdMemoContentByIds(coids); foreach (var item in list) { if (memoContentList.ContainsKey(item.coid)) { foreach (var pair in memoContentList) { if (pair.Key == item.coid) { item.memocontent = pair.Value.STRCONTENT; } } } } } var data = new LayuiData() { msg = "数据加载成功!", count = pager.count, code = 0, data = list }; return Json(data, JsonRequestBehavior.AllowGet); } [HttpPost] [AuthorizeRedirect(RightsConfig.CONST_录音查询, ToolBarConfig.CONST_NotButton, false)] public JsonResult Index(Laypage pager, string recordId, string userId, string resId,string UMID, string companyCode, int? isListened, int? callType, string slength, string elength, string stime, string etime, bool? export = false) { //if (string.IsNullOrEmpty(companyCode)) //{ // return Json(new LayuiData() { msg = "请查询", count = 0, code = 0, data = null }, JsonRequestBehavior.AllowGet); //} _cacheBL = new CACHE_BL(); var host = _cacheBL.GetValue_Parameter(CRM.Core.Model.Enum.Parameter.Hg_Internal_WebApi); var url = host + "/api/CsvrCallRecord/page"; //url = "https://localhost:7151/api/CsvrCallRecord/page"; var para = "PageSize=" + pager.limit; if (pager.page > 0) { para += "&PageIndex=" + pager.page.ToString(); } else { para += "&PageIndex=1"; } if (!string.IsNullOrEmpty(companyCode)) { para += "&companyCode=" + companyCode; } if (!string.IsNullOrEmpty(resId)) { para += "&resId=" + resId; } if (!string.IsNullOrEmpty(UMID)) { para += "&UMID=" + UMID; } if (!string.IsNullOrEmpty(recordId)) { para += "&recordId=" + recordId; } if (!string.IsNullOrEmpty(userId)) { para += "&eid=" + userId; } if (isListened != null) { para += "&isListened=" + isListened; } if (callType != null) { para += "&callType=" + callType; } if (!string.IsNullOrEmpty(slength)) { para += "&LengthFrom=" + slength; } if (!string.IsNullOrEmpty(elength)) { para += "&LengthTo=" + elength; } if (!string.IsNullOrEmpty(stime)) { para += "&TimeFrom=" + stime; } if (!string.IsNullOrEmpty(etime)) { para += "&TimeTo=" + etime; } if (export.HasValue) { para += "&Export=" + export; } LogHelper.Info("url:" + para); var res = CRM.Core.Common.Utility.GetData(url, para); if (export.HasValue && export.GetValueOrDefault()) { var exportReuslt = JsonConvert.DeserializeObject>(res); return Json(exportReuslt, JsonRequestBehavior.AllowGet); } var result = JsonConvert.DeserializeObject>>(res); if (result.Code != 0) { return Json("", JsonRequestBehavior.DenyGet); } pager.count = result.Data.Total; var data = new LayuiData() { msg = "数据加载成功!", count = pager.count, code = 0, data = result.Data.Data.ToList() }; return Json(data, JsonRequestBehavior.AllowGet); } [HttpPost] [AuthorizeRedirect(RightsConfig.CONST_录音查询, ToolBarConfig.CONST_NotButton, false)] public JsonResult AiIndex(Laypage pager, string columns, string resId, string UMID, string companyCode) { var bll = new Csvr_AiCallTask_BL(); _cacheBL = new CACHE_BL(); var dto = new AiRecordQueryDto { resId = resId, UMID=UMID }; if (!string.IsNullOrEmpty(companyCode)) { dto.channel = companyCode; } var aiList = bll.GetList(ref pager, dto); var list = new List(); foreach (var item in aiList) { list.Add(new CallRecordView2 { recordid = item.Id, sid = AESHelper.encyptData(item.Id.ToString(), "UPWEBSITE"), calltype = "呼出", resid = item.RESID, umid = item.UMID, servicenumber = "", saleseid = "AI机器人", telnumberlast4 = item.CallNo, timeend = item.EndTime, timelength = item.SvcTime, timestart = item.StartTime, FileName = item.Audio, DeptName = item.CHANNELNAME }); } var result = new ajaxResult>(); //pager.count = result.retcode; var data = new LayuiData() { msg = "数据加载成功!", count = pager.count, code = 0, data = list }; return Json(data, JsonRequestBehavior.AllowGet); } [HttpPost] public JsonResult Check(int check, string companyCode, long recordId) { try { if (string.IsNullOrEmpty(companyCode)) { return Json(new LayuiData() { msg = "请查询", count = 0, code = 0, data = null }, JsonRequestBehavior.AllowGet); } ConStringHelper.CompanyCode code = (ConStringHelper.CompanyCode)Enum.Parse(typeof(ConStringHelper.CompanyCode), companyCode); _csvrCallRecord = new Csvr_CallRecord_BL(code); _csvrCallRecord.Check(recordId, check); return Json(new { result = true }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error(ex.ToString()); return Json(new { result = false }, JsonRequestBehavior.AllowGet); } } [HttpPost] public JsonResult RecordPlay(string FileName, string companyCode) { try { //ConStringHelper.CompanyCode code = (ConStringHelper.CompanyCode)Enum.Parse(typeof(ConStringHelper.CompanyCode), companyCode); //_csvrCallRecord = new Csvr_CallRecord_BL(code); var host = ConfigurationManager.AppSettings["video_" + companyCode].ToString(); //var model = _csvrCallRecord.Get(p => p.recordid == recordid); //if (model == null) // return Json(new retMsg { result = false, retcode = 0, retmsg = "未能找到记录,请稍后重试!" }, JsonRequestBehavior.AllowGet); var url = host + FileName; return Json(new retMsg { result = true, retcode = 1, retmsg = url }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error(ex.ToString()); return Json(new retMsg { result = false, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet); } } //合规用法 [HttpPost] public JsonResult RecordPlay_Old(long recordid, string companyCode) { try { ConStringHelper.CompanyCode code = (ConStringHelper.CompanyCode)Enum.Parse(typeof(ConStringHelper.CompanyCode), companyCode); _csvrCallRecord = new Csvr_CallRecord_BL(code); var host = ConfigurationManager.AppSettings["video_" + companyCode].ToString(); var model = _csvrCallRecord.Get(p => p.recordid == recordid); if (model == null) return Json(new retMsg { result = false, retcode = 0, retmsg = "未能找到记录,请稍后重试!" }, JsonRequestBehavior.AllowGet); var ss = model.filename.Split('_'); if (ss.Length > 1) { model.filename = ss[1]; } var url = host + model.filename; return Json(new retMsg { result = true, retcode = 1, retmsg = url }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error(ex.ToString()); return Json(new retMsg { result = false, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet); } } } public class ajaxResult { public bool result { get; set; } public int retcode { get; set; } public T retmsg { get; set; } } public class Company { public string Code { get; set; } public string Name { get; set; } public string VideoUrl { get; set; } public string WxMessageUrl { get; set; } } }