郑许地铁

CallRecordController.cs 77KB

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