Nenhuma Descrição

CallInScreenController.cs 43KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using CallCenterApi.Interface.Models.Dto;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. namespace CallCenterApi.Interface.Controllers.tel
  12. {
  13. public class CallInScreenController : BaseController
  14. {
  15. private BLL.T_Sys_DictionaryValue dictionaryValueBLL = new BLL.T_Sys_DictionaryValue();
  16. /// <summary>
  17. /// 添加黑名单
  18. /// </summary>
  19. /// <returns></returns>
  20. public ActionResult AddBlack()
  21. {
  22. ActionResult res = NoToken("未知错误,请重新登录");
  23. if (Request.IsAuthenticated)
  24. {
  25. int userId = CurrentUser.UserData.F_UserId;
  26. if (userId != 0)
  27. {
  28. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  29. if (ua != null)
  30. {
  31. string tel = HttpUtility.UrlDecode(RequestString.GetFormString("tel"));
  32. string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
  33. int n = RequestString.GetInt("num", 0);
  34. int type = RequestString.GetInt("type", 0);
  35. Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
  36. var date = DateTime.Now;
  37. var enddate = date;
  38. switch (type)
  39. {
  40. case 1: enddate = enddate.AddDays(n); break;
  41. case 2: enddate = enddate.AddHours(n); break;
  42. case 3: enddate = enddate.AddMinutes(n); break;
  43. case 4: enddate = DateTime.MaxValue; break;
  44. }
  45. if (dModel == null)
  46. {
  47. dModel = new Model.T_Call_Blacklist();
  48. dModel.F_CallId = callid;
  49. dModel.F_TelPhone = tel.Trim();
  50. dModel.F_SetTime = date;
  51. dModel.F_RemoveTime = enddate;
  52. dModel.F_InterceptNum = 1;
  53. dModel.F_UserId = ua.F_UserId;
  54. int b = new BLL.T_Call_Blacklist().Add(dModel);
  55. if (b > 0)
  56. {
  57. res = Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
  58. }
  59. else
  60. {
  61. res = Error("添加失败");
  62. }
  63. }
  64. else
  65. {
  66. dModel.F_RemoveTime = enddate;
  67. if (new BLL.T_Call_Blacklist().Update(dModel))
  68. {
  69. res = Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
  70. }
  71. else
  72. {
  73. res = Error("修改失败");
  74. }
  75. }
  76. }
  77. }
  78. }
  79. return res;
  80. }
  81. /// <summary>
  82. /// 取消黑名单
  83. /// </summary>
  84. /// <returns></returns>
  85. public ActionResult DelBlack()
  86. {
  87. ActionResult res = NoToken("未知错误,请重新登录");
  88. if (Request.IsAuthenticated)
  89. {
  90. string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  91. Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
  92. if (dModel != null)
  93. {
  94. bool bl = new BLL.T_Call_Blacklist().Delete(dModel.F_BlackId);
  95. if (bl)
  96. {
  97. res = Success("取消成功");
  98. }
  99. }
  100. }
  101. return res;
  102. }
  103. /// <summary>
  104. /// 根据来电号码获取客户信息
  105. /// </summary>
  106. /// <returns></returns>
  107. public ActionResult GetCustomerByTel(string tel)
  108. {
  109. ActionResult res = NoToken("未知错误,请重新登录");
  110. if (Request.IsAuthenticated)
  111. {
  112. BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
  113. var cusmodel=bll.GetModelByTel(tel);
  114. CustomerDto cusdto = new CustomerDto();
  115. if (cusmodel != null)
  116. {
  117. cusdto.id = cusmodel.F_CustomerId;
  118. cusdto.cusname = cusmodel.F_CustomerName;
  119. cusdto.mobile = cusmodel.F_Mobile;
  120. cusdto.telphone = cusmodel.F_Telephone;
  121. cusdto.countryid = cusmodel.F_CityID.Value;
  122. cusdto.country = cusmodel.F_City;
  123. cusdto.address = cusmodel.F_Address;
  124. res = Success("获取成功", cusdto);
  125. }
  126. else
  127. res = Success("获取失败", null);
  128. }
  129. return res;
  130. }
  131. #region 20180509调整前
  132. //public ActionResult GetCustomerByTel()
  133. //{
  134. // ActionResult res = NoToken("未知错误,请重新登录");
  135. // if (Request.IsAuthenticated)
  136. // {
  137. // DataTable dt = new DataTable();
  138. // string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  139. // BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
  140. // dt = bll.GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Tables[0];
  141. // res = Success("客户信息加载成功", dt);
  142. // }
  143. // return res;
  144. //}
  145. #endregion
  146. /// <summary>
  147. /// 根据来电号码获取最近的callid
  148. /// </summary>
  149. /// <returns></returns>
  150. public ActionResult GetCallIdByPhone()
  151. {
  152. ActionResult res = NoToken("未知错误,请重新登录");
  153. if (Request.IsAuthenticated)
  154. {
  155. DataTable dt = new DataTable();
  156. string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  157. Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByTelphone(tel);
  158. res = Success("加载成功", model);
  159. }
  160. return res;
  161. }
  162. /// <summary>
  163. /// 根据callid获取最近的通话记录
  164. /// </summary>
  165. /// <returns></returns>
  166. public ActionResult GetTelRecordByCallid()
  167. {
  168. ActionResult res = NoToken("未知错误,请重新登录");
  169. if (Request.IsAuthenticated)
  170. {
  171. DataTable dt = new DataTable();
  172. string callid = HttpUtility.UrlDecode(RequestString.GetQueryString("callid"));
  173. Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  174. res = Success("通话记录加载成功", model);
  175. }
  176. return res;
  177. }
  178. /// <summary>
  179. /// 来电归属地查询
  180. /// </summary>
  181. /// <returns></returns>
  182. public ActionResult GetPhoneLocation()
  183. {
  184. ActionResult res = NoToken("未知错误,请重新登录");
  185. if (Request.IsAuthenticated)
  186. {
  187. string location = "未知";
  188. string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  189. if (tel.Trim().Length == 11 && tel.Substring(0, 1) != "0")
  190. {
  191. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  192. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='"+ tel.Substring(0, 7) + "'").FirstOrDefault();
  193. if (mobileModel != null)
  194. {
  195. location = mobileModel.F_CityDes + mobileModel.F_CardDes;
  196. }
  197. }
  198. else
  199. {
  200. BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
  201. List<Model.T_Sys_TelTitleData> mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + tel.Substring(0, 4) + "'");
  202. if (mobileModel == null || mobileModel.Count <= 0)
  203. {
  204. mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + tel.Substring(0, 3) + "'");
  205. }
  206. if (mobileModel.Count > 0)
  207. {
  208. location = mobileModel[0].F_TitleName;
  209. }
  210. }
  211. res = Success("归属地加载成功", location);
  212. }
  213. return res;
  214. }
  215. /// <summary>
  216. /// 历史记录列表
  217. /// </summary>
  218. /// <returns></returns>
  219. public ActionResult GetOldList()
  220. {
  221. ActionResult res = NoToken("未知错误,请重新登录");
  222. if (Request.IsAuthenticated)
  223. {
  224. string sql = "";
  225. string sqlcount = "";
  226. DataTable dt = new DataTable();
  227. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  228. string strcalltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
  229. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  230. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  231. string strpageindex = RequestString.GetQueryString("page");
  232. int pageindex = 1;
  233. string strpagesize = RequestString.GetQueryString("pagesize");
  234. int pagesize = 10;
  235. if (strcalltype.Trim() != "" && strcalltype != "undefined")
  236. {
  237. sql += " and CallType=" + strcalltype + " ";
  238. }
  239. if (strtel.Trim() != "" && strtel != "undefined")
  240. {
  241. sql += " and CallNumber= '" + strtel.Trim() + "' ";
  242. sqlcount += " and CallNumber= '" + strtel.Trim() + "' ";
  243. }
  244. //else
  245. //{
  246. // sql += " and 1=0 ";
  247. //}
  248. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  249. {
  250. sql += " and datediff(day,BeginTime,'" + strstarttime + "')<=0 ";
  251. sqlcount += " and datediff(day,BeginTime,'" + strstarttime + "')<=0 ";
  252. }
  253. if (strendtime.Trim() != "" && strendtime != "undefined")
  254. {
  255. sql += " and datediff(day,BeginTime,'" + strendtime + "')>=0 ";
  256. sqlcount += " and datediff(day,BeginTime,'" + strendtime + "')>=0 ";
  257. }
  258. if (strpageindex.Trim() != "")
  259. {
  260. pageindex = Convert.ToInt32(strpageindex);
  261. }
  262. if (strpagesize.Trim() != "")
  263. {
  264. pagesize = Convert.ToInt32(strpagesize);
  265. }
  266. int recordCount = 0;
  267. dt = BLL.PagerBLL.GetListPager(
  268. "T_Call_CallRecords",
  269. "CallRecordsId",
  270. "*",
  271. sql,
  272. "ORDER BY CallRecordsId desc",
  273. pagesize,
  274. pageindex,
  275. true,
  276. out recordCount);
  277. var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  278. foreach (DataRow dr in dt.Rows)
  279. {
  280. string path = dr["FilePath"] != null ? dr["FilePath"].ToString() : "";
  281. if (path != "" && config != null && !string.IsNullOrEmpty(config.F_ParamValue))
  282. {
  283. var ym = config.F_ParamValue;
  284. if (ym.Substring(ym.Length - 1) == "/")
  285. {
  286. ym = ym.Substring(0, ym.Length - 1);
  287. }
  288. dr["FilePath"] = ym + path.Substring(path.IndexOf(':') + 1).Replace('\\', '/');
  289. }
  290. }
  291. int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 "+ sqlcount);
  292. int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 "+ sqlcount);
  293. var obj = new
  294. {
  295. state = "success",
  296. message = "成功",
  297. rows = dt,
  298. total = recordCount,
  299. hrcount=hrcount,
  300. hccount=hccount,
  301. };
  302. res = Content(obj.ToJson());
  303. }
  304. return res;
  305. }
  306. /// <summary>
  307. /// 获取最新知识库
  308. /// </summary>
  309. /// <returns></returns>
  310. public ActionResult GetZSKList()
  311. {
  312. ActionResult res = NoToken("未知错误,请重新登录");
  313. if (Request.IsAuthenticated)
  314. {
  315. DataTable dt = new DataTable();
  316. string pid = HttpUtility.UrlDecode(RequestString.GetQueryString("pid"));
  317. string keywords = HttpUtility.UrlDecode(RequestString.GetQueryString("keywords"));
  318. string sql = " F_DeleteFlag=0";
  319. if (pid.Trim() != "")
  320. {
  321. sql += " and F_CategoryId=" + pid.Trim();
  322. }
  323. if (keywords.Trim() != "")
  324. {
  325. sql += " and (F_Content like '%" + keywords.Trim() + "%' or F_Title like '%"
  326. + keywords.Trim() + "%' or F_KeyWords like '%" + keywords.Trim() + "%')";
  327. }
  328. dt = new BLL.T_RepositoryInformation().GetList(8, sql, " F_RepositoryId desc").Tables[0];
  329. res = Success("加载成功", dt);
  330. }
  331. return res;
  332. }
  333. /// <summary>
  334. /// 振铃事件
  335. /// </summary>
  336. /// <returns></returns>
  337. public ActionResult UpdateZL()
  338. {
  339. ActionResult res = NoToken("未知错误,请重新登录");
  340. if (Request.IsAuthenticated)
  341. {
  342. int userId = CurrentUser.UserData.F_UserId;
  343. if (userId != 0)
  344. {
  345. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  346. if (ua != null)
  347. {
  348. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  349. model.CallId = RequestString.GetFormString("callid");
  350. model.UserId = ua.F_UserId;
  351. model.UserCode = ua.F_UserCode;
  352. model.UserName = ua.F_UserName;
  353. //model.ExtNumber = ua.F_WorkNumber;
  354. model.ExtNumber = CurrentUser.UserData.F_ExtensionNumber;
  355. model.DealType = 5;
  356. bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
  357. if (bl)
  358. {
  359. res = Success("更新振铃状态成功");
  360. }
  361. else
  362. {
  363. res = Success("更新振铃状态失败");
  364. }
  365. }
  366. }
  367. }
  368. return res;
  369. }
  370. /// <summary>
  371. /// 摘机事件
  372. /// </summary>
  373. /// <returns></returns>
  374. public ActionResult UpdateZJ()
  375. {
  376. ActionResult res = NoToken("未知错误,请重新登录");
  377. if (Request.IsAuthenticated)
  378. {
  379. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  380. model.CallId = RequestString.GetFormString("callid");
  381. model.CallState = 1;
  382. model.DealType = 6;
  383. bool bl = new BLL.T_Call_CallRecords().UpdateCallInAnswerTelRecord(model);
  384. if (bl)
  385. {
  386. Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(model.CallId);
  387. string type = vmodel.OperateType.ToString();
  388. if (type == "7")
  389. {
  390. new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
  391. }
  392. res = Success("更新摘机状态成功");
  393. }
  394. else
  395. {
  396. res = Success("更新摘机状态失败");
  397. }
  398. }
  399. return res;
  400. }
  401. /// <summary>
  402. /// 挂机事件
  403. /// </summary>
  404. /// <returns></returns>
  405. public ActionResult UpdateGJ()
  406. {
  407. ActionResult res = NoToken("未知错误,请重新登录");
  408. if (Request.IsAuthenticated)
  409. {
  410. string strid = RequestString.GetFormString("callid");
  411. bool bl = new BLL.T_Call_CallRecords().UpdateCallInHookTelRecord(strid);
  412. if (bl)
  413. {
  414. res = Success("更新挂机状态成功");
  415. }
  416. else
  417. {
  418. res = Success("更新挂机状态失败");
  419. }
  420. }
  421. return res;
  422. }
  423. /// <summary>
  424. /// 录音事件
  425. /// </summary>
  426. /// <returns></returns>
  427. public ActionResult UpdateLY()
  428. {
  429. ActionResult res = NoToken("未知错误,请重新登录");
  430. if (Request.IsAuthenticated)
  431. {
  432. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  433. model.CallId = RequestString.GetFormString("callid");
  434. model.CallState = 1;
  435. model.DealType = 6;
  436. model.FilePath = RequestString.GetFormString("path");
  437. bool bl = new BLL.T_Call_CallRecords().UpdateCallInPathTelRecord(model);
  438. if (bl)
  439. {
  440. Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(model.CallId);
  441. string type = vmodel.OperateType.ToString();
  442. if (type == "7")
  443. {
  444. new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
  445. }
  446. res = Success("更新挂机状态成功");
  447. }
  448. else
  449. {
  450. res = Success("更新挂机状态失败");
  451. }
  452. }
  453. return res;
  454. }
  455. #region 创建工单
  456. //zhengbingbing 20180503 根据息县工单调整
  457. /// <summary>
  458. /// 创建工单
  459. /// </summary>
  460. /// <returns></returns>
  461. public ActionResult AddWorkOrder(string callid, string source, string file
  462. , string customer, string custel, string country, string address, string inqtime, string inquser
  463. , string detail, string cont, string answer, string remark
  464. , string infotype, string unit, string clbm, string clr, int khid = 0)
  465. //, int infotypeid = 0, int unitid = 0, int clbm = 0, int clid = 0)
  466. {
  467. ActionResult res = NoToken("未知错误,请重新登录");
  468. if (Request.IsAuthenticated)
  469. {
  470. int userId = CurrentUser.UserData.F_UserId;
  471. if (userId != 0)
  472. {
  473. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  474. if (ua != null)
  475. {
  476. Model.T_Wo_WorkOrder model = new Model.T_Wo_WorkOrder();
  477. model.WorkOrderID = DateTime.Now.ToString("yyyyMMddHHmmss");//工单编号
  478. model.CallID = callid;
  479. model.CustomerID = khid;
  480. model.CustomerTel = custel;
  481. #region 息县工单
  482. if (!string.IsNullOrWhiteSpace(customer))
  483. model.Customer = customer;
  484. if (!string.IsNullOrWhiteSpace(inqtime))
  485. model.Inqtime = DateTime.Parse(inqtime);
  486. if (!string.IsNullOrWhiteSpace(inquser))
  487. model.Inquser = inquser;
  488. if (!string.IsNullOrWhiteSpace(country))
  489. model.County = country;
  490. if (!string.IsNullOrWhiteSpace(address))
  491. model.Address = address;
  492. if (!string.IsNullOrWhiteSpace(detail))
  493. model.Detail = detail;
  494. if (!string.IsNullOrWhiteSpace(answer))
  495. model.Answer = answer;
  496. if (!string.IsNullOrWhiteSpace(cont))
  497. model.Clcontent = cont;
  498. if (!string.IsNullOrWhiteSpace(remark))
  499. model.Remark = remark;
  500. #endregion
  501. #region 信息分类和交办单位
  502. model.InfoType = infotype;
  503. model.Unit = unit;
  504. //20180518 zhengbingbing 不传ID调整为只有文字
  505. //model.InfoTypeID = infotypeid;
  506. //if (infotypeid != 0)
  507. //{
  508. // Model.T_Sys_DictionaryValue dicVModel = dictionaryValueBLL.GetModel(infotypeid);
  509. // if (dicVModel != null)
  510. // {
  511. // model.InfoType = dicVModel.F_Name;
  512. // }
  513. //}
  514. //model.UnitID = unitid;
  515. //if (unitid != 0)
  516. //{
  517. // Model.T_Sys_DictionaryValue dicVModel = dictionaryValueBLL.GetModel(unitid);
  518. // if (dicVModel != null)
  519. // {
  520. // model.Unit = dicVModel.F_Name;
  521. // }
  522. //}
  523. #endregion
  524. if (source.Trim() == "1")
  525. model.Source = "手工制单";
  526. else if (source.Trim() == "2")
  527. model.Source = "电话";
  528. else if (source.Trim() == "3")
  529. model.Source = "微信";
  530. #region 无需参数字段
  531. model.Type = 3;//默认为投诉工单
  532. model.State = 0;
  533. model.IsDel = 0;
  534. model.IsReturn = 0;
  535. model.IsReturnBak = 0;
  536. model.IsTimeOut = 0;
  537. model.IsUserSend = 0;
  538. model.IsAdminSend = 0;
  539. model.CreateUser = ua.F_UserCode;
  540. model.CreateTime = DateTime.Now;
  541. #endregion
  542. #region 工单明细
  543. //if (clbm != 0 || clid != 0)
  544. //{
  545. // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
  546. // item.WorkOrderID = model.WorkOrderID;
  547. // item.ToDept = clbm;
  548. // item.Type = 1;
  549. // if (clid != 0)
  550. // {
  551. // Model.T_Sys_UserAccount clus = new BLL.T_Sys_UserAccount().GetModel(clid);
  552. // if (clus != null)
  553. // {
  554. // item.ToUser = clus.F_UserCode;
  555. // }
  556. // }
  557. // else
  558. // {
  559. // string users = string.Empty;
  560. // var list = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId='" + clbm + "'");
  561. // foreach (var l in list)
  562. // {
  563. // if (string.IsNullOrEmpty(users))
  564. // {
  565. // users = l.F_UserCode;
  566. // }
  567. // else
  568. // {
  569. // users = users + "," + l.F_UserCode;
  570. // }
  571. // }
  572. // item.ToUser = users;
  573. // }
  574. // if (item.ToUser != "")
  575. // {
  576. // item.SureUser = ua.F_UserCode;
  577. // item.State = 1;
  578. // item.SureTime = DateTime.Now;
  579. // item.IsStart = 1;
  580. // }
  581. // else
  582. // {
  583. // item.State = 0;
  584. // item.IsStart = 0;
  585. // }
  586. // item.Detail = model.Detail;
  587. // item.IsLast = 0;
  588. // item.IsTimeOut = 0;
  589. // item.IsDel = 0;
  590. // item.CreateUser = ua.F_UserCode;
  591. // item.CreateTime = DateTime.Now;
  592. // long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
  593. // if (itemid > 0)
  594. // {
  595. // model.State = 1;//已指派
  596. // model.AppointTime = DateTime.Now;
  597. // }
  598. //}
  599. #endregion
  600. #region 插入操作记录
  601. Model.T_Wo_Operation oper = new Model.T_Wo_Operation();
  602. oper.F_WorkOrderId = model.WorkOrderID;
  603. oper.F_State = model.State;
  604. oper.F_CallRecordId = model.CallID != "" ? int.Parse(model.CallID) : 0;
  605. oper.F_File = model.Files;
  606. string userinfo = ua.depname + "-" + ua.F_UserName + "(" + ua.F_UserCode + ")";
  607. if (model.State == 0)
  608. {
  609. oper.F_Message = userinfo + " 登记了工单,工单编号:" + model.WorkOrderID;
  610. }
  611. if (model.State == 1)
  612. {
  613. oper.F_Message = userinfo + " 登记并提交了工单,工单编号:" + model.WorkOrderID;
  614. }
  615. if (model.State == 2)
  616. {
  617. oper.F_Message = userinfo + " 登记并完结了工单,工单编号:" + model.WorkOrderID;
  618. }
  619. oper.F_CreateUser = ua.F_UserCode;
  620. oper.F_CreateTime = DateTime.Now;
  621. oper.F_IsDelete = 0;
  622. new BLL.T_Wo_Operation().Add(oper);
  623. #endregion
  624. if (new BLL.T_Wo_WorkOrder().Add(model) > 0)
  625. {
  626. if (!string.IsNullOrEmpty(callid))
  627. {
  628. var rec = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  629. if (rec != null)
  630. {
  631. rec.IsExitWorkOrder = true;
  632. new BLL.T_Call_CallRecords().Update(rec);
  633. }
  634. }
  635. res = Success("新增成功!");
  636. }
  637. else
  638. {
  639. res = Error("新增失败!");
  640. }
  641. }
  642. }
  643. }
  644. return res;
  645. }
  646. #endregion
  647. #region 创建工单调整前
  648. ///// <summary>
  649. ///// 创建工单
  650. ///// </summary>
  651. ///// <returns></returns>
  652. //public ActionResult AddWorkOrder()
  653. //{
  654. // ActionResult res = NoToken("未知错误,请重新登录");
  655. // if (Request.IsAuthenticated)
  656. // {
  657. // #region 获取参数
  658. // int type = RequestString.GetInt("type", 0);
  659. // //int tslx = RequestString.GetInt("tslx", 0);
  660. // string callid = RequestString.GetFormString("callid");
  661. // int khid = RequestString.GetInt("khid", 0);
  662. // string tskh = RequestString.GetFormString("tskh");
  663. // string tsdh = RequestString.GetFormString("tsdh");
  664. // //int zrbm = RequestString.GetInt("zrbm", 0);
  665. // //int zrid = RequestString.GetInt("zrid", 0);
  666. // string cont = RequestString.GetFormString("cont");
  667. // //string answer = RequestString.GetFormString("answer");
  668. // string clcont = RequestString.GetFormString("clcont");
  669. // int clbm = RequestString.GetInt("clbm", 0);
  670. // int clid = RequestString.GetInt("clid", 0);
  671. // string source = RequestString.GetFormString("source");
  672. // //string address = RequestString.GetFormString("address");
  673. // #region 新增字段
  674. // int infotypeid = RequestString.GetInt("infotypeid", 0);//信息分类
  675. // //int isreward = RequestString.GetInt("isreward", 0);//上报奖励
  676. // //string reamount = RequestString.GetFormString("reamount");//奖励金额
  677. // //string retime = RequestString.GetFormString("retime");//奖励时间
  678. // int unitid = RequestString.GetInt("unitid", 0);//交办单位
  679. // int isaudit = RequestString.GetInt("isaudit", 0);//0未审核,1无效,2有效
  680. // #endregion
  681. // #endregion
  682. // #region 判断输入数据类型
  683. // if (!Validate.IsNumber(tsdh))
  684. // {
  685. // res = Error("电话必须为数字");
  686. // return res;
  687. // }
  688. // #endregion
  689. // int userId = CurrentUser.UserData.F_UserId;
  690. // if (userId != 0)
  691. // {
  692. // Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  693. // if (ua != null)
  694. // {
  695. // Model.T_Wo_WorkOrder model = new Model.T_Wo_WorkOrder();
  696. // model.WorkOrderID = DateTime.Now.ToString("yyyyMMddHHmmssmsfff");//工单编号
  697. // model.CallID = callid;
  698. // model.Customer = tskh;
  699. // model.CustomerID = khid;
  700. // model.CustomerTel = tsdh;
  701. // model.Detail = cont;
  702. // model.Clcontent = clcont;
  703. // model.Type = type;
  704. // //model.TypeClass = tslx;
  705. // if (type == 1)
  706. // {
  707. // model.State = 2;
  708. // }
  709. // else
  710. // model.State = 0;
  711. // model.IsDel = 0;
  712. // model.IsReturn = 0;
  713. // model.IsReturnBak = 0;
  714. // //model.ResponDept = zrbm;
  715. // //model.Answer = answer;
  716. // model.IsTimeOut = 0;
  717. // model.IsUserSend = 0;
  718. // model.IsAdminSend = 0;
  719. // model.IsAudit = isaudit;//0未审核,1无效,2有效
  720. // if (source.Trim() == "1")
  721. // model.Source = "手工制单";
  722. // else if (source.Trim() == "2")
  723. // model.Source = "电话";
  724. // else if (source.Trim() == "3")
  725. // model.Source = "微信";
  726. // #region 新增字段
  727. // model.InfoTypeID = infotypeid;
  728. // if (infotypeid != 0)
  729. // {
  730. // Model.T_Sys_DictionaryValue dicVModel = dictionaryValueBLL.GetModel(infotypeid);
  731. // if (dicVModel != null)
  732. // {
  733. // model.InfoType = dicVModel.F_Name;
  734. // }
  735. // }
  736. // model.ISReward = 0;
  737. // //model.RewardAmount = reamount;
  738. // //model.RewardTime = retime;
  739. // model.UnitID = unitid;
  740. // if (unitid != 0)
  741. // {
  742. // Model.T_Sys_DictionaryValue dicVModel = dictionaryValueBLL.GetModel(unitid);
  743. // if (dicVModel != null)
  744. // {
  745. // model.Unit = dicVModel.F_Name;
  746. // }
  747. // }
  748. // #endregion
  749. // #region 工单超时
  750. // Model.T_Wo_WorkOrderTimeOut to = new BLL.T_Wo_WorkOrderTimeOut().GetModel(type);
  751. // if (to != null)
  752. // {
  753. // model.LimitTime = to.MainTime;
  754. // }
  755. // #endregion
  756. // model.CreateUser = ua.F_UserCode;
  757. // model.CreateTime = DateTime.Now;
  758. // #region 工单明细
  759. // if (clbm != 0 || clid != 0)
  760. // {
  761. // Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
  762. // item.WorkOrderID = model.WorkOrderID;
  763. // item.ToDept = clbm;
  764. // item.Type = 1;
  765. // if (clid != 0)
  766. // {
  767. // Model.T_Sys_UserAccount clus = new BLL.T_Sys_UserAccount().GetModel(clid);
  768. // if (clus != null)
  769. // {
  770. // item.ToUser = clus.F_UserCode;
  771. // }
  772. // }
  773. // else
  774. // {
  775. // string users = string.Empty;
  776. // var list = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId='" + clbm + "'");
  777. // foreach (var l in list)
  778. // {
  779. // if (string.IsNullOrEmpty(users))
  780. // {
  781. // users = l.F_UserCode;
  782. // }
  783. // else
  784. // {
  785. // users = users + "," + l.F_UserCode;
  786. // }
  787. // }
  788. // item.ToUser = users;
  789. // }
  790. // if (to != null)
  791. // {
  792. // item.LimitTime = to.ItemTime;
  793. // }
  794. // if (item.ToUser != "")
  795. // {
  796. // item.SureUser = ua.F_UserCode;
  797. // item.State = 1;
  798. // item.SureTime = DateTime.Now;
  799. // item.IsStart = 1;
  800. // }
  801. // else
  802. // {
  803. // item.State = 0;
  804. // item.IsStart = 0;
  805. // }
  806. // item.Detail = clcont;
  807. // item.IsLast = 0;
  808. // //item.State = 0;
  809. // //item.IsStart = 0;
  810. // item.IsTimeOut = 0;
  811. // item.IsDel = 0;
  812. // item.CreateUser = ua.F_UserCode;
  813. // item.CreateTime = DateTime.Now;
  814. // long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
  815. // if (itemid > 0)
  816. // {
  817. // model.State = 1;//已指派
  818. // model.AppointTime = DateTime.Now;
  819. // #region 消息表
  820. // //foreach (string ur in item.ToUser.Split(','))
  821. // //{
  822. // // Model.T_Msg_List msg = new Model.T_Msg_List();
  823. // // msg.Type = 1;
  824. // // msg.ToUser = ur;
  825. // // msg.ToID = Int32.Parse(itemid.ToString());
  826. // // msg.Detail = ua.F_UserName + "给你指派了工单,单号:" + model.WorkOrderID;
  827. // // msg.State = 0;
  828. // // msg.IsDel = 0;
  829. // // msg.CreateUser = ua.F_UserCode;
  830. // // msg.CreateDate = DateTime.Now;
  831. // // new BLL.T_Msg_List().Add(msg);
  832. // //}
  833. // #endregion
  834. // }
  835. // }
  836. // #endregion
  837. // #region 插入操作记录
  838. // Model.T_Wo_Operation oper = new Model.T_Wo_Operation();
  839. // oper.F_WorkOrderId = model.WorkOrderID;
  840. // oper.F_State = model.State;
  841. // oper.F_CallRecordId = model.CallID != "" ? int.Parse(model.CallID) : 0;
  842. // oper.F_File = model.Files;
  843. // string userinfo = ua.depname + "-" + ua.F_UserName + "(" + ua.F_UserCode + ")";
  844. // if (model.State == 0)
  845. // {
  846. // oper.F_Message = userinfo + " 登记了工单,工单编号:" + model.WorkOrderID;
  847. // }
  848. // if (model.State == 1)
  849. // {
  850. // oper.F_Message = userinfo + " 登记并提交了工单,工单编号:" + model.WorkOrderID;
  851. // }
  852. // if (model.State == 2)
  853. // {
  854. // oper.F_Message = userinfo + " 登记并完结了工单,工单编号:" + model.WorkOrderID;
  855. // }
  856. // oper.F_CreateUser = ua.F_UserCode;
  857. // oper.F_CreateTime = DateTime.Now;
  858. // oper.F_IsDelete = 0;
  859. // new BLL.T_Wo_Operation().Add(oper);
  860. // #endregion
  861. // if (new BLL.T_Wo_WorkOrder().Add(model) > 0)
  862. // {
  863. // if (!string.IsNullOrEmpty(callid))
  864. // {
  865. // var rec = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  866. // if (rec != null)
  867. // {
  868. // rec.IsExitWorkOrder = true;
  869. // new BLL.T_Call_CallRecords().Update(rec);
  870. // }
  871. // }
  872. // res = Success("新增成功!");
  873. // }
  874. // else
  875. // {
  876. // res = Error("新增失败!");
  877. // }
  878. // #region no use
  879. // //Model.T_Wo_WorkOrderBase model = new Model.T_Wo_WorkOrderBase();
  880. // //model.F_CODE = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
  881. // //model.F_WORKORDERTYPEID = type;
  882. // //model.F_WORKORDERSTATEID = 0;
  883. // //model.F_WORKORDERNAME = "";
  884. // //model.F_WORKORDERFROM = "";
  885. // //model.F_WORKORDERLEVELID = 0;
  886. // //model.F_ADSLACCOUNT = callid;
  887. // ////model.F_USERID = ua.F_UserId;
  888. // ////model.F_USERNAME = ua.F_UserName;
  889. // ////model.F_USERPHONE = ua.F_WorkNumber;
  890. // //model.F_TypeName = "";
  891. // //model.F_STARTTIME = DateTime.Now;
  892. // //model.F_RETURNVISITFLAG = 0;
  893. // //model.F_LINKMANTELEPHONE = tsdh;
  894. // //model.F_LINKMAN = tskh;
  895. // //model.F_DELETEFLAG = 0;
  896. // //model.F_CUSTOMERTELEPHONE = tsdh;
  897. // //model.F_CUSTOMERNAME = tskh;
  898. // //model.F_CUSTOMERID = 0;//待实现
  899. // //model.F_CREATEDATE = DateTime.Now;
  900. // //model.F_CREATEBY = ua.F_UserId;
  901. // //model.F_CONTENT = cont;
  902. // //model.F_REPAIRMANNAME = tskh;
  903. // //model.F_REPAIRMANPHONE = tsdh;
  904. // //if (new BLL.T_Wo_WorkOrderBase().Add(model) > 0)
  905. // //{
  906. // // res = Success("新增成功!");
  907. // //}
  908. // //else
  909. // //{
  910. // // res = Error("新增失败!");
  911. // //}
  912. // #endregion
  913. // }
  914. // }
  915. // }
  916. // return res;
  917. //}
  918. #endregion
  919. }
  920. }