| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822 |
- 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
- {
- public class IndexController : BaseController
- {
- private BLL.T_Sys_ModuleInfo moduleInfoBLL = new BLL.T_Sys_ModuleInfo();
- private BLL.T_Sys_RoleFunction roleFunctionBLL = new BLL.T_Sys_RoleFunction();
- /// <summary>
- /// 获取菜单
- /// </summary>
- /// <returns></returns>
- public ActionResult GetMenu()
- {
-
- if (Request.IsAuthenticated)
- {
- var roleId = CurrentUser.UserData.F_RoleId;
- var functionIdList = roleFunctionBLL.DataTableToList(roleFunctionBLL.GetList(" F_RoleId=" + roleId).Tables[0]).Select(x => x.F_FunctionId);
- var moduleInfoList = moduleInfoBLL.DataTableToList(moduleInfoBLL.GetList(" F_StateFlag=1 ").Tables[0]);
- moduleInfoList.Sort((x, y) => x.F_Sort - y.F_Sort);
- var authModuleFunctionList = moduleInfoList.Where(x => functionIdList.Contains(x.F_ModuleId)).ToList();
- return Success("获取符合权限的菜单", TreeRecursion(authModuleFunctionList));
- }
- return NoToken("未知错误,请重新登录");
- }
- private List<Model.T_Sys_ModuleInfo> TreeRecursion(List<Model.T_Sys_ModuleInfo> data, string parentId = "0")
- {
- List<Model.T_Sys_ModuleInfo> newList = new List<Model.T_Sys_ModuleInfo>();
- List<Model.T_Sys_ModuleInfo> item = data.FindAll(t => t.F_ParentID.ToString() == parentId);//data建议在调用此扩展方法前已经排序过
- if (item.Count > 0)
- {
- foreach (Model.T_Sys_ModuleInfo entity in item)
- {
- entity.ChildNodes = TreeRecursion(data, entity.F_ModuleId.ToString());
- newList.Add(entity);
- }
- }
- return newList;
- }
- /// <summary>
- /// 上传用户图片
- /// </summary>
- /// <returns></returns>
- public ActionResult UploadTX()
- {
-
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userModel != null)
- {
- string path = string.Empty;
- HttpPostedFile _upfile = RequestString.GetFile("upFile");
- if (_upfile != null)
- {
- //byte[] buffer = new Byte[(int)_upfile.InputStream.Length]; //声明文件长度的二进制类型
- //_upfile.InputStream.Read(buffer, 0, buffer.Length); //将文件转成二进制
- ImageUpload iu = new ImageUpload();
- iu.SavePath = "/Upload/ZXTX/";
- iu.PostFile = _upfile;
- iu.Upload();
- path = "/Upload/ZXTX/" + iu.OutFileName;
- userModel.F_See = path;
- new BLL.T_Sys_UserAccount().Update(userModel);
- return Success("成功", path);
- }
- else
- {
- return Error("请选择要上传的文件");
- }
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// APP上传图片
- /// </summary>
- /// <returns></returns>
- public ActionResult Upload64()
- {
- //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
- string dataurl = RequestString.GetFormString("dataurl");
- string filename = RequestString.GetFormString("filename");
- ActionResult res = NoToken("未知错误,请重新登录");
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userModel != null)
- {
- if (!string.IsNullOrEmpty(dataurl))
- {
- string path = "/Upload/APP/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
- ImageUpload iu = new ImageUpload();
- iu.SavePath = path;
- iu.DataUrl = dataurl;
- if (!string.IsNullOrEmpty(filename))
- {
- iu.SaveType = 1;
- iu.InFileName = filename;
- }
- iu.Upload64();
- int n = iu.Error;
- if (n == 0)
- {
- path = path + iu.OutFileName;
- Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
- model_T_Sys_Accessories.F_CreateTime = DateTime.Now;//上传时间
- model_T_Sys_Accessories.F_Name = iu.OutFileName;//附件名称
- model_T_Sys_Accessories.F_Type = ".jpg";//附件类型
- model_T_Sys_Accessories.F_Url = path;//附件地址
- model_T_Sys_Accessories.F_Size = iu.FileSize;
- //model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
- int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
- model_T_Sys_Accessories.F_Id = id;
- userModel.F_PId = id;
- new BLL.T_Sys_UserAccount().Update(userModel);
- return Success("成功", model_T_Sys_Accessories);
- }
- else
- {
- string msg = string.Empty;
- switch (n)
- {
- case 1: msg = "请选择要上传的文件"; break;
- case 2: msg = "上传的文件类型不支持"; break;
- case 3: msg = "上传的文件过大"; break;
- case 4: msg = "未知错误"; break;
- }
- return Error(msg);
- }
- }
- else
- {
- return Error("请选择要上传的文件");
- }
- }
- return res;
- }
- /// <summary>
- /// APP上传图片
- /// </summary>
- /// <returns></returns>
- public ActionResult UploadCL64()
- {
- //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
- string dataurl = RequestString.GetFormString("dataurl");
- string filename = RequestString.GetFormString("filename");
- ActionResult res = NoToken("未知错误,请重新登录");
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userModel != null)
- {
- if (!string.IsNullOrEmpty(dataurl))
- {
- string path = "/Upload/Workorder/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
- ImageUpload iu = new ImageUpload();
- iu.SavePath = path;
- iu.DataUrl = dataurl;
- if (!string.IsNullOrEmpty(filename))
- {
- iu.SaveType = 1;
- iu.InFileName = filename;
- }
- iu.Upload64();
- int n = iu.Error;
- if (n == 0)
- {
- path = path + iu.OutFileName;
- Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
- model_T_Sys_Accessories.F_CreateTime = DateTime.Now;//上传时间
- model_T_Sys_Accessories.F_Name = iu.OutFileName;//附件名称
- model_T_Sys_Accessories.F_Type = ".jpg";//附件类型
- model_T_Sys_Accessories.F_Url = path;//附件地址
- model_T_Sys_Accessories.F_Size = iu.FileSize;
- // model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
- int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
- model_T_Sys_Accessories.F_Id = id;
- return Success("成功", model_T_Sys_Accessories);
- }
- else
- {
- string msg = string.Empty;
- switch (n)
- {
- case 1: msg = "请选择要上传的文件"; break;
- case 2: msg = "上传的文件类型不支持"; break;
- case 3: msg = "上传的文件过大"; break;
- case 4: msg = "未知错误"; break;
- }
- return Error(msg);
- }
- }
- else
- {
- return Error("请选择要上传的文件");
- }
- }
- return res;
- }
- /// <summary>
- /// 上传用户图片
- /// </summary>
- /// <returns></returns>
- public ActionResult UploadTX64()
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userModel != null)
- {
- string path = string.Empty;
- string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
- if (!string.IsNullOrEmpty(dataurl))
- {
- path = "/Upload/ZXTX/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
- ImageUpload iu = new ImageUpload();
- iu.SavePath = path;
- iu.DataUrl = dataurl;
- iu.Upload64();
- int n = iu.Error;
- if (n == 0)
- {
- path = path + iu.OutFileName;
- Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
- model_T_Sys_Accessories.F_CreateTime = DateTime.Now;//上传时间
- model_T_Sys_Accessories.F_Name = iu.OutFileName;//附件名称
- model_T_Sys_Accessories.F_Type = ".jpg";//附件类型
- model_T_Sys_Accessories.F_Url = path;//附件地址
- model_T_Sys_Accessories.F_Size = iu.FileSize;
- int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
- model_T_Sys_Accessories.F_Id = id;
- userModel.F_PId = id;
- new BLL.T_Sys_UserAccount().Update(userModel);
- res = Success("成功", model_T_Sys_Accessories);
- }
- else
- {
- string msg = string.Empty;
- switch (n)
- {
- case 1: msg = "请选择要上传的文件"; break;
- case 2: msg = "上传的文件类型不支持"; break;
- case 3: msg = "上传的文件过大"; break;
- case 4: msg = "未知错误"; break;
- }
- res = Error(msg);
- }
- }
- else
- {
- res = Error("请选择要上传的文件");
- }
- }
- }
- }
- return res;
- }
- /// <summary>
- /// 通话记录数量
- /// </summary>
- /// <returns></returns>
- public ActionResult GetTelRecordsTotal()
- {
- ActionResult res = NoToken("未知错误,请重新登录");
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- string usercode = CurrentUser.UserData.F_UserCode;
- int roleid = CurrentUser.UserData.F_RoleId;
- if (userId != 0)
- {
- var date = DateTime.Now;
- string strDate = date.ToString("yyyy-MM-dd");
- string strMonth = date.ToString("yyyy-MM");
- //string uwhere = " 1=1 ";
- string uwhere = " 1=1 AND CONVERT(char(7),BeginTime,20) = '" + strMonth + "' "; //and ISNULL(groupcode,'') != ''
- if (roleid != 17)
- {
- uwhere += " and UserCode='" + usercode + "' ";
- }
- BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
- //var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
- //var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
- //var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
- //var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
- //int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' and CallState='0' ").Tables[0].Rows.Count;
- //2018-05-03 lihai 首页统计问题
- //var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' ");
- //var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' ");
- //var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' ");
- //var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' ");
- //int daynocon = bll.GetList("CallType='0' and CallState='0' and datediff(day,BeginTime, '" + strDate + "')=0 ").Tables[0].Rows.Count;
- ////int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' ").Tables[0].Rows.Count;
- DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),BeginTime, 23) AS yearmonthdays,CONVERT(char(7),BeginTime,20) AS yearmonths,CallType,BeginTime,groupcode,UserCode,ISNULL(TalkLongTime,0) AS TalkLongTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
- // 今日来电
- var dayinlist = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
- var dayinlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'");
- var dayinlist_totaltimesum = (from DataRow dr in dayinlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
- //今日去电
- var dayoutlist = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'").Count();
- var dayoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'");
- var dayoutlist_totaltimesum = (from DataRow dr in dayoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
- //本月来电
- var moninlist = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'").Count();
- var moninlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'");
- var moninlist_totaltimesum = (from DataRow dr in moninlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
- //本月去电
- var monoutlist = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'").Count();
- var monoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'");
- var monoutlist_totaltimesum = (from DataRow dr in monoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
- //未接来电
- var daynocon = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
- var obj = new
- {
- //dayin = new { count = dayinlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
- //dayout = new { count = dayoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
- //monin = new { count = moninlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
- //monout = new { count = monoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
- //daynocon = daynocon
- // 今日来电
- dayin = new { count = dayinlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist_totaltimesum.ToString()), 0) },
- //今日去电
- dayout = new { count = dayoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist_totaltimesum.ToString()), 0) },
- //本月来电
- monin = new { count = moninlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist_totaltimesum.ToString()), 0) },
- //本月去电
- monout = new { count = monoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist_totaltimesum.ToString()), 0) },
- //未接来电
- daynocon = daynocon
- };
- res = Success("成功", obj);
- }
- }
- return res;
- }
- ///// <summary>
- ///// 通话记录数量
- ///// </summary>
- ///// <returns></returns>
- //public ActionResult GetTelRecordsTotal()
- //{
-
- // if (Request.IsAuthenticated)
- // {
- // int userId = CurrentUser.UserData.F_UserId;
- // Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- // if (userId != 0)
- // {
- // var date = DateTime.Now;
- // string strDate = date.ToString("yyyy-MM-dd");
- // string strMonth = date.ToString("yyyy-MM");
- // string uwhere = " 1=1 and ISNULL(groupcode,'') != '' AND CONVERT(char(7),BeginTime,20) = '" + strMonth + "' ";;
- // if (userModel.rolecode != "XTGLY")
- // {
- // uwhere += " and UserCode='" + userModel.F_UserCode + "' ";
- // }
-
- // if (!string.IsNullOrEmpty(userModel.groupcode))
- // {
- // uwhere += " and groupcode = '" + userModel.groupcode + "' ";
- // }
- // BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
- // DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),BeginTime, 23) AS yearmonthdays,CONVERT(char(7),BeginTime,20) AS yearmonths,CallType,BeginTime,groupcode,UserCode,ISNULL(TalkLongTime,0) AS TalkLongTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
- // // 今日来电
- // var dayinlist = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
- // var dayinlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'");
- // var dayinlist_totaltimesum = (from DataRow dr in dayinlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
- // //今日去电
- // var dayoutlist = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'").Count();
- // var dayoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'");
- // var dayoutlist_totaltimesum = (from DataRow dr in dayoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
- // //本月来电
- // var moninlist = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'").Count();
- // var moninlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'");
- // var moninlist_totaltimesum = (from DataRow dr in moninlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
- // //本月去电
- // var monoutlist = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'").Count();
- // var monoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'");
- // var monoutlist_totaltimesum = (from DataRow dr in monoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
- // //未接来电
- // var daynocon = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
- // var obj = new
- // {
- // //// 今日来电
- // //dayin = new { count = dayinlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
- // ////今日去电
- // //dayout = new { count = dayoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
- // ////本月来电
- // //monin = new { count = moninlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
- // ////本月去电
- // //monout = new { count = monoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
- // ////未接来电
- // //daynocon = daynocon
- // // 今日来电
- // dayin = new { count = dayinlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist_totaltimesum.ToString()), 0) },
- // //今日去电
- // dayout = new { count = dayoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist_totaltimesum.ToString()), 0) },
- // //本月来电
- // monin = new { count = moninlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist_totaltimesum.ToString()), 0) },
- // //本月去电
- // monout = new { count = monoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist_totaltimesum.ToString()), 0) },
- // //未接来电
- // daynocon = daynocon
- // };
- // return Success("成功", obj);
-
- // }
- // }
- // return NoToken("未知错误,请重新登录");
- //}
- /// <summary>
- /// 获取当月/当天的工单量(已完成,未完成)
- /// </summary>
- /// <returns></returns>
- public ActionResult GetWorkTotal()
- {
-
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userModel != null)
- {
- var date = DateTime.Now;//DateTime.Parse("2015-04-14"); //
- string strDate = date.ToString("yyyy-MM-dd");
- string strMonth = date.ToString("yyyy-MM");
- //BLL.T_Wo_WorkOrderBase bll = new BLL.T_Wo_WorkOrderBase();
- //var list1 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + strDate + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
- //var list2 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + strDate + "' and F_WORKORDERSTATEID in (4,5,6,7,9,12,13) ").Tables[0];
- //var list3 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(char(7),F_CREATEDATE,20)='" + strMonth + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
- //var list4 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(char(7),F_CREATEDATE,20)='" + strMonth + "' and F_WORKORDERSTATEID in (4,5,6,7,9,12,13) ").Tables[0];
- string uwhere = " 1=1 and F_State !=11 and F_Duplicate!=5 AND CONVERT(char(7),F_CreateTime,20) = '" + strMonth + "'"; ;
- if (userModel.rolecode != "XTGLY")
- {
- uwhere += " and F_CreateUser='" + userModel.F_UserCode + "' ";
- }
- //var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =2 and IsDel=0 ").Tables[0];
- //var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State in (0,1) and IsDel=0 ").Tables[0];
- //var list3 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =2 and IsDel=0 ").Tables[0];
- //var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State in (0,1) and IsDel=0 ").Tables[0];
- DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),F_CreateTime, 23) AS yearmonthdays,CONVERT(char(7),F_CreateTime,20) AS yearmonths,F_State,F_IsDelete,F_CreateTime,F_CreateUser FROM T_Bus_WorkOrder WITH(NOLOCK) where " + uwhere + "").Tables[0];
- //日已完成
- int list1_count = dtConnect.Select(" yearmonthdays = '" + strDate + "' and F_State = 10 and F_IsDelete = 0").Count();
- //日未完成
- int list2_count = dtConnect.Select(" yearmonthdays = '" + strDate + "' and F_State<>10 and F_IsDelete=0 ").Count();
- //月已完成
- var list3_count = dtConnect.Select(" yearmonths = '" + strMonth + "' and F_State =10 and F_IsDelete=0 ").Count();
- //月未完成
- var list4_count = dtConnect.Select(" yearmonths = '" + strMonth + "' and F_State<>10 and F_IsDelete=0").Count();
- //BLL.T_Bus_WorkOrder bll = new BLL.T_Bus_WorkOrder();
- //var modellist = bll.GetModelList (uwhere + " and F_IsDelete = 0 and F_State !=11 and F_Duplicate!=5");
- //int list1 = 0, list2 = 0, list3 = 0, list4 = 0;
- //if (modellist!=null )
- //{
- // foreach (var it in modellist)
- // {
- // if (it .F_State ==10)
- // {
- // list3++;
- // if (DateTime .Parse (it.F_CreateTime.ToString ()).ToString("yyyy-MM-dd")== strDate)
- // {
- // list1++;
- // }
- // }
- // else
- // {
- // list4++;
- // if (DateTime.Parse(it.F_CreateTime.ToString()).ToString("yyyy-MM-dd") == strDate)
- // {
- // list2++;
- // }
- // }
- // }
- //}
- // var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),F_CreateTime, 23)='" + strDate + "' and F_State in(10) and F_IsDelete=0 ").Tables[0];
- // var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),F_CreateTime, 23)='" + strDate + "' and F_State in (1,3,4,5,6) and F_IsDelete=0 ").Tables[0];
- // var list3 = bll.GetList(uwhere + " and CONVERT(char(7),F_CreateTime,20)='" + strMonth + "' and F_State in(10) and F_IsDelete=0 ").Tables[0];
- // var list4 = bll.GetList(uwhere + " and CONVERT(char(7),F_CreateTime,20)='" + strMonth + "' and F_State in (1,3,4,5,6) and F_IsDelete=0 ").Tables[0];
- var obj = new
- {
- //daywc = list1,
- //daywwc = list2,
- //monwc = list3,
- //monwwc = list4
- daywc = list1_count,
- daywwc = list2_count,
- monwc = list3_count,
- monwwc = list4_count
- };
- return Success("成功", obj);
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 当天每小时的总通话量和接通量
- /// </summary>
- /// <returns></returns>
- public ActionResult GetTelRecordsByHour()
- {
-
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userId != 0)
- {
- var date = DateTime.Now;//DateTime.Parse("2014-05-05"); //
- string strDate = date.ToString("yyyy-MM-dd");
- string strMonth = date.ToString("yyyy-MM");
- string[] cols = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" };
- string uwhere = " 1=1 and ISNULL(groupcode,'')!= '' AND CONVERT(char(7),BeginTime,20) = '" + strMonth + "' ";
- if (userModel.rolecode != "XTGLY")
- {
- uwhere += " and UserCode='" + userModel.F_UserCode + "' ";
- }
- BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
- DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(13),BeginTime, 120) AS yearmonths,CallState,BeginTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
- int[] total = new int[24];
- int[] count = new int[24];
- for (int i = 0; i < cols.Length; i++)
- {
- var list = dtConnect.Select("yearmonths = '" + (strDate + " " + cols[i]) + "'");
- var conlist = dtConnect.Select("yearmonths = '" + (strDate + " " + cols[i]) + "' and CallState = 1");
- total[i] = list.Count();
- count[i] = conlist.Count();
- }
- var obj = new
- {
- col = cols,
- total,
- count
- };
- return Success("成功", obj);
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 获取当月每天的工单量和话务量
- /// </summary>
- /// <returns></returns>
- public ActionResult GetWorkTelByDay()
- {
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userModel != null)
- {
- var date = DateTime.Now;//DateTime.Parse("2015-04-05"); //
- string strDate = date.ToString("yyyy-MM");
- int days = DateTime.DaysInMonth(date.Year, date.Month);
- string[] strcols = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
- "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
- "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" };
- int newcount = 0;
- List<string> cols = strcols.Take(days).ToList();
- BLL.T_Call_CallRecords telbll = new BLL.T_Call_CallRecords();
- //BLL.T_Wo_WorkOrderBase workbll = new BLL.T_Wo_WorkOrderBase();
- BLL.T_Bus_WorkOrder workbll = new BLL.T_Bus_WorkOrder();
- int[] teltotal = new int[days];
- int[] worktotal = new int[days];
- string uwhere = " 1=1 AND CONVERT(char(7),F_CreateTime,20) = '" + strDate + "' ";
- string u1where = " 1=1 and ISNULL(groupcode,'') != '' AND CONVERT(char(7),BeginTime,20) = '" + strDate + "' ";
- if (userModel.rolecode != "XTGLY")
- {
- uwhere += " and F_CreateUser='" + userModel.F_UserCode + "' ";
- u1where += " and UserCode='" + userModel.F_UserCode + "' ";
- }
- DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),BeginTime, 23) AS yearmonthdays,CONVERT(char(7),BeginTime,20) AS yearmonths,CallType,BeginTime,groupcode,UserCode FROM T_Call_CallRecords WITH(NOLOCK) where " + u1where + "").Tables[0];
- DataTable dtConnect_Wo = DbHelperSQL.Query("select CONVERT(varchar(10),F_CreateTime, 23) AS yearmonthdays,CONVERT(char(7),F_CreateTime,20) AS yearmonths,F_State,F_IsDelete,F_CreateTime,F_CreateUser FROM T_Bus_WorkOrder WITH(NOLOCK) where " + uwhere + "").Tables[0];
- for (int i = 0; i < cols.Count; i++)
- {
- int tellist_Count = dtConnect.Select("yearmonthdays = '" + (strDate + "-" + cols[i]) + "'").Count();
- teltotal[i] = tellist_Count;
- newcount = newcount + tellist_Count;
- //var worklist = workbll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
- //var worklist = workbll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
- //int worklist_count = workbll.GetRecordCount(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
- int worklist_count = dtConnect_Wo.Select("yearmonthdays = '" + (strDate + "-" + cols[i]) + "'").Count();
- //worktotal[i] = worklist.Rows.Count;
- worktotal[i] = worklist_count;
- }
- var olddate = date.AddYears(-1);
- string strold1 = olddate.ToString("yyyy-MM") + "-1";
- string strold2 = olddate.ToString("yyyy-MM-dd");
- string bl = string.Empty;
- var oldcount = telbll.GetRecordCount(u1where + " and CONVERT(varchar(10),BeginTime, 23)>='" + strold1 + "' and CONVERT(varchar(10),BeginTime, 23)<='" + strold2 + "' ");
- if (oldcount == newcount)
- {
- bl = " 持平";
- }
- else
- {
- if (newcount != 0)
- {
- if (oldcount > newcount)
- {
- bl = " ↓ " + (Convert.ToDouble(oldcount - newcount) / Convert.ToDouble(newcount)).ToString("0.0%");
- }
- else if (oldcount < newcount)
- {
- bl = " ↑ " + (Convert.ToDouble(newcount - oldcount) / Convert.ToDouble(newcount)).ToString("0.0%");
- }
- }
- else
- {
- bl = " --";
- }
- }
- var obj = new
- {
- bl,
- col = cols.Select(p => p + "日"),
- worktotal,
- teltotal
- };
- return Success("成功", obj);
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 获取当前用户待派单、待接单、待处理工单数量
- /// </summary>
- /// <returns></returns>
- public ActionResult GetWorkOrderCount()
- {
-
- if (Request.IsAuthenticated)
- {
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (ua != null)
- {
- BLL.T_Bus_WorkOrder bll = new BLL.T_Bus_WorkOrder();
- string uwhere = " 1=1 ";
- if (ua.F_RoleId != 17)
- {
- uwhere += " and F_CreateUser='" + ua.F_UserCode + "' ";
- }
- var obj = new
- {
-
- dpd = bll.GetList(uwhere+ " and F_IsDelete=0 and F_State=0 ").Tables[0].Rows.Count,
- djd = new BLL.T_Wo_WorkOrderItem().GetModelList(" IsDel=0 and Type=1 and (state='0' and ','+ToUser+',' like '%," + ua.F_UserCode + ",%') ").Select(p => p.WorkOrderID).Distinct().Count(),
- dcl = new BLL.T_Wo_WorkOrderItem().GetModelList(" IsDel=0 and Type=1 and (state='1' and SureUser='" + ua.F_UserCode + "') ").Select(p => p.WorkOrderID).Distinct().Count()
- };
- return Success("成功", obj);
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 最近通话记录
- /// </summary>
- /// <returns></returns>
- public ActionResult GetLastCallList()
- {
-
- if (Request.IsAuthenticated)
- {
- DataTable dt = new DataTable();
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userModel != null)
- {
- string strnum = HttpUtility.UrlDecode(RequestString.GetQueryString("num"));
- int n = 0;
- if (strnum.Trim() != "")
- {
- n = Convert.ToInt32(strnum);
- }
- dt = new BLL.T_Call_CallRecords().GetList(n, " UserCode='" + userModel.F_UserCode + "' ", "CallRecordsId desc").Tables[0];
- var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
- 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);
- }
- dr["FilePath"] = ym + path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
- }
- }
- return Success("成功", dt);
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- /// <summary>
- /// 最近消息
- /// </summary>
- /// <returns></returns>
- public ActionResult GetLastMsgList()
- {
-
- if (Request.IsAuthenticated)
- {
- DataTable dt = new DataTable();
- int userId = CurrentUser.UserData.F_UserId;
- if (userId != 0)
- {
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (userModel != null)
- {
- string strnum = HttpUtility.UrlDecode(RequestString.GetQueryString("num"));
- int n = 0;
- if (strnum.Trim() != "")
- {
- n = Convert.ToInt32(strnum);
- }
- dt = new BLL.T_Msg_List().GetList(n, " ToUser='" + userModel.F_UserCode + "' and IsDel=0 ", "ID desc").Tables[0];
- return Success("成功", dt);
- }
- }
- }
- return NoToken("未知错误,请重新登录");
- }
- }
- }
|