renhao
2023-10-18 ff1d40a1a235da7c3bdfa26070af267f19c7a3d3
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
Quintiq file version 2.0
#parent: #root
Method DoASyncMappingSalesSegmentData (
  Strings businessTypes,
  const GlobalOTDTable globalOTDTable
)
{
  Description: 'ETL销售部门'
  TextBody:
  [*
    // yypsybs Aug-15-2023 (created)
    // 待处理数据
    listToDeal := construct( Global_MappingSalesSegment_MPs, constcontent );
    if( isnull( businessTypes ) or businessTypes.Size() = 0 ) {
        listToDeal := selectset( globalOTDTable, Global_MappingSalesSegment_MP, item, true );
    } else {
        listToDeal := selectset( globalOTDTable, 
                                 Global_MappingSalesSegment_MP, 
                                 item, 
                                 businessTypes.Find( item.BusinessType() ) <> -1 );
    }
    //nameList := construct( structured[String] );
    //nameList := selectvalues( listToDeal, Elements, item, true, item.Name() );
    //// 检查parent
    //traverse( listToDeal, Elements, item, item.ParentName() <> "" ) {
    //    if( nameList.Find( item.ParentName() ) = -1 ) {
    //        error( "sales segment parent not found: " + item.Name().AsQUILL() );
    //    }
    //}
    //// 逐层遍历,直至处理完成
    //dealtNameList := construct( structured[String] );
    //while( listToDeal.Size() <> dealtNameList.Size() ) {
    //    traverse( listToDeal, Elements, item ) {
    //        // 未处理过
    //        if( dealtNameList.Find( item.Name() ) < 0 ){
    //            // 无父部门,直接处理
    //            if( item.ParentName() = "" ) {
    //                SalesSegment_MP::CreateOrUpdate( this, item.Name(), item.DisplayIndex(), item.ParentName() );
    //                dealtNameList.Add( item.Name() );
    //            } 
    //            // 有父部门且父部门已处理
    //            else if( item.ParentName() <> "" and dealtNameList.Find(item.ParentName()) >= 0 ) {
    //                SalesSegment_MP::CreateOrUpdate( this, item.Name(), item.DisplayIndex(), item.ParentName() );
    //                dealtNameList.Add( item.Name() );
    //            }
    //            // 有父部门且父部门未处理,下一轮处理
    //        }
    //    }
    //}
    traverse( listToDeal,Elements,item ){
      if( item.ParentName() <> "" and isnull( SalesSegment_MP::FindByName( this, item.ParentName() ) ) ){
        SalesSegment_MP::CreateOrUpdate( this, item.ParentName(), item.DisplayIndex(), "" );
        }
      }
    
    traverse( listToDeal,Elements,item ){
        SalesSegment_MP::CreateOrUpdate( this, item.Name(), item.DisplayIndex(), item.ParentName() );
      }
  *]
}