Keine Beschreibung

SeatGroupController.cs 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using CallCenterApi.Interface.Models.Input;
  5. using CallCenterApi.Model;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace CallCenterApi.Interface.Controllers
  13. {
  14. [Authority]
  15. public class SeatGroupController : BaseController
  16. {
  17. BLL.T_Sys_SeatGroup seatBLL = new BLL.T_Sys_SeatGroup();
  18. /// <summary>
  19. /// 获取坐席组列表
  20. /// </summary>
  21. /// <returns></returns>
  22. public ActionResult GetList()
  23. {
  24. DataTable dt = new DataTable();
  25. string strpageindex = RequestString.GetQueryString("page");
  26. int pageindex = 1;
  27. string strpagesize = RequestString.GetQueryString("pagesize");
  28. int pagesize = 10;
  29. string sql = "";
  30. if (strpageindex.Trim() != "")
  31. {
  32. pageindex = Convert.ToInt32(strpageindex);
  33. }
  34. if (strpagesize.Trim() != "")
  35. {
  36. pagesize = Convert.ToInt32(strpagesize);
  37. }
  38. int recordCount = 0;
  39. dt = BLL.PagerBLL.GetListPager(
  40. "T_Sys_SeatGroup",
  41. "F_ID",
  42. "*",
  43. sql,
  44. "ORDER BY F_ID desc",
  45. pagesize,
  46. pageindex,
  47. true,
  48. out recordCount);
  49. var obj = new
  50. {
  51. rows = dt,
  52. total = recordCount
  53. };
  54. return Content(obj.ToJson()); ;
  55. }
  56. //获取坐席组列表
  57. public ActionResult GetSeatList()
  58. {
  59. List<Model.T_Sys_SeatGroup> seatList = seatBLL.GetModelList(" 1=1 order by F_ID desc ");
  60. if (seatList.Count > 0)
  61. return Success("坐席组列表加载成功", seatList);
  62. else
  63. return Error("坐席组列表加载失败");
  64. }
  65. /// <summary>
  66. /// 获取坐席组
  67. /// </summary>
  68. /// <param name="deptId"></param>
  69. /// <returns></returns>
  70. public ActionResult GetSeatGroup(int ZXZID = 0)
  71. {
  72. Model.T_Sys_SeatGroup sModel = seatBLL.GetModel(ZXZID);
  73. if (sModel != null)
  74. return Success("获取坐席组信息成功", sModel);
  75. return Error("获取坐席组信息失败");
  76. }
  77. /// <summary>
  78. /// 添加坐席组
  79. /// </summary>
  80. /// <param name="input"></param>
  81. /// <returns></returns>
  82. [HttpPost]
  83. public ActionResult AddSeatGroup(SeatGroupInput input)
  84. {
  85. if (GetExistByCode(input.ZXZCode, 0) || GetExistByName(input.ZXZName, 0))
  86. {
  87. return Error("坐席组编号和名称必须唯一,请重新输入!");
  88. }
  89. Model.T_Sys_SeatGroup sModel = new Model.T_Sys_SeatGroup();
  90. if (input.ZXZCode != null)
  91. sModel.F_ZXZCode = input.ZXZCode.Trim();
  92. if (input.ZXZName != null)
  93. sModel.F_ZXZName = input.ZXZName.Trim();
  94. if (input.ZXAtt != null)
  95. sModel.F_ZXAtt = input.ZXAtt.Trim();
  96. if (input.WHWDKey != null)
  97. sModel.F_WHWDKey = input.WHWDKey.Trim();
  98. if (input.WHBDKey != null)
  99. sModel.F_WHBDKey = input.WHBDKey.Trim();
  100. if (input.IVRKey != null)
  101. sModel.F_IVRKey = input.IVRKey;
  102. if (input.Des != null)
  103. sModel.F_Des = input.Des.Trim();
  104. sModel.F_CreateTime = DateTime.Now;
  105. sModel.F_CreateByName = User.F_UserName;
  106. sModel.F_CreateBy = User.F_UserId;
  107. int n = seatBLL.Add(sModel);
  108. if (n > 0)
  109. {
  110. string content = $"{User.F_UserName}({User.F_UserCode })添加坐席组{ sModel.F_ZXZName }";
  111. string Operation = OperationLogController
  112. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 0, 4598, n);
  113. return Success("添加成功");
  114. }
  115. else
  116. return Success("添加失败");
  117. }
  118. /// <summary>
  119. /// 编辑坐席组
  120. /// </summary>
  121. /// <param name="input"></param>
  122. /// <returns></returns>
  123. [HttpPost]
  124. public ActionResult EditSeatGroup(SeatGroupInput input)
  125. {
  126. if (input.ZXZID <= 0)
  127. return Error("请选择要编辑的坐席组");
  128. if (GetExistByCode(input.ZXZCode, input.ZXZID) || GetExistByName(input.ZXZName, input.ZXZID))
  129. {
  130. return Error("坐席组编号和名称必须唯一,请重新输入!");
  131. }
  132. Model.T_Sys_SeatGroup sModel = seatBLL.GetModel(input.ZXZID);
  133. if (sModel == null)
  134. return Error("获取信息失败");
  135. if (input.ZXZCode != null)
  136. sModel.F_ZXZCode = input.ZXZCode.Trim();
  137. if (input.ZXZName != null)
  138. sModel.F_ZXZName = input.ZXZName.Trim();
  139. if (input.ZXAtt != null)
  140. sModel.F_ZXAtt = input.ZXAtt.Trim();
  141. if (input.WHWDKey != null)
  142. sModel.F_WHWDKey = input.WHWDKey.Trim();
  143. if (input.WHBDKey != null)
  144. sModel.F_WHBDKey = input.WHBDKey.Trim();
  145. if (input.IVRKey != null)
  146. sModel.F_IVRKey = input.IVRKey;
  147. if (input.Des != null)
  148. sModel.F_Des = input.Des.Trim();
  149. if (seatBLL.Update(sModel))
  150. {
  151. string content = $"{User.F_UserName}({User.F_UserCode })修改坐席组{ sModel.F_ZXZName }";
  152. string Operation = OperationLogController
  153. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 1, 4598, sModel.F_ID );
  154. return Success("编辑成功");
  155. }
  156. return Error("编辑失败");
  157. }
  158. /// <summary>
  159. /// 删除坐席组
  160. /// </summary>
  161. /// <param name="ids"></param>
  162. /// <returns></returns>
  163. public ActionResult DelSeatGroup(string[] ids)
  164. {
  165. if (ids == null || ids.Length <= 0)
  166. return Error("请选择要删除的坐席组");
  167. var idStr = string.Join(",", ids);
  168. if (string.IsNullOrEmpty(idStr.Trim()))
  169. return Error("请选择要删除的坐席组");
  170. try
  171. {
  172. foreach (var it in ids)
  173. {
  174. Model.T_Sys_SeatGroup sModel = seatBLL.GetModel(int.Parse (it ));
  175. string content = $"{User.F_UserName}({User.F_UserCode })删除坐席组{ sModel.F_ZXZName }";
  176. string Operation = OperationLogController
  177. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 2, 4598, sModel.F_ID);
  178. }
  179. }
  180. catch
  181. {
  182. }
  183. if (seatBLL.DeleteList(idStr))
  184. {
  185. return Success("删除成功");
  186. }
  187. return Error("删除失败");
  188. }
  189. #region
  190. /// <summary>
  191. /// 根据坐席组编号查询是否存在此坐席组编号
  192. /// </summary>
  193. /// <param name="code"></param>
  194. /// <returns></returns>
  195. private bool GetExistByCode(string code, int? id)
  196. {
  197. string sql = " 1=1 ";
  198. if (code != null)
  199. {
  200. sql += " and F_ZXZCode='" + code.Trim() + "' ";
  201. }
  202. if (id != null)
  203. {
  204. sql += " and F_ID <>" + id;
  205. }
  206. var ss = seatBLL.GetRecordCount(sql);
  207. if (ss > 0)
  208. return true;
  209. else
  210. return false;
  211. }
  212. /// <summary>
  213. /// 根据坐席组名称查询是否存在此坐席组编号
  214. /// </summary>
  215. /// <param name="code"></param>
  216. /// <returns></returns>
  217. private bool GetExistByName(string name, int? id)
  218. {
  219. string sql = " 1=1 ";
  220. if (name != null)
  221. {
  222. sql += " and F_ZXZName='" + name.Trim() + "' ";
  223. }
  224. if (id != null)
  225. {
  226. sql += " and F_ID <>" + id;
  227. }
  228. var ss = seatBLL.GetRecordCount(sql);
  229. if (ss > 0)
  230. return true;
  231. else
  232. return false;
  233. }
  234. #endregion
  235. }
  236. }