添加项目文件。
This commit is contained in:
378
Epost.BLL/AddressstorageBLL.cs
Normal file
378
Epost.BLL/AddressstorageBLL.cs
Normal file
@ -0,0 +1,378 @@
|
||||
using Epost.DAL;
|
||||
using Epost.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static Epost.Model.AddressCheckModel;
|
||||
|
||||
namespace Epost.BLL
|
||||
{
|
||||
public class AddressstorageBLL
|
||||
{
|
||||
AddressstorageDAL dal = new AddressstorageDAL();
|
||||
|
||||
|
||||
|
||||
#region 查询设备所在区
|
||||
public DataTable getBlock(string address, string type, string controlip)
|
||||
{
|
||||
return dal.getBlock(address, type, controlip);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据标签地址 查询货位号
|
||||
public DataTable getLocationList(string address, string controlIP)
|
||||
{
|
||||
return dal.getLocationList(address, controlIP);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region 根据标签地址 查询货位号
|
||||
public DataTable getArea(string address, string controlIP)
|
||||
{
|
||||
return dal.getArea(address, controlIP);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据货位号查询标签地址
|
||||
public DataTable getAddressList(string location)
|
||||
{
|
||||
return dal.getAddressList(location);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region 根据货位号查询标签地址
|
||||
public DataTable getOrderAddress(string location)
|
||||
{
|
||||
return dal.getOrderAddress(location);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 根据小车编号获取控制器Ip地址
|
||||
public DataTable getIP(string carid)
|
||||
{
|
||||
return dal.getIP(carid);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据货位号查询标签地址
|
||||
public DataTable getAddressListByway(string location, string block, string area, string way)
|
||||
{
|
||||
return dal.getAddressListByway(location, block, area, way);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据区域 查询显示箱号地址
|
||||
public DataTable getAddressByBlock(string block)
|
||||
{
|
||||
return dal.getAddressByBlock(block);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据区域 查询显示箱号地址
|
||||
public DataTable getAddressByBlock(string block, string area)
|
||||
{
|
||||
return dal.getAddressByBlock(block, area);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取箱号显示标签
|
||||
public DataTable GetBoxAddress(string block,string area,int type)
|
||||
{
|
||||
return dal.GetBoxAddress(block,area,type);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据区域获取所有地址
|
||||
public DataTable getAddresslist(string block, string area,string type)
|
||||
{
|
||||
return dal.getAddresslist(block, area,type);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取扫描枪地址
|
||||
public DataTable GetScanList()
|
||||
{
|
||||
return dal.GetScanList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取通道灯地址
|
||||
public DataTable GetLightList()
|
||||
{
|
||||
return dal.GetLightList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 根据区域获取扫描枪地址
|
||||
public DataTable GetScanListByArea(string block, string area)
|
||||
{
|
||||
return dal.GetScanListByArea(block, area);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据区域获取通道灯地址
|
||||
public DataTable GetlightListByArea(string block, string area)
|
||||
{
|
||||
return dal.GetlightListByArea(block, area);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取控制器列表
|
||||
public DataTable getControlList()
|
||||
{
|
||||
return dal.getControlList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region 获取控制器列表
|
||||
public DataTable getLabelList(string controlid)
|
||||
{
|
||||
return dal.getLabelList(controlid);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取所有地址
|
||||
public DataTable getAddressList()
|
||||
{
|
||||
return dal.getAddressList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取所有大区
|
||||
public DataTable GetBlockList()
|
||||
{
|
||||
return dal.GetBlockList();
|
||||
}
|
||||
#endregion
|
||||
#region 获取控制器列表
|
||||
public List<AddressstorageModel> getDeviceList(string controlid)
|
||||
{
|
||||
DataTable dt = dal.getLabelList(controlid);
|
||||
return Common.ModelConvertHelper<AddressstorageModel>.ConvertToList(dt);
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region 获取所有小区
|
||||
public DataTable GetAreaListDT()
|
||||
{
|
||||
return dal.GetAreaList();
|
||||
}
|
||||
#endregion
|
||||
#region 获取所有小区
|
||||
public List<AddressstorageModel> GetAreaList(string block = "")
|
||||
{
|
||||
return dal.GetAreaList(block);
|
||||
}
|
||||
#endregion
|
||||
#region 获取所有通道
|
||||
public DataTable GetWayList()
|
||||
{
|
||||
return dal.GetWayList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
//#region
|
||||
///// <summary>
|
||||
///// 分页获取数据列表
|
||||
///// </summary>
|
||||
//public List<Model.AddressstorageModel> GetCityListByPage(string strWhere, string orderby, int pageSize, int pageIndex, out int recordCount)
|
||||
//{
|
||||
// int startIndex = 0;
|
||||
// int endIndex = 0;
|
||||
// if (pageIndex <= 0)
|
||||
// pageIndex = 1;
|
||||
// //计算查询的开始行数与结束行数
|
||||
// startIndex = (pageIndex - 1) * pageSize + 1;
|
||||
// endIndex = pageIndex * pageSize;
|
||||
// return dal.GetCityListByPage(strWhere, orderby, startIndex, endIndex, out recordCount);
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
|
||||
|
||||
#region 分页获取数据列表
|
||||
/// <summary>
|
||||
/// 分页获取数据列表
|
||||
/// </summary>
|
||||
public List<Model.AddressstorageModel> GetCityListByPage(string strWhere, string orderby, int pageSize, int pageIndex, out int recordCount)
|
||||
{
|
||||
int startIndex = 0;
|
||||
int endIndex = 0;
|
||||
if (pageIndex <= 0)
|
||||
pageIndex = 1;
|
||||
//计算查询的开始行数与结束行数
|
||||
startIndex = (pageIndex - 1) * pageSize + 1;
|
||||
endIndex = pageIndex * pageSize;
|
||||
return dal.GetLocationListByPage(strWhere, orderby, startIndex, endIndex, out recordCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//获取地址的检测的设备信息
|
||||
public static Dictionary<bool, Dictionary<string, List<Detail>>> listcheck = new Dictionary<bool, Dictionary<string, List<Detail>>>();
|
||||
public static List<Detail> list = new List<Detail>();
|
||||
Dictionary<string, List<Detail>> lists2 = new Dictionary<string, List<Detail>>();
|
||||
ErrorLogBLL errorLog = new ErrorLogBLL();
|
||||
#region 一直循环检测出设备返回的状态
|
||||
public static int Check()
|
||||
{
|
||||
while (listcheck.Count == 0)
|
||||
{
|
||||
ErrorLogBLL errorLogc = new ErrorLogBLL();
|
||||
//errorLogc.SaveSysytemError("调用接口一直等待", "程序一直在检测接口的数据,一直没有发过来");
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
return listcheck.Count;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 接口调用方法返回的信息
|
||||
public bool AddOrder(List<Detail> model)
|
||||
{
|
||||
string s = "1";
|
||||
list.Clear();
|
||||
lists2.Clear();
|
||||
listcheck.Clear();
|
||||
try
|
||||
{
|
||||
|
||||
for (int i = 0; i < model.Count; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model[i].Address) || string.IsNullOrEmpty(model[i].ControlIP))
|
||||
{
|
||||
s = "2";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
s = "3";
|
||||
}
|
||||
}
|
||||
if (s == "3")
|
||||
{
|
||||
list.AddRange(model);
|
||||
//将list排序
|
||||
//控制器Ip
|
||||
var details = (from d in list
|
||||
group d by d.ControlIP
|
||||
into g
|
||||
orderby g.Key
|
||||
where g.Count() > 0
|
||||
select new
|
||||
{
|
||||
g.Key,
|
||||
|
||||
}
|
||||
).ToList();
|
||||
//根据ip查询所有的地址
|
||||
string address_error = "";
|
||||
foreach (var a in details)
|
||||
{
|
||||
List<Detail> dtlist = list.FindAll(m => m.ControlIP == a.Key.ToString());
|
||||
List<Detail> su = dtlist.OrderBy(f => Convert.ToInt32(f.Address)).ToList();
|
||||
lists2.Add(a.Key.ToString(), su);
|
||||
address_error += a.Key.ToString() + "(IP):";
|
||||
for (int i = 0; i < su.Count; i++)
|
||||
{
|
||||
address_error += su[i].Address.ToString() + ",";
|
||||
}
|
||||
address_error += "|";
|
||||
}
|
||||
//如何判断接口被调用
|
||||
listcheck.Add(true, lists2);
|
||||
|
||||
//将调用接口成功返回的错误的地址和ip打包放置到数据库中去
|
||||
errorLog.SaveOperateError("调用接口成功", "返回的地址错误信息:" + address_error);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
listcheck.Add(true, lists2);
|
||||
errorLog.SaveOperateError("调用接口成功", "无错误返回");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
errorLog.SaveSysytemError("调用接口失败", ex.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取错误信息的state
|
||||
public DataTable GetErrorState(string address,string ip)
|
||||
{
|
||||
return dal.getErrorState(address,ip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 改变state的值为3
|
||||
public bool UpdateErrorState(string address, string ip)
|
||||
{
|
||||
return dal.UpdateErrorState(address, ip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 改变所有state的值为1
|
||||
public bool UpdateState()
|
||||
{
|
||||
return dal.UpdateState();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取所有设备
|
||||
public DataTable GetALLList(string strwhere)
|
||||
{
|
||||
return dal.GetALLList(strwhere);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 分页获取所有设备列表
|
||||
/// <summary>
|
||||
/// 分页获取数据列表
|
||||
/// </summary>
|
||||
public List<Model.AddressstorageModel> GetAddrListByPage(string strWhere, string orderby, int pageSize, int pageIndex, out int recordCount)
|
||||
{
|
||||
|
||||
int startIndex = 0;
|
||||
int endIndex = 0;
|
||||
if (pageIndex <= 0)
|
||||
pageIndex = 1;
|
||||
//计算查询的开始行数与结束行数
|
||||
startIndex = (pageIndex - 1) * pageSize + 1;
|
||||
endIndex = pageIndex * pageSize;
|
||||
return dal.GetAddressListByByPage(strWhere, orderby, startIndex, endIndex, out recordCount);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user