using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlTypes;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using Common;
|
using Model;
|
using Model.WcsModel;
|
|
namespace BLL.DAL
|
{
|
public class DAL_Alarm
|
{
|
public IList<WCSAlarmInfo> GetList(AjaxAlarmInfoList Json, ref PageInfo pageInfo)
|
{
|
try
|
{
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("Select * from WCSAlarmInfo where Status=1 ");
|
|
if (!string.IsNullOrWhiteSpace(Json.AlarmCode))
|
{
|
strSql.Append(" and AlarmCode like '%" + Json.AlarmCode + "%' ");
|
}
|
if (!string.IsNullOrWhiteSpace(Json.AlarmName))
|
{
|
strSql.Append(" and AlarmName like '%" + Json.AlarmName + "%' ");
|
}
|
DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), null, "CreateTime", "Desc", ref pageInfo);
|
return ModelConvertHelper<WCSAlarmInfo>.DataTableToModel(dt);
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
//获取排序好的储位俯视图列表
|
public IList<WCSStorageLocat> GetLocatList()
|
{
|
try
|
{
|
StringBuilder strSql = new StringBuilder();
|
strSql.Append("select WareHouseNo,RoadwayNo,Row,Depth,MAX([Column]) from WCSStorageLocat where IsDel = '0' and WareHouseNo = 'W01' group by WareHouseNo,RoadwayNo,Row,Depth " +
|
"ORDER BY " +
|
" RoadwayNo,Row,CASE " +
|
" WHEN Row % 2 = 1 and Depth = '02' THEN '00' " +
|
" WHEN Row % 2 = 1 and Depth = '01' THEN '01' " +
|
" WHEN Row % 2 = 0 and Depth = '02' THEN '02' " +
|
" WHEN Row % 2 = 0 and Depth = '01' THEN '01' " +
|
"END; ");
|
DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
|
List<WCSStorageLocat> list = (List<WCSStorageLocat>)ModelConvertHelper<WCSStorageLocat>.DataTableToModel(dt);
|
#region 注释无用代码
|
//获取对应垛机起始目标位置
|
//for (int i = 0; i < list.Count; i++)
|
//{
|
// //临时位置(实际位置到现成与plc沟通
|
// if (i == 0)
|
// {
|
// list[i].Column2 = list[i].Column1 + 1;
|
// list[i].Column3 = 0;
|
// }
|
// else
|
// {
|
// if (list[i - 1].RoadwayNo == list[i].RoadwayNo)
|
// {
|
// list[i].Column2 = list[i - 1].Column2;
|
// list[i].Column3 = list[i - 1].Column3;
|
// }
|
// else if (i == 4)
|
// {
|
// list[i].Column2 = 24;
|
// list[i].Column3 = 11;
|
// }
|
// else if (i == 8)
|
// {
|
// list[i].Column2 = i + 30;
|
// list[i].Column3 = list[i].Column1 + 1;
|
// }
|
// else if (i == 12)
|
// {
|
// list[i].Column2 = 3;
|
// list[i].Column3 = 42;
|
// }
|
// else if (i == 16)
|
// {
|
// list[i].Column2 = 9;
|
// list[i].Column3 = 33;
|
// }
|
// else if (i == 20)
|
// {
|
// list[i].Column2 = 30;
|
// list[i].Column3 = 50;
|
// }
|
// else if (i == 24)
|
// {
|
// list[i].Column2 = list[i].Column1 + 1;
|
// list[i].Column3 = list[i].Column1;
|
// }
|
// }
|
//}
|
#endregion
|
return list;
|
}
|
catch
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public bool AlarmDelete(string[] ID)
|
{
|
bool result = false;
|
try
|
{
|
int dt = DataFactory.SqlDataBase().IsExist("Alarm", "ID", ID);
|
if (dt >= ID.Length)
|
{
|
int i = 0;
|
while (i < ID.Length)
|
{
|
StringBuilder sql = new StringBuilder();
|
sql.Append("update Alarm set IsDel=1 where Id='" + ID[i] + "'");
|
int _ret = DataFactory.SqlDataBase().ExecuteBySql(sql);
|
if (_ret >= ID.Length) result = true;
|
i++;
|
}
|
|
}
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
|
public bool AlarmDispose(string[] ID, string loginUser)
|
{
|
bool result = false;
|
try
|
{
|
int dt = DataFactory.SqlDataBase().IsExist("Alarm", "ID", ID);
|
if (dt >= ID.Length)
|
{
|
int i = 0;
|
while (i < ID.Length)
|
{
|
StringBuilder sql = new StringBuilder();
|
sql.Append("update Alarm set State = 1,UpdateUser = '" + loginUser + "',UpdateTime = getdate() where Id='" + ID[i] + "'");
|
int _ret = DataFactory.SqlDataBase().ExecuteBySql(sql);
|
if (_ret >= ID.Length) result = true;
|
i++;
|
}
|
|
}
|
return result;
|
|
}
|
catch
|
{
|
return result;
|
}
|
}
|
}
|
}
|