地铁二期项目正式开始

CallRecordController.cs 75KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817
  1. using CallCenter.Utility;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. using YTSoft.BaseCallCenter.Model;
  13. using YTSoft.BaseCallCenter.MVCWeb.Commons;
  14. using YTSoft.BaseCallCenter.MVCWeb.Models;
  15. using YTSoft.Common;
  16. using YTSoft.DBUtility;
  17. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  18. {
  19. public class CallRecordController : BaseController
  20. {
  21. //工单信息
  22. BLL.T_Wo_WorkOrderBase orderBLL = new BLL.T_Wo_WorkOrderBase();
  23. //客户信息
  24. BLL.T_Cus_CustomerBase cusBLL = new BLL.T_Cus_CustomerBase();
  25. //部门表
  26. BLL.T_Sys_Department deptBll = new BLL.T_Sys_Department();
  27. //用户表
  28. BLL.T_Sys_UserAccount userBll = new BLL.T_Sys_UserAccount();
  29. //通话记录
  30. BLL.T_Call_CallRecords recordBLL = new BLL.T_Call_CallRecords();
  31. #region 来电弹屏信息
  32. /// <summary>
  33. /// 来电弹屏页面
  34. /// </summary>
  35. /// <param name="workOrderNum">工单编号</param>
  36. /// <returns></returns>
  37. public ActionResult CallScreen(string workOrderNum)
  38. {
  39. //workOrderNum = "12";
  40. //实例化基础信息表
  41. CallScreenModel callScreenModel = new CallScreenModel();
  42. //获取业务工单信息
  43. if (!string.IsNullOrEmpty(workOrderNum))
  44. {
  45. callScreenModel.WorkOrderBaseModel = orderBLL.GetModel(int.Parse(workOrderNum.ToString()));
  46. if (callScreenModel.WorkOrderBaseModel==null)
  47. {
  48. callScreenModel.WorkOrderBaseModel = new Model.T_Wo_WorkOrderBase()
  49. {
  50. CustomerBaseModel = new T_Cus_CustomerBase { F_CustomerId = 0 },
  51. F_WORKORDERID = 0
  52. };
  53. }
  54. //如果电话号码不为空
  55. if (callScreenModel.WorkOrderBaseModel != null && !string.IsNullOrEmpty(callScreenModel.WorkOrderBaseModel.F_CUSTOMERTELEPHONE))
  56. {
  57. //获取客户基本信息
  58. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = cusBLL.GetCusInfoModel(callScreenModel.WorkOrderBaseModel.F_CUSTOMERTELEPHONE);
  59. }
  60. if (callScreenModel.WorkOrderBaseModel != null && !string.IsNullOrEmpty(callScreenModel.WorkOrderBaseModel.F_KSHADDRESSCODE))
  61. {
  62. Model.T_Call_CallRecords callRecordModel = recordBLL.GetModelByCallId(callScreenModel.WorkOrderBaseModel.F_KSHADDRESSCODE);
  63. if (callRecordModel != null)
  64. {
  65. if (callRecordModel.BusinessType != null)
  66. {
  67. //业务选择按键
  68. callScreenModel.SelectBussType = int.Parse(callRecordModel.BusinessType.ToString());
  69. }
  70. else
  71. {
  72. callScreenModel.SelectBussType =1;
  73. }
  74. }
  75. }
  76. }
  77. callScreenModel.WorkOrderTypeModelList = GetWorkTypeModelList();//业务类型字典表
  78. //获取处理年龄段字典表
  79. callScreenModel.AgeModelList = GetCodeType("NLD");
  80. return View(callScreenModel);
  81. }
  82. /// <summary>
  83. /// 业务工单录入页面
  84. /// </summary>
  85. /// <param name="workOrderNum">工单编号</param>
  86. /// <param name="flowid">业务类型</param>
  87. /// <returns></returns>
  88. public ActionResult CallWorkFolw(string workOrderNum, int? flowid)
  89. {
  90. //实例化基础信息表
  91. CallScreenModel callScreenModel = new CallScreenModel();
  92. //选择的业务类型
  93. if (flowid != null && flowid > 0)
  94. {
  95. callScreenModel.Flowid = flowid;
  96. }
  97. else
  98. {
  99. callScreenModel.Flowid = 0;
  100. }
  101. //获取业务工单信息
  102. if (!string.IsNullOrEmpty(workOrderNum))
  103. {
  104. callScreenModel.WorkOrderBaseModel = orderBLL.GetModel(int.Parse(workOrderNum.ToString()));
  105. if (callScreenModel.WorkOrderBaseModel == null)
  106. {
  107. callScreenModel.WorkOrderBaseModel = new Model.T_Wo_WorkOrderBase()
  108. {
  109. CustomerBaseModel = new T_Cus_CustomerBase { F_CustomerId = 0 },
  110. F_WORKORDERID = 0
  111. };
  112. }
  113. //如果电话号码不为空
  114. if (callScreenModel.WorkOrderBaseModel != null && !string.IsNullOrEmpty(callScreenModel.WorkOrderBaseModel.F_CUSTOMERTELEPHONE))
  115. {
  116. T_Cus_CustomerBase baseCusModel = cusBLL.GetCusInfoModel(callScreenModel.WorkOrderBaseModel.F_CUSTOMERTELEPHONE);
  117. if (baseCusModel != null && baseCusModel.F_CustomerId > 0)
  118. {
  119. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = baseCusModel;
  120. }
  121. else
  122. {
  123. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  124. callScreenModel.WorkOrderBaseModel.CustomerBaseModel.F_CustomerName = callScreenModel.WorkOrderBaseModel.F_CUSTOMERNAME;
  125. }
  126. //选择的业务类型
  127. if (flowid != null && flowid > 0)
  128. {
  129. callScreenModel.BussnessContnet = GetTypeContenet(int.Parse(flowid.ToString()), callScreenModel.WorkOrderBaseModel.F_CREATEDATE.ToString());
  130. }
  131. }
  132. else
  133. {
  134. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  135. callScreenModel.WorkOrderBaseModel.CustomerBaseModel.F_CustomerName = callScreenModel.WorkOrderBaseModel.F_CUSTOMERNAME;
  136. }
  137. //获取客户基本信息
  138. }
  139. //业务类型字典表
  140. callScreenModel.WorkOrderTypeModelList = GetWorkTypeModelList();
  141. //获取处理方式字典表
  142. callScreenModel.GoTypeModelList = GetCodeType("CLFS");
  143. //获取处理年龄段字典表
  144. callScreenModel.AgeModelList = GetCodeType("NLD");
  145. //获取部门列表
  146. callScreenModel.DepartmentList = deptBll.GetModelList("F_ParentId=0");
  147. callScreenModel.HistoryOrderList = historyBll.GetModelList("F_INSTANCEID=" + workOrderNum.ToInt32());
  148. return View(callScreenModel);
  149. }
  150. //历史工单表
  151. BLL.T_Wo_WorkOrderHistory historyBll = new BLL.T_Wo_WorkOrderHistory();
  152. /// <summary>
  153. /// 业务工单录入页面
  154. /// </summary>
  155. /// <param name="workOrderNum">工单编号</param>
  156. /// <param name="flowid">业务类型</param>
  157. /// <returns></returns>
  158. public ActionResult EditCallWorkFolw(string workOrderNum)
  159. {
  160. //实例化基础信息表
  161. CallScreenModel callScreenModel = new CallScreenModel();
  162. //获取业务工单信息
  163. if (!string.IsNullOrEmpty(workOrderNum))
  164. {
  165. callScreenModel.WorkOrderBaseModel = orderBLL.GetModel(int.Parse(workOrderNum.ToString()));
  166. //如果电话号码不为空
  167. if (callScreenModel.WorkOrderBaseModel != null && !string.IsNullOrEmpty(callScreenModel.WorkOrderBaseModel.F_CUSTOMERTELEPHONE))
  168. {
  169. T_Cus_CustomerBase baseCusModel = cusBLL.GetCusInfoModel(callScreenModel.WorkOrderBaseModel.F_CUSTOMERTELEPHONE);
  170. if (baseCusModel != null && baseCusModel.F_CustomerId > 0)
  171. {
  172. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = baseCusModel;
  173. }
  174. else
  175. {
  176. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  177. callScreenModel.WorkOrderBaseModel.CustomerBaseModel.F_CustomerName = callScreenModel.WorkOrderBaseModel.F_CUSTOMERNAME;
  178. }
  179. }
  180. else
  181. {
  182. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  183. callScreenModel.WorkOrderBaseModel.CustomerBaseModel.F_CustomerName = callScreenModel.WorkOrderBaseModel.F_CUSTOMERNAME;
  184. }
  185. //获取客户基本信息
  186. if (!string.IsNullOrEmpty( callScreenModel.WorkOrderBaseModel.F_EMPCODE))
  187. {
  188. T_Cus_CustomerBase baseCusModel = cusBLL.GetCusInfoModel(1,callScreenModel.WorkOrderBaseModel.F_EMPCODE);
  189. if (baseCusModel != null && baseCusModel.F_CustomerId > 0)
  190. {
  191. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = baseCusModel;
  192. }
  193. else
  194. {
  195. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  196. }
  197. }
  198. }
  199. //业务类型字典表
  200. callScreenModel.WorkOrderTypeModelList = GetWorkTypeModelList();
  201. //获取处理方式字典表
  202. callScreenModel.GoTypeModelList = GetCodeType("CLFS");
  203. //回访满意度
  204. callScreenModel.MYdModelList = GetCodeType("khyjfl");
  205. //获取处理年龄段字典表
  206. callScreenModel.AgeModelList = GetCodeType("NLD");
  207. //获取部门列表
  208. callScreenModel.DepartmentList = deptBll.GetModelList("F_ParentId=0");
  209. return View(callScreenModel);
  210. }
  211. /// <summary>
  212. /// 编辑历史工单
  213. /// </summary>
  214. /// <param name="workOrderBaseModel"></param>
  215. /// <returns></returns>
  216. [AcceptVerbs(HttpVerbs.Post)]
  217. public bool workOrderEditData(T_Wo_WorkOrderBase workOrderBaseModel)
  218. {
  219. //工单来源
  220. //workOrderBaseModel.F_REPAIRMANID = 1;
  221. //workOrderBaseModel.F_WORKORDERFROM = "语音";
  222. string F_UserCode = "";
  223. if (Request.Cookies["BaseCallCenter_T_User"] != null)
  224. {
  225. F_UserCode = Request.Cookies["BaseCallCenter_T_User"]["F_UserCode"];
  226. }
  227. string bu = "";
  228. if (workOrderBaseModel.CustomerBaseModel != null)
  229. {
  230. string linkman= DbHelperSQL.GetSingle("select F_LINKMAN from T_Wo_WorkOrderBase where F_WORKORDERID='"+
  231. workOrderBaseModel.F_WORKORDERID + "'").ToString();
  232. if (linkman.Equals(F_UserCode))
  233. {
  234. //最近联络方式
  235. if (workOrderBaseModel.F_REPAIRMANID.ToString() == "4")
  236. {
  237. workOrderBaseModel.CustomerBaseModel.F_Kind = "3";
  238. workOrderBaseModel.F_CUSTOMERTELEPHONE = workOrderBaseModel.CustomerBaseModel.F_Mobile;
  239. }
  240. else
  241. {
  242. workOrderBaseModel.CustomerBaseModel.F_Kind = workOrderBaseModel.F_REPAIRMANID.ToString();
  243. }
  244. workOrderBaseModel.CustomerBaseModel.F_CustomerNature = workOrderBaseModel.F_WORKORDERFROM;
  245. //业务类型
  246. workOrderBaseModel.CustomerBaseModel.F_IndustryId = workOrderBaseModel.F_REPAIRLEVEL;
  247. workOrderBaseModel.CustomerBaseModel.F_Url = workOrderBaseModel.F_ADSLACCOUNT;
  248. //修改客户基础信息
  249. bu += "F_Kind old is:" + workOrderBaseModel.F_REPAIRMANID.ToString() + " F_Kind new is:" + workOrderBaseModel.CustomerBaseModel.F_Kind;
  250. bu += "F_CustomerNature old is:" + workOrderBaseModel.F_WORKORDERFROM + " F_CustomerNature new is:" + workOrderBaseModel.CustomerBaseModel.F_CustomerNature;
  251. bu += "F_IndustryId old is:" + workOrderBaseModel.F_REPAIRLEVEL + " F_IndustryId new is:" + workOrderBaseModel.CustomerBaseModel.F_IndustryId;
  252. bu += "F_Url old is:" + workOrderBaseModel.F_ADSLACCOUNT + " F_Url new is:" + workOrderBaseModel.CustomerBaseModel.F_Url;
  253. int cusid = cusBLL.EditCusInfoModel(workOrderBaseModel.CustomerBaseModel);
  254. if (cusid > 0)
  255. {
  256. workOrderBaseModel.F_CUSTOMERID = cusid;
  257. }
  258. }
  259. var res= DbHelperSQL.Query("select top 1 * from T_Wo_WorkOrderBase where F_WORKORDERID='" +
  260. workOrderBaseModel.F_WORKORDERID + "'").Tables[0];
  261. for (int i = 0; i < res.Rows.Count; i++)
  262. {
  263. bu += "F_CUSTOMERTELEPHONE old is:" + res.Rows[i]["F_CUSTOMERTELEPHONE"] + " CustomerBaseModel new is:" + workOrderBaseModel.F_CUSTOMERTELEPHONE ;
  264. bu += "F_CUSTOMERID old is:" + res.Rows[i]["F_CUSTOMERID"] + " F_CUSTOMERID new is:" + workOrderBaseModel.F_CUSTOMERID;
  265. }
  266. AddLog("T_Cus_CustomerBase", "T_Cus_CustomerBase", "记录工单操作记录", bu, "操作记录");
  267. return orderBLL.UpdateHistoryWorkOrderInfoModel(workOrderBaseModel);
  268. }
  269. else
  270. {
  271. return false;
  272. }
  273. }
  274. /// <summary>
  275. /// 撤回历史工单
  276. /// </summary>
  277. /// <param name="workOrderBaseModel"></param>
  278. /// <returns></returns>
  279. [AcceptVerbs(HttpVerbs.Get)]
  280. public bool ResetWorkOrder(int workOrderId)
  281. {
  282. string F_UserCode = "";
  283. if (Request.Cookies["BaseCallCenter_T_User"] != null)
  284. {
  285. F_UserCode = Request.Cookies["BaseCallCenter_T_User"]["F_UserCode"];
  286. }
  287. string linkman = DbHelperSQL.GetSingle("select F_LINKMAN from T_Wo_WorkOrderBase where F_WORKORDERID='" +
  288. workOrderId + "'").ToString();
  289. if (linkman.Equals(F_UserCode))
  290. {
  291. bool result = false; ;
  292. string bycode = F_UserCode;
  293. string byname = F_UserName;
  294. int bmid = F_DeptId;
  295. string bmmc = "";
  296. if (F_UserID > 0)
  297. {
  298. YTSoft.BaseCallCenter.BLL.T_Sys_Department depBll = new BLL.T_Sys_Department();
  299. List<Model.T_Sys_Department> list = new List<T_Sys_Department>();
  300. list = depBll.GetModelList("F_DeptId=" + bmid);
  301. if (list.Count > 0)
  302. {
  303. bmmc = list[0].F_DeptName.ToString();
  304. result = orderBLL.ResetWorkOrder(workOrderId, F_UserID, F_UserName, F_DeptId, bmmc);
  305. }
  306. }
  307. return result;
  308. }
  309. else
  310. {
  311. return false;
  312. }
  313. }
  314. /// <summary>
  315. /// 获取业务术语模板信息
  316. /// </summary>
  317. /// <param name="bussnessType">业务类型</param>
  318. /// <returns></returns>
  319. public string GetTypeContenet(int bussnessType, string creatDateTime)
  320. {
  321. try
  322. {
  323. //模板内容
  324. string bussContent = "";
  325. if (bussnessType > 0)
  326. {
  327. if (bussnessType > 0)
  328. {
  329. BLL.T_Wo_WorkOrderType bll = new BLL.T_Wo_WorkOrderType();
  330. Model.T_Wo_WorkOrderType orderTypeModel = new T_Wo_WorkOrderType();
  331. orderTypeModel = bll.GetModel(bussnessType);
  332. if (orderTypeModel != null && !string.IsNullOrEmpty(orderTypeModel.F_Remark))
  333. {
  334. bussContent += string.Format(orderTypeModel.F_Remark, DateTime.Parse(creatDateTime).ToString("f") + "分");
  335. }
  336. }
  337. }
  338. return bussContent;
  339. }
  340. catch (Exception ex)
  341. {
  342. }
  343. return null;
  344. }
  345. /// <summary>
  346. /// 保存用户信息
  347. /// </summary>
  348. /// <param name="workOrderBaseModel"></param>
  349. /// <returns></returns>
  350. [AcceptVerbs(HttpVerbs.Post)]
  351. public bool SaveCunInfo(T_Cus_CustomerBase CustomerBaseModel)
  352. {
  353. //客户属性
  354. if (string.IsNullOrEmpty(CustomerBaseModel.F_Kind))
  355. {
  356. CustomerBaseModel.F_Kind = "1";
  357. }
  358. if (string.IsNullOrEmpty(CustomerBaseModel.F_CustomerNature))
  359. {
  360. CustomerBaseModel.F_CustomerNature = "语音";
  361. }
  362. if (CustomerBaseModel.F_CustomerId > 0)
  363. {
  364. AddAction("t_cus_customerbase", CustomerBaseModel.F_CustomerId.ToMyString(), "更新客户信息", CustomerBaseModel.F_CustomerName.ToMyString());
  365. AddAction("t_cus_customerbase", CustomerBaseModel.F_CustomerId.ToMyString(), "更新客户信息", "数据:" + JsonConvert.SerializeObject(CustomerBaseModel), "关键信息");
  366. }
  367. else
  368. {
  369. YTSoft.BaseCallCenter.Model.T_Cus_CustomerBase modelcus= cusBLL.GetCusInfoModel(CustomerBaseModel.F_Telephone);
  370. if ( modelcus.F_CustomerId>0)
  371. {
  372. }
  373. AddAction("t_cus_customerbase", CustomerBaseModel.F_Telephone, "添加客户信息", CustomerBaseModel.F_CustomerName.ToMyString());
  374. AddAction("t_cus_customerbase", CustomerBaseModel.F_Telephone, "添加客户信息","数据:"+JsonConvert.SerializeObject(CustomerBaseModel), "关键信息");
  375. }
  376. return cusBLL.UpdateCusInfoModel(CustomerBaseModel);
  377. }
  378. /// <summary>
  379. /// 获取员工信息
  380. /// </summary>
  381. /// <param name="deptId">部门id</param>
  382. /// <returns></returns>
  383. public string GetDeptUsers(string deptId)
  384. {
  385. try
  386. {
  387. return JsonConvert.SerializeObject(userBll.GetModelList("F_DeptId=" + deptId));
  388. }
  389. catch (Exception ex)
  390. {
  391. }
  392. return null;
  393. }
  394. #endregion
  395. #region 微博工单
  396. /// <summary>
  397. /// 微信微博工单录入页面
  398. /// </summary>
  399. /// <param name="workOrderNum">工单编号</param>
  400. /// <param name="flowid">业务类型</param>
  401. /// <returns></returns>
  402. public ActionResult WBWorkFlow(string workOrderNum, int? flowid)
  403. {
  404. workOrderNum = "0"; flowid = 0;
  405. //实例化基础信息表
  406. CallScreenModel callScreenModel = new CallScreenModel();
  407. //选择的业务类型
  408. if (flowid != null && flowid > 0)
  409. {
  410. callScreenModel.Flowid = flowid;
  411. }
  412. else
  413. {
  414. callScreenModel.Flowid = 0;
  415. }
  416. //业务类型字典表
  417. callScreenModel.WorkOrderTypeModelList = GetWorkTypeModelList();
  418. //获取处理方式字典表
  419. callScreenModel.GoTypeModelList = GetCodeType("CLFS");
  420. //获取处理年龄段字典表
  421. callScreenModel.AgeModelList = GetCodeType("NLD");
  422. //获取部门列表
  423. callScreenModel.DepartmentList = deptBll.GetModelList("F_ParentId=0");
  424. return View(callScreenModel);
  425. }
  426. /// <summary>
  427. /// 微信编辑
  428. /// </summary>
  429. /// <param name="webChartNum">微信号</param>
  430. /// <param name="recordId">历史记录号</param>
  431. /// <param name="recordId">工单id</param>
  432. /// <returns></returns>
  433. public ActionResult WXWorkFlowEdit(int workOrderNum)
  434. {
  435. //实例化基础信息表
  436. CallScreenModel callScreenModel = new CallScreenModel();
  437. if ( workOrderNum > 0)
  438. {
  439. callScreenModel.WorkOrderBaseModel = orderBLL.GetModel(workOrderNum);
  440. //获取业务工单信息
  441. if (!string.IsNullOrEmpty(callScreenModel.WorkOrderBaseModel.F_EMPCODE))
  442. {
  443. T_Cus_CustomerBase baseCusModel = cusBLL.GetCusInfoModel(1, callScreenModel.WorkOrderBaseModel.F_EMPCODE);
  444. if (baseCusModel != null && baseCusModel.F_CustomerId > 0)
  445. {
  446. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = baseCusModel;
  447. }
  448. else
  449. {
  450. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  451. }
  452. }
  453. else
  454. {
  455. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  456. }
  457. //业务类型字典表
  458. callScreenModel.WorkOrderTypeModelList = GetWorkTypeModelList();
  459. //获取处理方式字典表
  460. callScreenModel.GoTypeModelList = GetCodeType("CLFS");
  461. //获取处理年龄段字典表
  462. callScreenModel.AgeModelList = GetCodeType("NLD");
  463. //获取部门列表
  464. callScreenModel.DepartmentList = deptBll.GetModelList("F_ParentId=0");
  465. callScreenModel.HistoryOrderList = historyBll.GetModelList("F_INSTANCEID=" + int.Parse(workOrderNum.ToString()));
  466. return View(callScreenModel);
  467. }
  468. return View();
  469. }
  470. /// <summary>
  471. /// 微博编辑
  472. /// </summary>
  473. /// <param name="webChartNum">微信号</param>
  474. /// <param name="recordId">历史记录号</param>
  475. /// <param name="recordId">工单id</param>
  476. /// <returns></returns>
  477. public ActionResult WBWorkFlowEdit(int workOrderNum)
  478. {
  479. //实例化基础信息表
  480. CallScreenModel callScreenModel = new CallScreenModel();
  481. if (workOrderNum > 0)
  482. {
  483. callScreenModel.WorkOrderBaseModel = orderBLL.GetModel(workOrderNum);
  484. //获取业务工单信息
  485. if (!string.IsNullOrEmpty(callScreenModel.WorkOrderBaseModel.F_EMPCODE))
  486. {//1微信,2微博
  487. T_Cus_CustomerBase baseCusModel = cusBLL.GetCusInfoModel(1, callScreenModel.WorkOrderBaseModel.F_EMPCODE);
  488. if (baseCusModel != null && baseCusModel.F_CustomerId > 0)
  489. {
  490. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = baseCusModel;
  491. }
  492. else
  493. {
  494. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  495. }
  496. }
  497. else
  498. {
  499. callScreenModel.WorkOrderBaseModel.CustomerBaseModel = new T_Cus_CustomerBase();
  500. }
  501. //业务类型字典表
  502. callScreenModel.WorkOrderTypeModelList = GetWorkTypeModelList();
  503. //获取处理方式字典表
  504. callScreenModel.GoTypeModelList = GetCodeType("CLFS");
  505. //获取处理年龄段字典表
  506. callScreenModel.AgeModelList = GetCodeType("NLD");
  507. //获取部门列表
  508. callScreenModel.DepartmentList = deptBll.GetModelList("F_ParentId=0");
  509. callScreenModel.HistoryOrderList = historyBll.GetModelList("F_INSTANCEID=" + int.Parse(workOrderNum.ToString()));
  510. return View(callScreenModel);
  511. }
  512. return View();
  513. }
  514. #endregion
  515. /// <summary>
  516. /// 补录工单处理信息
  517. /// </summary>
  518. /// <param name="workOrderBaseModel"></param>
  519. /// <returns></returns>
  520. [AcceptVerbs(HttpVerbs.Post)]
  521. public bool workOrderAddData(T_Wo_WorkOrderBase workOrderBaseModel)
  522. {
  523. if (workOrderBaseModel.F_REPAIRMANID == 4)
  524. {
  525. workOrderBaseModel.F_WORKORDERFROM = "微博工单";
  526. string wbh = workOrderBaseModel.CustomerBaseModel.F_CustomerEName.ToMyString().Trim();
  527. if (!string.IsNullOrEmpty(wbh))
  528. {
  529. workOrderBaseModel.F_EMPCODE = wbh;
  530. workOrderBaseModel.CustomerBaseModel.F_PostCode = wbh;
  531. }
  532. ////客户等级
  533. workOrderBaseModel.CustomerBaseModel.F_Kind = "3";
  534. workOrderBaseModel.CustomerBaseModel.F_ScaleResume = "1";
  535. workOrderBaseModel.CustomerBaseModel.F_CustomerClass = "一般客户";
  536. }
  537. else if (workOrderBaseModel.F_REPAIRMANID == 3)
  538. {
  539. workOrderBaseModel.F_WORKORDERFROM = "微信工单";
  540. string wbh = workOrderBaseModel.CustomerBaseModel.F_CustomerEName.ToMyString().Trim();
  541. if (!string.IsNullOrEmpty(wbh))
  542. {
  543. workOrderBaseModel.F_EMPCODE = wbh;
  544. workOrderBaseModel.CustomerBaseModel.F_PostCode = wbh;
  545. }
  546. ////客户等级
  547. workOrderBaseModel.CustomerBaseModel.F_Kind = "2";
  548. workOrderBaseModel.CustomerBaseModel.F_ScaleResume = "1";
  549. workOrderBaseModel.CustomerBaseModel.F_CustomerClass = "一般客户";
  550. }
  551. workOrderBaseModel.F_USERID = F_UserID;//id
  552. workOrderBaseModel.F_LINKMAN = F_UserCode;//工号
  553. workOrderBaseModel.F_REPAIRMANNAME = F_UserName;//姓名
  554. workOrderBaseModel.F_LINKMANTELEPHONE = workOrderBaseModel.CustomerBaseModel.F_Mobile;
  555. workOrderBaseModel.F_USERNAME = F_UserName;
  556. workOrderBaseModel.F_DEPTID = F_DeptId;
  557. T_Sys_Department deptmodel = deptBll.GetModel(F_DeptId);
  558. if (deptmodel != null)
  559. {
  560. workOrderBaseModel.F_DEPTCODE = deptmodel.F_DeptName;
  561. }
  562. AddAction("T_Wo_WorkOrderBase", workOrderBaseModel.F_WORKORDERID.ToMyString(), "录入工单", "数据:"+JsonConvert.SerializeObject(workOrderBaseModel), "关键信息");
  563. if (workOrderBaseModel.F_CONTENT == null)
  564. {
  565. workOrderBaseModel.F_CONTENT = "-";
  566. }
  567. if (workOrderBaseModel.F_RETURNVISITCONTENT == null)
  568. {
  569. workOrderBaseModel.F_RETURNVISITCONTENT = "-";
  570. }
  571. if (workOrderBaseModel.CustomerBaseModel != null)
  572. {
  573. //最近联络方式
  574. if (workOrderBaseModel.F_REPAIRMANID != 4&& workOrderBaseModel.F_REPAIRMANID != 3)
  575. {
  576. workOrderBaseModel.CustomerBaseModel.F_Kind = workOrderBaseModel.F_REPAIRMANID.ToString();
  577. }
  578. workOrderBaseModel.CustomerBaseModel.F_CustomerNature = workOrderBaseModel.F_WORKORDERFROM;
  579. //业务类型
  580. workOrderBaseModel.CustomerBaseModel.F_IndustryId = workOrderBaseModel.F_REPAIRLEVEL;
  581. workOrderBaseModel.CustomerBaseModel.F_Url = workOrderBaseModel.F_ADSLACCOUNT;
  582. //修改客户基础信息
  583. int cusid = cusBLL.EditCusInfoModel(workOrderBaseModel.CustomerBaseModel);
  584. if (cusid > 1)
  585. {
  586. workOrderBaseModel.F_CUSTOMERID = cusid;
  587. }
  588. }
  589. if (workOrderBaseModel.F_WORKORDERSTATEID > 0)
  590. {
  591. workOrderBaseModel.F_CODE= orderBLL.GetOrderNumber(workOrderBaseModel.F_REPAIRLEVEL.ToInt32());
  592. if (workOrderBaseModel.F_HOUSING == "表扬" || workOrderBaseModel.F_HOUSING == "咨询" || workOrderBaseModel.F_HOUSING == "挂失")
  593. {
  594. //workOrderBaseModel.F_WORKORDERTYPEID = 3;
  595. if (workOrderBaseModel.F_WORKORDERTYPEID == 1)
  596. {
  597. if (workOrderBaseModel.HistoryOrderList != null && workOrderBaseModel.HistoryOrderList.Count > 0)
  598. {
  599. Dictionary<int, string> dict = new Dictionary<int, string>() { };
  600. for (int i = workOrderBaseModel.HistoryOrderList.Count - 1; i >= 0; i--)
  601. {
  602. T_Wo_WorkOrderHistory modelhis = workOrderBaseModel.HistoryOrderList[i];
  603. Model.T_Sys_Department model = new BLL.T_Sys_Department().GetModel(string.Format("F_DeptId=(select top 1 F_DeptId from T_Sys_UserAccount where F_UserId={0})", modelhis.F_OPTUSERID));
  604. if (model != null && model.F_DeptId > 0)
  605. {
  606. if (dict.ContainsKey(model.F_DeptId))
  607. {
  608. workOrderBaseModel.HistoryOrderList.Remove(workOrderBaseModel.HistoryOrderList[i]);
  609. continue;
  610. }
  611. modelhis.F_OPTBTNID = model.F_DeptId;
  612. modelhis.F_NEXTOWNERARRID = model.F_DeptName;
  613. dict.Add(model.F_DeptId, "1");
  614. }
  615. }
  616. }
  617. }
  618. }
  619. if (workOrderBaseModel.F_WORKORDERTYPEID == 3)
  620. {
  621. Model.T_Wo_WorkOrderHistory historyModel = new Model.T_Wo_WorkOrderHistory();
  622. historyModel.F_INSTANCEID = 0;// workOrderBaseModel.F_WORKORDERID; 客服处理的工单按说不应该创建T_Wo_WorkOrderHistory,不知道为什么他要创建这个。所以给关联工单id的字段改成了0
  623. historyModel.F_OPTDATE = DateTime.Now;
  624. historyModel.ReplayTime = DateTime.Now;
  625. if (workOrderBaseModel.F_WORKORDERSTATEID >0)
  626. historyModel.F_WORKORDERSTATEID = (int)workOrderBaseModel.F_WORKORDERSTATEID;
  627. else
  628. historyModel.F_WORKORDERSTATEID = 1;
  629. historyModel.F_StateName = "已处理";
  630. historyModel.NeedReplayTime = workOrderBaseModel.F_REQUESTSERVICETIME;
  631. historyModel.F_OPTUSERID = F_UserID;
  632. historyModel.F_OPTBTNID = F_DeptId;
  633. historyModel.F_UserName = F_UserName;
  634. historyModel.F_REMARK = workOrderBaseModel.F_RETURNVISITCONTENT;
  635. Model.T_Sys_Department model = new BLL.T_Sys_Department().GetModel(string.Format("F_DeptId=(select top 1 F_DeptId from T_Sys_UserAccount where F_UserId={0})", F_UserID));
  636. if (model != null && model.F_DeptId > 0)
  637. {
  638. historyModel.F_NEXTOWNERARRID = model.F_DeptName;
  639. }
  640. else
  641. {
  642. historyModel.F_NEXTOWNERARRID = "全媒体客服";
  643. }
  644. workOrderBaseModel.HistoryOrderList = new List<T_Wo_WorkOrderHistory>();
  645. workOrderBaseModel.HistoryOrderList.Add(historyModel);
  646. }
  647. else
  648. {
  649. if (workOrderBaseModel.HistoryOrderList != null && workOrderBaseModel.HistoryOrderList.Count > 0)
  650. {
  651. Dictionary<int, string> dict = new Dictionary<int, string>() { };
  652. for (int i= workOrderBaseModel.HistoryOrderList.Count-1; i>=0;i--)
  653. {
  654. T_Wo_WorkOrderHistory modelhis = workOrderBaseModel.HistoryOrderList[i];
  655. if (dict.ContainsKey(modelhis.F_OPTUSERID.ToInt32()))
  656. {
  657. workOrderBaseModel.HistoryOrderList.Remove(workOrderBaseModel.HistoryOrderList[i]);
  658. continue;
  659. }
  660. new BLL.T_Com_Class().UpdateRate(F_UserCode, modelhis.F_OPTUSERID.ToInt32());
  661. Model.T_Sys_Department model= new BLL.T_Sys_Department().GetModel(string.Format("F_DeptId=(select top 1 F_DeptId from T_Sys_UserAccount where F_UserId={0})", modelhis.F_OPTUSERID));
  662. if (model != null && model.F_DeptId > 0)
  663. {
  664. modelhis.F_OPTBTNID = model.F_DeptId;
  665. modelhis.F_NEXTOWNERARRID = model.F_DeptName;
  666. }
  667. dict.Add(modelhis.F_OPTUSERID.ToInt32(), "1");
  668. }
  669. }
  670. }
  671. if (workOrderBaseModel.F_WORKORDERTYPEID == 1)
  672. {
  673. AddAction("t_wo_workorderbase", workOrderBaseModel.F_WORKORDERID.ToMyString(), "转单处理工单", workOrderBaseModel.F_CODE);
  674. }
  675. else
  676. {
  677. workOrderBaseModel.F_REMAINDERTIME = DateTime.Now;
  678. AddAction("t_wo_workorderbase", workOrderBaseModel.F_WORKORDERID.ToMyString(), "即时处理工单", workOrderBaseModel.F_CODE);
  679. }
  680. }
  681. else
  682. { workOrderBaseModel.F_CODE = ""; }
  683. if (workOrderBaseModel.F_WORKORDERID == 0&& (workOrderBaseModel.F_REPAIRMANID == 4|| workOrderBaseModel.F_REPAIRMANID==3))
  684. {
  685. //model.F_SERVICEWAY 记录id
  686. workOrderBaseModel.F_CREATEDATE = DateTime.Now;
  687. workOrderBaseModel.F_HASTENCOUNTS = 0;
  688. int workid = orderBLL.AddWbgd(workOrderBaseModel);
  689. if (workid == 0)
  690. {
  691. return false;
  692. }
  693. else if(workOrderBaseModel.F_REPAIRMANID == 3)
  694. {
  695. try
  696. {
  697. StringBuilder returnStr = new StringBuilder();
  698. string wxAddUrl = string.Format("http://rexian.zzmetro.com/api/customer/close/{0}/{1}", workOrderBaseModel.F_SERVICEWAY, workid);
  699. HttpHelper.HttpGet(wxAddUrl);
  700. }
  701. catch (Exception ex)
  702. {
  703. }
  704. }
  705. workOrderBaseModel.F_WORKORDERID = workid;
  706. }
  707. return orderBLL.UpdateWorkOrderInfoModel(workOrderBaseModel);
  708. }
  709. /// <summary>
  710. /// 来电弹屏处理工单 新增工单
  711. /// </summary>
  712. /// <param name="workOrderBaseModel"></param>
  713. /// <returns></returns>
  714. [AcceptVerbs(HttpVerbs.Post)]
  715. public bool workOrderAddDatanew(T_Wo_WorkOrderBase workOrderBaseModel)
  716. {
  717. bool bl = false;
  718. try
  719. {
  720. //工单来源
  721. workOrderBaseModel.F_REPAIRMANID = 4;
  722. workOrderBaseModel.F_WORKORDERFROM = "微博工单";
  723. string wbh = workOrderBaseModel.CustomerBaseModel.F_CustomerEName.Trim();
  724. if (!string.IsNullOrEmpty(wbh))
  725. {
  726. workOrderBaseModel.F_EMPCODE = wbh;
  727. workOrderBaseModel.CustomerBaseModel.F_PostCode = wbh;
  728. }
  729. //当前用户信息
  730. workOrderBaseModel.F_USERID = F_UserID;//id
  731. workOrderBaseModel.F_LINKMAN = F_UserCode;//工号
  732. workOrderBaseModel.F_REPAIRMANNAME = F_UserName;//姓名
  733. workOrderBaseModel.F_LINKMANTELEPHONE = workOrderBaseModel.CustomerBaseModel.F_Mobile;
  734. if (F_UserID > 0)
  735. {
  736. T_Sys_UserAccount usermodel = new T_Sys_UserAccount();
  737. usermodel = userBll.GetModel(F_UserID);
  738. workOrderBaseModel.F_REPAIRMANNAME = usermodel.F_UserName;//姓名
  739. }
  740. if (workOrderBaseModel.CustomerBaseModel != null)
  741. {
  742. //最近联络方式
  743. if (workOrderBaseModel.F_REPAIRMANID.ToString() == "4")
  744. { workOrderBaseModel.CustomerBaseModel.F_Kind = "3"; }
  745. else
  746. {
  747. workOrderBaseModel.CustomerBaseModel.F_Kind = workOrderBaseModel.F_REPAIRMANID.ToString();
  748. }
  749. workOrderBaseModel.CustomerBaseModel.F_CustomerNature = workOrderBaseModel.F_WORKORDERFROM;
  750. //业务类型
  751. workOrderBaseModel.CustomerBaseModel.F_IndustryId = workOrderBaseModel.F_REPAIRLEVEL;
  752. workOrderBaseModel.CustomerBaseModel.F_Url = workOrderBaseModel.F_ADSLACCOUNT;
  753. workOrderBaseModel.CustomerBaseModel.F_CustomerId = Convert.ToInt32(workOrderBaseModel.F_CUSTOMERID);
  754. ////客户等级
  755. workOrderBaseModel.CustomerBaseModel.F_ScaleResume = "1";
  756. workOrderBaseModel.CustomerBaseModel.F_CustomerClass = "一般客户";
  757. //保存工单基础信息
  758. //修改客户基础信息
  759. int cusid = cusBLL.EditCusInfoModel(workOrderBaseModel.CustomerBaseModel);
  760. if (cusid > 0)
  761. {
  762. workOrderBaseModel.F_CUSTOMERID = cusid;
  763. }
  764. }
  765. if (workOrderBaseModel.F_WORKORDERID == 0)
  766. {
  767. workOrderBaseModel.F_CREATEDATE = DateTime.Now;
  768. workOrderBaseModel.F_HASTENCOUNTS = 0;
  769. bl = orderBLL.AddWbgd(workOrderBaseModel)>0;
  770. }
  771. else
  772. {
  773. try
  774. {
  775. YTSoft.BaseCallCenter.Model.T_Wo_WorkOrderBase m = new YTSoft.BaseCallCenter.BLL.T_Wo_WorkOrderBase().GetModel(workOrderBaseModel.F_WORKORDERID);
  776. workOrderBaseModel.F_LINKMANTELEPHONE = m.F_LINKMANTELEPHONE;
  777. workOrderBaseModel.F_CUSTOMERTELEPHONE = m.F_CUSTOMERTELEPHONE;
  778. workOrderBaseModel.F_NUMBER = m.F_CODE;
  779. }
  780. catch
  781. { }
  782. if (workOrderBaseModel.F_SERVICETYPE == "待处理")
  783. {
  784. workOrderBaseModel.F_WORKORDERNAME = "手工工单";
  785. return orderBLL.UpdateWorkOrderInfoModel(workOrderBaseModel);
  786. }
  787. else
  788. {
  789. workOrderBaseModel.F_WORKORDERNAME = "手工工单";
  790. return orderBLL.UpdateWorkOrderInfoModel(workOrderBaseModel);
  791. }
  792. }
  793. }
  794. catch (Exception ex) { }
  795. return bl;
  796. }
  797. /// <summary>
  798. /// 初始化列表
  799. /// </summary>
  800. /// <returns></returns>
  801. public ActionResult CallRecordList()
  802. {
  803. WorkOrderMyModel model = new WorkOrderMyModel();
  804. return View(model);
  805. }
  806. /// <summary>
  807. /// 听取录音
  808. /// </summary>
  809. /// <returns></returns>
  810. public ActionResult VoicePlay(string type, string callid)
  811. {
  812. Models.VoicePlayModel model = new VoicePlayModel();
  813. model.playpath = type;
  814. AddAction("VoicePlay", callid, "听录音", string.Format("听了callid={0}的录音", callid), "敏感信息");
  815. if (!string.IsNullOrEmpty(callid))
  816. {
  817. if (callid.Contains("http://"))
  818. {
  819. model.downpath = callid;
  820. }
  821. else
  822. {
  823. BLL.rec_file_info busFile = new BLL.rec_file_info();
  824. if (type == "0")
  825. {
  826. //录音
  827. Model.rec_file_info modelfile= busFile.GetModel(callid);
  828. if (modelfile != null)
  829. {
  830. if (modelfile.FileName.Length > 10)
  831. {
  832. model.downpath = string.Format("{0}/oldyuyin/{1}", "http://10.200.46.21:8020", modelfile.FileName);
  833. }
  834. }
  835. }
  836. else if (type == "1")
  837. {
  838. //留言
  839. model.downpath = string.Format("{0}/oldliuyan/{1}", "http://10.200.46.21:8020", callid);// GetSysconfig("newPlayPath")
  840. }
  841. } }
  842. return View(model);
  843. }
  844. public ActionResult VoicePlay1(string type, string callid)
  845. {
  846. VoicePlayModel voicePlayModel = new VoicePlayModel();
  847. voicePlayModel.playpath = "";
  848. voicePlayModel.downpath = "";
  849. try
  850. {
  851. voicePlayModel.playpath = this.GetSrc(type, callid);
  852. voicePlayModel.downpath = !(type == "0") ? voicePlayModel.playpath.Replace("playvoicemail", "downvoicemail") : voicePlayModel.playpath.Replace("playbyappid", "downbyappid");
  853. if (!string.IsNullOrEmpty(voicePlayModel.playpath))
  854. {
  855. StringBuilder stringBuilder = new StringBuilder();
  856. string str = HttpHelper.HttpPost(voicePlayModel.playpath, (object)null);
  857. voicePlayModel.playpath = str;
  858. }
  859. }
  860. catch
  861. {
  862. }
  863. AddAction("VoicePlay1", callid, "听录音", string.Format("听了callid={0}的录音", callid), "敏感信息");
  864. return (ActionResult)this.View((object)voicePlayModel);
  865. }
  866. public string GetSrc(string type, string callid)
  867. {
  868. string s = "";
  869. BLL.T_Sys_SystemConfig bll_T_Sys_SystemConfig = new BLL.T_Sys_SystemConfig();
  870. try
  871. {
  872. string valueByParamCode = bll_T_Sys_SystemConfig.GetParamValueByParamCode(!(type == "0") ? "PlayLeaveVoice" : "PlayPath");
  873. string str = callid;
  874. s = str.IndexOf(":") >= 0 ? str.Replace("D:", valueByParamCode) : valueByParamCode + str;
  875. s = HttpUtility.HtmlEncode(s);
  876. }
  877. catch
  878. {
  879. }
  880. return s;
  881. }
  882. //public string GetSrc(string type, string callid)
  883. //{
  884. // string res = "";
  885. // try
  886. // {
  887. // string para = "PlayPath";
  888. // if (type == "0")
  889. // {
  890. // para = "PlayPath";
  891. // }
  892. // else
  893. // {
  894. // para = "PlayLeaveVoice";
  895. // }
  896. // BLL.T_Sys_SystemConfig bll_T_Sys_SystemConfig = new BLL.T_Sys_SystemConfig();
  897. // string CTIserverIP = bll_T_Sys_SystemConfig.GetParamValueByParamCode(para);//CTIIP
  898. // string path = callid;
  899. // if (path.IndexOf(":") < 0)
  900. // {
  901. // res = CTIserverIP + path;
  902. // }
  903. // else
  904. // {
  905. // res = path.Replace("D:", CTIserverIP);
  906. // }
  907. // res = HttpUtility.HtmlEncode(res);
  908. // }
  909. // catch
  910. // {
  911. // }
  912. // return res;
  913. //}
  914. /// <summary>
  915. /// 留言管理
  916. /// </summary>
  917. /// <returns></returns>
  918. public ActionResult CallLeaveList()
  919. {
  920. string userid = "0";
  921. YTSoft.BaseCallCenter.Model.T_Sys_UserAccount p_LoginUser = new YTSoft.BaseCallCenter.Model.T_Sys_UserAccount();
  922. try
  923. {
  924. if (Request.Cookies["BaseCallCenter_T_User"] != null)
  925. {
  926. userid = Request.Cookies["BaseCallCenter_T_User"]["F_UserId"];
  927. }
  928. int u = Convert.ToInt32(userid);
  929. }
  930. catch
  931. { }
  932. if (userid != "0")
  933. {
  934. p_LoginUser = new BLL.T_Sys_UserAccount().GetModel(Convert.ToInt32(userid));
  935. if (p_LoginUser != null)
  936. {
  937. if (Request.Cookies["BaseCallCenter_T_User"] != null)
  938. {
  939. p_LoginUser.F_ExtensionNumber = Request.Cookies["BaseCallCenter_T_User"]["F_ExtensionNumber"];
  940. }
  941. }
  942. }
  943. else
  944. {
  945. Response.Redirect("/Default/Login");
  946. }
  947. return View(p_LoginUser);
  948. }
  949. /// <summary>
  950. /// 坐席监控
  951. /// </summary>
  952. /// <returns></returns>
  953. public ActionResult SeatMonitoringList()
  954. {
  955. return View();
  956. }
  957. /// <summary>
  958. /// 获取通话记录
  959. /// </summary>
  960. /// <param name="page">当前页码</param>
  961. /// <param name="limit">每页数据量</param>
  962. /// <param name="sqlWhere">查询条件</param>
  963. /// <returns></returns>
  964. [ActionName("CallRecordData")]
  965. [HttpGet]
  966. public string CallRecordData(DateTime? NowDateTime, int page, int limit, string callnumber, string usercode, string callType,
  967. string callStatus, string dateParty,
  968. int F_WORKORDERTYPEID=0,string F_CONTENT="", string F_HOUSING="", string callid="0",string sort="",int ringtimes=0)
  969. {
  970. AddAction("T_Call_CallRecords", callid.ToMyString(), "获取通话记录列表", string.Format("获取{0}通话记录列表", dateParty), "敏感信息");
  971. //数据结果集
  972. ResponseData dataModel = new ResponseData();
  973. string sql = "";
  974. if (callid!="0"&&!string.IsNullOrEmpty(callid))
  975. {
  976. sql += string.Format(" and callid='{0}'", callid);
  977. }
  978. if (ringtimes > 0)
  979. {
  980. sql += string.Format(" and RingLongTime>{0}", ringtimes);
  981. }
  982. if (!string.IsNullOrEmpty(dateParty))
  983. {
  984. string startDate = dateParty.Substring(0, 10);
  985. string endDate = dateParty.Substring(12);
  986. sql += " and BeginTime>= '" + startDate + " 00:00:00" + "'";
  987. sql += " and BeginTime<= '" + endDate + " 23:59:59" + "'";
  988. }
  989. else
  990. {
  991. sql += " and BeginTime>= '" + DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00" + "'";
  992. sql += " and BeginTime<= '" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59" + "'";
  993. }
  994. if (!string.IsNullOrEmpty(callnumber))
  995. {
  996. sql += " and CallNumber like '%" + callnumber.Trim() + "%'";
  997. }
  998. if (!string.IsNullOrEmpty(usercode))
  999. {
  1000. sql += " and UserCode like '%" + usercode.Trim() + "%'";
  1001. }
  1002. //呼叫类型,0呼入1呼出
  1003. if (!string.IsNullOrEmpty(callType))
  1004. {
  1005. sql += " and CallType =" + callType;
  1006. }
  1007. //呼叫状态,0:未接通电话1已接通电话
  1008. if (!string.IsNullOrEmpty(callStatus))
  1009. {
  1010. sql += " and CallState =" + callStatus;
  1011. }
  1012. //工单类型 F_HOUSING select F_WORKORDERTYPEID,F_CONTENT,F_HOUSING from T_Wo_WorkOrderBase where 1=1 and F_CONTENT like '%'++'%'
  1013. //工单类型
  1014. if (!string.IsNullOrEmpty(F_HOUSING))
  1015. {
  1016. //sql += string.Format(" AND F_WorkOrderTypeId IS NOT null and T2.F_HOUSING='{0}'", F_HOUSING);
  1017. string F_HOUSINGint = "0";
  1018. switch (F_HOUSING)
  1019. {
  1020. case "咨询":
  1021. F_HOUSINGint = "1";
  1022. break;
  1023. case "投诉":
  1024. F_HOUSINGint = "2";
  1025. break;
  1026. case "建议":
  1027. F_HOUSINGint = "3";
  1028. break;
  1029. case "表扬":
  1030. F_HOUSINGint = "4";
  1031. break;
  1032. case "挂失":
  1033. F_HOUSINGint = "5";
  1034. break;
  1035. }
  1036. sql += string.Format("AND F_ServiceType={0} ", F_HOUSINGint);
  1037. }
  1038. //呼叫状态,0:未接通电话1已接通电话
  1039. if (!string.IsNullOrEmpty(callStatus))
  1040. {
  1041. sql += " and CallState =" + callStatus;
  1042. }
  1043. DataTable dt = new DataTable();
  1044. int recordCount = 0;
  1045. //BLL.T_Call_CallRecords busCall_CallRecords = new BLL.T_Call_CallRecords();
  1046. //busCall_CallRecords.GetListByPage();
  1047. Model.PageData<Model.T_Call_CallRecords_All> pageModel = new Model.PageData<Model.T_Call_CallRecords_All>();
  1048. // dt = BLL.PagerBLL.GetTableList(
  1049. // " (T_Call_CallRecords T1 LEFT JOIN T_Wo_WorkOrderBase T2 ON T1.CallId=T2.F_KSHADDRESSCODE ) ",
  1050. // "CallRecordsId",
  1051. // "T1.*,F_WORKORDERID,F_HOUSING,CONVERT(varchar,BeginTime, 120 ) as BeginTimeNew,CONVERT(varchar,TalkStartTime, 120 ) as TalkStartTimeNew,CONVERT(varchar,TalkEndTime, 120 ) as TalkEndTimeNew"
  1052. // + @",(select top 1 F_ScaleResume from T_Cus_CustomerBase n where
  1053. //CallNumber=F_Telephone) as F_ScaleResume,
  1054. //replace(replace(FilePath,'\','/'),'" + GetSysconfig("newFilePath") + "','" + GetSysconfig("newPlayPath") + "')" +
  1055. //@" as fileurl,case
  1056. // when BusinessType=1 then '咨询'
  1057. // when BusinessType=2 then '建议'
  1058. // when BusinessType=3 then '表扬'
  1059. // when BusinessType=4 then '挂失'
  1060. // when BusinessType=9 then '投诉'
  1061. // when T1.F_ServiceType=1 then '咨询'
  1062. // when T1.F_ServiceType = 2 then '投诉'
  1063. // when T1.F_ServiceType = 3 then '建议'
  1064. // when T1.F_ServiceType = 4 then '表扬'
  1065. // when T1.F_ServiceType = 5 then '挂失'
  1066. // else '' end as
  1067. //BType, case when (isnull(BusinessType,0)>0 or isnull(T1.F_ServiceType,0)>0) then '人工服务' else '' end as ywtype ",
  1068. // sql,
  1069. // // "ORDER BY LongTime,CallRecordsId desc",
  1070. // string.IsNullOrEmpty(sort) ? " BeginTime desc": sort + " desc"
  1071. // ,
  1072. // limit,
  1073. // page,
  1074. // out recordCount);
  1075. dt = BLL.PagerBLL.GetListPager(
  1076. " T_Call_CallRecords ",
  1077. "CallRecordsId",
  1078. "*," +
  1079. "(select top 1 F_WORKORDERID from T_Wo_WorkOrderBase where F_KSHADDRESSCODE=CallId) as F_WORKORDERID," +
  1080. "CONVERT(varchar,BeginTime, 120 ) as BeginTimeNew,CONVERT(varchar,TalkStartTime, 120 ) as TalkStartTimeNew,CONVERT(varchar,TalkEndTime, 120 ) as TalkEndTimeNew"
  1081. + @",(select top 1 F_ScaleResume from T_Cus_CustomerBase n where
  1082. CallNumber=F_Telephone) as F_ScaleResume,
  1083. replace(replace(FilePath,'\','/'),'" + GetSysconfig("newFilePath") + "','" + GetSysconfig("newPlayPath") + "')" +
  1084. @" as fileurl,case
  1085. when BusinessType=1 then '咨询'
  1086. when BusinessType=2 then '建议'
  1087. when BusinessType=3 then '表扬'
  1088. when BusinessType=4 then '挂失'
  1089. when BusinessType=9 then '投诉'
  1090. when F_ServiceType=1 then '咨询'
  1091. when F_ServiceType = 2 then '投诉'
  1092. when F_ServiceType = 3 then '建议'
  1093. when F_ServiceType = 4 then '表扬'
  1094. when F_ServiceType = 5 then '挂失'
  1095. else '' end as
  1096. BType, case when (isnull(BusinessType,0)>0 or isnull(F_ServiceType,0)>0) then '人工服务' else '' end as ywtype ",
  1097. sql,
  1098. // "ORDER BY LongTime,CallRecordsId desc",
  1099. string.IsNullOrEmpty(sort) ? "ORDER BY BeginTime desc" : "ORDER BY "+ sort + " desc"
  1100. ,
  1101. limit,
  1102. page,
  1103. true,
  1104. out recordCount);
  1105. dataModel.code = 0;
  1106. dataModel.count = recordCount;
  1107. dataModel.data = dt;
  1108. string json = JsonConvert.SerializeObject(dataModel);
  1109. return json;
  1110. }
  1111. /// <summary>
  1112. /// 获取留言记录
  1113. /// </summary>
  1114. /// <param name="page">当前页码</param>
  1115. /// <param name="limit">每页数据量</param>
  1116. /// <param name="sqlWhere">查询条件</param>
  1117. /// <returns></returns>
  1118. [ActionName("LeaveRecordData")]
  1119. [HttpGet]
  1120. public string LeaveRecordData(DateTime? NowDateTime, int page, int limit, string callnumber, string leavedate, string status)
  1121. {
  1122. AddAction("T_Call_LeaveRecord", status, "获取通话记录列表", string.Format("获取{0}留言记录列表", leavedate), "敏感信息");
  1123. //数据结果集
  1124. ResponseData dataModel = new ResponseData();
  1125. string sql = "";
  1126. if (!string.IsNullOrEmpty(callnumber))
  1127. {
  1128. sql += " and F_Phone like '%" + callnumber.Trim() + "%'";
  1129. }
  1130. //if (!string.IsNullOrEmpty(leavedate))
  1131. //{
  1132. // sql += " and datediff(day,'" + leavedate + "',F_LeaveTime)=0 ";
  1133. //}
  1134. string startDate = "";
  1135. string endDate = "";
  1136. if (!string.IsNullOrEmpty(leavedate))
  1137. {
  1138. startDate = leavedate.Substring(0, 10);
  1139. endDate = leavedate.Substring(12);
  1140. sql += " and F_LeaveTime>= '" + startDate + " 00:00:00" + "'";
  1141. sql += " and F_LeaveTime<= '" + endDate + " 23:59:59" + "'";
  1142. }
  1143. else {
  1144. startDate = DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd");
  1145. endDate = DateTime.Now.ToString("yyyy-MM-dd");
  1146. sql += " and F_LeaveTime>= '" + startDate + " 00:00:00" + "'";
  1147. sql += " and F_LeaveTime<= '" + endDate + " 23:59:59" + "'";
  1148. }
  1149. if (!string.IsNullOrEmpty(status))
  1150. {
  1151. sql += " and F_Status=" + status + " ";
  1152. }
  1153. DataTable dt = new DataTable();
  1154. int recordCount = 0;
  1155. dt = BLL.PagerBLL.GetListPager(
  1156. "T_Call_LeaveRecord",
  1157. "F_Id",
  1158. "*,CONVERT(varchar,F_LeaveTime, 120 ) as F_LeaveTimeNew,CONVERT(varchar,F_DealTime, 120 ) as F_DealTimeNew"
  1159. + ",(select top 1 F_ScaleResume from T_Cus_CustomerBase n where F_Phone=F_Telephone) as F_ScaleResume ," +
  1160. @"replace(replace(F_RecFileUrl, '\','/'),'" + GetSysconfig("newFilePath") + "','" + GetSysconfig("newPlayPath") + "') as TheLuyin",
  1161. sql,
  1162. "ORDER BY F_Id desc",
  1163. limit,
  1164. page,
  1165. true,
  1166. out recordCount);
  1167. dataModel.code = 0;
  1168. dataModel.count = recordCount;
  1169. dataModel.data = dt;
  1170. if (dt != null && recordCount > 0)
  1171. {
  1172. foreach (DataRow dr in dt.Rows)
  1173. {
  1174. if (dr["F_RecFileUrl"].ToMyString().Contains(GetSysconfig("newFilePath").Substring(0,2)))
  1175. {
  1176. if (!System.IO.File.Exists(dr["F_RecFileUrl"].ToMyString()))
  1177. {
  1178. dr["TheLuyin"] = "";
  1179. }
  1180. }
  1181. }
  1182. }
  1183. string json = JsonConvert.SerializeObject(dataModel);
  1184. return json;
  1185. }
  1186. /// <summary>
  1187. /// 留言创建工单处理
  1188. /// </summary>
  1189. /// <param name="LeaveOptAjax"></param>
  1190. /// <returns></returns>
  1191. [ActionName("LeaveOptAjax")]
  1192. [HttpGet]
  1193. public string LeaveOptAjax(string optaction, string timeno, string callid, string userid, string usercode, string username, string extnumber, string callernum, string leaveid)
  1194. {
  1195. //&timeno=" + timeno+"&callid=" + callID + "&userid=" + userid + "&usercode=" + usercode
  1196. //+ "&username=" + username + "&extnumber" + extnumber + "&callernum=" + callerNum
  1197. string res = "error";
  1198. try
  1199. {
  1200. switch (optaction)
  1201. {
  1202. case "leaveAddOrderEvent":
  1203. //振铃事件
  1204. res = leaveAddOrderEvent(callid, userid, usercode, username, extnumber, callernum, leaveid);
  1205. break;
  1206. }
  1207. }
  1208. catch
  1209. { }
  1210. return res;
  1211. }
  1212. #region 来电归属地查询
  1213. public string GetPhoneLocation(string phoneNumber, bool isPhone)
  1214. {
  1215. string location = "未知";
  1216. try
  1217. {
  1218. //如果是手机号码
  1219. if (isPhone)
  1220. {
  1221. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  1222. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModel(phoneNumber.Substring(0, 7));
  1223. return mobileModel != null ? (mobileModel.F_CityDes + mobileModel.F_CardDes) : location;
  1224. }
  1225. else//如果是电话号码
  1226. {
  1227. BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
  1228. List<Model.T_Sys_TelTitleData> mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + phoneNumber.Substring(0, 4) + "'");
  1229. if (mobileModel == null || mobileModel.Count <= 0)
  1230. mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + phoneNumber.Substring(0, 3) + "'");
  1231. return mobileModel.Count > 0 ? mobileModel[0].F_TitleName : location;
  1232. }
  1233. }
  1234. catch (System.Exception ex)
  1235. {
  1236. return location;
  1237. }
  1238. }
  1239. #endregion
  1240. #region 自动添加工单
  1241. public bool SubmitOSubmit(string phone, string recordid, string callid, string locationaddress, string userid, string username, string usercode, out int workorderid)
  1242. {
  1243. bool bl = false;
  1244. workorderid = 0;
  1245. try
  1246. {
  1247. Model.T_Wo_WorkOrderBase model = new Model.T_Wo_WorkOrderBase();
  1248. #region 工单信息
  1249. //model.F_WORKORDERTYPEID = Convert.ToInt32(typeid);//类型ID
  1250. model.F_WORKORDERSTATEID = 0;//状态ID
  1251. model.F_REPAIRREQUEST = "未处理";
  1252. model.F_CODE = "";//工单编号
  1253. model.F_WORKORDERNAME = "";//工单名称
  1254. model.F_NUMBER = model.F_CODE;
  1255. //model.F_CUSTOMERNAME = txtCustomerName.Text.Trim();//客户姓名
  1256. model.F_CUSTOMERTELEPHONE = phone.Trim();//客户电话
  1257. model.F_USERID = Convert.ToInt32(userid);//坐席id
  1258. model.F_LINKMAN = usercode.Trim();//坐席工号
  1259. model.F_REPAIRMANNAME = username.Trim();//坐席名称
  1260. model.F_LINKMANTELEPHONE = phone.Trim();//联系人电话
  1261. //model.F_ADSLACCOUNT = hfCallId.Value.Trim();
  1262. model.F_BANDWIDTH = "";
  1263. model.F_STANDARDADDRESS = locationaddress.Trim();
  1264. //model.F_INSTALLADDRESS = F_INSTALLADDRESS;
  1265. model.F_KSHADDRESSCODE = callid;
  1266. model.F_RANGEID = Convert.ToInt32(recordid);
  1267. model.F_PROVINCE = "";
  1268. model.F_CITY = "";
  1269. model.F_AREA = "";
  1270. model.F_ROAD = "";
  1271. model.F_HOUSING = "";
  1272. model.F_REPAIRMANID = 2;
  1273. model.F_WORKORDERFROM = "留言工单";
  1274. //model.F_WORKORDERLEVELID = F_WORKORDERLEVELID;
  1275. model.F_FILEFLAG = 0;
  1276. model.F_CREATEBY = Convert.ToInt32(userid.Trim());
  1277. model.F_CREATEDATE = DateTime.Now;
  1278. model.F_RETURNVISITFLAG = 0;
  1279. model.F_RETURNVISITSTATE = 0;
  1280. model.F_RETURNVISITRESULT = 0;
  1281. model.F_RETURNVISITCONTENT = "";
  1282. model.F_DELETEFLAG = 0;
  1283. model.F_ALLUSETIMES = 0;
  1284. model.F_STARTTIME = DateTime.Now;
  1285. model.F_OVERTIMES = 0;
  1286. model.F_FORMID = 0;
  1287. model.F_HASTENCOUNTS = 0;
  1288. model.F_RANGEX = 0;
  1289. model.F_RANGEY = 0;
  1290. model.F_REPAIRCLOSEMANID = 0;
  1291. model.F_REPAIRCLOSEMANNAME = "";
  1292. model.F_REPAIRCLOSEREASONS = "";
  1293. model.F_REPAIRCLOSEREPTID = 0;
  1294. model.F_REPAIRCLOSEREPT = "";
  1295. #endregion
  1296. int resorderbase = new BLL.T_Wo_WorkOrderBase().Add(model);//添加基本信息
  1297. workorderid = resorderbase;
  1298. if (resorderbase > 0)
  1299. {
  1300. bl = true;
  1301. }
  1302. else
  1303. {
  1304. bl = false;
  1305. }
  1306. }
  1307. catch (Exception ex)
  1308. {
  1309. }
  1310. return bl;
  1311. }
  1312. #endregion
  1313. #region 处理留言创建工单事件
  1314. public string leaveAddOrderEvent(string callid, string userid, string usercode, string username, string extnumber, string callernum, string leaveid)
  1315. {
  1316. string res = "error";
  1317. try
  1318. {
  1319. AddAction("leaveAddOrderEvent", callid, "创建留言工单", string.Format("{0}创建callid={1}留言工单{2}", username, callid, leaveid), "关键信息");
  1320. Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  1321. if (vmodel != null)
  1322. {
  1323. string phone = callernum;
  1324. #region 来电归属地查询
  1325. string location = "";
  1326. //来电归属地查询
  1327. if (phone.Trim().Length == 11 && phone.Substring(0, 1) != "0")
  1328. {
  1329. location = GetPhoneLocation(phone, true);
  1330. }
  1331. else
  1332. {
  1333. location = GetPhoneLocation(phone, false);
  1334. }
  1335. #endregion
  1336. #region 创建工单
  1337. int workorderid = 0;
  1338. bool wobl = SubmitOSubmit(phone, vmodel.CallRecordsId.ToString(), callid, location, userid, username, usercode, out workorderid);
  1339. if (wobl)
  1340. {
  1341. //处理留言
  1342. #region 处理留言
  1343. Model.T_Call_LeaveRecord leavemodel = new BLL.T_Call_LeaveRecord().GetModel(Convert.ToInt32(leaveid));
  1344. if (leavemodel != null)
  1345. {
  1346. //leavemodel.F_CallAppId = workorderid.ToString();
  1347. //leavemodel.F_Status = 1;
  1348. //leavemodel.F_UserId = Convert.ToInt32(userid);
  1349. //leavemodel.F_UserName = username;
  1350. //leavemodel.F_UserCode = usercode;
  1351. //leavemodel.F_DealTime = DateTime.Now;
  1352. //leavemodel.F_DealContent = "留言创建工单";
  1353. //new BLL.T_Call_LeaveRecord().Update(leavemodel);
  1354. string strSql = @"
  1355. update T_Call_LeaveRecord set
  1356. F_CallAppId = " + workorderid.ToString() + @",F_Status = 1,
  1357. F_UserId = " + Convert.ToInt32(userid) + @",F_UserName = '" + username + @"',F_UserCode = '" + usercode + @"',F_DealTime = '" + DateTime.Now + @"',
  1358. F_DealContent = '留言创建工单' where F_Id = " + leavemodel.F_Id;
  1359. int rows = DbHelperSQL.ExecuteSql(strSql);
  1360. }
  1361. #endregion
  1362. try
  1363. {
  1364. Model.T_Call_WorkOrder modelorder = new Model.T_Call_WorkOrder();
  1365. modelorder.CallId = callid;
  1366. modelorder.F_WORKORDERID = workorderid;
  1367. modelorder.F_WORKORDERSTATEID = 0;
  1368. new BLL.T_Call_WorkOrder().Add(modelorder);
  1369. }
  1370. catch { }
  1371. res = workorderid.ToString();
  1372. }
  1373. #endregion
  1374. }
  1375. }
  1376. catch (Exception ex)
  1377. {
  1378. //res = ex.ToString();
  1379. }
  1380. return res;
  1381. }
  1382. #endregion
  1383. /// <summary>
  1384. /// 获取坐席监控坐席列表
  1385. /// </summary>
  1386. /// <returns></returns>
  1387. [ActionName("getseatnewlist")]
  1388. [HttpGet]
  1389. public string getseatnewlist()
  1390. {
  1391. string strHtml = "";
  1392. string strList = "";
  1393. DataTable dt = new DataTable();
  1394. try
  1395. {
  1396. AddAction("T_Sys_UserAccount", "0", "获取坐席监控列表", "", "关键信息");
  1397. BLL.T_Sys_UserAccount bll = new BLL.T_Sys_UserAccount();
  1398. dt = bll.GetList(" f_seatflag=1 order by f_userid desc ").Tables[0];
  1399. if (dt.Rows.Count > 0)
  1400. {
  1401. for (int i = 0; i < dt.Rows.Count; i++)
  1402. {
  1403. strList += dt.Rows[i]["F_WorkNumber"] + ",";// "-" + dt.Rows[i]["ExtensionCode"] + ",";
  1404. strHtml += "<div id=\"div_" + dt.Rows[i]["F_WorkNumber"] + "\" style='float: left; width: 120px; height: 120px; text-align: center; padding: 8px;cursor:pointer'>";
  1405. strHtml += "<div style='height: 90px; border: 1px solid #CCCCCC; padding: 3px; text-align: center;cursor:pointer'";
  1406. strHtml += "onmouseover=\"this.style.border='1px solid #3A8BDC'\" onmouseout=\"this.style.border='1px solid #CCCCCC'\">";
  1407. strHtml += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100%\" style=\"text-align: center;cursor:pointer\" ";
  1408. strHtml += " onclick=\"GetOneState('" + dt.Rows[i]["F_WorkNumber"] + "','"+ dt.Rows[i]["ExtensionCode"] + "','" + dt.Rows[i]["F_UserName"] + "')\">";
  1409. strHtml += " <tr><td><input type=\"text\" id=\"" + dt.Rows[i]["F_WorkNumber"] + "\" style=\"display: none\" /><input type=\"text\" id=\"txtSeatState_" + dt.Rows[i]["F_WorkNumber"] + "\" value=\"0\" style=\"display: none\" />";
  1410. strHtml += " <span id=\"span_" + dt.Rows[i]["F_WorkNumber"] + "\" style=\"color: #000000;\">";
  1411. strHtml += dt.Rows[i]["F_WorkNumber"] + "(" + dt.Rows[i]["F_UserName"] + ")</span>";
  1412. strHtml += "</td></tr> <tr> <td><img id=\"img_" + dt.Rows[i]["F_WorkNumber"] + "\" src=\"/Content/images/seatimgs/weiqianru.jpg\" />";
  1413. strHtml += "</td></tr><tr><td><span id=\"span_state_" + dt.Rows[i]["F_WorkNumber"] + "\" style=\"color: #cccccc;\">未签入</span>";
  1414. strHtml += " </td></tr></table></div></div>";
  1415. }
  1416. }
  1417. strList += "!@#";
  1418. strList = strList.Replace(",!@#", "").Replace("!@#", "");
  1419. }
  1420. catch
  1421. {
  1422. }
  1423. finally
  1424. {
  1425. dt.Clear();
  1426. dt.Dispose();
  1427. }
  1428. return strList + "~" + strHtml;
  1429. }
  1430. //外呼判断本地外地以及加前缀返回
  1431. [ActionName("GetCallOutprefix")]
  1432. [HttpGet]
  1433. public string GetCallOutprefix(string phone) {
  1434. AddAction("T_Sys_UserAccount", phone, "外呼获取外呼前缀", phone);
  1435. string phone1 = CallCenter.Utility.RequestString.ToDBC(RequestString.RemoveNotNumber(StringHelper.NoHTML(phone)));
  1436. string tophone = phone1;
  1437. string zipcode = ""; string bfix = ""; string wfix = ""; string fix = "";
  1438. // string userseatgroupid = CurrentUser.UserData.F_SeartGroupID.ToString();
  1439. //if (userseatgroupid != "" && userseatgroupid != "0")
  1440. //{
  1441. //Model.T_Sys_SeatGroup smodel = new BLL.T_Sys_SeatGroup().GetModel(int.Parse(userseatgroupid));
  1442. //if (smodel != null)
  1443. //{
  1444. zipcode = "0371";
  1445. bfix ="9";
  1446. wfix = "90";
  1447. //}
  1448. //}
  1449. int zip = GetZipCodeByPhone(phone1, zipcode);
  1450. #region
  1451. if (zip == 1)
  1452. {//手机本地号码
  1453. fix = bfix;
  1454. }
  1455. else if (zip == 2)
  1456. {//手机外地号码
  1457. fix = wfix;
  1458. }
  1459. else
  1460. {
  1461. tophone = phone1.TrimStart('0');
  1462. if (zip == 3)
  1463. {//本地固话去0加9 比如:988888517,937188888517
  1464. fix = bfix;
  1465. }
  1466. else if (zip == 4)
  1467. {//外地固话前加9 比如:9037188888517
  1468. fix = wfix;
  1469. }
  1470. }
  1471. #endregion
  1472. var obj = new
  1473. {
  1474. phone = fix + tophone,
  1475. fix = fix
  1476. };
  1477. return fix;
  1478. // return Success("外呼号码加前缀" + phone, obj);
  1479. }
  1480. /// <summary>
  1481. /// 根据号码和区号判断号码是否为归属地号码
  1482. /// 返回0为分机号或特殊号码
  1483. /// 返回1为手机本地号码
  1484. /// 返回2为手机外地号码
  1485. /// 返回3为固定电话本地号码
  1486. /// 返回4为固定电话外地号码
  1487. /// </summary>
  1488. /// <param name="phone"></param>
  1489. /// <param name="zipcode"></param>
  1490. /// <returns></returns>
  1491. [NonAction]
  1492. public int GetZipCodeByPhone(string phone, string zipcode)
  1493. {
  1494. int n = 0;
  1495. if (phone.Trim().Length >= 7)
  1496. {
  1497. //7位及7位以上是固定电话或手机
  1498. //判断是否手机
  1499. if (phone.Trim().Length == 11 && phone[0] == '1')
  1500. {//号码为11位,首位是1,为手机号
  1501. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  1502. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList("F_MobileNum='" + phone.Substring(0, 7) + "'").FirstOrDefault();
  1503. if (mobileModel != null)
  1504. {
  1505. if (mobileModel.F_ZipCode.Equals(zipcode))
  1506. {
  1507. return 1;
  1508. }
  1509. else
  1510. {
  1511. return 2;
  1512. }
  1513. }
  1514. }
  1515. else
  1516. {
  1517. if (phone.Trim().Length == 11 && phone.Substring(0, 3).Equals(zipcode))
  1518. {//号码为11位
  1519. //截取前三位区号判断是否本地
  1520. bool resbd3 = phone.Substring(0, 3).Equals(zipcode);
  1521. //截取前四位区号判断是否本地
  1522. bool resbd4 = phone.Substring(0, 4).Equals(zipcode);
  1523. if (resbd3 || resbd4)
  1524. {
  1525. return 3;
  1526. }
  1527. else
  1528. {
  1529. return 4;
  1530. }
  1531. }
  1532. else if (phone.Trim().Length < 11)
  1533. {//号码小于11位,为本地
  1534. return 3;
  1535. }
  1536. else if (phone.Trim().Length > 11 && phone.Substring(0, 4).Equals(zipcode))
  1537. {//号码大于11位,截取前四位区号判断是否本地
  1538. return 3;
  1539. }
  1540. else
  1541. {
  1542. return 4;
  1543. }
  1544. }
  1545. }
  1546. else
  1547. {
  1548. return 3;
  1549. }
  1550. return n;
  1551. }
  1552. /// <summary>
  1553. /// 获取来电业务类型
  1554. /// </summary>
  1555. /// <param name="CallId">通话记录Callid </param>
  1556. /// <returns></returns>
  1557. [ActionName("GetCallType")]
  1558. [HttpGet]
  1559. public string GetCallType(string CallId)
  1560. {
  1561. //数据结果集
  1562. ResponseData dataModel = new ResponseData();
  1563. //来电业务类型
  1564. string sql = " select F_ServiceType from T_Call_CallRecords where CallId='" + CallId + "' order by BeginTime desc ";
  1565. //排队数量
  1566. // string sql2 = " select COUNT(CallId) as CallId from T_Call_CallRecords where F_linenum=1 ";
  1567. DataTable dt = new DataTable();
  1568. DataSet ds = DbHelperSQL.Query(sql);
  1569. dt = ds.Tables[0];
  1570. //来电业务类型
  1571. dataModel.code = Convert.ToInt32(dt.Rows[0]["F_ServiceType"].ToString() == "" ? "0" : dt.Rows[0]["F_ServiceType"].ToString());
  1572. //DataTable dt2 = new DataTable();
  1573. //DataSet ds2 = DbHelperSQL.Query(sql2);
  1574. //dt2 = ds2.Tables[0];
  1575. ////排队数量
  1576. //dataModel.msg = dt2.Rows[0]["CallId"].ToString() == "" ? "0" : dt2.Rows[0]["CallId"].ToString();
  1577. // dataModel.count = recordCount;
  1578. // dataModel.data = dt;
  1579. string json = JsonConvert.SerializeObject(dataModel);
  1580. return json;
  1581. }
  1582. /// <summary>
  1583. /// 获取排队数量
  1584. /// </summary>
  1585. /// <param name="CallId">通话记录Callid </param>
  1586. /// <returns></returns>
  1587. [ActionName("GetCallLineNum")]
  1588. [HttpGet]
  1589. public string GetCallLineNum()
  1590. {
  1591. //数据结果集
  1592. ResponseData dataModel = new ResponseData();
  1593. //排队数量
  1594. string sql2 = " select COUNT(CallId) as CallId from T_Call_CallRecords where F_linenum=1 and isnull(TalkStartTime,0)=0 ";
  1595. DataTable dt2 = new DataTable();
  1596. DataSet ds2 = DbHelperSQL.Query(sql2);
  1597. dt2 = ds2.Tables[0];
  1598. //排队数量
  1599. dataModel.code = Convert.ToInt32(dt2.Rows[0]["CallId"].ToString() == "" ? "0" : dt2.Rows[0]["CallId"].ToString());
  1600. // dataModel.count = recordCount;
  1601. // dataModel.data = dt;
  1602. string json = JsonConvert.SerializeObject(dataModel);
  1603. // return json;
  1604. return dataModel.code.ToString();
  1605. }
  1606. }
  1607. }