Нет описания

CallInScreenController.cs 43KB

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