From 4ab4a5430dc1fb127869e1a8c9b8e8bf4d0d0c09 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期四, 27 六月 2024 14:26:10 +0800
Subject: [PATCH] 财务产量报表导入校验
---
_Main/BL/Type_FinancialProductionReport/Method_IdentifyNullValues.qbl | 53 +++++++++++++++++
_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl | 5 +
_Main/BL/Type_FinancialProductionRow/Attribute_DuplicateValueMarker.qbl | 8 ++
_Main/BL/InfoMessages.qbl | 32 ++++++++++
_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl | 57 +++++++++++++++++++
_Main/BL/Type_FinancialProductionRow/DefaultValue_DuplicateValueMarker.qbl | 6 ++
6 files changed, 161 insertions(+), 0 deletions(-)
diff --git a/_Main/BL/InfoMessages.qbl b/_Main/BL/InfoMessages.qbl
index 79e2d9c..2e0fc10 100644
--- a/_Main/BL/InfoMessages.qbl
+++ b/_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: '瀵煎叆妯℃澘鍖呭惈鏈潵鏈堜唤鐨勮储鍔℃暟鎹紝鏄惁瑕嗙洊绯荤粺璁$畻缁撴灉锛�'
diff --git a/_Main/BL/Type_FinancialProductionReport/Method_IdentifyNullValues.qbl b/_Main/BL/Type_FinancialProductionReport/Method_IdentifyNullValues.qbl
new file mode 100644
index 0000000..eea236e
--- /dev/null
+++ b/_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() );
+ }
+ *]
+}
diff --git a/_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl b/_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl
new file mode 100644
index 0000000..55ea3ee
--- /dev/null
+++ b/_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() );
+ }
+ *]
+}
diff --git a/_Main/BL/Type_FinancialProductionRow/Attribute_DuplicateValueMarker.qbl b/_Main/BL/Type_FinancialProductionRow/Attribute_DuplicateValueMarker.qbl
new file mode 100644
index 0000000..4374a63
--- /dev/null
+++ b/_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
+}
diff --git a/_Main/BL/Type_FinancialProductionRow/DefaultValue_DuplicateValueMarker.qbl b/_Main/BL/Type_FinancialProductionRow/DefaultValue_DuplicateValueMarker.qbl
new file mode 100644
index 0000000..bbb8a45
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionRow/DefaultValue_DuplicateValueMarker.qbl
@@ -0,0 +1,6 @@
+Quintiq file version 2.0
+#parent: #root
+DefaultValue
+{
+ TargetAttribute: DuplicateValueMarker
+}
diff --git a/_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl b/_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl
index f5fdc53..44f9498 100644
--- a/_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl
+++ b/_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();
--
Gitblit v1.9.3