hongji.li
2023-10-26 dc03b8a0920cb6793a37e3a9cc4cd83ff384be94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Quintiq file version 2.0
#parent: #root
Method DoASyncMappingExternalSupplyData (
  Strings businessTypes,
  Boolean nuclear,
  const GlobalOTDTable globalOTDTable,
  Strings organcodelist
)
{
  TextBody:
  [*
    // renhao Aug-14-2023 (created)
    queryStartDate := guard( min( this, Period_MP, item, true, item.StartDate() ) - Duration::Days( 30 ), DateTime::MinDateTime() ).Date();
    queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
    
    listtodeal := construct( Global_MappingInventorySupplys, constcontent );
    if ( businessTypes.Size() > 0 ) {
      targetGlobal_ProductCategory := selectset( globalOTDTable, Global_ProductCategory, tempGPC, 
                                                 exists( businessTypes, Elements, tempBTN, tempBTN = tempGPC.BusinessTypeName() ) );
      listtodeal := selectset( targetGlobal_ProductCategory, 
                               Elements.Global_MappingProduct_MP.Global_InventorySupplyCategory.Global_MappingInventorySupply, 
                               tempGMIS, 
                               ( tempGMIS.UserQuantity()>0 ) and 
                               ( tempGMIS.Date() >= queryStartDate ) and 
                               ( organcodelist.Find( tempGMIS.StockingPointID().SubString( 0, 3 ) ) >= 0 ) );
    } else {
      listtodeal := selectset( globalOTDTable,
                               Global_MappingInventorySupply,
                               externalSupply, 
                               ( externalSupply.UserQuantity()>0 ) and 
                               ( externalSupply.Date() >= queryStartDate ) and 
                               ( organcodelist.Find( externalSupply.StockingPointID().SubString( 0, 3 ) ) >= 0 )/*and externalSupply.Date() <= queryEndDate*/);
    }
    
    totalcount := listtodeal.Size();
    description := "在途在制";
    info( "ExternalSupply has " + totalcount.AsQUILL() + " rows in total" );
    
    count := 0;
    traverse( listtodeal,Elements,externalSupply){
      count := count + 1;
      if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
        info( "Now is dealing with the " + count.AsQUILL() + "ExternalSupply " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
       }
      //product := select( globalOTDTable,Global_MappingProduct_MP,product,product.ID() = externalSupply.ProductID(),true);
      
      
      if( /*not isnull( product)*/ not isnull( externalSupply.Global_InventorySupplyCategory() ) ){
        productMP :=  Product_MP :: FindProductTypeIndex( externalSupply.ProductID());
        stockingpoint := select( this,StockingPoint_MP,st,st.ID() = externalSupply.StockingPointID(),true);
        if( not isnull( stockingpoint) and not isnull( productMP)){
        if( not isnull(businessTypes)){
        
          for( i :=0 ;i < businessTypes.Size();i++ ){
            //businessType := businessTypes.Element( i );
            if( /*product.BusinessType() = businessType and not product.IsCommon()*/ not externalSupply.Global_InventorySupplyCategory().IsCommon() ){
              InventorySupply::CreateOrUpdate( externalSupply.ID(),
                                               productMP,
                                               stockingpoint,
                                               externalSupply.Date(),
                                               externalSupply.ManufacturedDate(),
                                               externalSupply.UserQuantity(),description);
            }
          }
          
        }else{
          
            InventorySupply::CreateOrUpdate( externalSupply.ID(),
                                           productMP,
                                           stockingpoint,
                                           externalSupply.Date(),
                                           externalSupply.ManufacturedDate(),
                                           externalSupply.UserQuantity(),description);
          }
      
        }
        
      }
    }
  *]
}