地铁二期项目正式开始

CallRecordController.cs 76KB

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