Aucune description

InfoNewController.cs 48KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  1. using CallCenter.Utility;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using Newtonsoft.Json;
  5. using Newtonsoft.Json.Linq;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Threading.Tasks;
  11. using System.Web;
  12. using System.Web.Mvc;
  13. namespace CallCenterApi.Interface.Controllers.WebChart
  14. {
  15. public class InfoNewController : BaseController
  16. {
  17. // GET: InfoNew
  18. public ActionResult Index()
  19. {
  20. return Content("InfoNew");
  21. }
  22. public ActionResult WorkOrdrList()
  23. {
  24. DataTable dt = new DataTable();
  25. string sql = " and F_IsDelete=0 ";
  26. int source = RequestString.GetInt("source", 0);
  27. int hour = RequestString.GetInt("hour", -1);
  28. int type = RequestString.GetInt("type", 0);
  29. int dealtype = RequestString.GetInt("dealtype", -1);
  30. int timetype = RequestString.GetInt("timetype", 1);
  31. int sourceArea = RequestString.GetInt("sourceArea", 0);
  32. int keyid = RequestString.GetInt("keyid", 0);
  33. int deptid = RequestString.GetInt("deptid", 0);
  34. int dptype = RequestString.GetInt("dptype", 0);
  35. int kptype = RequestString.GetInt("kptype", 0);
  36. int handling = RequestString.GetInt("handling", 0);
  37. string kpcontent = RequestString.GetQueryString("kpcontent");
  38. string latitude = RequestString.GetQueryString("latitude");
  39. string longitude = RequestString.GetQueryString("longitude");
  40. string strpageindex = RequestString.GetQueryString("page");
  41. int pageindex = 1;
  42. string strpagesize = RequestString.GetQueryString("pagesize");
  43. int pagesize = 10;
  44. if (strpageindex.Trim() != "")
  45. {
  46. pageindex = Convert.ToInt32(strpageindex);
  47. }
  48. if (dealtype > -1)
  49. {
  50. if (dealtype == 2)
  51. {//按时
  52. sql += " and F_IsResult=0 and isnull(F_DealTime,'')<>'' and F_LimitTime>=F_DealTime ";
  53. }
  54. else if (dealtype == 3)
  55. {//超期
  56. sql += " and isnull(F_DealTime,'')<>'' and F_LimitTime<F_DealTime ";
  57. }
  58. else
  59. sql += " and isnull(F_IsResult,0) = '" + dealtype + "' ";
  60. }
  61. if (strpagesize.Trim() != "")
  62. {
  63. pagesize = Convert.ToInt32(strpagesize);
  64. }
  65. string value = "";
  66. if (handling>0)
  67. {
  68. if (handling==1)
  69. {
  70. value = "inner join T_Bus_RemindRecord b on a.F_WorkOrderId = b.F_WorkOrderId and datediff(MONTH , a.F_CreateTime , getdate())= 0 and F_Type = 1 ";
  71. }
  72. else if (handling == 2)
  73. {
  74. sql += "and F_IsResult=1";
  75. }
  76. else if (handling == 3)
  77. {
  78. sql += "and F_IsResult !=1";
  79. }
  80. else if (handling == 4)
  81. {
  82. value = "inner join T_SMS_RecvSMS b on a .F_WorkOrderId = b.F_Name and datediff(MONTH , b.RecvTime , getdate())= 0 and datediff(MONTH , a.F_CreateTime , getdate())= 0 and Content like '%收到催办,请及时处理%' ";
  83. }
  84. }
  85. if (deptid > 0)
  86. {
  87. sql += "and F_MainDeptId='" + deptid + "'";
  88. }
  89. if (latitude.Trim ()!="")
  90. {
  91. sql += "and F_Latitude='" + latitude + "'";
  92. }
  93. if (longitude .Trim() != "")
  94. {
  95. sql += "and F_Longitude='" + longitude + "'";
  96. }
  97. if (sourceArea >0)
  98. {
  99. sql += "and F_SourceArea='" + sourceArea + "'";
  100. }
  101. if (type >0)
  102. {
  103. sql += "and F_InfoType='" + type + "'";
  104. }
  105. if (source >0)
  106. {
  107. sql += "and F_InfoSource='" + source + "'";
  108. }
  109. if (keyid>0)
  110. {
  111. sql += "and F_Key='"+ keyid + "' ";
  112. }
  113. if (kptype <=0)
  114. {
  115. if (timetype == 1)
  116. {
  117. sql += "and datediff(DAY ,F_CreateTime ,getdate())=0 ";
  118. }
  119. else if (timetype == 2)
  120. {
  121. sql += "and datediff(WEEK ,F_CreateTime ,getdate())=0 ";
  122. }
  123. else
  124. {
  125. sql += "and datediff(MONTH ,F_CreateTime ,getdate())=0 ";
  126. }
  127. }
  128. if (hour > -1)
  129. {
  130. sql += " and datepart(hh,F_CreateTime)=" + hour;
  131. }
  132. if (dptype>0)
  133. {
  134. if (deptid <= 0)
  135. {
  136. return Error("请选择部门");
  137. }
  138. if (dptype==1)
  139. {
  140. //当月平均办理时长
  141. sql += " F_IsResult=0 and datediff(MONTH , F_CreateTime , getdate())= 0 and F_DealDeptId is not null and F_MainDeptId is not null and F_WorkState in(6, 9) and F_AssignTime is not null and F_DealTime is not null";
  142. }
  143. else if (dptype == 1)
  144. {
  145. //上月平均办理时长
  146. sql += " F_IsResult=0 and datediff(MONTH , F_CreateTime , getdate())= 1 and F_DealDeptId is not null and F_MainDeptId is not null and F_WorkState in(6, 9) and F_AssignTime is not null and F_DealTime is not null";
  147. }
  148. else if (dptype == 2)
  149. {
  150. //上月平均办理时长
  151. sql += " F_IsResult=0 and datediff(MONTH , F_CreateTime , getdate())= 1 and F_DealDeptId is not null and F_MainDeptId is not null and F_WorkState in(6, 9) and F_AssignTime is not null and F_DealTime is not null";
  152. }
  153. else if (dptype == 3)
  154. {
  155. //工单数量
  156. sql += " datediff(MONTH ,F_CreateTime ,getdate())=0 and F_WorkState not in (0, 1, 11) and F_MainDeptId is not null and F_MainDeptId != ''";
  157. }
  158. else if (dptype == 4)
  159. {
  160. //工单不满意数量
  161. sql += " datediff(MONTH ,F_CreateTime ,getdate())=0 and F_WorkState not in (0, 1, 11) and F_MainDeptId is not null and F_MainDeptId != ''and F_WorkOrderId in(select F_WorkOrderId from T_Bus_VisitResult where F_IsSatisfie = 0 and F_CreateTime > a.F_AssignTime )";
  162. }
  163. else if (dptype == 5)
  164. {
  165. //工单超期
  166. sql += " ((isnull(F_DealTime,F_CloseTime )>(select top 1 F_LimitTime from T_Bus_AssignedInfo WITH(NOLOCK)WHERE F_WorkOrderId = a.F_WorkOrderId and F_State = 1 and F_IsDelete = 0 and F_IsSure<>3 ORDER BY F_Id DESC) AND F_WorkState = 9 AND F_CloseTime IS NOT NULL) OR(isnull(F_DealTime, getdate()) > (select top 1 F_LimitTime from T_Bus_AssignedInfo WITH(NOLOCK)WHERE F_WorkOrderId = a.F_WorkOrderId and F_State = 1 and F_IsDelete = 0 and F_IsSure <> 3 ORDER BY F_Id DESC) AND F_WorkState in(2, 4, 6, 8) ) ) and datediff(MONTH , a.F_CreateTime , getdate())= 0 ";
  167. }
  168. }
  169. if (kptype>0)
  170. {
  171. if (deptid <= 0)
  172. {
  173. return Error("请选择部门");
  174. }
  175. if (string .IsNullOrEmpty (kpcontent))
  176. return Error("请选择考评内容");
  177. if (kptype==1)
  178. {
  179. sql +=" and F_WorkOrderId in( F_Deptid="+ deptid + " and datediff(MONTH ,F_CreatTime ,getdate())=0 and F_Type = 0 and F_Evaluation = '"+ kpcontent + "') ";
  180. }
  181. else
  182. {
  183. sql += " and F_WorkOrderId in( F_Deptid=" + deptid + " and datediff(MONTH ,F_CreatTime ,getdate())=0 and F_Type = 0 and F_Bonusitems = '" + kpcontent + "') ";
  184. }
  185. }
  186. string cols = "DISTINCT a.F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_IsResult,a.F_CreateTime,dbo.GetUserName(a.F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDictionaryName(F_Key) KeyName,dbo.GetDeptNames(F_MainDeptId) as DeptName,F_CloseTime,F_LimitTime as LimitTime,F_ComContent";
  187. int recordCount = 0;
  188. dt = BLL.PagerBLL.GetListPager(
  189. "T_Bus_WorkOrder a WITH(NOLOCK)"+ value,
  190. "F_WorkOrderId",
  191. cols,
  192. sql,
  193. "ORDER BY F_CreateTime DESC",
  194. pagesize,
  195. pageindex,
  196. true,
  197. out recordCount);
  198. var obj = new
  199. {
  200. state = "success",
  201. message = "成功",
  202. rows = dt,
  203. total = recordCount
  204. };
  205. return Content(obj.ToJson());
  206. }
  207. /// <summary>
  208. /// 退回工单列表
  209. /// </summary>
  210. /// <returns></returns>
  211. public ActionResult WorkBackOrdrList()
  212. {
  213. DataTable dt = new DataTable();
  214. string sql = " and F_IsDelete=0 ";
  215. int type = RequestString.GetInt("type", 0);
  216. int deptid = RequestString.GetInt("deptid", 0);
  217. string strpageindex = RequestString.GetQueryString("page");
  218. int pageindex = 1;
  219. string strpagesize = RequestString.GetQueryString("pagesize");
  220. int pagesize = 10;
  221. if (strpageindex.Trim() != "")
  222. {
  223. pageindex = Convert.ToInt32(strpageindex);
  224. }
  225. if (strpagesize.Trim() != "")
  226. {
  227. pagesize = Convert.ToInt32(strpagesize);
  228. }
  229. if (deptid>0)
  230. {
  231. sql += "and V.F_CreateDeptId='" + deptid + "'";
  232. }
  233. if (type >0)
  234. {
  235. sql += "and datediff(hh,(select F_CreateTime from T_Bus_AssignedInfo where F_Id = V.F_AssignedId ) ,v.F_CreateTime)> 4";
  236. }
  237. sql += "and datediff(MONTH ,F_CreateTime ,getdate())=0 ";
  238. string value = " INNER JOIN T_Bus_Feedback V on a .F_WorkOrderId =V.F_WorkOrderId and V.F_Type =3";
  239. string cols ="a.F_WorkOrderId,F_ComTitle,F_WorkState,F_MainDeptId,F_IsResult,a.F_CreateTime,dbo.GetUserName(a.F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDictionaryName(F_Key) KeyName,dbo.GetDeptNames(F_MainDeptId) as DeptName,F_CloseTime,F_LimitTime as LimitTime,F_ComContent ,v.F_CreateDeptId";
  240. int recordCount = 0;
  241. dt = BLL.PagerBLL.GetListPager(
  242. "T_Bus_WorkOrder a WITH(NOLOCK)" + value,
  243. "F_WorkOrderId",
  244. cols,
  245. sql,
  246. "ORDER BY F_CreateTime DESC",
  247. pagesize,
  248. pageindex,
  249. true,
  250. out recordCount);
  251. var obj = new
  252. {
  253. state = "success",
  254. message = "成功",
  255. rows = dt,
  256. total = recordCount
  257. };
  258. return Content(obj.ToJson());
  259. }
  260. /// <summary>
  261. /// 知识库
  262. /// </summary>
  263. /// <param name="stime"></param>
  264. /// <param name="etime"></param>
  265. /// <param name="deptid"></param>
  266. /// <param name="type"></param>
  267. /// <returns></returns>
  268. public ActionResult GetListDemands( string stime, string etime, int deptid = 0,int type=0)
  269. {
  270. string sql = " and F_IsDelete=0 ";
  271. DataTable dt = new DataTable();
  272. string strpageindex = RequestString.GetQueryString("page");
  273. int pageindex = 1;
  274. string strpagesize = RequestString.GetQueryString("pagesize");
  275. int pagesize = 10;
  276. if (deptid > 0)
  277. sql += " and F_Deptid='" + deptid + "'";
  278. else
  279. return Error("请选择部门");
  280. sql += "and datediff(MONTH ,F_CreateTime ,getdate())=0 ";
  281. if (type>0)
  282. {
  283. sql += "and isnull(F_SubmitTime , getdate()) >F_LimitTime ";
  284. }
  285. if (strpageindex.Trim() != "")
  286. pageindex = Convert.ToInt32(strpageindex);
  287. if (strpagesize.Trim() != "")
  288. pagesize = Convert.ToInt32(strpagesize);
  289. int recordCount = 0;
  290. dt = BLL.PagerBLL.GetListPager(
  291. "T_Repository_List_Demands",
  292. "F_DemandsId",
  293. "*,dbo.GetDeptName(F_Deptid) F_DeptName,dbo.GetUserName(F_CreateUser) as F_CreateUserName,dbo.GetUserName(F_SubmitUser) as F_SubmitUserName",
  294. sql,
  295. "ORDER BY F_CreateTime desc",
  296. pagesize,
  297. pageindex,
  298. true,
  299. out recordCount);
  300. var obj = new
  301. {
  302. state = "success",
  303. message = "成功",
  304. rows = dt,
  305. total = recordCount
  306. };
  307. return Content(obj.ToJson());
  308. }
  309. #region 工单类型
  310. /// <summary>
  311. /// 获取当日24小时类型受理量
  312. /// </summary>
  313. /// <returns></returns>
  314. public ActionResult GetTypeCount24ByNow()
  315. {
  316. var date = DateTime.Now;
  317. string where = $" and F_IsDelete=0 and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00'";
  318. var hr = date.Hour + 1;
  319. int[] hours = Enumerable.Range(0, hr).ToArray<int>();
  320. var typeList = new BLL.T_Sys_DictionaryValue().GetModelList(" F_PrentId=37 and F_State=0", " F_ValueId ");
  321. var obj = new
  322. {
  323. hours,
  324. cols = typeList.Select(p => p.F_Value).ToList(),
  325. colsid= typeList.Select(p => p.F_ValueId ).ToList(),
  326. counts = new List<int[]>(),
  327. };
  328. string sqltype = " select datepart(hh, F_CreateTime) hour, count(1) count,F_InfoType type from dbo.T_Bus_WorkOrder where 1=1 " + where + " group by datepart(hh, F_CreateTime),F_InfoType order by datepart(hh, F_CreateTime)";
  329. DataTable dttype = DbHelperSQL.Query(sqltype).Tables[0];
  330. foreach (var type in typeList)
  331. {
  332. int[] ah = new int[hours.Length];
  333. for (int i = 0; i < hours.Length; i++)
  334. {
  335. var drs = dttype.Select("type='" + type.F_ValueId + "' and hour='" + hours[i] + "'");
  336. int hc = 0;
  337. if (drs.Length > 0)
  338. hc = (from DataRow dr in drs select dr.Field<int>("count")).FirstOrDefault();
  339. ah[i] = hc;
  340. }
  341. obj.counts.Add(ah);
  342. }
  343. obj.cols.Insert(0, "总数");
  344. obj. colsid.Insert(0, 0);
  345. string sql = "select datepart(hh, F_CreateTime) hour, count(1) count from dbo.T_Bus_WorkOrder where 1=1 " + where + " group by datepart(hh, F_CreateTime) order by datepart(hh, F_CreateTime)";
  346. var dt = DbHelperSQL.Query(sql).Tables[0];
  347. int[] th = new int[hours.Length];
  348. for (int i = 0; i < hours.Length; i++)
  349. {
  350. var drs = dt.Select("hour='" + hours[i] + "'");
  351. int hc = 0;
  352. if (drs.Length > 0)
  353. hc = (from DataRow dr in drs select dr.Field<int>("count")).FirstOrDefault();
  354. th[i] = hc;
  355. }
  356. obj.counts.Insert(0, th);
  357. return Success("加载成功", obj);
  358. }
  359. /// <summary>
  360. /// 获取当日受理量
  361. /// </summary>
  362. /// <returns></returns>
  363. public ActionResult GetAcceptanceCountByNow()
  364. {
  365. var date = DateTime.Now;
  366. string where = $" and F_IsDelete=0 and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00'";
  367. string sql = $" and BeginTime>='{date.ToString("yyyy-MM-dd")} 00:00:00' and CallType = 0 ";
  368. string sqlhw = " select SUM(case CallType when 0 then 1 else 0 end) hrcount ,SUM(case CallType when 0 then(case CallState when 1then 1 else 0 end ) else 0 end) jtcount, SUM(case CallType when 1 then 1 else 0 end) hccount from T_Call_CallRecords where 1=1 "+sql;
  369. DataTable dthw = DbHelperSQL.Query(sqlhw).Tables[0];
  370. string sqltype = " select COUNT(1) lrcount,SUM(case F_WorkState when 6 then 1 when 9 then 1 else 0 end ) blcount ,SUM(case F_WorkState when 9 then 1 else 0 end) wjcount from dbo.T_Bus_WorkOrder where 1=1"+where ;
  371. DataTable dttype = DbHelperSQL.Query(sqltype).Tables[0];
  372. var obj = new
  373. {
  374. hw= dthw,
  375. gd= dttype
  376. };
  377. return Success("加载成功", obj);
  378. }
  379. /// <summary>
  380. /// 获取当日24小时受理量
  381. /// </summary>
  382. /// <returns></returns>
  383. public ActionResult GetAcceptanceCount24ByNow()
  384. {
  385. var date = DateTime.Now;
  386. string where = $" and F_IsDelete=0 and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00'";
  387. var hr = date.Hour + 1;
  388. int[] hours = Enumerable.Range(0, hr).ToArray<int>();
  389. var obj = new
  390. {
  391. hours,
  392. hrcount = new List<int[]>(),
  393. jtcount = new List<int[]>(),
  394. count = new List<int[]>(),
  395. counts = new List<int[]>(),
  396. };
  397. string sql = $" and BeginTime>='{date.ToString("yyyy-MM-dd")} 00:00:00' and CallType = 0 ";
  398. string sqlhw = " select datepart(hh, BeginTime ) hour, count(1) count,sum(case CallState when 1 then 1 else 0 end ) as jtcount from dbo.T_Call_CallRecords where 1=1 "+ sql + " group by datepart(hh, BeginTime) order by datepart(hh, BeginTime)";
  399. DataTable dthw = DbHelperSQL.Query(sqlhw).Tables[0];
  400. int[] hwc = new int[hours.Length]; int[] jcc = new int[hours.Length];
  401. for (int i = 0; i < hours.Length; i++)
  402. {
  403. var drs = dthw.Select("hour='" + hours[i] + "'");
  404. int hw = 0; int jc = 0;
  405. if (drs.Length > 0)
  406. {
  407. hw = (from DataRow dr in drs select dr.Field<int>("count")).FirstOrDefault();
  408. jc = (from DataRow dr in drs select dr.Field<int>("jtcount")).FirstOrDefault();
  409. }
  410. hwc[i] = hw;
  411. jcc[i] = jc;
  412. }
  413. obj.hrcount.Add(hwc);
  414. obj.jtcount .Add(jcc);
  415. string sqltype = " select datepart(hh, F_CreateTime) hour, count(1) count,sum(F_IsResult) as resultcount from dbo.T_Bus_WorkOrder where 1=1 "+where +" group by datepart(hh, F_CreateTime) order by datepart(hh, F_CreateTime)";
  416. DataTable dttype = DbHelperSQL.Query(sqltype).Tables[0];
  417. int[] ah = new int[hours.Length]; int[] rh = new int[hours.Length];
  418. for (int i = 0; i < hours.Length; i++)
  419. {
  420. var drs = dttype.Select("hour='" + hours[i] + "'");
  421. int hc = 0;int rc = 0;
  422. if (drs.Length > 0)
  423. {
  424. hc = (from DataRow dr in drs select dr.Field<int>("count")).FirstOrDefault();
  425. rc = (from DataRow dr in drs select dr.Field<int>("resultcount")).FirstOrDefault();
  426. }
  427. ah[i] = hc;
  428. rh[i] = rc;
  429. }
  430. obj.count.Add(ah);
  431. obj.counts.Add(rh);
  432. return Success("加载成功", obj);
  433. }
  434. /// <summary>
  435. /// 获取当日类型受理量
  436. /// </summary>
  437. /// <returns></returns>
  438. public ActionResult GetTypeCountByNow()
  439. {
  440. var date = DateTime.Now;
  441. string sql = $" select F_Value TypeName,(select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 and F_InfoType=F_ValueId and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00') Count from dbo.T_Sys_DictionaryValue where F_PrentId=37 and F_State=0 ";
  442. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  443. DataRow dr = dt.NewRow();
  444. dr["TypeName"] = "总数";
  445. string tsql = $"select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00'";
  446. dr["Count"] = Int32.Parse( DbHelperSQL.GetSingle(tsql).ToString());
  447. return Success("加载成功", dt);
  448. }
  449. #endregion
  450. #region 问题分类
  451. public class KeyCount
  452. {
  453. public int ValueCount { set; get; }
  454. public int ValueId { set; get; }
  455. }
  456. /// <summary>
  457. /// 获取当日问题分类受理量
  458. /// </summary>
  459. /// <returns></returns>
  460. public ActionResult GetKeyCountByNow(int pid = 38 )
  461. {
  462. var date = DateTime.Now;
  463. string sql = $" select F_Key keyid,count(1) count from dbo.T_Bus_WorkOrder where F_IsDelete=0 and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00' group by F_Key ";
  464. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  465. var keyAllList = new BLL.T_Sys_DictionaryValue().GetModelList(" F_State=0 ");
  466. var keylist = keyAllList.Where(p => p.F_PrentId == pid).ToList();
  467. int total = 0;
  468. List<KeyCount> jo = new List<KeyCount>();
  469. if (RedisHelper.StringGet("InfoNewKeyCountValueId" + pid) != null)
  470. {
  471. Task.Run(() =>
  472. {
  473. string obsql = $" select (select COUNT(1) from [GetValueId](p .F_ValueId )) as ValueCount ,p.F_ValueId ValueId from T_Sys_DictionaryValue p where F_PrentId = '" + pid + "' and F_State = 0 ";
  474. DataTable ob = DbHelperSQL.Query(obsql).Tables[0];
  475. RedisHelper.KeyDelete("InfoNewKeyCountValueId" + pid);
  476. RedisHelper.StringSet("InfoNewKeyCountValueId" + pid, ob.ToJson(), new TimeSpan(24, 0, 0));
  477. });
  478. ;
  479. jo = JsonConvert.DeserializeObject<List<KeyCount>>(RedisHelper.StringGet("InfoNewKeyCountValueId" + pid).ToString());
  480. }
  481. else
  482. {
  483. string obsql = $" select (select COUNT(1) from [GetValueId](p .F_ValueId )) as ValueCount ,p.F_ValueId ValueId from T_Sys_DictionaryValue p where F_PrentId = '" + pid + "' and F_State = 0 ";
  484. DataTable ob = DbHelperSQL.Query(obsql).Tables[0];
  485. RedisHelper.StringSet("InfoNewKeyCountValueId" + pid, ob.ToJson(), new TimeSpan(24, 0, 0));
  486. jo = JsonConvert.DeserializeObject<List<KeyCount>>(ob.ToJson());
  487. }
  488. int TotalClass = 1;
  489. var list = keylist.Select(p =>
  490. {
  491. var ids = getChildren(keyAllList, p.F_ValueId);
  492. ids.Insert(0, p.F_ValueId);
  493. int sum = dt.Select(" keyid in (" + string.Join(",", ids) + ") ").Sum(x => x.Field<int>("count"));
  494. int classcount = jo.Where(x => x.ValueId == p.F_ValueId).First().ValueCount;
  495. total += sum;
  496. TotalClass += classcount;
  497. return new
  498. {
  499. KeyId = p.F_ValueId,
  500. KeyName = p.F_Value,
  501. Count = sum,
  502. ClassCount= classcount
  503. };
  504. }).ToList();
  505. var listrate = list.Select(p => new
  506. {
  507. p.KeyId,
  508. p.KeyName,
  509. p.Count,
  510. Rate = string.Format("{0}%", Math.Round(p.Count * 100.00 / total, 2)),
  511. p .ClassCount
  512. });
  513. var obj = new
  514. {
  515. Date = listrate.OrderByDescending(p => p.Count),
  516. ClaseeCount = listrate.Count(),
  517. Total = total,
  518. ClassTotal= TotalClass
  519. };
  520. return Success("加载成功", obj);
  521. }
  522. /// <summary>
  523. /// 获取区域受理量
  524. /// </summary>
  525. /// <param name="date"></param>
  526. /// <param name="isdc"></param>
  527. /// <returns></returns>
  528. public ActionResult GetAreaCount()
  529. {
  530. if (RedisHelper.StringGet("InfoNewGetAreaCount") != null)
  531. {
  532. Task.Run(() =>
  533. {
  534. Dictionary<string, string> paras = new Dictionary<string, string>();
  535. var ob = DbHelperSQL.RunProcedure("P_Areacontrast", paras, "Areacontrast").Tables[0];
  536. RedisHelper.KeyDelete("InfoNewGetAreaCount");
  537. RedisHelper.StringSet("InfoNewGetAreaCount", ob.ToJson(), new TimeSpan(0, 5, 0));
  538. });
  539. return Content(RedisHelper.StringGet("InfoNewGetAreaCount").ToString());
  540. }
  541. else
  542. {
  543. Dictionary<string, string> paras = new Dictionary<string, string>();
  544. var obj = DbHelperSQL.RunProcedure("P_Areacontrast", paras, "Areacontrast").Tables[0];
  545. RedisHelper.StringSet("InfoNewGetAreaCount", obj.ToJson(), new TimeSpan(0, 5, 0));
  546. return Content(obj.ToJson());
  547. }
  548. }
  549. /// <summary>
  550. /// 获取当日问题分类受理量
  551. /// </summary>
  552. /// <returns></returns>
  553. public ActionResult GetMapByNow(int type=0,string areaid = "")
  554. {
  555. if (RedisHelper.StringGet("InfoNewMapByNow" + type+ areaid) != null)
  556. {
  557. Task.Run(() =>
  558. {
  559. Dictionary<string, string> paras = new Dictionary<string, string>();
  560. var ob = DbHelperSQL.RunProcedure("P_MapByNow", paras, "MapByNow").Tables[0];
  561. paras.Add("@type", type.ToString());
  562. RedisHelper.KeyDelete("InfoNewMapByNow" + type + areaid);
  563. RedisHelper.StringSet("InfoNewMapByNow" + type + areaid, ob.ToJson(), new TimeSpan(0, 5, 0));
  564. });
  565. return Content(RedisHelper.StringGet("InfoNewMapByNow" + type + areaid).ToString());
  566. }
  567. else
  568. {
  569. Dictionary<string, string> paras = new Dictionary<string, string>();
  570. var obj = DbHelperSQL.RunProcedure("P_MapByNow", paras, "MapByNow").Tables[0];
  571. RedisHelper.StringSet("InfoNewMapByNow" + type + areaid, obj.ToJson(), new TimeSpan(0, 5, 0));
  572. return Content(obj.ToJson());
  573. }
  574. }
  575. /// <summary>
  576. /// 获取办理情况三级
  577. /// </summary>
  578. /// <param name="date"></param>
  579. /// <param name="isdc"></param>
  580. /// <returns></returns>
  581. public ActionResult GetHandleCount( int type=0)
  582. {
  583. if (RedisHelper.StringGet("InfoNewHandleCount"+ type) != null)
  584. {
  585. Task.Run(() =>
  586. {
  587. Dictionary<string, string> paras = new Dictionary<string, string>();
  588. var ob = DbHelperSQL.RunProcedure("P_Handle", paras, "Handle").Tables[0];
  589. paras.Add("@type", type.ToString());
  590. RedisHelper.KeyDelete("InfoNewHandleCount"+ type);
  591. RedisHelper.StringSet("InfoNewHandleCount"+ type, ob.ToJson(), new TimeSpan(0, 5, 0));
  592. });
  593. return Content(RedisHelper.StringGet("InfoNewHandleCount"+ type).ToString());
  594. }
  595. else
  596. {
  597. Dictionary<string, string> paras = new Dictionary<string, string>();
  598. var obj = DbHelperSQL.RunProcedure("P_Handle", paras, "Handle").Tables[0];
  599. RedisHelper.StringSet("InfoNewHandleCount"+ type, obj.ToJson(), new TimeSpan(0, 5, 0));
  600. return Content(obj.ToJson());
  601. }
  602. }
  603. /// <summary>
  604. /// 获取平均办理时长
  605. /// </summary>
  606. /// <param name="date"></param>
  607. /// <param name="isdc"></param>
  608. /// <returns></returns>
  609. public ActionResult GetDeptDayTime()
  610. {
  611. if (RedisHelper.StringGet("InfoNewGetDeptDayTime") != null)
  612. {
  613. Task.Run(() =>
  614. {
  615. Dictionary<string, string> paras = new Dictionary<string, string>();
  616. var ob = DbHelperSQL.RunProcedure("P_DeptDayTime", paras, "DeptDayTime").Tables[0]; ;
  617. RedisHelper.KeyDelete("InfoNewGetDeptDayTime");
  618. RedisHelper.StringSet("InfoNewGetDeptDayTime", ob.ToJson(), new TimeSpan(0, 5, 0));
  619. });
  620. return Content(RedisHelper.StringGet("InfoNewGetDeptDayTime").ToString());
  621. }
  622. else
  623. {
  624. Dictionary<string, string> paras = new Dictionary<string, string>();
  625. var obj = DbHelperSQL.RunProcedure("P_DeptDayTime", paras, "DeptDayTime").Tables[0]; ;
  626. RedisHelper.StringSet("InfoNewGetDeptDayTime", obj.ToJson(), new TimeSpan(0, 5, 0));
  627. return Content(obj.ToJson());
  628. }
  629. }
  630. /// <summary>
  631. /// 获取平台办理情况分类
  632. /// </summary>
  633. /// <returns></returns>
  634. public ActionResult GetHandling()
  635. {
  636. if (RedisHelper.StringGet("InfoNewHandling") != null)
  637. {
  638. Task.Run(() =>
  639. {
  640. Dictionary<string, string> paras = new Dictionary<string, string>();
  641. var ob = DbHelperSQL.RunProcedure("P_Handling", paras, "Handling").Tables[0]; ;
  642. RedisHelper.KeyDelete("InfoNewHandling");
  643. RedisHelper.StringSet("InfoNewHandling", ob.ToJson(), new TimeSpan(0, 5, 0));
  644. });
  645. return Content(RedisHelper.StringGet("InfoNewHandling").ToString());
  646. }
  647. else
  648. {
  649. Dictionary<string, string> paras = new Dictionary<string, string>();
  650. var obj = DbHelperSQL.RunProcedure("P_Handling", paras, "Handling").Tables[0]; ;
  651. RedisHelper.StringSet("InfoNewHandling", obj.ToJson(), new TimeSpan(0, 5, 0));
  652. return Content(obj.ToJson());
  653. }
  654. }
  655. /// <summary>
  656. /// 获取绩效
  657. /// </summary>
  658. /// <param name="date"></param>
  659. /// <param name="isdc"></param>
  660. /// <returns></returns>
  661. public ActionResult GetDeptDeptAchievements()
  662. {
  663. if (RedisHelper.StringGet("InfoNewGetDeptAchievements") != null)
  664. {
  665. Task.Run(() =>
  666. {
  667. Dictionary<string, string> paras = new Dictionary<string, string>();
  668. var ob = DbHelperSQL.RunProcedure("P_DeptAchievements", paras, "DeptAchievements").Tables[0]; ;
  669. RedisHelper.KeyDelete("InfoNewGetDeptAchievements");
  670. RedisHelper.StringSet("InfoNewGetDeptAchievements", ob.ToJson(), new TimeSpan(0, 5, 0));
  671. });
  672. return Content(RedisHelper.StringGet("InfoNewGetDeptAchievements").ToString());
  673. }
  674. else
  675. {
  676. Dictionary<string, string> paras = new Dictionary<string, string>();
  677. var obj = DbHelperSQL.RunProcedure("P_DeptAchievements", paras, "DeptAchievements").Tables[0]; ;
  678. RedisHelper.StringSet("InfoNewGetDeptAchievements", obj.ToJson(), new TimeSpan(0, 5, 0));
  679. return Content(obj.ToJson());
  680. }
  681. }
  682. /// <summary>
  683. /// 平台受理情况概况
  684. /// </summary>
  685. /// <returns></returns>
  686. public ActionResult GetAreaAcceptance()
  687. {
  688. if (RedisHelper.StringGet("InfoNewGetAcceptance") != null)
  689. {
  690. Task.Run(() =>
  691. {
  692. Dictionary<string, string> paras = new Dictionary<string, string>();
  693. var ob = DbHelperSQL.RunProcedure("P_Acceptance", paras, "Acceptance").Tables[0]; ;
  694. RedisHelper.KeyDelete("InfoNewGetAcceptance");
  695. RedisHelper.StringSet("InfoNewGetAcceptance", ob.ToJson(), new TimeSpan(0, 5, 0));
  696. });
  697. return Content(RedisHelper.StringGet("InfoNewGetAcceptance").ToString());
  698. }
  699. else
  700. {
  701. Dictionary<string, string> paras = new Dictionary<string, string>();
  702. var obj = DbHelperSQL.RunProcedure("P_Acceptance", paras, "Acceptance").Tables[0]; ;
  703. RedisHelper.StringSet("InfoNewGetAcceptance", obj.ToJson(), new TimeSpan(0, 5, 0));
  704. return Content(obj.ToJson());
  705. }
  706. }
  707. /// <summary>
  708. /// 获取当月区域坐标
  709. /// </summary>
  710. /// <returns></returns>
  711. public ActionResult GetCoordinate(string areaid)
  712. {
  713. string sqlarea = "select F_Latitude,F_Longitude from t_bus_workorder where datediff(MONTH , F_CreateTime , getdate())= 0 and F_IsDelete = 0 and F_Latitude is not null and F_Longitude is not null and F_SourceArea = '"+ areaid + "' GROUP BY F_Latitude,F_Longitude";
  714. DataTable dttype = DbHelperSQL.Query(sqlarea).Tables[0];
  715. var obj = new
  716. {
  717. Coordinate= dttype
  718. };
  719. return Success("获取成功", obj);
  720. }
  721. /// <summary>
  722. /// 获取父级下的所有子级id
  723. /// </summary>
  724. /// <param name="list"></param>
  725. /// <param name="pid"></param>
  726. /// <returns></returns>
  727. private List<int> getChildren(List<Model.T_Sys_DictionaryValue> list, int pid)
  728. {
  729. List<int> ids = new List<int>();
  730. var clist = list.Where(p => p.F_PrentId == pid).ToList();
  731. foreach (var d in clist)
  732. {
  733. ids.Add(d.F_ValueId);
  734. ids = ids.Union(getChildren(list, d.F_ValueId)).ToList();
  735. }
  736. return ids;
  737. }
  738. #endregion
  739. #region 受理渠道
  740. /// <summary>
  741. /// 获取当日渠道受理量
  742. /// </summary>
  743. /// <returns></returns>
  744. public ActionResult GetSourceCountByNow()
  745. {
  746. var date = DateTime.Now;
  747. string sql = $" select F_Value TypeName,F_ValueId ValueId,(select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 and F_InfoSource=F_ValueId and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00') Count from dbo.T_Sys_DictionaryValue where F_PrentId=36 and F_State=0 ";
  748. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  749. //DataRow dr = dt.NewRow();
  750. //dr["TypeName"] = "总数";
  751. //string tsql = $"select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00'";
  752. //dr["Count"] = Int32.Parse(DbHelperSQL.GetSingle(tsql).ToString());
  753. return Success("加载成功", dt);
  754. }
  755. #endregion
  756. #region 办理情况
  757. /// <summary>
  758. /// 获取当日办理类型受理量
  759. /// </summary>
  760. /// <returns></returns>
  761. public ActionResult GetDealTypeCountByNow()
  762. {
  763. var date = DateTime.Now;
  764. DataTable dt = new DataTable();
  765. dt.Columns.Add("DealType");
  766. dt.Columns.Add("Count");
  767. DataRow dr = dt.NewRow();
  768. dr["DealType"] = "当即办理";
  769. string tsql = $"select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 and isnull(F_IsResult,0)=1 and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00'";
  770. dr["Count"] = DbHelperSQL.GetSingle(tsql).ToString();
  771. DataRow dr1 = dt.NewRow();
  772. dr["DealType"] = "网络转办";
  773. string tsql1 = $"select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 and isnull(F_IsResult,0)=0 and F_CreateTime>='{date.ToString("yyyy-MM-dd")} 00:00:00'";
  774. dr["Count"] = DbHelperSQL.GetSingle(tsql1).ToString();
  775. return Success("加载成功", dt);
  776. }
  777. #endregion
  778. #region 工单相关
  779. /// <summary>
  780. /// 工单列表
  781. /// </summary>
  782. /// <returns></returns>
  783. public ActionResult GetList()
  784. {
  785. DataTable dt = new DataTable();
  786. string sql = " and F_IsDelete=0 ";
  787. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  788. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  789. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  790. int source = RequestString.GetInt("source", 0);
  791. int keyid = RequestString.GetInt("keyid", 0);
  792. int type = RequestString.GetInt("type", 0);
  793. int sourcearea = RequestString.GetInt("sourcearea", 0);
  794. int deptid = RequestString.GetInt("deptid", 0);
  795. int dealtype = RequestString.GetInt("dealtype", -1);
  796. string strpageindex = RequestString.GetQueryString("page");
  797. int pageindex = 1;
  798. string strpagesize = RequestString.GetQueryString("pagesize");
  799. int pagesize = 10;
  800. string dealstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("dealstarttime"));
  801. string dealstrendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("dealstrendtime"));
  802. if (dealstarttime.Trim() != "" && dealstarttime != "undefined")
  803. {
  804. if (dealstrendtime.Trim() != "" && dealstrendtime != "undefined")
  805. {
  806. sql += " and F_DealTime between '" + dealstarttime +
  807. "' AND '" + dealstrendtime + "'";
  808. }
  809. else
  810. {
  811. sql += " and F_DealTime>='" + dealstarttime + "' ";
  812. }
  813. }
  814. else
  815. {
  816. if (dealstrendtime.Trim() != "" && dealstrendtime != "undefined")
  817. {
  818. sql += " and F_DealTime<='" + dealstrendtime + "' ";
  819. }
  820. }
  821. if (strstate.Trim() != "" && strstate != "undefined")
  822. {
  823. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  824. }
  825. if (source != 0)
  826. {
  827. sql += " and F_InfoSource = '" + source + "' ";
  828. }
  829. if (keyid != 0)
  830. {
  831. sql += " and F_Key = '" + keyid + "' ";
  832. }
  833. if (type != 0)
  834. {
  835. sql += " and F_InfoType = '" + type + "' ";
  836. }
  837. if (sourcearea != 0)
  838. {
  839. sql += " and F_SourceArea = '" + sourcearea + "' ";
  840. }
  841. if (deptid != 0)
  842. {
  843. sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
  844. }
  845. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  846. {
  847. if (strendtime.Trim() != "" && strendtime != "undefined")
  848. {
  849. sql += " and F_CreateTime between '" + strstarttime +
  850. "' AND '" + strendtime + "'";
  851. }
  852. else
  853. {
  854. sql += " and F_CreateTime>='" + strstarttime + "' ";
  855. }
  856. }
  857. else
  858. {
  859. if (strendtime.Trim() != "" && strendtime != "undefined")
  860. {
  861. sql += " and F_CreateTime<='" + strendtime + "' ";
  862. }
  863. }
  864. if (dealtype != -1)
  865. {
  866. sql += " and isnull(F_IsResult,0) = '" + dealtype + "' ";
  867. }
  868. if (strpageindex.Trim() != "")
  869. {
  870. pageindex = Convert.ToInt32(strpageindex);
  871. }
  872. if (strpagesize.Trim() != "")
  873. {
  874. pagesize = Convert.ToInt32(strpagesize);
  875. }
  876. string cols = "F_Result,F_WorkOrderId,F_WorkState,F_DealTime,F_IsResult,F_CreateTime,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDeptNames(F_MainDeptId) as DeptName,F_CloseTime,F_AssignTime as AssignTime,F_LimitTime as LimitTime,F_ComContent ";
  877. int recordCount = 0;
  878. dt = BLL.PagerBLL.GetListPager(
  879. "T_Bus_WorkOrder WITH(NOLOCK)",
  880. "F_WorkOrderId",
  881. cols,
  882. sql,
  883. "ORDER BY F_CreateTime DESC",
  884. pagesize,
  885. pageindex,
  886. true,
  887. out recordCount);
  888. var obj = new
  889. {
  890. state = "success",
  891. message = "成功",
  892. rows = dt,
  893. total = recordCount
  894. };
  895. return Content(obj.ToJson());
  896. }
  897. /// <summary>
  898. /// 工单详情
  899. /// </summary>
  900. /// <returns></returns>
  901. public ActionResult GetWorkOrder()
  902. {
  903. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  904. if (!string.IsNullOrEmpty(strworkorderid))
  905. {
  906. string sql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName1,dbo.GetAreaName(F_SourceArea) as AreaName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetDictionaryName(F_Key) as KeyName,dbo.GetDeptName(F_MainDeptId) deptname from T_Bus_WorkOrder a WITH(NOLOCK) where F_WorkOrderId ='" + strworkorderid + "'";
  907. var dt = DbHelperSQL.Query(sql).Tables[0];
  908. if (dt.Rows.Count > 0)
  909. {
  910. if (dt.Rows[0]["F_IsProtect"] != null)
  911. {
  912. if (dt.Rows[0]["F_IsProtect"].ToString() == "1")
  913. {
  914. dt.Rows[0]["F_CusName"] = "";
  915. dt.Rows[0]["F_CusPhone"] = "";
  916. dt.Rows[0]["F_ConPhone"] = "";
  917. }
  918. }
  919. return Success("获取成功", dt);
  920. }
  921. else
  922. {
  923. return Error("获取失败");
  924. }
  925. }
  926. else
  927. {
  928. return Error("参数传输失败");
  929. }
  930. }
  931. /// <summary>
  932. /// 工单流转
  933. /// </summary>
  934. /// <returns></returns>
  935. public ActionResult GetWorkOrderProcess()
  936. {
  937. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  938. if (!string.IsNullOrEmpty(strworkorderid))
  939. {
  940. string gcsql = "select F_Message,F_CreateTime from T_Bus_Operation where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime ";
  941. var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  942. return Success("获取成功", gcdt);
  943. }
  944. else
  945. {
  946. return Error("参数传输失败");
  947. }
  948. }
  949. //获取通话记录列表
  950. public ActionResult GetCallList()
  951. {
  952. string sql = "";
  953. DataTable dt = new DataTable();
  954. string callstate = HttpUtility.UrlDecode(RequestString.GetQueryString("callstate"));
  955. string calltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
  956. string actiontype = HttpUtility.UrlDecode(RequestString.GetQueryString("actiontype"));
  957. string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  958. string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  959. string tasktype = HttpUtility.UrlDecode(RequestString.GetQueryString("tasktype"));
  960. string extnumber = HttpUtility.UrlDecode(RequestString.GetQueryString("extnumber"));
  961. string PhoneType = HttpUtility.UrlDecode(RequestString.GetQueryString("phoneType"));
  962. int type = RequestString.GetInt("type", 0);
  963. int islike = RequestString.GetInt("islike", 1);
  964. string strpageindex = RequestString.GetQueryString("page");
  965. int pageindex = 1;
  966. string strpagesize = RequestString.GetQueryString("pagesize");
  967. int pagesize = 10;
  968. int hour = RequestString.GetInt("hour", -1);
  969. if (hour > -1)
  970. {
  971. int hours = hour + 1;
  972. if (hour < 23)
  973. sql += " and datepart(hh,BeginTime)>=" + hour + " AND datepart(hh,BeginTime)<" + hours;
  974. else
  975. sql += " and datepart(hh,BeginTime)>=" + hour;
  976. }
  977. if (type != 0)
  978. {
  979. sql += " and F_CallInType = '" + type + "' ";
  980. }
  981. if (PhoneType != null && PhoneType.Trim() != "")
  982. {
  983. sql += " and PhoneType='" + PhoneType + "'";
  984. }
  985. if (callstate.Trim() != "")
  986. {
  987. if (callstate.Trim() == "0")
  988. {
  989. sql += " and CallState=0 and isnull(UserCode,'')!='' ";
  990. }
  991. else if (callstate.Trim() == "3")
  992. {
  993. sql += " and CallState=0 and CallType=0 and isnull(UserCode,'')='' ";
  994. }
  995. else
  996. {
  997. sql += " and CallState='" + callstate + "'";
  998. }
  999. }
  1000. if (calltype.Trim() != "")
  1001. {
  1002. if (calltype == "3")
  1003. {
  1004. sql += " and CallType='1'";
  1005. sql += " and CallRecordsId in(select F_CallRecordId from T_Bus_VisitResult WITH(NOLOCK) where F_CallRecordId !='' and F_CallRecordId is not null )";
  1006. }
  1007. else
  1008. sql += " and CallType='" + calltype + "'";
  1009. }
  1010. if (tasktype.Trim() != "")
  1011. {
  1012. if (tasktype.Trim() == "2")
  1013. {
  1014. sql += " and TaskType='" + tasktype + "'";
  1015. }
  1016. else if (tasktype.Trim() == "0")
  1017. {
  1018. sql += " and (TaskType is null or TaskType!='2')";
  1019. }
  1020. }
  1021. if (actiontype.Trim() != "")
  1022. {
  1023. sql += " and ActionType=" + actiontype.Trim();
  1024. }
  1025. if (starttime.Trim() != "")
  1026. {
  1027. sql += " and BeginTime>='" + starttime + "' ";
  1028. }
  1029. else
  1030. {
  1031. DateTime date = DateTime.Now;
  1032. sql += $" and BeginTime>='{date.ToString("yyyy-MM-dd")} 00:00:00'";
  1033. }
  1034. if (endtime.Trim() != "")
  1035. {
  1036. sql += " and BeginTime<='" + endtime + "' ";
  1037. }
  1038. if (extnumber.Trim() != "")
  1039. {
  1040. sql += " and isnull(ExtNumber,'')='" + extnumber.Trim() + "'";
  1041. }
  1042. if (strpageindex.Trim() != "")
  1043. {
  1044. pageindex = Convert.ToInt32(strpageindex);
  1045. }
  1046. if (strpagesize.Trim() != "")
  1047. {
  1048. pagesize = Convert.ToInt32(strpagesize);
  1049. }
  1050. int recordCount = 0;
  1051. dt = BLL.PagerBLL.GetListPager(
  1052. "T_Call_CallRecords WITH(NOLOCK)",
  1053. "CallRecordsId",
  1054. "*,dbo.GetUserName(UserCode) as UserName, WorkOrderId,dbo.GetDictionaryName(F_CallInType) as TypeName",
  1055. sql,
  1056. "ORDER BY CallRecordsId desc",
  1057. pagesize,
  1058. pageindex,
  1059. true,
  1060. out recordCount);
  1061. var obj = new
  1062. {
  1063. state = "success",
  1064. message = "成功",
  1065. rows = dt,
  1066. total = recordCount
  1067. };
  1068. return Content(obj.ToJson());
  1069. }
  1070. #endregion
  1071. }
  1072. }