admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
StaticMethod CheckImport (
  MacroPlan macroplan
)
{
  TextBody:
  [*
    // 甄兰鸽 Aug-22-2024 (created)
    if( exists( macroplan, ChangeLossSettingExcel, excel, excel.Product1() = '' 
                or excel.Product2() = '' 
                or excel.Unit() = '' 
                or excel.ChangeLossNumber() = ''
                or not excel.StartDate().IsFinite()
                or not excel.EndDate().IsFinite() ) ){
      error( Translations::MP_ChangeLossSettingExcel_Import_NullInputRequiredField() );
    }
    //导入的数量小于0
    if( exists( macroplan, ChangeLossSettingExcel, excel, [Real]excel.ChangeLossNumber() <= 0 ) ){
      error( Translations::MP_ChangeLossSettingExcel_Import_PositiveInteger() );
    }
    //导入产品是否存在
    productfirsts         := selectuniquevalues( macroplan, ChangeLossSettingExcel, excel, excel.Product1() );
    productseconds        := selectuniquevalues( macroplan, ChangeLossSettingExcel, excel, excel.Product2() );
    productids            := productfirsts.Union( productseconds );
    nonproductids         := selectuniquevalues( productids, Elements, e, not exists( macroplan, Product_MP, product, product.ID() = e ), e );
    if( nonproductids.Size() > 0 ){
      error( Translations::MP_ChangeLossSettingExcel_Import_ProductNoExist( nonproductids.Concatenate( ";" ) ) );
    //if( exists( macroplan, ChangeLossSettingExcel, excel, not exists( macroplan, Product_MP, product, product.ID() = excel.Product1() or product.ID() = excel.Product2() ) ) ){
    //  error( Translations::MP_ChangeLossSettingExcel_Import_ProductNoExist() );
    }
    //导入产线是否存在
    if( exists( macroplan, ChangeLossSettingExcel, excel, not exists( macroplan, Unit, unit, unit.ID() = excel.Unit() ) ) ){
      error( Translations::MP_ChangeLossSettingExcel_Import_UnitNoExist() );
    }
    //导入的两个产品相等
    if( exists( macroplan, ChangeLossSettingExcel, excel, excel.Product1() = excel.Product2() ) ){
      error( Translations::MP_ChangeLossSetting_SameProduct() );
    }
    //导入的时间区间校验
    if( exists( macroplan, ChangeLossSettingExcel, excel, excel.StartDate() > excel.EndDate() ) ){
      error( Translations::MP_LibCal_Event_ValidDatePeriod() );
    }
    //重复导入校验
    //if( selectduplicates( owner, LaneExcel, excel, excel.StartFrom(), 
    //                      excel.EndTo(), 
    //                      excel.StartStockingPoint(), 
    //                      excel.EndStockingPoint(), 
    //                      excel.TransporationType(), 
    //                      excel.Product(), 
    //                      excel.TransporationTime() ).Size() > 0 ){
    //  error( Translations::MP_LaneExcel_Import_RepeatKey() );
    //}
  *]
}