Нет описания

CallInScreenController.cs 42KB

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