PingAnYeXianSZCG_API 接口代码

CallInScreenController.cs 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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 = Error("更新振铃状态失败");
  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 = Error("更新摘机状态失败");
  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. /// <summary>
  429. /// 创建工单
  430. /// </summary>
  431. /// <returns></returns>
  432. public ActionResult AddWorkOrder()
  433. {
  434. ActionResult res = NoToken("未知错误,请重新登录");
  435. if (Request.IsAuthenticated)
  436. {
  437. #region 获取参数
  438. int type = RequestString.GetInt("type", 0);
  439. //int tslx = RequestString.GetInt("tslx", 0);
  440. string callid = RequestString.GetFormString("callid");
  441. int khid = RequestString.GetInt("khid", 0);
  442. string tskh = RequestString.GetFormString("tskh");
  443. string tsdh = RequestString.GetFormString("tsdh");
  444. //int zrbm = RequestString.GetInt("zrbm", 0);
  445. //int zrid = RequestString.GetInt("zrid", 0);
  446. string cont = RequestString.GetFormString("cont");
  447. //string answer = RequestString.GetFormString("answer");
  448. string clcont = RequestString.GetFormString("clcont");
  449. int clbm = RequestString.GetInt("clbm", 0);
  450. int clid = RequestString.GetInt("clid", 0);
  451. string source = RequestString.GetFormString("source");
  452. //string address = RequestString.GetFormString("address");
  453. #region 新增字段
  454. int infotypeid = RequestString.GetInt("infotypeid", 0);//信息分类
  455. //int isreward = RequestString.GetInt("isreward", 0);//上报奖励
  456. //string reamount = RequestString.GetFormString("reamount");//奖励金额
  457. //string retime = RequestString.GetFormString("retime");//奖励时间
  458. int unitid = RequestString.GetInt("unitid", 0);//交办单位
  459. int isaudit = RequestString.GetInt("isaudit", 0);//0未审核,1无效,2有效
  460. #endregion
  461. #endregion
  462. #region 判断输入数据类型
  463. if (!Validate.IsNumber(tsdh))
  464. {
  465. res = Error("电话必须为数字");
  466. return res;
  467. }
  468. #endregion
  469. int userId = CurrentUser.UserData.F_UserId;
  470. if (userId != 0)
  471. {
  472. Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
  473. if (ua != null)
  474. {
  475. Model.T_Wo_WorkOrder model = new Model.T_Wo_WorkOrder();
  476. model.WorkOrderID = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
  477. model.CallID = callid;
  478. model.Customer = tskh;
  479. model.CustomerID = khid;
  480. model.CustomerTel = tsdh;
  481. model.Detail = cont;
  482. model.Clcontent = clcont;
  483. model.Type = type;
  484. //model.TypeClass = tslx;
  485. if (type == 1)
  486. {
  487. model.State = 2;
  488. }
  489. else
  490. model.State = 0;
  491. model.IsDel = 0;
  492. model.IsReturn = 0;
  493. model.IsReturnBak = 0;
  494. //model.ResponDept = zrbm;
  495. //model.Answer = answer;
  496. model.IsTimeOut = 0;
  497. model.IsUserSend = 0;
  498. model.IsAdminSend = 0;
  499. model.IsAudit = isaudit;//0未审核,1无效,2有效
  500. if (source.Trim() == "1")
  501. model.Source = "手工制单";
  502. else if (source.Trim() == "2")
  503. model.Source = "电话";
  504. else if (source.Trim() == "3")
  505. model.Source = "微信";
  506. #region 新增字段
  507. model.InfoTypeID = infotypeid;
  508. if (infotypeid != 0)
  509. {
  510. Model.T_Sys_DictionaryValue dicVModel = dictionaryValueBLL.GetModel(infotypeid);
  511. if (dicVModel != null)
  512. {
  513. model.InfoType = dicVModel.F_Name;
  514. }
  515. }
  516. model.ISReward = 0;
  517. //model.RewardAmount = reamount;
  518. //model.RewardTime = retime;
  519. model.UnitID = unitid;
  520. if (unitid != 0)
  521. {
  522. Model.T_Sys_DictionaryValue dicVModel = dictionaryValueBLL.GetModel(unitid);
  523. if (dicVModel != null)
  524. {
  525. model.Unit = dicVModel.F_Name;
  526. }
  527. }
  528. #endregion
  529. #region 工单超时
  530. Model.T_Wo_WorkOrderTimeOut to = new BLL.T_Wo_WorkOrderTimeOut().GetModel(type);
  531. if (to != null)
  532. {
  533. model.LimitTime = to.MainTime;
  534. }
  535. #endregion
  536. model.CreateUser = ua.F_UserCode;
  537. model.CreateTime = DateTime.Now;
  538. #region 工单明细
  539. if (clbm != 0 || clid != 0)
  540. {
  541. Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
  542. item.WorkOrderID = model.WorkOrderID;
  543. item.ToDept = clbm;
  544. item.Type = 1;
  545. if (clid != 0)
  546. {
  547. Model.T_Sys_UserAccount clus = new BLL.T_Sys_UserAccount().GetModel(clid);
  548. if (clus != null)
  549. {
  550. item.ToUser = clus.F_UserCode;
  551. }
  552. }
  553. else
  554. {
  555. string users = string.Empty;
  556. var list = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId='" + clbm + "'");
  557. foreach (var l in list)
  558. {
  559. if (string.IsNullOrEmpty(users))
  560. {
  561. users = l.F_UserCode;
  562. }
  563. else
  564. {
  565. users = users + "," + l.F_UserCode;
  566. }
  567. }
  568. item.ToUser = users;
  569. }
  570. if (to != null)
  571. {
  572. item.LimitTime = to.ItemTime;
  573. }
  574. item.Detail = clcont;
  575. item.IsLast = 0;
  576. item.State = 0;
  577. item.IsStart = 0;
  578. item.IsTimeOut = 0;
  579. item.IsDel = 0;
  580. item.CreateUser = ua.F_UserCode;
  581. item.CreateTime = DateTime.Now;
  582. long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
  583. if (itemid > 0)
  584. {
  585. model.State = 1;//已指派
  586. model.AppointTime = DateTime.Now;
  587. #region 消息表
  588. foreach (string ur in item.ToUser.Split(','))
  589. {
  590. Model.T_Msg_List msg = new Model.T_Msg_List();
  591. msg.Type = 1;
  592. msg.ToUser = ur;
  593. msg.ToID = Int32.Parse(itemid.ToString());
  594. msg.Detail = ua.F_UserName + "给你指派了工单,单号:" + model.WorkOrderID;
  595. msg.State = 0;
  596. msg.IsDel = 0;
  597. msg.CreateUser = ua.F_UserCode;
  598. msg.CreateDate = DateTime.Now;
  599. new BLL.T_Msg_List().Add(msg);
  600. }
  601. #endregion
  602. }
  603. }
  604. #endregion
  605. #region 插入操作记录
  606. Model.T_Wo_Operation oper = new Model.T_Wo_Operation();
  607. oper.F_WorkOrderId = model.WorkOrderID;
  608. oper.F_State = model.State;
  609. oper.F_CallRecordId = model.CallID != null ? int.Parse(model.CallID) : 0;
  610. oper.F_File = model.Files;
  611. string userinfo = ua.depname + "-" + ua.F_UserName + "(" + ua.F_UserCode + ")";
  612. if (model.State == 0)
  613. {
  614. oper.F_Message = userinfo + " 登记了工单,工单编号:" + model.WorkOrderID;
  615. }
  616. if (model.State == 1)
  617. {
  618. oper.F_Message = userinfo + " 登记并提交了工单,工单编号:" + model.WorkOrderID;
  619. }
  620. if (model.State == 2)
  621. {
  622. oper.F_Message = userinfo + " 登记并完结了工单,工单编号:" + model.WorkOrderID;
  623. }
  624. oper.F_CreateUser = ua.F_UserCode;
  625. oper.F_CreateTime = DateTime.Now;
  626. oper.F_IsDelete = 0;
  627. new BLL.T_Wo_Operation().Add(oper);
  628. #endregion
  629. if (new BLL.T_Wo_WorkOrder().Add(model) > 0)
  630. {
  631. if (!string.IsNullOrEmpty(callid))
  632. {
  633. var rec = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  634. if (rec != null)
  635. {
  636. rec.IsExitWorkOrder = true;
  637. new BLL.T_Call_CallRecords().Update(rec);
  638. }
  639. }
  640. res = Success("新增成功!");
  641. }
  642. else
  643. {
  644. res = Error("新增失败!");
  645. }
  646. #region no use
  647. //Model.T_Wo_WorkOrderBase model = new Model.T_Wo_WorkOrderBase();
  648. //model.F_CODE = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
  649. //model.F_WORKORDERTYPEID = type;
  650. //model.F_WORKORDERSTATEID = 0;
  651. //model.F_WORKORDERNAME = "";
  652. //model.F_WORKORDERFROM = "";
  653. //model.F_WORKORDERLEVELID = 0;
  654. //model.F_ADSLACCOUNT = callid;
  655. ////model.F_USERID = ua.F_UserId;
  656. ////model.F_USERNAME = ua.F_UserName;
  657. ////model.F_USERPHONE = ua.F_WorkNumber;
  658. //model.F_TypeName = "";
  659. //model.F_STARTTIME = DateTime.Now;
  660. //model.F_RETURNVISITFLAG = 0;
  661. //model.F_LINKMANTELEPHONE = tsdh;
  662. //model.F_LINKMAN = tskh;
  663. //model.F_DELETEFLAG = 0;
  664. //model.F_CUSTOMERTELEPHONE = tsdh;
  665. //model.F_CUSTOMERNAME = tskh;
  666. //model.F_CUSTOMERID = 0;//待实现
  667. //model.F_CREATEDATE = DateTime.Now;
  668. //model.F_CREATEBY = ua.F_UserId;
  669. //model.F_CONTENT = cont;
  670. //model.F_REPAIRMANNAME = tskh;
  671. //model.F_REPAIRMANPHONE = tsdh;
  672. //if (new BLL.T_Wo_WorkOrderBase().Add(model) > 0)
  673. //{
  674. // res = Success("新增成功!");
  675. //}
  676. //else
  677. //{
  678. // res = Error("新增失败!");
  679. //}
  680. #endregion
  681. }
  682. }
  683. }
  684. return res;
  685. }
  686. }
  687. }