地铁二期项目正式开始

CallRecordController.cs 59KB

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