| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- using CallCenter.Utility;
- 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
- {
- [Authority]
- public class ATheChangeLogController : BaseController
- {
- // GET: ATheChangeLog
- private BLL.T_Sys_ATheChangeLog areaBLL = new BLL.T_Sys_ATheChangeLog();
- private BLL.T_Sys_BTheChangeLog BreaBLL = new BLL.T_Sys_BTheChangeLog();
- #region 区域
- /// <summary>
- /// 获取区域列表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetATheChangeLogList()
- {
- //int userId = CurrentUser.UserData.F_UserId;
- //Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- string where = " F_IsDelete=0 ";
- //if (!string.IsNullOrEmpty(userModel.groupcode))
- //{
- // where += " and F_GroupCode = '" + userModel.groupcode + "'";
- //}
- DataTable dt = areaBLL.GetList(0, where, " F_Sort asc").Tables[0];
- return Success("加载成功", dt);
- }
- /// <summary>
- /// 获取区域列表
- /// </summary>
- /// <returns></returns>
- public ActionResult GetAreaListById(int id = 0)
- {
- //int userId = CurrentUser.UserData.F_UserId;
- //Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- string where = " isnull(F_ParentId,0)='" + id + "' and F_IsDelete=0 ";
- //if (!string.IsNullOrEmpty(userModel.groupcode))
- //{
- // where += " and F_GroupCode = '" + userModel.groupcode + "'";
- //}
- DataTable dt = areaBLL.GetList(0, where, " F_Sort asc").Tables[0];
- return Success("列表加载成功", dt);
- }
- /// <summary>
- /// 获取区域
- /// </summary>
- /// <param name="areaId"></param>
- /// <returns></returns>
- public ActionResult GetATheChangeLog()
- {
- int id = RequestString.GetInt("id", 0);
- Model.T_Sys_ATheChangeLog dModel = areaBLL.GetModel(id);
- if (dModel != null)
- return Success("获取信息成功", dModel);
- return Error("获取信息失败");
- }
- /// <summary>
- /// 添加转移记录
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult AddAreaATheChangeLog()
- {
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- //接收Id
- int id = RequestString.GetInt("id", 0);
- //档案信息Id
- int pid = RequestString.GetInt("F_CustomerId", 0);
- //int sort = RequestString.GetInt("sort", 0);
- //string name = RequestString.GetFormString("name");
- //string code = RequestString.GetFormString("code");
- Model.T_Sys_ATheChangeLog dModel = new Model.T_Sys_ATheChangeLog();
- if (id == 0)
- {
-
- dModel.F_CreateUserId = userId;
- dModel.F_CreateUserName = userModel.F_UserName;
- dModel.F_CreateDate = DateTime.Now;
- dModel.F_deptid = userModel.F_DeptId;
- dModel.F_deptname = userModel.depname;
- dModel.F_type = 0;
- dModel.F_CustomerId = pid;
- dModel.F_Memo = "系统自动记录转移";
- int n = areaBLL.Add(dModel);
- if (n > 0)
- return Success("添加成功", n);
- else
- return Error("添加失败");
-
- }
- else
- {
- dModel = areaBLL.GetModel(id);
- if (dModel != null)
- {
- dModel.F_CreateUserId = userId;
- dModel.F_CreateUserName = userModel.F_UserName;
- dModel.F_CreateDate = DateTime.Now;
- dModel.F_deptid = userModel.F_DeptId;
- dModel.F_deptname = userModel.depname;
- dModel.F_type = 0;
- dModel.F_CustomerId = pid;
- dModel.F_Memo = "系统自动记录转移编辑";
- if (areaBLL.Update(dModel))
- return Success("修改成功");
- else
- return Error("修改失败");
-
- }
- else
- {
- return Error("修改失败");
- }
- }
- }
- /// <summary>
- /// 添加接收记录
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult AddBTheChangeLog()
- {
- int userId = CurrentUser.UserData.F_UserId;
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- //接收Id
- int ATheChangeLogid = RequestString.GetInt("ATheChangeLogid", 0);
- //档案信息Id
- //int pid = RequestString.GetInt("F_CustomerId", 0);
- //int sort = RequestString.GetInt("sort", 0);
- //string name = RequestString.GetFormString("name");
- //string code = RequestString.GetFormString("code");
- Model.T_Sys_BTheChangeLog dModel = new Model.T_Sys_BTheChangeLog();
- dModel.F_CreateUserId = userId;
- dModel.F_CreateUserName = userModel.F_UserName;
- dModel.F_CreateDate = DateTime.Now;
- dModel.F_deptid = userModel.F_DeptId;
- dModel.F_deptname = userModel.depname;
- // dModel.F_type = 0;
- dModel.F_ATheChangeLog = ATheChangeLogid;
- dModel.F_Memo = "系统自动接收记录";
- int n = BreaBLL.Add(dModel);
- //转移方 状态变为 1
- string sql = " update T_Sys_ATheChangeLog set F_type=1 where F_Id="+ ATheChangeLogid;
- //登记信息 变为外部转入
- Model.T_Sys_ATheChangeLog AModel = new BLL.T_Sys_ATheChangeLog().GetModel(ATheChangeLogid);
- string sql2 = " update T_Rec_RegRecords set F_InnerType=1 where F_Id=" + AModel.F_CustomerId;
- int a =DbHelperSQL.ExecuteSql(sql);
- int b = DbHelperSQL.ExecuteSql(sql2);
- if (n > 0 && a==1 && b==1)
- return Success("添加成功", n);
- else
- return Error("添加失败");
- }
- /// <summary>
- /// 删除 之前看是否有接收记录
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult DelATheChangeLog(string[] ids)
- {
- if (ids == null || ids.Length <= 0)
- return Error("请选择要删除的转移");
- var idStr = string.Join(",", ids);
- if (string.IsNullOrEmpty(idStr.Trim()))
- return Error("请选择要删除的转移");
- if (areaBLL.DeleteList(idStr))
- return Success("删除成功");
- return Error("删除失败");
- }
- /// <summary>
- /// 删除区域和其下级区域
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult DelAreas(int id)
- {
- if (id > 0)
- {
- var model = new BLL.T_Sys_Area().GetModel(id);
- if (DelAreasByPId(id))
- {
- new BLL.T_Sys_Area().Delete(id);
- }
- return Success("删除成功");
- }
- else
- {
- return Error("删除失败");
- }
- }
- public bool DelAreasByPId(int id)
- {
- bool bl = true;
- var list = new BLL.T_Sys_Area().GetModelList(" F_ParentId ='" + id + "'");
- foreach (var l in list)
- {
- if (DelAreasByPId(l.F_Id))
- {
- new BLL.T_Sys_Area().Delete(l.F_Id);
- }
- }
- return bl;
- }
- #endregion
- }
- }
|