xiaoding721
2024-10-29 11b179f35b54d33f8414ccaa815b5fa8313b7746
_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_DispatchDL.qbl
@@ -8,46 +8,59 @@
  [*
    // Akari Oct-28-2024 (created)
    // 接口地址:172.30.9.10/PPPS/AddPlan—大连地址
    url := "http://172.30.9.10/PPPS/AddPlan"
    address := "172.30.9.10"
    url := "/PPPS/AddPlan";
    
    datas := selectset( recycleBin,DispatchShiftSchedulingLine.DispatchShiftSchedulingProduct,object,object.DispatchShiftSchedulingLine().Fac() = "DL" );
    
    datas_Json := JSON::Array();
    traverse( datas,Elements,product ){
    traverse( datas,Elements,product ,product.DispatchShiftSchedulingDetail( relsize ) <> 0 ){
      line := product.DispatchShiftSchedulingLine();
      
      data_Json := JSON::Object();
      datas_Json.Add( data_Json );
      data_Json.Add( "LineName" , line.LineName() );
      data_Json.Add( "ProductionDate",line.ShiftDate().Format( "Y-M2-D2" ));
      data_Json.Add( "shiftCode" , line.ShiftName() );
      details_Json := JSON::Array();
      data_Json.Add( "planItems",details_Json );
      traverse( product,DispatchShiftSchedulingDetail,detail ){
        detail_Json := JSON::Object();
        details_Json.Add( detail_Json );
        detail_Json.Add( "ShiftName",detail.SingleShiftName() );
        detail_Json.Add( "Quantity",detail.ShiftVolume() );
        detail_Json.Add( "ProductNo",detail.DispatchShiftSchedulingProduct().ProductID() );
        details_Json.Add( detail_Json );
      }
      data_Json.Add( "planItems",details_Json );
      datas_Json.Add( data_Json );
    }
    
    info( datas_Json.AsString() );
    i := HTTPInterface::Create( url, 80 );
    i := HTTPInterface::Create( address, 80 );
    i.URL( url );
    i.PostMethod( true );
    i.MediaType( "application/json" );
    i.TimeOut( Duration::Minutes( 5 ) );
    
    i.Call( datas_Json.AsString() );
    resultJson := JSON::Object();
    resultJson.Add( "jsonStr", datas_Json.Build().AsString() );
    json := resultJson.Build().AsString();
    LocalTool::WriteStringToFile( json );
    i.Call( json );
    htmlresult := i.Result();
    respJSON   := JSON::Parse( htmlresult );
    
    return respJSON.Get( "Message" ).AsString();
    result := respJSON.Get( "State" ).AsString();
    message := respJSON.Get( "Message" ).AsString();
    if( result = "Error" ){
      error( "远程服务器返回了一个错误:" + message );
    }
    return message;
  *]
}