452 lines
15 KiB
C#
452 lines
15 KiB
C#
using Epost.Common;
|
|
using Epost.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Epost.DAL
|
|
{
|
|
public class OrdersQueueDAL
|
|
{
|
|
DataBaseOpration.OprationSqlDAL db = DB_DLL.GetInstance();
|
|
#region 添加任务信息
|
|
public bool insertQueueOrders(OrdersQueueModel model)
|
|
{
|
|
string sql = string.Format("insert into OrdersQueue(shopid,sort,taskarea,state,taskblock,usercode,orderid,sku,location,matchid,lightcolor) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')",
|
|
model.Shopid,
|
|
model.Sort,
|
|
model.Taskarea,
|
|
model.State,
|
|
model.Taskblock,
|
|
model.UserCode,
|
|
model.Orderid,
|
|
model.Sku,
|
|
model.Location,
|
|
model.Matchid,
|
|
model.Lightcolor);
|
|
LogHelper.WriteLogInfo("进入拣货队列========="+sql);
|
|
long x = db.InsertSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
#region 获取任务信息
|
|
public DataTable getQueuesOrder()
|
|
{
|
|
string sql = "select * from OrdersQueue";
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
#region 获取任务信息
|
|
public DataTable getQueuesOrderbyState(string state="0")
|
|
{
|
|
string sql = string.Format("select * from OrdersQueue where state ='{0}'",
|
|
state);
|
|
// LogHelper.WriteLogInfo("获取正在绑定的信息" + sql);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取queue信息
|
|
public DataTable getQueuesOrderbyState(string block,string area,string state,string usercode)
|
|
{
|
|
string strwhere = string.Empty;
|
|
if (!string.IsNullOrEmpty(usercode))
|
|
{
|
|
strwhere += " and usercode= '" + usercode + "'";
|
|
}
|
|
string sql = string.Format("select * from OrdersQueue where (state ='{0}' or state='0') and taskblock='{1}' and taskarea='{2}' "+ strwhere,
|
|
state,
|
|
block,
|
|
area);
|
|
LogHelper.WriteLogInfo("获取queue信息" + sql);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
#region 获取任务信息
|
|
public DataTable getQueuesbyState()
|
|
{
|
|
string sql = "select * from OrdersQueue where state<>0 and state<>3";
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取任务信息
|
|
public DataTable getOrderqueueByAddr(string addr,string ip)
|
|
{
|
|
string sql =string.Format("select * from OrdersQueue where state=2 and taskarea='{0}' and taskblock='{1}'",
|
|
addr,
|
|
ip);
|
|
LogHelper.WriteLogInfo("获取=="+sql);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取当前区的作业状态
|
|
public DataTable getQueueOrderState(OrdersQueueModel model)
|
|
{
|
|
string sql = string.Format("select * from OrdersQueue where taskblock='{0}' and taskarea='{1}' and state=0 order by sort",
|
|
model.Taskblock,
|
|
model.Taskarea);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
#region 删除
|
|
public bool DeleteQueue(string matchid)
|
|
{
|
|
string sql = string.Format("delete from OrdersQueue where matchid='{0}'",
|
|
matchid);
|
|
long x = db.DeleteSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
public bool DeleteQueuebyUser(string strwhere)
|
|
{
|
|
string sql = string.Format("delete from OrdersQueue where 1=1 "+ strwhere
|
|
);
|
|
long x = db.DeleteSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
public bool DeleteOrderQueue(string matchid,string CancelTime)
|
|
{
|
|
string sql = string.Format("delete from OrdersQueue where matchid='{0}' and Addtime='{1}'",
|
|
matchid,CancelTime);
|
|
long x = db.DeleteSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取当前区的作业状态
|
|
public DataTable getQueueState(OrdersQueueModel model)
|
|
{
|
|
string sql = string.Format("select * from OrdersQueue where taskblock='{0}' and taskarea='{1}' and state=1",
|
|
model.Taskblock,
|
|
model.Taskarea);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
#region 获取当前区的作业状态
|
|
public DataTable getQueueState(string usercode,string matchid,string block,string area)
|
|
{
|
|
string sql = string.Format("select * from ordersqueue where UserCode='{0}' and matchid='{1}' and Taskblock='{2}' and TaskArea='{3}' and state in(0,1)",
|
|
usercode,
|
|
matchid,
|
|
block,
|
|
area);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
#region 获取用户下的所有sku
|
|
public DataTable getQueueSKU(OrdersQueueModel model)
|
|
{
|
|
string sql = string.Format("select sku from OrdersQueue where taskblock = '{0}' and taskarea = '{1}' and UserCode = '{2}'",
|
|
model.Taskblock,
|
|
model.Taskarea,
|
|
model.UserCode);
|
|
DataTable dt= db.GetsqlForDT(sql);
|
|
|
|
return dt;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 修改区域
|
|
public bool updateOrderQueue(string usercode, string block, string area, string sort)
|
|
{
|
|
string sql = string.Format("update ordersqueue set state = 0,sort='{0}',taskarea='{1}' where usercode='{2}' and taskblock ='{3}' and state<>3",
|
|
sort, area, usercode, block);
|
|
LogHelper.WriteLogInfo("修改区域" + sql);
|
|
long x = db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 换箱、拆箱后恢复作业
|
|
public bool updateOrderQueue(string block, string area)
|
|
{
|
|
string sql = string.Format("update ordersqueue set state = 0 where state=1 and taskblock='{0}' and TaskArea='{1}'",
|
|
block,area);
|
|
LogHelper.WriteLogInfo("换箱、拆箱后恢复作业" + sql);
|
|
long x = db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 修改作业全部完成
|
|
public bool updateOrderQueueState(string usercode, string block)
|
|
{
|
|
string sql = string.Format("update ordersqueue set state =3 where usercode='{0}' and taskblock ='{1}'",
|
|
usercode, block);
|
|
LogHelper.WriteLogInfo("修改作业全部完成" + sql);
|
|
long x = db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取当前区的队列
|
|
public DataTable getQueueOrderStateList(OrdersQueueModel model)
|
|
{
|
|
string sql = string.Format("select * from OrdersQueue where taskblock='{0}' and taskarea='{1}' ",
|
|
model.Taskblock,
|
|
model.Taskarea);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取sku是否正在作业
|
|
public DataTable GetOrderQueue(string block,string area,string state,string sku)
|
|
{
|
|
string sql = string.Format("select * from OrdersQueue where state ='{0}' or (state = 1 and sku='{3}') and taskblock='{1}' and taskarea='{2}'",
|
|
state,
|
|
block,area,sku);
|
|
LogHelper.WriteLogInfo("获取sku是否正在作业" + sql);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取sku是否正在作业
|
|
public DataTable GetOrderQueueByuser(string state, string usercode)
|
|
{
|
|
string sql = string.Format("select * from OrdersQueue where state ='{0}' and usercode = '{1}'",
|
|
state,
|
|
usercode);
|
|
LogHelper.WriteLogInfo("获取工号是否正在作业" + sql);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 获取当前区的作业状态
|
|
public bool UpdateQueueOrderState(OrdersQueueModel model)
|
|
{
|
|
string sql = string.Format("update OrdersQueue set state='{1}' where id ='{0}'",
|
|
model.Id,
|
|
model.State);
|
|
|
|
|
|
long x= db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
|
|
#region 修改作业状态
|
|
public bool UpdateQueueState(string id,string state)
|
|
{
|
|
string sql = string.Format("update OrdersQueue set state='{0}' where id ='{1}'",
|
|
state,id);
|
|
long x = db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定箱号完成
|
|
public bool UpdateBoxCode(string id,string boxcode)
|
|
{
|
|
string sql = string.Format("update OrdersQueue set state=3,boxcode='{0}' where id ='{1}'",
|
|
boxcode,
|
|
id);
|
|
long x = db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
|
|
#region 修改作业区段
|
|
public bool UpdateQueueTaskArea(OrdersQueueModel model)
|
|
{
|
|
string sql = string.Format("update OrdersQueue set taskarea='{0}',state='{2}' where orderid='{1}' and state<>2",
|
|
model.Taskarea,
|
|
model.Orderid,
|
|
model.State);
|
|
long x= db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 修改作业区段
|
|
public bool UpdateQueueTaskArea_Car(OrdersQueueModel model)
|
|
{
|
|
string strwhere = string.Empty;
|
|
if (!string.IsNullOrEmpty(model.Taskblock))
|
|
{
|
|
strwhere = "and taskblock='"+model.Taskblock+"'";
|
|
}
|
|
if (!string.IsNullOrEmpty(model.Taskarea))
|
|
{
|
|
strwhere += "and Taskarea='" + model.Taskarea + "'";
|
|
}
|
|
string sql = string.Format("update OrdersQueue set state='{0}' where state<>3 and usercode = '{1}' "+ strwhere,
|
|
model.State
|
|
,model.UserCode
|
|
|
|
|
|
);
|
|
LogHelper.WriteLogInfo("修改作业区段"+sql);
|
|
long x = db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 恢复作业
|
|
public bool UpdateQueueState()
|
|
{
|
|
string sql = string.Format("update OrdersQueue set state=0 where state<>3");
|
|
long x = db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
|
|
|
|
}
|
|
#endregion
|
|
#region 获取用户是否已领任务
|
|
public DataTable GetQueueByUser(string usercode)
|
|
{
|
|
string sql = string.Format("select * from OrdersQueue where state<>3 and usercode='{0}'",
|
|
usercode);
|
|
return db.GetsqlForDT(sql);
|
|
|
|
|
|
}
|
|
#endregion
|
|
#region 删除未进通道的箱号
|
|
public bool deleteBoxpick()
|
|
{
|
|
string sql = string.Format(" delete from Boxpick where shopid not in(select shopid from OrdersQueue )");
|
|
long x = db.DeleteSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 删除
|
|
public bool DeleteQueueOrder(string orderid)
|
|
{
|
|
string sql = string.Format("delete from OrdersQueue where orderid='{0}' and state=0",
|
|
orderid);
|
|
long x = db.DeleteSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 删除queue
|
|
public bool DelQueueOrder(string sku,string block,string area)
|
|
{
|
|
string sql = string.Format("delete from OrdersQueue where sku='{0}' and taskblock='{1}' and taskarea='{2}' and state<>3",
|
|
sku,block,area);
|
|
LogHelper.WriteLogInfo("删除queue"+sql);
|
|
long x = db.DeleteSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
|
|
#region 查询排序序号
|
|
public int getOrderAreaSort(string block, string area)
|
|
{
|
|
string sql = string.Format("select if (isnull(max(sort)),1,max(sort)) as sort from ordersqueue where TaskBlock='{0}' and TaskArea='{1}'",
|
|
block,
|
|
area);
|
|
LogHelper.WriteLogInfo("查询排序序号:" + sql);
|
|
DataTable dt = db.GetsqlForDT(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dt.Rows[0]["sort"].ToString());
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 删除queue
|
|
public bool DeleteQueue(string block,string area)
|
|
{
|
|
string sql = string.Format("delete from OrdersQueue where taskblock='{0}' and taskarea='{1}'",
|
|
block, area);
|
|
LogHelper.WriteLogInfo("清理orderqueue" + sql);
|
|
long x = db.DeleteSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取当前区的作业状态
|
|
public DataTable getQueueOrderStateList()
|
|
{
|
|
string sql = string.Format("select * from OrdersQueue where state<>2 and state<>3 order by sort");
|
|
return db.GetsqlForDT(sql);
|
|
|
|
}
|
|
#endregion
|
|
#region 扫描工号启动任务
|
|
public bool UpdateQueueByUser(string usercode,string color)
|
|
{
|
|
string sql = string.Format("update OrdersQueue set state = 0,usercode ='{0}',lightcolor='{1}' where state=2 ",
|
|
usercode,color);
|
|
long x= db.UpdateSql(sql);
|
|
if (x > 0)
|
|
return true;
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|