三元财务API

IndexController.cs 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using CallCenterApi.Interface.Controllers.workorder;
  5. using CallCenterApi.Interface.Models.Enum;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace CallCenterApi.Interface.Controllers
  13. {
  14. public class IndexController : BaseController
  15. {
  16. private BLL.T_Sys_ModuleInfo moduleInfoBLL = new BLL.T_Sys_ModuleInfo();
  17. private BLL.T_Sys_RoleFunction roleFunctionBLL = new BLL.T_Sys_RoleFunction();
  18. /// <summary>
  19. /// 获取菜单
  20. /// </summary>
  21. /// <returns></returns>
  22. public ActionResult GetMenu()
  23. {
  24. ActionResult res = NoToken("未知错误,请重新登录");
  25. if (Request.IsAuthenticated)
  26. {
  27. var roleId = CurrentUser.UserData.F_RoleId;
  28. var functionIdList = roleFunctionBLL.DataTableToList(roleFunctionBLL.GetList(" F_RoleId=" + roleId).Tables[0]).Select(x => x.F_FunctionId);
  29. var moduleInfoList = moduleInfoBLL.DataTableToList(moduleInfoBLL.GetList(" F_StateFlag=1 ").Tables[0]);
  30. moduleInfoList.Sort((x, y) => x.F_Sort - y.F_Sort);
  31. var authModuleFunctionList = moduleInfoList.Where(x => functionIdList.Contains(x.F_ModuleId)).ToList();
  32. res = Success("获取符合权限的菜单", TreeRecursion(authModuleFunctionList));
  33. }
  34. return res;
  35. }
  36. private List<Model.T_Sys_ModuleInfo> TreeRecursion(List<Model.T_Sys_ModuleInfo> data, string parentId = "0")
  37. {
  38. List<Model.T_Sys_ModuleInfo> newList = new List<Model.T_Sys_ModuleInfo>();
  39. List<Model.T_Sys_ModuleInfo> item = data.FindAll(t => t.F_ParentID.ToString() == parentId);//data建议在调用此扩展方法前已经排序过
  40. if (item.Count > 0)
  41. {
  42. foreach (Model.T_Sys_ModuleInfo entity in item)
  43. {
  44. entity.ChildNodes = TreeRecursion(data, entity.F_ModuleId.ToString());
  45. newList.Add(entity);
  46. }
  47. }
  48. return newList;
  49. }
  50. /// <summary>
  51. /// 上传用户图片
  52. /// </summary>
  53. /// <returns></returns>
  54. public ActionResult UploadTX()
  55. {
  56. ActionResult res = NoToken("未知错误,请重新登录");
  57. if (Request.IsAuthenticated)
  58. {
  59. int userId = CurrentUser.UserData.F_UserId;
  60. if (userId != 0)
  61. {
  62. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  63. if (userModel != null)
  64. {
  65. string path = string.Empty;
  66. HttpPostedFile _upfile = RequestString.GetFile("upFile");
  67. if (_upfile != null)
  68. {
  69. //byte[] buffer = new Byte[(int)_upfile.InputStream.Length]; //声明文件长度的二进制类型
  70. //_upfile.InputStream.Read(buffer, 0, buffer.Length); //将文件转成二进制
  71. ImageUpload iu = new ImageUpload();
  72. iu.SavePath = "/Upload/ZXTX/";
  73. iu.PostFile = _upfile;
  74. iu.Upload();
  75. path = "/Upload/ZXTX/" + iu.OutFileName;
  76. userModel.F_See = path;
  77. new BLL.T_Sys_UserAccount().Update(userModel);
  78. res = Success("成功", path);
  79. }
  80. else
  81. {
  82. res = Error("请选择要上传的文件");
  83. }
  84. }
  85. }
  86. }
  87. return res;
  88. }
  89. /// <summary>
  90. /// 上传用户图片
  91. /// </summary>
  92. /// <returns></returns>
  93. public ActionResult UploadTX64()
  94. {
  95. ActionResult res = NoToken("未知错误,请重新登录");
  96. if (Request.IsAuthenticated)
  97. {
  98. int userId = CurrentUser.UserData.F_UserId;
  99. if (userId != 0)
  100. {
  101. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  102. if (userModel != null)
  103. {
  104. string path = string.Empty;
  105. string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
  106. if (!string.IsNullOrEmpty(dataurl))
  107. {
  108. ImageUpload iu = new ImageUpload();
  109. iu.SavePath = "/Upload/ZXTX/";
  110. iu.DataUrl = dataurl;
  111. iu.Upload64();
  112. int n = iu.Error;
  113. if (n == 0)
  114. {
  115. path = "/Upload/ZXTX/" + iu.OutFileName;
  116. userModel.F_See = path;
  117. new BLL.T_Sys_UserAccount().Update(userModel);
  118. res = Success("成功", path);
  119. }
  120. else
  121. {
  122. string msg = string.Empty;
  123. switch (n)
  124. {
  125. case 1: msg = "请选择要上传的文件"; break;
  126. case 2: msg = "上传的文件类型不支持"; break;
  127. case 3: msg = "上传的文件过大"; break;
  128. case 4: msg = "未知错误"; break;
  129. }
  130. res = Error(msg);
  131. }
  132. }
  133. else
  134. {
  135. res = Error("请选择要上传的文件");
  136. }
  137. }
  138. }
  139. }
  140. return res;
  141. }
  142. /// <summary>
  143. /// 通话记录数量
  144. /// </summary>
  145. /// <returns></returns>
  146. public ActionResult GetTelRecordsTotal()
  147. {
  148. ActionResult res = NoToken("未知错误,请重新登录");
  149. if (Request.IsAuthenticated)
  150. {
  151. int userId = CurrentUser.UserData.F_UserId;
  152. string usercode = CurrentUser.UserData.F_UserCode;
  153. int roleid = CurrentUser.UserData.F_RoleId;
  154. if (userId != 0)
  155. {
  156. var date = DateTime.Now;
  157. string strDate = date.ToString("yyyy-MM-dd");
  158. string strMonth = date.ToString("yyyy-MM");
  159. string uwhere = " 1=1 ";
  160. if (roleid != 17)
  161. {
  162. uwhere += " and UserCode='" + usercode + "' ";
  163. }
  164. BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
  165. //var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
  166. //var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
  167. //var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
  168. //var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
  169. //int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' and CallState='0' ").Tables[0].Rows.Count;
  170. //2018-05-03 lihai 首页统计问题
  171. var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' ");
  172. var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' ");
  173. var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' ");
  174. var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' ");
  175. int daynocon = bll.GetList("CallType='0' and CallState='0' and datediff(day,BeginTime, '" + strDate + "')=0 ").Tables[0].Rows.Count;
  176. //int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' ").Tables[0].Rows.Count;
  177. var obj = new
  178. {
  179. dayin = new { count = dayinlist.Count, totaltime =DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist.Select(p => p.TalkLongTime).Sum().ToString()),0) },
  180. dayout = new { count = dayoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
  181. monin = new { count = moninlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist.Select(p => p.TalkLongTime).Sum().ToString()),0) },
  182. monout = new { count = monoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist.Select(p => p.TalkLongTime).Sum().ToString()),0) },
  183. daynocon = daynocon
  184. };
  185. res = Success("成功", obj);
  186. }
  187. }
  188. return res;
  189. }
  190. /// <summary>
  191. /// 获取当月/当天的工单量(已完成,未完成)
  192. /// </summary>
  193. /// <returns></returns>
  194. public ActionResult GetWorkTotal()
  195. {
  196. ActionResult res = NoToken("未知错误,请重新登录");
  197. if (Request.IsAuthenticated)
  198. {
  199. int userId = CurrentUser.UserData.F_UserId;
  200. int deptid = CurrentUser.UserData.F_DeptId; //部门id
  201. if (userId != 0)
  202. {
  203. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  204. if (ua != null)
  205. {
  206. var date = DateTime.Now;//DateTime.Parse("2015-04-14"); //
  207. string strDate = date.ToString("yyyy-MM-dd");
  208. string strMonth = date.ToString("yyyy-MM");
  209. //BLL.T_Wo_WorkOrderBase bll = new BLL.T_Wo_WorkOrderBase();
  210. //var list1 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + strDate + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
  211. //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];
  212. //var list3 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(char(7),F_CREATEDATE,20)='" + strMonth + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
  213. //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];
  214. //部门信息
  215. var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
  216. int depType = 0;
  217. if (modelDep != null)
  218. depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  219. string uwhere = " 1=1 ";
  220. if (ua.F_RoleId != 17 && depType != 1 && depType != 3)
  221. {
  222. uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
  223. }
  224. BLL.T_Wo_WorkOrder bll = new BLL.T_Wo_WorkOrder();
  225. var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =" + (int)EnumWorkOrderState.finish + " and IsDel=0 ").Tables[0];
  226. var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State <" + (int)EnumWorkOrderState.finish + " and IsDel=0 ").Tables[0];
  227. var list3 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =" + (int)EnumWorkOrderState.finish + " and IsDel=0 ").Tables[0];
  228. var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State <" + (int)EnumWorkOrderState.finish + " and IsDel=0 ").Tables[0];
  229. #region
  230. //var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =2 and IsDel=0 ").Tables[0];
  231. //var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State in (0,1) and IsDel=0 ").Tables[0];
  232. //var list3 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =2 and IsDel=0 ").Tables[0];
  233. //var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State in (0,1) and IsDel=0 ").Tables[0];
  234. ////日已完成
  235. //var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =1 and IsDel=0 ").Tables[0];
  236. ////日未完成
  237. //var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State=0 and IsDel=0 ").Tables[0];
  238. ////月已完成
  239. //var list3 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =1 and IsDel=0 ").Tables[0];
  240. ////月未完成
  241. //var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State=0 and IsDel=0 ").Tables[0];
  242. #endregion
  243. var obj = new
  244. {
  245. daywc = list1.Rows.Count,
  246. daywwc = list2.Rows.Count,
  247. monwc = list3.Rows.Count,
  248. monwwc = list4.Rows.Count
  249. };
  250. res = Success("成功", obj);
  251. }
  252. }
  253. }
  254. return res;
  255. }
  256. /// <summary>
  257. /// 当天每小时的总通话量和接通量
  258. /// </summary>
  259. /// <returns></returns>
  260. public ActionResult GetTelRecordsByHour()
  261. {
  262. ActionResult res = NoToken("未知错误,请重新登录");
  263. if (Request.IsAuthenticated)
  264. {
  265. int userId = CurrentUser.UserData.F_UserId;
  266. string usercode = CurrentUser.UserData.F_UserCode;
  267. int roleid = CurrentUser.UserData.F_RoleId;
  268. if (userId != 0)
  269. {
  270. var date = DateTime.Now;//DateTime.Parse("2014-05-05"); //
  271. string strDate = date.ToString("yyyy-MM-dd");
  272. 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" };
  273. string uwhere = " 1=1 ";
  274. if (roleid != 17)
  275. {
  276. uwhere += " and UserCode='" + usercode + "' ";
  277. }
  278. BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
  279. int[] total = new int[24];
  280. int[] count = new int[24];
  281. for (int i = 0; i < cols.Length; i++)
  282. {
  283. var list = bll.GetModelList(uwhere + " and CONVERT(varchar(13),BeginTime, 120)='" + (strDate + " " + cols[i]) + "' ");
  284. var conlist = list.Where(p => p.CallState == 1);
  285. total[i] = list.Count;
  286. count[i] = conlist.Count();
  287. }
  288. var obj = new
  289. {
  290. col = cols,
  291. total = total,
  292. count = count
  293. };
  294. res = Success("成功", obj);
  295. }
  296. }
  297. return res;
  298. }
  299. /// <summary>
  300. /// 获取当月每天的工单量和话务量
  301. /// </summary>
  302. /// <returns></returns>
  303. public ActionResult GetWorkTelByDay()
  304. {
  305. ActionResult res = NoToken("未知错误,请重新登录");
  306. if (Request.IsAuthenticated)
  307. {
  308. int userId = CurrentUser.UserData.F_UserId;
  309. int deptid = CurrentUser.UserData.F_DeptId; //部门id
  310. if (userId != 0)
  311. {
  312. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  313. if (ua != null)
  314. {
  315. var date = DateTime.Now;//DateTime.Parse("2015-04-05"); //
  316. string strDate = date.ToString("yyyy-MM");
  317. int days = DateTime.DaysInMonth(date.Year, date.Month);
  318. string[] strcols = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
  319. "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
  320. "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" };
  321. int newcount = 0;
  322. List<string> cols = strcols.Take(days).ToList();
  323. BLL.T_Call_CallRecords telbll = new BLL.T_Call_CallRecords();
  324. //BLL.T_Wo_WorkOrderBase workbll = new BLL.T_Wo_WorkOrderBase();
  325. BLL.T_Wo_WorkOrder workbll = new BLL.T_Wo_WorkOrder();
  326. int[] teltotal = new int[days];
  327. int[] worktotal = new int[days];
  328. //部门信息
  329. var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
  330. int depType = 0;
  331. if (modelDep != null)
  332. depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  333. string uwhere = " 1=1 ";
  334. string u1where = " 1=1 ";
  335. if (ua.F_RoleId != 17 && depType != 1 && depType != 3)
  336. {
  337. uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
  338. u1where += " and UserCode='" + ua.F_UserCode + "' ";
  339. }
  340. for (int i = 0; i < cols.Count; i++)
  341. {
  342. //var tellist = telbll.GetModelList(" UserId='" + userId + "' and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
  343. var tellist = telbll.GetModelList(u1where + " and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
  344. teltotal[i] = tellist.Count;
  345. newcount = newcount + tellist.Count;
  346. //var worklist = workbll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
  347. var worklist = workbll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
  348. worktotal[i] = worklist.Rows.Count;
  349. }
  350. var olddate = date.AddYears(-1);
  351. string strold1 = olddate.ToString("yyyy-MM") + "-1";
  352. string strold2 = olddate.ToString("yyyy-MM-dd");
  353. string bl = string.Empty;
  354. var oldcount = telbll.GetModelList(u1where + " and CONVERT(varchar(10),BeginTime, 23)>='" + strold1 + "' and CONVERT(varchar(10),BeginTime, 23)<='" + strold2 + "' ").Count;
  355. if (oldcount == newcount)
  356. {
  357. bl = " 持平";
  358. }
  359. else
  360. {
  361. if (newcount != 0)
  362. {
  363. if (oldcount > newcount)
  364. {
  365. bl = " ↓ " + (Convert.ToDouble(oldcount - newcount) / Convert.ToDouble(newcount)).ToString("0.0%");
  366. }
  367. else if (oldcount < newcount)
  368. {
  369. bl = " ↑ " + (Convert.ToDouble(newcount - oldcount) / Convert.ToDouble(newcount)).ToString("0.0%");
  370. }
  371. }
  372. else
  373. {
  374. bl = " --";
  375. }
  376. }
  377. var obj = new
  378. {
  379. bl = bl,
  380. col = cols.Select(p => p + "日"),
  381. worktotal = worktotal,
  382. teltotal = teltotal
  383. };
  384. res = Success("成功", obj);
  385. }
  386. }
  387. }
  388. return res;
  389. }
  390. /// <summary>
  391. /// 获取当前用户待派单、待接单、待处理工单数量
  392. /// </summary>
  393. /// <returns></returns>
  394. public ActionResult GetWorkOrderCount()
  395. {
  396. ActionResult res = NoToken("未知错误,请重新登录");
  397. if (Request.IsAuthenticated)
  398. {
  399. int userId = CurrentUser.UserData.F_UserId;
  400. int deptid = CurrentUser.UserData.F_DeptId; //部门id
  401. string deptCode = CurrentUser.UserData.F_DeptCode; //部门code
  402. int userRegionId = CurrentUser.UserData.RegionId; //项目id
  403. if (userId != 0)
  404. {
  405. var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='TimeLimitDays' ").FirstOrDefault();
  406. int days = config != null ? Convert.ToInt32(config.F_ParamValue) : 60; //默认60天
  407. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  408. if (ua != null)
  409. {
  410. #region 权限限制
  411. string sql = " and IsDel=0 ";
  412. ////部门信息
  413. //var modelDep = new BLL.T_Sys_Department().GetModel(deptid);
  414. //int depType = 0, depRegion = 0;
  415. //if (modelDep != null)
  416. //{
  417. // depType = modelDep.F_Type ?? 0; //部门操作权限:1接待部,2办理人员,3区域客服,4监管
  418. // depRegion = modelDep.F_Header ?? 0; //部门权限范围:9全部,1区域,2项目,3期
  419. //}
  420. //if (ua.F_RoleId != 17)
  421. //{
  422. // if (depType == 2)
  423. // {
  424. // if (depRegion == 1)
  425. // {
  426. // // 查看该区域工单
  427. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  428. // sql += $" and IsUserSend = {userRegionId} ";
  429. // }
  430. // else if (depRegion == 2)
  431. // {
  432. // // 查看该项目工单
  433. // sql += $" and IsAdminSend = {userRegionId} ";
  434. // }
  435. // }
  436. // else if (depType == 3)
  437. // {
  438. // if (depRegion == 1)
  439. // {
  440. // // 查看该区域工单
  441. // //sql += $" and IsUserSend = (SELECT TOP 1 F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = {userRegionId}) ";
  442. // sql += $" and IsUserSend = {userRegionId} ";
  443. // }
  444. // }
  445. // else if (depType == 4)
  446. // {
  447. // if (depRegion == 2)
  448. // {
  449. // // 查看该项目工单
  450. // sql += $" and IsAdminSend = {userRegionId} ";
  451. // }
  452. // else if (depRegion == 9)
  453. // {
  454. // // 查看该部门工单(包括一级,二级)
  455. // string deptCodeNew = String.Empty;
  456. // int deptCodeIndex = 0; //变量声明
  457. // string deptCodeN = deptCode.TrimEnd('|'); //去掉最后一个|
  458. // deptCodeIndex = deptCodeN.LastIndexOf("|"); //获得|的索引
  459. // deptCodeNew = deptCodeN.Substring(0, deptCodeIndex + 1); //获得目标字符串(//去掉最后一个|后面的字符串)
  460. // //============== 部门权限条件 - 部门 ================
  461. // string arrUser = " select F_UserCode from T_Sys_UserAccount where F_DeptCode LIKE '" + deptCodeNew + "%' ";
  462. // sql += $" and WorkOrderID in (SELECT DISTINCT WorkOrderID FROM dbo.T_Wo_WorkOrderItem WHERE ToUser IN ({arrUser})) ";
  463. // }
  464. // }
  465. //}
  466. #endregion
  467. BLL.T_Wo_WorkOrder bll = new BLL.T_Wo_WorkOrder();
  468. WorkOrderController woController = new WorkOrderController();
  469. string uwhere = " 1=1 ";
  470. //1、待指派的
  471. if (ua.F_RoleId != 17)
  472. {
  473. uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
  474. uwhere += " and State =" + (int)EnumWorkOrderState.neworder + " ";
  475. //uwhere += " and State =0 ";
  476. }
  477. //2、待接单的
  478. string djdwhere = $" 1=1 and State =" + (int)EnumWorkOrderState.assign + " and T_Wo_WorkOrder.ID in ( " + woController.GetDJDWorkOrderID(ua.F_UserCode) + ") ";//" 1=1 and State =1 and WorkOrderID in ( " + woController.GetDJDWorkOrderID(ua.F_UserCode) + ") ";
  479. //3、待完成(处理)的
  480. string dclwhere = $" 1=1 and State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + ") and T_Wo_WorkOrder.ID in ( " + woController.GetDWCWorkOrderID(ua.F_UserCode) + ") ";//" 1=1 and State =1 and WorkOrderID in ( " + woController.GetDWCWorkOrderID(ua.F_UserCode) + ") ";
  481. //4、已处理的
  482. string yclwhere = $" 1=1 and State =" + (int)EnumWorkOrderState.finish + " and LastDealUser = '" + ua.F_UserCode + "' ";//" 1=1 and State =2 and LastDealUser = '" + ua.F_UserCode + "' ";
  483. //5、我参与的
  484. string wcywhere = $" 1=1 and (CreateUser= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.ID in ( " + woController.GetCYWorkOrderID(ua.F_UserCode) + ")) ";//" 1=1 and (CreateUser= '" + ua.F_UserCode + "' or WorkOrderID in ( " + woController.GetCYWorkOrderID(ua.F_UserCode) + ")) ";
  485. //5、超期工单
  486. string cqwhere = $" 1=1 and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < " + (int)EnumWorkOrderState.finish + " ";//$" 1=1 and DATEADD(DAY,{days},CreateTime) < GETDATE() AND State < 2 ";
  487. //5、未审核微信工单
  488. string wxwhere = $" 1=1 "; // ANd Type = (SELECT F_DictionaryValueId FROM dbo.T_Sys_DictionaryValue (NOLOCK) WHERE F_DictionaryFlag = 'GDLY' AND F_Name = '微信')
  489. var obj = new
  490. {
  491. dpd = bll.GetList(uwhere + sql + " and State=" + (int)EnumWorkOrderState.neworder + " and IsAudit = 1 ").Tables[0].Rows.Count, //待指派的统计
  492. djd = bll.GetList(djdwhere + sql + " and State =" + (int)EnumWorkOrderState.assign + " and IsAudit = 1 ").Tables[0].Rows.Count, //待接单的统计
  493. dcl = bll.GetList(dclwhere + sql + " and State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + ") and IsAudit = 1 ").Tables[0].Rows.Count, //待处理的统计
  494. ycl = bll.GetList(yclwhere + sql + " and State =" + (int)EnumWorkOrderState.finish + " and IsAudit = 1 ").Tables[0].Rows.Count, //已处理的统计
  495. wyc = bll.GetList(wcywhere + sql + " and IsAudit = 1 ").Tables[0].Rows.Count, //我参与的的统计
  496. cq = bll.GetList(cqwhere + sql + " AND State < " + (int)EnumWorkOrderState.finish + " and IsAudit = 1 ").Tables[0].Rows.Count, //超期工单的统计
  497. wx = bll.GetList(wxwhere + sql + " and IsAudit = 0 ").Tables[0].Rows.Count, //微信工单的统计
  498. //dpd = bll.GetList(uwhere + sql+ " and State=0 and IsAudit = 1 ").Tables[0].Rows.Count, //待指派的统计
  499. //djd = bll.GetList(djdwhere + sql + " and State =1 and IsAudit = 1 ").Tables[0].Rows.Count, //待接单的统计
  500. //dcl = bll.GetList(dclwhere + sql + " and State =1 and IsAudit = 1 ").Tables[0].Rows.Count, //待处理的统计
  501. //ycl = bll.GetList(yclwhere + sql + " and State =2 and IsAudit = 1 ").Tables[0].Rows.Count, //已处理的统计
  502. //wyc = bll.GetList(wcywhere + sql + " and IsAudit = 1 ").Tables[0].Rows.Count, //我参与的的统计
  503. //cq = bll.GetList(cqwhere + sql + " AND State < 2 and IsAudit = 1 ").Tables[0].Rows.Count, //超期工单的统计
  504. //wx = bll.GetList(wxwhere + sql + " and IsAudit = 0 ").Tables[0].Rows.Count, //微信工单的统计
  505. //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(),
  506. //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()
  507. };
  508. res = Success("成功", obj);
  509. }
  510. }
  511. }
  512. return res;
  513. }
  514. /// <summary>
  515. /// 最近通话记录
  516. /// </summary>
  517. /// <returns></returns>
  518. public ActionResult GetLastCallList()
  519. {
  520. ActionResult res = NoToken("未知错误,请重新登录");
  521. if (Request.IsAuthenticated)
  522. {
  523. DataTable dt = new DataTable();
  524. int userId = CurrentUser.UserData.F_UserId;
  525. if (userId != 0)
  526. {
  527. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  528. if (userModel != null)
  529. {
  530. string strnum = HttpUtility.UrlDecode(RequestString.GetQueryString("num"));
  531. int n = 0;
  532. if (strnum.Trim() != "")
  533. {
  534. n = Convert.ToInt32(strnum);
  535. }
  536. dt = new BLL.T_Call_CallRecords().GetList(n, " UserCode='" + userModel.F_UserCode + "' ", "CallRecordsId desc").Tables[0];
  537. var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  538. foreach (DataRow dr in dt.Rows)
  539. {
  540. string path = dr["FilePath"] != null ? dr["FilePath"].ToString() : "";
  541. if (path != "" && config != null && !string.IsNullOrEmpty(config.F_ParamValue))
  542. {
  543. var ym = config.F_ParamValue;
  544. if (ym.Substring(ym.Length - 1) == "/")
  545. {
  546. ym = ym.Substring(0, ym.Length - 1);
  547. }
  548. dr["FilePath"] = ym + path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
  549. }
  550. }
  551. res = Success("成功", dt);
  552. }
  553. }
  554. }
  555. return res;
  556. }
  557. /// <summary>
  558. /// 最近消息
  559. /// </summary>
  560. /// <returns></returns>
  561. public ActionResult GetLastMsgList()
  562. {
  563. ActionResult res = NoToken("未知错误,请重新登录");
  564. if (Request.IsAuthenticated)
  565. {
  566. DataTable dt = new DataTable();
  567. int userId = CurrentUser.UserData.F_UserId;
  568. if (userId != 0)
  569. {
  570. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  571. if (userModel != null)
  572. {
  573. string strnum = HttpUtility.UrlDecode(RequestString.GetQueryString("num"));
  574. int n = 0;
  575. if (strnum.Trim() != "")
  576. {
  577. n = Convert.ToInt32(strnum);
  578. }
  579. dt = new BLL.T_Msg_List().GetList(n, " ToUser='" + userModel.F_UserCode + "' and IsDel=0 ", "ID desc").Tables[0];
  580. res = Success("成功", dt);
  581. }
  582. }
  583. }
  584. return res;
  585. }
  586. }
  587. }