@ -1,5 +1,6 @@
using BWP.B3ClientService.BO ;
using BWP.B3ClientService.BO ;
using BWP.B3ClientService.RpcBO ;
using BWP.B3ClientService.RpcBO ;
using BWP.B3Frameworks.Utils ;
using Forks.EnterpriseServices.DomainObjects2 ;
using Forks.EnterpriseServices.DomainObjects2 ;
using Forks.EnterpriseServices.DomainObjects2.DQuery ;
using Forks.EnterpriseServices.DomainObjects2.DQuery ;
using Forks.EnterpriseServices.JsonRpc ;
using Forks.EnterpriseServices.JsonRpc ;
@ -111,23 +112,12 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
}
}
[Rpc]
[Rpc]
public static string GetBackWeightBillInfo ( long weightID , long backId )
public static int GetLastNumber ( long weightID , long backId )
{
{
var query = new DQueryDom ( new JoinAlias ( typeof ( WeightBill ) ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "Supplier_Name" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "HouseNames" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "WeighTime" ) ) ;
query . Where . Conditions . Add ( DQCondition . EQ ( "ID" , weightID ) ) ;
var result = query . EExecuteScalar < string , string , DateTime > ( ) ;
var entity = new NeedOrderEntity ( ) ;
entity . WeightBill_ID = weightID ;
entity . Supplier_Name = result . Item1 ;
entity . HouseNames = result . Item2 ;
entity . WeighTime = result . Item3 ;
entity . Number = GetWeightNumber ( weightID ) ;
entity . AlreadyNumber = GetAlreadyNumberWithoutBack ( weightID , backId ) ;
var totalNumber = GetWeightNumber ( weightID ) ;
var alreadyNumber = GetAlreadyNumberWithoutBack ( weightID , backId ) ;
return serializer . Serialize ( entity ) ;
return totalNumber - alreadyNumber ;
}
}
static int GetWeightNumber ( long wid )
static int GetWeightNumber ( long wid )
@ -141,10 +131,10 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
return 0 ;
return 0 ;
}
}
static int GetAlreadyNumberWithoutBack ( long wid , long b id)
static int GetAlreadyNumberWithoutBack ( long wid , long o id)
{
{
var query = new DQueryDom ( new JoinAlias ( typeof ( OrderDetail ) ) ) ;
var query = new DQueryDom ( new JoinAlias ( typeof ( OrderDetail ) ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . EQ ( "DeleteState" , false ) , DQCondition . EQ ( "WeightBill_ID" , wid ) , DQCondition . InEQ ( "ID" , b id) ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . EQ ( "DeleteState" , false ) , DQCondition . EQ ( "WeightBill_ID" , wid ) , DQCondition . InEQ ( "ID" , o id) ) ) ;
query . Columns . Add ( DQSelectColumn . Sum ( "PlanNumber" ) ) ;
query . Columns . Add ( DQSelectColumn . Sum ( "PlanNumber" ) ) ;
var rst = query . EExecuteScalar ( ) ;
var rst = query . EExecuteScalar ( ) ;
if ( rst ! = null )
if ( rst ! = null )
@ -153,21 +143,19 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
}
}
[Rpc]
[Rpc]
public static string GetOrderDetail ( DateTime date , int pageSize , int pageNumb er )
public static string GetOrderDetail ( DateTime date , int? minOrd er )
{
{
var temp = new JoinAlias ( typeof ( OrderTemp ) ) ;
var query = new DQueryDom ( temp ) ;
OrderTemp . Register ( query , date , pageSize * pageNumber ) ;
var alias = new JoinAlias ( typeof ( OrderDetail ) ) ;
query . From . AddJoin ( JoinType . Left , new DQDmoSource ( alias ) , DQCondition . EQ ( temp , "ID" , alias , "ID" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "ID" , alias ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "WeightBill_ID" , alias ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "Order" , alias ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "PlanNumber" , alias ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "LiveColonyHouse_Name" , alias ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "IsHurryButcher" , alias ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "B3WeighBill_ID" , alias ) ) ;
query . Where . Conditions . Add ( DQCondition . GreaterThan ( temp , "RowNumber" , pageSize * ( pageNumber - 1 ) ) ) ;
var query = new DQueryDom ( new JoinAlias ( typeof ( OrderDetail ) ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "ID" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "WeightBill_ID" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "Order" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "PlanNumber" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "LiveColonyHouse_Name" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "IsHurryButcher" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "B3WeighBill_ID" ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . EQ ( "Date" , date ) , DQCondition . EQ ( "DeleteState" , false ) , DQCondition . EQ ( "SecondarySplit" , false ) ) ) ;
if ( minOrder . HasValue )
query . Where . Conditions . Add ( DQCondition . GreaterThanOrEqual ( "Order" , minOrder ) ) ;
var list = new List < OrderDetail > ( ) ;
var list = new List < OrderDetail > ( ) ;
using ( var session = Dmo . NewSession ( ) )
using ( var session = Dmo . NewSession ( ) )
{
{
@ -190,56 +178,33 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
return serializer . Serialize ( list ) ;
return serializer . Serialize ( list ) ;
}
}
class OrderTemp
{
public int RowNumber { get ; set ; }
public long ID { get ; set ; }
public static void Register ( DQueryDom root , DateTime date , int total )
{
var query = new DQueryDom ( new JoinAlias ( "_pageTemp" , typeof ( OrderDetail ) ) ) ;
query . Range = SelectRange . Top ( total ) ;
query . Columns . Add ( DQSelectColumn . Create ( DQExpression . Snippet ( "row_number() OVER (order by [_pageTemp].[Order] desc)" ) , "RowNumber" ) ) ;
query . Columns . Add ( DQSelectColumn . Field ( "ID" ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . EQ ( "Date" , date ) , DQCondition . EQ ( "DeleteState" , false ) , DQCondition . EQ ( "SecondarySplit" , false ) ) ) ;
root . RegisterQueryTable ( typeof ( OrderTemp ) , new string [ ] { "RowNumber" , "ID" } , query ) ;
}
}
[Rpc]
[Rpc]
public static int GetMaxPageNumb er ( DateTime date , int pageSiz e )
public static int GetMaxOrder ( DateTime date )
{
{
var query = new DQueryDom ( new JoinAlias ( typeof ( OrderDetail ) ) ) ;
var query = new DQueryDom ( new JoinAlias ( typeof ( OrderDetail ) ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . EQ ( "Date" , date ) , DQCondition . EQ ( "DeleteState" , false ) , DQCondition . EQ ( "SecondarySplit" , false ) ) ) ;
query . Columns . Add ( DQSelectColumn . Count ( ) ) ;
var total = Convert . ToInt32 ( query . EExecuteScalar ( ) ) ;
var maxPageSize = total / pageSize ;
if ( total % pageSize ! = 0 )
maxPageSize + = 1 ;
return maxPageSize ;
query . Columns . Add ( DQSelectColumn . Max ( "Order" ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . Between ( "Date" , date . Date , date . Date + new TimeSpan ( 2 3 , 5 9 , 2 9 ) ) , DQCondition . EQ ( "DeleteState" , false ) ) ) ;
return query . EExecuteScalar < int? > ( ) ? ? 0 ;
}
}
[Rpc]
[Rpc]
public static int GetMaxOrder ( DateTime date )
public static int GetCurrentOrder ( long id )
{
{
var query = new DQueryDom ( new JoinAlias ( typeof ( OrderDetail ) ) ) ;
var query = new DQueryDom ( new JoinAlias ( typeof ( OrderDetail ) ) ) ;
query . Columns . Add ( DQSelectColumn . Max ( "Order" ) ) ;
query . Where . Conditions . Add ( DQCondition . And ( DQCondition . Between ( "Date " , date . Date , date . Date + new T imeSpan ( 2 3 , 5 9 , 2 9 ) ) , DQCon dition . EQ ( "DeleteState" , false ) ) ) ;
return query . EExecuteScalar < int? > ( ) ? ? 0 ;
query . Columns . Add ( DQSelectColumn . Field ( "Order" ) ) ;
query . Where . Conditions . Add ( DQCondition . EQ ( "ID" , id ) ) ;
return query . EExecuteScalar < int > ( ) ;
}
}
[Rpc]
[Rpc]
public static long Insert ( string update , string insert )
public static long Insert ( string insert )
{
{
var list = serializer . Deserialize < List < CTuple < long , int > > > ( update ) ;
insert = insert . ESerializeDateTime ( ) ;
insert = insert . ESerializeDateTime ( ) ;
var entity = serializer . Deserialize < OrderDetail > ( insert ) ;
var entity = serializer . Deserialize < OrderDetail > ( insert ) ;
entity . ModifyTime = DateTime . Now ;
entity . ModifyTime = DateTime . Now ;
using ( var session = Dmo . NewSession ( ) )
using ( var session = Dmo . NewSession ( ) )
{
{
foreach ( var item in list )
UpdateOrderDetailPartial ( session , item . Item1 , "Order" , item . Item2 ) ;
UpdateOrder ( session , entity . Order - 1 , 1 , entity . Date ) ;
session . Insert ( entity ) ;
session . Insert ( entity ) ;
session . Commit ( ) ;
session . Commit ( ) ;
}
}
@ -268,13 +233,12 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
}
}
[Rpc]
[Rpc]
public static int Delete ( string update , long id )
public static int Delete ( long id )
{
{
var list = serializer . Deserialize < List < CTuple < long , int > > > ( update ) ;
using ( var session = Dmo . NewSession ( ) )
using ( var session = Dmo . NewSession ( ) )
{
{
foreach ( var item in list )
UpdateOrderDetailPartial ( session , item . Item1 , "Order" , item . Item2 ) ;
var entity = InnerBLUtil . GetSingleDmo < OrderDetail > ( session , "ID" , id , "Order" , "Date" ) ;
UpdateOrder ( session , entity . Order , - 1 , entity . Date ) ;
UpdateOrderDetailPartial ( session , id , "DeleteState" , true ) ;
UpdateOrderDetailPartial ( session , id , "DeleteState" , true ) ;
session . Commit ( ) ;
session . Commit ( ) ;
}
}
@ -294,5 +258,15 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
}
}
return 1 ;
return 1 ;
}
}
static void UpdateOrder ( IDmoSession session , int greaterThanOrder , int offset , DateTime ? date )
{
var update = new DQUpdateDom ( typeof ( OrderDetail ) ) ;
update . Columns . Add ( new DQUpdateColumn ( "Order" , DQExpression . Add ( DQExpression . Field ( "Order" ) , DQExpression . Value ( offset ) ) ) ) ;
update . Columns . Add ( new DQUpdateColumn ( "Sync" , false ) ) ;
update . Columns . Add ( new DQUpdateColumn ( "ModifyTime" , DateTime . Now ) ) ;
update . Where . Conditions . Add ( DQCondition . And ( DQCondition . GreaterThan ( "Order" , greaterThanOrder ) , DQCondition . EQ ( "Date" , date ) , DQCondition . EQ ( "DeleteState" , false ) , DQCondition . EQ ( "SecondarySplit" , false ) ) ) ;
session . ExecuteNonQuery ( update ) ;
}
}
}
}
}