Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
c8b6338d
Commit
c8b6338d
authored
Jul 13, 2018
by
frank.xa.zhang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev_frank
parents
a3310810
577a7b36
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
160 additions
and
160 deletions
+160
-160
CloseableFormulaDataSource.java
...c/taxtech/atms/dto/vatdto/CloseableFormulaDataSource.java
+3
-3
FormulaDataSourceDto.java
...ava/pwc/taxtech/atms/dto/vatdto/FormulaDataSourceDto.java
+1
-1
ReportCellDataSourceDto.java
.../pwc/taxtech/atms/dto/vatdto/ReportCellDataSourceDto.java
+3
-2
FormulaAgent.java
.../java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
+22
-12
ReportFormulaFactory.java
...c/taxtech/atms/vat/service/impl/ReportFormulaFactory.java
+0
-141
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+2
-1
BB.java
...wc/taxtech/atms/vat/service/impl/report/functions/BB.java
+115
-0
FunctionBase.java
.../atms/vat/service/impl/report/functions/FunctionBase.java
+14
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/CloseableFormulaDataSource.java
View file @
c8b6338d
...
...
@@ -6,18 +6,18 @@ import java.util.ArrayList;
import
java.util.List
;
public
class
CloseableFormulaDataSource
implements
AutoCloseable
{
private
List
<
Formula
DataSourceDto
>
dataSourceList
=
new
ArrayList
<>();
private
List
<
ReportCell
DataSourceDto
>
dataSourceList
=
new
ArrayList
<>();
private
FormulaAgent
agent
;
public
CloseableFormulaDataSource
(
FormulaAgent
agent
)
{
this
.
agent
=
agent
;
}
public
void
addDS
(
Formula
DataSourceDto
ds
){
public
void
addDS
(
ReportCell
DataSourceDto
ds
){
dataSourceList
.
add
(
ds
);
}
public
void
addDS
(
List
<
Formula
DataSourceDto
>
dss
){
public
void
addDS
(
List
<
ReportCell
DataSourceDto
>
dss
){
dataSourceList
.
addAll
(
dss
);
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/FormulaDataSourceDto.java
View file @
c8b6338d
...
...
@@ -3,7 +3,7 @@ package pwc.taxtech.atms.dto.vatdto;
import
pwc.taxtech.atms.constant.enums.CellDataSourceType
;
public
class
FormulaDataSourceDto
extends
DataSourceDto
{
Integer
type
;
public
Integer
type
;
public
FormulaDataSourceDto
()
{
super
();
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/ReportCellDataSourceDto.java
View file @
c8b6338d
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
pwc.taxtech.atms.constant.Constant
;
import
lombok.Getter
;
import
pwc.taxtech.atms.constant.DataSourceName
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceType
;
import
pwc.taxtech.atms.dto.CellTemplateDto
;
import
pwc.taxtech.atms.vat.entity.CellData
;
@Getter
public
class
ReportCellDataSourceDto
extends
FormulaDataSourceDto
{
Integer
year
;
Integer
period
;
...
...
@@ -39,6 +39,7 @@ public class ReportCellDataSourceDto extends FormulaDataSourceDto {
public
static
ReportCellDataSourceDto
extractFromGroup
(
BBParasBo
bbParasBo
,
CurrentPeriodBo
currentPeriodBo
,
CellData
cellData
,
CellTemplatePerGroupDto
cellTemplateData
)
{
ReportCellDataSourceDto
dataSource
=
new
ReportCellDataSourceDto
();
dataSource
.
name
=
DataSourceName
.
ReportDataSource
;
dataSource
.
year
=
currentPeriodBo
.
curYear
;
dataSource
.
period
=
currentPeriodBo
.
curPeriod
;
dataSource
.
columnIndex
=
bbParasBo
.
getColumnIndex
();
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FormulaAgent.java
View file @
c8b6338d
...
...
@@ -6,9 +6,10 @@ import pwc.taxtech.atms.constant.enums.EnumServiceType;
import
pwc.taxtech.atms.dao.FormulaAdminMapper
;
import
pwc.taxtech.atms.dto.GroupId
;
import
pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dto.vatdto.
Formula
DataSourceDto
;
import
pwc.taxtech.atms.dto.vatdto.
ReportCell
DataSourceDto
;
import
pwc.taxtech.atms.entitiy.ProjectServiceType
;
import
pwc.taxtech.atms.entitiy.ProjectServiceTypeExample
;
import
pwc.taxtech.atms.service.impl.DistributedIDService
;
import
pwc.taxtech.atms.vat.dao.CellDataMapper
;
import
pwc.taxtech.atms.vat.dao.FormulaProjectMapper
;
import
pwc.taxtech.atms.vat.dao.ReportMapper
;
...
...
@@ -18,6 +19,8 @@ import pwc.taxtech.atms.vat.entity.DataSource;
import
pwc.taxtech.atms.vat.entity.Report
;
import
pwc.taxtech.atms.vat.entity.ReportExample
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
import
static
pwc
.
taxtech
.
atms
.
constant
.
Constant
.
FIRST_OR_DEFAULT
;
...
...
@@ -32,6 +35,8 @@ public class FormulaAgent extends VatAbstractService {
public
ReportMapper
reportMapper
;
@Autowired
public
CellDataMapper
cellDataMapper
;
@Autowired
public
DistributedIDService
distributedIDService
;
public
List
<
CellTemplatePerGroupDto
>
getCellTemplateGroupDto
(
Long
templateGroupId
,
String
projectId
)
{
...
...
@@ -73,20 +78,25 @@ public class FormulaAgent extends VatAbstractService {
return
null
;
}
public
void
save
(
List
<
FormulaDataSourceDto
>
dataSourceDtos
)
{
dataSourceDtos
.
forEach
(
m
->
{
public
void
save
(
List
<
ReportCellDataSourceDto
>
dataSourceDtos
)
{
dataSourceDtos
.
forEach
(
m
->
{
DataSource
ds
=
new
DataSource
();
ds
.
setAmount
(
m
.
getAmount
());
ds
.
setCreateBy
(
m
.
getCreator
());
ds
.
setCreateTime
(
m
.
getCreateTime
());
ds
.
setDescription
(
m
.
getDescription
());
ds
.
setAmount
(
m
.
getAmount
()
==
null
?
new
BigDecimal
(
0
)
:
m
.
getAmount
()
);
ds
.
setCreateBy
(
m
.
getCreator
()
==
null
?
"Admin"
:
m
.
getCreator
()
);
ds
.
setCreateTime
(
m
.
getCreateTime
()
==
null
?
new
Date
()
:
m
.
getCreateTime
()
);
ds
.
setDescription
(
m
.
getDescription
()
==
null
?
""
:
m
.
getDescription
()
);
ds
.
setKeyValueDataId
(
m
.
getKeyValueDataID
());
ds
.
setName
(
m
.
getName
());
ds
.
setId
(
m
.
getId
());
ds
.
setType
(
m
.
getType
());
ds
.
setUpdateBy
(
m
.
getUpdater
());
ds
.
setUpdateTime
(
m
.
getUpdateTime
());
ds
.
setType
(
m
.
type
);
ds
.
setUpdateBy
(
m
.
getUpdater
()
==
null
?
"Admin"
:
m
.
getUpdater
());
ds
.
setUpdateTime
(
m
.
getUpdateTime
()
==
null
?
new
Date
()
:
m
.
getUpdateTime
());
ds
.
setId
(
distributedIDService
.
nextId
());
ds
.
setKeyValueDataId
(
m
.
getDescription
()
==
null
?
""
:
m
.
getDescription
());
//TODO: tobe fixed
ds
.
setRowName
(
m
.
getRowName
()
==
null
?
""
:
m
.
getRowName
());
ds
.
setColumnName
(
m
.
getColumnName
()
==
null
?
""
:
m
.
getColumnName
());
ds
.
setRowIndex
(
m
.
getRowIndex
());
ds
.
setColumnIndex
(
m
.
getColumnIndex
());
ds
.
setRemapBatchId
(
"0"
);
//TODO: tobe fixed
dataSourceMapper
.
insert
(
ds
);
});
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportFormulaFactory.java
deleted
100644 → 0
View file @
a3310810
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.NumberEval
;
import
org.apache.poi.ss.formula.eval.StringEval
;
import
org.apache.poi.ss.formula.eval.ValueEval
;
import
org.apache.poi.ss.formula.functions.FreeRefFunction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
pwc.taxtech.atms.common.datasource.ShardingContextHolder
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.dto.vatdto.BBParasBo
;
import
pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dto.vatdto.CloseableFormulaDataSource
;
import
pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.entity.CellData
;
import
pwc.taxtech.atms.vat.entity.Report
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext
;
import
java.math.BigDecimal
;
public
class
ReportFormulaFactory
{
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ReportFormulaFactory
.
class
);
final
static
ValueEval
defaultEval
=
new
StringEval
(
"0"
);
final
static
BigDecimal
defaultBigDecimal
=
new
BigDecimal
(
"0"
);
public
static
abstract
class
ReportBaseFormula
implements
FreeRefFunction
{
final
FormulaContext
context
;
final
FormulaAgent
agent
;
protected
ReportBaseFormula
(
FormulaContext
context
)
{
this
.
context
=
context
;
this
.
agent
=
context
.
getFormulaAgent
();
}
public
int
getYear
(
int
parameterYear
)
{
if
(
parameterYear
<=
-
1
)
{
return
parameterYear
+
context
.
getYear
();
}
else
if
(
parameterYear
==
0
)
{
return
context
.
getYear
();
}
else
{
return
parameterYear
;
}
}
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
try
{
return
wrapExceptionEval
(
args
,
ec
);
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"un expect exception"
,
e
);
e
.
printStackTrace
();
return
defaultEval
;
}
}
public
abstract
ValueEval
wrapExceptionEval
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
throws
Exception
;
}
public
static
class
BB
extends
ReportBaseFormula
{
protected
BB
(
FormulaContext
context
)
{
super
(
context
);
}
@Override
public
ValueEval
wrapExceptionEval
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
throws
Exception
{
return
new
NumberEval
(
bb
(
new
BBParasBo
(
args
,
ec
)).
doubleValue
());
}
public
BigDecimal
bb
(
BBParasBo
bo
)
throws
Exception
{
try
(
CloseableFormulaDataSource
closeDataSource
=
new
CloseableFormulaDataSource
(
context
.
getFormulaAgent
()))
{
CurrentPeriodBo
curPeriod
=
CurrentPeriodBo
.
getPeriod
(
bo
.
getPeriod
().
intValue
(),
context
.
getPeriod
());
curPeriod
.
fixedCurYear
(
getYear
(
curPeriod
.
getCurYear
()));
ReportCellDataSourceDto
nullCellDto
=
ReportCellDataSourceDto
.
nullDataSource
(
bo
,
curPeriod
);
closeDataSource
.
addDS
(
nullCellDto
);
CellTemplatePerGroupDto
cellTemplateData
=
agent
.
getCellTemplateGroupDto
(
context
.
getReportTemplateGroupID
(),
context
.
getProjectID
()).
stream
().
filter
(
dto
->
dto
.
getRowIndex
()
==
bo
.
getColumnIndex
()
-
1
&&
dto
.
getColumnIndex
()
==
bo
.
getColumnIndex
()
-
1
).
findFirst
().
get
();
MyAsserts
.
assertNotNull
(
cellTemplateData
,
Exceptions
.
BB_CELL_TEMP_NULL
);
nullCellDto
.
fixedWithGroup
(
cellTemplateData
);
// todo: fix datasource name by templateList(neo)
if
(
curPeriod
.
getCurPeriod
()
==
-
99
)
{
closeDataSource
.
clean
();
BigDecimal
returnEval
=
defaultBigDecimal
;
if
(
context
.
getPeriod
()
<=
1
)
{
return
defaultBigDecimal
;
}
for
(
int
p
=
1
;
p
<
context
.
getPeriod
();
p
++)
{
returnEval
=
returnEval
.
add
(
bb
(
new
BBParasBo
(
bo
,
p
,
curPeriod
.
getCurYear
())));
}
return
returnEval
;
}
bo
.
disCount
();
String
dbName
=
SpringContextUtil
.
formulaAdminMapper
.
getPastProjectDbName
(
curPeriod
.
getCurYear
(),
context
.
getOrganizationID
());
String
currentProjectDb
=
ShardingContextHolder
.
getDataSourceKey
();
ShardingContextHolder
.
setDataSourceKey
(
dbName
);
try
{
Report
report
=
agent
.
getReportByTemplate
(
cellTemplateData
.
getReportTemplateID
(),
curPeriod
.
getCurPeriod
());
MyAsserts
.
assertNotNull
(
report
,
Exceptions
.
BB_REPORT_NULL
);
CellData
cellData
=
agent
.
getCellDataListByTemplate
(
cellTemplateData
.
getCellTemplateID
(),
report
.
getId
());
MyAsserts
.
assertNotNull
(
cellData
,
Exceptions
.
BB_CELL_DATA_NULL
);
nullCellDto
=
ReportCellDataSourceDto
.
extractFromGroup
(
bo
,
curPeriod
,
cellData
,
cellTemplateData
);
// todo: fix datasource name by templateList(neo)
MyAsserts
.
assertNotNull
(
cellData
.
getData
(),
Exceptions
.
BB_CELL_DATA_NULL
);
// cellValue= RoundValue(cellValue, cellDataType)TODO:maybe fixd round by cellDataTyep(KV neo)
BigDecimal
cellValue
=
new
BigDecimal
(
cellData
.
getData
()).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
);
nullCellDto
.
setAmount
(
cellValue
);
LOGGER
.
debug
(
"cell static value "
);
ShardingContextHolder
.
setDataSourceKey
(
currentProjectDb
);
return
cellValue
;
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"un support exception"
,
e
);
ShardingContextHolder
.
setDataSourceKey
(
currentProjectDb
);
throw
e
;
}
}
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
c8b6338d
...
...
@@ -26,6 +26,7 @@ import pwc.taxtech.atms.dto.vatdto.PeriodCellTemplateConfigExtendDto;
import
pwc.taxtech.atms.entitiy.Project
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.service.ReportGenerator
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.BB
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FSJZ
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.ND
;
...
...
@@ -282,7 +283,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
private
void
addFunctionsToWorkbook
(
Workbook
workbook
,
FormulaContext
formulaContext
)
{
String
[]
functionNames
=
{
"SGSR"
,
"FSJZ"
,
"ND"
,
"BB"
};
FreeRefFunction
[]
functionImpls
=
{
new
SGSR
(
formulaContext
),
new
FSJZ
(
formulaContext
),
new
ND
(
formulaContext
),
new
ReportFormulaFactory
.
BB
(
formulaContext
)};
new
BB
(
formulaContext
)};
UDFFinder
udfs
=
new
DefaultUDFFinder
(
functionNames
,
functionImpls
);
UDFFinder
udfToolpack
=
new
AggregatingUDFFinder
(
udfs
);
workbook
.
addToolPack
(
udfToolpack
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/BB.java
0 → 100644
View file @
c8b6338d
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.NumberEval
;
import
org.apache.poi.ss.formula.eval.StringEval
;
import
org.apache.poi.ss.formula.eval.ValueEval
;
import
org.apache.poi.ss.formula.functions.FreeRefFunction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
pwc.taxtech.atms.common.datasource.ShardingContextHolder
;
import
pwc.taxtech.atms.common.util.MyAsserts
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.dto.vatdto.BBParasBo
;
import
pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto
;
import
pwc.taxtech.atms.dto.vatdto.CloseableFormulaDataSource
;
import
pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo
;
import
pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto
;
import
pwc.taxtech.atms.exception.Exceptions
;
import
pwc.taxtech.atms.vat.entity.CellData
;
import
pwc.taxtech.atms.vat.entity.Report
;
import
java.math.BigDecimal
;
public
class
BB
extends
FunctionBase
implements
FreeRefFunction
{
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
BB
.
class
);
final
static
ValueEval
defaultEval
=
new
StringEval
(
"0"
);
final
static
BigDecimal
defaultBigDecimal
=
new
BigDecimal
(
"0"
);
public
BB
(
FormulaContext
context
)
{
super
(
context
);
}
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
try
{
return
wrapExceptionEval
(
args
,
ec
);
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"un expect exception"
,
e
);
e
.
printStackTrace
();
return
defaultEval
;
}
}
public
ValueEval
wrapExceptionEval
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
throws
Exception
{
return
new
NumberEval
(
bb
(
new
BBParasBo
(
args
,
ec
)).
doubleValue
());
}
public
BigDecimal
bb
(
BBParasBo
bo
)
throws
Exception
{
try
(
CloseableFormulaDataSource
closeDataSource
=
new
CloseableFormulaDataSource
(
formulaContext
.
getFormulaAgent
()))
{
CurrentPeriodBo
curPeriod
=
CurrentPeriodBo
.
getPeriod
(
bo
.
getPeriod
().
intValue
(),
formulaContext
.
getPeriod
());
curPeriod
.
fixedCurYear
(
getYear
(
curPeriod
.
getCurYear
()));
ReportCellDataSourceDto
nullCellDto
=
ReportCellDataSourceDto
.
nullDataSource
(
bo
,
curPeriod
);
closeDataSource
.
addDS
(
nullCellDto
);
CellTemplatePerGroupDto
cellTemplateData
=
agent
.
getCellTemplateGroupDto
(
formulaContext
.
getReportTemplateGroupID
(),
formulaContext
.
getProjectID
()).
stream
().
filter
(
dto
->
dto
.
getRowIndex
()
==
bo
.
getColumnIndex
()
-
1
&&
dto
.
getColumnIndex
()
==
bo
.
getColumnIndex
()
-
1
).
findFirst
().
get
();
MyAsserts
.
assertNotNull
(
cellTemplateData
,
Exceptions
.
BB_CELL_TEMP_NULL
);
nullCellDto
.
fixedWithGroup
(
cellTemplateData
);
// todo: fix datasource name by templateList(neo)
if
(
curPeriod
.
getCurPeriod
()
==
-
99
)
{
closeDataSource
.
clean
();
BigDecimal
returnEval
=
defaultBigDecimal
;
if
(
formulaContext
.
getPeriod
()
<=
1
)
{
return
defaultBigDecimal
;
}
for
(
int
p
=
1
;
p
<
formulaContext
.
getPeriod
();
p
++)
{
returnEval
=
returnEval
.
add
(
bb
(
new
BBParasBo
(
bo
,
p
,
curPeriod
.
getCurYear
())));
}
return
returnEval
;
}
bo
.
disCount
();
String
dbName
=
SpringContextUtil
.
formulaAdminMapper
.
getPastProjectDbName
(
curPeriod
.
getCurYear
(),
formulaContext
.
getOrganizationID
());
String
currentProjectDb
=
ShardingContextHolder
.
getDataSourceKey
();
ShardingContextHolder
.
setDataSourceKey
(
dbName
);
try
{
Report
report
=
agent
.
getReportByTemplate
(
cellTemplateData
.
getReportTemplateID
(),
curPeriod
.
getCurPeriod
());
MyAsserts
.
assertNotNull
(
report
,
Exceptions
.
BB_REPORT_NULL
);
CellData
cellData
=
agent
.
getCellDataListByTemplate
(
cellTemplateData
.
getCellTemplateID
(),
report
.
getId
());
MyAsserts
.
assertNotNull
(
cellData
,
Exceptions
.
BB_CELL_DATA_NULL
);
nullCellDto
=
ReportCellDataSourceDto
.
extractFromGroup
(
bo
,
curPeriod
,
cellData
,
cellTemplateData
);
closeDataSource
.
clean
();
closeDataSource
.
addDS
(
nullCellDto
);
// todo: fix datasource name by templateList(neo)
MyAsserts
.
assertNotNull
(
cellData
.
getData
(),
Exceptions
.
BB_CELL_DATA_NULL
);
// cellValue= RoundValue(cellValue, cellDataType)TODO:maybe fixd round by cellDataTyep(KV neo)
BigDecimal
cellValue
=
new
BigDecimal
(
cellData
.
getData
()).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_DOWN
);
nullCellDto
.
setAmount
(
cellValue
);
LOGGER
.
debug
(
"cell static value "
);
ShardingContextHolder
.
setDataSourceKey
(
currentProjectDb
);
return
cellValue
;
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"un support exception"
,
e
);
ShardingContextHolder
.
setDataSourceKey
(
currentProjectDb
);
throw
e
;
}
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/FunctionBase.java
View file @
c8b6338d
...
...
@@ -6,14 +6,17 @@ import org.apache.poi.ss.formula.eval.OperandResolver;
import
org.apache.poi.ss.formula.eval.ValueEval
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
pwc.taxtech.atms.vat.service.impl.FormulaAgent
;
public
class
FunctionBase
{
protected
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
protected
FormulaContext
formulaContext
;
final
FormulaAgent
agent
;
public
FunctionBase
(
FormulaContext
formulaContext
){
this
.
formulaContext
=
formulaContext
;
this
.
agent
=
formulaContext
.
getFormulaAgent
();
}
public
String
getStringParam
(
ValueEval
valueEval
,
OperationEvaluationContext
ec
)
{
...
...
@@ -44,4 +47,15 @@ public class FunctionBase {
return
FormulaHelper
.
getCellTemplateIDWithTemplateCodeAndColumnIndexAndRowIndex
(
ec
.
getWorkbook
().
getSheetName
(
ec
.
getSheetIndex
()),
ec
.
getColumnIndex
(),
ec
.
getRowIndex
(),
period
,
formulaContext
);
}
public
int
getYear
(
int
parameterYear
)
{
if
(
parameterYear
<=
-
1
)
{
return
parameterYear
+
formulaContext
.
getYear
();
}
else
if
(
parameterYear
==
0
)
{
return
formulaContext
.
getYear
();
}
else
{
return
parameterYear
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment