县级监管平台

CountyBranchController.cs 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. using CallCenterApi.Common;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.App_Start;
  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.County
  12. {
  13. public class CountyBranchController : BaseController
  14. {
  15. // GET: CountyBranch
  16. private BLL.T_Branch_List branchBLL = new BLL.T_Branch_List();
  17. #region 网点
  18. /// <summary>
  19. /// 获取所有网点
  20. /// </summary>
  21. /// <returns></returns>
  22. [OutActionFilter]
  23. public ActionResult GetCityList(string code,string name)
  24. {
  25. string sql = " F_IsDelete=0 ";
  26. if (!string.IsNullOrEmpty(code))
  27. {
  28. sql += " and F_Code like '%" + code + "%' ";
  29. }
  30. if (!string.IsNullOrEmpty(name))
  31. {
  32. sql += " and F_Name like '%" + name + "%' ";
  33. }
  34. DataTable dt = branchBLL.GetList(sql).Tables[0];
  35. return Success("成功", dt);
  36. }
  37. /// <summary>
  38. /// 获取详情
  39. /// </summary>
  40. /// <param name="code"></param>
  41. /// <returns></returns>
  42. [OutActionFilter]
  43. public ActionResult GetCityDetail(string code)
  44. {
  45. string sql = " F_IsDelete=0 ";
  46. if (!string.IsNullOrEmpty(code))
  47. {
  48. sql += " and F_Code = '" + code + "' ";
  49. }
  50. var model = branchBLL.GetModelList(sql).FirstOrDefault();
  51. return Success("成功", model);
  52. }
  53. /// <summary>
  54. /// 获取网点列表
  55. /// </summary>
  56. /// <returns></returns>
  57. [Authority]
  58. public ActionResult GetList(int isdc = 0)
  59. {
  60. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(User.UserData["F_UserCode"]);
  61. DataTable dt = new DataTable();
  62. string sql = " and F_IsDelete=0 ";
  63. string strcode = HttpUtility.UrlDecode(RequestString.GetQueryString("code"));
  64. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  65. string strpageindex = RequestString.GetQueryString("page");
  66. int pageindex = 1;
  67. string strpagesize = RequestString.GetQueryString("pagesize");
  68. int pagesize = 10;
  69. if (strcode.Trim() != "" && strcode != "undefined")
  70. {
  71. sql += " and F_Code like '%" + strcode + "%' ";
  72. }
  73. if (strname.Trim() != "" && strname != "undefined")
  74. {
  75. sql += " and F_Name like '%" + strname + "%' ";
  76. }
  77. if (strpageindex.Trim() != "")
  78. {
  79. pageindex = Convert.ToInt32(strpageindex);
  80. }
  81. if (strpagesize.Trim() != "")
  82. {
  83. pagesize = Convert.ToInt32(strpagesize);
  84. }
  85. string cols = "*,dbo.GetUserName(F_CreateUser) as UserName";
  86. if (isdc > 0)
  87. {
  88. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Branch_List where 1=1 " + sql).Tables[0];
  89. var msg = new NPOIHelper().ExportToExcel("网点列表", dtdc);
  90. if (msg == "")
  91. {
  92. return Success("导出成功");
  93. }
  94. else
  95. {
  96. return Error("导出失败");
  97. }
  98. }
  99. int recordCount = 0;
  100. dt = BLL.PagerBLL.GetListPager(
  101. "T_Branch_List",
  102. "F_Id",
  103. cols,
  104. sql,
  105. "ORDER BY F_CreateTime DESC",
  106. pagesize,
  107. pageindex,
  108. true,
  109. out recordCount);
  110. var obj = new
  111. {
  112. state = "success",
  113. message = "成功",
  114. rows = dt,
  115. total = recordCount
  116. };
  117. return Content(obj.ToJson());
  118. }
  119. /// <summary>
  120. /// 获取网点列表
  121. /// </summary>
  122. /// <returns></returns>
  123. [Authority]
  124. public ActionResult GetBranchList()
  125. {
  126. DataTable dt = branchBLL.GetList(" F_IsDelete=0 ").Tables[0];
  127. return Success("加载成功", dt);
  128. }
  129. /// <summary>
  130. /// 获取网点
  131. /// </summary>
  132. /// <param name="BranchId"></param>
  133. /// <returns></returns>
  134. [Authority]
  135. public ActionResult GetBranch()
  136. {
  137. int id = RequestString.GetInt("id", 0);
  138. Model.T_Branch_List dModel = branchBLL.GetModel(id);
  139. if (dModel != null)
  140. return Success("获取信息成功", dModel);
  141. return Error("获取信息失败");
  142. }
  143. /// <summary>
  144. /// 添加网点
  145. /// </summary>
  146. /// <param name="input"></param>
  147. /// <returns></returns>
  148. [HttpPost]
  149. [Authority]
  150. public ActionResult AddBranch()
  151. {
  152. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(User.UserData["F_UserCode"]);
  153. int id = RequestString.GetInt("id", 0);
  154. string code = RequestString.GetFormString("code");
  155. string name = RequestString.GetFormString("name");
  156. string pwd = RequestString.GetFormString("pwd");
  157. string address = RequestString.GetFormString("address");
  158. string conname = RequestString.GetFormString("conname");
  159. string conphone = RequestString.GetFormString("conphone");
  160. string contel = RequestString.GetFormString("contel");
  161. string conemail = RequestString.GetFormString("conemail");
  162. string url = RequestString.GetFormString("url");
  163. string sign = RequestString.GetFormString("sign");
  164. string wsurl = RequestString.GetFormString("wsurl");
  165. string phone = RequestString.GetFormString("phone");
  166. Model.T_Branch_List dModel = new Model.T_Branch_List();
  167. if (id == 0)
  168. {
  169. var list = branchBLL.GetModelList(" F_Name='" + name + "' ");
  170. if (list.Count > 0)
  171. {
  172. return Error("已经存在此网点");
  173. }
  174. else
  175. {
  176. dModel.F_Code = code;
  177. dModel.F_Name = name;
  178. dModel.F_Password = pwd;
  179. dModel.F_Address = address;
  180. dModel.F_ConName = conname;
  181. dModel.F_ConPhone = conphone;
  182. dModel.F_ConTel = contel;
  183. dModel.F_ConEmail = conemail;
  184. dModel.F_Url = url;
  185. dModel.F_Sign = sign;
  186. dModel.F_WebSocketUrl = wsurl;
  187. dModel.F_Phone = phone;
  188. dModel.F_IsDelete = 0;
  189. dModel.F_State = 0;
  190. dModel.F_CreateUser = userModel.F_UserCode;
  191. dModel.F_CreateTime = DateTime.Now;
  192. int n = branchBLL.Add(dModel);
  193. if (n > 0)
  194. return Success("添加成功", n);
  195. else
  196. return Error("添加失败");
  197. }
  198. }
  199. else
  200. {
  201. dModel = branchBLL.GetModel(id);
  202. if (dModel != null)
  203. {
  204. var list = branchBLL.GetModelList(" F_Name='" + name + "' and F_Id!='" + id + "' ");
  205. if (list.Count > 0)
  206. {
  207. return Error("已经存在此网点");
  208. }
  209. else
  210. {
  211. dModel.F_Code = code;
  212. dModel.F_Name = name;
  213. dModel.F_Password = pwd;
  214. dModel.F_Address = address;
  215. dModel.F_ConName = conname;
  216. dModel.F_ConPhone = conphone;
  217. dModel.F_ConTel = contel;
  218. dModel.F_ConEmail = conemail;
  219. dModel.F_Url = url;
  220. dModel.F_Sign = sign;
  221. dModel.F_WebSocketUrl = wsurl;
  222. dModel.F_Phone = phone;
  223. if (branchBLL.Update(dModel))
  224. return Success("修改成功");
  225. else
  226. return Error("修改失败");
  227. }
  228. }
  229. else
  230. {
  231. return Error("修改失败");
  232. }
  233. }
  234. }
  235. /// <summary>
  236. /// 删除网点
  237. /// </summary>
  238. /// <param name="ids"></param>
  239. /// <returns></returns>
  240. [Authority]
  241. public ActionResult DelBranch(string[] ids)
  242. {
  243. if (ids == null || ids.Length <= 0)
  244. return Error("请选择要删除的网点");
  245. var idStr = string.Join(",", ids);
  246. if (string.IsNullOrEmpty(idStr.Trim()))
  247. return Error("请选择要删除的网点");
  248. if (branchBLL.DeleteList(idStr))
  249. return Success("删除成功");
  250. return Error("删除失败");
  251. }
  252. /// <summary>
  253. /// 删除网点
  254. /// </summary>
  255. /// <param name="ids"></param>
  256. /// <returns></returns>
  257. [Authority]
  258. public ActionResult DelBranchs(int id)
  259. {
  260. if (id > 0)
  261. {
  262. if (new BLL.T_Branch_List().Delete(id))
  263. {
  264. return Success("删除成功");
  265. }
  266. else
  267. {
  268. return Error("删除失败");
  269. }
  270. }
  271. else
  272. {
  273. return Error("删除失败");
  274. }
  275. }
  276. //大屏展示使用
  277. /// <summary>
  278. /// 获取网点列表
  279. /// </summary>
  280. /// <returns></returns>
  281. //[Authority]
  282. public ActionResult GetBranchListS()
  283. {
  284. DataTable dt = branchBLL.GetList(" F_IsDP=1 ").Tables[0];
  285. return Success("加载成功", dt);
  286. }
  287. #endregion
  288. }
  289. }