This commit is contained in:
@ -48,7 +48,7 @@ namespace Epost.DAL
|
||||
string sql = string.Empty;
|
||||
if (!string.IsNullOrEmpty(area))
|
||||
{
|
||||
sql = string.Format("select id, ProdArea, LotNo, Matchid, orderid, barcode, BatchId, DownDate, Tolocation, Sku, GoodsName, Discount, Quantity, GoodsType, corlorcode, address, ControlIP,area, block,boxcode,bkbarcode,isnull(checkquantity,0) as checkquantity,wholeunit,unit,shopid,wmsboxcode from v_orders where state = 0 and oprationstate <>3 and sku = '{0}' and block = '{1}' and area='{2}' " + strwhere + "",
|
||||
sql = string.Format("select id, Matchid, orderid, barcode, BatchId, DownDate, Tolocation, Sku, GoodsName, Discount, Quantity, address, ControlIP,area, block,unit,shopid from v_orders where state = 0 and oprationstate <>3 and sku = '{0}' and block = '{1}' and area='{2}' " + strwhere + "",
|
||||
|
||||
sku,
|
||||
block, area);
|
||||
@ -56,7 +56,7 @@ namespace Epost.DAL
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = string.Format("select id,ProdArea, LotNo, Matchid, orderid, barcode, BatchId, DownDate, Tolocation, Sku, GoodsName, Discount, Quantity, GoodsType, corlorcode, address, ControlIP, area , block,boxcode,bkbarcode,isnull(checkquantity,0) as checkquantity,wholeunit,unit,shopid,wmsboxcode from v_orders where state = 0 and oprationstate <>3 and sku = '{0}' and block = '{1}' " + strwhere + "",
|
||||
sql = string.Format("select id, Matchid, orderid, barcode, BatchId, DownDate, Tolocation, Sku, GoodsName, Discount, Quantity, address, ControlIP, area , block,unit,shopid from v_orders where state = 0 and oprationstate <>3 and sku = '{0}' and block = '{1}' " + strwhere + "",
|
||||
|
||||
sku,
|
||||
block);
|
||||
@ -90,7 +90,7 @@ namespace Epost.DAL
|
||||
string sql = string.Empty;
|
||||
if (!string.IsNullOrEmpty(area))
|
||||
{
|
||||
sql = string.Format("select id,ProdArea, LotNo, Matchid, orderid, barcode, BatchId, DownDate, Tolocation, Sku, GoodsName, Discount, Quantity, GoodsType, corlorcode, address, ControlIP,area, block,boxcode,bkbarcode,isnull(checkquantity,0) as checkquantity,wholeunit,unit,shopid,wmsboxcode from v_orders where state = 0 and sku = '{0}' and block = '{1}' and area='{2}' " + strwhere + "",
|
||||
sql = string.Format("select id,Matchid,orderid, barcode, BatchId, DownDate, Tolocation, Sku, GoodsName, Discount, Quantity, address, ControlIP,area, block,bkbarcode,wholeunit,unit,shopid,wmsboxcode from v_orders where state = 0 and sku = '{0}' and block = '{1}' and area='{2}' " + strwhere + "",
|
||||
|
||||
sku,
|
||||
block, area);
|
||||
@ -98,7 +98,7 @@ namespace Epost.DAL
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = string.Format("select id,ProdArea, LotNo, Matchid, orderid, barcode, BatchId, DownDate, Tolocation, Sku, GoodsName, Discount, Quantity, GoodsType, corlorcode, address, ControlIP, area , block,boxcode,bkbarcode,isnull(checkquantity,0) as checkquantity,wholeunit,unit,shopid,wmsboxcode from v_orders where state = 0 and sku = '{0}' and block = '{1}' " + strwhere + "",
|
||||
sql = string.Format("select id,Matchid,orderid, barcode, BatchId, DownDate, Tolocation, Sku, GoodsName, Discount, Quantity, address, ControlIP, area , block,bkbarcode,wholeunit,unit,shopid,wmsboxcode from v_orders where state = 0 and sku = '{0}' and block = '{1}' " + strwhere + "",
|
||||
|
||||
sku,
|
||||
block);
|
||||
@ -485,7 +485,7 @@ namespace Epost.DAL
|
||||
sql = string.Format(" update orders set oprationstate=1,oprationtime='{0}' where matchid='{1}' and id='{2}'",
|
||||
DateTime.Now.ToString(),
|
||||
orderid,
|
||||
|
||||
|
||||
id);
|
||||
}
|
||||
else
|
||||
@ -2492,6 +2492,373 @@ namespace Epost.DAL
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 三迎
|
||||
//========三迎========
|
||||
|
||||
#region 查询扫描的是否为运单号
|
||||
public DataTable GetOrdersMatchidIf(string matchid)
|
||||
{
|
||||
string sql = string.Format("select distinct matchid,shopid,shopname,prino+0 from Orders where matchid='" + matchid + "' order by prino+0 asc");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询可分配的货位
|
||||
public DataTable GetAddressNolocation(string block, string area)
|
||||
{
|
||||
string sql = string.Format("select * from Addressstorage where bkaddress='0' and type='1' and block='" + block + "' and area='" + area + "' order by location+1 asc");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 为orders分配货位
|
||||
public bool UpOrderstolocation(string shopid, string tolocation, string matchid)
|
||||
{
|
||||
string sql = string.Format("update Orders set tolocation='" + tolocation + "' where shopid='" + shopid + "' and matchid='" + matchid + "'");
|
||||
long x = db.UpdateSql(sql);
|
||||
LogHelper.WriteLogInfo("为orders分配货位:" + sql + ",成功条数:" + x + "");
|
||||
if (x > 0)
|
||||
{
|
||||
sql = string.Format("update Addressstorage set bkaddress='" + shopid + "' where location='" + tolocation + "' and bkaddress='0' ");
|
||||
long b = db.UpdateSql(sql);
|
||||
LogHelper.WriteLogInfo("更新Addressstorage货位为已占用:" + sql + ",成功条数:" + b + "");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询是否有正在作业的运单号
|
||||
public DataTable GetOrderMatchidBin(string matchid)
|
||||
{
|
||||
string sql = string.Format("select * from v_orders where tolocation!='' and matchid='" + matchid + "' ");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
|
||||
public DataTable GetOrderMatchidLocation(string block, string area)
|
||||
{
|
||||
string sql = string.Format("select * from v_orders where tolocation!='' and block='" + block + "' and area='" + area + "' ");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
|
||||
public DataTable GetOrderMatchidInfo(string block, string area)
|
||||
{
|
||||
string sql = string.Format("select distinct matchid,ControlIP from v_orders where tolocation!='' and block='" + block + "' and area='" + area + "' ");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 强制结束修改状态
|
||||
public bool UpOrdersMatchid(string block, string area, string matchid)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = string.Format("update orders set state='3' where tolocation!='' and matchid='" + matchid + "' ");
|
||||
long x = db.UpdateSql(sql);
|
||||
LogHelper.WriteLogInfo("强制结束修改状态:" + sql + ",成功条数:" + x + "");
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogInfo("强制结束修改状态异常:" + ex + "");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpBkAddresss(string block, string area)
|
||||
{
|
||||
string sql = string.Format("update Addressstorage set bkaddress='0' where block='" + block + "' and area='" + area + "' ");
|
||||
long x = db.UpdateSql(sql);
|
||||
LogHelper.WriteLogInfo("强制结束修改Addressstorage:" + sql + ",成功条数:" + x + "");
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpOrdersqueue(string block, string area, string matchid)
|
||||
{
|
||||
string sql = string.Format("update ordersqueue set state='3' where Taskblock='" + block + "' and Taskarea='" + area + "' and matchid='" + matchid + "' ");
|
||||
long x = db.UpdateSql(sql);
|
||||
LogHelper.WriteLogInfo("强制结束修改ordersqueue:" + sql + ",成功条数:" + x + "");
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询
|
||||
public DataTable GetSkuQuantity(string sku, string matchid)
|
||||
{
|
||||
string sql = string.Format("select sum(quantity) sumqty from Orders where sku='" + sku + "' and matchid='" + matchid + "' ");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
|
||||
public DataTable GetSku(string sku)
|
||||
{
|
||||
string sql = string.Format("select * from SkuInfo where sku = '" + sku + "' ");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 释放播种位
|
||||
public bool UpdateLocation(string block, string area)
|
||||
{
|
||||
string sql = string.Format("update Addressstorage set bkaddress='0' where block='" + block + "' and area='" + area + "' and type='1' ");
|
||||
long x = db.UpdateSql(sql);
|
||||
LogHelper.WriteLogInfo("运单完成-释放播种位:" + sql + ",条数:" + x + "");
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MyRegion
|
||||
public bool UpdateWorkState_DPS(string matchid, int truequantity, string sku, int batchid, int checkquantity, string usercode = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (uplock)
|
||||
{
|
||||
int oprationstate = 3;
|
||||
|
||||
string upsql = string.Format("update Orders set oprationstate = '{3}' ,oprationtime='{0}',oprationcode='{5}',truequantity=quantity where matchid='{2}' and id='{4}' ",
|
||||
DateTime.Now.ToString(),
|
||||
truequantity,
|
||||
matchid,
|
||||
oprationstate,
|
||||
batchid,
|
||||
//checkquantity,
|
||||
usercode
|
||||
);
|
||||
LogHelper.WriteLogInfo("-修改orders" + upsql);
|
||||
long x = db.UpdateSql(upsql);
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogInfo("修改orders异常:" + upsql, LogHelper.Log_Type.ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogInfo("修改当前标签拣货状态异常:" + ex.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region
|
||||
public DataTable GetOrderinfoNumber(string matchid)
|
||||
{
|
||||
string sql = string.Format("select distinct matchid,clientname,COUNT(distinct shopid) 'shopcount',count(distinct sku) qty from Orders where matchid='" + matchid + "' group by matchid,clientname");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return dt;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MyRegion
|
||||
public bool ImportOrderinfo(DataTable ds, Dictionary<string, string> diclist)
|
||||
{
|
||||
|
||||
bool bo = db.UpdateData(ds, "orders", diclist);
|
||||
if (bo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogInfo("添加取消订单失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 数据维护
|
||||
public bool DelOrderSku()
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = string.Format("delete from Orders where sku not in (select sku from SkuInfo) ");
|
||||
long x = db.DeleteSql(sql);
|
||||
LogHelper.WriteLogInfo("数据维护:" + sql + ",成功条数:" + x + "");
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogInfo("数据维护异常:" + ex + "", LogHelper.Log_Type.ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 导入数据清理之前orders
|
||||
public void DelOrdersBeforeDate()
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = string.Format("insert into Ordershis select * from Orders");
|
||||
long x = db.InsertSql(sql);
|
||||
LogHelper.WriteLogInfo("导入数据清理之前orders:" + sql + ",成功条数:" + x + "");
|
||||
if (x > 0)
|
||||
{
|
||||
sql = string.Format("delete from Orders");
|
||||
x = db.DeleteSql(sql);
|
||||
LogHelper.WriteLogInfo("清理orders数据:" + sql + ",成功条数:" + x + "");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogInfo("导入数据清理之前orders异常:" + ex.Message + "", LogHelper.Log_Type.ERROR);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 运单用时
|
||||
public List<OrdersModel> GetMatchUserTimeByPage(string strWhere, string orderby, int startIndex, int endIndex, out int recordCount)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("SELECT * FROM ( ");
|
||||
strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
||||
if (!string.IsNullOrEmpty(orderby.Trim()))
|
||||
{
|
||||
strSql.Append("order by T." + orderby);
|
||||
}
|
||||
else
|
||||
{
|
||||
strSql.Append("order by matchid asc");
|
||||
}
|
||||
strSql.Append(")AS Row,matchid as matchid,clientname as clientname,count(distinct(shopid)) as ShopCount,MIN(CONVERT(datetime,oprationtime)) AS starttime,MAX(CONVERT(datetime,oprationtime)) AS endtime,DATEDIFF(MINUTE,MIN(CONVERT(datetime,oprationtime)),MAX(CONVERT(datetime,oprationtime))) AS UseTime FROM Ordershis where 1=1 " + strWhere + " GROUP BY matchid,clientname ");
|
||||
strSql.Append(" ) TT");
|
||||
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
||||
List<OrdersModel> list = ModelConvertHelper<OrdersModel>.ConvertToList(db.GetsqlForDT(strSql.ToString()));
|
||||
|
||||
strSql.Remove(0, strSql.Length);
|
||||
strSql.Append("SELECT count(distinct matchid) FROM Ordershis");
|
||||
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
||||
{
|
||||
strSql.AppendFormat(" WHERE 1=1 {0}", strWhere);
|
||||
}
|
||||
|
||||
object obj = db.GetsqlForDT(strSql.ToString()).Rows[0][0];
|
||||
if (obj != null)
|
||||
recordCount = Convert.ToInt32(obj);
|
||||
else
|
||||
recordCount = 0;
|
||||
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(GetType(), ex.Message);
|
||||
recordCount = 0;
|
||||
return new List<Model.OrdersModel>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public DataTable GetMatchUserTime_DT(string strWhere)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = string.Format("SELECT matchid as matchid,clientname as clientname,count(distinct(shopid)) as ShopCount,MIN(CONVERT(datetime,oprationtime)) AS starttime,MAX(CONVERT(datetime,oprationtime)) AS endtime,DATEDIFF(MINUTE,MIN(CONVERT(datetime,oprationtime)),MAX(CONVERT(datetime,oprationtime))) AS UseTime FROM Ordershis where 1=1 " + strWhere + " GROUP BY matchid,clientname ");
|
||||
|
||||
return db.GetsqlForDT(sql.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(GetType(), ex.Message);
|
||||
return new DataTable();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取当前区的作业状态
|
||||
public DataTable getQueueState(string block, string area, string state)
|
||||
{
|
||||
string sql = string.Format("select * from OrdersQueue where taskblock='{0}' and taskarea='{1}' and state!='" + state + "' order by sort",
|
||||
block,
|
||||
area);
|
||||
return db.GetsqlForDT(sql);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 判断订单状态为已完成
|
||||
public bool IsFinishWork_box(string boxcode, int endcount, string matchid = "")
|
||||
{
|
||||
string sql = string.Format("select matchid from Orders where (matchid='{0}') and oprationstate<>3",
|
||||
matchid);
|
||||
|
||||
|
||||
LogHelper.WriteLogInfo("判断整箱状态为已完成" + sql);
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
if (dt == null || dt.Rows.Count == endcount)
|
||||
{
|
||||
LogHelper.WriteLogInfo("判断整箱状态为已完成true");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogInfo("判断整箱状态为已完成false");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user