地铁二期项目正式开始

CallRecordController.cs 84KB

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