| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- using CallCenter.Utility;
- using CallCenterApi.Common;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Input;
- using CallCenterApi.Model;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers
- {
- [Authority]
- public class SeatGroupController : BaseController
- {
- BLL.T_Sys_SeatGroup seatBLL = new BLL.T_Sys_SeatGroup();
- /// <summary>
- /// 获取坐席组列表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetList()
- {
- DataTable dt = new DataTable();
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- string sql = "";
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_SeatGroup",
- "F_ID",
- "*",
- sql,
- "ORDER BY F_ID desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson()); ;
- }
- //获取坐席组列表
- public ActionResult GetSeatList()
- {
- List<Model.T_Sys_SeatGroup> seatList = seatBLL.GetModelList(" 1=1 order by F_ID desc ");
- if (seatList.Count > 0)
- return Success("坐席组列表加载成功", seatList);
- else
- return Error("坐席组列表加载失败");
- }
- /// <summary>
- /// 获取坐席组
- /// </summary>
- /// <param name="deptId"></param>
- /// <returns></returns>
- public ActionResult GetSeatGroup(int ZXZID = 0)
- {
- Model.T_Sys_SeatGroup sModel = seatBLL.GetModel(ZXZID);
- if (sModel != null)
- return Success("获取坐席组信息成功", sModel);
- return Error("获取坐席组信息失败");
- }
- /// <summary>
- /// 添加坐席组
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult AddSeatGroup(SeatGroupInput input)
- {
- if (GetExistByCode(input.ZXZCode, 0) || GetExistByName(input.ZXZName, 0))
- {
- return Error("坐席组编号和名称必须唯一,请重新输入!");
- }
- Model.T_Sys_SeatGroup sModel = new Model.T_Sys_SeatGroup();
- if (input.ZXZCode != null)
- sModel.F_ZXZCode = input.ZXZCode.Trim();
- if (input.ZXZName != null)
- sModel.F_ZXZName = input.ZXZName.Trim();
- if (input.ZXAtt != null)
- sModel.F_ZXAtt = input.ZXAtt.Trim();
- if (input.WHWDKey != null)
- sModel.F_WHWDKey = input.WHWDKey.Trim();
- if (input.WHBDKey != null)
- sModel.F_WHBDKey = input.WHBDKey.Trim();
- if (input.IVRKey != null)
- sModel.F_IVRKey = input.IVRKey;
- if (input.Des != null)
- sModel.F_Des = input.Des.Trim();
- sModel.F_CreateTime = DateTime.Now;
- sModel.F_CreateByName = User.F_UserName;
- sModel.F_CreateBy = User.F_UserId;
- int n = seatBLL.Add(sModel);
- if (n > 0)
- {
- string content = $"{User.F_UserName}({User.F_UserCode })添加坐席组{ sModel.F_ZXZName }";
- string Operation = OperationLogController
- .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 0, 4598, n);
- return Success("添加成功");
- }
-
- else
- return Success("添加失败");
-
- }
- /// <summary>
- /// 编辑坐席组
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult EditSeatGroup(SeatGroupInput input)
- {
- if (input.ZXZID <= 0)
- return Error("请选择要编辑的坐席组");
- if (GetExistByCode(input.ZXZCode, input.ZXZID) || GetExistByName(input.ZXZName, input.ZXZID))
- {
- return Error("坐席组编号和名称必须唯一,请重新输入!");
- }
- Model.T_Sys_SeatGroup sModel = seatBLL.GetModel(input.ZXZID);
- if (sModel == null)
- return Error("获取信息失败");
- if (input.ZXZCode != null)
- sModel.F_ZXZCode = input.ZXZCode.Trim();
- if (input.ZXZName != null)
- sModel.F_ZXZName = input.ZXZName.Trim();
- if (input.ZXAtt != null)
- sModel.F_ZXAtt = input.ZXAtt.Trim();
- if (input.WHWDKey != null)
- sModel.F_WHWDKey = input.WHWDKey.Trim();
- if (input.WHBDKey != null)
- sModel.F_WHBDKey = input.WHBDKey.Trim();
- if (input.IVRKey != null)
- sModel.F_IVRKey = input.IVRKey;
- if (input.Des != null)
- sModel.F_Des = input.Des.Trim();
- if (seatBLL.Update(sModel))
- {
- string content = $"{User.F_UserName}({User.F_UserCode })修改坐席组{ sModel.F_ZXZName }";
- string Operation = OperationLogController
- .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 1, 4598, sModel.F_ID );
- return Success("编辑成功");
- }
-
- return Error("编辑失败");
- }
- /// <summary>
- /// 删除坐席组
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult DelSeatGroup(string[] ids)
- {
- if (ids == null || ids.Length <= 0)
- return Error("请选择要删除的坐席组");
- var idStr = string.Join(",", ids);
- if (string.IsNullOrEmpty(idStr.Trim()))
- return Error("请选择要删除的坐席组");
- try
- {
- foreach (var it in ids)
- {
- Model.T_Sys_SeatGroup sModel = seatBLL.GetModel(int.Parse (it ));
- string content = $"{User.F_UserName}({User.F_UserCode })删除坐席组{ sModel.F_ZXZName }";
- string Operation = OperationLogController
- .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 2, 4598, sModel.F_ID);
- }
- }
- catch
- {
- }
-
-
- if (seatBLL.DeleteList(idStr))
- {
- return Success("删除成功");
- }
-
- return Error("删除失败");
- }
- #region
- /// <summary>
- /// 根据坐席组编号查询是否存在此坐席组编号
- /// </summary>
- /// <param name="code"></param>
- /// <returns></returns>
- private bool GetExistByCode(string code, int? id)
- {
- string sql = " 1=1 ";
- if (code != null)
- {
- sql += " and F_ZXZCode='" + code.Trim() + "' ";
- }
- if (id != null)
- {
- sql += " and F_ID <>" + id;
- }
- var ss = seatBLL.GetRecordCount(sql);
- if (ss > 0)
- return true;
- else
- return false;
- }
- /// <summary>
- /// 根据坐席组名称查询是否存在此坐席组编号
- /// </summary>
- /// <param name="code"></param>
- /// <returns></returns>
- private bool GetExistByName(string name, int? id)
- {
- string sql = " 1=1 ";
- if (name != null)
- {
- sql += " and F_ZXZName='" + name.Trim() + "' ";
- }
- if (id != null)
- {
- sql += " and F_ID <>" + id;
- }
- var ss = seatBLL.GetRecordCount(sql);
- if (ss > 0)
- return true;
- else
- return false;
- }
- #endregion
- }
- }
|