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
c1b08986
Commit
c1b08986
authored
Jul 03, 2018
by
frank.xa.zhang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev_frank
parents
7f336aed
269b7466
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
465 additions
and
0 deletions
+465
-0
DataSourceDto.java
.../main/java/pwc/taxtech/atms/dto/vatdto/DataSourceDto.java
+188
-0
FormulaDataSourceDto.java
...ava/pwc/taxtech/atms/dto/vatdto/FormulaDataSourceDto.java
+6
-0
ReportFormulaFactory.java
...a/pwc/taxtech/atms/service/impl/ReportFormulaFactory.java
+61
-0
FormulaContext.java
.../src/main/java/pwc/taxtech/atms/utils/FormulaContext.java
+171
-0
FormulaResult.java
...i/src/main/java/pwc/taxtech/atms/utils/FormulaResult.java
+39
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/DataSourceDto.java
0 → 100644
View file @
c1b08986
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
public
class
DataSourceDto
{
private
static
String
_DataSourcePrefix
=
"DS["
;
private
static
String
_DataSourceSuffix
=
"]"
;
public
DataSourceDto
()
{
this
.
internalCode
=
_DataSourcePrefix
+
new
Object
().
hashCode
()
+
_DataSourceSuffix
;
}
private
String
id
;
private
String
internalCode
;
private
String
name
;
// 1: Formula, 2: Voucher, 3: OutputInvoice, 4: InputInvoice, 5: CustomInvoice, 6: KeyIn, 7: RelatedModel, 8: SapDaily
private
Integer
dataSourceType
;
private
BigDecimal
amount
;
private
String
description
;
// 1: +, 2: -, 3: *, 4: /
private
Integer
operationType
;
// 1: Number, 2: Percentage, 3: Boolean, 4: String
private
Integer
resultType
;
private
Integer
type
;
private
String
keyValueDataID
;
private
String
creator
;
private
Date
createTime
;
private
String
updater
;
private
Date
updateTime
;
private
String
cellDataID
;
private
List
<
String
>
items
;
private
String
projectID
;
private
String
serviceTypeID
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getInternalCode
()
{
return
internalCode
;
}
public
void
setInternalCode
(
String
internalCode
)
{
this
.
internalCode
=
internalCode
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Integer
getDataSourceType
()
{
return
dataSourceType
;
}
public
void
setDataSourceType
(
Integer
dataSourceType
)
{
this
.
dataSourceType
=
dataSourceType
;
}
public
BigDecimal
getAmount
()
{
return
amount
;
}
public
void
setAmount
(
BigDecimal
amount
)
{
this
.
amount
=
amount
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Integer
getOperationType
()
{
return
operationType
;
}
public
void
setOperationType
(
Integer
operationType
)
{
this
.
operationType
=
operationType
;
}
public
Integer
getResultType
()
{
return
resultType
;
}
public
void
setResultType
(
Integer
resultType
)
{
this
.
resultType
=
resultType
;
}
public
Integer
getType
()
{
return
type
;
}
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
public
String
getKeyValueDataID
()
{
return
keyValueDataID
;
}
public
void
setKeyValueDataID
(
String
keyValueDataID
)
{
this
.
keyValueDataID
=
keyValueDataID
;
}
public
String
getCreator
()
{
return
creator
;
}
public
void
setCreator
(
String
creator
)
{
this
.
creator
=
creator
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getUpdater
()
{
return
updater
;
}
public
void
setUpdater
(
String
updater
)
{
this
.
updater
=
updater
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
String
getCellDataID
()
{
return
cellDataID
;
}
public
void
setCellDataID
(
String
cellDataID
)
{
this
.
cellDataID
=
cellDataID
;
}
public
List
<
String
>
getItems
()
{
return
items
;
}
public
void
setItems
(
List
<
String
>
items
)
{
this
.
items
=
items
;
}
public
String
getProjectID
()
{
return
projectID
;
}
public
void
setProjectID
(
String
projectID
)
{
this
.
projectID
=
projectID
;
}
public
String
getServiceTypeID
()
{
return
serviceTypeID
;
}
public
void
setServiceTypeID
(
String
serviceTypeID
)
{
this
.
serviceTypeID
=
serviceTypeID
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/FormulaDataSourceDto.java
0 → 100644
View file @
c1b08986
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
public
class
FormulaDataSourceDto
extends
DataSourceDto
{
private
Integer
type
;
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/ReportFormulaFactory.java
0 → 100644
View file @
c1b08986
package
pwc
.
taxtech
.
atms
.
service
.
impl
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.EvaluationException
;
import
org.apache.poi.ss.formula.eval.OperandResolver
;
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.utils.FormulaContext
;
public
class
ReportFormulaFactory
{
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ReportFormulaFactory
.
class
);
public
static
abstract
class
ReportBaseFormula
implements
FreeRefFunction
{
final
FormulaContext
context
;
protected
ReportBaseFormula
(
FormulaContext
context
)
{
this
.
context
=
context
;
}
static
String
resolverString
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
,
int
index
)
throws
EvaluationException
{
return
OperandResolver
.
coerceValueToString
(
OperandResolver
.
getSingleValue
(
args
[
index
],
ec
.
getRowIndex
(),
ec
.
getColumnIndex
()));
}
static
Integer
resolverInteger
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
,
int
index
)
throws
EvaluationException
{
return
OperandResolver
.
coerceValueToInt
(
OperandResolver
.
getSingleValue
(
args
[
index
],
ec
.
getRowIndex
(),
ec
.
getColumnIndex
()));
}
static
Double
resolverDouble
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
,
int
index
)
throws
EvaluationException
{
return
OperandResolver
.
coerceValueToDouble
(
OperandResolver
.
getSingleValue
(
args
[
index
],
ec
.
getRowIndex
(),
ec
.
getColumnIndex
()));
}
}
public
static
class
BB
extends
ReportBaseFormula
{
protected
BB
(
FormulaContext
context
)
{
super
(
context
);
}
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
try
{
String
v1
=
OperandResolver
.
coerceValueToString
(
OperandResolver
.
getSingleValue
(
args
[
0
],
ec
.
getRowIndex
(),
ec
.
getColumnIndex
()));
}
catch
(
EvaluationException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
}
atms-api/src/main/java/pwc/taxtech/atms/utils/FormulaContext.java
0 → 100644
View file @
c1b08986
package
pwc
.
taxtech
.
atms
.
utils
;
import
java.util.Map
;
public
class
FormulaContext
{
private
String
projectID
;
private
String
reportTemplateGroupID
;
private
String
reportID
;
private
String
organizationID
;
private
Integer
period
;
private
Integer
year
;
private
Boolean
isYear
;
private
String
indexResultId
;
private
Integer
yearBeginPeriod
;
private
Integer
yearEndPeriod
;
private
Boolean
ifRound
;
private
Boolean
isValidation
;
private
Boolean
isDetailed
;
private
Boolean
isIndexAnalysis
;
private
Boolean
cacheHasIndexCode
;
// <summary>
// 如果BB公式在cache中取上期失败,是否去上期取
// </summary>
private
Boolean
ifCalcStackValue
;
// <summary>
// 如果为99,则实时计算;如果为-1,则不用于判断是否实时计算;其他情况会在对应时机计算并保存
// </summary>
private
Integer
calculateStatus
;
private
Map
<
String
,
FormulaResult
>
replaceSpecialCellFormulaDic
;
public
String
getProjectID
()
{
return
projectID
;
}
public
void
setProjectID
(
String
projectID
)
{
this
.
projectID
=
projectID
;
}
public
String
getReportTemplateGroupID
()
{
return
reportTemplateGroupID
;
}
public
void
setReportTemplateGroupID
(
String
reportTemplateGroupID
)
{
this
.
reportTemplateGroupID
=
reportTemplateGroupID
;
}
public
String
getReportID
()
{
return
reportID
;
}
public
void
setReportID
(
String
reportID
)
{
this
.
reportID
=
reportID
;
}
public
String
getOrganizationID
()
{
return
organizationID
;
}
public
void
setOrganizationID
(
String
organizationID
)
{
this
.
organizationID
=
organizationID
;
}
public
Integer
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
Integer
period
)
{
this
.
period
=
period
;
}
public
Integer
getYear
()
{
return
year
;
}
public
void
setYear
(
Boolean
year
)
{
isYear
=
year
;
}
public
String
getIndexResultId
()
{
return
indexResultId
;
}
public
void
setIndexResultId
(
String
indexResultId
)
{
this
.
indexResultId
=
indexResultId
;
}
public
Integer
getYearBeginPeriod
()
{
return
yearBeginPeriod
;
}
public
void
setYearBeginPeriod
(
Integer
yearBeginPeriod
)
{
this
.
yearBeginPeriod
=
yearBeginPeriod
;
}
public
Integer
getYearEndPeriod
()
{
return
yearEndPeriod
;
}
public
void
setYearEndPeriod
(
Integer
yearEndPeriod
)
{
this
.
yearEndPeriod
=
yearEndPeriod
;
}
public
Boolean
getIfRound
()
{
return
ifRound
;
}
public
void
setIfRound
(
Boolean
ifRound
)
{
this
.
ifRound
=
ifRound
;
}
public
Boolean
getValidation
()
{
return
isValidation
;
}
public
void
setValidation
(
Boolean
validation
)
{
isValidation
=
validation
;
}
public
Boolean
getDetailed
()
{
return
isDetailed
;
}
public
void
setDetailed
(
Boolean
detailed
)
{
isDetailed
=
detailed
;
}
public
Boolean
getIndexAnalysis
()
{
return
isIndexAnalysis
;
}
public
void
setIndexAnalysis
(
Boolean
indexAnalysis
)
{
isIndexAnalysis
=
indexAnalysis
;
}
public
Boolean
getCacheHasIndexCode
()
{
return
cacheHasIndexCode
;
}
public
void
setCacheHasIndexCode
(
Boolean
cacheHasIndexCode
)
{
this
.
cacheHasIndexCode
=
cacheHasIndexCode
;
}
public
Boolean
getIfCalcStackValue
()
{
return
ifCalcStackValue
;
}
public
void
setIfCalcStackValue
(
Boolean
ifCalcStackValue
)
{
this
.
ifCalcStackValue
=
ifCalcStackValue
;
}
public
Integer
getCalculateStatus
()
{
return
calculateStatus
;
}
public
void
setCalculateStatus
(
Integer
calculateStatus
)
{
this
.
calculateStatus
=
calculateStatus
;
}
public
Map
<
String
,
FormulaResult
>
getReplaceSpecialCellFormulaDic
()
{
return
replaceSpecialCellFormulaDic
;
}
public
void
setReplaceSpecialCellFormulaDic
(
Map
<
String
,
FormulaResult
>
replaceSpecialCellFormulaDic
)
{
this
.
replaceSpecialCellFormulaDic
=
replaceSpecialCellFormulaDic
;
}
public
void
setYear
(
Integer
year
)
{
this
.
year
=
year
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/utils/FormulaResult.java
0 → 100644
View file @
c1b08986
package
pwc
.
taxtech
.
atms
.
utils
;
import
pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
FormulaResult
{
private
static
final
List
<
FormulaDataSourceDto
>
emptyDataSourceList
=
new
ArrayList
<>();
private
Boolean
isNullCalculated
;
// If the calculation is canceled. May be used while report generation
private
Boolean
isCanceled
;
private
Object
data
;
private
String
exp
;
private
String
description
;
// 是否需要四舍五入
private
Boolean
ifRound
;
// 1: Number, 2: Percentage, 3: Boolean, 4: String, 5: Integer
// If null, means we do not know the type exactly.
// public KeyValueConfigResultType? ResultType ;
// private EnumOperationType operationType ;
private
Boolean
isValidation
;
private
List
<
FormulaDataSourceDto
>
dataSourceList
;
public
FormulaResult
(
Object
data
)
{
this
.
data
=
data
;
}
}
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