Нет описания

SeatGroupController.cs 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using CallCenterApi.Interface.Models.Input;
  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
  12. {
  13. public class SeatGroupController : BaseController
  14. {
  15. BLL.T_Sys_SeatGroup seatBLL = new BLL.T_Sys_SeatGroup();
  16. /// <summary>
  17. /// 获取坐席组列表
  18. /// </summary>
  19. /// <returns></returns>
  20. public ActionResult GetList()
  21. {
  22. ActionResult res = NoToken("未知错误,请重新登录");
  23. DataTable dt = new DataTable();
  24. string strpageindex = RequestString.GetQueryString("page");
  25. int pageindex = 1;
  26. string strpagesize = RequestString.GetQueryString("pagesize");
  27. int pagesize = 10;
  28. string strcontent = RequestString.GetQueryString("content");
  29. string sql = "";
  30. if (strcontent!=null&&strcontent != "")
  31. {
  32. sql = " and( F_ZXZCode like '" + strcontent + "' or F_ZXZName like '%" + strcontent + "%' or F_WHBDKey like '" + strcontent + "%' or F_WHWDKey like '" + strcontent + "%' or F_ZXAtt like '" + strcontent + "' or F_Des like '" + strcontent + "')";
  33. }
  34. if (strpageindex.Trim() != "")
  35. {
  36. pageindex = Convert.ToInt32(strpageindex);
  37. }
  38. if (strpagesize.Trim() != "")
  39. {
  40. pagesize = Convert.ToInt32(strpagesize);
  41. }
  42. int recordCount = 0;
  43. dt = BLL.PagerBLL.GetListPager(
  44. "T_Sys_SeatGroup",
  45. "F_ZXZID",
  46. "*",
  47. sql,
  48. "ORDER BY F_ZXZID desc",
  49. pagesize,
  50. pageindex,
  51. true,
  52. out recordCount);
  53. var obj = new
  54. {
  55. rows = dt,
  56. total = recordCount
  57. };
  58. res = Content(obj.ToJson());
  59. return res;
  60. }
  61. //获取坐席组列表
  62. public ActionResult GetSeatList()
  63. {
  64. ActionResult res = NoToken("未知错误,请重新登录");
  65. if (Request.IsAuthenticated)
  66. {
  67. List<Model.T_Sys_SeatGroup> seatList = seatBLL.GetModelList(" 1=1 order by F_ZXZID desc ");
  68. if (seatList.Count > 0)
  69. res = Success("坐席组列表加载成功", seatList);
  70. else
  71. res = Error("坐席组列表加载失败");
  72. }
  73. return res;
  74. }
  75. /// <summary>
  76. /// 获取坐席组
  77. /// </summary>
  78. /// <param name="deptId"></param>
  79. /// <returns></returns>
  80. public ActionResult GetSeatGroup(int ZXZID = 0)
  81. {
  82. if (Request.IsAuthenticated)
  83. {
  84. Model.T_Sys_SeatGroup sModel = seatBLL.GetModel(ZXZID);
  85. string Region="";
  86. if (sModel != null)
  87. {
  88. if (!string .IsNullOrEmpty (sModel.F_Region) )
  89. {
  90. string[] mRegion = sModel.F_Region.Split(',');
  91. if (mRegion.Length >0)
  92. {
  93. foreach (var it in mRegion)
  94. {
  95. try
  96. {
  97. if (int.Parse(it) < 32)
  98. {
  99. var model = new BLL.T_RegionCategory().GetModel(int.Parse(it));
  100. if (model != null)
  101. {
  102. if (Region == "")
  103. Region = model.F_RegionName;
  104. else
  105. Region = Region + "," + model.F_RegionName;
  106. }
  107. }
  108. }
  109. catch
  110. {
  111. }
  112. }
  113. }
  114. }
  115. var obj = new
  116. {
  117. sModel,
  118. Region
  119. };
  120. return Success("获取坐席组信息成功",
  121. obj);
  122. }
  123. return Error("获取坐席组信息失败");
  124. }
  125. return NoToken("未知错误,请重新登录");
  126. }
  127. /// <summary>
  128. /// 验证code是否唯一
  129. /// </summary>
  130. private bool getunphone( string ZXZCode)
  131. {
  132. var sql = " ";
  133. sql += " (F_ZXZCode='" + ZXZCode + "')";
  134. var count = seatBLL.GetModelList(sql).Count();
  135. return count > 0;
  136. }
  137. /// <summary>
  138. /// 添加坐席组
  139. /// </summary>
  140. /// <param name="input"></param>
  141. /// <returns></returns>
  142. [HttpPost]
  143. public ActionResult AddSeatGroup(SeatGroupInput input)
  144. {
  145. ActionResult res = NoToken("未知错误,请重新登录");
  146. if (Request.IsAuthenticated)
  147. {
  148. Model.T_Sys_SeatGroup sModel = new Model.T_Sys_SeatGroup();
  149. if (input.ZXZCode != null)
  150. {
  151. if (getunphone( input.ZXZCode))
  152. return Error("已存在该编号勿重复添加");
  153. else
  154. sModel.F_ZXZCode = input.ZXZCode.Trim();
  155. }
  156. else
  157. {
  158. res = Error("编号不能为空");
  159. return res;
  160. }
  161. if (input.ZXZName != null)
  162. sModel.F_ZXZName = input.ZXZName.Trim();
  163. else
  164. {
  165. res = Error("名称不能为空");
  166. return res;
  167. }
  168. if (input.ZXAtt != null)
  169. sModel.F_ZXAtt = input.ZXAtt.Trim();
  170. else
  171. {
  172. res = Error("坐席地区号不能为空");
  173. return res;
  174. }
  175. if (input.WHWDKey != null)
  176. sModel.F_WHWDKey = input.WHWDKey.Trim();
  177. else
  178. {
  179. res = Error("外呼外地前缀不能为空");
  180. return res;
  181. }
  182. if (input.WHBDKey != null)
  183. sModel.F_WHBDKey = input.WHBDKey.Trim();
  184. else
  185. {
  186. res = Error("外呼本地前缀不能为空");
  187. return res;
  188. }
  189. if (input.IVRKey != null)
  190. sModel.F_IVRKey = input.IVRKey;
  191. if (input.Des != null)
  192. sModel.F_Des = input.Des.Trim();
  193. if (input.Region != null)
  194. sModel.F_Region = input.Region.Trim();
  195. if (!Validate.IsNumber(input.WHWDKey.ToString()))
  196. {
  197. res = Error("外呼外地前缀必须为数字");
  198. return res;
  199. }
  200. if (!Validate.IsNumber(input.WHBDKey.ToString()))
  201. {
  202. res = Error("外呼本地前缀必须为数字");
  203. return res;
  204. }
  205. sModel.F_CreateTime = DateTime.Now;
  206. sModel.F_CreateByName = CurrentUser.UserData.F_UserName;
  207. sModel.F_CreateBy = CurrentUser.UserData.F_UserId;
  208. if (seatBLL.Add(sModel) > 0)
  209. res = Success("添加成功");
  210. else
  211. res = Error("添加失败");//res = Success("添加失败");//2017-11-15
  212. }
  213. return res;
  214. }
  215. /// <summary>
  216. /// 编辑坐席组
  217. /// </summary>
  218. /// <param name="input"></param>
  219. /// <returns></returns>
  220. [HttpPost]
  221. public ActionResult EditSeatGroup(SeatGroupInput input)
  222. {
  223. if (Request.IsAuthenticated)
  224. {
  225. if (input.ZXZID <= 0)
  226. return Error("请选择要编辑的坐席组");
  227. Model.T_Sys_SeatGroup sModel = seatBLL.GetModel(input.ZXZID);
  228. if (sModel == null)
  229. return Error("获取信息失败");
  230. if (input.ZXZCode != null)
  231. sModel.F_ZXZCode = input.ZXZCode.Trim();
  232. if (input.ZXZName != null)
  233. sModel.F_ZXZName = input.ZXZName.Trim();
  234. if (input.ZXAtt != null)
  235. sModel.F_ZXAtt = input.ZXAtt.Trim();
  236. if (input.WHWDKey != null)
  237. sModel.F_WHWDKey = input.WHWDKey.Trim();
  238. if (input.WHBDKey != null)
  239. sModel.F_WHBDKey = input.WHBDKey.Trim();
  240. if (input.IVRKey != null)
  241. sModel.F_IVRKey = input.IVRKey;
  242. if (input.Des != null)
  243. sModel.F_Des = input.Des.Trim();
  244. if (input.Region != null)
  245. sModel.F_Region = input.Region.Trim();
  246. if (seatBLL.Update(sModel))
  247. return Success("编辑成功");
  248. return Error("编辑失败");
  249. }
  250. return NoToken("未知错误,请重新登录");
  251. }
  252. /// <summary>
  253. /// 删除坐席组
  254. /// </summary>
  255. /// <param name="ids"></param>
  256. /// <returns></returns>
  257. public ActionResult DelSeatGroup(string[] ids)
  258. {
  259. if (Request.IsAuthenticated)
  260. {
  261. if (ids == null || ids.Length <= 0)
  262. return Error("请选择要删除的坐席组");
  263. var idStr = string.Join(",", ids);
  264. if (string.IsNullOrEmpty(idStr.Trim()))
  265. return Error("请选择要删除的坐席组");
  266. if (seatBLL.DeleteList(idStr))
  267. return Success("删除成功");
  268. return Error("删除失败");
  269. }
  270. return NoToken("未知错误,请重新登录");
  271. }
  272. #region 按内容搜索
  273. /// <summary>
  274. /// 获取坐席组
  275. /// </summary>
  276. /// <param name="deptId"></param>
  277. /// <returns></returns>
  278. public ActionResult GetSearch()
  279. {
  280. if (Request.IsAuthenticated)
  281. {
  282. string strcontent= RequestString.GetQueryString("content");
  283. string strwhere = "";
  284. if (strcontent != "")
  285. {
  286. strwhere = " F_ZXZCode='" + strcontent + "' or F_ZXZName='" + strcontent + "'";
  287. }
  288. DataSet ds = seatBLL.GetList(strwhere);
  289. if (ds != null)
  290. return Success("查询坐席组信息成功", ds);
  291. return Error("查询坐席组信息失败");
  292. }
  293. return NoToken("未知错误,请重新登录");
  294. }
  295. #endregion
  296. }
  297. }