123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581 |
- using LeaRun.Application.Busines.NBManage;
- using LeaRun.Util.WebControl;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using LeaRun.Util;
- using Newtonsoft.Json.Linq;
- namespace LeaRun.Application.Web.Areas.NBManage.Controllers
- {
- public class NBUserManageController : MvcControllerBase
- {
- // GET: /NBManage/NBUserManage/
- NBUserManageBLL bll = new NBUserManageBLL();
- #region 用户管理
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 小区form
- /// </summary>
- /// <returns></returns>
- public ActionResult AreaForm()
- {
- return View();
- }
- /// <summary>
- /// 楼宇form
- /// </summary>
- /// <returns></returns>
- public ActionResult BldgForm()
- {
- return View();
- }
- /// <summary>
- /// 单元form
- /// </summary>
- /// <returns></returns>
- public ActionResult ApmtForm()
- {
- return View();
- }
- /// <summary>
- /// 用户form
- /// </summary>
- /// <returns></returns>
- public ActionResult UserForm()
- {
- return View();
- }
- /// <summary>
- /// 表具 from
- /// </summary>
- /// <returns></returns>
- public ActionResult MeterForm()
- {
- return View();
- }
- #endregion
- #region 获取用户管理数据列表
- /// <summary>
- /// 获取用户管理数据列表
- /// </summary>
- /// <param name="pagination"></param>
- /// <param name="keyword"></param>
- /// <param name="searchType"></param>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetNBUserList(Pagination pagination, string keyword, string searchType, string id, string level)
- {
- return Content(bll.GetNBUserList(pagination, keyword, searchType, id, level));
- }
- #endregion
- #region 保存区域数据
- /// <summary>
- /// 保存区域数据
- /// </summary>
- /// <param name="keyValue"></param>
- /// <param name="data"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveAreaForm(string keyValue, string data)
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- switch (bll.SaveAreaForm(data))
- {
- case 0:
- return Error("保存失败。");
- case 1:
- return Success("保存成功。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("保存失败。");
- }
- }
- else
- {
- switch (bll.EditAreaForm(keyValue, data))
- {
- case 0:
- return Error("修改失败。");
- case 1:
- return Success("修改成功。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("修改失败。");
- }
- }
- }
- #endregion
- #region 获取小区信息
- /// <summary>
- /// 获取小区信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult GetAreaInfo(string id)
- {
- return Content(bll.GetAreaInfo(id));
- }
- #endregion
- #region 删除小区信息
- /// <summary>
- /// 删除小区信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult DeleteAreaForm(string id)
- {
- switch (bll.DeleteAreaForm(id))
- {
- case 2:
- return Error("有下级数据,不允许删除。");
- case 1:
- return Success("删除成功。");
- case 0:
- return Error("删除失败。");
- default:
- return Error("删除失败。");
- }
- }
- #endregion
- #region 保存楼宇数据
- /// <summary>
- /// 保存楼宇数据
- /// </summary>
- /// <param name="keyValue"></param>
- /// <param name="data"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveBldgForm(string keyValue, string parentId, string data)
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- switch (bll.SaveBldgForm(parentId, data))
- {
- case 0:
- return Error("保存失败。");
- case 1:
- return Success("保存成功。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("保存失败。");
- }
- }
- else
- {
- switch (bll.EditBldgForm(parentId, keyValue, data))
- {
- case 0:
- return Error("修改失败。");
- case 1:
- return Success("修改成功。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("修改失败。");
- }
- }
- }
- /// <summary>
- /// 保存楼宇数据
- /// </summary>
- /// <param name="keyValue"></param>
- /// <param name="data"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveBatchBldgForm(string parentId, string data)
- {
- bll.SaveBatchBldgForm(parentId, data);
- return Success("修改成功。");
- }
- #endregion
- #region 获取楼宇信息
- /// <summary>
- /// 获取楼宇信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult GetBldgInfo(string id)
- {
- return Content(bll.GetBldgInfo(id));
- }
- #endregion
- #region 删除楼宇信息
- /// <summary>
- /// 删除小区信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult DeleteBldgForm(string id)
- {
- switch (bll.DeleteBldgForm(id))
- {
- case 2:
- return Error("有下级数据,不允许删除。");
- case 1:
- return Success("删除成功。");
- case 0:
- return Error("删除失败。");
- default:
- return Error("删除失败。");
- }
- }
- #endregion
- #region 保存单元数据
- /// <summary>
- /// 保存单元数据
- /// </summary>
- /// <param name="keyValue"></param>
- /// <param name="data"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveApmtForm(string keyValue, string parentId, string data)
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- switch (bll.SaveApmtForm(parentId, data))
- {
- case 0:
- return Error("保存失败。");
- case 1:
- return Success("保存成功。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("保存失败。");
- }
- }
- else
- {
- switch (bll.EditApmtForm(parentId, keyValue, data))
- {
- case 0:
- return Error("修改失败。");
- case 1:
- return Success("修改成功。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("修改失败。");
- }
- }
- }
- /// <summary>
- /// 批量保存单元数据
- /// </summary>
- /// <param name="data"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveBatchApmtForm(string parentId, string data)
- {
- bll.SaveBatchApmtForm(parentId, data);
- return Success("修改成功。");
- }
- #endregion
- #region 获取单元信息
- /// <summary>
- /// 获取单元信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult GetApmtInfo(string id)
- {
- return Content(bll.GetApmtInfo(id));
- }
- #endregion
- #region 删除单元信息
- /// <summary>
- /// 删除单元信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult DeleteApmtForm(string id)
- {
- switch (bll.DeleteApmtForm(id))
- {
- case 1:
- return Success("删除成功。");
- case 0:
- return Error("删除失败。");
- case 2:
- return Error("有下级数据,不允许删除。");
- default:
- return Error("删除失败。");
- }
- }
- #endregion
- #region 保存用户数据
- /// <summary>
- /// 保存用户数据
- /// </summary>
- /// <param name="keyValue"></param>
- /// <param name="parentId">单元ID</param>
- /// <param name="data">用户数据</param>
- /// <param name="roomNo">房间号</param>
- /// <param name="bldgId">楼宇ID</param>
- /// <param name="areaId">小区ID</param>
- /// <param name="meterData">水表数据</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveUserForm(string keyValue, string parentId, string data, string meterData)
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- int roomId = bll.SaveUserForm(parentId, data);
- //保存表具信息
- switch (bll.SaveMeterForm(roomId.ToString(), meterData))
- {
- case 0:
- return Success("保存成功。");
- default:
- return Error("保存失败。");
- }
- }
- else
- {
- switch (bll.EditUserForm(parentId, keyValue, data))
- {
- case 0:
- return Error("修改失败。");
- case 1:
- return Success("修改成功。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("修改失败。");
- }
- }
- }
- /// <summary>
- /// 批量保存用户数据
- /// </summary>
- /// <param name="keyValue"></param>
- /// <param name="data"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveBatchUserForm(string parentId, string data)
- {
- bll.SaveBatchUserForm(parentId, data);
- return Success("保存成功。");
- }
- #endregion
- #region 获取用户信息
- /// <summary>
- /// 获取用户信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult GetUserInfo(string id)
- {
- return Content(bll.GetUserInfo(id));
- }
- #endregion
- #region 删除用户信息
- /// <summary>
- /// 删除用户信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult DeleteUserForm(string id)
- {
- switch (bll.DeleteUserForm(id))
- {
- case 2:
- return Error("有下级数据,不允许删除。");
- case 1:
- return Success("删除成功。");
- case 0:
- return Error("删除失败。");
- default:
- return Error("删除失败。");
- }
- }
- #endregion
- #region 保存表具数据
- /// <summary>
- /// 保存表具数据
- /// </summary>
- /// <param name="keyValue"></param>
- /// <param name="data"></param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveMeterForm(string keyValue, string parentId, string data)
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- switch (bll.SaveMeterForm(parentId, data))
- {
- case 0:
- return Success("保存成功。");
- case 1:
- return Error("保存失败。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("保存失败。");
- }
- }
- else
- {
- switch (bll.EditMeterForm(keyValue, data))
- {
- case 0:
- return Success("保存成功。");
- case 1:
- return Error("修改失败。");
- case 2:
- return Error("重复数据。");
- default:
- return Error("修改失败。");
- }
- }
- }
- #endregion
- #region 获取表具信息
- /// <summary>
- /// 保存用户信息
- /// </summary>
- /// <param name="data"></param>
- /// <returns></returns>
- public ActionResult GetMeterByMeterId(string keyValue)
- {
- return Content(bll.GetMeterByMeterId(keyValue).ToJson());
- }
- #endregion
- #region 删除表具信息
- /// <summary>
- /// 删除表具信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult DeleteMeterForm(string id)
- {
- switch (bll.DeleteMeterForm(id))
- {
- case 1:
- return Success("删除成功。");
- case 0:
- return Error("删除失败。");
- default:
- return Error("删除失败。");
- }
- }
- #endregion
- /// <summary>
- /// 移动表的安装位置
- /// </summary>
- /// <returns></returns>
- public ActionResult RemoveMeterForm()
- {
- return View();
- }
- /// <summary>
- /// 移动表位置 操作保存
- /// </summary>
- /// <param name="meterId">表ID</param>
- /// <param name="jsonData">新位置JSON</param>
- /// <returns></returns>
- public ActionResult SaveMeterRemove(string meterId, string jsonData)
- {
- JObject jsonDataJObj; // jsonData 的JObject 对象
- JObject upJobj;//更新结果的 JObject 对象
- string areaId; // 区域ID
- string bldgId; // 楼宇ID
- string apmtId; // 单元ID
- string roomId; // 房间ID
- if (string.IsNullOrEmpty(meterId) || string.IsNullOrEmpty(jsonData) || "{}".Equals(jsonData))
- {
- return Error("参数不全!");
- }
- jsonDataJObj = jsonData.ToJObject();
- if (jsonDataJObj["AreaId"] != null && jsonDataJObj["BldgId"] != null && jsonDataJObj["ApmtId"] != null && jsonDataJObj["RoomId"] != null)
- {
- areaId = jsonDataJObj["AreaId"].ToString();
- bldgId = jsonDataJObj["BldgId"].ToString();
- apmtId = jsonDataJObj["ApmtId"].ToString();
- roomId = jsonDataJObj["RoomId"].ToString();
- //验证是否为 INT 类型值
- if (ValidateUtil.IsValidInt(meterId) && ValidateUtil.IsValidInt(areaId) && ValidateUtil.IsValidInt(bldgId) && ValidateUtil.IsValidInt(apmtId) && ValidateUtil.IsValidInt(roomId))
- {
- upJobj = bll.SaveMeterRemove(meterId, areaId, bldgId, apmtId, roomId).ToJObject();
- }
- else
- {
- return Error("参数格式错误!");
- }
- }
- else
- {
- return Error("参数不全!");
- }
- //失败
- if ("0".Equals(upJobj["code"].ToString()))
- {
- return Error(upJobj["message"].ToString());
- }
- return Success(upJobj["message"].ToString());
- }
- }
- }
|