| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- using CallCenter.Utility;
- using CallCenterApi.Common;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers
- {
- public class GroupClassController : BaseController
- {
- // GET: GroupClass
- /// <summary>
- /// 获取用户班别列表
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetList(int isdc = 0)
- {
- DataTable dt = new DataTable();
- string sql = " and F_IsDelete=0 ";
- string groupcode = HttpUtility.UrlDecode(RequestString.GetQueryString("groupcode"));
- string classcode = HttpUtility.UrlDecode(RequestString.GetQueryString("classcode"));
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (groupcode.Trim() != "" && groupcode != "undefined")
- {
- sql += " and F_GroupCode = '" + groupcode.Trim() + "' ";
- }
- if (classcode.Trim() != "" && classcode != "undefined")
- {
- sql += " and F_ClassCode = '" + classcode.Trim() + "' ";
- }
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- sql += " and datediff(day,F_Date,'" + strstarttime + "')<=0 ";
- }
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and datediff(day,F_Date,'" + strendtime + "')>=0 ";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- string cols = "*,dbo.GetUserName(F_GroupCode) as UserName";
- if (isdc > 0)
- {
- var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Sys_GroupClass where 1=1 " + sql).Tables[0];
- var msg = new NPOIHelper().ExportToExcel("班组班别列表", dtdc);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_GroupClass",
- "F_Id",
- cols,
- sql,
- "ORDER BY F_Date DESC",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取用户班别列表
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetRLList()
- {
- string sql = " F_IsDelete=0 ";
- string groupcode = HttpUtility.UrlDecode(RequestString.GetQueryString("groupcode"));
- string classcode = HttpUtility.UrlDecode(RequestString.GetQueryString("classcode"));
- string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- //
- //
- //if (User.F_RoleCode == "ZXHWY" || User.F_RoleCode == "ZXBZ")
- //{
- // sql += " and F_GroupCode = '" + User.F_GroupCode + "' ";
- //}
- if (groupcode.Trim() != "" && groupcode != "undefined")
- {
- sql += " and F_GroupCode = '" + groupcode.Trim() + "' ";
- }
- if (classcode.Trim() != "" && classcode != "undefined")
- {
- sql += " and F_ClassCode = '" + classcode.Trim() + "' ";
- }
- if (strstarttime.Trim() != "" && strstarttime != "undefined")
- {
- sql += " and datediff(day,F_Date,'" + strstarttime + "')<=0 ";
- }
- if (strendtime.Trim() != "" && strendtime != "undefined")
- {
- sql += " and datediff(day,F_Date,'" + strendtime + "')>=0 ";
- }
- var list = new BLL.T_Sys_GroupClass().GetModelList(sql);
- var obj = list.Select(p => {
- var cls = new BLL.T_Sys_Class().GetModelList(" F_Code='" + p.F_ClassCode + "' ").FirstOrDefault();
- var group = new BLL.T_Sys_Group().GetModelList(" F_GroupCode='" + p.F_GroupCode + "' ").FirstOrDefault();
- string[] ins = cls.F_InTime.Split(':');
- string[] outs = cls.F_OutTime.Split(':');
- bool bl = Int32.Parse(ins[0]) > Int32.Parse(outs[0]);
- var edate = bl ? p.F_Date.Value.AddDays(1) : p.F_Date.Value;
- return new
- {
- id = p.F_Id,
- groupcode= p.F_GroupCode,
- classcode= p.F_ClassCode,
- title = group.F_GroupName+" "+cls.F_Name + "[" + cls.F_InTime + "-" + cls.F_OutTime + "]",
- start = p.F_Date.Value.ToString("yyyy-MM-dd") + " " + cls.F_InTime,
- end = edate.ToString("yyyy-MM-dd") + " " + cls.F_OutTime
- };
- });
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 添加用户班别
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- [Authority]
- public ActionResult AddGroupClass()
- {
- string strid = RequestString.GetFormString("id"); ;
- string date = RequestString.GetFormString("date");
- string groupcode = RequestString.GetFormString("groupcode");
- string classcode = RequestString.GetFormString("classcode");
- long id = 0;
- if (!string.IsNullOrEmpty(strid))
- {
- id = long.Parse(strid);
- }
- Model.T_Sys_GroupClass dModel = new Model.T_Sys_GroupClass();
- if (id == 0)
- {
- var list = new BLL.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + date + "' and F_GroupCode='" + groupcode + "' and F_IsDelete=0 ");
- if (list.Count > 0)
- {
- return Error("已经存在此班别");
- }
- else
- {
- dModel.F_ClassCode = classcode;
- dModel.F_Date = Convert.ToDateTime(date);
- dModel.F_GroupCode = groupcode;
- dModel.F_State = 0;
- dModel.F_IsDelete = 0;
- dModel.F_CreateUser = User.F_UserCode;
- dModel.F_CreateTime = DateTime.Now;
- long n = new BLL.T_Sys_GroupClass().Add(dModel);
- if (n > 0)
- return Success("添加成功", n);
- else
- return Error("添加失败");
- }
- }
- else
- {
- dModel = new BLL.T_Sys_GroupClass().GetModel(id);
- if (dModel != null)
- {
- var list = new BLL.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + date + "' and F_GroupCode='" + groupcode + "' and F_IsDelete=0 and F_Id!='" + id + "' ");
- if (list.Count > 0)
- {
- return Error("已经存在此班别");
- }
- else
- {
- dModel.F_ClassCode = classcode;
- dModel.F_Date = Convert.ToDateTime(date);
- dModel.F_GroupCode = groupcode;
- if (new BLL.T_Sys_GroupClass().Update(dModel))
- return Success("修改成功");
- else
- return Error("修改失败");
- }
- }
- else
- {
- return Error("修改失败");
- }
- }
- }
- /// <summary>
- /// 删除班别
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult DelGroupClass(long id)
- {
-
-
- var model = new BLL.T_Sys_GroupClass().GetModel(id);
- model.F_IsDelete = 1;
- model.F_DeleteUser = User.F_GroupCode;
- model.F_DeleteTime = DateTime.Now;
- if (new BLL.T_Sys_GroupClass().Update(model))
- {
- return Success("删除成功");
- }
- return Error("删除失败");
- }
- /// <summary>
- /// 获取未分组坐席
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetNoGroupSeatList()
- {
- var dt = new BLL.T_Sys_UserAccount().GetList(" f_seatflag=1 and isnull(F_GroupCode,'')='' ").Tables[0];
- return Success("成功", dt);
- }
- /// <summary>
- /// 坐席分组
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GroupSeat()
- {
- string groupcode = RequestString.GetFormString("groupcode");
- string usercode = RequestString.GetFormString("usercode");
- var ur = new BLL.T_Sys_UserAccount().GetModelList(" F_UserCode='" + usercode + "' ").FirstOrDefault();
- if (ur != null)
- {
- ur.F_GroupCode = groupcode;
- if (new BLL.T_Sys_UserAccount().Update(ur))
- {
- return Success("成功");
- }
- else
- {
- return Error("分组失败");
- }
- }
- else
- {
- return Error("分组失败");
- }
- }
- }
- }
|