Sin descripción

GroupClassController.cs 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  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 GroupClassController : BaseController
  14. {
  15. // GET: GroupClass
  16. /// <summary>
  17. /// 获取用户班别列表
  18. /// </summary>
  19. /// <returns></returns>
  20. [Authority]
  21. public ActionResult GetList(int isdc = 0)
  22. {
  23. DataTable dt = new DataTable();
  24. string sql = " and F_IsDelete=0 ";
  25. string groupcode = HttpUtility.UrlDecode(RequestString.GetQueryString("groupcode"));
  26. string classcode = HttpUtility.UrlDecode(RequestString.GetQueryString("classcode"));
  27. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  28. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  29. string strpageindex = RequestString.GetQueryString("page");
  30. int pageindex = 1;
  31. string strpagesize = RequestString.GetQueryString("pagesize");
  32. int pagesize = 10;
  33. if (groupcode.Trim() != "" && groupcode != "undefined")
  34. {
  35. sql += " and F_GroupCode = '" + groupcode.Trim() + "' ";
  36. }
  37. if (classcode.Trim() != "" && classcode != "undefined")
  38. {
  39. sql += " and F_ClassCode = '" + classcode.Trim() + "' ";
  40. }
  41. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  42. {
  43. sql += " and datediff(day,F_Date,'" + strstarttime + "')<=0 ";
  44. }
  45. if (strendtime.Trim() != "" && strendtime != "undefined")
  46. {
  47. sql += " and datediff(day,F_Date,'" + strendtime + "')>=0 ";
  48. }
  49. if (strpageindex.Trim() != "")
  50. {
  51. pageindex = Convert.ToInt32(strpageindex);
  52. }
  53. if (strpagesize.Trim() != "")
  54. {
  55. pagesize = Convert.ToInt32(strpagesize);
  56. }
  57. string cols = "*,dbo.GetUserName(F_GroupCode) as UserName";
  58. if (isdc > 0)
  59. {
  60. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Sys_GroupClass where 1=1 " + sql).Tables[0];
  61. var msg = new NPOIHelper().ExportToExcel("班组班别列表", dtdc);
  62. if (msg == "")
  63. {
  64. return Success("导出成功");
  65. }
  66. else
  67. {
  68. return Error("导出失败");
  69. }
  70. }
  71. int recordCount = 0;
  72. dt = BLL.PagerBLL.GetListPager(
  73. "T_Sys_GroupClass",
  74. "F_Id",
  75. cols,
  76. sql,
  77. "ORDER BY F_Date DESC",
  78. pagesize,
  79. pageindex,
  80. true,
  81. out recordCount);
  82. var obj = new
  83. {
  84. state = "success",
  85. message = "成功",
  86. rows = dt,
  87. total = recordCount
  88. };
  89. return Content(obj.ToJson());
  90. }
  91. /// <summary>
  92. /// 获取用户班别列表
  93. /// </summary>
  94. /// <returns></returns>
  95. [Authority]
  96. public ActionResult GetRLList()
  97. {
  98. string sql = " F_IsDelete=0 ";
  99. string groupcode = HttpUtility.UrlDecode(RequestString.GetQueryString("groupcode"));
  100. string classcode = HttpUtility.UrlDecode(RequestString.GetQueryString("classcode"));
  101. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  102. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  103. //
  104. //
  105. //if (User.F_RoleCode == "ZXHWY" || User.F_RoleCode == "ZXBZ")
  106. //{
  107. // sql += " and F_GroupCode = '" + User.F_GroupCode + "' ";
  108. //}
  109. if (groupcode.Trim() != "" && groupcode != "undefined")
  110. {
  111. sql += " and F_GroupCode = '" + groupcode.Trim() + "' ";
  112. }
  113. if (classcode.Trim() != "" && classcode != "undefined")
  114. {
  115. sql += " and F_ClassCode = '" + classcode.Trim() + "' ";
  116. }
  117. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  118. {
  119. sql += " and datediff(day,F_Date,'" + strstarttime + "')<=0 ";
  120. }
  121. if (strendtime.Trim() != "" && strendtime != "undefined")
  122. {
  123. sql += " and datediff(day,F_Date,'" + strendtime + "')>=0 ";
  124. }
  125. var list = new BLL.T_Sys_GroupClass().GetModelList(sql);
  126. var obj = list.Select(p => {
  127. var cls = new BLL.T_Sys_Class().GetModelList(" F_Code='" + p.F_ClassCode + "' ").FirstOrDefault();
  128. var group = new BLL.T_Sys_Group().GetModelList(" F_GroupCode='" + p.F_GroupCode + "' ").FirstOrDefault();
  129. string[] ins = cls.F_InTime.Split(':');
  130. string[] outs = cls.F_OutTime.Split(':');
  131. bool bl = Int32.Parse(ins[0]) > Int32.Parse(outs[0]);
  132. var edate = bl ? p.F_Date.Value.AddDays(1) : p.F_Date.Value;
  133. return new
  134. {
  135. id = p.F_Id,
  136. groupcode= p.F_GroupCode,
  137. classcode= p.F_ClassCode,
  138. title = group.F_GroupName+" "+cls.F_Name + "[" + cls.F_InTime + "-" + cls.F_OutTime + "]",
  139. start = p.F_Date.Value.ToString("yyyy-MM-dd") + " " + cls.F_InTime,
  140. end = edate.ToString("yyyy-MM-dd") + " " + cls.F_OutTime
  141. };
  142. });
  143. return Content(obj.ToJson());
  144. }
  145. /// <summary>
  146. /// 添加用户班别
  147. /// </summary>
  148. /// <param name="input"></param>
  149. /// <returns></returns>
  150. [HttpPost]
  151. [Authority]
  152. public ActionResult AddGroupClass()
  153. {
  154. string strid = RequestString.GetFormString("id"); ;
  155. string date = RequestString.GetFormString("date");
  156. string groupcode = RequestString.GetFormString("groupcode");
  157. string classcode = RequestString.GetFormString("classcode");
  158. long id = 0;
  159. if (!string.IsNullOrEmpty(strid))
  160. {
  161. id = long.Parse(strid);
  162. }
  163. Model.T_Sys_GroupClass dModel = new Model.T_Sys_GroupClass();
  164. if (id == 0)
  165. {
  166. var list = new BLL.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + date + "' and F_GroupCode='" + groupcode + "' and F_IsDelete=0 ");
  167. if (list.Count > 0)
  168. {
  169. return Error("已经存在此班别");
  170. }
  171. else
  172. {
  173. dModel.F_ClassCode = classcode;
  174. dModel.F_Date = Convert.ToDateTime(date);
  175. dModel.F_GroupCode = groupcode;
  176. dModel.F_State = 0;
  177. dModel.F_IsDelete = 0;
  178. dModel.F_CreateUser = User.F_UserCode;
  179. dModel.F_CreateTime = DateTime.Now;
  180. long n = new BLL.T_Sys_GroupClass().Add(dModel);
  181. if (n > 0)
  182. return Success("添加成功", n);
  183. else
  184. return Error("添加失败");
  185. }
  186. }
  187. else
  188. {
  189. dModel = new BLL.T_Sys_GroupClass().GetModel(id);
  190. if (dModel != null)
  191. {
  192. 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 + "' ");
  193. if (list.Count > 0)
  194. {
  195. return Error("已经存在此班别");
  196. }
  197. else
  198. {
  199. dModel.F_ClassCode = classcode;
  200. dModel.F_Date = Convert.ToDateTime(date);
  201. dModel.F_GroupCode = groupcode;
  202. if (new BLL.T_Sys_GroupClass().Update(dModel))
  203. return Success("修改成功");
  204. else
  205. return Error("修改失败");
  206. }
  207. }
  208. else
  209. {
  210. return Error("修改失败");
  211. }
  212. }
  213. }
  214. /// <summary>
  215. /// 删除班别
  216. /// </summary>
  217. /// <param name="ids"></param>
  218. /// <returns></returns>
  219. [Authority]
  220. public ActionResult DelGroupClass(long id)
  221. {
  222. var model = new BLL.T_Sys_GroupClass().GetModel(id);
  223. model.F_IsDelete = 1;
  224. model.F_DeleteUser = User.F_GroupCode;
  225. model.F_DeleteTime = DateTime.Now;
  226. if (new BLL.T_Sys_GroupClass().Update(model))
  227. {
  228. return Success("删除成功");
  229. }
  230. return Error("删除失败");
  231. }
  232. /// <summary>
  233. /// 获取未分组坐席
  234. /// </summary>
  235. /// <returns></returns>
  236. [Authority]
  237. public ActionResult GetNoGroupSeatList()
  238. {
  239. var dt = new BLL.T_Sys_UserAccount().GetList(" f_seatflag=1 and isnull(F_GroupCode,'')='' ").Tables[0];
  240. return Success("成功", dt);
  241. }
  242. /// <summary>
  243. /// 坐席分组
  244. /// </summary>
  245. /// <returns></returns>
  246. [Authority]
  247. public ActionResult GroupSeat()
  248. {
  249. string groupcode = RequestString.GetFormString("groupcode");
  250. string usercode = RequestString.GetFormString("usercode");
  251. var ur = new BLL.T_Sys_UserAccount().GetModelList(" F_UserCode='" + usercode + "' ").FirstOrDefault();
  252. if (ur != null)
  253. {
  254. ur.F_GroupCode = groupcode;
  255. if (new BLL.T_Sys_UserAccount().Update(ur))
  256. {
  257. return Success("成功");
  258. }
  259. else
  260. {
  261. return Error("分组失败");
  262. }
  263. }
  264. else
  265. {
  266. return Error("分组失败");
  267. }
  268. }
  269. }
  270. }