haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
Quintiq file version 2.0
#parent: #root
Method DoASyncMappingActualPISPIPData (
  Strings businessTypes,
  const GlobalOTDTable globalOTDTable,
  Boolean nuclear,
  Strings organcodelist
)
{
  TextBody:
  [*
    // renhao Aug-14-2023 (created)
    listtodeal := construct( Global_MappingActualProductInStockingPointInPeriods, 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_MAPISPIPCategory.Global_MappingActualProductInStockingPointInPeriod, 
                               tempGMPIL, 
                               ( tempGMPIL.ActualInventoryLevelEnd() > 0 ) and 
                               ( organcodelist.Find( tempGMPIL.StockingPointID().SubString( 0, 3 ) ) >= 0 ) );
    } else {  
      listtodeal := selectset( globalOTDTable,
                               Global_MappingActualProductInStockingPointInPeriod,
                               actual,
                               ( actual.ActualInventoryLevelEnd() > 0 ) and 
                               ( organcodelist.Find( actual.StockingPointID().SubString( 0, 3 ) ) >= 0 ) );
    }
    totalcount := listtodeal.Size();
    info( "ActualPISPIP has " + totalcount.AsQUILL() + " rows in total" );
    
    count := 0;
    traverse( listtodeal,Elements,actual){
      count := count + 1;
      if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
        info( "Now is dealing with the " + count.AsQUILL() + "ActualPISPIP " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
        }
      //product := select( globalOTDTable,Global_MappingProduct_MP,product,product.ID() = actual.ProductID() and product.KeyProduct() = nuclear,true);
      //if( guard( actual.Global_MAPISPIPCategory().KeyProduct() = nuclear, false ) ){
      if( not nuclear or (nuclear and actual.Global_MAPISPIPCategory().Critical() = nuclear) ){
      if( not isnull(businessTypes)){
      
        
          //businessType := businessTypes.Element( i );
          if( /*product.BusinessType() = businessType and not product.IsCommon()*/ not actual.Global_MAPISPIPCategory().IsCommon() ){
            ActualProductInStockingPointInPeriod::CreateOrUpdate( this,
                                                                  actual.ProductID(),
                                                                  actual.StockingPointID(),
                                                                  actual.Description(),
                                                                  actual.ActualInventoryLevelEnd(),
                                                                  actual.ManufacturedDate());
          }
        
        
      }else{
        ActualProductInStockingPointInPeriod::CreateOrUpdate( this,
                                                              actual.ProductID(),
                                                              actual.StockingPointID(),
                                                              actual.Description(),
                                                              actual.ActualInventoryLevelEnd(),
                                                              actual.ManufacturedDate());
      }
        
      }
    }
  *]
}