No Description

IndexController.cs 44KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. namespace CallCenterApi.Interface.Controllers
  12. {
  13. public class IndexController : BaseController
  14. {
  15. private BLL.T_Sys_ModuleInfo moduleInfoBLL = new BLL.T_Sys_ModuleInfo();
  16. private BLL.T_Sys_RoleFunction roleFunctionBLL = new BLL.T_Sys_RoleFunction();
  17. /// <summary>
  18. /// 获取菜单
  19. /// </summary>
  20. /// <returns></returns>
  21. public ActionResult GetMenu()
  22. {
  23. if (Request.IsAuthenticated)
  24. {
  25. var roleId = CurrentUser.UserData.F_RoleId;
  26. var functionIdList = roleFunctionBLL.DataTableToList(roleFunctionBLL.GetList(" F_RoleId=" + roleId).Tables[0]).Select(x => x.F_FunctionId);
  27. var moduleInfoList = moduleInfoBLL.DataTableToList(moduleInfoBLL.GetList(" F_StateFlag=1 ").Tables[0]);
  28. moduleInfoList.Sort((x, y) => x.F_Sort - y.F_Sort);
  29. var authModuleFunctionList = moduleInfoList.Where(x => functionIdList.Contains(x.F_ModuleId)).ToList();
  30. return Success("获取符合权限的菜单", TreeRecursion(authModuleFunctionList));
  31. }
  32. return NoToken("未知错误,请重新登录");
  33. }
  34. private List<Model.T_Sys_ModuleInfo> TreeRecursion(List<Model.T_Sys_ModuleInfo> data, string parentId = "0")
  35. {
  36. List<Model.T_Sys_ModuleInfo> newList = new List<Model.T_Sys_ModuleInfo>();
  37. List<Model.T_Sys_ModuleInfo> item = data.FindAll(t => t.F_ParentID.ToString() == parentId);//data建议在调用此扩展方法前已经排序过
  38. if (item.Count > 0)
  39. {
  40. foreach (Model.T_Sys_ModuleInfo entity in item)
  41. {
  42. entity.ChildNodes = TreeRecursion(data, entity.F_ModuleId.ToString());
  43. newList.Add(entity);
  44. }
  45. }
  46. return newList;
  47. }
  48. /// <summary>
  49. /// 上传用户图片
  50. /// </summary>
  51. /// <returns></returns>
  52. public ActionResult UploadTX()
  53. {
  54. if (Request.IsAuthenticated)
  55. {
  56. int userId = CurrentUser.UserData.F_UserId;
  57. if (userId != 0)
  58. {
  59. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  60. if (userModel != null)
  61. {
  62. string path = string.Empty;
  63. HttpPostedFile _upfile = RequestString.GetFile("upFile");
  64. if (_upfile != null)
  65. {
  66. //byte[] buffer = new Byte[(int)_upfile.InputStream.Length]; //声明文件长度的二进制类型
  67. //_upfile.InputStream.Read(buffer, 0, buffer.Length); //将文件转成二进制
  68. ImageUpload iu = new ImageUpload();
  69. iu.SavePath = "/Upload/ZXTX/";
  70. iu.PostFile = _upfile;
  71. iu.Upload();
  72. path = "/Upload/ZXTX/" + iu.OutFileName;
  73. userModel.F_See = path;
  74. new BLL.T_Sys_UserAccount().Update(userModel);
  75. return Success("成功", path);
  76. }
  77. else
  78. {
  79. return Error("请选择要上传的文件");
  80. }
  81. }
  82. }
  83. }
  84. return NoToken("未知错误,请重新登录");
  85. }
  86. /// <summary>
  87. /// APP上传图片
  88. /// </summary>
  89. /// <returns></returns>
  90. public ActionResult Upload64()
  91. {
  92. //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
  93. string dataurl = RequestString.GetFormString("dataurl");
  94. string filename = RequestString.GetFormString("filename");
  95. ActionResult res = NoToken("未知错误,请重新登录");
  96. int userId = CurrentUser.UserData.F_UserId;
  97. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  98. if (userModel != null)
  99. {
  100. if (!string.IsNullOrEmpty(dataurl))
  101. {
  102. string path = "/Upload/APP/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  103. ImageUpload iu = new ImageUpload();
  104. iu.SavePath = path;
  105. iu.DataUrl = dataurl;
  106. if (!string.IsNullOrEmpty(filename))
  107. {
  108. iu.SaveType = 1;
  109. iu.InFileName = filename;
  110. }
  111. iu.Upload64();
  112. int n = iu.Error;
  113. if (n == 0)
  114. {
  115. path = path + iu.OutFileName;
  116. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  117. model_T_Sys_Accessories.F_CreateTime = DateTime.Now;//上传时间
  118. model_T_Sys_Accessories.F_Name = iu.OutFileName;//附件名称
  119. model_T_Sys_Accessories.F_Type = ".jpg";//附件类型
  120. model_T_Sys_Accessories.F_Url = path;//附件地址
  121. model_T_Sys_Accessories.F_Size = iu.FileSize;
  122. //model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
  123. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  124. model_T_Sys_Accessories.F_Id = id;
  125. userModel.F_PId = id;
  126. new BLL.T_Sys_UserAccount().Update(userModel);
  127. return Success("成功", model_T_Sys_Accessories);
  128. }
  129. else
  130. {
  131. string msg = string.Empty;
  132. switch (n)
  133. {
  134. case 1: msg = "请选择要上传的文件"; break;
  135. case 2: msg = "上传的文件类型不支持"; break;
  136. case 3: msg = "上传的文件过大"; break;
  137. case 4: msg = "未知错误"; break;
  138. }
  139. return Error(msg);
  140. }
  141. }
  142. else
  143. {
  144. return Error("请选择要上传的文件");
  145. }
  146. }
  147. return res;
  148. }
  149. /// <summary>
  150. /// APP上传图片
  151. /// </summary>
  152. /// <returns></returns>
  153. public ActionResult UploadCL64()
  154. {
  155. //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
  156. string dataurl = RequestString.GetFormString("dataurl");
  157. string filename = RequestString.GetFormString("filename");
  158. ActionResult res = NoToken("未知错误,请重新登录");
  159. int userId = CurrentUser.UserData.F_UserId;
  160. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  161. if (userModel != null)
  162. {
  163. if (!string.IsNullOrEmpty(dataurl))
  164. {
  165. string path = "/Upload/Workorder/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  166. ImageUpload iu = new ImageUpload();
  167. iu.SavePath = path;
  168. iu.DataUrl = dataurl;
  169. if (!string.IsNullOrEmpty(filename))
  170. {
  171. iu.SaveType = 1;
  172. iu.InFileName = filename;
  173. }
  174. iu.Upload64();
  175. int n = iu.Error;
  176. if (n == 0)
  177. {
  178. path = path + iu.OutFileName;
  179. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  180. model_T_Sys_Accessories.F_CreateTime = DateTime.Now;//上传时间
  181. model_T_Sys_Accessories.F_Name = iu.OutFileName;//附件名称
  182. model_T_Sys_Accessories.F_Type = ".jpg";//附件类型
  183. model_T_Sys_Accessories.F_Url = path;//附件地址
  184. model_T_Sys_Accessories.F_Size = iu.FileSize;
  185. // model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
  186. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  187. model_T_Sys_Accessories.F_Id = id;
  188. return Success("成功", model_T_Sys_Accessories);
  189. }
  190. else
  191. {
  192. string msg = string.Empty;
  193. switch (n)
  194. {
  195. case 1: msg = "请选择要上传的文件"; break;
  196. case 2: msg = "上传的文件类型不支持"; break;
  197. case 3: msg = "上传的文件过大"; break;
  198. case 4: msg = "未知错误"; break;
  199. }
  200. return Error(msg);
  201. }
  202. }
  203. else
  204. {
  205. return Error("请选择要上传的文件");
  206. }
  207. }
  208. return res;
  209. }
  210. /// <summary>
  211. /// 上传用户图片
  212. /// </summary>
  213. /// <returns></returns>
  214. public ActionResult UploadTX64()
  215. {
  216. ActionResult res = NoToken("未知错误,请重新登录");
  217. if (Request.IsAuthenticated)
  218. {
  219. int userId = CurrentUser.UserData.F_UserId;
  220. if (userId != 0)
  221. {
  222. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  223. if (userModel != null)
  224. {
  225. string path = string.Empty;
  226. string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
  227. if (!string.IsNullOrEmpty(dataurl))
  228. {
  229. path = "/Upload/ZXTX/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  230. ImageUpload iu = new ImageUpload();
  231. iu.SavePath = path;
  232. iu.DataUrl = dataurl;
  233. iu.Upload64();
  234. int n = iu.Error;
  235. if (n == 0)
  236. {
  237. path = path + iu.OutFileName;
  238. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  239. model_T_Sys_Accessories.F_CreateTime = DateTime.Now;//上传时间
  240. model_T_Sys_Accessories.F_Name = iu.OutFileName;//附件名称
  241. model_T_Sys_Accessories.F_Type = ".jpg";//附件类型
  242. model_T_Sys_Accessories.F_Url = path;//附件地址
  243. model_T_Sys_Accessories.F_Size = iu.FileSize;
  244. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  245. model_T_Sys_Accessories.F_Id = id;
  246. userModel.F_PId = id;
  247. new BLL.T_Sys_UserAccount().Update(userModel);
  248. res = Success("成功", model_T_Sys_Accessories);
  249. }
  250. else
  251. {
  252. string msg = string.Empty;
  253. switch (n)
  254. {
  255. case 1: msg = "请选择要上传的文件"; break;
  256. case 2: msg = "上传的文件类型不支持"; break;
  257. case 3: msg = "上传的文件过大"; break;
  258. case 4: msg = "未知错误"; break;
  259. }
  260. res = Error(msg);
  261. }
  262. }
  263. else
  264. {
  265. res = Error("请选择要上传的文件");
  266. }
  267. }
  268. }
  269. }
  270. return res;
  271. }
  272. /// <summary>
  273. /// 通话记录数量
  274. /// </summary>
  275. /// <returns></returns>
  276. public ActionResult GetTelRecordsTotal()
  277. {
  278. ActionResult res = NoToken("未知错误,请重新登录");
  279. if (Request.IsAuthenticated)
  280. {
  281. int userId = CurrentUser.UserData.F_UserId;
  282. string usercode = CurrentUser.UserData.F_UserCode;
  283. int roleid = CurrentUser.UserData.F_RoleId;
  284. if (userId != 0)
  285. {
  286. var date = DateTime.Now;
  287. string strDate = date.ToString("yyyy-MM-dd");
  288. string strMonth = date.ToString("yyyy-MM");
  289. //string uwhere = " 1=1 ";
  290. string uwhere = " 1=1 AND CONVERT(char(7),BeginTime,20) = '" + strMonth + "' "; //and ISNULL(groupcode,'') != ''
  291. if (roleid != 17)
  292. {
  293. uwhere += " and UserCode='" + usercode + "' ";
  294. }
  295. BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
  296. //var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
  297. //var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
  298. //var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
  299. //var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
  300. //int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' and CallState='0' ").Tables[0].Rows.Count;
  301. //2018-05-03 lihai 首页统计问题
  302. //var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' ");
  303. //var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' ");
  304. //var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' ");
  305. //var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' ");
  306. //int daynocon = bll.GetList("CallType='0' and CallState='0' and datediff(day,BeginTime, '" + strDate + "')=0 ").Tables[0].Rows.Count;
  307. ////int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' ").Tables[0].Rows.Count;
  308. 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];
  309. // 今日来电
  310. var dayinlist = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
  311. var dayinlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'");
  312. var dayinlist_totaltimesum = (from DataRow dr in dayinlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
  313. //今日去电
  314. var dayoutlist = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'").Count();
  315. var dayoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'");
  316. var dayoutlist_totaltimesum = (from DataRow dr in dayoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
  317. //本月来电
  318. var moninlist = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'").Count();
  319. var moninlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'");
  320. var moninlist_totaltimesum = (from DataRow dr in moninlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
  321. //本月去电
  322. var monoutlist = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'").Count();
  323. var monoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'");
  324. var monoutlist_totaltimesum = (from DataRow dr in monoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
  325. //未接来电
  326. var daynocon = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
  327. var obj = new
  328. {
  329. //dayin = new { count = dayinlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  330. //dayout = new { count = dayoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  331. //monin = new { count = moninlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  332. //monout = new { count = monoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  333. //daynocon = daynocon
  334. // 今日来电
  335. dayin = new { count = dayinlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist_totaltimesum.ToString()), 0) },
  336. //今日去电
  337. dayout = new { count = dayoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist_totaltimesum.ToString()), 0) },
  338. //本月来电
  339. monin = new { count = moninlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist_totaltimesum.ToString()), 0) },
  340. //本月去电
  341. monout = new { count = monoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist_totaltimesum.ToString()), 0) },
  342. //未接来电
  343. daynocon = daynocon
  344. };
  345. res = Success("成功", obj);
  346. }
  347. }
  348. return res;
  349. }
  350. ///// <summary>
  351. ///// 通话记录数量
  352. ///// </summary>
  353. ///// <returns></returns>
  354. //public ActionResult GetTelRecordsTotal()
  355. //{
  356. // if (Request.IsAuthenticated)
  357. // {
  358. // int userId = CurrentUser.UserData.F_UserId;
  359. // Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  360. // if (userId != 0)
  361. // {
  362. // var date = DateTime.Now;
  363. // string strDate = date.ToString("yyyy-MM-dd");
  364. // string strMonth = date.ToString("yyyy-MM");
  365. // string uwhere = " 1=1 and ISNULL(groupcode,'') != '' AND CONVERT(char(7),BeginTime,20) = '" + strMonth + "' ";;
  366. // if (userModel.rolecode != "XTGLY")
  367. // {
  368. // uwhere += " and UserCode='" + userModel.F_UserCode + "' ";
  369. // }
  370. // if (!string.IsNullOrEmpty(userModel.groupcode))
  371. // {
  372. // uwhere += " and groupcode = '" + userModel.groupcode + "' ";
  373. // }
  374. // BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
  375. // 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];
  376. // // 今日来电
  377. // var dayinlist = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
  378. // var dayinlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'");
  379. // var dayinlist_totaltimesum = (from DataRow dr in dayinlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
  380. // //今日去电
  381. // var dayoutlist = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'").Count();
  382. // var dayoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'");
  383. // var dayoutlist_totaltimesum = (from DataRow dr in dayoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
  384. // //本月来电
  385. // var moninlist = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'").Count();
  386. // var moninlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'");
  387. // var moninlist_totaltimesum = (from DataRow dr in moninlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
  388. // //本月去电
  389. // var monoutlist = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'").Count();
  390. // var monoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'");
  391. // var monoutlist_totaltimesum = (from DataRow dr in monoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
  392. // //未接来电
  393. // var daynocon = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
  394. // var obj = new
  395. // {
  396. // //// 今日来电
  397. // //dayin = new { count = dayinlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  398. // ////今日去电
  399. // //dayout = new { count = dayoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  400. // ////本月来电
  401. // //monin = new { count = moninlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  402. // ////本月去电
  403. // //monout = new { count = monoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  404. // ////未接来电
  405. // //daynocon = daynocon
  406. // // 今日来电
  407. // dayin = new { count = dayinlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist_totaltimesum.ToString()), 0) },
  408. // //今日去电
  409. // dayout = new { count = dayoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist_totaltimesum.ToString()), 0) },
  410. // //本月来电
  411. // monin = new { count = moninlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist_totaltimesum.ToString()), 0) },
  412. // //本月去电
  413. // monout = new { count = monoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist_totaltimesum.ToString()), 0) },
  414. // //未接来电
  415. // daynocon = daynocon
  416. // };
  417. // return Success("成功", obj);
  418. // }
  419. // }
  420. // return NoToken("未知错误,请重新登录");
  421. //}
  422. /// <summary>
  423. /// 获取当月/当天的工单量(已完成,未完成)
  424. /// </summary>
  425. /// <returns></returns>
  426. public ActionResult GetWorkTotal()
  427. {
  428. if (Request.IsAuthenticated)
  429. {
  430. int userId = CurrentUser.UserData.F_UserId;
  431. if (userId != 0)
  432. {
  433. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  434. if (userModel != null)
  435. {
  436. var date = DateTime.Now;//DateTime.Parse("2015-04-14"); //
  437. string strDate = date.ToString("yyyy-MM-dd");
  438. string strMonth = date.ToString("yyyy-MM");
  439. //BLL.T_Wo_WorkOrderBase bll = new BLL.T_Wo_WorkOrderBase();
  440. //var list1 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + strDate + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
  441. //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];
  442. //var list3 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(char(7),F_CREATEDATE,20)='" + strMonth + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
  443. //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];
  444. string uwhere = " 1=1 and F_State !=11 and F_Duplicate!=5 AND CONVERT(char(7),F_CreateTime,20) = '" + strMonth + "'"; ;
  445. if (userModel.rolecode != "XTGLY")
  446. {
  447. uwhere += " and F_CreateUser='" + userModel.F_UserCode + "' ";
  448. }
  449. //var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =2 and IsDel=0 ").Tables[0];
  450. //var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State in (0,1) and IsDel=0 ").Tables[0];
  451. //var list3 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =2 and IsDel=0 ").Tables[0];
  452. //var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State in (0,1) and IsDel=0 ").Tables[0];
  453. 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];
  454. //日已完成
  455. int list1_count = dtConnect.Select(" yearmonthdays = '" + strDate + "' and F_State = 10 and F_IsDelete = 0").Count();
  456. //日未完成
  457. int list2_count = dtConnect.Select(" yearmonthdays = '" + strDate + "' and F_State<>10 and F_IsDelete=0 ").Count();
  458. //月已完成
  459. var list3_count = dtConnect.Select(" yearmonths = '" + strMonth + "' and F_State =10 and F_IsDelete=0 ").Count();
  460. //月未完成
  461. var list4_count = dtConnect.Select(" yearmonths = '" + strMonth + "' and F_State<>10 and F_IsDelete=0").Count();
  462. //BLL.T_Bus_WorkOrder bll = new BLL.T_Bus_WorkOrder();
  463. //var modellist = bll.GetModelList (uwhere + " and F_IsDelete = 0 and F_State !=11 and F_Duplicate!=5");
  464. //int list1 = 0, list2 = 0, list3 = 0, list4 = 0;
  465. //if (modellist!=null )
  466. //{
  467. // foreach (var it in modellist)
  468. // {
  469. // if (it .F_State ==10)
  470. // {
  471. // list3++;
  472. // if (DateTime .Parse (it.F_CreateTime.ToString ()).ToString("yyyy-MM-dd")== strDate)
  473. // {
  474. // list1++;
  475. // }
  476. // }
  477. // else
  478. // {
  479. // list4++;
  480. // if (DateTime.Parse(it.F_CreateTime.ToString()).ToString("yyyy-MM-dd") == strDate)
  481. // {
  482. // list2++;
  483. // }
  484. // }
  485. // }
  486. //}
  487. // var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),F_CreateTime, 23)='" + strDate + "' and F_State in(10) and F_IsDelete=0 ").Tables[0];
  488. // 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];
  489. // var list3 = bll.GetList(uwhere + " and CONVERT(char(7),F_CreateTime,20)='" + strMonth + "' and F_State in(10) and F_IsDelete=0 ").Tables[0];
  490. // 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];
  491. var obj = new
  492. {
  493. //daywc = list1,
  494. //daywwc = list2,
  495. //monwc = list3,
  496. //monwwc = list4
  497. daywc = list1_count,
  498. daywwc = list2_count,
  499. monwc = list3_count,
  500. monwwc = list4_count
  501. };
  502. return Success("成功", obj);
  503. }
  504. }
  505. }
  506. return NoToken("未知错误,请重新登录");
  507. }
  508. /// <summary>
  509. /// 当天每小时的总通话量和接通量
  510. /// </summary>
  511. /// <returns></returns>
  512. public ActionResult GetTelRecordsByHour()
  513. {
  514. if (Request.IsAuthenticated)
  515. {
  516. int userId = CurrentUser.UserData.F_UserId;
  517. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  518. if (userId != 0)
  519. {
  520. var date = DateTime.Now;//DateTime.Parse("2014-05-05"); //
  521. string strDate = date.ToString("yyyy-MM-dd");
  522. string strMonth = date.ToString("yyyy-MM");
  523. 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" };
  524. string uwhere = " 1=1 and ISNULL(groupcode,'')!= '' AND CONVERT(char(7),BeginTime,20) = '" + strMonth + "' ";
  525. if (userModel.rolecode != "XTGLY")
  526. {
  527. uwhere += " and UserCode='" + userModel.F_UserCode + "' ";
  528. }
  529. BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
  530. DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(13),BeginTime, 120) AS yearmonths,CallState,BeginTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
  531. int[] total = new int[24];
  532. int[] count = new int[24];
  533. for (int i = 0; i < cols.Length; i++)
  534. {
  535. var list = dtConnect.Select("yearmonths = '" + (strDate + " " + cols[i]) + "'");
  536. var conlist = dtConnect.Select("yearmonths = '" + (strDate + " " + cols[i]) + "' and CallState = 1");
  537. total[i] = list.Count();
  538. count[i] = conlist.Count();
  539. }
  540. var obj = new
  541. {
  542. col = cols,
  543. total,
  544. count
  545. };
  546. return Success("成功", obj);
  547. }
  548. }
  549. return NoToken("未知错误,请重新登录");
  550. }
  551. /// <summary>
  552. /// 获取当月每天的工单量和话务量
  553. /// </summary>
  554. /// <returns></returns>
  555. public ActionResult GetWorkTelByDay()
  556. {
  557. if (Request.IsAuthenticated)
  558. {
  559. int userId = CurrentUser.UserData.F_UserId;
  560. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  561. if (userModel != null)
  562. {
  563. var date = DateTime.Now;//DateTime.Parse("2015-04-05"); //
  564. string strDate = date.ToString("yyyy-MM");
  565. int days = DateTime.DaysInMonth(date.Year, date.Month);
  566. string[] strcols = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
  567. "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
  568. "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" };
  569. int newcount = 0;
  570. List<string> cols = strcols.Take(days).ToList();
  571. BLL.T_Call_CallRecords telbll = new BLL.T_Call_CallRecords();
  572. //BLL.T_Wo_WorkOrderBase workbll = new BLL.T_Wo_WorkOrderBase();
  573. BLL.T_Bus_WorkOrder workbll = new BLL.T_Bus_WorkOrder();
  574. int[] teltotal = new int[days];
  575. int[] worktotal = new int[days];
  576. string uwhere = " 1=1 AND CONVERT(char(7),F_CreateTime,20) = '" + strDate + "' ";
  577. string u1where = " 1=1 and ISNULL(groupcode,'') != '' AND CONVERT(char(7),BeginTime,20) = '" + strDate + "' ";
  578. if (userModel.rolecode != "XTGLY")
  579. {
  580. uwhere += " and F_CreateUser='" + userModel.F_UserCode + "' ";
  581. u1where += " and UserCode='" + userModel.F_UserCode + "' ";
  582. }
  583. 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];
  584. 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];
  585. for (int i = 0; i < cols.Count; i++)
  586. {
  587. int tellist_Count = dtConnect.Select("yearmonthdays = '" + (strDate + "-" + cols[i]) + "'").Count();
  588. teltotal[i] = tellist_Count;
  589. newcount = newcount + tellist_Count;
  590. //var worklist = workbll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
  591. //var worklist = workbll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
  592. //int worklist_count = workbll.GetRecordCount(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
  593. int worklist_count = dtConnect_Wo.Select("yearmonthdays = '" + (strDate + "-" + cols[i]) + "'").Count();
  594. //worktotal[i] = worklist.Rows.Count;
  595. worktotal[i] = worklist_count;
  596. }
  597. var olddate = date.AddYears(-1);
  598. string strold1 = olddate.ToString("yyyy-MM") + "-1";
  599. string strold2 = olddate.ToString("yyyy-MM-dd");
  600. string bl = string.Empty;
  601. var oldcount = telbll.GetRecordCount(u1where + " and CONVERT(varchar(10),BeginTime, 23)>='" + strold1 + "' and CONVERT(varchar(10),BeginTime, 23)<='" + strold2 + "' ");
  602. if (oldcount == newcount)
  603. {
  604. bl = " 持平";
  605. }
  606. else
  607. {
  608. if (newcount != 0)
  609. {
  610. if (oldcount > newcount)
  611. {
  612. bl = " ↓ " + (Convert.ToDouble(oldcount - newcount) / Convert.ToDouble(newcount)).ToString("0.0%");
  613. }
  614. else if (oldcount < newcount)
  615. {
  616. bl = " ↑ " + (Convert.ToDouble(newcount - oldcount) / Convert.ToDouble(newcount)).ToString("0.0%");
  617. }
  618. }
  619. else
  620. {
  621. bl = " --";
  622. }
  623. }
  624. var obj = new
  625. {
  626. bl,
  627. col = cols.Select(p => p + "日"),
  628. worktotal,
  629. teltotal
  630. };
  631. return Success("成功", obj);
  632. }
  633. }
  634. return NoToken("未知错误,请重新登录");
  635. }
  636. /// <summary>
  637. /// 获取当前用户待派单、待接单、待处理工单数量
  638. /// </summary>
  639. /// <returns></returns>
  640. public ActionResult GetWorkOrderCount()
  641. {
  642. if (Request.IsAuthenticated)
  643. {
  644. int userId = CurrentUser.UserData.F_UserId;
  645. if (userId != 0)
  646. {
  647. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  648. if (ua != null)
  649. {
  650. BLL.T_Bus_WorkOrder bll = new BLL.T_Bus_WorkOrder();
  651. string uwhere = " 1=1 ";
  652. if (ua.F_RoleId != 17)
  653. {
  654. uwhere += " and F_CreateUser='" + ua.F_UserCode + "' ";
  655. }
  656. var obj = new
  657. {
  658. dpd = bll.GetList(uwhere+ " and F_IsDelete=0 and F_State=0 ").Tables[0].Rows.Count,
  659. 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(),
  660. 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()
  661. };
  662. return Success("成功", obj);
  663. }
  664. }
  665. }
  666. return NoToken("未知错误,请重新登录");
  667. }
  668. /// <summary>
  669. /// 最近通话记录
  670. /// </summary>
  671. /// <returns></returns>
  672. public ActionResult GetLastCallList()
  673. {
  674. if (Request.IsAuthenticated)
  675. {
  676. DataTable dt = new DataTable();
  677. int userId = CurrentUser.UserData.F_UserId;
  678. if (userId != 0)
  679. {
  680. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  681. if (userModel != null)
  682. {
  683. string strnum = HttpUtility.UrlDecode(RequestString.GetQueryString("num"));
  684. int n = 0;
  685. if (strnum.Trim() != "")
  686. {
  687. n = Convert.ToInt32(strnum);
  688. }
  689. dt = new BLL.T_Call_CallRecords().GetList(n, " UserCode='" + userModel.F_UserCode + "' ", "CallRecordsId desc").Tables[0];
  690. var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  691. foreach (DataRow dr in dt.Rows)
  692. {
  693. string path = dr["FilePath"] != null ? dr["FilePath"].ToString() : "";
  694. if (path != "" && config != null && !string.IsNullOrEmpty(config.F_ParamValue))
  695. {
  696. var ym = config.F_ParamValue;
  697. if (ym.Substring(ym.Length - 1) == "/")
  698. {
  699. ym = ym.Substring(0, ym.Length - 1);
  700. }
  701. dr["FilePath"] = ym + path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
  702. }
  703. }
  704. return Success("成功", dt);
  705. }
  706. }
  707. }
  708. return NoToken("未知错误,请重新登录");
  709. }
  710. /// <summary>
  711. /// 最近消息
  712. /// </summary>
  713. /// <returns></returns>
  714. public ActionResult GetLastMsgList()
  715. {
  716. if (Request.IsAuthenticated)
  717. {
  718. DataTable dt = new DataTable();
  719. int userId = CurrentUser.UserData.F_UserId;
  720. if (userId != 0)
  721. {
  722. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  723. if (userModel != null)
  724. {
  725. string strnum = HttpUtility.UrlDecode(RequestString.GetQueryString("num"));
  726. int n = 0;
  727. if (strnum.Trim() != "")
  728. {
  729. n = Convert.ToInt32(strnum);
  730. }
  731. dt = new BLL.T_Msg_List().GetList(n, " ToUser='" + userModel.F_UserCode + "' and IsDel=0 ", "ID desc").Tables[0];
  732. return Success("成功", dt);
  733. }
  734. }
  735. }
  736. return NoToken("未知错误,请重新登录");
  737. }
  738. }
  739. }