2023-01-13 15:30:20 +08:00
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 sql = string . Format ( "select * from OrdersQueue where (state ='{0}' or state='0') and taskblock='{1}' and taskarea='{2}' " ,
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<>2 and state<>3 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 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 sql = string . Format ( "select * from OrdersQueue where state <>'{0}' and taskblock='{1}' and taskarea='{2}'" ,
state ,
block , area ) ;
LogHelper . WriteLogInfo ( "获取sku是否正在作业" + 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 sku = '{1}' and matchid='{2}' and usercode='{3}'" + strwhere ,
model . State
, model . Sku ,
model . Matchid , 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 sql = string . Format ( "delete from OrdersQueue where sku='{0}' and taskblock='{1}' and state<>3" ,
sku , block ) ;
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
2024-01-15 17:37:47 +08:00
#region 获 取 最 新 一 条 记 录
public DataTable getQueueList ( )
{
string sql = string . Format ( "select top 1 * from OrdersQueue where state=3 order by id desc" ) ;
return db . GetsqlForDT ( sql ) ;
}
#endregion
2023-01-13 15:30:20 +08:00
}
}