using LeaRun.Application.Entity.WaterWellManage;
using LeaRun.Application.Service.WaterWellManage;
using LeaRun.Util;
using LeaRun.Util.WebControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LeaRun.Application.Busines.WaterWell
{
public class DeviceBLL
{
private DeviceService deviceService = new DeviceService();
private DeviceInfoService deviceInfoService = new DeviceInfoService();
#region 获取列表
///
/// 获取列表
///
///
///
///
public IEnumerable GetTreeEntity(string parentId, bool showcheck)
{
var parentdata = deviceService.GetList(parentId).ToList();
var treeList = new List();
foreach (var item in parentdata)
{
var tree = new TreeEntity();
tree.id = "sys" + item.OrganizeId;
tree.text = item.ShortName;
tree.isexpand = false;
tree.complete = true;
tree.hasChildren = true;
tree.parentId = "sys" + item.ParentId.ToString();
tree.value = "sys" + item.EnCode;
tree.showcheck = showcheck;
tree.checkstate = 1;
tree.isexpand = true;
//tree.cascadecheck = true;
treeList.Add(tree);
var childList = deviceService.GetList(item.OrganizeId).ToList();
if (childList.Count == 0)
{
//加载子级节点
treeList.AddRange(GetTreeList(tree.id, item.EnCode.ToString(), showcheck));
}
else
{
treeList.AddRange(GetTreeEntity(item.OrganizeId, showcheck));
}
}
return treeList;
}
#endregion
#region 根据父级Id生成左侧菜单TreeList
///
/// 根据父级Id生成左侧菜单TreeList
///
/// 父级Id,包含在哪个节点下面
/// 管理Id
///
///
public List GetTreeList(string parentId, string enCode, bool showcheck)
{
var treeList = new List();
var deviceInfoData = deviceInfoService.GetMenuList(enCode);
if (deviceInfoData != null && deviceInfoData.ToList().Count > 0)
{
foreach (DeviceInfoEntity item in deviceInfoData)
{
TreeEntity tree = new TreeEntity();
tree.id = "dev" + item.WaterWellId.ToString();
tree.text = item.WaterWellName;
tree.value = "dev" + item.WaterWellId;
tree.isexpand = false;
tree.complete = true;
tree.hasChildren = false;
tree.parentId = parentId;
tree.showcheck = showcheck;
tree.checkstate = 1;
tree.isexpand = true;
//tree.cascadecheck = true;
treeList.Add(tree);
}
}
return treeList;
}
#endregion
#region 获取无父级列表
///
/// 获取无父级列表
///
///
///
public string GetTreeList(bool showcheck)
{
return Json.ToJson(deviceInfoService.GetTreeList(showcheck));
}
#endregion
#region 根据名称模糊查询获取水源井列表
///
/// 根据名称获取水源井列表
///
///
///
public string SearchWaterWellLikeName(string name)
{
return deviceInfoService.SearchWaterWellLikeName(name);
}
#endregion
#region 水源井名称列表查询
///
/// 水源井名称列表查询
///
public string SearchWaterWellName()
{
return deviceInfoService.SearchWaterWellName();
}
#endregion
#region 获取所有设备列表
///
/// 获取所有设备列表
///
///
public string GetAllDevice()
{
return Json.ToJson(deviceInfoService.GetAllDevice());
}
#endregion
}
}