lazhen
2024-06-27 4ab4a5430dc1fb127869e1a8c9b8e8bf4d0d0c09
财务产量报表导入校验
已修改2个文件
已添加4个文件
161 ■■■■■ 文件已修改
_Main/BL/InfoMessages.qbl 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionReport/Method_IdentifyNullValues.qbl 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionRow/Attribute_DuplicateValueMarker.qbl 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionRow/DefaultValue_DuplicateValueMarker.qbl 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/InfoMessages.qbl
@@ -98,6 +98,38 @@
  {
    DefaultText: 'The two products selected are the same.'
  }
  InfoMessage MP_FinancialProductionReport_ImportIndetifyDuplicateData
  {
    DefaultText: 'There is duplicate data present.'
  }
  InfoMessage MP_FinancialProductionReport_ImportIndetifyFactoryNoExist
  {
    DefaultText: 'Factory does not exist.'
  }
  InfoMessage MP_FinancialProductionReport_ImportIndetifyIllegalCharacter
  {
    DefaultText: 'The required quantity contains illegal characters.'
  }
  InfoMessage MP_FinancialProductionReport_ImportIndetifyIllegalTime
  {
    DefaultText: 'The required period contains illegal time.'
  }
  InfoMessage MP_FinancialProductionReport_ImportIndetifyNegativeNumber
  {
    DefaultText: 'The required quantity includes negative numbers.'
  }
  InfoMessage MP_FinancialProductionReport_ImportIndetifyNullStrings
  {
    DefaultText: 'Required fields contain empty data.'
  }
  InfoMessage MP_FinancialProductionReport_ImportIndetifyOverPeriod
  {
    DefaultText: 'The template month is not within the planning cycle.'
  }
  InfoMessage MP_FinancialProductionReport_ImportIndetifyProductNoExist
  {
    DefaultText: 'Product does not exist.'
  }
  InfoMessage MP_FinancialProductionReport_Question
  {
    DefaultText: '导入模板包含未来月份的财务数据,是否覆盖系统计算结果?'
_Main/BL/Type_FinancialProductionReport/Method_IdentifyNullValues.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
Quintiq file version 2.0
#parent: #root
Method IdentifyNullValues
{
  TextBody:
  [*
    // åˆ é™¤ç©ºè¡Œæ•°æ®
    productcolumn := selectobject( this, FinancialProductionColumn, column, column.Index() = 0 );
    unitcolumn    := selectobject( this, FinancialProductionColumn, column, column.Index() = 1 );
    //删除没有对应日期数据的行
    traverse ( this, FinancialProductionRow, row ) {
      if ( forall( row, FinancialProductionCell, cell, true, ( cell.FinancialProductionColumn() <> productcolumn or cell.FinancialProductionColumn() <> unitcolumn ) and cell.Value().TrimBoth() = "" ) ) {
        row.Delete();
      }
    }
    // åˆ¤æ–­æ˜¯å¦å­˜åœ¨è´Ÿæ•°
    traverse ( this, FinancialProductionRow.FinancialProductionCell, cell ) {
      if ( cell.FinancialProductionColumn().Index() <= 1 ) {
        if ( cell.Value().TrimBoth() = "" ) {
          error( Translations::MP_FinancialProductionReport_ImportIndetifyNullStrings() );
        }
      } else {
        if ( cell.Value().TrimBoth() = "" ) {
          cell.Value( '0' );
    //      error( Translations::AC_SalesForecastInputSource_Error6() );
        } else {
          stn := StringToReal::StandardConverter();
          if ( not stn.CanConvert( cell.Value().TrimBoth() ) ) {
            error( Translations::MP_FinancialProductionReport_ImportIndetifyIllegalCharacter() );
          } else {
            if ( stn.Convert( cell.Value().TrimBoth() ) >= 0 ) {
              cell.Value( [String]ceil( stn.Convert( cell.Value().TrimBoth() ) ) );
            } else {
              error( Translations::MP_FinancialProductionReport_ImportIndetifyNegativeNumber() );
            }
          }
        }
      }
      cell.FinancialProductionRow().DuplicateValueMarker( cell.FinancialProductionRow().DuplicateValueMarker()                  +
                                                        ifexpr( cell.FinancialProductionColumn().Index() = 0, "", "-" ) +
                                                        cell.Value()
                                                       );
    }
    // åˆ¤æ–­æ˜¯å¦å­˜åœ¨é‡å¤æ•°æ®
    row := selectduplicates( this, FinancialProductionRow, row, true, row.DuplicateValueMarker() );
    if ( row.Size() > 1 ) {
      error( Translations::MP_FinancialProductionReport_ImportIndetifyDuplicateData() );
    }
  *]
}
_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,57 @@
Quintiq file version 2.0
#parent: #root
Method ImportVerification
{
  TextBody:
  [*
    // ç”„兰鸽 Jun-27-2024 (created)
    owner           := this.FinancialProductionSource().MacroPlan();
    startofthisyear := owner.StartOfPlanning().StartOfYear().Date();
    startofnextyear := owner.StartOfPlanning().StartOfNextYear().Date();
    if ( exists( this, FinancialProductionColumn, column, ( column.Index() = 0 and column.Name() <> "Product" )             or
                                                      ( column.Index() = 1 and column.Name() <> "Unit" )  ) ){
      error( Translations::MP_FinancialProductionReport_ImportIndetifyNullStrings() );
    }
    indexcolumn := select( this, FinancialProductionColumn, column, column.Index() = 2 );
    if ( isnull( indexcolumn ) ) {
      error( Translations::MP_FinancialProductionReport_ImportIndetifyNullStrings() );
    } else {
      cnv2 := StringToDate::StandardConverter();
      cnv2.SetCustomConversion();
      cnv2.CustomFormatString( "dd/MM/yyyy" );
      while ( not isnull( indexcolumn ) ) {
        if ( not cnv2.CanConvert( indexcolumn.Name() ) ) {
          error( Translations::MP_FinancialProductionReport_ImportIndetifyIllegalTime() );
        }
        period := cnv2.Convert( indexcolumn.Name() );
      //  info( "开始时间:", this.SalesForecastInputSource().PlanningStartDate().Format( "Y-M2-D2" ),
      //        "结束时间:", this.SalesForecastInputSource().PlanningEndDate().Format( "Y-M2-D2" ),
      //        "列时间:", cnv2.Convert( indexColumn.name() ).Format( "Y-M2-D2" ) );
        // åˆ¤æ–­æ˜¯å¦åœ¨è®¡åˆ’周期内
        if ( period <= startofthisyear or period >= startofnextyear ) {
          error( Translations::MP_FinancialProductionReport_ImportIndetifyOverPeriod() );
        }
        indexcolumn := indexcolumn.NextColumn();
      }
    }
    productcolumn := selectobject( this, FinancialProductionColumn, column, column.Index() = 0 );
    unitcolumn    := selectobject( this, FinancialProductionColumn, column, column.Index() = 1 );
    units         := selectuniquevalues( unitcolumn, FinancialProductionCell, cell, cell.Value() );
    if( units.Size() <> 2 or ( units.Find( FinancialProductionReport::GetDefaultCCUnit() ) >= 0
                               and units.Find( FinancialProductionReport::GetDefaultDLUnit() ) >= 0 ) ){
      error( Translations::MP_FinancialProductionReport_ImportIndetifyFactoryNoExist() );
    }
    products     := selectuniquevalues( productcolumn, FinancialProductionCell, cell, cell.Value() );
    productnames := selectuniquevalues( owner, Product_MP, product, product.ID() );
    if( not productnames.ContainsAll( products ) ){
      error( Translations::MP_FinancialProductionReport_ImportIndetifyProductNoExist() );
    }
  *]
}
_Main/BL/Type_FinancialProductionRow/Attribute_DuplicateValueMarker.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
Quintiq file version 2.0
#parent: #root
Attribute DuplicateValueMarker
{
  #keys: '3[415136.0.857450433][415136.0.857450432][415136.0.857450434]'
  Description: '判断是否存在重复值'
  ValueType: String
}
_Main/BL/Type_FinancialProductionRow/DefaultValue_DuplicateValueMarker.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,6 @@
Quintiq file version 2.0
#parent: #root
DefaultValue
{
  TargetAttribute: DuplicateValueMarker
}
_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl
@@ -24,6 +24,11 @@
      this.FinancialProductionReport( relinsert, &xlstable ); 
      
      Transaction::Transaction().Propagate( attribute( FinancialProductionColumn, Index ) );
      // ï¼ˆå¯¼å…¥å‰ï¼‰ç»™ç©ºå€¼èµ‹äºˆé»˜è®¤å€¼ï¼ˆN/A),并且删除空行数据和数据校验
      xlstable.IdentifyNullValues();
      xlstable.ImportVerification();
    }
    //导入后处理数据
    //this.AfterImport();