using Learun.Util;
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
namespace Learun.Application.TwoDevelopment.LogisticsManagement
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-04-26 15:02
/// 描 述:学生宿舍管理
///
public class AccommodationBLL : AccommodationIBLL
{
private AccommodationService accommodationService = new AccommodationService();
#region 获取数据
///
/// 获取页面显示列表数据
///
/// 查询参数
///
public IEnumerable GetPageList(Pagination pagination, string queryJson)
{
try
{
return accommodationService.GetPageList(pagination, queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public IEnumerable GetBedListByRoomId(string RoomId)
{
try
{
return accommodationService.GetBedListByRoomId(RoomId);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public IEnumerable GetAllList()
{
try
{
return accommodationService.GetAllList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public IEnumerable GetClassifyList(Pagination paginationobj, string queryJson)
{
try
{
return accommodationService.GetClassifyList(paginationobj, queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public object GetDormitoryList()
{
try
{
return accommodationService.GetDormitoryList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public object GetUnitList(string ParentID)
{
try
{
return accommodationService.GetUnitList(ParentID);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public object GetFloorList(string parentID)
{
try
{
return accommodationService.GetFloorList(parentID);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public object GetRoomList(string parentID)
{
try
{
return accommodationService.GetRoomList(parentID);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public object GetBedList(string parentID)
{
try
{
return accommodationService.GetBedList(parentID);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public string GetBuildType(string parentID)
{
try
{
return accommodationService.GetBuildType(parentID);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public string GetParentBuildType(string keyValue)
{
try
{
return accommodationService.GetParentBuildType(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取Acc_DormitoryBuild表实体数据
/// 主键
///
///
public Acc_DormitoryBuildEntity GetAcc_DormitoryBuildEntity(string keyValue)
{
try
{
return accommodationService.GetAcc_DormitoryBuildEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取Acc_DormitoryBuild表实体数据
/// 主键
///
///
public Acc_DormitoryBuildEntity GetAcc_DormitoryBuildEntityByName(string name)
{
try
{
return accommodationService.GetAcc_DormitoryBuildEntityByName(name);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取Acc_DormitoryBuild表实体数据
/// 主键
///
///
public List GetList()
{
try
{
return accommodationService.GetSqlTree();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
//public List GetDept()
//{
// try
// {
// return accommodationService.GetSelectData("").Select(x => new Acc_DormitoryBuildEntity { Dept = x.Dept, DeptName = x.DeptName }).Distinct().ToList();
// }
// catch (Exception ex)
// {
// if (ex is ExceptionEx)
// {
// throw;
// }
// else
// {
// throw ExceptionEx.ThrowBusinessException(ex);
// }
// }
//}
//public List GetMajor(string strWhere)
//{
// try
// {
// return accommodationService.GetSelectData(strWhere).Select(x => new Acc_DormitoryBuildEntity { Major = x.Major, MajorName = x.MajorName }).Distinct().ToList();
// }
// catch (Exception ex)
// {
// if (ex is ExceptionEx)
// {
// throw;
// }
// else
// {
// throw ExceptionEx.ThrowBusinessException(ex);
// }
// }
//}
//public List GetClass(string strWhere)
//{
// try
// {
// return accommodationService.GetSelectData(strWhere).Select(x => new Acc_DormitoryBuildEntity { Class = x.Class, ClassName = x.ClassName }).Distinct().ToList();
// }
// catch (Exception ex)
// {
// if (ex is ExceptionEx)
// {
// throw;
// }
// else
// {
// throw ExceptionEx.ThrowBusinessException(ex);
// }
// }
//}
public List GetDept()
{
try
{
return accommodationService.GetDeptOrMajorOrClass("").Select(x => new Acc_DormitoryBuildEntity { Dept = x.Dept, DeptName = x.DeptName }).Distinct().ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public List GetMajor(string strWhere)
{
try
{
return accommodationService.GetDeptOrMajorOrClass(strWhere).Select(x => new Acc_DormitoryBuildEntity { Major = x.Major, MajorName = x.MajorName }).Distinct().ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public List GetClass(string strWhere)
{
try
{
return accommodationService.GetDeptOrMajorOrClass(strWhere).Select(x => new Acc_DormitoryBuildEntity { Class = x.Class, ClassName = x.ClassName }).Distinct().ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取左侧树形数据
///
///
public List GetTree()
{
try
{
List list = accommodationService.GetSqlTree();
List treeList = new List();
foreach (Acc_DormitoryBuildEntity item in list)
{
TreeModel node = new TreeModel
{
id = item.ID.ToString(),
text = item.Name.ToString(),
value = item.ID.ToString(),
showcheck = false,
checkstate = 0,
isexpand = true,
parentId = item.ParentID == null ? "" : item.ParentID,
title = item.BuildType
};
treeList.Add(node);
}
return treeList.ToTree();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public List GetTreeNew()
{
try
{
List list = accommodationService.GetSqlTreeNew();
List treeList = new List();
foreach (Acc_DormitoryBuildEntity item in list)
{
TreeModel node = new TreeModel
{
id = item.ID.ToString(),
text = item.Name.ToString(),
value = item.ID.ToString(),
showcheck = false,
checkstate = 0,
isexpand = false,
parentId = item.ParentID == null ? "" : item.ParentID
};
treeList.Add(node);
}
return treeList.ToTree();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public List GetClassifyTree()
{
try
{
List list = accommodationService.GetClassifyTree();
List treeList = new List();
foreach (Acc_DormitoryBuildEntity item in list)
{
TreeModel node = new TreeModel
{
id = item.ID.ToString(),
text = item.Name.ToString(),
value = item.ID.ToString(),
showcheck = false,
checkstate = 0,
isexpand = false,
parentId = item.ParentID == null ? "" : item.ParentID,
title = string.IsNullOrEmpty(item.BuildType) ? "" : (Convert.ToInt32(item.BuildType) + 1).ToString(),
};
treeList.Add(node);
}
return treeList.ToTree();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 根据父id 获取树形数据
///
///
///
public List GetTreeByParentID(string parentID)
{
try
{
DataTable list = accommodationService.GetTreeByParentId(parentID);
List treeList = new List();
foreach (DataRow item in list.Rows)
{
TreeModel node = new TreeModel
{
id = item["id"].ToString(),
text = item["name"].ToString(),
value = item["id"].ToString(),
showcheck = false,
checkstate = 0,
isexpand = true,
parentId = item["parentid"].ToString()
};
treeList.Add(node);
}
return treeList.ToTree();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 根据父id 获取树形数据
///
///
///
public string GetDormitoryInfoByPlanStuNo(string stuNo)
{
try
{
return accommodationService.GetDormitoryInfoByPlanStuNo(stuNo);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public string GetDormitoryInfoByStuNo(string stuNo)
{
try
{
return accommodationService.GetDormitoryInfoByStuNo(stuNo);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public bool MatchDormitoryInfo(string stuNo, string dormitory, string unit, string floor, string room, string bed, List data)
{
try
{
return accommodationService.MatchDormitoryInfo(stuNo, dormitory, unit, floor, room, bed, data);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 删除实体数据
/// 主键
///
///
public void DeleteEntity(string keyValue)
{
try
{
accommodationService.DeleteEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 删除实体数据
/// 主键
///
///
public void DeleteBed(string keyValue, string ParentID)
{
try
{
accommodationService.DeleteBed(keyValue, ParentID);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
public void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity)
{
try
{
accommodationService.SaveEntity(keyValue, entity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
public void SaveBedEntity(string keyValue, string ParentID, Acc_DormitoryBuildEntity entity)
{
try
{
accommodationService.SaveBedEntity(keyValue, ParentID, entity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 分配系
///
///
///
public void SaveDeptClass(string keyValue, Acc_DormitoryBuildEntity entity, int type)
{
try
{
accommodationService.SaveDeptClass(keyValue, entity, type);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public string SaveRoom(string RoomId, List list)
{
try
{
return accommodationService.SaveRoom(RoomId, list);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 批量添加单元、楼层、宿舍、床位
///
///
///
///
///
///
public void DormitoryAdd(string keyValue, int elementNum, int floorNum, int roomNum, int bedNum)
{
try
{
accommodationService.DormitoryAdd(keyValue, elementNum, floorNum, roomNum, bedNum);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 随机分配床位给学生
///
/// 是否不许一个名族的在一起
/// 是否不许一个地方的在一起
public void Automatic_allocation_accommodation(bool noNation, bool noPlace)
{
try
{
accommodationService.Automatic_allocation_accommodation(noNation, noPlace, "1");
accommodationService.Automatic_allocation_accommodation(noNation, noPlace, "0");
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public void SyncData()
{
try
{
accommodationService.SyncData();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 清空实体数据
/// 主键
///
///
public void ClearEntity(string Grade)
{
try
{
accommodationService.ClearEntity(Grade);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
}
}