| | |
| | | *创建时间:2023-09-27 |
| | | *描 述:填产后订单冲减,填产后的表:Owner.FillingCapacityOrder |
| | | *参 数:Operator 操作人 |
| | | *返 回 值:JSON {Status: true 成功/false 失败,Msg:"提示消息"} |
| | | *返 回 值:JSON {Status: true 成功/false 失败,Msg:"提示消息",Count: 0(冲减订单的数量)} |
| | | *******************************************************************/ |
| | | // 初始化结果 |
| | | bStatus := false; |
| | | strMsg :=""; |
| | | // 冲减成功条数 |
| | | nCount:=0; |
| | | try |
| | | { |
| | | error( "AAAAAA"); |
| | | if(not isnull( Owner)) |
| | | { |
| | | // Customer 换成状态 |
| | | NewOrders := selectset( Owner,FillingCapacityOrder,Obj,Obj.State() = "未冲减"); |
| | | // 获取操作订单 |
| | | NewOrders := selectset( Owner,FillingCapacityOrder,Obj,Obj.State() = "未冲减" or Obj.State() =""); |
| | | if(NewOrders.Size()>0) |
| | | { |
| | | // 新订单与原订单冲减 |
| | | traverse( NewOrders,Elements,Obj) |
| | | { |
| | | if( Obj.OrderType()="反签" or Obj.OrderType()="授权") |
| | | if( (Obj.OrderType()="反签" or Obj.OrderType()="授权") and Obj.Quantity()>0 ) |
| | | { |
| | | // 更新状态 |
| | | // 得到操作相关的反签订单 |
| | | ROrders:= select( Owner,SalesDemand.astype( CustomerOrder ),ObjOrder, |
| | | ObjOrder.CustomerName() = Obj.Customer() |
| | | and ObjOrder.ProductID()=Obj.ProductID() |
| | | and ObjOrder.OrderTag() ="反签" |
| | | ); |
| | | // 反签无冲减,直接向订单中加入反签数据 |
| | | if( Obj.OrderType()="反签") |
| | | { |
| | | if( not isnull( ROrders)) |
| | | { |
| | | ROrders.Quantity(ROrders.Quantity()+Obj.Quantity()); |
| | | } |
| | | else |
| | | { |
| | | // 新增订单 |
| | | error( "----------------请实现新增反签订单功能代码---------------------"); |
| | | // 订单必要信息如下: |
| | | // OrderTag = "反签" |
| | | // Quantity = Obj.Quantity() |
| | | // 其他信息继承当前的订单 |
| | | } |
| | | } |
| | | else if(Obj.OrderType()="授权") |
| | | { |
| | | // 得到操作相关的授权订单 |
| | | AOrders:= select( Owner,SalesDemand.astype( CustomerOrder ),ObjOrder, |
| | | ObjOrder.CustomerName() = Obj.Customer() |
| | | and ObjOrder.ProductID()=Obj.ProductID() |
| | | and ObjOrder.OrderTag() ="授权" |
| | | ); |
| | | if( not isnull( ROrders)) |
| | | { |
| | | // 当前反签数量 |
| | | RQty:=ROrders.Quantity(); |
| | | // 计算新的授权数量 |
| | | AQty:= Obj.Quantity() - ROrders.Quantity(); |
| | | // 授权大于0,反签被冲没,否则授权被冲,反签等于AQty的绝对值 |
| | | if( AQty>=0) |
| | | { |
| | | RQty:=0; |
| | | } |
| | | else |
| | | { |
| | | RQty :=ROrders.Quantity() - Obj.Quantity(); |
| | | AQty :=0; |
| | | } |
| | | // 更新反签数据 |
| | | if( RQty>=0) |
| | | { |
| | | ROrders.Quantity(RQty); |
| | | } |
| | | else |
| | | { |
| | | ROrders.Delete(); |
| | | } |
| | | // 更新授权数据 |
| | | if(AQty>0 ) |
| | | { |
| | | if( not isnull( AOrders)) |
| | | { |
| | | AOrders.Quantity(AOrders.Quantity()+AQty); |
| | | } |
| | | // 新增授权订单 |
| | | error( "----------------请实现新增授权订单功能代码---------------------"); |
| | | // 订单必要信息如下: |
| | | // OrderTag = "授权" |
| | | // Quantity = AQty |
| | | // 其他信息继承当前的订单 |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 将新授权数据累加到订单中 |
| | | if( not isnull( AOrders)) |
| | | { |
| | | AOrders.Quantity(AOrders.Quantity()+Obj.Quantity()); |
| | | } |
| | | else |
| | | { |
| | | // 新增授权订单 |
| | | error( "----------------请实现新增授权订单功能代码---------------------"); |
| | | // 订单必要信息如下: |
| | | // OrderTag = "授权" |
| | | // Quantity = Obj.Quantity() |
| | | // 其他信息继承当前的订单 |
| | | } |
| | | } |
| | | } |
| | | // 更新冲减状态 |
| | | Obj.State("已冲减"); |
| | | nCount++; |
| | | } |
| | | else |
| | | { |
| | | strMsg :="订单类型:" + Obj.OrderType() + "无法冲减!"; |
| | | // 无法识别的类型,或数量为0时暂不处理 |
| | | //strMsg :="订单类型:" + Obj.OrderType() + "无法冲减!"; |
| | | } |
| | | } |
| | | bStatus:=true; |
| | |
| | | { |
| | | strMsg :="填产后订单冲减发生错误,请联系系统管理员!"; |
| | | // 记录错误日志 |
| | | Owner.H_ErrorLogs(relnew,EClassName := "H_FunctionClass",EDateTime := DateTime::ActualGMTTime(),EFunctionName := "SM_OrderHedgingEx", |
| | | DeveloperInformation := e.DeveloperInformation(),ErrorNr := e.ErrorNr(),DetailedInformation := e.DetailedInformation(), |
| | | GeneralInformation := e.GeneralInformation()); |
| | | // Owner.H_ErrorLogs(relnew,EClassName := "H_FunctionClass",EDateTime := DateTime::ActualGMTTime(),EFunctionName := "SM_OrderHedgingEx", |
| | | // DeveloperInformation := e.DeveloperInformation(),ErrorNr := e.ErrorNr(),DetailedInformation := e.DetailedInformation(), |
| | | // GeneralInformation := e.GeneralInformation()); |
| | | } |
| | | return JSON::Object().Add( "Status",bStatus) |
| | | .Add( "Count",nCount) |
| | | .Add( "Msg",strMsg).Build(); |
| | | *] |
| | | } |