2023-05-23 16:13:17 +08:00
/// <summary>
///INTERFACE IMPLIMENT FOR TABLE t_wmsOutPickLable
///By wm with codesmith.
///on 05/22/2017
/// </summary>
using System ;
using System.Data.SqlClient ;
namespace DeiNiu.wms.Data.Model
{
[Serializable] class WmsOutPickLable_Imp : WmsOutPickLable_base_Imp
{
protected override void CmdPrepare ( SqlCommand sqlCmd )
{
base . CmdPrepare ( sqlCmd ) ;
WmsOutPickLable mObj = ( WmsOutPickLable ) modelObj ;
bool isShowAll = false ;
string wherestr = "" ;
switch ( _cust_op_flag )
{
case 99 : //query with dic
_strSql = "SELECT *,ROW_NUMBER() OVER (ORDER BY ID DESC) as sortNo FROM t_wmsOutPickLable WHERE DR = 1 " + mObj . CmdParameters [ 0 ] . ToString ( ) ;
_strSql = "SELECT * FROM (" + _strSql + " )AS SORTEDTB WHERE sortNo BETWEEN @START AND @END" + " ORDER BY ID DESC" ;
_strSql + = ";SELECT COUNT(*) FROM t_wmsOutPickLable WHERE DR = 1 " + mObj . CmdParameters [ 0 ] . ToString ( ) ;
sqlCmd . CommandText = _strSql ;
sqlCmd . Parameters . AddWithValue ( "@START" , this . _rownumStart ) ;
sqlCmd . Parameters . AddWithValue ( "@END" , this . _rownumEnd ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 100 : //by name
_strSql = "SELECT * FROM t_wmsOutPickLable WHERE NAME = @NAME" ;
sqlCmd . CommandText = _strSql ;
sqlCmd . Parameters . AddWithValue ( "@NAME" , mObj . CmdParameters [ 0 ] ) ;
break ;
case 200 : //by pickorder
isShowAll = Convert . ToBoolean ( mObj . CmdParameters [ 1 ] ) ;
_strSql = "SELECT a.* FROM [v_stockOutLablePickDetail] a where orderNo =@orderNo " ;
if ( ! isShowAll )
{
_strSql + = " and state =@state " ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 2 ] ) ;
}
sqlCmd . Parameters . AddWithValue ( "@orderNo" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 300 : //by dpsOrder
isShowAll = Convert . ToBoolean ( mObj . CmdParameters [ 1 ] ) ;
_strSql = "SELECT a.* FROM [v_stockOutLablePickDetail] a where dpsOrder =@dpsOrder " ;
if ( ! isShowAll )
{
_strSql + = " and state =@state " ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 2 ] ) ;
}
sqlCmd . Parameters . AddWithValue ( "@dpsOrder" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 400 : //by state
_strSql = "SELECT a.* FROM [v_stockOutLablePickDetail] a where 1=1 " ;
_strSql + = " and state =@state " ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 401 : //可亮灯第三方数据
_strSql = "SELECT * FROM [v_unpick_toLight] where 1=1 order by port,color " ;
sqlCmd . CommandText = _strSql ;
break ;
case 402 : //第三方数据,location 需要维护的数据
_strSql = "SELECT distinct locationid FROM t_wmsOutPickLable a where not exists(select 1 from t_wmslocation where locationid =a.locationid)" ;
sqlCmd . CommandText = _strSql ;
break ;
case 403 : //第三方数据,当前波次
_strSql = "SELECT *,0 AS isLightUp, 0 AS isPicked FROM t_wmsOutPickLable_tmp " ;
_strSql + = "; SELECT distinct locationId FROM t_wmsOutPickLable a where not exists(select 1 from t_wmslocation where locationid =a.locationid)" ;
sqlCmd . CommandText = _strSql ;
break ;
case 500 : //to get current wave picking list by state
_strSql = "SELECT a.* FROM [t_wmsOutPickLable_tmp] a where state =@state " ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 501 : //to get current wave picking list by state
_strSql = "SELECT a.* FROM [t_wmsOutPickLable_tmp] a where partion=@partion and state =@state " ;
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 502 : //to get current wave picking list by partion
_strSql = "SELECT a.* FROM [t_wmsOutPickLable_tmp] a where partion=@partion " ;
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
2023-11-21 19:18:23 +08:00
case 503 :
_strSql = "SELECT * FROM [t_wmsOutPickLable_tmp] where dpsOrder=@dpsOrder " ;
sqlCmd . Parameters . AddWithValue ( "@dpsOrder" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
2023-05-23 16:13:17 +08:00
/ * case 503 : //to get current wave picking list by partions
_strSql = "SELECT a.* FROM [t_wmsOutPickLable_tmp] a where state =@state " ;
if ( ! String . IsNullOrEmpty ( mObj . CmdParameters [ 1 ] . ToString ( ) ) ) {
_strSql + = "and partion in " + mObj . CmdParameters [ 1 ] ;
}
//sqlCmd.Parameters.AddWithValue("@partions", mObj.CmdParameters[1]);
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
2023-11-21 19:18:23 +08:00
* /
2023-05-23 16:13:17 +08:00
case 600 : //拣选结束lable 回传数据
wherestr = " where state = 0 and color =@color and elabId =@elabId and elabAddress=@elabAddress "
+ " and pickCount =0 and count =@pickCount" ;
// + "and isnull(plate,'-1')!='-1'"; //seed picking, a location can split to plates.
// bool isPDAouting = Convert.ToBoolean(mObj.CmdParameters[4].ToString());
//更新库存信息
if ( Convert . ToBoolean ( mObj . CmdParameters [ 4 ] . ToString ( ) ) )
{
/ * update t_wmsStockRecord
* string recDesc = string . Format ( ";{0}:{1}" , "电子标签捡货" , DateTime . Now ) ;
_strSql = " update [t_wmsStockRecord] set count = @pickCount,description =@desc ,lastmodified =@timenow where exists(select 1 from t_wmsOutPickLable_tmp "
+ wherestr
+ " and recordId = t_wmsStockRecord.id ); " ;
* /
//更新库存
_strSql = " update t_wmsStock set countOuting = countOuting - @pickCount,countOut =countOut + @pickCount "
+ " where exists(select 1 from t_wmsOutPickLable_tmp "
+ wherestr
+ " and locationid = t_wmsStock.locationId);"
;
// sqlCmd.Parameters.AddWithValue("@desc",recDesc);
sqlCmd . Parameters . AddWithValue ( "@timenow" , DateTime . Now ) ;
}
else
{
_strSql = "" ;
}
_strSql + = " update [t_wmsOutPickLable_tmp] set state = @state , pickCount =@pickCount "
+ wherestr ;
2024-02-06 19:36:47 +08:00
2023-05-23 16:13:17 +08:00
sqlCmd . Parameters . AddWithValue ( "@state" , ( int ) DeiNiu . Utils . enumPickState . 已 拣 ) ; //can be picked more than onece?
sqlCmd . Parameters . AddWithValue ( "@color" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@elabId" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@pickCount" , mObj . CmdParameters [ 2 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@elabAddress" , mObj . CmdParameters [ 3 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 610 : // 更新 待复核数据状态
_strSql = " update t_wmsOutPickDetail_tmp set bulkPickState = @bulkPickState where "
+ " exists(select 1 from t_wmsOutPickLable_tmp where dpsOrder = t_wmsOutPickDetail_tmp.waveOrder "
+ " and orderdetailId = t_wmsOutPickDetail_tmp.id"
+ " and state =@pickState"
+ " and color =@color and elabId =@elabId and elabAddress=@elabAddress)" ;
// _strSql += "; update t_wmsOutDesk set state =0";
sqlCmd . Parameters . AddWithValue ( "@bulkPickState" , ( int ) DeiNiu . Utils . enumOutStockPickStatus . 分 拣 完 成 ) ;
sqlCmd . Parameters . AddWithValue ( "@pickState" , ( int ) DeiNiu . Utils . enumPickState . 已 拣 ) ;
sqlCmd . Parameters . AddWithValue ( "@color" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@elabId" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@elabAddress" , mObj . CmdParameters [ 2 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 611 : // 强制更新 待复核数据状态
_strSql = " update t_wmsOutPickDetail_tmp set bulkPickState = @bulkPickState, bulkpicked =bulkcount where "
+ " waveOrder=@waveNo" ;
// _strSql += "; update t_wmsOutPickDetail set bulkPickState = @bulkPickState, bulkpicked =bulkcount where "
// + " waveOrder=@waveNo";
// _strSql += "; update t_wmsOutDesk set state =0";
sqlCmd . Parameters . AddWithValue ( "@bulkPickState" , ( int ) DeiNiu . Utils . enumOutStockPickStatus . 分 拣 完 成 ) ;
sqlCmd . Parameters . AddWithValue ( "@waveNo" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 700 : //清除临时数据
string cols = " [pickOrderNo],[dpsOrder] ,[color] ,[recordId] ,[count] ,[locationId] ,[elabId] ,[port] ,[elabAddress]"
+ ",[state] ,[pickCount] ,[description] ,[operater] ,[dr] ,[createtime] ,[lastmodified],[plate],[partion]" ;
_strSql = string . Format ( " insert into t_wmsOutPickLable ({0}) " , cols )
+ string . Format ( " select {0} from t_wmsOutPickLable_tmp where state = @state ;" , cols )
+ string . Format ( " delete from t_wmsOutPickLable_tmp where state = @state ;" ) ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 701 : //清除part临时数据
string cols4 = " [pickOrderNo],[dpsOrder] ,[color] ,[recordId] ,[count] ,[locationId] ,[elabId] ,[port] ,[elabAddress]"
+ ",[state] ,[pickCount] ,[description] ,[partion] ,[operater] ,[dr] ,[createtime] ,[lastmodified],[plate],[partion]" ;
_strSql = string . Format ( " insert into t_wmsOutPickLable ({0}) " , cols4 )
+ string . Format ( " select {0} from t_wmsOutPickLable_tmp where partion=@partion and state = @state ;" , cols4 )
+ string . Format ( " delete from t_wmsOutPickLable_tmp where partion=@partion and state = @state ;" ) ;
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 710 : //强制清除临时数据 by force
string cols2 = " [pickOrderNo],[dpsOrder] ,[color] ,[recordId] ,[count] ,[locationId] ,[elabId] ,[port] ,[elabAddress]"
+ ",[state] ,[pickCount] ,[description] ,[operater] ,[dr] ,[createtime] ,[lastmodified],[plate],[partion]" ;
_strSql = " update [t_wmsOutPickLable_tmp] set state = @state ,description ='强制结束' where state =" + ( int ) DeiNiu . Utils . enumPickState . 未 拣
+ string . Format ( "; insert into t_wmsOutPickLable ({0}) select {1} from t_wmsOutPickLable_tmp" , cols2 , cols2 )
+ string . Format ( "; delete from t_wmsOutPickLable_tmp " ) ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 711 : //强制清除 part 临时数据 by force
string cols3 = " [pickOrderNo],[dpsOrder] ,[color] ,[recordId] ,[count] ,[locationId] ,[elabId] ,[port] ,[elabAddress]"
+ ",[state] ,[pickCount] ,[description],[partion] ,[operater] ,[dr] ,[createtime] ,[lastmodified],[plate],[partion]" ;
_strSql = " update [t_wmsOutPickLable_tmp] set state = @state ,description ='强制结束' where partion=@partion and state =" + ( int ) DeiNiu . Utils . enumPickState . 未 拣
+ string . Format ( "; insert into t_wmsOutPickLable ({0}) select {1} from t_wmsOutPickLable_tmp where partion=@partion " , cols3 , cols3 )
+ string . Format ( "; delete from t_wmsOutPickLable_tmp where partion=@partion " ) ;
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 712 : //分区现有订单中未完成分拣的明细(订单明细可能在其他区或未开始拣选)
_strSql = " select * from t_wmsOutPickDetail_tmp pd where "
+ " exists(select 1 from t_wmsOutPickLable_tmp where partion =@partion and pickOrderNo = pd.pickOrderNo)"
+ " and bulkPickState <@bulkPickState" ;
sqlCmd . Parameters . AddWithValue ( "@bulkPickState" , ( int ) DeiNiu . Utils . enumOutStockPickStatus . 分 拣 完 成 ) ;
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 720 : // 清除第三方临时数据 , 已完成部分的t_wmsOutPickLable的数据, 由第三方负责转入历史表t_wmsOutPickLable_history
_strSql = " update [t_wmsOutPickLable] set state = @state ,description =@desc where dpsOrder =@dpsOrder and state ="
+ ( int ) DeiNiu . Utils . enumPickState . 未 拣
+ "; delete from t_wmsOutPickLable_tmp " ;
sqlCmd . Parameters . AddWithValue ( "@state" , ( int ) DeiNiu . Utils . enumPickState . 已 拣 ) ;
sqlCmd . Parameters . AddWithValue ( "@dpsOrder" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@desc" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 721 : //
_strSql = " " ;
sqlCmd . Parameters . AddWithValue ( "@state" , ( int ) DeiNiu . Utils . enumPickState . 已 拣 ) ;
sqlCmd . Parameters . AddWithValue ( "@dpsOrder" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@desc" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 800 : //pick list by dpsOrder
_strSql = "SELECT elabid as ele_lab_id,elabAddress as ele_address,port,count as pick_count,count - pickCount as send_count, color ,color as ele_order "
+ " FROM [t_wmsOutPickLable_tmp] a where dpsOrder =@dpsOrder order by port,color " ; // 按 Port, color排序, 否则点灯异常
sqlCmd . Parameters . AddWithValue ( "@dpsOrder" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 900 : //get pick detail by state
_strSql = "SELECT elabid as ele_lab_id,elabAddress as ele_address,port,count as pick_count,count - pickCount as send_count, color ,color as ele_order "
+ " FROM [t_wmsOutPickLable_tmp] a where state =@state order by port,color" ; // 按 Port, color排序, 否则点灯异常
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 901 : //get part pick light data, all include picked, picked will be not lightup,but 相应完成器会点亮
_strSql = "SELECT elabid as ele_lab_id,elabAddress as ele_address,port,count as pick_count,count - pickCount as send_count, color ,partion as ele_order ,state"
+ " FROM [t_wmsOutPickLable_tmp] a where partion=@partion order by port,partion" ; // 按 Port, color排序, 否则点灯异常
sqlCmd . Parameters . AddWithValue ( "@partion" , 4 ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 902 : //get part pick light data
_strSql = "SELECT elabid as ele_lab_id,elabAddress as ele_address,port,count as pick_count,count - pickCount as send_count, color ,partion as ele_order ,state"
+ " FROM [t_wmsOutPickLable_tmp] a where state =@state " ;
if ( ! String . IsNullOrEmpty ( mObj . CmdParameters [ 1 ] . ToString ( ) ) )
{
_strSql + = " and partion in " + mObj . CmdParameters [ 1 ] ;
}
_strSql + = " order by port,partion" ; // 按 Port, partion排序, 否则点灯异常
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 903 : //get part pick light data
_strSql = "SELECT elabid as ele_lab_id,elabAddress as ele_address,port,count as pick_count,count - pickCount as send_count, color ,partion as ele_order ,state"
+ " FROM [t_wmsOutPickLable_tmp] a where state =@state and partion=@partion order by port,partion" ; // 按 Port, color排序, 否则点灯异常
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@partion" , 1 ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 904 : //get part task list
_strSql = "SELECT elabid as ele_lab_id,elabAddress as ele_address,port,count as pick_count,count - pickCount as send_count, color ,partion as ele_order ,state"
+ " FROM [t_wmsOutPickLable_tmp] a where state =@state and partion=1 order by port,partion" ; // 按 Port, color排序, 否则点灯异常
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 905 : //get part task list
_strSql = "SELECT elabid as ele_lab_id,elabAddress as ele_address,port,count as pick_count,count - pickCount as send_count, color ,partion as ele_order ,state,dpsOrder"
+ " FROM [t_wmsOutPickLable_tmp] a where exists(select 1 from(SELECT distinct top (@cnt) dpsorder ,[color] FROM [t_wmsOutPickLable_tmp] " ; // 按 Port, color排序, 否则点灯异常
_strSql + = "where state =@state and partion=@partion order by dpsorder ,color ) b where b.dpsorder =a.dpsorder and b.color = a.color ) and state =@state and partion=@partion" ;
_strSql + = " order by port,color" ; // 按 Port, partion排序, 否则点灯异常// 按 Port, color排序, 否则点灯异常
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@state" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@cnt" , mObj . CmdParameters [ 2 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 1000 : //按分区待拣数据体积、重量、数目等 , 用于rf终端
_strSql = "select * from [v_stockOutPartionBulkSum4wince] "
+ " where 分区编号 =@partion "
+ " order by color" ;
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 1100 : // 按周转箱、分区号,取播种亮灯任务
// _strSql = "select * from [t_wmsOutPickLable_tmp] "
// + " where plate=@plateId and partion = @partion";
_strSql = "SELECT elabid as ele_lab_id,elabAddress as ele_address,port,count as pick_count,count - pickCount as send_count, color ,partion as ele_order "
+ " FROM [t_wmsOutPickLable_tmp] a where state=0 and plate=@plateId "
+ " and partion = @partion "
+ " order by port,ele_lab_id,ele_address " ; // 端口, 标签id,位置
sqlCmd . Parameters . AddWithValue ( "@plateId" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
case 1200 : // 按周转箱、分区号,取播种亮灯任务
_strSql = " SELECT goodsname as 货品, [count] as 数量,locationId as 货位,[elabId] as 标签ID,[color] as 播种台 ,[dpsOrder] as 播种单 "
+ " FROM [v_stockOutPartionBulkInCurrentWave] a where state=0 and plate=@plateId "
+ " and partion = @partion "
+ " order by locationId " ;
sqlCmd . Parameters . AddWithValue ( "@plateId" , mObj . CmdParameters [ 0 ] ) ;
sqlCmd . Parameters . AddWithValue ( "@partion" , mObj . CmdParameters [ 1 ] ) ;
sqlCmd . CommandText = _strSql ;
break ;
}
}
}
}