@ -18,8 +18,8 @@ namespace WeighBusiness.BL
public static bool Insert ( WeightInfo weight , SqlHelperEx she2 = null )
public static bool Insert ( WeightInfo weight , SqlHelperEx she2 = null )
{
{
string insertSql = InsertUtil . GetInsertSql ( TableNames . 称 重 记 录 ,
string insertSql = InsertUtil . GetInsertSql ( TableNames . 称 重 记 录 ,
new string [ ] { "Goods_Name" , "Goods_Spec" , "Goods_ID" , "Weight" , "SubWeight" , "NetWeight" , "CreateTime" , "ProductBatch" , "IsSend" , "SecondNum" , "ButcDetailID" } ,
new string [ ] { weight . Goods_Name , weight . Goods_Spec , weight . Goods_ID . ToString ( ) , weight . Weight . ToString ( ) , weight . SubWeight = = null ? "null" : weight . SubWeight . ToString ( ) , weight . NetWeight = = null ? "null" : weight . NetWeight . ToString ( ) , weight . CreateTime = = null ? "null" : weight . CreateTime . ToString ( ) , weight . ProductBatch , weight . IsSelected ? "1" : "0" , weight . SecondNum = = null ? "null" : weight . SecondNum . ToString ( ) , weight . ButcDetailID = = null ? "null" : weight . ButcDetailID . ToString ( ) } ) ;
new string [ ] { "Goods_Name" , "Goods_Spec" , "Goods_ID" , "Weight" , "SubWeight" , "NetWeight" , "CreateTime" , "ProductBatch" , "IsSend" , "SecondNum" , "ButcDetailID" , "ProductNum" } ,
new string [ ] { weight . Goods_Name , weight . Goods_Spec , weight . Goods_ID . ToString ( ) , weight . Weight . ToString ( ) , weight . SubWeight = = null ? "null" : weight . SubWeight . ToString ( ) , weight . NetWeight = = null ? "null" : weight . NetWeight . ToString ( ) , weight . CreateTime = = null ? "null" : weight . CreateTime . ToString ( ) , weight . ProductBatch , weight . IsSelected ? "1" : "0" , weight . SecondNum = = null ? "null" : weight . SecondNum . ToString ( ) , weight . ButcDetailID = = null ? "null" : weight . ButcDetailID . ToString ( ) , weight . ProductNum = = null ? "null" : weight . ProductNum . ToString ( ) } ) ;
bool success ;
bool success ;
string errorMsg ;
string errorMsg ;
if ( she2 = = null ) {
if ( she2 = = null ) {
@ -70,14 +70,13 @@ namespace WeighBusiness.BL
}
}
public static List < WeightInfo > GetWeightInfos ( bool hasOutputId = false )
public static List < WeightInfo > GetWeightInfos ( bool hasOutputId = false , long? detailID = null )
{
{
var sql = "select SecondNum,Weight,SubWeight,NetWeight,CreateTime,Goods_ID,ID,Goods_Name,Goods_Spec,ButcDetailID from {0} where 1=1 {1} order by ID desc" . FormatWith ( TableNames . 称 重 记 录 , hasOutputId ? "and Output_ID is not null" : "and Output_ID is null" ) ;
var sql = "select SecondNum,Weight,SubWeight,NetWeight,CreateTime,Goods_ID,ID,Goods_Name,Goods_Spec,ButcDetailID,ProductNum from {0} where 1=1 {1} order by ID desc" . FormatWith ( TableNames . 称 重 记 录 , hasOutputId ? "and Output_ID is not null" : "and Output_ID is null" ) ;
var table = SqlHelperEx . DoQuery ( sql ) ;
var table = SqlHelperEx . DoQuery ( sql ) ;
if ( table . Rows . Count = = 0 )
if ( table . Rows . Count = = 0 )
return new List < WeightInfo > ( ) ;
return new List < WeightInfo > ( ) ;
var list = new List < WeightInfo > ( ) ;
var list = new List < WeightInfo > ( ) ;
var i = table . Rows . Count ;
foreach ( DataRow row in table . Rows ) {
foreach ( DataRow row in table . Rows ) {
var detail = new WeightInfo ( ) ;
var detail = new WeightInfo ( ) ;
detail . SecondNum = DataTypeUtil . GetDecimalNum ( row [ 0 ] ) ;
detail . SecondNum = DataTypeUtil . GetDecimalNum ( row [ 0 ] ) ;
@ -90,11 +89,40 @@ namespace WeighBusiness.BL
detail . Goods_Name = DataTypeUtil . ToStringEmptyIfNull ( row [ 7 ] ) ;
detail . Goods_Name = DataTypeUtil . ToStringEmptyIfNull ( row [ 7 ] ) ;
detail . Goods_Spec = DataTypeUtil . ToStringEmptyIfNull ( row [ 8 ] ) ;
detail . Goods_Spec = DataTypeUtil . ToStringEmptyIfNull ( row [ 8 ] ) ;
detail . ButcDetailID = DataTypeUtil . GetLongNullNum ( row [ 9 ] ) ;
detail . ButcDetailID = DataTypeUtil . GetLongNullNum ( row [ 9 ] ) ;
detail . Number = i ;
i - - ;
detail . ProductNum = DataTypeUtil . GetDecimalNullNum ( row [ 1 0 ] ) ;
list . Add ( detail ) ;
list . Add ( detail ) ;
}
}
return list ;
var wList = new List < WeightInfo > ( ) ;
var groups = list . GroupBy ( x = > x . ButcDetailID ) ;
if ( detailID ! = null ) {
var resultGroups = groups . Where ( x = > x . Key = = detailID ) ;
if ( resultGroups . Count ( ) > 0 ) {
var currentGroup = resultGroups . FirstOrDefault ( ) . OrderByDescending ( x = > x . ID ) ;
int i = currentGroup . Count ( ) ;
currentGroup . ForEach ( x = > { x . DetailSequence = i - - ; wList . Add ( x ) ; } ) ;
}
foreach ( var group in groups . Where ( x = > x . Key ! = detailID ) ) {
var orderList = group . OrderByDescending ( x = > x . ID ) ;
int i = orderList . Count ( ) ;
orderList . ForEach ( x = > { x . DetailSequence = i - - ; wList . Add ( x ) ; } ) ;
}
} else {
var results = list . Where ( x = > x . ButcDetailID = = null ) ;
if ( results . Count ( ) > 0 ) {
int i = results . Count ( ) ;
var orderResults = results . OrderByDescending ( x = > x . ID ) ;
orderResults . ForEach ( x = > { x . DetailSequence = i - - ; wList . Add ( x ) ; } ) ;
}
var notNullResults = list . Where ( x = > x . ButcDetailID ! = null ) ;
var gps = notNullResults . GroupBy ( x = > x . ButcDetailID ) ;
foreach ( var group in gps ) {
var orderList = group . OrderByDescending ( x = > x . ID ) ;
int i = orderList . Count ( ) ;
orderList . ForEach ( x = > { x . DetailSequence = i - - ; wList . Add ( x ) ; } ) ;
}
}
return wList ;
}
}
public static decimal? GetButcDetailIDWeight ( long? butcDetailID , SqlHelperEx she2 = null )
public static decimal? GetButcDetailIDWeight ( long? butcDetailID , SqlHelperEx she2 = null )
@ -159,20 +187,20 @@ namespace WeighBusiness.BL
return num2 > 0 ? num1 + 1 : num1 ;
return num2 > 0 ? num1 + 1 : num1 ;
}
}
public static List < UnfinishedBatch > GetUnfinishedBatchPage ( int pageIndex , int pageSize )
public static int GetCurrentSequence ( long detailId )
{
{
var sql = "select * from(select ProductBatch,LegType from {0} where State=0) rows {1} to {2} " . FormatWith ( TableNames . 未 完 成 生 产 批 次 , pageIndex = = 1 ? 1 : ( pageIndex - 1 ) * pageSize + 1 , pageIndex * pageSize ) ;
var sql = "select max(DetailSequence) from {0} where ButcDetailID = {1} " . FormatWith ( TableNames . 称 重 记 录 , detailId ) ;
var table = SqlHelperEx . DoQuery ( sql ) ;
var table = SqlHelperEx . DoQuery ( sql ) ;
if ( table . Rows . Count = = 0 )
if ( table . Rows . Count = = 0 )
return new List < UnfinishedBatch > ( ) ;
var list = new List < UnfinishedBatch > ( ) ;
foreach ( DataRow row in table . Rows ) {
var detail = new UnfinishedBatch ( ) ;
detail . ProductBatch = DataTypeUtil . ToStringEmptyIfNull ( row [ 0 ] ) ;
detail . LegType = row [ 1 ] . ToString ( ) = = "前腿" ? LegType . 前 腿 : LegType . 后 腿 ;
list . Add ( detail ) ;
return 1 ;
var result = table . Rows [ 0 ] [ 0 ] ;
if ( result = = DBNull . Value ) {
return 1 ;
} else {
var sequence = ( int ) ( result ) ;
sequence = sequence + 1 ;
return sequence ;
}
}
return list ;
}
}
public static List < WeightInfo > GetWeightInfoByIds ( params long [ ] weightIds )
public static List < WeightInfo > GetWeightInfoByIds ( params long [ ] weightIds )