地铁二期项目正式开始

CallRecordController.cs 70KB

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