高新区管委会,以5.0标准版为基准,从双汇项目拷贝

ATheChangeLogController.cs 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. using CallCenter.Utility;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. namespace CallCenterApi.Interface.Controllers
  11. {
  12. [Authority]
  13. public class ATheChangeLogController : BaseController
  14. {
  15. // GET: ATheChangeLog
  16. private BLL.T_Sys_ATheChangeLog areaBLL = new BLL.T_Sys_ATheChangeLog();
  17. private BLL.T_Sys_BTheChangeLog BreaBLL = new BLL.T_Sys_BTheChangeLog();
  18. #region 区域
  19. /// <summary>
  20. /// 获取区域列表
  21. /// </summary>
  22. /// <returns></returns>
  23. public ActionResult GetATheChangeLogList()
  24. {
  25. //int userId = CurrentUser.UserData.F_UserId;
  26. //Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  27. string where = " F_IsDelete=0 ";
  28. //if (!string.IsNullOrEmpty(userModel.groupcode))
  29. //{
  30. // where += " and F_GroupCode = '" + userModel.groupcode + "'";
  31. //}
  32. DataTable dt = areaBLL.GetList(0, where, " F_Sort asc").Tables[0];
  33. return Success("加载成功", dt);
  34. }
  35. /// <summary>
  36. /// 获取区域列表
  37. /// </summary>
  38. /// <returns></returns>
  39. public ActionResult GetAreaListById(int id = 0)
  40. {
  41. //int userId = CurrentUser.UserData.F_UserId;
  42. //Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  43. string where = " isnull(F_ParentId,0)='" + id + "' and F_IsDelete=0 ";
  44. //if (!string.IsNullOrEmpty(userModel.groupcode))
  45. //{
  46. // where += " and F_GroupCode = '" + userModel.groupcode + "'";
  47. //}
  48. DataTable dt = areaBLL.GetList(0, where, " F_Sort asc").Tables[0];
  49. return Success("列表加载成功", dt);
  50. }
  51. /// <summary>
  52. /// 获取区域
  53. /// </summary>
  54. /// <param name="areaId"></param>
  55. /// <returns></returns>
  56. public ActionResult GetATheChangeLog()
  57. {
  58. int id = RequestString.GetInt("id", 0);
  59. Model.T_Sys_ATheChangeLog dModel = areaBLL.GetModel(id);
  60. if (dModel != null)
  61. return Success("获取信息成功", dModel);
  62. return Error("获取信息失败");
  63. }
  64. /// <summary>
  65. /// 添加转移记录
  66. /// </summary>
  67. /// <param name="input"></param>
  68. /// <returns></returns>
  69. [HttpPost]
  70. public ActionResult AddAreaATheChangeLog()
  71. {
  72. int userId = CurrentUser.UserData.F_UserId;
  73. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  74. //接收Id
  75. int id = RequestString.GetInt("id", 0);
  76. //档案信息Id
  77. int pid = RequestString.GetInt("F_CustomerId", 0);
  78. //int sort = RequestString.GetInt("sort", 0);
  79. //string name = RequestString.GetFormString("name");
  80. //string code = RequestString.GetFormString("code");
  81. Model.T_Sys_ATheChangeLog dModel = new Model.T_Sys_ATheChangeLog();
  82. if (id == 0)
  83. {
  84. dModel.F_CreateUserId = userId;
  85. dModel.F_CreateUserName = userModel.F_UserName;
  86. dModel.F_CreateDate = DateTime.Now;
  87. dModel.F_deptid = userModel.F_DeptId;
  88. dModel.F_deptname = userModel.depname;
  89. dModel.F_type = 0;
  90. dModel.F_CustomerId = pid;
  91. dModel.F_Memo = "系统自动记录转移";
  92. int n = areaBLL.Add(dModel);
  93. if (n > 0)
  94. return Success("添加成功", n);
  95. else
  96. return Error("添加失败");
  97. }
  98. else
  99. {
  100. dModel = areaBLL.GetModel(id);
  101. if (dModel != null)
  102. {
  103. dModel.F_CreateUserId = userId;
  104. dModel.F_CreateUserName = userModel.F_UserName;
  105. dModel.F_CreateDate = DateTime.Now;
  106. dModel.F_deptid = userModel.F_DeptId;
  107. dModel.F_deptname = userModel.depname;
  108. dModel.F_type = 0;
  109. dModel.F_CustomerId = pid;
  110. dModel.F_Memo = "系统自动记录转移编辑";
  111. if (areaBLL.Update(dModel))
  112. return Success("修改成功");
  113. else
  114. return Error("修改失败");
  115. }
  116. else
  117. {
  118. return Error("修改失败");
  119. }
  120. }
  121. }
  122. /// <summary>
  123. /// 添加接收记录
  124. /// </summary>
  125. /// <param name="input"></param>
  126. /// <returns></returns>
  127. [HttpPost]
  128. public ActionResult AddBTheChangeLog()
  129. {
  130. int userId = CurrentUser.UserData.F_UserId;
  131. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  132. //接收Id
  133. int ATheChangeLogid = RequestString.GetInt("ATheChangeLogid", 0);
  134. //档案信息Id
  135. //int pid = RequestString.GetInt("F_CustomerId", 0);
  136. //int sort = RequestString.GetInt("sort", 0);
  137. //string name = RequestString.GetFormString("name");
  138. //string code = RequestString.GetFormString("code");
  139. Model.T_Sys_BTheChangeLog dModel = new Model.T_Sys_BTheChangeLog();
  140. dModel.F_CreateUserId = userId;
  141. dModel.F_CreateUserName = userModel.F_UserName;
  142. dModel.F_CreateDate = DateTime.Now;
  143. dModel.F_deptid = userModel.F_DeptId;
  144. dModel.F_deptname = userModel.depname;
  145. // dModel.F_type = 0;
  146. dModel.F_ATheChangeLog = ATheChangeLogid;
  147. dModel.F_Memo = "系统自动接收记录";
  148. int n = BreaBLL.Add(dModel);
  149. //转移方 状态变为 1
  150. string sql = " update T_Sys_ATheChangeLog set F_type=1 where F_Id="+ ATheChangeLogid;
  151. //登记信息 变为外部转入
  152. Model.T_Sys_ATheChangeLog AModel = new BLL.T_Sys_ATheChangeLog().GetModel(ATheChangeLogid);
  153. string sql2 = " update T_Rec_RegRecords set F_InnerType=1 where F_Id=" + AModel.F_CustomerId;
  154. int a =DbHelperSQL.ExecuteSql(sql);
  155. int b = DbHelperSQL.ExecuteSql(sql2);
  156. if (n > 0 && a==1 && b==1)
  157. return Success("添加成功", n);
  158. else
  159. return Error("添加失败");
  160. }
  161. /// <summary>
  162. /// 删除 之前看是否有接收记录
  163. /// </summary>
  164. /// <param name="ids"></param>
  165. /// <returns></returns>
  166. public ActionResult DelATheChangeLog(string[] ids)
  167. {
  168. if (ids == null || ids.Length <= 0)
  169. return Error("请选择要删除的转移");
  170. var idStr = string.Join(",", ids);
  171. if (string.IsNullOrEmpty(idStr.Trim()))
  172. return Error("请选择要删除的转移");
  173. if (areaBLL.DeleteList(idStr))
  174. return Success("删除成功");
  175. return Error("删除失败");
  176. }
  177. /// <summary>
  178. /// 删除区域和其下级区域
  179. /// </summary>
  180. /// <param name="ids"></param>
  181. /// <returns></returns>
  182. public ActionResult DelAreas(int id)
  183. {
  184. if (id > 0)
  185. {
  186. var model = new BLL.T_Sys_Area().GetModel(id);
  187. if (DelAreasByPId(id))
  188. {
  189. new BLL.T_Sys_Area().Delete(id);
  190. }
  191. return Success("删除成功");
  192. }
  193. else
  194. {
  195. return Error("删除失败");
  196. }
  197. }
  198. public bool DelAreasByPId(int id)
  199. {
  200. bool bl = true;
  201. var list = new BLL.T_Sys_Area().GetModelList(" F_ParentId ='" + id + "'");
  202. foreach (var l in list)
  203. {
  204. if (DelAreasByPId(l.F_Id))
  205. {
  206. new BLL.T_Sys_Area().Delete(l.F_Id);
  207. }
  208. }
  209. return bl;
  210. }
  211. #endregion
  212. }
  213. }