地铁二期项目正式开始

CallRecordController.cs 58KB

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